Bläddra i källkod

Merge remote-tracking branch 'origin/master'

xiexiang 1 år sedan
förälder
incheckning
759e182058
22 ändrade filer med 863 tillägg och 155 borttagningar
  1. 4 4
      src/main/java/cn/cslg/pas/common/config/WebSocketConfig.java
  2. 1 0
      src/main/java/cn/cslg/pas/common/dto/UploadPatentWebDTO.java
  3. 178 0
      src/main/java/cn/cslg/pas/common/vo/ChinaLeagalStatus.java
  4. 26 0
      src/main/java/cn/cslg/pas/common/vo/FamilyPatentNo.java
  5. 6 0
      src/main/java/cn/cslg/pas/common/vo/StarPatentVO.java
  6. 33 0
      src/main/java/cn/cslg/pas/domain/es/EventMessage.java
  7. 4 23
      src/main/java/cn/cslg/pas/domain/es/LegalEvent.java
  8. 3 3
      src/main/java/cn/cslg/pas/domain/es/Patent.java
  9. 1 1
      src/main/java/cn/cslg/pas/domain/es/PatentQuoteMessage.java
  10. 2 2
      src/main/java/cn/cslg/pas/domain/es/QuotePatent.java
  11. 327 27
      src/main/java/cn/cslg/pas/service/business/es/EsService.java
  12. 42 15
      src/main/java/cn/cslg/pas/service/common/PatentStarApiService.java
  13. 67 22
      src/main/java/cn/cslg/pas/service/importPatent/GetCataloguingFromWebThread.java
  14. 4 0
      src/main/java/cn/cslg/pas/service/importPatent/GetPatentPDFFromWebThread.java
  15. 4 0
      src/main/java/cn/cslg/pas/service/importPatent/GetPatentPictureFromWebThread.java
  16. 11 2
      src/main/java/cn/cslg/pas/service/importPatent/GetRightAndFullTextFromWebThread.java
  17. 56 33
      src/main/java/cn/cslg/pas/service/importPatent/ImportFromWebToEsService.java
  18. 20 0
      src/main/java/cn/cslg/pas/service/importPatent/SavePatentToEsThread.java
  19. 14 2
      src/main/resources/jsons/importTaskConfig.json
  20. 46 19
      src/test/java/cn/cslg/pas/service/EsServiceTests.java
  21. 2 2
      src/test/java/cn/cslg/pas/service/EventServiceTests.java
  22. 12 0
      src/test/java/cn/cslg/pas/service/PatentStarServiceTests.java

+ 4 - 4
src/main/java/cn/cslg/pas/common/config/WebSocketConfig.java

@@ -6,8 +6,8 @@ import org.springframework.web.socket.server.standard.ServerEndpointExporter;
 
 @Configuration
 public class WebSocketConfig {
-    @Bean
-    public ServerEndpointExporter serverEndpointExporter() {
-        return new ServerEndpointExporter();
-    }
+//    @Bean
+//    public ServerEndpointExporter serverEndpointExporter() {
+//        return new ServerEndpointExporter();
+//    }
 }

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

@@ -3,6 +3,7 @@ package cn.cslg.pas.common.dto;
 import cn.cslg.pas.common.vo.StarPatentVO;
 import cn.cslg.pas.common.vo.UploadParamsVO;
 import cn.cslg.pas.domain.es.Patent;
+import com.baomidou.mybatisplus.annotation.DbType;
 import lombok.Data;
 import org.apache.poi.ss.usermodel.PictureData;
 

+ 178 - 0
src/main/java/cn/cslg/pas/common/vo/ChinaLeagalStatus.java

@@ -0,0 +1,178 @@
+package cn.cslg.pas.common.vo;
+
+import lombok.Data;
+import lombok.experimental.Accessors;
+
+import java.io.Serializable;
+
+/**
+ * 专利之星获得中国专利法律状态接口实体类
+ *
+ * @Author chenyu
+ * @Date 2023/6/28
+ */
+@Accessors(chain = true)
+@Data
+public class ChinaLeagalStatus implements Serializable {
+    /**
+     * 流水号
+     */
+    private String ID;
+    /**
+     * 卷期号
+     */
+    private String JUANQI;
+    /**
+     * 专利类型
+     */
+    private String PatentType;
+    /**
+     * 法律状态日期
+     */
+    private String LegalDate;
+    /**
+     * 法律状态
+     */
+    private String LegalStatus;
+    /**
+     * 详细法律状态
+     */
+    private String LegalStatusInfo;
+    /**
+     * 法律状态编码
+     */
+    private String LegalCode;
+    /**
+     * 卷
+     */
+    private String VOL;
+    /**
+     * 期
+     */
+    private String NUM;
+    /**
+     * 页码
+     */
+    private String PAG;
+    /**
+     * IPC分类
+     */
+    private String IPC;
+    /**
+     * 申请号
+     */
+    private String SHENQINGH;
+    /**
+     * 申请日
+     */
+    private String SHENQINGR;
+    /**
+     * 公开日
+     */
+    private String SHENQINGGBR;
+    /**
+     * 公告日
+     */
+    private String SHOUQUANGGR;
+    /**
+     * 无效登记号
+     */
+    private String WUXIAOXGJDH;
+    /**
+     * 无效登记日
+     */
+    private String WUXIAOXGJDR;
+    /**
+     * 终止日
+     */
+    private String ZHONGZHIR;
+    /**
+     * 放弃生效日
+     */
+    private String FANGQISXR;
+    /**
+     * 原名称
+     */
+    private String YUANMINGC;
+    /**
+     * 原公告号
+     */
+    private String YUANGONGGR;
+    /**
+     * 变更编号
+     */
+    private String BIANGENGSXCODE;
+    /**
+     * 变更事项
+     */
+    private String BIANGENGSX;
+    /**
+     * 变更前
+     */
+    private String BIANGENGQ;
+    /**
+     * 变更后
+     */
+    private String BIANGENGH;
+    /**
+     * 登记生效日
+     */
+    private String DENGJISXR;
+    /**
+     * 合同备案号
+     */
+    private String HETONGBAH;
+    /**
+     * 让与人
+     */
+    private String RANGYUR;
+    /**
+     * 受让人
+     */
+    private String SHOURANGR;
+    /**
+     * 专利名称
+     */
+    private String ZHUANLIMC;
+    /**
+     * 许可种类
+     */
+    private String XUKEZL;
+    /**
+     * 备案日期
+     */
+    private String BEIANRQ;
+    /**
+     * 变更日
+     */
+    private String BIANGENGR;
+    /**
+     * 解除日
+     */
+    private String JIECHUR;
+    /**
+     * 登记号
+     */
+    private String DENGJIH;
+    /**
+     * 出质人
+     */
+    private String CHUZHIR;
+    /**
+     * 质权人
+     */
+    private String ZHIQUANR;
+    /**
+     * 收件日
+     */
+    private String SHOUJIANR;
+    /**
+     * 文件名称
+     */
+    private String WENJIANMC;
+    /**
+     * 详细信息
+     */
+    private String DETAIL;
+
+}

+ 26 - 0
src/main/java/cn/cslg/pas/common/vo/FamilyPatentNo.java

@@ -0,0 +1,26 @@
+package cn.cslg.pas.common.vo;
+
+import lombok.Data;
+import lombok.experimental.Accessors;
+
+import java.io.Serializable;
+
+/**
+ * 专利之星获得同族专利接口实体类
+ *
+ * @Author chenyu
+ * @Date 2023/6/27
+ */
+@Accessors(chain = true)
+@Data
+public class FamilyPatentNo implements Serializable {
+    /**
+     * 同族专利(包含自身,以分号;分隔的多个专利号)
+     */
+    private String familyinfo;
+    /**
+     * 同族专利数量
+     */
+    private String familycount;
+
+}

+ 6 - 0
src/main/java/cn/cslg/pas/common/vo/StarPatentVO.java

@@ -132,6 +132,12 @@ public class StarPatentVO implements Serializable {
     @JSONField(name = "PRD")
     private String priorityDate;
 
+    /**
+     * 优先权日
+     */
+    @JSONField(name = "CC")
+    private String quoteNos;
+
     private List<PatentInventor> inventor;
     private List<String> ipcList;
     private List<PatentApplicant> applicant;

+ 33 - 0
src/main/java/cn/cslg/pas/domain/es/EventMessage.java

@@ -0,0 +1,33 @@
+package cn.cslg.pas.domain.es;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import lombok.Data;
+
+import java.util.List;
+
+@Data
+public class EventMessage {
+    /**
+     * code码
+     */
+    @JsonProperty("code")
+    private String code;
+
+    /**
+     * 名称
+     */
+    @JsonProperty("name")
+    private String name;
+
+    /**
+     * 描述
+     */
+    @JsonProperty("description")
+    private String description;
+
+    /**
+     * 发生时间
+     */
+    @JsonProperty("event_date")
+    private String eventDate;
+}

+ 4 - 23
src/main/java/cn/cslg/pas/domain/es/LegalEvent.java

@@ -18,32 +18,13 @@ import java.util.List;
 @NoArgsConstructor
 public class LegalEvent {
 
-    /**
-     * code码
-     */
-    @JsonProperty("code")
-    private String code;
-
-    /**
-     * 名称
-     */
-    @JsonProperty("name")
-    private String name;
 
-    /**
-     * 描述
-     */
-    @JsonProperty("description")
-    private String description;
+    @JsonProperty("event_message")
+    private List<EventMessage> eventMessages;
     /**
      * 专利号
      */
-    @JsonProperty("patent_no")
-    private String patentNo;
+    @JsonProperty("app_no")
+    private String appNo;
 
-    /**
-     * 发生时间
-     */
-    @JsonProperty("event_date")
-    private String eventDate;
 }

+ 3 - 3
src/main/java/cn/cslg/pas/domain/es/Patent.java

@@ -87,7 +87,7 @@ public class Patent {
      * 公开日
      */
     @JsonProperty("public_date")
-    private Integer publicDate;
+    private Date publicDate;
 
     /**
      * 申请号
@@ -99,7 +99,7 @@ public class Patent {
      * 申请日
      */
     @JsonProperty("app_date")
-    private Integer appDate;
+    private Date appDate;
 
     /**
      * 授权号
@@ -111,7 +111,7 @@ public class Patent {
      * 授权日
      */
     @JsonProperty("grant_date")
-    private String grantDate;
+    private Date grantDate;
 
     /**
      * 优先权

+ 1 - 1
src/main/java/cn/cslg/pas/domain/es/PatentQuoteMessage.java

@@ -28,7 +28,7 @@ public class PatentQuoteMessage {
      * 被引用专利
      */
     @JsonProperty("quoted_patent")
-    private QuotePatent quoted_Patent;
+    private List<QuotePatent> quotedPatents;
 
     /**
      * 引用来源

+ 2 - 2
src/main/java/cn/cslg/pas/domain/es/QuotePatent.java

@@ -27,6 +27,6 @@ public class QuotePatent {
     @JsonProperty("right_holder")
     private List<PatentPerson> rightHolder;
 
-    @JsonProperty("patent_no")
-    private String patentNo;
+    @JsonProperty("app_no")
+    private String appNo;
 }

+ 327 - 27
src/main/java/cn/cslg/pas/service/business/es/EsService.java

@@ -4,6 +4,7 @@ import cn.cslg.pas.common.core.base.IfConstant;
 import cn.cslg.pas.common.dto.PatentColumnDTO;
 import cn.cslg.pas.common.dto.PatentDTO;
 //import cn.cslg.pas.common.dto.business.EsPatentFamilyDTO;
+import cn.cslg.pas.common.dto.PatentStarListDTO;
 import cn.cslg.pas.common.dto.business.EsPatentFamilyDTO;
 import cn.cslg.pas.common.model.request.MapRequest;
 import cn.cslg.pas.common.model.request.OrderDTO;
@@ -12,10 +13,11 @@ import cn.cslg.pas.common.model.request.StringRequest;
 import cn.cslg.pas.common.utils.parseQueryToTree.expressManager;
 import cn.cslg.pas.common.utils.parseQueryToTree.operateNode;
 import cn.cslg.pas.common.utils.parseQueryToTree.treeNode;
+import cn.cslg.pas.common.vo.ChinaLeagalStatus;
 import cn.cslg.pas.common.vo.PatentWithIdVO;
-import cn.cslg.pas.domain.es.FamilyPatent;
-import cn.cslg.pas.domain.es.Patent;
-import cn.cslg.pas.domain.es.PatentFamilyMessage;
+import cn.cslg.pas.common.vo.StarPatentVO;
+import cn.cslg.pas.domain.es.*;
+import cn.cslg.pas.service.common.PatentStarApiService;
 import cn.cslg.pas.service.query.FormatQueryService;
 import co.elastic.clients.elasticsearch.ElasticsearchClient;
 import co.elastic.clients.elasticsearch._types.SortOrder;
@@ -24,6 +26,7 @@ import co.elastic.clients.elasticsearch.core.*;
 import co.elastic.clients.elasticsearch.core.search.Hit;
 import co.elastic.clients.elasticsearch.core.search.HitsMetadata;
 import co.elastic.clients.elasticsearch.core.search.TotalHits;
+import com.alibaba.fastjson.JSON;
 import lombok.RequiredArgsConstructor;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -33,8 +36,10 @@ import org.springframework.util.CollectionUtils;
 
 import java.io.IOException;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.List;
 import java.util.Map;
+import java.util.stream.Collectors;
 
 
 @Service
@@ -45,6 +50,9 @@ public class EsService {
 
     @Autowired
     private FormatQueryService formatQueryService;
+    @Autowired
+    private PatentStarApiService patentStarApiService;
+
 
     /**
      * @param patent
@@ -175,7 +183,7 @@ public class EsService {
 
         //分页
         if (current > 0 && size > 0) {
-            builder.from((current.intValue()-1)*size.intValue()).size(size.intValue());
+            builder.from((current.intValue() - 1) * size.intValue()).size(size.intValue());
         }
 
         SearchResponse<Patent> response = client.search(builder.build(), Patent.class);
@@ -289,6 +297,7 @@ public class EsService {
 
     /**
      * 查询是否存在专利
+     *
      * @param parentId
      * @param projectId
      * @return
@@ -313,19 +322,21 @@ public class EsService {
 
     /**
      * 查询同族
+     *
      * @param nos
      * @param type
      * @return
      * @throws IOException
      */
-    public EsPatentFamilyDTO selectEsPatentFamily(List<String> nos, String type) throws IOException {
+    public EsPatentFamilyDTO addEsPatentFamily(List<String> nos, String type) throws IOException {
         EsPatentFamilyDTO esDTO = new EsPatentFamilyDTO();
 
-        //不存在no
         List<String> absentList = new ArrayList<>();
-        //存在no
-        List<String> existList = new ArrayList<>();
 
+        PatentFamilyMessage patentFamilyMessage = null;
+        String id = "";
+
+        //遍历,根据专利号查询同族
         for (String no : nos) {
             SearchRequest.Builder builder = new SearchRequest.Builder();
             //设置查询索引
@@ -338,41 +349,95 @@ public class EsService {
             Query q3 = QueryBuilders.term(t -> t.field("grant_no").value(no));
             //类型
             Query q4 = QueryBuilders.term(t -> t.field("family_type").value(type));
-            Query bool = QueryBuilders.bool(i -> i.must(q4).should(q1, q2,q3));
+            Query bool = QueryBuilders.bool(i -> i.must(q4).should(q1, q2, q3));
             builder.query(bool);
             SearchResponse<PatentFamilyMessage> response = client.search(builder.build(), PatentFamilyMessage.class);
             long total = response.hits().total().value();
             if (total > 0) {
                 List<FamilyPatent> list = new ArrayList<>();
                 List<Hit<PatentFamilyMessage>> hits = response.hits().hits();
-                for (Hit<PatentFamilyMessage> hit : hits) {
-                    String id = hit.id();
-                    PatentFamilyMessage esMess = hit.source();
-                    list.addAll(esMess.getPatent());
-                    esDTO.setPatentFamilyId(id);
-                }
-                esDTO.setFamilyNum(list.size());
-                existList.add(no);
-            } else {
-                //获取不存在的号码
-                absentList.add(no);
+                Hit<PatentFamilyMessage> hit = hits.get(0);
+                id = hit.id();
+                patentFamilyMessage = hit.source();
                 break;
             }
         }
-        //todo 判断是否全新/部分
-        if (existList.size() != nos.size()) {
-            if (absentList.size() == nos.size()) {
-                //插入
-            } else {
-                //更新
+
+        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().equals(no) || item.getPublicNo().equals(no) || item.getGrantNo().equals(no))
+                        .findFirst().orElse(null);
+                if (familyPatent == null) {
+                    notInNos.add(no);
+                }
+
             }
         }
+        //当未查询到同族时
+        else {
+            patentFamilyMessage = new PatentFamilyMessage();
+            patentFamilyMessage.setFamilyType(type);
+            patentFamilyMessage.setPatent(new ArrayList<>());
+            notInNos.addAll(nos);
+
+        }
+
+        if (notInNos.size() > 0) {
+            //所有专利号的专利详情
+            List<StarPatentVO> starPatents = new ArrayList<>();
+
+            PatentStarListDTO patentStarListDTO = new PatentStarListDTO();
+            List<PatentStarListDTO> patentStarListDtos = patentStarApiService.splitPatentNoByType(notInNos, patentStarListDTO);
+            while (patentStarListDtos.size() > 0) {
+                PatentStarListDTO patentStarListDTO1 = patentStarListDtos.remove(0);
+                patentStarListDTO1.setPageNum(1);
+                patentStarListDTO1.setRowCount(50);
+                Map<String, Object> resultMap = patentStarApiService.patentStarSearchApi(patentStarListDTO1);
+                if (resultMap == null || (Integer) resultMap.get("total") == 0) {
+                    continue;
+                }
+                starPatents.addAll((List<StarPatentVO>) resultMap.get("records"));
+
+            }
 
+            List<FamilyPatent> patents = new ArrayList<>();
+            starPatents.forEach(item -> {
+                FamilyPatent familyPatent = new FamilyPatent();
+                familyPatent.setAppNo(item.getApplicationNo());
+                familyPatent.setPublicNo(item.getPublicNo());
+                familyPatent.setGrantNo(item.getPublicAccreditNo());
+                patents.add(familyPatent);
+            });
+
+            patentFamilyMessage.getPatent().addAll(patents);
+
+
+            //当id不为null时
+            if (!id.equals("")) {
+
+                this.updatePatentFamily(patentFamilyMessage, id);
+
+            } else {
+                try {
+                    id = this.addPatentFamily(patentFamilyMessage);
+                } catch (Exception e) {
+                }
+
+
+            }
+        }
+        esDTO.setPatentFamilyId(id);
+        esDTO.setFamilyNum(patentFamilyMessage.getPatent().size());
         return esDTO;
     }
 
     /**
      * 添加同族
+     *
      * @param message
      * @return
      * @throws Exception
@@ -388,6 +453,7 @@ public class EsService {
 
     /**
      * 更新同族
+     *
      * @param message
      * @param id
      * @return
@@ -406,7 +472,241 @@ public class EsService {
             return -1;
         }
     }
-}
 
+    /**
+     * 更新专利事务
+     *
+     * @param
+     * @param id
+     * @return
+     */
+    public Integer updateLegalEvent(LegalEvent legalEvent, String id) {
+        UpdateRequest<LegalEvent, LegalEvent> req;
+        req = UpdateRequest.of(
+                b -> b.index("legal_event")
+                        .id(id)
+                        .doc(legalEvent)
+        );
+        try {
+            client.update(req, LegalEvent.class);
+            return 1;
+        } catch (IOException e) {
+            return -1;
+        }
+    }
+
+    /**
+     * 添加法律事务
+     *
+     * @param
+     * @return
+     * @throws Exception
+     */
+    public String addLegalEvent(LegalEvent legalEvent) throws Exception {
+        IndexResponse indexResponse = client.index(i -> i
+                .index("legal_event")
+                .document(legalEvent)
+        );
+        return indexResponse.id();
+
+    }
+
+    /**
+     * 更新专利事务
+     *
+     * @param
+     * @param id
+     * @return
+     */
+    public Integer updateQuotePatent(PatentQuoteMessage patentQuoteMessage, String id) {
+        UpdateRequest<PatentQuoteMessage, PatentQuoteMessage> req;
+        req = UpdateRequest.of(
+                b -> b.index("quote_patent")
+                        .id(id)
+                        .doc(patentQuoteMessage)
+        );
+        try {
+            client.update(req, PatentQuoteMessage.class);
+            return 1;
+        } catch (IOException e) {
+            return -1;
+        }
+    }
+
+    /**
+     * 添加法律事务
+     *
+     * @param
+     * @return
+     * @throws Exception
+     */
+    public String addQuotePatent(PatentQuoteMessage patentQuoteMessage) throws Exception {
+        IndexResponse indexResponse = client.index(i -> i
+                .index("quote_patent")
+                .document(patentQuoteMessage)
+        );
+        return indexResponse.id();
+
+    }
+
+
+    public String addEsQuotePatent(String no, List<String> nos) throws Exception {
+        StarPatentVO starPatentVO = patentStarApiService.getPatentByNo(no);
+        if (starPatentVO == null) {
+            return null;
+        }
+        QuotePatent quotePatent = this.reQuotePatent(starPatentVO);
+        PatentQuoteMessage patentQuoteMessage = null;
+        //根据申请号和
+        String id = "";
+        //根据专利号查询是否有引用信息
+        SearchRequest.Builder builder = new SearchRequest.Builder();
+
+        //设置查询索引
+        builder.index("quote_patent");
+        //申请号
+        Query q1 = QueryBuilders.term(t -> t.field("patent.app_no").value(starPatentVO.getApplicationNo()));
+        Query bool = QueryBuilders.bool(i -> i.must(q1));
+        builder.query(bool);
+        SearchResponse<PatentQuoteMessage> response = client.search(builder.build(), PatentQuoteMessage.class);
+        long total = response.hits().total().value();
+        if (total > 0) {
+            patentQuoteMessage = response.hits().hits().get(0).source();
+            id = response.hits().hits().get(0).id();
+        }
+
+        List<QuotePatent> quotePatents = new ArrayList<>();
+        if (patentQuoteMessage != null && patentQuoteMessage.getQuotedPatents() != null) {
+            quotePatents = patentQuoteMessage.getQuotedPatents();
+
+        }
+
+        for (String patentNo : nos) {
+            StarPatentVO starPatentVO1 = patentStarApiService.getPatentByNo(patentNo);
+            QuotePatent quotePatent1 = null;
+            if (quotePatents.size() > 0) {
+                quotePatent1 = quotePatents.stream()
+                        .filter(item -> item.getAppNo().equals(starPatentVO1.getApplicationNo())).findFirst().orElse(null);
+            }
+            if (quotePatent1 == null) {
+                quotePatent1 = this.reQuotePatent(starPatentVO1);
+                quotePatents.add(quotePatent1);
+            }
+        }
+
+        if (patentQuoteMessage == null) {
+            if (quotePatents.size() != 0) {
+                patentQuoteMessage = new PatentQuoteMessage();
+                patentQuoteMessage.setPatent(quotePatent);
+                patentQuoteMessage.setQuotedPatents(quotePatents);
+                this.addQuotePatent(patentQuoteMessage);
+            }
+        } else {
+            patentQuoteMessage.getQuotedPatents().addAll(quotePatents);
+            this.updateQuotePatent(patentQuoteMessage, id);
+
+        }
+
+        return "";
+    }
+
+    private QuotePatent reQuotePatent(StarPatentVO starPatentVO) {
+        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);
+
+        }
+
+        //装载权利人
+        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());
+        return quotePatent;
+    }
+
+    public String addEsLegalEvent(String patentNo) {
+        LegalEvent legalEvent =null;
+        String id="";
+
+        //根据专利号查询
+        StarPatentVO starPatentVO = patentStarApiService.getPatentByNo(patentNo);
+        if (starPatentVO == null) {
+            return null;
+        }
+        //根据专利号查询是否有引用信息
+        SearchRequest.Builder builder = new SearchRequest.Builder();
+
+        //设置查询索引
+        builder.index("legal_event");
+        //申请号
+        Query q1 = QueryBuilders.term(t -> t.field("app_no").value(starPatentVO.getApplicationNo()));
+        Query bool = QueryBuilders.bool(i -> i.must(q1));
+        builder.query(bool);
+        SearchResponse<LegalEvent> response = null;
+        try {
+            response = client.search(builder.build(), LegalEvent.class);
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+        long total = response.hits().total().value();
+        if (total > 0) {
+            legalEvent = response.hits().hits().get(0).source();
+            id = response.hits().hits().get(0).id();
+        }
+
+        String cnLegalApiStr = patentStarApiService.getCnLegalApi(starPatentVO.getRowApplicationNo());
+        if (cnLegalApiStr != null && !cnLegalApiStr.equals("")) {
+            List<ChinaLeagalStatus> chinaLeagalStatuses = JSON.parseArray(cnLegalApiStr, ChinaLeagalStatus.class);
+            List<EventMessage> eventMessages = new ArrayList<>();
+            chinaLeagalStatuses.forEach(item -> {
+                EventMessage eventMessage = new EventMessage();
+                eventMessage.setEventDate(item.getLegalDate());
+                eventMessage.setCode(item.getLegalCode());
+                eventMessage.setDescription(item.getLegalStatusInfo());
+                eventMessages.add(eventMessage);
+            });
+
+
+         if(legalEvent==null){
+             try {
+                 legalEvent =new LegalEvent();
+                 legalEvent.setAppNo(starPatentVO.getApplicationNo());
+                 legalEvent.setEventMessages(eventMessages);
+                 this.addLegalEvent(legalEvent);
+             } catch (Exception e) {
+                 e.printStackTrace();
+             }
+         }
+         else {
+             legalEvent.setAppNo(starPatentVO.getApplicationNo());
+             legalEvent.setEventMessages(eventMessages);
+             this.updateLegalEvent(legalEvent,id);
+
+         }
+        }
+        return "";
+    }
+}
 
 

+ 42 - 15
src/main/java/cn/cslg/pas/service/common/PatentStarApiService.java

@@ -831,24 +831,51 @@ public class PatentStarApiService {
         }
 
         result.forEach(item -> {
-            String dbType = "CN";
-            String patentNo = item.get(0);
-            if (!patentNo.startsWith("CN")) {
-                dbType = "WD";
+            if (item.size() > 0) {
+                String dbType = "CN";
+                String patentNo = item.get(0);
+                if (!patentNo.startsWith("CN")) {
+                    dbType = "WD";
+                }
+                String join = StringUtils.join(item, " OR ");
+                String conditions = "AN=(" + join + ") OR PN=(" + join + ") OR GN=(" + join + ")";
+                PatentStarListDTO patentStarListDTO1 = new PatentStarListDTO();
+                patentStarListDTO1.setOrderByType(patentStarListDTO.getOrderByType());
+                patentStarListDTO1.setCurrentQuery(conditions);
+                patentStarListDTO1.setPageNum(patentStarListDTO.getPageNum());
+                patentStarListDTO1.setDBType(dbType);
+                patentStarListDTO1.setCurrentQuery(conditions);
+                patentStarListDTO1.setRowCount(50);
+                patentStarListDTO1.setTotal(item.size());
+                patentStarListDTOS.add(patentStarListDTO1);
             }
-            String join = StringUtils.join(item, " OR ");
-            String conditions = "AN=(" + join + ") OR PN=(" + join + ") OR GN=(" + join + ")";
-            PatentStarListDTO patentStarListDTO1 = new PatentStarListDTO();
-            patentStarListDTO1.setOrderByType(patentStarListDTO.getOrderByType());
-            patentStarListDTO1.setCurrentQuery(conditions);
-            patentStarListDTO1.setPageNum(patentStarListDTO.getPageNum());
-            patentStarListDTO1.setDBType(dbType);
-            patentStarListDTO1.setCurrentQuery(conditions);
-            patentStarListDTO1.setRowCount(patentStarListDTO.getRowCount());
-            patentStarListDTO1.setTotal(item.size());
-            patentStarListDTOS.add(patentStarListDTO1);
         });
 
         return patentStarListDTOS;
     }
+
+    public StarPatentVO getPatentByNo(String patentNo) {
+        StarPatentVO starPatentVO = null;
+        String condition ="AN=(" + patentNo + ") OR PN=(" + patentNo + ") OR GN=(" + patentNo + ")";
+        String dbType = "CN";
+        if (!patentNo.startsWith("CN")) {
+            dbType = "WD";
+        }
+        PatentStarListDTO patentStarListDTO = new PatentStarListDTO();
+        patentStarListDTO.setCurrentQuery(condition);
+        patentStarListDTO.setPageNum(1);
+        patentStarListDTO.setRowCount(50);
+        patentStarListDTO.setDBType(dbType);
+        try {
+            Map<String, Object> resultMap = this.patentStarSearchApi(patentStarListDTO);
+            if (resultMap == null || (Integer) resultMap.get("total") == 0) {
+                return starPatentVO;
+            }
+            List<StarPatentVO> starPatents = (List<StarPatentVO>) resultMap.get("records");
+            starPatentVO = starPatents.get(0);
+
+        } catch (Exception e) {
+        }
+        return starPatentVO;
+    }
 }

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

@@ -1,6 +1,7 @@
 package cn.cslg.pas.service.importPatent;
 
 import cn.cslg.pas.common.dto.UploadPatentWebDTO;
+import cn.cslg.pas.common.dto.business.EsPatentFamilyDTO;
 import cn.cslg.pas.common.model.cronModel.SystemFile;
 import cn.cslg.pas.common.utils.DateUtils;
 import cn.cslg.pas.common.utils.ReadExcelUtils;
@@ -8,10 +9,12 @@ 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.EsService;
 import cn.cslg.pas.service.common.ExcuteDataToVOService;
 import cn.cslg.pas.service.common.ExcuteUploadSettingService;
 import cn.cslg.pas.service.common.FileManagerService;
 import cn.cslg.pas.service.common.PatentStarApiService;
+import co.elastic.clients.elasticsearch.core.UpdateRequest;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONArray;
 import org.apache.commons.compress.utils.IOUtils;
@@ -19,12 +22,10 @@ import org.apache.poi.ss.usermodel.Sheet;
 import org.springframework.beans.factory.annotation.Configurable;
 import org.springframework.context.ApplicationContext;
 
-import java.io.ByteArrayInputStream;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.InputStream;
+import java.io.*;
 import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.Date;
 import java.util.List;
 import java.util.concurrent.locks.Condition;
 import java.util.concurrent.locks.Lock;
@@ -41,6 +42,7 @@ public class GetCataloguingFromWebThread extends Thread {
     private final Lock taskLock = new ReentrantLock();
     private final Condition taskCondition = taskLock.newCondition();
     private Boolean ifProductAll = false;
+    private TaskThread taskThread;
 
     @Override
     public void run() {
@@ -54,25 +56,50 @@ public class GetCataloguingFromWebThread extends Thread {
                 }
                 //根据专利申请号查询著录并装载信息
                 UploadPatentWebDTO uploadPatentWebDTO = uploadPatentWebDTOs.remove(0);
+                StarPatentVO starPatentVO = uploadPatentWebDTO.getStarPatentVO();
                 String patentZhuLuStr = "";
-                patentStarApiService=applicationContext.getBean(PatentStarApiService.class);
-                if (importTaskAMVO.getDbType().equals("CN")) {
+                patentStarApiService = applicationContext.getBean(PatentStarApiService.class);
+                if (starPatentVO.getApplicationNo().startsWith("CN")) {
                     patentZhuLuStr = patentStarApiService.getCnBibApi(uploadPatentWebDTO.getStarPatentVO().getRowApplicationNo());
                 } else {
                     patentZhuLuStr = patentStarApiService.getENBibApi(uploadPatentWebDTO.getStarPatentVO().getRowApplicationNo());
                 }
                 if (patentZhuLuStr != null && !patentZhuLuStr.trim().equals("") && !patentZhuLuStr.equals("{}") && !patentZhuLuStr.contains("请求不合法")) {
                     this.loadPatent(uploadPatentWebDTO);
-                    if (importTaskAMVO.getDbType().equals("CN")) {
+                    if (starPatentVO.getApplicationNo().startsWith("CN")) {
                         this.loadCNPatent(patentZhuLuStr, uploadPatentWebDTO.getPatent());
                     } else {
                         this.loadWorldPatent(patentZhuLuStr, uploadPatentWebDTO.getPatent());
                     }
                 }
+
+                EsService esService = applicationContext.getBean(EsService.class);
+
+                //添加同族专利
+                String familyPatentNoStr = patentStarApiService.getFamilyByPubNoApi(uploadPatentWebDTO.getPatent().getPublicNo());
+                if (!familyPatentNoStr.equals("no data")) {
+                    FamilyPatentNo familyPatentNo = JSON.parseObject(familyPatentNoStr, FamilyPatentNo.class);
+                    List<String> familyPatentNos = Arrays.asList(familyPatentNo.getFamilyinfo().split(";"));
+                    if (familyPatentNos.size() != 0) {
+                        EsPatentFamilyDTO esPatentFamilyDTO = esService.addEsPatentFamily(familyPatentNos, "inpadoc");
+                        uploadPatentWebDTO.getPatent().setInpadocFamilyNum(esPatentFamilyDTO.getFamilyNum());
+                        uploadPatentWebDTO.getPatent().setInpadocFamilyId(esPatentFamilyDTO.getPatentFamilyId());
+                    }
+                }
+
+                //添加法律事务
+                esService.addEsLegalEvent(uploadPatentWebDTO.getPatent().getPublicNo());
+
+                //添加引用专利
+                String nos = starPatentVO.getQuoteNos();
+                if(nos!=null) {
+                    List<String> quotedNos = this.reQuotedNos(nos);
+                    esService.addEsQuotePatent(uploadPatentWebDTO.getPatent().getPublicNo(), quotedNos);
+                }
                 //加入es保存队列
                 importFromWebToEsService.savePatentToEs(uploadPatentWebDTO);
             }
-
+            taskThread.awakeTaskThread();
         } catch (Exception e) {
             e.printStackTrace();
         }
@@ -145,6 +172,8 @@ public class GetCataloguingFromWebThread extends Thread {
         if (starPatentVO.getPublicAccreditDate() != null && !starPatentVO.getPublicAccreditDate().equals("")) {
 //
 //            patent.setGrantDate();
+            Date date = DateUtils.strToDate(starPatentVO.getPublicAccreditDate());
+            patent.setGrantDate(date);
         }
 
         //装载摘要
@@ -158,8 +187,8 @@ public class GetCataloguingFromWebThread extends Thread {
 
         //装载申请日
         if (starPatentVO.getApplicationDate() != null && !starPatentVO.getApplicationDate().equals("")) {
-//            int timeStamp = stringDateToTimeStamp(starPatent.getApplicationDate());
-//            uploadParamsVO.getPatent().setApplicationDate(timeStamp);
+            Date date = DateUtils.strToDate(starPatentVO.getApplicationDate());
+            patent.setAppDate(date);
         }
 
         //装载发明人
@@ -168,7 +197,7 @@ public class GetCataloguingFromWebThread extends Thread {
             List<PatentPerson> patentPeople = new ArrayList<>();
             for (int i = 0; i < patentInventorNames.size(); i++) {
                 PatentPerson patentPerson = new PatentPerson();
-                patentPerson.setOrder(0);
+                patentPerson.setOrder(i + 1);
                 patentPerson.setType("1");
                 patentPerson.setName(patentInventorNames.get(i));
                 patentPeople.add(patentPerson);
@@ -198,7 +227,7 @@ public class GetCataloguingFromWebThread extends Thread {
             List<PatentPerson> patentPeople = new ArrayList<>();
             for (int i = 0; i < names.size(); i++) {
                 PatentPerson patentPerson = new PatentPerson();
-                patentPerson.setOrder(0);
+                patentPerson.setOrder(i + 1);
                 patentPerson.setType("1");
                 patentPerson.setName(names.get(i));
                 patentPeople.add(patentPerson);
@@ -216,8 +245,8 @@ public class GetCataloguingFromWebThread extends Thread {
 
         //装载公开日
         if (starPatentVO.getPublicDate() != null && !starPatentVO.getPublicDate().equals("")) {
-//            int timeStamp = stringDateToTimeStamp(starPatent.getPublicDate());
-//            uploadParamsVO.getPatent().setPublicDate(timeStamp);
+            Date date = DateUtils.strToDate(starPatentVO.getPublicDate());
+            patent.setPublicDate(date);
         }
 
         //装载标题
@@ -266,7 +295,7 @@ public class GetCataloguingFromWebThread extends Thread {
             priorities.setPriorityCountry(pCountry);
             //装载优先权日
             if (starPatentVO.getPriorityDate() != null && !starPatentVO.getPriorityDate().equals("")) {
-
+                DateUtils.str2Date(starPatentVO.getPriorityDate());
             }
             patent.setPriorities(Arrays.asList(priorities));
         }
@@ -279,7 +308,7 @@ public class GetCataloguingFromWebThread extends Thread {
 
     //装载中国专利
     private void loadCNPatent(String chinaPatentZhuLuStr, Patent patent) {
-                  patent.setPatentNo(patent.getAppNo());
+        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);
@@ -321,7 +350,7 @@ public class GetCataloguingFromWebThread extends Thread {
                 }
             }
             //装载优先权号、优先权国家、优先权日
-            if (patent.getPriorities() == null&&chinaPatentZhuLu.getPR()!=null&&chinaPatentZhuLu.getPR()!="") {
+            if (patent.getPriorities() == null && chinaPatentZhuLu.getPR() != null && chinaPatentZhuLu.getPR() != "") {
                 Priorities priorities = new Priorities();
                 priorities.setPriorityNo(chinaPatentZhuLu.getPR());
                 String pCountry = chinaPatentZhuLu.getPR().substring(0, 2);
@@ -348,13 +377,13 @@ public class GetCataloguingFromWebThread extends Thread {
         }
         //装载申请日
         if (patent.getAppDate() == null) {
-//                int timeStamp = stringDateToTimeStamp(worldPatentZhuLu.getAppDate());
-//                uploadParamsVO.getPatent().setApplicationDate(timeStamp);
+            Date date = DateUtils.strToDate(worldPatentZhuLu.getAppDate());
+            patent.setAppDate(date);
         }
         //装载公开日
         if (patent.getPublicDate() == null) {
-//                int timeStamp = stringDateToTimeStamp(worldPatentZhuLu.getPubDate());
-//                uploadParamsVO.getPatent().setPublicDate(timeStamp);
+            Date date = DateUtils.strToDate(worldPatentZhuLu.getPubDate());
+            patent.setPublicDate(date);
         }
         //装载IPC分类号
         if (patent.getIpc() == null || patent.getIpc().size() == 0) {
@@ -419,7 +448,7 @@ public class GetCataloguingFromWebThread extends Thread {
         }
 
         //装载优先权号、优先权国家、优先权日
-        if (patent.getPriorities() == null&&worldPatentZhuLu.getPr()!=null&&worldPatentZhuLu.getPr()!="") {
+        if (patent.getPriorities() == null && worldPatentZhuLu.getPr() != null && worldPatentZhuLu.getPr() != "") {
             Priorities priorities = new Priorities();
             priorities.setPriorityNo(worldPatentZhuLu.getPr());
             String pCountry = worldPatentZhuLu.getPr().substring(0, 2);
@@ -446,4 +475,20 @@ public class GetCataloguingFromWebThread extends Thread {
 
 
     }
+
+    public List<String> reQuotedNos(String str) {
+        List<String> strings = Arrays.asList(str.split(";"));
+        List<String> nos = new ArrayList<>();
+        strings.forEach(item -> {
+            List<String> string2 = Arrays.asList(item.split(","));
+            if (string2.size() > 0) {
+                nos.add(string2.get(0).replace(" ", ""));
+            }
+
+        });
+        return nos;
+
+    }
+
+
 }

+ 4 - 0
src/main/java/cn/cslg/pas/service/importPatent/GetPatentPDFFromWebThread.java

@@ -141,5 +141,9 @@ public class GetPatentPDFFromWebThread extends Thread {
             taskLock.unlock();
         }
     }
+    public void setIfProductAll(Boolean ifProductAll) {
 
+        this.ifProductAll = ifProductAll;
+
+    }
 }

+ 4 - 0
src/main/java/cn/cslg/pas/service/importPatent/GetPatentPictureFromWebThread.java

@@ -82,5 +82,9 @@ public class GetPatentPictureFromWebThread extends Thread {
             taskLock.unlock();
         }
     }
+    public void setIfProductAll(Boolean ifProductAll) {
 
+        this.ifProductAll = ifProductAll;
+
+    }
 }

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

@@ -8,6 +8,7 @@ import cn.cslg.pas.common.vo.ImportTaskAMVO;
 import cn.cslg.pas.common.vo.StarPatentVO;
 import cn.cslg.pas.domain.es.Patent;
 import cn.cslg.pas.domain.es.Text;
+import cn.cslg.pas.service.business.es.EsService;
 import cn.cslg.pas.service.common.PatentStarApiService;
 import com.alibaba.fastjson.JSON;
 import org.dom4j.Document;
@@ -36,11 +37,11 @@ public class GetRightAndFullTextFromWebThread extends Thread {
     private List<UploadPatentWebDTO> uploadPatentWebDTOs =new ArrayList<>();
     private final Lock taskLock = new ReentrantLock();
     private final Condition taskCondition = taskLock.newCondition();
-
+    private Boolean ifProductAll = false;
     @Override
     public void run() {
         try {
-            while (uploadPatentWebDTOs.size() > 0 || importTaskAMVO.getState().equals(1)) {
+            while ((!ifProductAll || uploadPatentWebDTOs.size() > 0) && importTaskAMVO.getState().equals(1)) {
                 if (uploadPatentWebDTOs.size() == 0) {
                     taskLock.lock();
                     taskCondition.await();
@@ -57,8 +58,11 @@ public class GetRightAndFullTextFromWebThread extends Thread {
                 }
                 //加入es保存队列
                 importFromWebToEsService.savePatentToEs(uploadPatentWebDTO);
+
             }
 
+
+
         } catch (Exception e) {
             e.printStackTrace();
         }
@@ -173,4 +177,9 @@ public class GetRightAndFullTextFromWebThread extends Thread {
 
 
     }
+    public void setIfProductAll(Boolean ifProductAll) {
+
+        this.ifProductAll = ifProductAll;
+
+    }
 }

+ 56 - 33
src/main/java/cn/cslg/pas/service/importPatent/ImportFromWebToEsService.java

@@ -15,6 +15,7 @@ import cn.cslg.pas.service.common.PatentStarApiService;
 import com.alibaba.fastjson.JSONArray;
 import org.apache.commons.compress.utils.IOUtils;
 import org.apache.poi.ss.usermodel.Sheet;
+import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.context.ApplicationContext;
 import org.springframework.context.annotation.Scope;
@@ -47,13 +48,14 @@ public class ImportFromWebToEsService implements PatentImportImp {
     private GetPatentPictureFromWebThread getPatentPictureFromWebThread;
     private GetRightAndFullTextFromWebThread getRightAndFullTextFromWebThread;
     private ApplicationContext applicationContext;
+
     @Override
     public void startPatentThread() {
         //装载专利信息的计数器
         Integer addPatentCounter = 0;
         //十进制转二进制
-        String imContents="0000";
-        if(!importTaskAMVO.getImportContent().equals(0)){
+        String imContents = "0000";
+        if (!importTaskAMVO.getImportContent().equals(0)) {
             imContents = MathUtils.fun(2, importTaskAMVO.getImportContent());
         }
 
@@ -70,7 +72,6 @@ public class ImportFromWebToEsService implements PatentImportImp {
         importTaskAMVO.setIfAddPDF(ifPdf);
         importTaskAMVO.setShouldSaveCounter(0);
         importTaskAMVO.setHaveSaveCounter(0);
-        int patentNum = 10000;
         savePatentToEsThread = new SavePatentToEsThread(taskThread, taskThread.getApplicationContext());
         savePatentToEsThread.start();
         if (ifAddPicture == '1') {
@@ -98,13 +99,13 @@ public class ImportFromWebToEsService implements PatentImportImp {
         if (ifCataloguing == '1' || ifFullText == '1') {
             importTaskAMVO.setShouldSaveCounter(importTaskAMVO.getShouldSaveCounter() + 1);
         }
-        excuteLessThan10000(importTaskAMVO,addPatentCounter);
+        excuteLessThan10000(importTaskAMVO, addPatentCounter);
 
 
     }
 
 
-    private void excuteLessThan10000(ImportTaskAMVO importTaskAMVO,Integer addPatentCounter) {
+    private void excuteLessThan10000(ImportTaskAMVO importTaskAMVO, Integer addPatentCounter) {
         try {
             String orderBy = importTaskAMVO.getOrderBy();  //排序字段
             String orderByType = importTaskAMVO.getOrderByType();  //排序类型
@@ -115,23 +116,25 @@ public class ImportFromWebToEsService implements PatentImportImp {
             //检索式
             String conditions = importTaskAMVO.getSearchCondition();
 
-            List<PatentStarListDTO> patentStarListDtos =new ArrayList<>();
+            List<PatentStarListDTO> patentStarListDtos = new ArrayList<>();
 
             //获得返回的的多个检索式 patentStarListDtos
-
-           patentStarListDtos = patentStarApiService.getSplitedConditions(new PatentStarListDTO()
-                    .setCurrentQuery(conditions)
-                    .setOrderBy(orderBy)
-                    .setOrderByType(orderByType)
-                    .setDBType(dbType), patentNum);
-
+            if (importTaskAMVO.getType().equals(4)) {
+                patentStarListDtos = patentStarApiService.getSplitedConditions(new PatentStarListDTO()
+                        .setCurrentQuery(conditions)
+                        .setOrderBy(orderBy)
+                        .setOrderByType(orderByType)
+                        .setDBType(dbType), patentNum);
+            }
             //当专利为专利号导入时
             if (importTaskAMVO.getType().equals(2)) {
-                conditions = conditions.replaceAll(" +", "");  //去掉所有空格
+                PatentStarListDTO patentStarListDTO = new PatentStarListDTO();
+                patentStarListDTO.setCurrentQuery(conditions)
+                        .setOrderBy(orderBy)
+                        .setOrderByType(orderByType)
+                        .setDBType(dbType);
                 List<String> patentNos = Arrays.asList(conditions.split("[,|,]"));  //生成专利号集合
-                String join = StringUtils.join(patentNos, " OR ");
-                conditions = "AN=(" + join + ") OR PN=(" + join + ") OR GN=(" + join + ")";
-                importTaskAMVO.setDbType("CN");
+                patentStarListDtos = patentStarApiService.splitPatentNoByType(patentNos, patentStarListDTO);
             }
 
             //当专利为专利号文件导入时
@@ -154,8 +157,12 @@ public class ImportFromWebToEsService implements PatentImportImp {
                 }
                 Sheet sheet = ReadExcelUtils.readExcel(tempFile);
                 List<String> patentNos = ReadExcelUtils.getPatentNoFromExcel(sheet);
-                String join = StringUtils.join(patentNos, " OR ");
-                conditions = "AN=(" + join + ") OR PN=(" + join + ") OR GN=(" + join + ")";
+                PatentStarListDTO patentStarListDTO = new PatentStarListDTO();
+                patentStarListDTO.setCurrentQuery(conditions)
+                        .setOrderBy(orderBy)
+                        .setOrderByType(orderByType)
+                        .setDBType(dbType);
+                patentStarListDtos = patentStarApiService.splitPatentNoByType(patentNos, patentStarListDTO);
             }
 
             char ifCataloguing = importTaskAMVO.getIfAddCatalogue();
@@ -164,38 +171,42 @@ public class ImportFromWebToEsService implements PatentImportImp {
             char ifPdf = importTaskAMVO.getIfAddPDF();
             //下载字段
 
-
             //已经跳过的数量
-            Integer overNum =0;
+            Integer overNum = 0;
             while (patentStarListDtos.size() > 0) {
-                PatentStarListDTO  patentStarListDto =  patentStarListDtos.remove(0);
-                Integer total=patentStarListDto.getTotal();
-                overNum+=total;
-                if(total<=doneNum){
+                PatentStarListDTO patentStarListDto = patentStarListDtos.remove(0);
+                Integer total = patentStarListDto.getTotal();
+                Integer lastTotalNum =overNum;
+                overNum += total;
+                if (overNum < doneNum) {
                     continue;
                 }
-                Integer startNum =overNum-doneNum;
+                Integer startNum = doneNum-lastTotalNum;
                 Calculate calculate = DateUtils.calculateFromStartAndEndNumber(startNum, total, 50);
                 Integer startPage = calculate.getStartPage();
                 Integer endPage = calculate.getEndPage();
+
                 for (int i = startPage; i <= endPage; i++) {
+                    PatentStarListDTO patentStarListDTOTemp =new PatentStarListDTO();
+                    BeanUtils.copyProperties(patentStarListDto,patentStarListDTOTemp);
+                    patentStarListDTOTemp.setPageNum(i+1);
+                    patentStarListDTOTemp.setRowCount(50);
                     //调用一般接口返回一批专利著录相关数据
-                    Map<String, Object> resultMap = patentStarApiService.patentStarSearchApi(patentStarListDto);
+                    Map<String, Object> resultMap = patentStarApiService.patentStarSearchApi(patentStarListDTOTemp);
                     if (resultMap == null || (Integer) resultMap.get("total") == 0) {
-                        ThrowException.throwXiaoShiException("未检索到相关专利");
+                        continue;
                     }
-
                     List<StarPatentVO> starPatents = (List<StarPatentVO>) resultMap.get("records");
                     //遍历这一页的专利
                     for (int j = 0; j < starPatents.size(); j++) {
-                        if((i*50+j)<startNum){
+                        if ((i * 50 + j) < startNum) {
                             continue;
                         }
                         UploadPatentWebDTO uploadPatentWebDTO = new UploadPatentWebDTO();
                         Patent patent = new Patent();
 
                         //装载start
-                        uploadPatentWebDTO.setStarPatentVO(starPatents.get(i));
+                        uploadPatentWebDTO.setStarPatentVO(starPatents.get(j));
                         uploadPatentWebDTO.setPatent(patent);
                         uploadPatentWebDTO.setCounter(0);
                         uploadPatentWebDTO.setTotalCounter(addPatentCounter);
@@ -215,9 +226,21 @@ public class ImportFromWebToEsService implements PatentImportImp {
                     }
 
                 }
-
+                doneNum =overNum;
+                if (ifCataloguing == '1') {
+                    getCataloguingFromWebThread.setIfProductAll(true);
+                }
+                if (ifAddPicture == '1') {
+                    getPatentPictureFromWebThread.setIfProductAll(true);
+                }
+                if (ifAddFullText == '1') {
+                    getRightAndFullTextFromWebThread.setIfProductAll(true);
+                }
+                if (ifPdf == '1') {
+                    getPatentPDFFromWebThread.setIfProductAll(true);
+                }
             }
-        }catch (Exception e) {
+        } catch (Exception e) {
             e.printStackTrace();
             //生产消费到一半时,发生错误异常,将任务状态置为完成
 //            task = taskService.getById(task.getId());

+ 20 - 0
src/main/java/cn/cslg/pas/service/importPatent/SavePatentToEsThread.java

@@ -11,6 +11,7 @@ import cn.cslg.pas.service.business.ImportTaskService;
 import cn.cslg.pas.service.business.es.EsService;
 import cn.cslg.pas.service.common.FileManagerService;
 import cn.cslg.pas.service.common.MessageService;
+import cn.cslg.pas.service.common.PatentStarApiService;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.context.ApplicationContext;
@@ -109,4 +110,23 @@ public class SavePatentToEsThread extends Thread {
         this.ifProductAll = ifProductAll;
 
     }
+
+
+    //保存同族专利信息
+
+public void saveFamilyMessage(List<String> patentNos,String type){
+    //根据专利号查询同族信息
+    PatentStarApiService patentStarApiService = applicationContext.getBean(PatentStarApiService.class);
+   String familyStr = patentStarApiService.getFamilyByPubNoApi("CN116825114A");
+     //根据专利号查询同族
+    EsService esService =applicationContext.getBean(EsService.class);
+
+
+}
+
+
+    //保存专利事务信息
+
+
+
 }

+ 14 - 2
src/main/resources/jsons/importTaskConfig.json

@@ -1,9 +1,21 @@
 [
-  {"taskType": 1,
+  {
+    "taskType": 1,
     "importClass": "importFromExcelToEsService",
     "importTo": 1
   },
-  {"taskType": 2,
+  {
+    "taskType": 2,
+    "importClass": "importFromWebToEsService",
+    "importTo": 1
+  },
+  {
+    "taskType": 3,
+    "importClass": "importFromWebToEsService",
+    "importTo": 1
+  },
+  {
+    "taskType": 4,
     "importClass": "importFromWebToEsService",
     "importTo": 1
   }

+ 46 - 19
src/test/java/cn/cslg/pas/service/EsServiceTests.java

@@ -13,12 +13,15 @@ import cn.cslg.pas.service.business.es.EsService;
 import cn.cslg.pas.service.importPatent.SchedulingTaskService;
 import cn.hutool.core.util.XmlUtil;
 import org.junit.Test;
+import org.junit.runner.RunWith;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
 
 import javax.swing.text.Document;
 import java.io.IOException;
+import java.util.ArrayList;
 import java.util.List;
 
 /**
@@ -26,46 +29,40 @@ import java.util.List;
  * @date 2023/9/6
  */
 @SpringBootTest
+@RunWith(SpringRunner.class)
 public class EsServiceTests {
 
     @Autowired
     private EsService esService;
 
-    @Autowired
-    private PatentService patentService;
-
-    @Autowired
-    private RedisUtil redisUtil;
 
-    @Autowired
-    private SchedulingTaskService importTaskAdd;
     @Test
- public    void addPatent() throws Exception {
-        Patent patent =new Patent();
+    public void addPatent() throws Exception {
+        Patent patent = new Patent();
         patent.setPatentNo("CN202023204739.4");
-     String id = esService.addPatent(patent);
+        String id = esService.addPatent(patent);
         System.out.println(id);
     }
 
     @Test
-    public   void getPatentByPatentNo() throws  Exception {
+    public void getPatentByPatentNo() throws Exception {
         //根据专利号获得id
-        PatentWithIdVO patentWithIdVO  = esService.getIdByPatentNo("CN201114765Y");
-        Patent patent =new Patent();
+        PatentWithIdVO patentWithIdVO = esService.getIdByPatentNo("CN201114765Y");
+        Patent patent = new Patent();
         patent.setAgency("张三");
-        Patent orgPatent =patentWithIdVO.getPatent();
-        BeanUtils.copyProperties(patent,orgPatent, FormatUtil.getNullPropertyNames(patent));
-          esService.updateDocument(orgPatent,patentWithIdVO.getId());
-    System.out.println();
+        Patent orgPatent = patentWithIdVO.getPatent();
+        BeanUtils.copyProperties(patent, orgPatent, FormatUtil.getNullPropertyNames(patent));
+        esService.updateDocument(orgPatent, patentWithIdVO.getId());
+        System.out.println();
     }
 
     @Test
-    public   void updatePatent() throws Exception{
+    public void updatePatent() throws Exception {
 
     }
 
     @Test
-    void search() throws Exception {
+  public  void search() throws Exception {
         StringRequest stringRequest = new StringRequest();
         stringRequest.setSearchQuery("patentNo=CN201199922Y and (simpleFamilyNum>1 or simpleFamilyNum=0)");
         stringRequest.setCurrent(0L);
@@ -85,4 +82,34 @@ public class EsServiceTests {
 //        List<Patent> list = esService.search("patentNo=CN201199922Y", 0, 50);
 //        System.out.println(list);
     }
+
+    @Test
+    public void addQuotePatent() throws Exception {
+        String no = "CN202221363803.X";
+        List<String> nos = new ArrayList<>();
+        nos.add("CN201920033236.3");
+        nos.add("CN202010306989.4");
+        esService.addEsQuotePatent(no, nos);
+        System.out.println("aa");
+    }
+
+    @Test
+    public void addFamilyPatent() throws Exception {
+        String no = "CN202221363803.X";
+        List<String> nos = new ArrayList<>();
+        nos.add("CN201920033236.3");
+        nos.add("CN202010306989.4");
+        esService.addEsPatentFamily( nos,"inpadoc");
+        System.out.println("aa");
+    }
+    @Test
+    public void addAffairPatent() throws Exception {
+        String no = "CN202221363803.X";
+        List<String> nos = new ArrayList<>();
+        nos.add("CN201920033236.3");
+        nos.add("CN202010306989.4");
+        esService.addEsLegalEvent(no);
+        System.out.println("aa");
+    }
+
 }

+ 2 - 2
src/test/java/cn/cslg/pas/service/EventServiceTests.java

@@ -187,14 +187,14 @@ public class EventServiceTests {
     @Test
     void test3() throws IOException {
         List<String> stringList = Arrays.asList("US369258147", "US258369147", "14528");
-        EsPatentFamilyDTO test = esService.selectEsPatentFamily(stringList, "test");
+        EsPatentFamilyDTO test = esService.addEsPatentFamily(stringList, "test");
         System.out.println(test);
     }
 
     @Test
     void test4() throws IOException {
         List<String> stringList = Arrays.asList("US369258147", "US258369147", "14528");
-        EsPatentFamilyDTO test = esService.selectEsPatentFamily(stringList, "test");
+        EsPatentFamilyDTO test = esService.addEsPatentFamily(stringList, "test");
         System.out.println(test);
     }
 }

+ 12 - 0
src/test/java/cn/cslg/pas/service/PatentStarServiceTests.java

@@ -7,6 +7,7 @@ import cn.cslg.pas.common.utils.FormatUtil;
 import cn.cslg.pas.common.utils.RedisUtil;
 import cn.cslg.pas.common.utils.StringUtils;
 import cn.cslg.pas.common.vo.PatentWithIdVO;
+import cn.cslg.pas.common.vo.StarPatentVO;
 import cn.cslg.pas.domain.es.Patent;
 import cn.cslg.pas.service.business.es.EsService;
 import cn.cslg.pas.service.common.PatentStarApiService;
@@ -24,6 +25,7 @@ import org.springframework.boot.test.context.SpringBootTest;
 import java.io.Reader;
 import java.io.StringReader;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.List;
 import java.util.Map;
 
@@ -160,4 +162,14 @@ public class PatentStarServiceTests {
         System.out.println(a);
         Thread.sleep(1000000);
     }
+
+    @Test
+    void getPatentByNo() throws Exception {
+        StarPatentVO a = patentStarApiService.getPatentByNo("CN116825114A");
+
+        System.out.println(a);
+        Thread.sleep(1000000);
+    }
+
+
 }