Ver Fonte

7/30 外部检索逻辑更改

lwhhszx há 1 ano atrás
pai
commit
f0a7eb0988

+ 138 - 50
src/main/java/cn/cslg/pas/common/vo/StarPatentVO.java

@@ -16,53 +16,44 @@ public class StarPatentVO implements Serializable {
     /**
      * 原始申请号
      */
-    @JSONField(name = "ANO")
-    private String rowApplicationNo;
+    private String ANO;
     /**
      * 专利类型(1和8为发明 2和9为新型 3为外观)
      */
-    @JSONField(name = "PT")
-    private Integer patentType;
+    private Integer PT;
     /**
      * 申请人地址
      */
-    @JSONField(name = "DZ")
-    private String applicationAddress;
+    private String DZ;
     /**
      * 主分类号
      */
-    @JSONField(name = "MC")
-    private String mainIpc;
+
+    private String MC;
     /**
      * IPC分类号
      */
-    @JSONField(name = "IC")
-    private String ipcListStr;
+    private String IC;
     /**
      * 公告日
      */
-    @JSONField(name = "GD")
-    private String publicAccreditDate;
+    private String GD;
     /**
      * 摘要
      */
-    @JSONField(name = "AB")
-    private String abstractStr;
+    private String AB;
     /**
      * 权利要求
      */
-    @JSONField(name = "CL")
-    private String claimStr;
+    private String CL;
     /**
      * 申请日
      */
-    @JSONField(name = "AD")
-    private String applicationDate;
+    private String AD;
     /**
      * 发明人
      */
-    @JSONField(name = "IN")
-    private String inventorStr;
+    private String IN;
     /**
      * 专利号
      */
@@ -70,79 +61,64 @@ public class StarPatentVO implements Serializable {
     /**
      * 公告号
      */
-    @JSONField(name = "GN")
-    private String publicAccreditNo;
+    private String GN;
     /**
      * 代理机构
      */
-    @JSONField(name = "AGN")
-    private String agencyStr;
+    private String AGN;
     /**
      * 申请号
      */
-    @JSONField(name = "AN")
-    private String applicationNo;
+    private String AN;
     /**
      * 申请人
      */
-    @JSONField(name = "PA")
-    private String applicantStr;
+    private String PA;
     /**
      * 代理人
      */
-    @JSONField(name = "AT")
-    private String agentStr;
+    private String AT;
     /**
      * 公开日
      */
-    @JSONField(name = "PD")
-    private String publicDate;
+    private String PD;
     /**
      * 标题
      */
-    @JSONField(name = "TI")
-    private String name;
+    private String TI;
     /**
      * 权利人
      */
-    @JSONField(name = "PE")
-    private String currentApplicantStr;
+    private String PE;
     /**
      * 法律状态
      */
-    @JSONField(name = "LG")
     private Integer LG;
     /**
      * 公开号
      */
-    @JSONField(name = "PN")
-    private String publicNo;
+    private String PN;
     /**
      * 受理局
      */
-    @JSONField(name = "GJ")
-    private String bureau;
+    private String GJ;
     /**
      * 优先权
      */
-    @JSONField(name = "PR")
-    private String priorityNo;
+    private String PR;
     /**
      * 优先权日
      */
-    @JSONField(name = "PRD")
-    private String priorityDate;
+    private String PRD;
 
     /**
      * 引用专利
      */
-    @JSONField(name = "CC")
-    private String quoteNos;
+    private String CC;
     /**
      * 省?国家
      */
-    @JSONField(name = "CO")
-    private String provinceStr;
+    private String CO;
 
     private List<PatentInventor> inventor;
 
@@ -155,9 +131,121 @@ public class StarPatentVO implements Serializable {
 
     private String simpleStatus;
     /**
+     *
      * 摘要附图路径
      */
     private String abstractPath;
-
+    private String CPT;
     private Integer counter;
+    private String CGT;
+    private String ZLTP;
+    private String MingCheng;
+    /**
+     * 代理机构代码
+     */
+    private String AG;
+
+    /**
+     * 范畴分类
+     */
+    private String CT;
+    /**
+     * 发明人
+     */
+    private String IV;
+    private String ZipCode;
+
+    private String Examiner;
+    private String CiteInfo;
+    private String NoCiteInfo;
+    /**
+     * 主权要
+     */
+    private String CL1;
+
+    /**
+     * 公开号(DocDB)
+     */
+    private String DocdbPubNo;
+
+    /**
+     * 申请号(Epo)
+     */
+    private String EpoAppNo;
+    /**
+     * 申请日
+     */
+    private String AppDate;
+    /**
+     * 公开日
+     */
+    private String PubDate;
+
+    /**
+     * IPC分类号
+     */
+    private String Ipc;
+
+    /**
+     * CPC分类号
+     */
+    private String cpc;
+
+    /**
+     * ECLA分类号
+     */
+    private String Ecla;
+    /**
+     * 申请人
+     */
+    private String Pa;
+    /**
+     * 申请人国别
+     */
+    private String PaAllCountry;
+    /**
+     * 发明人
+     */
+    private String Iv;
+    /**
+     * 发明人国别
+     */
+    private String IvAllCountry;
+    /**
+     * 引用文献号
+     */
+    private String Patcit;
+
+    /**
+     * 公开号(Original)
+     */
+    private String OriPubNo;
+    /**
+     * 申请号(Original)
+     */
+    private String OriAppNo;
+    /**
+     * 申请号(DocDB)
+     */
+    private String DocdbAppNo;
+    /**
+     * 公开号(EPO)
+     */
+    private String EpoPubNo;
+    /**
+     * 优先权
+     */
+    private String Pr;
+    /**
+     * 简单同族docdb
+     */
+    private String DocdbFamily;
+    /**
+     * 标题
+     */
+    private String Title;
+    /**
+     * 摘要
+     */
+    private String Abstract;
 }

+ 37 - 4
src/main/java/cn/cslg/pas/service/business/es/EsFamilyService.java

@@ -19,12 +19,18 @@ import cn.cslg.pas.common.vo.business.PatentNoVO;
 import cn.cslg.pas.domain.es.*;
 import cn.cslg.pas.service.query.FormatQueryService;
 import co.elastic.clients.elasticsearch.ElasticsearchClient;
+import co.elastic.clients.elasticsearch._types.FieldValue;
+import co.elastic.clients.elasticsearch._types.InlineScript;
+import co.elastic.clients.elasticsearch._types.Script;
 import co.elastic.clients.elasticsearch._types.SortOrder;
 import co.elastic.clients.elasticsearch._types.query_dsl.Query;
 import co.elastic.clients.elasticsearch._types.query_dsl.QueryBuilders;
+import co.elastic.clients.elasticsearch._types.query_dsl.TermsQueryField;
 import co.elastic.clients.elasticsearch.core.SearchRequest;
 import co.elastic.clients.elasticsearch.core.SearchResponse;
+import co.elastic.clients.elasticsearch.core.UpdateByQueryRequest;
 import co.elastic.clients.elasticsearch.core.search.Hit;
+import co.elastic.clients.json.JsonData;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson2.JSONObject;
 import lombok.RequiredArgsConstructor;
@@ -65,7 +71,7 @@ public class EsFamilyService {
         }
         Query query = QueryBuilders.term((t -> t.field("family_type").value(type)));
         Query nosQuerys = QueryBuilders.bool((i -> i.should(querys)));
-        Query finalQuery =QueryBuilders.bool((i->i.must(nosQuerys,query)));
+        Query finalQuery = QueryBuilders.bool((i -> i.must(nosQuerys, query)));
         builder.query(finalQuery);
         SearchResponse<PatentFamilyMessage> response = client.search(builder.build(), PatentFamilyMessage.class);
         List<Hit<PatentFamilyMessage>> hits = response.hits().hits();
@@ -77,11 +83,11 @@ public class EsFamilyService {
                 Map<String, Object> reFamily = new HashMap<>();
                 List<String> nos = new ArrayList<>();
                 patentList.forEach(item -> {
-                    if (item.getGrantNo() != null&&!item.getGrantNo().trim().equals("")) {
+                    if (item.getGrantNo() != null && !item.getGrantNo().trim().equals("")) {
                         nos.add(item.getGrantNo());
-                    } else if (item.getPublicNo() != null&&!item.getPublicNo().trim().equals("")) {
+                    } else if (item.getPublicNo() != null && !item.getPublicNo().trim().equals("")) {
                         nos.add(item.getPublicNo());
-                    } else if (item.getAppNo() != null&&!item.getAppNo().trim().equals("")) {
+                    } else if (item.getAppNo() != null && !item.getAppNo().trim().equals("")) {
                         nos.add(item.getAppNo());
                     }
                 });
@@ -94,4 +100,31 @@ public class EsFamilyService {
         return reFamilies;
     }
 
+
+    public void updatePatentFamilyByQuery(String patentFamilyType, String patentFamilyId, Integer patentFamilyCount, List<String> nos) {
+        String familyNum = "inpadoc_family_num";
+        String familyName = "inpadoc_family_id";
+        String source = "";
+        source = "ctx._source." + familyName + "=" + patentFamilyId + ";" + "ctx._source." + familyNum + "=" + patentFamilyCount + ";";
+        String finalSource = source;
+        InlineScript inlineScript = InlineScript.of(i ->  i.lang("painless").source(finalSource));
+        Script script = Script.of(i -> i.inline(inlineScript));
+        List<FieldValue> fieldValues = new ArrayList<>();
+
+        nos.forEach(item -> {
+            fieldValues.add(FieldValue.of(item));
+        });
+        Query query1 = QueryBuilders.terms(i -> i.field("app_no.keyword").terms(new TermsQueryField.Builder().value(fieldValues).build()));
+        Query query2 = QueryBuilders.terms(i -> i.field("public_no.keyword").terms(new TermsQueryField.Builder().value(fieldValues).build()));
+        Query query3 = QueryBuilders.terms(i -> i.field("grant_no.keyword").terms(new TermsQueryField.Builder().value(fieldValues).build()));
+
+       Query query4 =QueryBuilders.bool(i->i.should(query1,query2,query3));
+        UpdateByQueryRequest request = UpdateByQueryRequest.of(i -> i.index("patent").script(script).query(query4));
+        try {
+            client.updateByQuery(request);
+        } catch (IOException e) {
+        }
+
+    }
+
 }

+ 27 - 0
src/main/java/cn/cslg/pas/service/business/es/EsQuotePatentService.java

@@ -66,4 +66,31 @@ public class EsQuotePatentService {
         return reQuotePatent;
     }
 
+
+
+    //根据专利号查询同族专利号
+    public  PatentQuoteMessage getByQuotedNo(String patentNo) throws Exception {
+        SearchRequest.Builder builder = new SearchRequest.Builder();
+        //设置查询索引
+        builder.index("quote_patent");
+        List<Query> querys = new ArrayList<>();
+
+        Query q1 = QueryBuilders.term(t -> t.field("quoted_patent.app_no.keyword").value(patentNo));
+        //公开号
+        Query q2 = QueryBuilders.term(t -> t.field("quoted_patent.public_no.keyword").value(patentNo));
+        //授权号
+        Query q3 = QueryBuilders.term(t -> t.field("quoted_patent.grant_no.keyword").value(patentNo));
+        Query query = QueryBuilders.bool(i -> i.should(q1, q2, q3));
+
+        builder.query(query);
+        SearchResponse<PatentQuoteMessage> response = client.search(builder.build(), PatentQuoteMessage.class);
+        List<Hit<PatentQuoteMessage>> hits = response.hits().hits();
+        if(hits.size()<=0){
+            return null;
+        }
+      else {
+          return  hits.get(0).source();
+        }
+
+    }
 }

+ 85 - 111
src/main/java/cn/cslg/pas/service/business/es/EsService.java

@@ -20,6 +20,7 @@ import cn.cslg.pas.domain.es.*;
 import cn.cslg.pas.exception.XiaoShiException;
 import cn.cslg.pas.service.business.CommonService;
 import cn.cslg.pas.service.common.PatentStarApiService;
+import cn.cslg.pas.service.importPatent.WebVOTransformService;
 import cn.cslg.pas.service.query.FormatQueryService;
 import co.elastic.clients.elasticsearch.ElasticsearchClient;
 import co.elastic.clients.elasticsearch._types.*;
@@ -46,6 +47,8 @@ import java.text.SimpleDateFormat;
 import java.util.*;
 import java.util.stream.Collectors;
 
+import static org.springframework.data.elasticsearch.annotations.TermVector.no;
+
 
 @Service
 @RequiredArgsConstructor(onConstructor_ = {@Lazy})
@@ -54,7 +57,7 @@ public class EsService {
     private final ElasticsearchClient client;
 
     @Autowired
-    private FormatQueryService formatQueryService;
+    private EsFamilyService esFamilyService;
     @Autowired
     private PatentStarApiService patentStarApiService;
     @Autowired
@@ -65,7 +68,6 @@ public class EsService {
     @Autowired
     private EsCustomFieldService esCustomFieldService;
 
-
     /**
      * @param patent
      * @throws Exception
@@ -849,6 +851,7 @@ public class EsService {
         nos.forEach(item -> newNos.add(item.trim()));
         nos = newNos;
         PatentFamilyMessage patentFamilyMessage = null;
+        List<FamilyPatent> familyPatents = new ArrayList<>();
         String id = "";
 
         PatentFamilyMessageWithId patentFamilyMessageWithId = queryPatentFamily(patent, type);
@@ -885,32 +888,16 @@ public class EsService {
             }
         }
 
-        List<String> notInNos = new ArrayList<>();
-        //当查询到同族时
-        if (patentFamilyMessage != null) {
-            List<FamilyPatent> familyPatents = patentFamilyMessage.getPatent();
-            for (String no : nos) {
-                FamilyPatent familyPatent = familyPatents.stream()
-                        .filter(item -> item.getAppNo() != null && item.getAppNo().equals(no) ||
-                                item.getPublicNo() != null && item.getPublicNo().equals(no) ||
-                                item.getGrantNo() != null && item.getGrantNo().equals(no))
-                        .findFirst().orElse(null);
-                if (familyPatent == null) {
-                    notInNos.add(no);
-                }
-
-            }
-        }
-        //当未查询到同族时
-        else {
+        if (patentFamilyMessage == null) {
             patentFamilyMessage = new PatentFamilyMessage();
             patentFamilyMessage.setFamilyType(type);
-            patentFamilyMessage.setPatent(new ArrayList<>());
-            notInNos.addAll(nos);
-
+        } else {
+            familyPatents = patentFamilyMessage.getPatent();
+            familyPatents = this.getDistFamilyPatents(familyPatents);
         }
 
-        List<FamilyPatent> familyPatents = patentFamilyMessage.getPatent();
+
+        //装载专利
         String appNo = "";
         String publicNo = "";
         String grantNo = "";
@@ -927,9 +914,7 @@ public class EsService {
         String publicNo1 = publicNo;
         String grantNo1 = grantNo;
         FamilyPatent patent1 = familyPatents.stream().filter(item ->
-                publicNo1.equals(item.getPublicNo())
-                        || publicNo1.equals(item.getGrantNo())
-                        || grantNo1.equals(item.getPublicNo())
+                publicNo1.equals(item.getPublicNo()) || publicNo1.equals(item.getGrantNo()) || grantNo1.equals(item.getPublicNo())
                         || grantNo1.equals(item.getGrantNo())
         ).findFirst().orElse(null);
         if (patent1 == null) {
@@ -944,60 +929,78 @@ public class EsService {
             patent1.setPublicNo(patent.getPublicNo());
         }
 
-
-        if (notInNos.size() > 0) {
-            //所有专利号的专利详情
-            List<FamilyPatent> patents = new ArrayList<>();
-            notInNos.forEach(item -> {
-                FamilyPatent familyPatent = new FamilyPatent();
-                familyPatent.setPublicNo(item);
-                patents.add(familyPatent);
-            });
-            patentFamilyMessage.getPatent().addAll(patents);
-
-        }
-        List<FamilyPatent> familyPatents1 = patentFamilyMessage.getPatent();
-        if (familyPatents1.size() != 0) {
-            List<FamilyPatent> familyPatentsNew = this.getDistFamilyPatents(familyPatents1);
-            patentFamilyMessage.setPatent(familyPatentsNew);
-        }
+        //装载专利号
+        familyPatents = this.getDistFamilyPatentsWithNos(familyPatents, nos);
+        patentFamilyMessage.setPatent(familyPatents);
         //当id不为null时
         if (!id.equals("")) {
-
             this.updatePatentFamily(patentFamilyMessage, id);
-
         } else {
             try {
                 id = this.addPatentFamily(patentFamilyMessage);
             } catch (Exception e) {
             }
+        }
 
-
+        if (familyPatents != null && familyPatents.size() > 0) {
+            List<String> temNos = new ArrayList<>();
+            familyPatents.forEach(item -> {
+                if (item.getGrantNo() != null) {
+                    temNos.add(item.getGrantNo());
+                } else if (item.getPublicNo() != null) {
+                    temNos.add(item.getPublicNo());
+                } else if (item.getAppNo() != null) {
+                    temNos.add(item.getAppNo());
+                }
+            });
+            esFamilyService.updatePatentFamilyByQuery(type, id, familyPatents.size(), temNos);
         }
+
+
         esDTO.setPatentFamilyId(id);
         esDTO.setFamilyNum(patentFamilyMessage.getPatent().size());
-
         return esDTO;
     }
 
     private List<FamilyPatent> getDistFamilyPatents(List<FamilyPatent> familyPatents) {
+
         List<FamilyPatent> familyPatentsNew = new ArrayList<>();
+        if (familyPatents == null || familyPatents.size() == 0) {
+            return familyPatentsNew;
+        }
         for (int i = 0; i < familyPatents.size(); i++) {
             FamilyPatent familyPatent = familyPatents.get(i);
             FamilyPatent familyPatentNew = familyPatentsNew.stream().filter(item -> (item.getPublicNo() != null && item.getPublicNo().equals(familyPatent.getPublicNo()))
                     || (item.getGrantNo() != null && item.getGrantNo().equals(familyPatent.getGrantNo()))).findFirst().orElse(null);
             if (familyPatentNew == null) {
                 familyPatentsNew.add(familyPatent);
-            } else {
-                if (familyPatentNew.getGrantNo() == null && familyPatent.getAppNo() == null) {
-                    familyPatentsNew.remove(familyPatentNew);
-                    familyPatentsNew.add(familyPatent);
-                }
             }
         }
         return familyPatentsNew;
     }
 
+    private List<FamilyPatent> getDistFamilyPatentsWithNos(List<FamilyPatent> familyPatents, List<String> nos) {
+
+        List<FamilyPatent> familyPatentsNew = new ArrayList<>();
+        if (nos.size() == 0 || nos == null) {
+            return familyPatents;
+        }
+        if (familyPatents == null) {
+            familyPatents = new ArrayList<>();
+        }
+
+        for (int i = 0; i < nos.size(); i++) {
+            FamilyPatent familyPatentNew = familyPatents.stream().filter(item -> (item.getPublicNo() != null && item.getPublicNo().equals(no))
+                    || (item.getGrantNo() != null && item.getGrantNo().equals(no))).findFirst().orElse(null);
+            if (familyPatentNew == null) {
+                familyPatentNew = new FamilyPatent();
+                familyPatentNew.setPublicNo(nos.get(i));
+                familyPatents.add(familyPatentNew);
+            }
+        }
+        return familyPatents;
+    }
+
     /**
      * 添加同族
      *
@@ -1113,11 +1116,11 @@ public class EsService {
     }
 
 
-    public String addEsQuotePatent(StarPatentVO starPatentVO, List<String> nos) throws Exception {
-        if (starPatentVO == null) {
+    public PatentQuoteMessage addEsQuotePatent(Patent patent, List<String> nos) throws Exception {
+        if (patent == null) {
             return null;
         }
-        QuotePatent quotePatent = this.reQuotePatent(starPatentVO);
+        QuotePatent quotePatent = this.reQuotePatent(patent);
         PatentQuoteMessage patentQuoteMessage = null;
         //根据申请号和
         String id = "";
@@ -1127,7 +1130,7 @@ public class EsService {
         //设置查询索引
         builder.index("quote_patent");
         //申请号
-        Query q1 = QueryBuilders.term(t -> t.field("patent.app_no").value(starPatentVO.getApplicationNo()));
+        Query q1 = QueryBuilders.term(t -> t.field("patent.app_no").value(patent.getAppNo()));
         Query bool = QueryBuilders.bool(i -> i.must(q1));
         builder.query(bool);
         SearchResponse<PatentQuoteMessage> response = client.search(builder.build(), PatentQuoteMessage.class);
@@ -1140,7 +1143,6 @@ public class EsService {
         List<QuotePatent> quotePatents = new ArrayList<>();
         if (patentQuoteMessage != null && patentQuoteMessage.getQuotedPatents() != null) {
             quotePatents = patentQuoteMessage.getQuotedPatents();
-
         }
         if (nos != null && nos.size() > 0) {
             List<Patent> patents = esPatentService.getPatentsByNo(nos, true, null, null);
@@ -1150,18 +1152,12 @@ public class EsService {
                     quotePatent1 = quotePatents.stream()
                             .filter(item -> patentNo.equals(item.getAppNo()) || patentNo.equals(item.getPublicNo()) || patentNo.equals(item.getGrantNo())).findFirst().orElse(null);
                 }
-                Patent patent = patents.stream().filter(item -> patentNo.equals(item.getAppNo())).findFirst().orElse(null);
-                if (quotePatent1 == null) {
-                    quotePatent1 = this.reQuotePatent(patent, patentNo);
-                    quotePatents.add(quotePatent1);
-                } else {
-                    quotePatent1 = this.reQuotePatent(patent, patentNo);
-                }
+                Patent patent1 = patents.stream().filter(item -> patentNo.equals(item.getAppNo())).findFirst().orElse(null);
+                quotePatent1 = this.reQuotePatent(patent1, patentNo);
+                quotePatents.add(quotePatent1);
             }
 
         }
-
-
         if (patentQuoteMessage == null) {
             if (quotePatents.size() != 0) {
                 patentQuoteMessage = new PatentQuoteMessage();
@@ -1175,44 +1171,22 @@ public class EsService {
 
         }
 
-        return "";
+        return patentQuoteMessage;
     }
 
-    private QuotePatent reQuotePatent(StarPatentVO starPatentVO) {
+    private QuotePatent reQuotePatent(Patent patent) {
         QuotePatent quotePatent = new QuotePatent();
-
         //装载申请人
-        if (starPatentVO.getApplicantStr() != null && !starPatentVO.getApplicantStr().equals("")) {
-            List<String> names = Arrays.asList(starPatentVO.getApplicantStr().split(";"));
-            List<PatentPerson> patentPeople = new ArrayList<>();
-            for (int i = 0; i < names.size(); i++) {
-                PatentPerson patentPerson = new PatentPerson();
-                patentPerson.setOrder(i + 1);
-                patentPerson.setType("1");
-                patentPerson.setName(names.get(i));
-                patentPeople.add(patentPerson);
-            }
-            quotePatent.setApplicant(patentPeople);
-
-        }
+        quotePatent.setApplicant(patent.getApplicant());
 
         //装载权利人
-        if (starPatentVO.getCurrentApplicantStr() != null && !starPatentVO.getCurrentApplicantStr().equals("")) {
-            List<String> names = Arrays.asList(starPatentVO.getCurrentApplicantStr().split(";"));
-            List<PatentPerson> patentPeople = new ArrayList<>();
-            for (int i = 0; i < names.size(); i++) {
-                PatentPerson patentPerson = new PatentPerson();
-                patentPerson.setOrder(0);
-                patentPerson.setType("1");
-                patentPerson.setName(names.get(i));
-                patentPeople.add(patentPerson);
-            }
-            quotePatent.setRightHolder(patentPeople);
-        }
 
-        quotePatent.setAppNo(starPatentVO.getApplicationNo());
-        quotePatent.setGrantNo(starPatentVO.getPublicAccreditNo());
-        quotePatent.setPublicNo(starPatentVO.getPublicNo());
+        quotePatent.setRightHolder(patent.getRightHolder());
+
+
+        quotePatent.setAppNo(patent.getAppNo());
+        quotePatent.setGrantNo(patent.getGrantNo());
+        quotePatent.setPublicNo(patent.getPublicNo());
         return quotePatent;
     }
 
@@ -1243,7 +1217,7 @@ public class EsService {
         if (starPatentVO == null) {
             return null;
         }
-        String cnLegalApiStr = patentStarApiService.getCnLegalApi(starPatentVO.getRowApplicationNo());
+        String cnLegalApiStr = patentStarApiService.getCnLegalApi(starPatentVO.getANO());
         if (cnLegalApiStr != null && !cnLegalApiStr.equals("")) {
             List<LegalEvent> legalEvents = new ArrayList<>();
             //根据专利号查询是否有引用信息
@@ -1252,16 +1226,16 @@ public class EsService {
             builder.index("legal_event");
             //申请号
             List<Query> queries = new ArrayList<>();
-            if (starPatentVO.getApplicationNo() != null) {
-                Query q1 = QueryBuilders.term(t -> t.field("app_no").value(starPatentVO.getApplicationNo()));
+            if (starPatentVO.getAN() != null) {
+                Query q1 = QueryBuilders.term(t -> t.field("app_no").value(starPatentVO.getAN()));
                 queries.add(q1);
             }
-            if (starPatentVO.getPublicAccreditNo() != null) {
-                Query q2 = QueryBuilders.term((t -> t.field("grant_no").value(starPatentVO.getPublicAccreditNo())));
+            if (starPatentVO.getGN() != null) {
+                Query q2 = QueryBuilders.term((t -> t.field("grant_no").value(starPatentVO.getGN())));
                 queries.add(q2);
             }
-            if (starPatentVO.getPublicNo() != null) {
-                Query q3 = QueryBuilders.term((t -> t.field("public_no").value(starPatentVO.getPublicNo())));
+            if (starPatentVO.getPN() != null) {
+                Query q3 = QueryBuilders.term((t -> t.field("public_no").value(starPatentVO.getPN())));
                 queries.add(q3);
             }
 
@@ -1287,9 +1261,9 @@ public class EsService {
                         LegalEvent legalEvent1 = new LegalEvent();
                         legalEvent1.setEventDate(item.getLegalDate());
                         legalEvent1.setCode(item.getLegalCode());
-                        legalEvent1.setAppNo(starPatentVO.getApplicationNo());
-                        legalEvent1.setGrantNo(starPatentVO.getPublicAccreditNo());
-                        legalEvent1.setPublicNo(starPatentVO.getPublicNo());
+                        legalEvent1.setAppNo(starPatentVO.getAN());
+                        legalEvent1.setGrantNo(starPatentVO.getGN());
+                        legalEvent1.setPublicNo(starPatentVO.getPN());
                         legalEvent1.setDescription(item.getLegalStatusInfo());
                         legalEvent1.setName(item.getLegalStatus());
                         try {
@@ -1443,7 +1417,7 @@ public class EsService {
         builderPatent.index("patent_family");
         //申请号
         List<Query> queries = new ArrayList<>();
-        if (patent.getAppNo() != null) {
+        if (patent.getAppNo() != null && !patent.getAppNo().equals("")) {
             Query q1 = QueryBuilders.term(t -> t.field("patent.app_no").value(patent.getAppNo()));
             //公开号
             Query q2 = QueryBuilders.term(t -> t.field("patent.public_no").value(patent.getAppNo()));
@@ -1454,7 +1428,7 @@ public class EsService {
             queries.add(q2);
             queries.add(q3);
         }
-        if (patent.getPublicNo() != null) {
+        if (patent.getPublicNo() != null && !patent.getPublicNo().equals("")) {
             Query q1 = QueryBuilders.term(t -> t.field("patent.app_no").value(patent.getPublicNo()));
             //公开号
             Query q2 = QueryBuilders.term(t -> t.field("patent.public_no").value(patent.getPublicNo()));
@@ -1464,7 +1438,7 @@ public class EsService {
             queries.add(q2);
             queries.add(q3);
         }
-        if (patent.getGrantNo() != null) {
+        if (patent.getGrantNo() != null && !patent.getGrantNo().equals("")) {
             Query q1 = QueryBuilders.term(t -> t.field("patent.app_no").value(patent.getGrantNo()));
             //公开号
             Query q2 = QueryBuilders.term(t -> t.field("patent.public_no").value(patent.getGrantNo()));

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

@@ -9,6 +9,7 @@ import cn.cslg.pas.common.utils.esDataForm.AddressSplitter;
 import cn.cslg.pas.common.utils.esDataForm.PatentClassifySplitter;
 import cn.cslg.pas.common.vo.*;
 import cn.cslg.pas.domain.es.*;
+import cn.cslg.pas.service.business.es.EsQuotePatentService;
 import cn.cslg.pas.service.business.es.EsService;
 import cn.cslg.pas.service.common.ExcuteDataToVOService;
 import cn.cslg.pas.service.common.ExcuteUploadSettingService;
@@ -47,7 +48,6 @@ public class GetCataloguingFromWebThread extends Thread {
 
     @Override
     public void run() {
-
         while ((!ifProductAll || uploadPatentWebDTOs.size() > 0) && importTaskAMVO.getState().equals(1)) {
             try {
                 //判断任务队列是否有任务,若没有则线程等待唤醒
@@ -64,34 +64,18 @@ public class GetCataloguingFromWebThread extends Thread {
                 StarPatentVO starPatentVO = uploadPatentWebDTO.getStarPatentVO();
                 String patentZhuLuStr = "";
                 patentStarApiService = applicationContext.getBean(PatentStarApiService.class);
-                if (starPatentVO.getApplicationNo().startsWith("CN")) {
-                    patentZhuLuStr = patentStarApiService.getCnBibApi(uploadPatentWebDTO.getStarPatentVO().getRowApplicationNo());
+                WebVOTransformService webVOTransformService = applicationContext.getBean(WebVOTransformService.class);
+                if (starPatentVO.getAB().startsWith("CN")) {
+                    patentZhuLuStr = patentStarApiService.getCnBibApi(uploadPatentWebDTO.getStarPatentVO().getANO());
                 } else {
-                    patentZhuLuStr = patentStarApiService.getENBibApi(uploadPatentWebDTO.getStarPatentVO().getPublicNo());
+                    patentZhuLuStr = patentStarApiService.getENBibApi(uploadPatentWebDTO.getStarPatentVO().getPN());
                 }
                 if (patentZhuLuStr != null && !patentZhuLuStr.trim().equals("") && !patentZhuLuStr.equals("{}") && !patentZhuLuStr.contains("请求不合法")) {
-                    this.loadPatent(uploadPatentWebDTO);
-                    if (starPatentVO.getApplicationNo().startsWith("CN")) {
-                        this.loadCNPatent(patentZhuLuStr, uploadPatentWebDTO.getPatent(), starPatentVO);
-
-                        //装载专利号
-                        if (uploadPatentWebDTO.getPatent().getAppNo() != null) {
-                            uploadPatentWebDTO.getPatent().setPatentNo(uploadPatentWebDTO.getPatent().getAppNo());
-                        } else if (uploadPatentWebDTO.getPatent().getGrantNo() != null) {
-                            uploadPatentWebDTO.getPatent().setPatentNo(uploadPatentWebDTO.getPatent().getGrantNo());
-                        } else if (uploadPatentWebDTO.getPatent().getPublicNo() != null) {
-                            uploadPatentWebDTO.getPatent().setPatentNo(uploadPatentWebDTO.getPatent().getPublicNo());
-                        }
+                    webVOTransformService.loadPatent(uploadPatentWebDTO);
+                    if (starPatentVO.getAN().startsWith("CN")) {
+                        webVOTransformService.loadCNPatent(patentZhuLuStr, uploadPatentWebDTO.getPatent(), starPatentVO);
                     } else {
-                        this.loadWorldPatent(patentZhuLuStr, uploadPatentWebDTO.getPatent());
-                        //装载专利号
-                        if (uploadPatentWebDTO.getPatent().getGrantNo() != null) {
-                            uploadPatentWebDTO.getPatent().setPatentNo(uploadPatentWebDTO.getPatent().getGrantNo());
-                        } else if (uploadPatentWebDTO.getPatent().getPublicNo() != null) {
-                            uploadPatentWebDTO.getPatent().setPatentNo(uploadPatentWebDTO.getPatent().getPublicNo());
-                        } else if (uploadPatentWebDTO.getPatent().getAppNo() != null) {
-                            uploadPatentWebDTO.getPatent().setPatentNo(uploadPatentWebDTO.getPatent().getAppNo());
-                        }
+                        webVOTransformService.loadWorldPatent(patentZhuLuStr, uploadPatentWebDTO.getPatent());
                     }
                 }
 
@@ -118,21 +102,31 @@ public class GetCataloguingFromWebThread extends Thread {
                     uploadPatentWebDTO.getPatent().setInpadocFamilyNum(esPatentFamilyDTO.getFamilyNum());
                     uploadPatentWebDTO.getPatent().setInpadocFamilyId(esPatentFamilyDTO.getPatentFamilyId());
                 }
-                if (uploadPatentWebDTO.getStarPatentVO().getApplicationNo().contains("CN")) {
+                if (uploadPatentWebDTO.getStarPatentVO().getAN().contains("CN")) {
                     //添加法律事务
                     esService.addEsLegalEvent(uploadPatentWebDTO.getStarPatentVO());
                 }
                 //添加引用专利
-                String nos = starPatentVO.getQuoteNos();
+                Patent patent = uploadPatentWebDTO.getPatent();
+                String nos = starPatentVO.getCO();
                 if (nos != null) {
                     List<String> quotedNos = this.reQuotedNos(nos);
-                    esService.addEsQuotePatent(uploadPatentWebDTO.getStarPatentVO(), quotedNos);
+                    PatentQuoteMessage patentQuoteMessage = esService.addEsQuotePatent(uploadPatentWebDTO.getPatent(), quotedNos);
+                    if (patentQuoteMessage != null && patentQuoteMessage.getQuotedPatents() != null) {
+                        patent.setQuotePatentNoNum(patentQuoteMessage.getQuotedPatents().size());
+                    }
+                }
+                EsQuotePatentService esQuotePatentService = applicationContext.getBean(EsQuotePatentService.class);
+
+                PatentQuoteMessage patentQuoteMessage2 = esQuotePatentService.getByQuotedNo(patent.getAppNo());
+                if (patentQuoteMessage2 != null && patentQuoteMessage2.getQuotedPatents() != null) {
+                    patent.setQuotedPatentNoNum(patentQuoteMessage2.getQuotedPatents().size());
                 }
 
                 //加入es保存队列
-                importFromWebToEsService.loadPatentMessageDone(uploadPatentWebDTO);
+                this.addPatent(uploadPatentWebDTO);
             } catch (Exception e) {
-                importFromWebToEsService.loadPatentMessageDone(uploadPatentWebDTO);
+                this.addPatent(uploadPatentWebDTO);
                 e.printStackTrace();
             }
         }
@@ -167,372 +161,6 @@ public class GetCataloguingFromWebThread extends Thread {
         }
     }
 
-    //装载专利信息
-    private void loadPatent(UploadPatentWebDTO uploadPatentWebDTO) {
-        String country = "";
-        Patent patent = uploadPatentWebDTO.getPatent();
-        StarPatentVO starPatentVO = uploadPatentWebDTO.getStarPatentVO();
-        //装载专利类型
-        Integer patentType = starPatentVO.getPatentType();
-        if (patentType != null) {
-            if (patentType.equals(2) || patentType.equals(9)) {
-                patent.setPatentType("2");  //实用新型
-            } else if (patentType.equals(1) || patentType.equals(8)) {
-                patent.setPatentType("1");  //发明
-            } else if (patentType.equals(3)) {
-                patent.setPatentType("3");  //外观设计
-            }
-        }
-
-        //装载申请人地址
-        if (starPatentVO.getApplicationAddress() != null && !starPatentVO.getApplicationAddress().equals("")) {
-            String applicationAddress = starPatentVO.getApplicationAddress();
-            PersonAddress personAddress = AddressSplitter.splitAddress(applicationAddress, starPatentVO.getProvinceStr());
-            patent.setApplicantAddr(personAddress);
-        }
-
-        //装载IPC分类号
-        if (starPatentVO.getIpcListStr() != null && !starPatentVO.getIpcListStr().equals("")) {
-            List<PatentClassify> patentClassifies = new ArrayList<>();
-            List<String> ipcArr = Arrays.asList(starPatentVO.getIpcListStr().split(";"));
-            for (int i = 0; i < ipcArr.size(); i++) {
-                PatentClassify patentClassify = PatentClassifySplitter.split(ipcArr.get(i));
-                patentClassifies.add(patentClassify);
-                if (i == 0) {
-                    patent.setMipc(patentClassify);
-                }
-            }
-            patent.setIpc(patentClassifies);
-        }
-
-        //装载公告日
-        if (starPatentVO.getPublicAccreditDate() != null && !starPatentVO.getPublicAccreditDate().equals("")) {
-            Date date = DateUtils.strToDate(starPatentVO.getPublicAccreditDate());
-            patent.setGrantDate(date);
-        }
-
-        //装载摘要
-        if (starPatentVO.getAbstractStr() != null && !starPatentVO.getAbstractStr().equals("")) {
-            Text text = new Text();
-            text.setLanguage(patent.getAppCountry());
-            text.setIfOrigin(true);
-            text.setTextContent(starPatentVO.getAbstractStr());
-            patent.setAbstractStr(Arrays.asList(text));
-        }
-
-        //装载申请日
-        if (starPatentVO.getApplicationDate() != null && !starPatentVO.getApplicationDate().equals("")) {
-            Date date = DateUtils.strToDate(starPatentVO.getApplicationDate());
-            patent.setAppDate(date);
-        }
-
-        //装载发明人
-        if (starPatentVO.getInventorStr() != null && !starPatentVO.getInventorStr().equals("")) {
-            List<String> patentInventorNames = Arrays.asList(starPatentVO.getInventorStr().split(";"));
-            List<PatentPerson> patentPeople = new ArrayList<>();
-            for (int i = 0; i < patentInventorNames.size(); i++) {
-                PatentPerson patentPerson = new PatentPerson();
-                patentPerson.setOrder(i + 1);
-                patentPerson.setType("1");
-                patentPerson.setName(patentInventorNames.get(i));
-                patentPeople.add(patentPerson);
-            }
-            patent.setInventor(patentPeople);
-        }
-
-        //装载申请号
-        if (starPatentVO.getApplicationNo() != null && !starPatentVO.getApplicationNo().equals("")) {
-            patent.setAppNo(starPatentVO.getApplicationNo());
-            country = starPatentVO.getApplicationNo().substring(0, 2);
-        }
-
-        //装载公开号
-        if (starPatentVO.getPublicNo() != null && !starPatentVO.getPublicNo().equals("")) {
-            patent.setPublicNo(starPatentVO.getPublicNo());
-            country = starPatentVO.getApplicationNo().substring(0, 2);
-        }
-
-        if (starPatentVO.getPublicAccreditNo() != null && !starPatentVO.getPublicAccreditNo().equals("")) {
-            patent.setGrantNo(starPatentVO.getPublicAccreditNo());
-            country = starPatentVO.getApplicationNo().substring(0, 2);
-        }
-
-        //装载申请人
-        if (starPatentVO.getApplicantStr() != null && !starPatentVO.getApplicantStr().equals("")) {
-            List<String> names = Arrays.asList(starPatentVO.getApplicantStr().split(";"));
-            List<PatentPerson> patentPeople = new ArrayList<>();
-            for (int i = 0; i < names.size(); i++) {
-                PatentPerson patentPerson = new PatentPerson();
-                patentPerson.setOrder(i + 1);
-                patentPerson.setType("1");
-                patentPerson.setName(names.get(i));
-                patentPeople.add(patentPerson);
-            }
-            patent.setApplicant(patentPeople);
-        }
-
-        //装载代理人
-        if (starPatentVO.getAgentStr() != null && !starPatentVO.getAgentStr().equals("")) {
-            List<String> patentAgents = Arrays.asList(starPatentVO.getAgentStr().split(";"));
-            if (patentAgents != null && patentAgents.size() != 0) {
-                patent.setAgent(patentAgents);
-            }
-        }
-
-        if (starPatentVO.getAgencyStr() != null && !starPatentVO.getAgencyStr().equals("")) {
-            patent.setAgency(starPatentVO.getAgencyStr());
-        }
-
-        //装载公开日
-        if (starPatentVO.getPublicDate() != null && !starPatentVO.getPublicDate().equals("")) {
-            Date date = DateUtils.strToDate(starPatentVO.getPublicDate());
-            patent.setPublicDate(date);
-        }
-
-        //装载标题
-        if (starPatentVO.getName() != null && !starPatentVO.getName().equals("")) {
-            Text text = new Text();
-            text.setLanguage(country);
-            text.setIfOrigin(true);
-            text.setTextContent(starPatentVO.getName());
-            patent.setTitle(Arrays.asList(text));
-        }
-
-        //装载权利人
-        if (starPatentVO.getCurrentApplicantStr() != null && !starPatentVO.getCurrentApplicantStr().equals("")) {
-            List<String> names = Arrays.asList(starPatentVO.getCurrentApplicantStr().split(";"));
-            List<PatentPerson> patentPeople = new ArrayList<>();
-            for (int i = 0; i < names.size(); i++) {
-                PatentPerson patentPerson = new PatentPerson();
-                patentPerson.setOrder(0);
-                patentPerson.setType("1");
-                patentPerson.setName(names.get(i));
-                patentPeople.add(patentPerson);
-            }
-            patent.setRightHolder(patentPeople);
-        } else if (patent.getApplicant() != null) {
-            patent.setRightHolder(patent.getApplicant());
-        }
-
-        //装载法律状态(os_patent表status字段值)
-        Integer status = starPatentVO.getLG();
-        if (status != null) {
-            //有效(有权)
-            if (status == 1) {
-                patent.setSimpleStatus("1");
-                //失效(无权)
-            } else if (status == 2) {
-                patent.setSimpleStatus("2");
-                //审中(审中)
-            } else if (status == 3) {
-                patent.setSimpleStatus("3");
-            }
-        }
-
-           System.out.println("国家"+country);
-            patent.setAppCountry(country);
-
-    }
-
-    //装载中国专利
-    private void loadCNPatent(String chinaPatentZhuLuStr, Patent patent, StarPatentVO starPatentVO) {
-        patent.setPatentNo(patent.getAppNo());
-        if (chinaPatentZhuLuStr != null && !chinaPatentZhuLuStr.trim().equals("") && !chinaPatentZhuLuStr.equals("{}") && !chinaPatentZhuLuStr.contains("请求不合法")) {
-            List<ChinaPatentZhuLu> chinaPatentZhuLus = JSON.parseArray(chinaPatentZhuLuStr, ChinaPatentZhuLu.class);
-            ChinaPatentZhuLu chinaPatentZhuLu = chinaPatentZhuLus.get(0);
-
-            //装载申请人地址
-            if (patent.getApplicantAddr() == null) {
-                if (chinaPatentZhuLu.getDZ() != null && !chinaPatentZhuLu.getDZ().equals("")) {
-                    PersonAddress personAddress = AddressSplitter.splitAddress(chinaPatentZhuLu.getDZ(), starPatentVO.getProvinceStr());
-                    patent.setApplicantAddr(personAddress);
-                    patent.setApplicantAddr(personAddress);
-                }
-            }
-
-            //装载代理人
-            if (patent.getAgent() == null || patent.getAgent().size() == 0) {
-                if (chinaPatentZhuLu.getAT() != null && !chinaPatentZhuLu.getAT().equals("")) {
-                    List<String> patentAgents = Arrays.asList(chinaPatentZhuLu.getAT().split(";"));
-                    if (patentAgents != null && patentAgents.size() != 0) {
-                        patent.setAgent(patentAgents);
-                    }
-                }
-            }
-
-            //装载发明人
-            if (patent.getInventor() == null || patent.getInventor().size() == 0) {
-
-                if (chinaPatentZhuLu.getIV() != null && !chinaPatentZhuLu.getIV().equals("")) {
-                    List<String> patentInventorNames = Arrays.asList(chinaPatentZhuLu.getIV().split(";"));
-                    List<PatentPerson> patentPeople = new ArrayList<>();
-                    for (int i = 0; i < patentInventorNames.size(); i++) {
-                        PatentPerson patentPerson = new PatentPerson();
-                        patentPerson.setOrder(0);
-                        patentPerson.setType("1");
-                        patentPerson.setName(patentInventorNames.get(i));
-                        patentPeople.add(patentPerson);
-                    }
-                    patent.setInventor(patentPeople);
-                }
-            }
-
-            //装载优先权号、优先权国家、优先权日
-            if (chinaPatentZhuLu.getPR() != null && chinaPatentZhuLu.getPR() != "") {
-                String pr = chinaPatentZhuLu.getPR();
-                String[] prStrs = pr.split(" ");
-                String priorityNo = prStrs[0];
-                if (chinaPatentZhuLu.getPRD() != null) {
-
-                }
-                String prDate = "";
-                if (prStrs.length > 1) {
-                    prDate = prStrs[1];
-                }
-                Priorities priorities = new Priorities();
-                priorities.setPriorityNo(priorityNo);
-                String pCountry = priorityNo.substring(0, 2);
-                priorities.setPriorityCountry(pCountry);
-                //装载优先权日
-                if (prDate != null) {
-                    String a = DateUtils.strToStr(prDate, "yyyy-MM-dd");
-                    priorities.setPriorityDate(a);
-                }
-                patent.setPriorities(Arrays.asList(priorities));
-
-            }
-
-        }
-    }
-
-    // 装载世界专利
-    private void loadWorldPatent(String worldPatentZhuLuStr, Patent patent) {
-        String country = "";
-        List<WorldPatentZhuLu> worldPatentZhuLus = JSON.parseArray(worldPatentZhuLuStr, WorldPatentZhuLu.class);
-        WorldPatentZhuLu worldPatentZhuLu = worldPatentZhuLus.get(0);
-
-        //装载公开号
-        if (patent.getPublicNo() == null || patent.getPublicNo().equals("")) {
-            patent.setPublicNo(worldPatentZhuLu.getDocdbPubNo());
-        }
-        //装载申请号
-        if (patent.getAppNo() == null || patent.getAppNo().equals("")) {
-            patent.setAppNo(worldPatentZhuLu.getEpoAppNo());
-        }
-        //装载申请日
-        if (patent.getAppDate() == null) {
-            Date date = DateUtils.strToDate(worldPatentZhuLu.getAppDate());
-            patent.setAppDate(date);
-        }
-        //装载公开日
-        if (patent.getPublicDate() == null) {
-            Date date = DateUtils.strToDate(worldPatentZhuLu.getPubDate());
-            patent.setPublicDate(date);
-        }
-        //装载IPC分类号
-        if (patent.getIpc() == null || patent.getIpc().size() == 0) {
-            List<PatentClassify> patentClassifies = new ArrayList<>();
-            List<String> ipcArr = Arrays.asList(worldPatentZhuLu.getIpc().split(";"));
-            for (int i = 0; i < ipcArr.size(); i++) {
-                PatentClassify patentClassify = PatentClassifySplitter.split(ipcArr.get(i));
-                patentClassifies.add(patentClassify);
-                if (i == 0) {
-                    patent.setMipc(patentClassify);
-                }
-            }
-            patent.setIpc(patentClassifies);
-        }
-
-        //装载CPC分类号
-        if (patent.getCpc() == null || patent.getCpc().size() == 0) {
-            if (worldPatentZhuLu.getCpc() != null && !worldPatentZhuLu.getCpc().equals("")) {
-                List<PatentClassify> patentClassifies = new ArrayList<>();
-                List<String> cpcArr = Arrays.asList(worldPatentZhuLu.getCpc().split(";"));
-                for (int i = 0; i < cpcArr.size(); i++) {
-                    PatentClassify patentClassify = PatentClassifySplitter.split(cpcArr.get(i));
-                    patentClassifies.add(patentClassify);
-                    if (i == 0) {
-                        patent.setMipc(patentClassify);
-                    }
-                }
-                patent.setCpc(patentClassifies);
-            }
-        }
-
-        //装载申请人
-        if (patent.getApplicant() == null || patent.getApplicant().size() == 0) {
-            List<String> names = Arrays.asList(worldPatentZhuLu.getPa().split(";"));
-            List<PatentPerson> patentPeople = new ArrayList<>();
-            for (int i = 0; i < names.size(); i++) {
-                PatentPerson patentPerson = new PatentPerson();
-                patentPerson.setOrder(0);
-                patentPerson.setType("1");
-                patentPerson.setName(names.get(i));
-                patentPeople.add(patentPerson);
-            }
-            patent.setApplicant(patentPeople);
-            if (patent.getRightHolder() == null || patent.getRightHolder().size() == 0) {
-                patent.setRightHolder(patent.getApplicant());
-            }
-        }
-
-
-        //装载发明人
-        if (patent.getInventor() == null || patent.getInventor().size() == 0) {
-            if (worldPatentZhuLu.getIv() != null && !worldPatentZhuLu.getIv().equals("")) {
-                List<String> patentInventorNames = Arrays.asList(worldPatentZhuLu.getIv().split(";"));
-                List<PatentPerson> patentPeople = new ArrayList<>();
-                for (int i = 0; i < patentInventorNames.size(); i++) {
-                    PatentPerson patentPerson = new PatentPerson();
-                    patentPerson.setOrder(0);
-                    patentPerson.setType("1");
-                    patentPerson.setName(patentInventorNames.get(i));
-                    patentPeople.add(patentPerson);
-                }
-                patent.setInventor(patentPeople);
-            }
-        }
-
-        //装载优先权号、优先权国家、优先权日
-        if (patent.getPriorities() == null && worldPatentZhuLu.getPr() != null && worldPatentZhuLu.getPr() != "") {
-
-            String pr = worldPatentZhuLu.getPr();
-            String prStrs[] = pr.split(" ");
-            String priorityNo = prStrs[0];
-            String prDate = "";
-            if (prStrs.length > 1) {
-                prDate = prStrs[1];
-            }
-            Priorities priorities = new Priorities();
-            priorities.setPriorityNo(priorityNo);
-            String pCountry = priorityNo.substring(0, 2);
-            priorities.setPriorityCountry(pCountry);
-            //装载优先权日
-            if (prDate != null) {
-                String a = DateUtils.strToStr(prDate, "yyyy-MM-dd");
-                priorities.setPriorityDate(a);
-            }
-            patent.setPriorities(Arrays.asList(priorities));
-        }
-
-        //装载标题
-        if (patent.getTitle() == null || patent.getTitle().size() != 0) {
-            Text text = new Text();
-            text.setLanguage(country);
-            text.setIfOrigin(true);
-            text.setTextContent(worldPatentZhuLu.getTitle());
-            patent.setTitle(Arrays.asList(text));
-        }
-
-        //装载摘要
-        if (patent.getAbstractStr() == null || patent.getAbstractStr().equals("")) {
-            Text text = new Text();
-            text.setLanguage(patent.getAppCountry());
-            text.setIfOrigin(true);
-            text.setTextContent(worldPatentZhuLu.getAbstract());
-            patent.setAbstractStr(Arrays.asList(text));
-        }
-    }
 
     public List<String> reQuotedNos(String str) {
         List<String> strings = Arrays.asList(str.split(";"));
@@ -542,10 +170,21 @@ public class GetCataloguingFromWebThread extends Thread {
             if (string2.size() > 0) {
                 nos.add(string2.get(0).replace(" ", ""));
             }
-
         });
         return nos;
+    }
 
+    /**
+     * @param uploadPatentWebDTO
+     */
+    public void addPatent(UploadPatentWebDTO uploadPatentWebDTO) {
+        GetRightAndFullTextFromWebThread getRightAndFullTextFromWebThread = importFromWebToEsService.getRightAndFullTextFromWebThreadObject();
+        SavePatentToEsThread savePatentToEsThread = importFromWebToEsService.getSavePatentToEsThreadObject();
+        if (getRightAndFullTextFromWebThread != null) {
+            getRightAndFullTextFromWebThread.awakeTask(uploadPatentWebDTO);
+        } else {
+            savePatentToEsThread.awakeTask(uploadPatentWebDTO);
+        }
     }
 
 

+ 39 - 18
src/main/java/cn/cslg/pas/service/importPatent/ImportFromWebToEsService.java

@@ -44,17 +44,33 @@ public class ImportFromWebToEsService implements PatentImportImp {
     @Autowired
     private PatentStarApiService patentStarApiService;
     private ImportTaskAMVO importTaskAMVO;
+    private SavePatentToEsThread savePatentToEsThread = null;
+    public GetCataloguingFromWebThread getCataloguingFromWebThread = null;
+    public GetPatentPDFFromWebThread getPatentPDFFromWebThread = null;
+    public GetPatentPictureFromWebThread getPatentPictureFromWebThread = null;
+    public GetRightAndFullTextFromWebThread getRightAndFullTextFromWebThread = null;
+    private ApplicationContext applicationContext;
+    private List<UploadPatentWebDTO> uploadPatentWebDTOS = new ArrayList<>();
 
-    private SavePatentToEsThread savePatentToEsThread;
 
-    private GetCataloguingFromWebThread getCataloguingFromWebThread;
+    public GetCataloguingFromWebThread getCataloguingFromWebThreadObject(){
+        return  getCataloguingFromWebThread;
+    }
+    public GetPatentPDFFromWebThread getPatentPDFFromWebThreadObject() {
+        return getPatentPDFFromWebThread;
+    }
 
-    private GetPatentPDFFromWebThread getPatentPDFFromWebThread;
-    private GetPatentPictureFromWebThread getPatentPictureFromWebThread;
-    private GetRightAndFullTextFromWebThread getRightAndFullTextFromWebThread;
-    private ApplicationContext applicationContext;
-    private List<UploadPatentWebDTO> uploadPatentWebDTOS = new ArrayList<>();
+    public GetPatentPictureFromWebThread getPatentPictureFromWebThreadObject() {
+        return getPatentPictureFromWebThread;
+    }
+
+    public GetRightAndFullTextFromWebThread getRightAndFullTextFromWebThreadObject() {
+        return getRightAndFullTextFromWebThread;
+    }
 
+    public SavePatentToEsThread getSavePatentToEsThreadObject() {
+        return savePatentToEsThread;
+    }
     @Override
     public Boolean startPatentThread() {
         //装载专利信息的计数器
@@ -67,6 +83,12 @@ public class ImportFromWebToEsService implements PatentImportImp {
         //若本次下载任务是超过一万条专利的全部下载任务
         savePatentToEsThread = new SavePatentToEsThread(taskThread, taskThread.getApplicationContext());
         savePatentToEsThread.start();
+
+        if (ifCataloguing == '1') {
+            getCataloguingFromWebThread = new GetCataloguingFromWebThread(taskThread, this);
+            getCataloguingFromWebThread.start();
+        }
+
         if (ifAddPicture == '1') {
             getPatentPictureFromWebThread = new GetPatentPictureFromWebThread(taskThread, this);
             getPatentPictureFromWebThread.start();
@@ -80,11 +102,8 @@ public class ImportFromWebToEsService implements PatentImportImp {
             getPatentPDFFromWebThread.start();
         }
 
-        if (ifCataloguing == '1') {
-            getCataloguingFromWebThread = new GetCataloguingFromWebThread(taskThread, this);
-            getCataloguingFromWebThread.start();
-        }
-       return excuteLessThan10000(importTaskAMVO, addPatentCounter);
+
+        return excuteLessThan10000(importTaskAMVO, addPatentCounter);
     }
 
 
@@ -224,10 +243,10 @@ public class ImportFromWebToEsService implements PatentImportImp {
                         StarPatentVO starPatentVO = starPatents.get(j);
 
                         if (nos != null) {
-                            nos.removeIf(item -> item.equals(starPatentVO.getApplicationNo())
-                                    || item.equals(starPatentVO.getPublicNo())
-                                    || item.equals(starPatentVO.getPublicAccreditNo())
-                                    || item.equals(starPatentVO.getRowApplicationNo()));
+                            nos.removeIf(item -> item.equals(starPatentVO.getAN())
+                                    || item.equals(starPatentVO.getPN())
+                                    || item.equals(starPatentVO.getGN())
+                                    || item.equals(starPatentVO.getANO()));
                         }
                         UploadPatentWebDTO uploadPatentWebDTO = new UploadPatentWebDTO();
                         Patent patent = new Patent();
@@ -288,11 +307,11 @@ public class ImportFromWebToEsService implements PatentImportImp {
                 getPatentPDFFromWebThread.setIfProductAll(true);
             }
 
-        return ifHaveGet;
+            return ifHaveGet;
         } catch (Exception e) {
             e.printStackTrace();
             //生产消费到一半时,发生错误异常,将任务状态置为完成
-           return  ifHaveGet;
+            return ifHaveGet;
         }
     }
 
@@ -338,8 +357,10 @@ public class ImportFromWebToEsService implements PatentImportImp {
         }
     }
 
+
     private void loadPatent(StarPatentVO starPatentVO, Patent patent) {
 
 
+
     }
 }

+ 771 - 0
src/main/java/cn/cslg/pas/service/importPatent/WebVOTransformService.java

@@ -0,0 +1,771 @@
+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.utils.DateUtils;
+import cn.cslg.pas.common.utils.esDataForm.AddressSplitter;
+import cn.cslg.pas.common.utils.esDataForm.PatentClassifySplitter;
+import cn.cslg.pas.common.vo.StarPatentVO;
+import cn.cslg.pas.domain.es.*;
+import com.alibaba.fastjson.JSON;
+import org.dom4j.Document;
+import org.dom4j.Element;
+import org.dom4j.XPath;
+import org.dom4j.io.SAXReader;
+import org.springframework.stereotype.Service;
+
+import java.io.Reader;
+import java.io.StringReader;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Date;
+import java.util.List;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+import java.util.stream.Collectors;
+
+@Service
+public class WebVOTransformService {
+    private static List<String> SCHOOL = new ArrayList<String>() {{
+        add("大学");
+        add("学院");
+        add("小学");
+        add("中学");
+        add("学校");
+        add("幼儿园");
+    }};
+    private static List<String> INSTITUTES = new ArrayList<String>() {{
+        add("研究院");
+        add("研究所");
+    }};
+
+    private static List<String> COMPANY = new ArrayList<String>() {{
+        add("公司");
+        add("集团");
+        add("事务所");
+    }};
+
+    //装载中国专利
+    public void loadCNPatent(String chinaPatentZhuLuStr, Patent patent, StarPatentVO starPatentVO) {
+        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());
+
+            this.loadCountry(patent, true);
+        }
+    }
+
+
+    //装载专利信息
+    public void loadPatent(UploadPatentWebDTO uploadPatentWebDTO) {
+        String country = "";
+        Patent patent = uploadPatentWebDTO.getPatent();
+        StarPatentVO starPatentVO = uploadPatentWebDTO.getStarPatentVO();
+        //装载专利类型
+        Integer patentType = starPatentVO.getPT();
+        this.loadPatentType(patent, patentType);
+        //装载申请号
+        this.loadApplicationNo(patent, starPatentVO.getAN());
+        //装载公告号
+        this.loadGrantNo(patent, starPatentVO.getPN(), starPatentVO.getGN());
+        //装载公开号
+        this.loadPublicNo(patent, starPatentVO.getPN(), starPatentVO.getGN());
+
+
+        this.loadCountry(patent, true);
+
+
+        //装载申请人地址
+        this.loadApplicantAddr(patent, starPatentVO.getDZ(), starPatentVO.getCO());
+
+        //装载IPC分类号
+        this.loadPatentIPC(patent, starPatentVO.getMC(), starPatentVO.getIC());
+
+
+        //装载摘要
+        this.loadAbstractStr(patent, starPatentVO.getAB());
+
+        //装载申请日
+        if (starPatentVO.getAD() != null && !starPatentVO.getAD().equals("")) {
+            Date date = DateUtils.strToDate(starPatentVO.getAD());
+            patent.setAppDate(date);
+        }
+
+        //装载发明人
+        this.loadInventor(patent, starPatentVO.getIV());
+
+        //装载申请人
+        this.loadApplicant(patent, starPatentVO.getPA());
+
+        //装载代理人
+        this.loadAgent(patent, starPatentVO.getAT());
+
+        //装载代理机构
+        this.loadAgency(patent, starPatentVO.getAGN());
+
+
+        //装载公告日
+        this.loadGrantDate(patent, starPatentVO.getPD(), starPatentVO.getGD());
+        //装载公开日
+        this.loadPublicDate(patent, starPatentVO.getPD(), starPatentVO.getGD());
+
+        //装载标题
+        this.loadTitle(patent, starPatentVO.getTI());
+
+        //装载权利人
+        this.loadRightHolder(patent, starPatentVO.getPE());
+
+        //装载法律状态(os_patent表status字段值)
+        this.loadPatentStatus(patent, starPatentVO.getLG());
+        patent.setAppCountry(country);
+    }
+
+
+    // 装载世界专利
+    public void loadWorldPatent(String worldPatentZhuLuStr, Patent patent) {
+        List<StarPatentVO> worldPatentZhuLus = JSON.parseArray(worldPatentZhuLuStr, StarPatentVO.class);
+        StarPatentVO worldPatentZhuLu = worldPatentZhuLus.get(0);
+        //装载申请号
+        this.loadApplicationNo(patent, worldPatentZhuLu.getEpoAppNo());
+
+        //装载公开号
+        this.loadPublicNo(patent, worldPatentZhuLu.getDocdbPubNo(), null);
+
+        this.loadCountry(patent, 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());
+
+        //装载申请人
+        this.loadApplicant(patent, worldPatentZhuLu.getPA());
+
+        //装载发明人
+        this.loadInventor(patent, worldPatentZhuLu.getIV());
+
+        //装载优先权号、优先权国家、优先权日
+        this.loadPriorities(patent, worldPatentZhuLu.getPR());
+
+        //装载标题
+        this.loadTitle(patent, worldPatentZhuLu.getTitle());
+
+        //装载摘要
+        this.loadAbstractStr(patent, worldPatentZhuLu.getAbstract());
+    }
+
+    /**
+     * 装载申请人地址
+     *
+     * @param patent
+     * @param address
+     * @param proviceStr
+     */
+    public void loadApplicantAddr(Patent patent, String address, String proviceStr) {
+        //装载申请人地址
+        if (patent.getApplicantAddr() == null) {
+            if (address != null && !address.equals("")) {
+                PersonAddress personAddress = AddressSplitter.splitAddress(address, proviceStr);
+                patent.setApplicantAddr(personAddress);
+            }
+        }
+    }
+
+    /**
+     * 装载代理人
+     *
+     * @param patent
+     * @param agentStr
+     */
+    public void loadAgent(Patent patent, String agentStr) {
+        if (patent.getAgent() == null || patent.getAgent().size() == 0) {
+            if (agentStr != null && !agentStr.equals("")) {
+                List<String> patentAgents = Arrays.asList(agentStr.split(";"));
+                if (patentAgents != null && patentAgents.size() != 0) {
+                    patent.setAgent(patentAgents);
+                }
+            }
+        }
+
+    }
+
+    /**
+     * 装载专利类型
+     *
+     * @param patent
+     * @param patentType
+     */
+    public void loadPatentType(Patent patent, Integer patentType) {
+        //装载专利类型
+        if (patentType != null) {
+            patent.setPatentType(patentType.toString());
+        }
+    }
+
+    /**
+     * 装载简单法律状态
+     *
+     * @param patent
+     * @param status
+     */
+    public void loadPatentStatus(Patent patent, Integer status) {
+        if (status != null) {
+            //1有效(有权)2失效(无权)3审中(审中)
+            patent.setSimpleStatus(status.toString());
+        }
+
+    }
+
+    /**
+     * 装载优先权
+     *
+     * @param patent
+     * @param pr
+     */
+    public void loadPriorities(Patent patent, String pr) {
+        //装载优先权号、优先权国家、优先权日
+        if (pr != null && pr != "") {
+            String[] prStrs = pr.split(" ");
+            String priorityNo = prStrs[0];
+            String prDate = "";
+            if (prStrs.length > 1) {
+                prDate = prStrs[1];
+            }
+            Priorities priorities = new Priorities();
+            priorities.setPriorityNo(priorityNo);
+            String pCountry = priorityNo.substring(0, 2);
+            priorities.setPriorityCountry(pCountry);
+            //装载优先权日
+            if (prDate != null) {
+                String a = DateUtils.strToStr(prDate, "yyyy-MM-dd");
+                priorities.setPriorityDate(a);
+            }
+            patent.setPriorities(Arrays.asList(priorities));
+        }
+    }
+
+    /**
+     * 装载发明人
+     *
+     * @param patent
+     * @param inventors
+     */
+    public void loadInventor(Patent patent, String inventors) {
+        if (patent.getInventor() == null || patent.getInventor().size() == 0) {
+
+            if (inventors != null && !inventors.equals("")) {
+                List<String> patentInventorNames = Arrays.asList(inventors.split(";"));
+                List<PatentPerson> patentPeople = new ArrayList<>();
+                for (int i = 0; i < patentInventorNames.size(); i++) {
+                    PatentPerson patentPerson = new PatentPerson();
+                    patentPerson.setOrder(0);
+                    patentPerson.setType("1");
+                    patentPerson.setName(patentInventorNames.get(i));
+                    patentPeople.add(patentPerson);
+                }
+                patent.setInventor(patentPeople);
+            }
+        }
+    }
+
+    /**
+     * 装载ipc分类号
+     *
+     * @param patent
+     * @param mainIpc
+     * @param ipcs
+     */
+    public void loadPatentIPC(Patent patent, String mainIpc, String ipcs) {
+        //装载IPC分类号
+        if (ipcs != null && !ipcs.equals("")) {
+            List<PatentClassify> patentClassifies = new ArrayList<>();
+            List<String> ipcArr = Arrays.asList(ipcs.split(";"));
+            for (int i = 0; i < ipcArr.size(); i++) {
+                PatentClassify patentClassify = PatentClassifySplitter.split(ipcArr.get(i));
+                patentClassifies.add(patentClassify);
+            }
+            patent.setIpc(patentClassifies);
+            if (mainIpc == null || mainIpc.equals("")) {
+                if (patentClassifies.size() > 0) {
+                    patent.setMipc(patentClassifies.get(0));
+                }
+            } else {
+                PatentClassify patentClassify = PatentClassifySplitter.split(mainIpc);
+                patent.setMipc(patentClassify);
+            }
+        } else {
+            if (mainIpc != null || !mainIpc.equals("")) {
+                PatentClassify patentClassify = PatentClassifySplitter.split(mainIpc);
+                patent.setMipc(patentClassify);
+                patent.setIpc(Arrays.asList(patentClassify));
+            }
+        }
+    }
+
+    /**
+     * 装载loc分类号
+     *
+     * @param patent
+     * @param mainIpc
+     * @param ipcs
+     */
+    public void loadPatentLoc(Patent patent, String mainIpc, String ipcs) {
+        //装载Loc分类号
+        if (ipcs != null && !ipcs.equals("")) {
+            List<PatentClassify> patentClassifies = new ArrayList<>();
+            List<String> ipcArr = Arrays.asList(ipcs.split(";"));
+            for (int i = 0; i < ipcArr.size(); i++) {
+                PatentClassify patentClassify = PatentClassifySplitter.split(ipcArr.get(i));
+                patentClassifies.add(patentClassify);
+            }
+            patent.setLoc(patentClassifies);
+
+            if (mainIpc == null || mainIpc.equals("")) {
+                if (patentClassifies.size() > 0) {
+                    patent.setMloc(patentClassifies.get(0));
+                }
+            } else {
+                PatentClassify patentClassify = PatentClassifySplitter.split(mainIpc);
+                patent.setMloc(patentClassify);
+            }
+        } else {
+            if (mainIpc != null || !mainIpc.equals("")) {
+                PatentClassify patentClassify = PatentClassifySplitter.split(mainIpc);
+                patent.setMloc(patentClassify);
+                patent.setLoc(Arrays.asList(patentClassify));
+            }
+        }
+    }
+
+    /**
+     * 装载cpc分类号
+     *
+     * @param patent
+     * @param cpcs
+     */
+    public void loadPatentCPC(Patent patent, String cpcs) {
+        //装载IPC分类号
+        if (cpcs != null && !cpcs.equals("")) {
+            List<PatentClassify> patentClassifies = new ArrayList<>();
+            List<String> cpcArr = Arrays.asList(cpcs.split(";"));
+            for (int i = 0; i < cpcArr.size(); i++) {
+                PatentClassify patentClassify = PatentClassifySplitter.split(cpcArr.get(i));
+                patentClassifies.add(patentClassify);
+            }
+            patent.setIpc(patentClassifies);
+        }
+    }
+
+    /**
+     * 装载摘要
+     *
+     * @param patent
+     * @param abstractStr
+     */
+    public void loadAbstractStr(Patent patent, String abstractStr) {
+        //装载摘要
+        if (abstractStr != null && !abstractStr.equals("")) {
+            Text text = new Text();
+            text.setLanguage(patent.getAppCountry());
+            text.setIfOrigin(true);
+            text.setTextContent(abstractStr);
+            patent.setAbstractStr(Arrays.asList(text));
+        }
+    }
+
+
+    /**
+     * 装载标题
+     *
+     * @param patent
+     * @param title
+     */
+    public void loadTitle(Patent patent, String title) {
+        if (title != null && !title.equals("")) {
+            Text text = new Text();
+            text.setLanguage(patent.getAppCountry());
+            text.setIfOrigin(true);
+            text.setTextContent(title);
+            patent.setTitle(Arrays.asList(text));
+        }
+    }
+
+    /**
+     * 装载公开日
+     *
+     * @param patent
+     * @param publicDate
+     */
+    public void loadPublicDate(Patent patent, String publicDate, String grantDate) {
+        //装载公开日
+        if (publicDate != null && !publicDate.equals("")) {
+            Date date = DateUtils.strToDate(publicDate);
+            patent.setPublicDate(date);
+        } else if (!patent.getPatentType().equals("1") && !patent.getPatentType().equals("8")) {
+            if (grantDate != null && !grantDate.trim().equals("")) {
+                Date date = DateUtils.strToDate(grantDate);
+                patent.setPublicDate(date);
+            }
+        }
+    }
+
+
+    /**
+     * 装载公开日
+     *
+     * @param patent
+     * @param
+     */
+    public void loadGrantDate(Patent patent, String publicDate, String grantDate) {
+        if (grantDate != null && !grantDate.equals("")) {
+            Date date = DateUtils.strToDate(grantDate);
+            patent.setGrantDate(date);
+        } else if (!patent.getPatentType().equals("1") && !patent.getPatentType().equals("8")) {
+            if (publicDate != null && !publicDate.trim().equals("")) {
+                Date date = DateUtils.strToDate(publicDate);
+                patent.setGrantDate(date);
+            }
+        }
+    }
+
+    /**
+     * 装载公开号
+     *
+     * @param patent
+     * @param publicNo
+     */
+    public void loadPublicNo(Patent patent, String publicNo, String grantNo) {
+        publicNo = publicNo.trim();
+        if (publicNo != null && !publicNo.equals("")) {
+            patent.setPublicNo(publicNo);
+        } else if (!patent.getPatentType().equals("1") && !patent.getPatentType().equals("8")) {
+            if (grantNo != null && !grantNo.equals("")) {
+                patent.setPublicNo(grantNo);
+            }
+        }
+    }
+
+    /**
+     * 装载公告号
+     *
+     * @param patent
+     * @param grantNo
+     */
+    public void loadGrantNo(Patent patent, String publicNo, String grantNo) {
+        if (grantNo != null && !grantNo.equals("")) {
+            patent.setGrantNo(grantNo);
+        } else if (!patent.getPatentType().equals("1") && !patent.getPatentType().equals("8")) {
+            if (publicNo != null && !publicNo.equals("")) {
+                patent.setGrantNo(publicNo);
+            }
+        }
+    }
+
+    /**
+     * 装载申请号
+     *
+     * @param patent
+     * @param appNo
+     */
+    public void loadApplicationNo(Patent patent, String appNo) {
+        if (appNo != null && !appNo.equals("")) {
+            patent.setAppNo(appNo);
+        }
+    }
+
+
+    /**
+     * 装载权利人
+     *
+     * @param patent
+     * @param rightHolder
+     */
+    public void loadRightHolder(Patent patent, String rightHolder) {
+        //装载权利人
+        if (rightHolder != null && !rightHolder.equals("")) {
+            List<String> names = Arrays.asList(rightHolder.split(";"));
+            List<PatentPerson> patentPeople = new ArrayList<>();
+            for (int i = 0; i < names.size(); i++) {
+                String name = names.get(i);
+                String type = this.getPersonType(name, patent.getInventor());
+                PatentPerson patentPerson = new PatentPerson();
+                patentPerson.setOrder(0);
+                patentPerson.setType(type);
+                patentPerson.setName(names.get(i));
+                patentPeople.add(patentPerson);
+            }
+            patent.setRightHolder(patentPeople);
+        } else if (patent.getApplicant() != null) {
+            patent.setRightHolder(patent.getApplicant());
+        }
+    }
+
+    /**
+     * 装载代理机构
+     * @param patent
+     * @param agency
+     */
+    public void loadAgency(Patent patent, String agency) {
+        if (agency != null && !agency.equals("")) {
+            patent.setAgency(agency);
+        }
+    }
+
+
+    /**
+     * 装载申请人
+     *
+     * @param patent
+     * @param applicant
+     */
+    public void loadApplicant(Patent patent, String applicant) {
+        if (applicant != null && !applicant.equals("")) {
+            List<String> names = Arrays.asList(applicant.split(";"));
+            List<PatentPerson> patentPeople = new ArrayList<>();
+            for (int i = 0; i < names.size(); i++) {
+                String name = names.get(i);
+                String type = this.getPersonType(name, patent.getInventor());
+                PatentPerson patentPerson = new PatentPerson();
+                patentPerson.setOrder(i + 1);
+                patentPerson.setType(type);
+                patentPerson.setName(names.get(i));
+                patentPeople.add(patentPerson);
+            }
+            patent.setApplicant(patentPeople);
+        }
+    }
+
+    /**
+     * 装载申请日
+     *
+     * @param patent
+     * @param appDate
+     */
+    public void loadAppDate(Patent patent, String appDate) {
+        if (appDate != null && !appDate.equals("")) {
+            Date date = DateUtils.strToDate(appDate);
+            patent.setAppDate(date);
+        }
+    }
+
+    /**
+     * 装载申请国家
+     *
+     * @param patent
+     * @param ifCN
+     */
+    public void loadCountry(Patent patent, boolean ifCN) {
+        if (ifCN) {
+            patent.setAppCountry("CN");
+        } else {
+            String appNo = patent.getAppNo();
+            String publicNo = patent.getPublicNo();
+            String grantNo = patent.getGrantNo();
+            String useNo = null;
+            if (grantNo != null) {
+                useNo = grantNo;
+            } else if (publicNo != null) {
+                useNo = publicNo;
+            } else if (appNo != null) {
+                useNo = appNo;
+            }
+            if (useNo != null) {
+                // 定义正则表达式,^[A-Za-z]+ 表示从字符串开头匹配一个或多个英文字母
+                Pattern pattern = Pattern.compile("^[A-Za-z]+");
+                Matcher matcher = pattern.matcher(useNo);
+                if (matcher.find()) {
+                    // 如果找到匹配项,则获取匹配的内容
+                    String prefix = matcher.group();
+                    patent.setAppCountry(prefix);
+                }
+            }
+        }
+    }
+
+    /**
+     * 装载中国专利号
+     *
+     * @param patent
+     */
+    public void loadCNPatentNo(Patent patent) {
+        patent.setPatentNo(patent.getAppNo());
+    }
+
+
+    /**
+     * 装载世界专利号
+     */
+    public void loadWorldPatentNo(Patent patent) {
+        String publicNo = patent.getPublicNo();
+        String grantNo = patent.getGrantNo();
+        if (grantNo != null) {
+            patent.setPatentNo(grantNo);
+        } else if (publicNo != null) {
+            patent.setPatentNo(publicNo);
+        }
+    }
+
+
+    /**
+     * 装载说明书
+     *
+     * @param patent
+     * @param cnFullXmlStr
+     */
+    private void loadFullText(Patent patent, String cnFullXmlStr) {
+        try {
+            //若没有取到全文文本,即取不到说明书文本,则将当前申请号或专利号和备注信息记录到问题记录表
+            if (cnFullXmlStr.equals("")) {
+                return;
+            }
+
+            SAXReader reader = new SAXReader();
+            reader.setEntityResolver(new IgnoreDTDEntityResolver());
+            Reader stringReader = new StringReader(cnFullXmlStr);
+            Document document = reader.read(stringReader);
+            XPath xpath = document.createXPath("//description//p");
+            List<Element> elements = (List<Element>) xpath.selectNodes(document);
+            if (elements.size() == 0) {
+                xpath = document.createXPath("//business:Description//base:Paragraphs");
+                elements = (List<Element>) xpath.selectNodes(document);
+            }
+            List<String> fullTexts = new ArrayList<>();
+            Integer count = 1;
+            List<String> ts = this.getTitleStrs();
+            for (Element item : elements) {
+                String fullText = item.getText().replaceAll("<br/>", "");
+                if (!ts.contains(fullText.trim())) {
+                    String formattedNum = String.format("%04d", count);
+                    fullText = "[" + formattedNum + "]" + fullText;
+                    count++;
+                }
+                fullText = fullText.replaceAll("\r\n|\r|\n| ", "");
+                if (!fullText.trim().equals("")) {
+                    fullTexts.add(fullText);
+                }
+            }
+            String fullText = "";
+            if (fullTexts.size() != 0) {
+                fullText = cn.cslg.pas.common.utils.StringUtils.join(fullTexts, "\r\n");
+            }
+            Text text = new Text();
+            text.setIfOrigin(true);
+            text.setTextContent(fullText);
+            text.setLanguage(patent.getAppCountry());
+            patent.setPublicFullText(Arrays.asList(text));
+
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+
+    private List<String> getTitleStrs() {
+        String t1 = "技术领域";
+        String t2 = "发明内容";
+        String t3 = "附图说明";
+        String t4 = "具体实施方式";
+        String t5 = "背景技术";
+        String t6 = "实用新型内容";
+        String t7 = "【技术领域】";
+        String t8 = "【背景技术】";
+        String t9 = "【发明内容】";
+        String t10 = "【附图说明】";
+        String t11 = "【具体实施方式】";
+        List<String> ts = Arrays.asList(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11);
+        return ts;
+    }
+
+
+    /**
+     * 装载权利要求
+     *
+     * @param patent
+     * @param cnFullXmlStr
+     */
+    public void loadClaim(Patent patent, String cnFullXmlStr) {
+        try {
+            if (cnFullXmlStr != null && cnFullXmlStr != "") {
+                SAXReader reader = new SAXReader();
+                reader.setEntityResolver(new IgnoreDTDEntityResolver());
+                Reader stringReader = new StringReader(cnFullXmlStr);
+                Document document = reader.read(stringReader);
+                XPath xpath = document.createXPath("//claim-text");
+                List<Element> element = (List<Element>) xpath.selectNodes(document);
+                if (element.size() == 0) {
+                    xpath = document.createXPath("//business:ClaimText");
+                    element = (List<Element>) xpath.selectNodes(document);
+                }
+                List<String> reClaims = new ArrayList<>();
+                element.forEach(item -> {
+                    String claim = item.getText();
+                    claim = claim.replaceAll("\r\n|\r|\n|\t| ", "");
+                    reClaims.add(claim);
+                });
+                String reClaim = "";
+                if (reClaims.size() != 0) {
+                    reClaim = cn.cslg.pas.common.utils.StringUtils.join(reClaims, "@##");
+                }
+                //装载权利要求原文
+                Text text = new Text();
+                text.setLanguage("CN");
+                text.setTextContent(reClaim);
+                text.setIfOrigin(true);
+                patent.setClaim(Arrays.asList(text));
+
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+
+    public String getPersonType(String name, List<PatentPerson> personList) {
+        List<String> names = new ArrayList<>();
+        if (personList != null) {
+            names = personList.stream().map(PatentPerson::getName).collect(Collectors.toList());
+            if (names.contains(name)) {
+                return "1";
+            } else {
+                return this.getPersonTypeByName(name);
+            }
+        } else {
+            return this.getPersonTypeByName(name);
+        }
+    }
+
+    public String getPersonTypeByName(String name) {
+        if (SCHOOL.contains(name)) {
+            return "3";
+        } else if (INSTITUTES.contains(name)) {
+            return "4";
+        } else if (COMPANY.contains(name)) {
+            return "2";
+        } else {
+            return "1";
+        }
+    }
+    public void addLegalEvent(Patent patent){
+
+    }
+}

+ 2 - 2
src/main/resources/application-dev.yml

@@ -61,8 +61,8 @@ spring:
     #初始化表结构
     jdbc:
       initialize-schema: always
-authorUrl: http://localhost:8871
-PCSUrl: http://localhost:8871
+authorUrl: http://localhost:8885
+PCSUrl: http://localhost:8885
 #OPSUrl: http://192.168.2.24:5001
 OPSUrl: http://139.224.24.90:5001
 PASUrl: http://localhost:8879