浏览代码

修复导入商品专利/查询权利要求/权利要求树bug

lwhhszx 1 年之前
父节点
当前提交
5add8b83fc

+ 1 - 0
src/main/java/cn/cslg/pas/common/dto/ImportTaskDTO.java

@@ -85,4 +85,5 @@ public class ImportTaskDTO {
 
     private List<EsCustomFieldDTO> fieldDTOS;
     private List<String> patentNos;
+    private Integer productId;
 }

+ 22 - 3
src/main/java/cn/cslg/pas/common/utils/PatentRightUtils.java

@@ -1,8 +1,6 @@
 package cn.cslg.pas.common.utils;
 
 
-
-
 import cn.cslg.pas.common.vo.PatentRightParams;
 import cn.cslg.pas.common.vo.RePatentClaim;
 import org.springframework.stereotype.Component;
@@ -12,6 +10,7 @@ import java.util.Arrays;
 import java.util.List;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
+import java.util.stream.Collectors;
 
 /**
  * 拆分权要工具类
@@ -25,7 +24,10 @@ public class PatentRightUtils {
     public static List<RePatentClaim> formatPatentRight(PatentRightParams params) {
         try {
             //国家
-            String country = params.getPatentNo().substring(0, 2);
+            String country = params.getCountry();
+            if (country == null) {
+                country = params.getPatentNo().substring(0, 2);
+            }
             //原文
             String content = params.getContent();
             //译文
@@ -322,6 +324,23 @@ public class PatentRightUtils {
             patentRights.add(new RePatentClaim().setPatentNo(params.getPatentNo()).setContent(params.getContent()).setContentOut(params.getContentOut()).setType(1).setSort(0).setParentSort("-1"));
             return patentRights;
         }
+
+
     }
 
+    public static String getFormatClaim(String claim, String country) {
+        String reStr = "";
+        PatentRightParams params = new PatentRightParams();
+        if (country == null) {
+            country = "CN";
+        }
+        params.setContent(claim);
+        params.setCountry(country);
+        List<RePatentClaim> rePatentClaims = PatentRightUtils.formatPatentRight(params);
+        if (rePatentClaims.size() > 0) {
+            List<String> claims = rePatentClaims.stream().map(RePatentClaim::getContent).collect(Collectors.toList());
+            reStr = StringUtils.join(claims, "。\t");
+        }
+        return reStr;
+    }
 }

+ 1 - 0
src/main/java/cn/cslg/pas/common/vo/PatentRightParams.java

@@ -29,4 +29,5 @@ public class PatentRightParams {
      * 独立权要
      */
     private String selfContent;
+    private String country;
 }

+ 2 - 2
src/main/java/cn/cslg/pas/controller/FeatureController.java

@@ -79,10 +79,10 @@ public class FeatureController {
 
     @Operation(summary = "查询权要树")
     @GetMapping("/getPatentRightTree")
-    public Response getPatentRightTree(String patentNo) throws Exception {
+    public Response getPatentRightTree(String patentNo,String appNo) throws Exception {
         try {
             Records records = new Records();
-            records.setData(featureService.getPatentRightTree(patentNo));
+            records.setData(featureService.getPatentRightTree(patentNo,appNo));
             return Response.success(records);
         } catch (Exception e) {
             return Response.error(e.getMessage());

+ 1 - 2
src/main/java/cn/cslg/pas/service/PatentLabelService.java

@@ -39,7 +39,7 @@ public class PatentLabelService {
                 esCustomField.setStatsValue(labels);
                 esCustomField.setFieldValue(labels);
                 patent.setESCustomField(esCustomField);
-                esService.updatePatent(patent, patentWithIdVO.getId());
+                esService.updateByQuery(patent, patentWithIdVO.getId());
                 id = patentWithIdVO.getId();
             } else {
                 ESCustomField esCustomField = new ESCustomField();
@@ -50,7 +50,6 @@ public class PatentLabelService {
                 esCustomField.setFieldValue(labels);
                 esCustomField.setStatsValue(labels);
                 id = esCustomFieldService.addEsCustomFieldToEs(esCustomField, patentNo, null);
-
             }
         } catch (Exception e) {
             throw new XiaoShiException("查询失败");

+ 38 - 2
src/main/java/cn/cslg/pas/service/business/FeatureService.java

@@ -18,6 +18,7 @@ import cn.cslg.pas.exception.XiaoShiException;
 import cn.cslg.pas.mapper.FeatureMapper;
 import cn.cslg.pas.service.business.es.EsService;
 import cn.cslg.pas.service.business.invalidReport.AssoGroupFeatureService;
+import cn.cslg.pas.service.common.PatentStarApiService;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@@ -56,6 +57,8 @@ public class FeatureService extends ServiceImpl<FeatureMapper, Feature> {
     @Lazy
     private AssoGroupFeatureService assoGroupFeatureService;
 
+    @Autowired
+    private PatentStarApiService patentStarApiService;
     @Transactional(rollbackFor = Exception.class)
     public List<PatentRightVo> splitPatentFeature(SplitVO splitVO) throws IOException {
         String patentNo = splitVO.getPatentNo();
@@ -190,6 +193,39 @@ public class FeatureService extends ServiceImpl<FeatureMapper, Feature> {
         return patentRights;
     }
 
+    @Transactional(rollbackFor = Exception.class)
+    public List<RePatentClaim> getRightListByNo(String patentNo,String appNo) throws IOException {
+        //从pas获得拆分后的权要
+        SelectClaimDTO selectClaimDTO = null;
+        String patentRight ="";
+        try {if(appNo!=null) {
+            selectClaimDTO = patentStarApiService.getOrginCalim(appNo);
+            if(selectClaimDTO!=null&&selectClaimDTO.getClaimContent()!=null&&selectClaimDTO.getClaimContent().size()!=0){
+              patentRight=selectClaimDTO.getClaimContent().get(0).getTextContent();
+
+            }
+        }
+        else if(patentNo!=null){
+            selectClaimDTO = esService.selectClaim(patentNo);
+        }
+
+        } catch (Exception e) {
+            throw new XiaoShiException("未查询到权要");
+        }
+        if (selectClaimDTO == null) {
+            throw new XiaoShiException("未查询到权要");
+        }
+
+        PatentRightParams params = new PatentRightParams();
+        params.setContent(patentRight);
+        params.setPatentNo(patentNo);
+        List<RePatentClaim> patentRights = PatentRightUtils.formatPatentRight(params);
+        patentRights.forEach(item -> {
+            item.setRightName("权要" + (item.getSort() + 1));
+        });
+        return patentRights;
+    }
+
     //获得专利拆分信息
     public QuerySplitVO getSplitMessage(QuerySplitDTO splitDTO) {
         QuerySplitVO splitVO = new QuerySplitVO();
@@ -224,9 +260,9 @@ public class FeatureService extends ServiceImpl<FeatureMapper, Feature> {
         }
     }
 
-    public List<PatentRightTree> getPatentRightTree(String patentNo) {
+    public List<PatentRightTree> getPatentRightTree(String patentNo,String appNo) {
         try {
-            List<RePatentClaim> patentRights = this.getRightListByNo(patentNo);
+            List<RePatentClaim> patentRights = this.getRightListByNo(patentNo,appNo);
 
             List<PatentRightTree> treeNodeList = new ArrayList<>();
             //装载权要原文

+ 1 - 0
src/main/java/cn/cslg/pas/service/business/ImportTaskService.java

@@ -163,6 +163,7 @@ public class ImportTaskService extends ServiceImpl<ImportTaskMapper, ImportTask>
         importTaskCondition.setOrderBy(importTaskDTO.getOrderBy());
         importTaskCondition.setOrderByType(importTaskDTO.getOrderByType());
         importTaskCondition.setCreateId(personnelVO.getId());
+
         if (importTaskDTO.getPatentNos() != null && importTaskDTO.getPatentNos().size() > 0) {
             String jsons = JSONObject.toJSON(importTaskDTO.getPatentNos()).toString();
             importTaskCondition.setPatentNos(jsons);

+ 2 - 0
src/main/java/cn/cslg/pas/service/business/es/EsCustomFieldService.java

@@ -867,4 +867,6 @@ public class EsCustomFieldService {
 
         return patentWithIdVOS;
     }
+
+
 }

+ 10 - 2
src/main/java/cn/cslg/pas/service/business/es/EsPatentService.java

@@ -12,6 +12,7 @@ import cn.cslg.pas.common.model.request.QueryRequest;
 import cn.cslg.pas.common.model.request.StringRequest;
 import cn.cslg.pas.common.utils.CacheUtils;
 import cn.cslg.pas.common.utils.FormatUtil;
+import cn.cslg.pas.common.utils.PatentRightUtils;
 import cn.cslg.pas.common.utils.parseQueryToTree.expressManager;
 import cn.cslg.pas.common.utils.parseQueryToTree.operateNode;
 import cn.cslg.pas.common.utils.parseQueryToTree.treeNode;
@@ -23,6 +24,7 @@ import cn.cslg.pas.common.vo.business.PatentKinDetailVO;
 import cn.cslg.pas.common.vo.business.PatentKinVO;
 import cn.cslg.pas.common.vo.business.PatentNoVO;
 import cn.cslg.pas.common.vo.business.SelectProductVO;
+import cn.cslg.pas.domain.business.PatentClaim;
 import cn.cslg.pas.domain.business.Product;
 import cn.cslg.pas.domain.business.ProductCategory;
 import cn.cslg.pas.domain.es.*;
@@ -103,6 +105,13 @@ public class EsPatentService {
         for (Hit<Patent> hit : hits) {
             Patent esMess = hit.source();
             BeanUtils.copyProperties(esMess, dto);
+            //格式化权利要求
+            List<Text> claims =dto.getClaim();
+            if(claims!=null&&claims.size()>0){
+                claims.forEach(item->{
+                    item.setTextContent(PatentRightUtils.getFormatClaim(item.getTextContent(),item.getLanguage()));
+                });
+            }
             dto.setRightHolderAddr(esMess.getRightHolderAddr());
             dto.setApplicantAddr(esMess.getApplicantAddr());
             if (!CollectionUtils.isEmpty(esMess.getApplicant())) {
@@ -611,7 +620,6 @@ public class EsPatentService {
         DeleteResponse deleteResponse = client.delete(deleteRequest ->
                 deleteRequest.index("patent").id(id)
         );
-
-
     }
+
 }

+ 13 - 0
src/main/java/cn/cslg/pas/service/business/es/EsProductPatentService.java

@@ -104,4 +104,17 @@ public class EsProductPatentService {
             throw new XiaoShiException("删除失败");
         }
     }
+
+//添加
+    @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Throwable.class)
+    public String addProductPatent(String patentId, Integer productId) throws Exception {
+        Patent patent = new Patent();
+        PatentJoin patentJoin = new PatentJoin();
+        patentJoin.setParent(patentId);
+        patentJoin.setName("product");
+        patent.setPatentJoin(patentJoin);
+        patent.setProductId(productId);
+      String id=  esService.addChildPatent(patent,patentId);
+        return id;
+    }
 }

+ 40 - 5
src/main/java/cn/cslg/pas/service/common/PatentStarApiService.java

@@ -515,13 +515,13 @@ public class PatentStarApiService {
         List<String> reClaims = new ArrayList<>();
         element.forEach(item -> {
             String claim = item.getText();
-            claim =   claim.replaceAll("\r\n|\r|\n| ", "");
+            claim = claim.replaceAll("\r\n|\r|\n| ", "");
             reClaims.add(claim);
 
         });
         String reClaim = "";
         if (reClaims.size() != 0) {
-            reClaim = cn.cslg.pas.common.utils.StringUtils.join(reClaims, "\r\n");
+            reClaim = cn.cslg.pas.common.utils.StringUtils.join(reClaims, "");
         }
         return reClaim;
     }
@@ -935,8 +935,8 @@ public class PatentStarApiService {
             }
 
             //装载代理机构
-            if (item.getAgencyStr() != null && !item.getAgencyStr() .trim().equals("")) {
-                patentColumnDTO.setAgency(item.getAgencyStr() );
+            if (item.getAgencyStr() != null && !item.getAgencyStr().trim().equals("")) {
+                patentColumnDTO.setAgency(item.getAgencyStr());
             }
 
             patentColumnDTOS.add(patentColumnDTO);
@@ -948,6 +948,7 @@ public class PatentStarApiService {
 
     /**
      * 根据专利号查询外部权利要求
+     *
      * @param appNo
      * @return
      * @throws IOException
@@ -964,6 +965,9 @@ public class PatentStarApiService {
         try {
             String fullText = this.getExternalClaim(cnFullXmlApi);
             Text pubText = new Text();
+            if (fullText != null && !fullText.trim().equals("")) {
+                fullText = PatentRightUtils.getFormatClaim(fullText, "CN");
+            }
             pubText.setTextContent(fullText);
             pubText.setIfOrigin(true);
             claimList.add(pubText);
@@ -979,6 +983,7 @@ public class PatentStarApiService {
 
     /**
      * 根据专利号查询外部权利要求
+     *
      * @param vo
      * @return
      * @throws IOException
@@ -1007,6 +1012,7 @@ public class PatentStarApiService {
 
     /**
      * 查询外部专利同族专利
+     *
      * @param vo
      * @return
      * @throws IOException
@@ -1036,7 +1042,7 @@ public class PatentStarApiService {
         }
         if (StringUtils.isNotEmpty(pubNo)) {
             PatentStarListDTO patentStarListDTO = new PatentStarListDTO();
-            String condition = "PN="  + "(" + pubNo + ")";
+            String condition = "PN=" + "(" + pubNo + ")";
             patentStarListDTO.setCurrentQuery(condition);
             patentStarListDTO.setDBType("CN");
             patentStarListDTO.setOrderBy("AD");
@@ -1050,6 +1056,7 @@ public class PatentStarApiService {
 
     /**
      * 获取公开说明书
+     *
      * @param appNo
      * @return
      */
@@ -1154,6 +1161,7 @@ public class PatentStarApiService {
 
     /**
      * 获取附图
+     *
      * @param appNo
      * @return
      */
@@ -1173,6 +1181,7 @@ public class PatentStarApiService {
 
     /**
      * 获取摘要附图
+     *
      * @param appNo
      * @return
      */
@@ -1215,4 +1224,30 @@ public class PatentStarApiService {
         infoDTO.setLegalEvents(legalEvents);
         return infoDTO;
     }
+
+
+    public SelectClaimDTO getOrginCalim(String appNo) throws IOException {
+        List<Text> claimList = new ArrayList<>();
+        //获取公开说明书
+        String cnFullXmlApi = null;
+        try {
+            cnFullXmlApi = this.getCnFullXmlApi(appNo);
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+        try {
+            String fullText = this.getExternalClaim(cnFullXmlApi);
+            Text pubText = new Text();
+            pubText.setTextContent(fullText);
+            pubText.setIfOrigin(true);
+            claimList.add(pubText);
+        } catch (DocumentException e) {
+            e.printStackTrace();
+        }
+        SelectClaimDTO dto = new SelectClaimDTO();
+        if (!CollectionUtils.isEmpty(claimList)) {
+            dto.setClaimContent(claimList);
+        }
+        return dto;
+    }
 }

+ 1 - 1
src/main/java/cn/cslg/pas/service/importPatent/GetCataloguingFromWebThread.java

@@ -116,7 +116,7 @@ public class GetCataloguingFromWebThread extends Thread {
                 }
 
                 //添加法律事务
-                esService.addEsLegalEvent(uploadPatentWebDTO.getStarPatentVO().getPublicNo());
+              //  esService.addEsLegalEvent(uploadPatentWebDTO.getStarPatentVO().getPublicNo());
 
                 //添加引用专利
                 String nos = starPatentVO.getQuoteNos();

+ 2 - 2
src/main/java/cn/cslg/pas/service/importPatent/GetRightAndFullTextFromWebThread.java

@@ -117,7 +117,7 @@ public class GetRightAndFullTextFromWebThread extends Thread {
                 });
                 String reClaim = "";
                 if (reClaims.size() != 0) {
-                    reClaim = cn.cslg.pas.common.utils.StringUtils.join(reClaims, "\r\n");
+                    reClaim = cn.cslg.pas.common.utils.StringUtils.join(reClaims, "");
                 }
                 //装载权利要求原文
                 Text text = new Text();
@@ -172,7 +172,7 @@ public class GetRightAndFullTextFromWebThread extends Thread {
             }
             String fullText = "";
             if (fullTexts.size() != 0) {
-                fullText = cn.cslg.pas.common.utils.StringUtils.join(fullTexts, "\r\n");
+                fullText = cn.cslg.pas.common.utils.StringUtils.join(fullTexts, "");
             }
             Text text =new Text();
             text.setIfOrigin(true);

+ 5 - 1
src/main/java/cn/cslg/pas/service/importPatent/SavePatentToEsThread.java

@@ -10,6 +10,7 @@ import cn.cslg.pas.domain.es.Patent;
 import cn.cslg.pas.domain.es.PatentJoin;
 import cn.cslg.pas.service.business.CompareLiteratureService;
 import cn.cslg.pas.service.business.ImportTaskService;
+import cn.cslg.pas.service.business.es.EsProductPatentService;
 import cn.cslg.pas.service.business.es.EsService;
 import cn.cslg.pas.service.common.FileManagerService;
 import cn.cslg.pas.service.common.MessageService;
@@ -84,7 +85,7 @@ public class SavePatentToEsThread extends Thread {
 
                         //添加报告对比文件
                         if (importTaskAMVO.getProjectType() != null && importTaskAMVO.getProjectType().equals(1)) {
-                            if (importTaskAMVO.getReportType().equals(7)||importTaskAMVO.getReportType().equals(1)||importTaskAMVO.getReportType().equals(2)) {
+                            if (importTaskAMVO.getReportType().equals(7) || importTaskAMVO.getReportType().equals(1) || importTaskAMVO.getReportType().equals(2)) {
                                 CompareLiteratureService compareLiteratureService = applicationContext.getBean(CompareLiteratureService.class);
                                 compareLiteratureService.addPatentCompareLiterature(patent, importTaskAMVO.getProjectId(), importTaskAMVO.getCreateId());
                             }
@@ -110,6 +111,9 @@ public class SavePatentToEsThread extends Thread {
                         }
 
                     }
+                } else if (importTaskAMVO.getProductId() != null&&patentId!=null) {
+                    EsProductPatentService esProductPatentService = applicationContext.getBean(EsProductPatentService.class);
+                    esProductPatentService.addProductPatent(patentId,importTaskAMVO.getProductId());
                 }
                 //导入完成,通知前台
                 taskThread.updateProcess(false, 1, "");

+ 0 - 1
src/main/java/cn/cslg/pas/service/importPatent/SchedulingTaskService.java

@@ -101,7 +101,6 @@ public class SchedulingTaskService {
                 importTaskAMVO.setOrderByType(importTaskCondition.getOrderByType());
                 importTaskAMVO.setProjectType(importTaskCondition.getProjectType());
                 importTaskAMVO.setPatentNoStr(importTaskCondition.getPatentNos());
-
                 LambdaQueryWrapper<ReportProject> rQueryWrapper = new LambdaQueryWrapper<>();
                 rQueryWrapper.eq(ReportProject::getProjectId, importTaskCondition.getProjectId());
                 ReportProject reportProject = reportProjectService.getOne(rQueryWrapper, false);

+ 14 - 0
src/main/resources/jsons/importTask.json

@@ -161,6 +161,20 @@
     "ifGroup": "false",
     "ifShow": "false",
     "ifAsCondition": "true"
+  },
+  {
+    "name": "专利数据库id",
+    "type": "Integer",
+    "value": "productId",
+    "field": "productId",
+    "sqlField": "itc.product_id",
+    "sqlClass": "getComSql",
+    "orderClass": "",
+    "groupClass": "",
+    "ifSearch": "false",
+    "ifGroup": "false",
+    "ifShow": "false",
+    "ifAsCondition": "true"
   }
 
 

+ 15 - 0
src/test/java/cn/cslg/pas/service/EsPatentServiceTests.java

@@ -5,6 +5,7 @@ import cn.cslg.pas.domain.es.Patent;
 import cn.cslg.pas.service.business.AvoidDesignService;
 import cn.cslg.pas.service.business.es.EsFamilyService;
 import cn.cslg.pas.service.business.es.EsPatentService;
+import co.elastic.clients.elasticsearch.core.search.Hit;
 import org.junit.jupiter.api.Test;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.boot.test.context.SpringBootTest;
@@ -49,4 +50,18 @@ patentNos.add("CN116525219A");
  List<Map<String,Object>>    maps =   esFamilyService.getPatentFamilyByNos(patentNos,"inpadoc");
    System.out.println(maps);
     }
+
+      @Test
+    public  void getById() throws Exception{
+        List<String> list =new ArrayList<>();
+        list.add("UPK6H40BFl_J55316ou9");
+          List<Hit<Patent>> p =esPatentService.getById(list);
+          System.out.println(p);
+    }
+    @Test
+    public  void removeById() throws Exception{
+        List<String> list =new ArrayList<>();
+        list.add("UPK6H40BFl_J55316ou9");
+  esPatentService.removeById("UPK6H40BFl_J55316ou9");
+    }
 }