|
@@ -3,15 +3,17 @@ package cn.cslg.pas.service.importPatent;
|
|
|
import cn.cslg.pas.common.core.IgnoreDTDEntityResolver;
|
|
|
import cn.cslg.pas.common.dto.UploadPatentWebDTO;
|
|
|
import cn.cslg.pas.common.dto.es.EsCustomFieldDTO;
|
|
|
-import cn.cslg.pas.common.utils.DateUtils;
|
|
|
-import cn.cslg.pas.common.utils.DateUtils2;
|
|
|
+import cn.cslg.pas.common.utils.*;
|
|
|
+import cn.cslg.pas.common.utils.ClaimUtils.ClaimSplitUtils;
|
|
|
import cn.cslg.pas.common.utils.esDataForm.AddressSplitter;
|
|
|
import cn.cslg.pas.common.utils.esDataForm.PatentClassifySplitter;
|
|
|
-import cn.cslg.pas.common.vo.ImportTaskAMVO;
|
|
|
-import cn.cslg.pas.common.vo.StarPatentVO;
|
|
|
-import cn.cslg.pas.common.vo.UploadParamsVO;
|
|
|
+import cn.cslg.pas.common.vo.*;
|
|
|
import cn.cslg.pas.domain.es.*;
|
|
|
+import cn.cslg.pas.exception.ExceptionEnum;
|
|
|
+import cn.cslg.pas.exception.XiaoShiException;
|
|
|
import cn.cslg.pas.service.business.CustomFieldService;
|
|
|
+import cn.cslg.pas.service.common.FileManagerService;
|
|
|
+import cn.cslg.pas.service.common.PatentStarApiService;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
import org.apache.xml.utils.QName;
|
|
@@ -21,6 +23,8 @@ import org.dom4j.XPath;
|
|
|
import org.dom4j.io.SAXReader;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
+import java.io.File;
|
|
|
+import java.io.IOException;
|
|
|
import java.io.Reader;
|
|
|
import java.io.StringReader;
|
|
|
import java.util.ArrayList;
|
|
@@ -35,6 +39,8 @@ import java.util.stream.Collectors;
|
|
|
@RequiredArgsConstructor
|
|
|
public class WebVOTransformService {
|
|
|
private final CustomFieldService customFieldService;
|
|
|
+ private final PatentStarApiService patentStarApiService;
|
|
|
+ private final FileManagerService fileManagerService;
|
|
|
private static List<String> SCHOOL = new ArrayList<String>() {{
|
|
|
add("大学");
|
|
|
add("学院");
|
|
@@ -55,21 +61,14 @@ public class WebVOTransformService {
|
|
|
}};
|
|
|
|
|
|
//装载中国专利
|
|
|
- public void loadCNPatent(String chinaPatentZhuLuStr, Patent patent, StarPatentVO starPatentVO) {
|
|
|
+ public void loadCNPatent(String chinaPatentZhuLuStr, UploadPatentWebDTO uploadPatentWebDTO) {
|
|
|
+ this.loadPatent(uploadPatentWebDTO, true);
|
|
|
+ Patent patent = uploadPatentWebDTO.getPatent();
|
|
|
patent.setPatentNo(patent.getAppNo());
|
|
|
if (chinaPatentZhuLuStr != null && !chinaPatentZhuLuStr.trim().equals("") && !chinaPatentZhuLuStr.equals("{}") && !chinaPatentZhuLuStr.contains("请求不合法")) {
|
|
|
List<StarPatentVO> chinaPatentZhuLus = JSON.parseArray(chinaPatentZhuLuStr, StarPatentVO.class);
|
|
|
StarPatentVO chinaPatentZhuLu = chinaPatentZhuLus.get(0);
|
|
|
|
|
|
- //装载 申请人地址
|
|
|
- this.loadApplicantAddr(patent, chinaPatentZhuLu.getDZ(), starPatentVO.getCO());
|
|
|
-
|
|
|
- //装载代理人
|
|
|
- this.loadAgent(patent, chinaPatentZhuLu.getAT());
|
|
|
-
|
|
|
- //装载发明人
|
|
|
- this.loadInventor(patent, chinaPatentZhuLu.getIV());
|
|
|
-
|
|
|
//装载优先权号、优先权国家、优先权日
|
|
|
this.loadPriorities(patent, chinaPatentZhuLu.getPR());
|
|
|
|
|
@@ -79,7 +78,7 @@ public class WebVOTransformService {
|
|
|
|
|
|
|
|
|
//装载专利信息
|
|
|
- public void loadPatent(UploadPatentWebDTO uploadPatentWebDTO) {
|
|
|
+ public void loadPatent(UploadPatentWebDTO uploadPatentWebDTO, Boolean ifCn) {
|
|
|
String country = "";
|
|
|
Patent patent = uploadPatentWebDTO.getPatent();
|
|
|
StarPatentVO starPatentVO = uploadPatentWebDTO.getStarPatentVO();
|
|
@@ -93,16 +92,11 @@ public class WebVOTransformService {
|
|
|
//装载公开号
|
|
|
this.loadPublicNo(patent, starPatentVO.getPN(), starPatentVO.getGN());
|
|
|
|
|
|
-
|
|
|
- this.loadCountry(patent, true);
|
|
|
-
|
|
|
+ this.loadCountry(patent, ifCn);
|
|
|
|
|
|
//装载申请人地址
|
|
|
this.loadApplicantAddr(patent, starPatentVO.getDZ(), starPatentVO.getCO());
|
|
|
|
|
|
- //装载IPC分类号
|
|
|
- this.loadPatentIPC(patent, starPatentVO.getMC(), starPatentVO.getIC());
|
|
|
-
|
|
|
|
|
|
//装载摘要
|
|
|
this.loadAbstractStr(patent, starPatentVO.getAB());
|
|
@@ -125,7 +119,12 @@ public class WebVOTransformService {
|
|
|
//装载代理机构
|
|
|
this.loadAgency(patent, starPatentVO.getAGN());
|
|
|
|
|
|
-
|
|
|
+ //装载IPC分类号
|
|
|
+ if (patent.getPatentType().equals("3")) {
|
|
|
+ this.loadPatentLoc(patent, starPatentVO.getMC(), starPatentVO.getIC());
|
|
|
+ } else {
|
|
|
+ this.loadPatentIPC(patent, starPatentVO.getMC(), starPatentVO.getIC());
|
|
|
+ }
|
|
|
//装载公告日
|
|
|
this.loadGrantDate(patent, starPatentVO.getPD(), starPatentVO.getGD());
|
|
|
//装载公开日
|
|
@@ -144,28 +143,18 @@ public class WebVOTransformService {
|
|
|
|
|
|
|
|
|
// 装载世界专利
|
|
|
- public void loadWorldPatent(String worldPatentZhuLuStr, Patent patent) {
|
|
|
+ public void loadWorldPatent(String worldPatentZhuLuStr, UploadPatentWebDTO uploadPatentWebDTO) {
|
|
|
List<StarPatentVO> worldPatentZhuLus = JSON.parseArray(worldPatentZhuLuStr, StarPatentVO.class);
|
|
|
StarPatentVO worldPatentZhuLu = worldPatentZhuLus.get(0);
|
|
|
- //装载申请号
|
|
|
- this.loadApplicationNo(patent, worldPatentZhuLu.getEpoAppNo());
|
|
|
-
|
|
|
- //装载公开号
|
|
|
- this.loadPublicNo(patent, worldPatentZhuLu.getDocdbPubNo(), null);
|
|
|
+ Patent patent = uploadPatentWebDTO.getPatent();
|
|
|
|
|
|
- this.loadCountry(patent, false);
|
|
|
+ this.loadPatent(uploadPatentWebDTO, false);
|
|
|
//装载申请日
|
|
|
this.loadAppDate(patent, worldPatentZhuLu.getAppDate());
|
|
|
|
|
|
//装载公开日
|
|
|
this.loadPublicDate(patent, worldPatentZhuLu.getPubDate(), null);
|
|
|
|
|
|
- //装载IPC分类号
|
|
|
- if (patent.getPatentType().equals(3)) {
|
|
|
- this.loadPatentLoc(patent, worldPatentZhuLu.getMC(), worldPatentZhuLu.getIpc());
|
|
|
- } else {
|
|
|
- this.loadPatentIPC(patent, worldPatentZhuLu.getMC(), worldPatentZhuLu.getIpc());
|
|
|
- }
|
|
|
//装载CPC分类号
|
|
|
this.loadPatentCPC(patent, worldPatentZhuLu.getCpc());
|
|
|
|
|
@@ -366,6 +355,12 @@ public class WebVOTransformService {
|
|
|
patent.setLoc(Arrays.asList(patentClassify));
|
|
|
}
|
|
|
}
|
|
|
+ PatentClassify patentClassify = new PatentClassify();
|
|
|
+ patentClassify.setLevel1("");
|
|
|
+ patentClassify.setLevel2("");
|
|
|
+ patentClassify.setLevel3("");
|
|
|
+ patent.setMipc(patentClassify);
|
|
|
+ patent.setIpc(new ArrayList<>());
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -757,7 +752,11 @@ public class WebVOTransformService {
|
|
|
text.setIfOrigin(true);
|
|
|
|
|
|
patent.setClaim(Arrays.asList(text));
|
|
|
-
|
|
|
+ PatentRightParams params = new PatentRightParams();
|
|
|
+ params.setContent(reClaim);
|
|
|
+ params.setPatentNo(patent.getPatentNo());
|
|
|
+ List<RePatentClaim> rePatentClaims = ClaimSplitUtils.formatPatentRight(params);
|
|
|
+ System.out.println(rePatentClaims);
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
@@ -854,5 +853,52 @@ public class WebVOTransformService {
|
|
|
return esCustomFieldDTOList;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 获取附图
|
|
|
+ *
|
|
|
+ * @param appNo
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public List<String> getExternalFigure(String appNo) throws IOException {
|
|
|
+ List<String> list = new ArrayList<>();
|
|
|
+ String wgPictureApi = patentStarApiService.getWGPictureApi(appNo);
|
|
|
+ if (StringUtils.isNotEmpty(wgPictureApi)) {
|
|
|
+ if (wgPictureApi.contains("|http")) {
|
|
|
+ String[] urlArr = wgPictureApi.split("\\|");
|
|
|
+ list.addAll(Arrays.asList(urlArr));
|
|
|
+ } else {
|
|
|
+ list.add(wgPictureApi);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return list;
|
|
|
+ }
|
|
|
+
|
|
|
+ public void getCNPatentPicture(UploadPatentWebDTO uploadPatentWebDTO) {
|
|
|
+ try {
|
|
|
+ Long startMillis = System.currentTimeMillis();
|
|
|
+ List<String> pictureUrls = patentStarApiService.getExternalFigure(uploadPatentWebDTO.getStarPatentVO().getANO());
|
|
|
+ Long endMillis = System.currentTimeMillis();
|
|
|
+
|
|
|
+ System.out.println("获取图片时间" + (endMillis - startMillis));
|
|
|
+ Patent patent = uploadPatentWebDTO.getPatent();
|
|
|
+ if (pictureUrls != null && pictureUrls.size() > 0) {
|
|
|
+ for (int i = 0; i < pictureUrls.size(); i++) {
|
|
|
+ String pictureUrl = pictureUrls.get(i);
|
|
|
+ Long s4 = System.currentTimeMillis();
|
|
|
+ File file = FileUtils.getPictureFileByUrl(pictureUrl);
|
|
|
+ Long e4 = System.currentTimeMillis();
|
|
|
+ System.out.println("下载文件耗时" + (e4 - s4));
|
|
|
+ String guid = FormatUtil.getPictureFormat(patent.getAppNo()) + (i + 1);
|
|
|
+ fileManagerService.uploadFileWithGuid(file, guid);
|
|
|
+ file.delete();
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, "添加附图错误");
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
}
|