|
@@ -23,7 +23,6 @@ import cn.cslg.pas.service.WebLoginConfigService;
|
|
|
import cn.cslg.pas.service.importPatent.WebVOTransformService;
|
|
|
import cn.cslg.pas.service.novelty.AssoRetrieveRecordProjectService;
|
|
|
import cn.cslg.pas.service.query.FormatQueryService;
|
|
|
-import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.sun.istack.NotNull;
|
|
@@ -32,7 +31,6 @@ import lombok.experimental.Accessors;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import okhttp3.*;
|
|
|
import okhttp3.Response;
|
|
|
-import org.apache.commons.lang3.ObjectUtils;
|
|
|
import org.dom4j.Document;
|
|
|
import org.dom4j.DocumentException;
|
|
|
import org.dom4j.Element;
|
|
@@ -47,7 +45,6 @@ import org.springframework.context.ApplicationContext;
|
|
|
import org.springframework.context.annotation.Lazy;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
-import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
import java.io.File;
|
|
|
import java.io.IOException;
|
|
@@ -89,8 +86,6 @@ public class PatentStarApiService {
|
|
|
private AssoRetrieveRecordProjectService assoRetrieveRecordProjectService;
|
|
|
@Autowired
|
|
|
private NOSCacheService cacheService;
|
|
|
- @Autowired
|
|
|
- private FileManagerService fileManagerService;
|
|
|
|
|
|
public Records patentStarSearchLocal(PatentStarListDTO patentStarListDTO) throws IOException {
|
|
|
RetrieveRecord retrieveRecord = retrieveRecordService.setRetrieveRecord(patentStarListDTO);
|
|
@@ -128,7 +123,7 @@ public class PatentStarApiService {
|
|
|
assoRetrieveRecordProjectService.add(retrieveRecord.getId(), projectId);
|
|
|
}
|
|
|
} else {
|
|
|
- retrieveRecord =retrieveRecordService.getById(patentStarListDTO.getRetrieveRecordId());
|
|
|
+ retrieveRecord = retrieveRecordService.getById(patentStarListDTO.getRetrieveRecordId());
|
|
|
retrieveRecord.setRetrieveTime(new Date());
|
|
|
retrieveRecord.updateById();
|
|
|
}
|
|
@@ -156,6 +151,7 @@ public class PatentStarApiService {
|
|
|
|
|
|
/**
|
|
|
* 格式化条件后并请求外部接口
|
|
|
+ *
|
|
|
* @param PatentStarListDTO
|
|
|
* @return
|
|
|
* @throws IOException
|
|
@@ -194,9 +190,9 @@ public class PatentStarApiService {
|
|
|
String signMd5 = FormatUtil.MD5(Sign);
|
|
|
// 创建一个OkHttpClient对象
|
|
|
OkHttpClient okHttpClient = new OkHttpClient.Builder()
|
|
|
- .connectTimeout(300, TimeUnit.SECONDS)
|
|
|
- .writeTimeout(300, TimeUnit.SECONDS)
|
|
|
- .readTimeout(300, TimeUnit.SECONDS)
|
|
|
+ .connectTimeout(5, TimeUnit.SECONDS)
|
|
|
+ .writeTimeout(5, TimeUnit.SECONDS)
|
|
|
+ .readTimeout(5, TimeUnit.SECONDS)
|
|
|
.addInterceptor(new PatentStarApiService.OkhttpInterceptor(3))
|
|
|
.build();
|
|
|
|
|
@@ -252,7 +248,7 @@ public class PatentStarApiService {
|
|
|
for (PatentColumnDTO columnDTO : columnDTOS) {
|
|
|
if (containsNumber(columnDTO, formattedNo)) {
|
|
|
PatentColumnDTO dto = new PatentColumnDTO();
|
|
|
- BeanUtils.copyProperties(columnDTO,dto);
|
|
|
+ BeanUtils.copyProperties(columnDTO, dto);
|
|
|
dto.setSearchNo(patentNo);
|
|
|
result.add(dto);
|
|
|
searchedNumbers.add(patentNo); // 标记为已搜索
|
|
@@ -375,6 +371,7 @@ public class PatentStarApiService {
|
|
|
* 从专利之星获取中国专利著录
|
|
|
*/
|
|
|
public String getCnBibApi(String appNo) {
|
|
|
+ Long start = System.currentTimeMillis();
|
|
|
String url = "https://api.patentstar.com.cn/api/Patent/CnBibo/" + appNo;
|
|
|
JSONObject configObject = this.getConfigObject(4, 2);
|
|
|
String appId = configObject.getString("appId");
|
|
@@ -399,6 +396,8 @@ public class PatentStarApiService {
|
|
|
// 发送请求获取响应
|
|
|
try {
|
|
|
Response response = okHttpClient.newCall(request).execute();
|
|
|
+ Long end = System.currentTimeMillis();
|
|
|
+ System.out.println("get zhulu cost" + (end - start));
|
|
|
// 判断请求是否成功
|
|
|
if (response.isSuccessful()) {
|
|
|
// 打印服务端返回结果
|
|
@@ -453,7 +452,7 @@ public class PatentStarApiService {
|
|
|
e.printStackTrace();
|
|
|
return null;
|
|
|
}
|
|
|
- return "{}";
|
|
|
+ return null;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -463,7 +462,7 @@ public class PatentStarApiService {
|
|
|
* @author 李仁杰
|
|
|
* 从专利之星获取中国专利外观图
|
|
|
*/
|
|
|
- public String getWGPictureApi(String appNo) throws IOException {
|
|
|
+ public String getWGPictureApi(String appNo) {
|
|
|
String url = "https://api.patentstar.com.cn/api/Patent/CnWGImage/" + appNo;
|
|
|
JSONObject configObject = this.getConfigObject(4, 2);
|
|
|
String appId = configObject.getString("appId");
|
|
@@ -497,7 +496,7 @@ public class PatentStarApiService {
|
|
|
} catch (IOException e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
- return "{}";
|
|
|
+ return null;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -539,7 +538,7 @@ public class PatentStarApiService {
|
|
|
} catch (IOException e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
- return "{}";
|
|
|
+ return null;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -789,7 +788,7 @@ public class PatentStarApiService {
|
|
|
* 从专利之星获取同族专利
|
|
|
*/
|
|
|
public String getFamilyByPubNoApi(String patentNo) {
|
|
|
- patentNo = "CN217038881U";
|
|
|
+ Long start = System.currentTimeMillis();
|
|
|
String url = "https://api.patentstar.com.cn/api/Patent/FamilyByPubNo/" + patentNo;
|
|
|
JSONObject configObject = this.getConfigObject(4, 2);
|
|
|
String appId = configObject.getString("appId");
|
|
@@ -813,6 +812,8 @@ public class PatentStarApiService {
|
|
|
// 发送请求获取响应
|
|
|
try {
|
|
|
Response response = okHttpClient.newCall(request).execute();
|
|
|
+ Long end = System.currentTimeMillis();
|
|
|
+ System.out.println("get family cost" + (end - start));
|
|
|
// 判断请求是否成功
|
|
|
if (response.isSuccessful()) {
|
|
|
// 打印服务端返回结果
|
|
@@ -1146,98 +1147,6 @@ public class PatentStarApiService {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 根据专利号查询外部权利要求
|
|
|
- *
|
|
|
- * @param patentNo
|
|
|
- * @return
|
|
|
- * @throws IOException
|
|
|
- */
|
|
|
- public PatentInfoDTO queryPatentDetailByPatentNo(String patentNo) throws IOException {
|
|
|
- PatentStarListDTO patentStarListDTO = new PatentStarListDTO();
|
|
|
- String condition = "AN=" + patentNo + " OR " + "PN=" + patentNo + " OR " + "GN=" + patentNo;
|
|
|
- patentStarListDTO.setCurrentQuery(condition);
|
|
|
- String index = patentNo.substring(0, 2);
|
|
|
- if (index.equals("CN") || index.equals("ZL")) {
|
|
|
- patentStarListDTO.setDBType("CN");
|
|
|
- } else {
|
|
|
- patentStarListDTO.setDBType("WD");
|
|
|
- }
|
|
|
- patentStarListDTO.setOrderBy("AD");
|
|
|
- patentStarListDTO.setOrderByType("DESC");
|
|
|
- patentStarListDTO.setPageNum(1);
|
|
|
- patentStarListDTO.setRowCount(10);
|
|
|
- Records records = this.patentStarSearchLocal(patentStarListDTO);
|
|
|
- Object data = records.getData();
|
|
|
- String s = JSON.toJSONString(data);
|
|
|
- List<PatentColumnDTO> list = JSON.parseArray(s, PatentColumnDTO.class);
|
|
|
- PatentInfoDTO dto = new PatentInfoDTO();
|
|
|
- if (!CollectionUtils.isEmpty(list)) {
|
|
|
- for (PatentColumnDTO columnDTO : list) {
|
|
|
- BeanUtils.copyProperties(columnDTO, dto);
|
|
|
- }
|
|
|
- }
|
|
|
- if (StringUtils.isNotEmpty(dto.getRowApplicationNo())) {
|
|
|
- String txtGuid = this.getTxtGuid(dto.getRowApplicationNo(), patentNo);
|
|
|
- dto.setTxtGuid(txtGuid);
|
|
|
- }
|
|
|
- List<InnerPatentPdfDTO> pdfList = this.getExternalTextPdf(dto.getAppNo(), dto.getRowApplicationNo(), dto.getPublicNo(), dto.getGrantNo());
|
|
|
- if (!CollectionUtils.isEmpty(pdfList)) {
|
|
|
- List<InnerPatentPdfDTO> pdfDTOS = new ArrayList<>();
|
|
|
- for (InnerPatentPdfDTO innerPatentPdfDTO : pdfList) {
|
|
|
- File file = FileUtils.getFileByUrl(innerPatentPdfDTO.getPdfGuid());
|
|
|
- List<String> guidList = fileManagerService.uploadFileGetGuid2(Collections.singletonList(file));
|
|
|
- if (!CollectionUtils.isEmpty(guidList)) {
|
|
|
- InnerPatentPdfDTO pdfDTO = new InnerPatentPdfDTO();
|
|
|
- pdfDTO.setPdfGuid(guidList.get(0));
|
|
|
- pdfDTO.setType(innerPatentPdfDTO.getType());
|
|
|
- pdfDTOS.add(pdfDTO);
|
|
|
- }
|
|
|
- }
|
|
|
- dto.setPdfDTOS(pdfDTOS);
|
|
|
- }
|
|
|
- return dto;
|
|
|
- }
|
|
|
-
|
|
|
- public String getTxtGuid(String rowApplicationNo,String patentNo) throws IOException {
|
|
|
- StringBuilder builder = new StringBuilder();
|
|
|
- SelectClaimDTO externalClaim = this.queryExternalClaim(rowApplicationNo);
|
|
|
- if (ObjectUtils.isNotEmpty(externalClaim)) {
|
|
|
- List<Text> claimContent = externalClaim.getClaimContent();
|
|
|
- if (!CollectionUtils.isEmpty(claimContent)) {
|
|
|
- Text text = claimContent.stream().filter(i -> i.getIfOrigin().equals(true)).findFirst().orElse(null);
|
|
|
- if (ObjectUtils.isNotEmpty(text)) {
|
|
|
- String claim = text.getTextContent();
|
|
|
- String claimStr = claim.replaceAll("\t", "\n");
|
|
|
- builder.append(" 权利要求");
|
|
|
- builder.append("\n");
|
|
|
- builder.append(claimStr);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- List<Text> fullText = this.getCnFullText(rowApplicationNo);
|
|
|
- if (!CollectionUtils.isEmpty(fullText)) {
|
|
|
- Text text = fullText.stream().filter(i -> i.getIfOrigin().equals(true)).findFirst().orElse(null);
|
|
|
- if (ObjectUtils.isNotEmpty(text)) {
|
|
|
- String specification = text.getTextContent();
|
|
|
- builder.append("\n");
|
|
|
- builder.append("\n");
|
|
|
- builder.append("\n");
|
|
|
- builder.append(" 说明书");
|
|
|
- builder.append("\n");
|
|
|
- builder.append(specification);
|
|
|
- }
|
|
|
- }
|
|
|
- String result = builder.toString();
|
|
|
- byte[] bytes = result.getBytes();
|
|
|
- MultipartFile multipartFile = FileUtils.convertBytesToMultipartFile(bytes, patentNo + "-" + "文本文档.txt");
|
|
|
- List<String> list = fileManagerService.uploadFileGetGuid(Collections.singletonList(multipartFile));
|
|
|
- if (!CollectionUtils.isEmpty(list)) {
|
|
|
- return list.get(0);
|
|
|
- }
|
|
|
- return "";
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
* 查询外部专利同族专利
|
|
|
*
|
|
|
* @param vo
|
|
@@ -1508,7 +1417,7 @@ public class PatentStarApiService {
|
|
|
Request request = chain.request();
|
|
|
Response response = null;
|
|
|
try {
|
|
|
- System.out.println("第" + (retryCent + 1) + "次执行发http请求.");
|
|
|
+ System.out.println("第" + (retryCent + 1) + "次执行发http请求.");
|
|
|
response = chain.proceed(request);
|
|
|
} catch (Exception e) {
|
|
|
if (maxRentry > retryCent) {
|