Pārlūkot izejas kodu

Merge remote-tracking branch 'origin/importPatent'

# Conflicts:
#	src/main/java/cn/cslg/pas/service/common/PatentStarApiService.java
#	src/main/java/cn/cslg/pas/service/importPatent/GetPatentPictureFromWebThread.java
lwhhszx 1 gadu atpakaļ
vecāks
revīzija
e060cb3b23
67 mainītis faili ar 3848 papildinājumiem un 1891 dzēšanām
  1. 12 0
      src/main/java/cn/cslg/pas/common/PatentImportErrorLog/ImportErrorLogQueryDTO.java
  2. 29 0
      src/main/java/cn/cslg/pas/common/PatentImportErrorLog/ImportErrorLogQueryVO.java
  3. 1 1
      src/main/java/cn/cslg/pas/common/config/ElasticSearchClientConfig.java
  4. 1 0
      src/main/java/cn/cslg/pas/common/dto/ImportTaskDTO.java
  5. 1 0
      src/main/java/cn/cslg/pas/common/dto/business/PatentProjectDTO.java
  6. 1 0
      src/main/java/cn/cslg/pas/common/dto/business/UpdatePatentProjectDTO.java
  7. 110 0
      src/main/java/cn/cslg/pas/common/importTask/ImportTaskConditionVO.java
  8. 8 0
      src/main/java/cn/cslg/pas/common/importTask/ProjectQuartzQueryDTO.java
  9. 10 0
      src/main/java/cn/cslg/pas/common/importTask/ProjectQuartzSetDTO.java
  10. 54 0
      src/main/java/cn/cslg/pas/common/importTask/QuartzConditionDTO.java
  11. 16 0
      src/main/java/cn/cslg/pas/common/importTask/QuartzConditionQueryDTO.java
  12. 11 0
      src/main/java/cn/cslg/pas/common/importTask/QuartzConditionRemoveDTO.java
  13. 55 0
      src/main/java/cn/cslg/pas/common/importTask/QuartzConditionUpdateDTO.java
  14. 16 0
      src/main/java/cn/cslg/pas/common/patentProject/ProjectQuartzDTO.java
  15. 28 68
      src/main/java/cn/cslg/pas/common/utils/ClaimUtils/ClaimSplitUtils.java
  16. 42 0
      src/main/java/cn/cslg/pas/common/utils/CronUtil.java
  17. 13 1
      src/main/java/cn/cslg/pas/common/utils/DateUtils.java
  18. 115 0
      src/main/java/cn/cslg/pas/common/utils/DateUtils2.java
  19. 25 16
      src/main/java/cn/cslg/pas/common/utils/esDataForm/PatentClassifySplitter.java
  20. 1 1
      src/main/java/cn/cslg/pas/common/vo/ImportTaskAMVO.java
  21. 138 50
      src/main/java/cn/cslg/pas/common/vo/StarPatentVO.java
  22. 4 0
      src/main/java/cn/cslg/pas/common/vo/business/ImportTaskVO.java
  23. 3 0
      src/main/java/cn/cslg/pas/common/vo/business/PatentProjectVO.java
  24. 53 0
      src/main/java/cn/cslg/pas/controller/ImportTaskConditionController.java
  25. 12 0
      src/main/java/cn/cslg/pas/controller/ImportTaskController.java
  26. 21 1
      src/main/java/cn/cslg/pas/controller/PatentProjectController.java
  27. 25 0
      src/main/java/cn/cslg/pas/controller/ProjectMonitorSetController.java
  28. 7 0
      src/main/java/cn/cslg/pas/domain/business/ImportTask.java
  29. 8 0
      src/main/java/cn/cslg/pas/domain/business/ImportTaskCondition.java
  30. 2 0
      src/main/java/cn/cslg/pas/domain/business/PatentProject.java
  31. 1 0
      src/main/java/cn/cslg/pas/domain/business/TreeNode.java
  32. 16 0
      src/main/java/cn/cslg/pas/domain/es/Patent.java
  33. 0 3
      src/main/java/cn/cslg/pas/service/MailSendService.java
  34. 2 2
      src/main/java/cn/cslg/pas/service/business/CustomFieldService.java
  35. 256 0
      src/main/java/cn/cslg/pas/service/business/ImportTaskConditionService.java
  36. 177 94
      src/main/java/cn/cslg/pas/service/business/ImportTaskService.java
  37. 69 0
      src/main/java/cn/cslg/pas/service/business/PatentImportErrorLogService.java
  38. 191 21
      src/main/java/cn/cslg/pas/service/business/PatentProjectService.java
  39. 3 3
      src/main/java/cn/cslg/pas/service/business/TreeNodeService.java
  40. 51 4
      src/main/java/cn/cslg/pas/service/business/es/EsFamilyService.java
  41. 95 5
      src/main/java/cn/cslg/pas/service/business/es/EsLegalEventService.java
  42. 27 0
      src/main/java/cn/cslg/pas/service/business/es/EsQuotePatentService.java
  43. 80 185
      src/main/java/cn/cslg/pas/service/business/es/EsService.java
  44. 158 207
      src/main/java/cn/cslg/pas/service/common/PatentStarApiService.java
  45. 22 3
      src/main/java/cn/cslg/pas/service/common/PersonFieldService.java
  46. 58 404
      src/main/java/cn/cslg/pas/service/importPatent/GetCataloguingFromWebThread.java
  47. 30 96
      src/main/java/cn/cslg/pas/service/importPatent/GetPatentFromExcelThread.java
  48. 52 83
      src/main/java/cn/cslg/pas/service/importPatent/GetPatentPDFFromWebThread.java
  49. 13 10
      src/main/java/cn/cslg/pas/service/importPatent/GetPatentPictureFromWebThread.java
  50. 29 57
      src/main/java/cn/cslg/pas/service/importPatent/GetRightAndFullTextFromWebThread.java
  51. 46 54
      src/main/java/cn/cslg/pas/service/importPatent/ImportFromWebToEsService.java
  52. 28 420
      src/main/java/cn/cslg/pas/service/importPatent/ImportSinglePatentService.java
  53. 5 5
      src/main/java/cn/cslg/pas/service/importPatent/SavePatentToEsThread.java
  54. 24 5
      src/main/java/cn/cslg/pas/service/importPatent/SchedulingTaskService.java
  55. 5 3
      src/main/java/cn/cslg/pas/service/importPatent/TaskThread.java
  56. 1066 0
      src/main/java/cn/cslg/pas/service/importPatent/WebVOTransformService.java
  57. 0 24
      src/main/java/cn/cslg/pas/service/quartzService/ImportJobService.java
  58. 38 0
      src/main/java/cn/cslg/pas/service/quartzService/ImportPatentJobService.java
  59. 26 24
      src/main/java/cn/cslg/pas/service/quartzService/JobService.java
  60. 3 0
      src/main/java/cn/cslg/pas/service/quartzService/QrtzTaskDTO.java
  61. 3 1
      src/main/java/cn/cslg/pas/service/quartzService/QuartzVO.java
  62. 1 1
      src/main/resources/application-testNetIn.yml
  63. 1 1
      src/main/resources/mapper/ImportTaskMapper.xml
  64. 2 2
      src/main/resources/mapper/PatentProjectMapper.xml
  65. 8 6
      src/test/java/cn/cslg/pas/service/ClaimTextTests.java
  66. 10 30
      src/test/java/cn/cslg/pas/service/EsServiceTests.java
  67. 430 0
      src/test/java/cn/cslg/pas/service/WebVoTransformServiceTests.java

+ 12 - 0
src/main/java/cn/cslg/pas/common/PatentImportErrorLog/ImportErrorLogQueryDTO.java

@@ -0,0 +1,12 @@
+package cn.cslg.pas.common.PatentImportErrorLog;
+
+import lombok.Data;
+
+@Data
+public class ImportErrorLogQueryDTO {
+
+    private Integer taskId;
+    private long size;
+    private long current;
+
+}

+ 29 - 0
src/main/java/cn/cslg/pas/common/PatentImportErrorLog/ImportErrorLogQueryVO.java

@@ -0,0 +1,29 @@
+package cn.cslg.pas.common.PatentImportErrorLog;
+
+import com.baomidou.mybatisplus.annotation.TableField;
+import lombok.Data;
+
+@Data
+public class ImportErrorLogQueryVO {
+
+    /**
+     * 专利号
+     */
+    private String patentNo;
+
+    /**
+     * 错误类型
+     */
+    private Integer errorType;
+    /**
+     * 错误信息
+     */
+    private String errorMessage;
+
+
+    /**
+     * 错误类型名称
+     */
+    private String errorName;
+
+}

+ 1 - 1
src/main/java/cn/cslg/pas/common/config/ElasticSearchClientConfig.java

@@ -56,7 +56,7 @@ public class  ElasticSearchClientConfig {
         public ElasticsearchClient elasticsearchClient() throws Exception {
             RestClientBuilder builder = RestClient.builder(new HttpHost(config, 9200, "http"));
             CredentialsProvider credentialsProvider = new BasicCredentialsProvider();
-            credentialsProvider.setCredentials(AuthScope.ANY, new UsernamePasswordCredentials("elastic", "Xiaoshi221101"));
+            credentialsProvider.setCredentials(AuthScope.ANY, new UsernamePasswordCredentials("elastic", "xiaoshi221101"));
             SSLContext sslContext = SSLContextBuilder.create()
                     .loadTrustMaterial(new TrustSelfSignedStrategy())
                     .build();

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

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

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

@@ -54,4 +54,5 @@ public class PatentProjectDTO {
     @Schema(description = "文件guids")
     private List<String> fileGuids;
     private String personId;
+    private String updateCycle;
 }

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

@@ -54,4 +54,5 @@ public class UpdatePatentProjectDTO {
     private List<ProjectEventDTO> events;
     @Schema(description = "文件guids")
     private List<String> fileGuids;
+    private String updateCycle;
 }

+ 110 - 0
src/main/java/cn/cslg/pas/common/importTask/ImportTaskConditionVO.java

@@ -0,0 +1,110 @@
+package cn.cslg.pas.common.importTask;
+
+import cn.cslg.pas.common.dto.es.EsCustomFieldDTO;
+import cn.cslg.pas.domain.BaseEntity;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.Data;
+
+import java.util.Date;
+import java.util.List;
+
+/**
+ * @Author lrj
+ * @Date 2023/8/15
+ */
+@Data
+
+public class ImportTaskConditionVO  {
+    private Integer id;
+    /**
+     * 项目id
+     */
+    private Integer projectId;
+
+    private String patentNos;
+    /**
+     * 项目类型
+     * 0专题库 1报告
+     */
+    private Integer projectType;
+
+    /**
+     * 产品id
+     */
+    private Integer productId;
+
+    /**
+     * 周期
+     */
+    private String crons;
+
+    private String updateCycle;
+
+    /**
+     * 上次更新时间
+     */
+    private Date lastUpdateDate;
+
+    /**
+     * 若是检索导入/专利号导入则必填
+     * 五位数字
+     * 第1著录项目2附图
+     * 3权利要求,4说明书文本,5pdf文档
+     */
+    private Integer importContent;
+
+    /**
+     * 是否更新
+     */
+    private Boolean ifUpdate;
+
+    /**
+     * 条件
+     */
+    private String searchCondition;
+
+    /**
+     * 1excel导入
+     * 2专利号导入
+     * 3专利号文件导入
+     * 4检索导入
+     * 5pdf文档导入
+     */
+    private Integer type;
+
+    /**
+     * 文件guid
+     */
+    private String fileGuid;
+
+    /**
+     * 若是excel导入任务,则使用到配置文件source_id
+     */
+    private Integer sourceId;
+
+    /**
+     * 创建人id
+     */
+
+    private String createId;
+    private String dbType;
+    private String orderByType;
+    private String orderBy;
+    /**
+     * 创建时间
+     */
+    private Date createTime;
+    private List<EsCustomFieldDTO> fieldDTOS;
+
+    private Integer pdfType;
+
+
+    private String searchSetting;
+
+    private Boolean ifDelete;
+
+
+    private String createName;
+
+}

+ 8 - 0
src/main/java/cn/cslg/pas/common/importTask/ProjectQuartzQueryDTO.java

@@ -0,0 +1,8 @@
+package cn.cslg.pas.common.importTask;
+
+import lombok.Data;
+
+@Data
+public class ProjectQuartzQueryDTO {
+    private Integer projectId;
+}

+ 10 - 0
src/main/java/cn/cslg/pas/common/importTask/ProjectQuartzSetDTO.java

@@ -0,0 +1,10 @@
+package cn.cslg.pas.common.importTask;
+
+import lombok.Data;
+
+@Data
+public class ProjectQuartzSetDTO {
+  private   Integer projectId;
+    private Boolean ifUpdate;
+    private String updateCycle;
+}

+ 54 - 0
src/main/java/cn/cslg/pas/common/importTask/QuartzConditionDTO.java

@@ -0,0 +1,54 @@
+package cn.cslg.pas.common.importTask;
+
+import cn.cslg.pas.common.dto.es.EsCustomFieldDTO;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import lombok.Data;
+
+import java.util.List;
+
+@Data
+public class QuartzConditionDTO {
+    private  Integer id;
+    /**
+     * 导入id
+     */
+    private Integer importToId;
+
+    private Integer importToType;
+
+    private String searchSetting;
+    /**
+     * 周期
+     */
+    private String crons;
+
+    private String updateCycle;
+    /**
+     * 若是检索导入/专利号导入则必填
+     * 五位数字
+     * 第1著录项目2附图
+     * 3权利要求,4说明书文本,5pdf文档
+     */
+    private Integer importContent;
+
+    /**
+     * 是否更新
+     */
+    private Boolean ifUpdate;
+
+    /**
+     * 条件
+     */
+    private String searchCondition;
+
+
+    /**
+     * 检索导入使用的数据库类型(中国or世界)
+     */
+    @JsonProperty(value = "DBType")
+    private String DBType;
+
+    private String orderBy;
+    private String orderByType;
+    private List<EsCustomFieldDTO> fieldDTOS;
+}

+ 16 - 0
src/main/java/cn/cslg/pas/common/importTask/QuartzConditionQueryDTO.java

@@ -0,0 +1,16 @@
+package cn.cslg.pas.common.importTask;
+
+import cn.cslg.pas.common.dto.es.EsCustomFieldDTO;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import lombok.Data;
+
+import java.util.List;
+
+@Data
+public class QuartzConditionQueryDTO {
+
+    private Integer projectId;
+    private long size;
+    private long current;
+
+}

+ 11 - 0
src/main/java/cn/cslg/pas/common/importTask/QuartzConditionRemoveDTO.java

@@ -0,0 +1,11 @@
+package cn.cslg.pas.common.importTask;
+
+import cn.cslg.pas.common.dto.es.EsCustomFieldDTO;
+import lombok.Data;
+
+import java.util.List;
+
+@Data
+public class QuartzConditionRemoveDTO {
+    private List<Integer> ids;
+}

+ 55 - 0
src/main/java/cn/cslg/pas/common/importTask/QuartzConditionUpdateDTO.java

@@ -0,0 +1,55 @@
+package cn.cslg.pas.common.importTask;
+
+import cn.cslg.pas.common.dto.es.EsCustomFieldDTO;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import lombok.Data;
+
+import java.util.List;
+
+@Data
+public class QuartzConditionUpdateDTO {
+    private Integer id;
+
+    /**
+     * 导入id
+     */
+    private Integer importToId;
+    /**
+     * 前端检索配置
+     */
+    private String searchSetting;
+
+    /**
+     * 周期
+     */
+    private String crons;
+
+    /**
+     * 若是检索导入/专利号导入则必填
+     * 五位数字
+     * 第1著录项目2附图
+     * 3权利要求,4说明书文本,5pdf文档
+     */
+    private Integer importContent;
+
+    /**
+     * 是否更新
+     */
+    private Boolean ifUpdate;
+
+    /**
+     * 条件
+     */
+    private String searchCondition;
+
+
+    /**
+     * 检索导入使用的数据库类型(中国or世界)
+     */
+    private String dbType;
+
+    private String orderBy;
+    private String orderByType;
+    private List<EsCustomFieldDTO> fieldDTOS;
+    private String updateCycle;
+}

+ 16 - 0
src/main/java/cn/cslg/pas/common/patentProject/ProjectQuartzDTO.java

@@ -0,0 +1,16 @@
+package cn.cslg.pas.common.patentProject;
+
+import cn.cslg.pas.common.vo.PersonSelfFieldVO;
+import lombok.Data;
+
+import java.util.List;
+
+/**
+ * 实体类表以及栏位信息
+ */
+@Data
+public class ProjectQuartzDTO {
+    private Integer projectId;
+    private Boolean ifUpdate;
+    private String crons;
+}

+ 28 - 68
src/main/java/cn/cslg/pas/common/utils/ClaimUtils/ClaimSplitUtils.java

@@ -45,13 +45,16 @@ public class ClaimSplitUtils {
             if (content == null || content.equals("")) {
                 return patentRights;
             }
-            String regex = ClaimSplitUtils.getRegex(country, content);
-            if (regex == null) {
-                reDefaultPatentClaim(patentRights, content);
-                return patentRights;
+            if (content.contains("@##")) {
+                patentRights = getSplitedRePatentClaim(content);
+            } else {
+                String regex = ClaimSplitUtils.getRegex(country, content);
+                if (regex == null) {
+                    reDefaultPatentClaim(patentRights, content);
+                    return patentRights;
+                }
+                patentRights = splitPatentRight(regex, content);
             }
-            patentRights = splitPatentRight(regex, content);
-
             switch (country) {
                 case "CN":
                     loadCNPatentClaim(patentNo, patentRights);
@@ -74,63 +77,6 @@ public class ClaimSplitUtils {
 
     }
 
-//    private static final ArrayList<RePatentClaim> splitPatentRight(String regex, String content) {
-//        //获取拆分信息
-//        List<ClaimSplitVO> claimSplitVOS = ClaimSplitUtils.getClaimSpitVO(regex, content);
-//
-//        String regexNum = "[1-9][0-9]*";
-//        Integer num = 1;
-//        ArrayList<RePatentClaim> patentRights = new ArrayList<>();
-//        Boolean flag = true;
-//        Integer start =0;
-//        Integer end =0;
-//        for (int i = 0; i < claimSplitVOS.size(); i++) {
-////            Integer start = claimSplitVOS.get(i).getPosition();
-////            Integer end = content.length();
-//            String cont = claimSplitVOS.get(i).getContent();
-//            Matcher matcherNum = Pattern.compile(regexNum).matcher(cont);
-//
-//            //查询当前序号
-//            if (matcherNum.find()) {
-//                String a = matcherNum.group();
-//                Integer num2 = Integer.parseInt(a);
-//                if (num2 != num) {
-//                    if (i == 0 && num2.equals(2)) {
-//                        start =claimSplitVOS.get(i).getPosition();
-//                        String str = content.substring(0, start);
-//                        RePatentClaim rePatentClaim = new RePatentClaim();
-//                        rePatentClaim.setSort(num - 1);
-//                        rePatentClaim.setContent(str);
-//                        patentRights.add(rePatentClaim);
-//                        num++;
-//                    } else {
-//                        flag = false;
-//                        break;
-//                    }
-//                }
-//
-//                start =claimSplitVOS.get(i).getPosition();
-//                if (i + 1 < claimSplitVOS.size()) {
-//                    end = claimSplitVOS.get(i + 1).getPosition();
-//                }
-//
-//                String str = content.substring(start, end);
-//                RePatentClaim rePatentClaim = new RePatentClaim();
-//                rePatentClaim.setSort(num - 1);
-//                rePatentClaim.setContent(str);
-//                patentRights.add(rePatentClaim);
-//                num++;
-//            } else {
-//                flag = false;
-//                break;
-//            }
-//        }
-//        if (flag.equals(false) || patentRights.size() == 1) {
-//            reDefaultPatentClaim(patentRights, content);
-//        }
-//        return patentRights;
-//    }
-
 
     private static final ArrayList<RePatentClaim> splitPatentRight(String regex, String content) {
         //获取拆分信息
@@ -164,8 +110,8 @@ public class ClaimSplitUtils {
                         num++;
 
                         //最后一个的处理逻辑
-                        if(i+1==claimSplitVOS.size()){
-                            end=content.length();
+                        if (i + 1 == claimSplitVOS.size()) {
+                            end = content.length();
                             String str1 = content.substring(start, end);
                             RePatentClaim rePatentClaim1 = new RePatentClaim();
                             rePatentClaim1.setSort(num - 1);
@@ -177,14 +123,14 @@ public class ClaimSplitUtils {
 
                 } else {
                     if (i == 0 && num2.equals(2)) {
-                        end =claimSplitVOS.get(i).getPosition();
+                        end = claimSplitVOS.get(i).getPosition();
                         String str = content.substring(0, end);
                         RePatentClaim rePatentClaim = new RePatentClaim();
                         rePatentClaim.setSort(num - 1);
                         rePatentClaim.setContent(str);
                         patentRights.add(rePatentClaim);
-                        start =claimSplitVOS.get(i).getPosition();
-                        num+=2;
+                        start = claimSplitVOS.get(i).getPosition();
+                        num += 2;
                     }
                     continue;
                 }
@@ -473,4 +419,18 @@ public class ClaimSplitUtils {
         return nums;
     }
 
+
+    public static final ArrayList<RePatentClaim> getSplitedRePatentClaim(String content) {
+        ArrayList<RePatentClaim> arrayList = new ArrayList<>();
+
+        String[] contents = content.split("@##");
+        for (int i = 0; i < contents.length; i++) {
+            RePatentClaim rePatentClaim = new RePatentClaim();
+            rePatentClaim.setSort(i + 1);
+            rePatentClaim.setContent(contents[i]);
+            arrayList.add(rePatentClaim);
+        }
+        return arrayList;
+
+    }
 }

+ 42 - 0
src/main/java/cn/cslg/pas/common/utils/CronUtil.java

@@ -0,0 +1,42 @@
+package cn.cslg.pas.common.utils;
+
+
+import cn.cslg.pas.exception.ExceptionEnum;
+import cn.cslg.pas.exception.XiaoShiException;
+import org.springframework.beans.BeanWrapper;
+import org.springframework.beans.BeanWrapperImpl;
+
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+public class CronUtil {
+    public static String getCron(String cron) {
+        if(cron==null){
+            return null;
+        }
+        switch (cron) {
+            case "week":
+//                cron = "0 0 0 ? * 1 *";
+                cron="30 * * * * ?";
+                break;
+            case "month":
+                cron = "0 0 0 1 * ?";
+                break;
+            case "quarter":
+                cron = "0 0 0 1 1,4,7,10 ?";
+                break;
+            case "year":
+                cron = "0 0 0 1 1 ? *";
+                break;
+            default:
+                throw new XiaoShiException(ExceptionEnum.BUSINESS_CHECK,"周期非法输入");
+        }
+        return cron;
+
+    }
+
+}

+ 13 - 1
src/main/java/cn/cslg/pas/common/utils/DateUtils.java

@@ -17,7 +17,6 @@ import java.util.*;
 import java.util.regex.Pattern;
 
 public class DateUtils {
-
     public static final String START_TIME = " 00:00:00";
     public static final String END_TIME = " 23:59:59";
     public final static String FORMAT_STRING = "yyyy-MM-dd HH:mm:ss";
@@ -554,6 +553,19 @@ public class DateUtils {
     }
 
     /**
+     * 获取几天之后的日期
+     *
+     * @param date yyyy-MM-dd HH:mm:ss
+     * @param day  加减的天数
+     */
+    public static Date getDate(Date date, int day) {
+        Calendar cal = Calendar.getInstance();
+            cal.setTime(date);
+            cal.add(Calendar.DAY_OF_MONTH, day);
+            return cal.getTime();
+    }
+
+    /**
      * 获取某个日期 在加上 秒数的时间
      *
      * @param beforeDate yyyy-MM-dd HH:mm:ss

+ 115 - 0
src/main/java/cn/cslg/pas/common/utils/DateUtils2.java

@@ -88,5 +88,120 @@ public class DateUtils2 {
         return dateTimes;
     }
 
+    public static String dateTimeToPatentStr(Date dateTime) {
+        SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd");
+        return format.format(dateTime);
+    }
+
+
+    public static Date formStrToDate(String dateString) {
+        try {
+            if(dateString==null||dateString.trim().equals("")){
+                return null;
+            }
+            SimpleDateFormat formatter;
+            if (dateString.contains("-")) {
+                formatter = new SimpleDateFormat("yyyy-MM-dd");
+            } else if (dateString.contains("//")) {
+                formatter = new SimpleDateFormat("yyyy/MM/dd");
+            } else if (dateString.contains(":")) {
+                formatter = new SimpleDateFormat("yyyy:MM:dd");
+            } else if (dateString.contains(".")) {
+                formatter = new SimpleDateFormat("yyyy.MM.dd");
+            } else {
+                formatter = new SimpleDateFormat("yyyyMMdd");
+            }
+
+            return formatter.parse(dateString);
+        } catch (Exception e) {
+            throw new RuntimeException("时间转化格式错误" + "[dateString=" + dateString + "]" + "[FORMAT_STRING=" + FORMAT_STRING + "]");
+        }
+    }
+
+    /**
+     * 获取第几个星期
+     *
+     * @param date
+     * @return
+     */
+    public static int getDateWeekIndex(Date date) {
+        Calendar calendar = Calendar.getInstance(Locale.getDefault());
+        calendar.setTime(date); // 注意月份是从0开始的,即0=1月,1=2月,...
+        // 获取周数可能依赖于Calendar的设置,这里使用默认设置
+        int weekOfYear = calendar.get(Calendar.WEEK_OF_YEAR);
+        return weekOfYear;
+    }
+
+
+    /**
+     * 获取第几个月
+     *
+     * @param date
+     * @return
+     */
+    public static int getDateMonthIndex(Date date) {
+        Calendar calendar = Calendar.getInstance(Locale.getDefault());
+        calendar.setTime(date); // 注意月份是从0开始的,即0=1月,1=2月,...
+        // 获取周数可能依赖于Calendar的设置,这里使用默认设置
+        int month = calendar.get(Calendar.MONTH) + 1;
+        return month;
+    }
+
+
+    /**
+     * 获取第几个季度
+     *
+     * @param date
+     * @return
+     */
+    public static int getDateQuarterIndex(Date date) {
+        Calendar calendar = Calendar.getInstance(Locale.getDefault());
+        calendar.setTime(date); // 注意月份是从0开始的,即0=1月,1=2月,...
+        // 获取周数可能依赖于Calendar的设置,这里使用默认设置
+        int month = calendar.get(Calendar.MONTH) + 1;
+        int quarter;
+
+        if (month >= Calendar.JANUARY && month <= Calendar.MARCH) {
+            quarter = 1;
+        } else if (month >= Calendar.APRIL && month <= Calendar.JUNE) {
+            quarter = 2;
+        } else if (month >= Calendar.JULY && month <= Calendar.SEPTEMBER) {
+            quarter = 3;
+        } else {
+            quarter = 4;
+        }
+        return quarter;
+    }
+
+    public static int getDateYear(Date date) {
+        Calendar calendar = Calendar.getInstance(Locale.getDefault());
+        calendar.setTime(date); // 注意月份是从0开始的,即0=1月,1=2月,...
+        // 获取周数可能依赖于Calendar的设置,这里使用默认设置
+        int year = calendar.get(Calendar.YEAR);
+        return year;
+    }
+
+
+    public static String getDateIndexStr(Date date, String type) {
+        StringBuilder dateStr = new StringBuilder();
+        int year = DateUtils2.getDateYear(date);
+        dateStr.append(year+"年");
+        switch (type) {
+            case "week":
+                int week = DateUtils2.getDateWeekIndex(date);
+                dateStr.append("第" + week + "周");
+                break;
+            case "month":
+                int month = DateUtils2.getDateMonthIndex(date);
+                dateStr.append( month + "月");
+                break;
+            case "quarter":
+                int quarter = DateUtils2.getDateQuarterIndex(date);
+                dateStr.append("第" + quarter + "季度");
+                break;
+        }
+        String reDate = dateStr.toString();
+        return reDate;
+    }
 
 }

+ 25 - 16
src/main/java/cn/cslg/pas/common/utils/esDataForm/PatentClassifySplitter.java

@@ -25,27 +25,36 @@ public class PatentClassifySplitter {
         String level3 = "";
         String level4 = "";
         String level5 = "";
-        level1 = classify.substring(0, 1);
-        patentClassify.setLevel1(level1);
-        level2 = classify.substring(0, 3);
-        patentClassify.setLevel2(level2);
 
-        if (length >= 4) {
+
+        if (length >= 8) {
+            level1 = classify.substring(0, 1);
+            level2 = classify.substring(0, 3);
             level3 = classify.substring(0, 4);
             patentClassify.setLevel3(level3);
+            patentClassify.setLevel1(level1);
+
+            patentClassify.setLevel2(level2);
+            Integer s =classify.length();
 
-            if (length >= 8) {
-                Integer s =classify.length();
-
-                if(classify.contains("/"))
-                {
-                    s =classify.indexOf("/");
-                }
-                level4 = classify.substring(0, s);
-                patentClassify.setLevel4(level4);
-                level5 = classify;
-                patentClassify.setLevel5(level5);
+            if(classify.contains("/"))
+            {
+                s =classify.indexOf("/");
             }
+            level4 = classify.substring(0, s);
+            patentClassify.setLevel4(level4);
+            level5 = classify;
+            patentClassify.setLevel5(level5);
+        }
+
+     else  if (length >= 4) {
+            level1 =classify.substring(0,2);
+            level2= classify;
+            patentClassify.setLevel1(level1);
+
+            patentClassify.setLevel2(level2);
+
+
         }
         return patentClassify;
     }

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

@@ -1,7 +1,6 @@
 package cn.cslg.pas.common.vo;
 
 import cn.cslg.pas.common.dto.es.EsCustomFieldDTO;
-import com.baomidou.mybatisplus.annotation.TableField;
 import lombok.Data;
 
 import java.util.List;
@@ -96,4 +95,5 @@ public class ImportTaskAMVO {
     private String patentNoStr;
     private List<EsCustomFieldDTO> fieldDTOS;
     private Integer pdfType;
+    private String updateCycle;
 }

+ 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;
 }

+ 4 - 0
src/main/java/cn/cslg/pas/common/vo/business/ImportTaskVO.java

@@ -1,5 +1,6 @@
 package cn.cslg.pas.common.vo.business;
 
+import cn.cslg.pas.common.model.cronModel.SystemFile;
 import cn.cslg.pas.common.vo.ProgressVO;
 import com.baomidou.mybatisplus.annotation.TableField;
 import io.swagger.v3.oas.annotations.media.Schema;
@@ -76,4 +77,7 @@ public class ImportTaskVO {
     private Integer importToType;
     private String importToName;
     private Integer importToId;
+    private SystemFile systemFile;
+    private Integer importContent;
+    private String importContentName;
 }

+ 3 - 0
src/main/java/cn/cslg/pas/common/vo/business/PatentProjectVO.java

@@ -166,4 +166,7 @@ public class PatentProjectVO {
 
     @Schema(description = "状态")
     private Integer status;
+
+    @Schema(description = "状态")
+    private String updateCycle;
 }

+ 53 - 0
src/main/java/cn/cslg/pas/controller/ImportTaskConditionController.java

@@ -0,0 +1,53 @@
+package cn.cslg.pas.controller;
+
+import cn.cslg.pas.common.core.base.Constants;
+import cn.cslg.pas.common.importTask.QuartzConditionDTO;
+import cn.cslg.pas.common.importTask.QuartzConditionQueryDTO;
+import cn.cslg.pas.common.importTask.QuartzConditionRemoveDTO;
+import cn.cslg.pas.common.importTask.QuartzConditionUpdateDTO;
+import cn.cslg.pas.common.model.cronModel.Records;
+import cn.cslg.pas.common.model.request.StringRequest;
+import cn.cslg.pas.common.utils.Response;
+import cn.cslg.pas.domain.business.ImportTaskCondition;
+import cn.cslg.pas.factorys.businessFactory.Business;
+import cn.cslg.pas.service.business.ImportTaskConditionService;
+import io.swagger.v3.oas.annotations.Operation;
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+@Slf4j
+@RequestMapping(Constants.API_XiaoSHI + "/importTaskCondition")
+@RestController
+@RequiredArgsConstructor
+public class ImportTaskConditionController {
+private final ImportTaskConditionService importTaskConditionService;
+    @Operation(summary = "添加定时条件")
+    @PostMapping("/addQuartzCondition")
+    public Response addQuartzCondition(@RequestBody QuartzConditionDTO quartzConditionDTO) throws Exception {
+     ImportTaskCondition importTaskCondition = importTaskConditionService.addQuartzCondition(quartzConditionDTO);
+        return Response.success(importTaskCondition.getId());
+    }
+
+    @Operation(summary = "查询定时条件")
+    @PostMapping("/queryQuartzCondition")
+    public Response queryQuartzCondition(@RequestBody QuartzConditionQueryDTO quartzConditionQueryDTO) throws Exception {
+    Records records=importTaskConditionService.queryQuartzCondition(quartzConditionQueryDTO);
+        return Response.success(records);
+    }
+    @Operation(summary = "更新定时条件")
+    @PostMapping("/updateQuartzCondition")
+    public Response updateQuartzCondition(@RequestBody QuartzConditionUpdateDTO quartzConditionUpdateDTO) throws Exception {
+        importTaskConditionService.updateQuartzCondition(quartzConditionUpdateDTO);
+        return Response.success(true);
+    }
+
+    @Operation(summary = "删除定时条件")
+    @PostMapping("/removeQuartzCondition")
+    public Response removeQuartzCondition(@RequestBody QuartzConditionRemoveDTO quartzConditionRemoveDTO) throws Exception {
+        importTaskConditionService.removeQuartzCondition(quartzConditionRemoveDTO);
+        return Response.success(true);
+    }
+}

+ 12 - 0
src/main/java/cn/cslg/pas/controller/ImportTaskController.java

@@ -1,6 +1,8 @@
 package cn.cslg.pas.controller;
 
 
+import cn.cslg.pas.common.PatentImportErrorLog.ImportErrorLogQueryDTO;
+import cn.cslg.pas.common.PatentImportErrorLog.ImportErrorLogQueryVO;
 import cn.cslg.pas.common.core.base.Constants;
 import cn.cslg.pas.common.dto.ImportTaskDTO;
 import cn.cslg.pas.common.model.cronModel.Records;
@@ -27,6 +29,8 @@ public class ImportTaskController {
     @Autowired
     private BusinessFactory businessFactory;
 
+    @Autowired
+    private PatentImportErrorLogService patentImportErrorLogService;
     @Operation(summary = "查询导入任务")
     @PostMapping("/queryImportTask")
     public Response queryImportTask(@RequestBody StringRequest stringRequest) throws Exception {
@@ -64,4 +68,12 @@ public Response addPdfTask(@RequestBody AddImportPDFTaskDTO addImportPDFTaskDTO)
   Integer id=  importTaskService.addPdfTask(addImportPDFTaskDTO);
     return Response.success(id);
 }
+
+
+    @Operation(summary = "查询任务报错信息")
+    @PostMapping("/getPatentImportLog")
+    public Response getPatentImportLog(@RequestBody ImportErrorLogQueryDTO importErrorLogQueryDTO) throws Exception {
+        Records records=  patentImportErrorLogService.getPatentImportLog(importErrorLogQueryDTO);
+        return Response.success(records);
+    }
 }

+ 21 - 1
src/main/java/cn/cslg/pas/controller/PatentProjectController.java

@@ -4,16 +4,21 @@ import cn.cslg.pas.common.core.base.Constants;
 import cn.cslg.pas.common.dto.business.PatentProjectDTO;
 import cn.cslg.pas.common.dto.business.UpdateEventDTO;
 import cn.cslg.pas.common.dto.business.UpdatePatentProjectDTO;
+import cn.cslg.pas.common.importTask.ProjectQuartzQueryDTO;
+import cn.cslg.pas.common.importTask.ProjectQuartzSetDTO;
 import cn.cslg.pas.common.model.addPatentToReport.AddProjectPatentToReportDTO;
 import cn.cslg.pas.common.model.cronModel.Records;
 import cn.cslg.pas.common.model.request.StringGroupRequest;
 import cn.cslg.pas.common.model.request.StringRequest;
+import cn.cslg.pas.common.patentProject.ProjectQuartzDTO;
 import cn.cslg.pas.common.utils.Response;
+import cn.cslg.pas.domain.business.PatentProject;
 import cn.cslg.pas.exception.ConditionException;
 import cn.cslg.pas.exception.UnLoginException;
 import cn.cslg.pas.exception.XiaoShiException;
 import cn.cslg.pas.factorys.businessFactory.Business;
 import cn.cslg.pas.factorys.businessFactory.BusinessFactory;
+import cn.cslg.pas.service.business.PatentProjectService;
 import cn.cslg.pas.service.business.ProjectService;
 import com.alibaba.fastjson.JSONObject;
 import io.swagger.v3.oas.annotations.Operation;
@@ -40,7 +45,8 @@ public class PatentProjectController {
     private BusinessFactory businessFactory;
     @Autowired
     private ProjectService projectService;
-
+    @Autowired
+    private PatentProjectService patentProjectService;
     @Operation(summary = "查询专利数据库")
     @PostMapping("/queryPatentProject")
     public Response queryPatentProject(@RequestBody StringRequest stringRequest) throws Exception {
@@ -126,4 +132,18 @@ public class PatentProjectController {
         projectService.addProjectPatentToReport(addProjectPatentToReportDTO);
         return Response.success();
     }
+
+    @Operation(summary = "设置更新周期")
+    @PostMapping("/setProjectQuartz")
+    public Response setProjectQuartz(@RequestBody ProjectQuartzSetDTO projectQuartzSetDTO) throws Exception {
+        patentProjectService.setProjectQuartz(projectQuartzSetDTO);
+        return  Response.success(true);
+    }
+
+    @Operation(summary = "查询更新周期")
+    @PostMapping("/queryProjectQuartz")
+    public Response queryProjectQuartz(@RequestBody ProjectQuartzQueryDTO projectQuartzDTO) throws Exception {
+        PatentProject patentProject= patentProjectService.queryProjectQuartz(projectQuartzDTO);
+        return  Response.success(patentProject);
+    }
 }

+ 25 - 0
src/main/java/cn/cslg/pas/controller/ProjectMonitorSetController.java

@@ -0,0 +1,25 @@
+package cn.cslg.pas.controller;
+
+
+import cn.cslg.pas.common.core.base.Constants;
+import cn.cslg.pas.common.model.cronModel.Records;
+import cn.cslg.pas.common.model.request.StringRequest;
+import cn.cslg.pas.common.utils.Response;
+import io.swagger.v3.oas.annotations.Operation;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+@Slf4j
+@RequestMapping(Constants.API_XiaoSHI + "/projectMonitorSet")
+@RestController
+public class ProjectMonitorSetController {
+    @Operation(summary = "")
+    @PostMapping("/addQuartzCondition")
+    public Response addQuartzCondition(@RequestBody StringRequest stringRequest) throws Exception {
+
+        return null;
+    }
+}

+ 7 - 0
src/main/java/cn/cslg/pas/domain/business/ImportTask.java

@@ -4,6 +4,7 @@ import cn.cslg.pas.domain.BaseEntity;
 import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableName;
 import lombok.Data;
+import org.joda.time.DateTime;
 
 import java.util.Date;
 
@@ -94,4 +95,10 @@ public class ImportTask extends BaseEntity<ImportTask> {
     @TableField(value = "picture_done_num")
     private Integer pictureDoneNum;
     private String remark;
+
+    @TableField(value = "update_to_date")
+    private Date updateToDate;
+
+    @TableField(value = "last_update_to_date")
+    private Date lastUpdateToDate;
 }

+ 8 - 0
src/main/java/cn/cslg/pas/domain/business/ImportTaskCondition.java

@@ -37,6 +37,8 @@ public class ImportTaskCondition extends BaseEntity<ImportTaskCondition> {
      */
     private String crons;
 
+    private String updateCycle;
+
     /**
      * 上次更新时间
      */
@@ -105,4 +107,10 @@ public class ImportTaskCondition extends BaseEntity<ImportTaskCondition> {
     @TableField(value = "pdf_type")
     private Integer pdfType;
 
+
+    private String searchSetting;
+
+    private Boolean ifDelete;
+    private Boolean ifCycle;
+
 }

+ 2 - 0
src/main/java/cn/cslg/pas/domain/business/PatentProject.java

@@ -37,4 +37,6 @@ public class PatentProject extends BaseEntity<PatentProject> {
 
     @TableField(value = "status")
     private Integer status;
+
+    private String updateCycle;
 }

+ 1 - 0
src/main/java/cn/cslg/pas/domain/business/TreeNode.java

@@ -76,4 +76,5 @@ public class TreeNode extends BaseEntity<TreeNode> {
     @TableField(value = "description")
     private String description;
 
+
 }

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

@@ -129,6 +129,7 @@ public class Patent {
     /**
      * IPC分类号(主)
      */
+
     @JsonProperty("mipc")
     private PatentClassify mipc;
 
@@ -419,4 +420,19 @@ public class Patent {
     PatentJoin patentJoin;
 
 
+
+    /**
+     * 权要数量
+     */
+    @JsonProperty("right_num")
+    private Integer rightNum;
+
+
+    /**
+     * 主权要数量
+     */
+    @JsonProperty("main_right_num")
+    private Integer mainRightNum;
+
+
 }

+ 0 - 3
src/main/java/cn/cslg/pas/service/MailSendService.java

@@ -142,8 +142,5 @@ public class MailSendService {
             map.put("value3",taskName);
             rabbitMQUtils.sendEmailMessage(map);
         }
-
-
-
 }
 }

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

@@ -780,7 +780,7 @@ public class CustomFieldService extends ServiceImpl<CustomFieldMapper, CustomFie
     /**
      * @param customerFieldList
      */
-    public  List<EsCustomFieldDTO> getFieldDTOByStrings(List<UploadParamsVO.Field> customerFieldList, Integer projectId) {
+    public  List<EsCustomFieldDTO> getFieldDTOByStrings(List<UploadParamsVO.Field> customerFieldList, Integer projectId,Integer contionId) {
       List<EsCustomFieldDTO>  esCustomFieldDTOs =new ArrayList<>();
         if (customerFieldList != null && customerFieldList.size() != 0) {
 
@@ -812,7 +812,7 @@ public class CustomFieldService extends ServiceImpl<CustomFieldMapper, CustomFie
                         break;
                     case "6":
                         esCustomFieldDTO.setFieldType(Integer.parseInt(type));
-                       values =treeNodeService.getIdByNames(fieldList,fieldId);
+                       values =treeNodeService.getIdByNames(fieldList,fieldId,contionId);
                         break;
                 }
                 esCustomFieldDTO.setFieldValue(values);

+ 256 - 0
src/main/java/cn/cslg/pas/service/business/ImportTaskConditionService.java

@@ -1,10 +1,29 @@
 package cn.cslg.pas.service.business;
 
+import cn.cslg.pas.common.dto.ImportTaskDTO;
+import cn.cslg.pas.common.dto.es.EsCustomFieldDTO;
+import cn.cslg.pas.common.importTask.*;
+import cn.cslg.pas.common.model.cronModel.Personnel;
+import cn.cslg.pas.common.model.cronModel.PersonnelVO;
+import cn.cslg.pas.common.model.cronModel.Records;
+import cn.cslg.pas.common.utils.*;
 import cn.cslg.pas.domain.business.ImportTaskCondition;
+import cn.cslg.pas.exception.ExceptionEnum;
+import cn.cslg.pas.exception.XiaoShiException;
 import cn.cslg.pas.mapper.ImportTaskConditionMapper;
+import cn.cslg.pas.service.permissions.PermissionService;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import lombok.RequiredArgsConstructor;
+import org.springframework.beans.BeanUtils;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.util.ArrayList;
+import java.util.List;
 
 /**
  * 导入任务条件表业务层
@@ -15,4 +34,241 @@ import org.springframework.stereotype.Service;
 @Service
 @RequiredArgsConstructor
 public class ImportTaskConditionService extends ServiceImpl<ImportTaskConditionMapper, ImportTaskCondition> {
+    private final PermissionService permissionService;
+    private final PatentProjectService patentProjectService;
+    private final CacheUtils cacheUtils;
+    private final LoginUtils loginUtils;
+    /**
+     * 添加定时周期
+     *
+     * @param quartzConditionDTO
+     * @return
+     */
+    public ImportTaskCondition addQuartzCondition(QuartzConditionDTO quartzConditionDTO) {
+        PersonnelVO personnelVO = new PersonnelVO();
+        personnelVO = cacheUtils.getLoginUser(loginUtils.getId());
+        Integer projectId =quartzConditionDTO.getImportToId();
+        Boolean ifUpdate =quartzConditionDTO.getIfUpdate();
+        String updateCycle=quartzConditionDTO.getUpdateCycle();
+        ImportTaskCondition importTaskCondition = new ImportTaskCondition();
+        importTaskCondition.setProjectType(0);
+        importTaskCondition.setSearchCondition(quartzConditionDTO.getSearchCondition());
+        importTaskCondition.setProjectId(projectId);
+        importTaskCondition.setDbType(quartzConditionDTO.getDBType());
+        importTaskCondition.setType(4);
+        importTaskCondition.setUpdateCycle(quartzConditionDTO.getUpdateCycle());
+        importTaskCondition.setIfUpdate(true);
+        importTaskCondition.setIfCycle(true);
+        importTaskCondition.setOrderByType(quartzConditionDTO.getOrderByType());
+        importTaskCondition.setOrderBy(quartzConditionDTO.getOrderBy());
+        importTaskCondition.setImportContent(quartzConditionDTO.getImportContent());
+        importTaskCondition.setSearchSetting(quartzConditionDTO.getSearchSetting());
+        importTaskCondition.setUpdateCycle(quartzConditionDTO.getUpdateCycle());
+        importTaskCondition.setCreateId(personnelVO.getId());
+        //保存标引信息
+        if (quartzConditionDTO.getFieldDTOS() != null && quartzConditionDTO.getFieldDTOS().size() > 0) {
+            String fieldJson = JsonUtils.objectToJson(quartzConditionDTO.getFieldDTOS());
+            importTaskCondition.setCustomFields(fieldJson);
+        }
+        //保存周期
+        String crons = CronUtil.getCron(quartzConditionDTO.getUpdateCycle());
+        importTaskCondition.setCrons(crons);
+        importTaskCondition.insert();
+        if(ifUpdate!=null&&ifUpdate){
+            Boolean flag= patentProjectService.checkIfHaveQuartz(projectId);
+            if(flag==null||!flag){
+                ProjectQuartzSetDTO projectQuartzSetDTO =new ProjectQuartzSetDTO();
+                projectQuartzSetDTO.setProjectId(projectId);
+                projectQuartzSetDTO.setIfUpdate(ifUpdate);
+                projectQuartzSetDTO.setUpdateCycle(updateCycle);
+                patentProjectService.setProjectQuartz(projectQuartzSetDTO);
+            }
+        }
+        return importTaskCondition;
+    }
+
+
+    public ImportTaskCondition addQuartzCondition(ImportTaskDTO importTaskDTO){
+
+        PersonnelVO personnelVO = new PersonnelVO();
+        personnelVO = cacheUtils.getLoginUser(loginUtils.getId());
+        Boolean ifUpdate =importTaskDTO.getIfUpdate();
+        ImportTaskCondition importTaskCondition = new ImportTaskCondition();
+        if (importTaskDTO.getImportToId() != null) {
+            if (importTaskDTO.getImportToType().equals(0)) {
+                importTaskCondition.setProjectType(0);
+                importTaskCondition.setProjectId(importTaskDTO.getImportToId());
+            } else if (importTaskDTO.getImportToType().equals(1)) {
+                importTaskCondition.setProjectType(1);
+                importTaskCondition.setProjectId(importTaskDTO.getImportToId());
+            } else if (importTaskDTO.getImportToType().equals(2)) {
+                importTaskCondition.setProductId(importTaskDTO.getImportToId());
+            }
+        }
+        importTaskCondition.setImportContent(importTaskDTO.getImportContent());
+        importTaskCondition.setCrons(importTaskDTO.getCrons());
+        importTaskCondition.setSearchCondition(importTaskDTO.getSearchCondition());
+        importTaskCondition.setType(importTaskDTO.getType());
+        importTaskCondition.setFileGuid(importTaskDTO.getFileGuid());
+        importTaskCondition.setSourceId(importTaskDTO.getSourceId());
+        importTaskCondition.setDbType(importTaskDTO.getDBType());
+        importTaskCondition.setOrderBy(importTaskDTO.getOrderBy());
+        importTaskCondition.setOrderByType(importTaskDTO.getOrderByType());
+        importTaskCondition.setIfCycle(importTaskDTO.getIfUpdate());
+        if(ifUpdate!=null&&ifUpdate){
+            importTaskCondition.setIfUpdate(true);
+        }
+        importTaskCondition.setCreateId(personnelVO.getId());
+
+        if (importTaskDTO.getPatentNos() != null && importTaskDTO.getPatentNos().size() > 0) {
+            String jsons = JSONObject.toJSON(importTaskDTO.getPatentNos()).toString();
+            importTaskCondition.setPatentNos(jsons);
+        }
+
+        //保存标引信息
+        if (importTaskDTO.getFieldDTOS() != null && importTaskDTO.getFieldDTOS().size() > 0) {
+            String fieldJson = JsonUtils.objectToJson(importTaskDTO.getFieldDTOS());
+            importTaskCondition.setCustomFields(fieldJson);
+        }
+        importTaskCondition.insert();
+return  importTaskCondition;
+
+    }
+    /**
+     * 查询定时任务条件
+     *
+     * @param quartzConditionQueryDTO
+     * @return
+     */
+    public Records queryQuartzCondition(QuartzConditionQueryDTO quartzConditionQueryDTO) {
+        Long size = quartzConditionQueryDTO.getSize();
+        Long current = quartzConditionQueryDTO.getCurrent();
+        Integer projectId = quartzConditionQueryDTO.getProjectId();
+
+        LambdaQueryWrapper<ImportTaskCondition> queryWrapper = new LambdaQueryWrapper<>();
+        queryWrapper.eq(ImportTaskCondition::getProjectId, projectId)
+                .eq(ImportTaskCondition::getIfDelete, false)
+                .eq(ImportTaskCondition::getIfCycle,true);
+
+        Records records = new Records();
+        records.setSize(size);
+        records.setCurrent(current);
+        List<ImportTaskCondition> importTaskConditions = new ArrayList<>();
+        if (size != null && current != null) {
+            Page<ImportTaskCondition> page = this.page(new Page<>(current, size), queryWrapper);
+            importTaskConditions = page.getRecords();
+            records.setTotal(page.getTotal());
+        } else {
+            importTaskConditions = this.list(queryWrapper);
+            Long total = this.count(queryWrapper);
+            records.setTotal(total);
+        }
+        try {
+            List<ImportTaskConditionVO> importTaskConditionVOS = this.loadImportVos(importTaskConditions);
+            records.setData(importTaskConditionVOS);
+        } catch (Exception e) {
+            throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, "装载信息错误");
+        }
+
+        return records;
+    }
+
+    public List<ImportTaskConditionVO> loadImportVos(List<ImportTaskCondition> importTaskConditions) throws Exception {
+        List<ImportTaskConditionVO> importTaskConditionVOS = new ArrayList<>();
+        List<String> createIds = new ArrayList<>();
+        List<Personnel> personnels = new ArrayList<>();
+        importTaskConditions.forEach(
+                item -> {
+                    if (item.getCreateId() != null) {
+                        createIds.add(item.getCreateId());
+                    }
+                }
+        );
+
+        if (createIds.size() != 0) {
+            String res = permissionService.getPersonnelByIdsFromPCS(createIds);
+            JSONObject jsonObject = JSONObject.parseObject(res);
+            personnels = JSONObject.parseArray(jsonObject.getString("data"), Personnel.class);
+        }
+        for (ImportTaskCondition importTaskCondition : importTaskConditions) {
+            ImportTaskConditionVO importTaskConditionVO =new ImportTaskConditionVO();
+            BeanUtils.copyProperties(importTaskCondition,importTaskConditionVO);
+
+            String customFields =importTaskCondition.getCustomFields();
+            if(customFields!=null&&!customFields.equals(""))
+            {
+                List<EsCustomFieldDTO> esCustomFieldDTOList = JSONArray.parseArray(customFields,EsCustomFieldDTO.class);
+                importTaskConditionVO.setFieldDTOS(esCustomFieldDTOList);
+            }
+         Personnel personnel =personnels.stream().filter(item->item.getId().equals(importTaskCondition.getCreateId())).findFirst().orElse(null);
+            if(personnel!=null){
+                importTaskConditionVO.setCreateName(personnel.getPersonnelName());
+            }
+  importTaskConditionVOS.add(importTaskConditionVO);
+
+        }
+        return importTaskConditionVOS;
+    }
+
+
+
+    /**
+     * 添加定时周期
+     *
+     * @param quartzConditionDTO
+     * @return
+     */
+    @Transactional(rollbackFor = Exception.class)
+    public ImportTaskCondition updateQuartzCondition(QuartzConditionUpdateDTO quartzConditionDTO) {
+         Integer id =quartzConditionDTO.getId();
+        ImportTaskCondition importTaskCondition =this.getById(id);
+        if(importTaskCondition==null){
+            throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR,"未查询到条件");
+        }
+        Boolean ifUpdate =quartzConditionDTO.getIfUpdate();
+        String updateCycle=quartzConditionDTO.getUpdateCycle();
+        importTaskCondition.setSearchCondition(quartzConditionDTO.getSearchCondition());
+        importTaskCondition.setDbType(quartzConditionDTO.getDbType());
+        importTaskCondition.setIfUpdate(ifUpdate);
+        importTaskCondition.setOrderByType(quartzConditionDTO.getOrderByType());
+        importTaskCondition.setOrderBy(quartzConditionDTO.getOrderBy());
+        importTaskCondition.setImportContent(MathUtils.BinaryToDecimal(quartzConditionDTO.getImportContent()));
+        importTaskCondition.setSearchSetting(quartzConditionDTO.getSearchSetting());
+        importTaskCondition.setUpdateCycle(quartzConditionDTO.getUpdateCycle());
+        //保存标引信息
+        if (quartzConditionDTO.getFieldDTOS() != null && quartzConditionDTO.getFieldDTOS().size() > 0) {
+            String fieldJson = JsonUtils.objectToJson(quartzConditionDTO.getFieldDTOS());
+            importTaskCondition.setCustomFields(fieldJson);
+        }
+        //保存周期
+        String crons = CronUtil.getCron(quartzConditionDTO.getUpdateCycle());
+        importTaskCondition.setCrons(crons);
+        importTaskCondition.updateById();
+
+                ProjectQuartzSetDTO projectQuartzSetDTO =new ProjectQuartzSetDTO();
+                projectQuartzSetDTO.setProjectId(importTaskCondition.getProjectId());
+                projectQuartzSetDTO.setIfUpdate(ifUpdate);
+                projectQuartzSetDTO.setUpdateCycle(updateCycle);
+                patentProjectService.setProjectQuartz(projectQuartzSetDTO);
+
+        return importTaskCondition;
+    }
+
+
+
+    /**
+     * 删除定时周期条件
+     *
+     * @param quartzConditionRemoveDTO
+     * @return
+     */
+    @Transactional(rollbackFor = Exception.class)
+    public Boolean removeQuartzCondition(QuartzConditionRemoveDTO quartzConditionRemoveDTO) {
+        List<Integer> ids =quartzConditionRemoveDTO.getIds();
+        if(ids==null||ids.size()==0){
+            throw new XiaoShiException(ExceptionEnum.BUSINESS_CHECK,"请选择至少一个条件");
+        }
+        this.removeBatchByIds(ids);
+        return  true;
+    }
 }

+ 177 - 94
src/main/java/cn/cslg/pas/service/business/ImportTaskService.java

@@ -3,6 +3,7 @@ package cn.cslg.pas.service.business;
 import cn.cslg.pas.common.dto.ExportTaskDTO;
 import cn.cslg.pas.common.dto.ImportTaskDTO;
 import cn.cslg.pas.common.dto.PatentStarListDTO;
+import cn.cslg.pas.common.importTask.QuartzConditionDTO;
 import cn.cslg.pas.common.model.cronModel.Personnel;
 import cn.cslg.pas.common.model.cronModel.PersonnelVO;
 import cn.cslg.pas.common.model.cronModel.Records;
@@ -12,6 +13,7 @@ import cn.cslg.pas.common.model.request.GroupRequest;
 import cn.cslg.pas.common.model.request.QueryRequest;
 import cn.cslg.pas.common.utils.*;
 import cn.cslg.pas.common.vo.ImportTaskAMVO;
+import cn.cslg.pas.common.vo.StarPatentVO;
 import cn.cslg.pas.common.vo.business.ImportTaskVO;
 import cn.cslg.pas.domain.business.*;
 import cn.cslg.pas.exception.UnLoginException;
@@ -30,6 +32,8 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import lombok.RequiredArgsConstructor;
 import org.apache.commons.compress.utils.IOUtils;
 import org.apache.poi.ss.usermodel.Sheet;
+import org.joda.time.DateTime;
+import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.context.annotation.Lazy;
 import org.springframework.stereotype.Service;
@@ -37,10 +41,8 @@ import org.springframework.transaction.annotation.Transactional;
 import org.springframework.web.multipart.MultipartFile;
 
 import java.io.*;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
+import java.util.stream.Collectors;
 
 /**
  * 导入任务表业务层
@@ -88,7 +90,6 @@ public class ImportTaskService extends ServiceImpl<ImportTaskMapper, ImportTask>
         List<ImportTaskVO> importTaskVOS = importTaskMapper.getImportTask(sqls.get(0), sqls.get(1), sqls.get(2));
         //查询总数
         Long total = importTaskMapper.getImportTaskCount(sqls.get(0));
-
         //装载事件信息
         this.loadImportTask(importTaskVOS);
         Records records = new Records();
@@ -122,59 +123,36 @@ public class ImportTaskService extends ServiceImpl<ImportTaskMapper, ImportTask>
     @Override
     @Transactional(rollbackFor = Exception.class)
     public Object addMessage(Object object) {
+
         if (object == null) {
             throw new XiaoShiException("参数不能为空");
         }
+
         //TODO 校验参数
         ImportTaskDTO importTaskDTO = (ImportTaskDTO) object;
-
+        Boolean ifUpdate = importTaskDTO.getIfUpdate();
         PersonnelVO personnelVO = new PersonnelVO();
-
-            personnelVO = cacheUtils.getLoginUser(loginUtils.getId());
-
+        personnelVO = cacheUtils.getLoginUser(loginUtils.getId());
 
         if (importTaskDTO.getType() == null) {
             importTaskDTO.setType(4);
         }
         List<String> addPatentNos = importTaskDTO.getPatentNos();
-        ImportTaskCondition importTaskCondition = new ImportTaskCondition();
-        if (importTaskDTO.getImportToId() != null) {
-            if (importTaskDTO.getImportToType().equals(0)) {
-                importTaskCondition.setProjectType(0);
-                importTaskCondition.setProjectId(importTaskDTO.getImportToId());
-            } else if (importTaskDTO.getImportToType().equals(1)) {
-                importTaskCondition.setProjectType(1);
-                importTaskCondition.setProjectId(importTaskDTO.getImportToId());
-            } else if (importTaskDTO.getImportToType().equals(2)) {
-                importTaskCondition.setProductId(importTaskDTO.getImportToId());
-            }
-        }
+
         if (!importTaskDTO.getType().equals(1)) {
             importTaskDTO.setImportContent(MathUtils.BinaryToDecimal(importTaskDTO.getImportContent()));
         }
-        importTaskCondition.setImportContent(importTaskDTO.getImportContent());
-        importTaskCondition.setCrons(importTaskDTO.getCrons());
-        importTaskCondition.setIfUpdate(importTaskDTO.getIfUpdate());
-        importTaskCondition.setSearchCondition(importTaskDTO.getSearchCondition());
-        importTaskCondition.setType(importTaskDTO.getType());
-        importTaskCondition.setFileGuid(importTaskDTO.getFileGuid());
-        importTaskCondition.setSourceId(importTaskDTO.getSourceId());
-        importTaskCondition.setDbType(importTaskDTO.getDBType());
-        importTaskCondition.setOrderBy(importTaskDTO.getOrderBy());
-        importTaskCondition.setOrderByType(importTaskDTO.getOrderByType());
-        importTaskCondition.setCreateId(personnelVO.getId());
-
-        if (importTaskDTO.getPatentNos() != null && importTaskDTO.getPatentNos().size() > 0) {
-            String jsons = JSONObject.toJSON(importTaskDTO.getPatentNos()).toString();
-            importTaskCondition.setPatentNos(jsons);
-        }
+        ImportTaskCondition importTaskCondition = new ImportTaskCondition();
 
-        //保存标引信息
-        if (importTaskDTO.getFieldDTOS() != null && importTaskDTO.getFieldDTOS().size() > 0) {
-            String fieldJson = JsonUtils.objectToJson(importTaskDTO.getFieldDTOS());
-            importTaskCondition.setCustomFields(fieldJson);
+
+        if (ifUpdate != null && ifUpdate) {
+            QuartzConditionDTO quartzConditionDTO = new QuartzConditionDTO();
+            BeanUtils.copyProperties(importTaskDTO, quartzConditionDTO);
+            importTaskCondition = importTaskConditionService.addQuartzCondition(quartzConditionDTO);
+        } else {
+            importTaskCondition = importTaskConditionService.addQuartzCondition(importTaskDTO);
         }
-        importTaskCondition.insert();
+
 
         //装载任务
         ImportTask importTask = new ImportTask();
@@ -194,7 +172,7 @@ public class ImportTaskService extends ServiceImpl<ImportTaskMapper, ImportTask>
                 File tempFile = File.createTempFile(systemFile.getFileName() + "temp", suffix);
                 try (
                         InputStream inputStream = new ByteArrayInputStream(bytes);
-                        FileOutputStream outputStream = new FileOutputStream(tempFile)
+                        FileOutputStream outputStream = new FileOutputStream(tempFile);
                 ) {
                     IOUtils.copy(inputStream, outputStream); // 将输入流复制到临时文件
                 }
@@ -203,7 +181,7 @@ public class ImportTaskService extends ServiceImpl<ImportTaskMapper, ImportTask>
                 //删除临时文件tempFile
                 new File(tempFile.getPath()).delete();
             } catch (Exception e) {
-//                e.printStackTrace();
+                e.printStackTrace();
                 throw new XiaoShiException(e.getMessage());
             }
         } else if (importTaskCondition.getType().equals(4)) {
@@ -214,9 +192,8 @@ public class ImportTaskService extends ServiceImpl<ImportTaskMapper, ImportTask>
                             .setOrderBy(importTaskCondition.getOrderBy())
                             .setOrderByType(importTaskCondition.getOrderByType())
                             .setPageNum(1)
-                            .setRowCount(50)
+                            .setRowCount(10)
                             .setDBType(importTaskCondition.getDbType());
-
                     //调用一般接口返回一批专利著录相关数据
                     Map<String, Object> resultMap = patentStarApiService.patentStarSearchApi(patentStarListDto);
                     if (resultMap == null || (Integer) resultMap.get("total") == 0) {
@@ -252,10 +229,8 @@ public class ImportTaskService extends ServiceImpl<ImportTaskMapper, ImportTask>
                     }
                     Sheet sheet = ReadExcelUtils.readExcel(tempFile);
                     patentNos = ReadExcelUtils.getPatentNoFromExcel(sheet);
-
                 } catch (Exception e) {
                 }
-
             }
             importTask.setAllNum(patentNos.size());
         }
@@ -263,10 +238,8 @@ public class ImportTaskService extends ServiceImpl<ImportTaskMapper, ImportTask>
         String taskName = this.setImportTaskName(importTaskCondition, personnelVO.getName());
         importTask.setName(taskName);
         importTask.insert();
-
         schedulingTaskService.startTask();
         return importTask.getId();
-
     }
 
     @Override
@@ -282,21 +255,27 @@ public class ImportTaskService extends ServiceImpl<ImportTaskMapper, ImportTask>
         List<String> createIds = new ArrayList<>();
 
         List<Integer> projectIds = new ArrayList<>();
-        List<Integer> productIds =new ArrayList<>();
+        List<Integer> productIds = new ArrayList<>();
+        List<String> guids = new ArrayList<>();
         importTaskVOS.forEach(item -> {
             if (item.getCreateId() != null) {
                 createIds.add(item.getCreateId());
             }
-            if(item.getProductId()!=null){
+            if (item.getProductId() != null) {
                 productIds.add(item.getProductId());
             }
-            if(item.getProjectId()!=null){
+            if (item.getProjectId() != null) {
                 projectIds.add(item.getProjectId());
             }
+            if (item.getFileGuid() != null) {
+                guids.add(item.getFileGuid());
+            }
         });
         List<Personnel> personnels = new ArrayList<>();
         List<Product> products = new ArrayList<>();
         List<Project> projects = new ArrayList<>();
+        List<SystemFile> systemFiles = new ArrayList<>();
+
         //查询创建人名称
         if (createIds.size() != 0) {
             String res = permissionService.getPersonnelByIdsFromPCS(createIds);
@@ -306,16 +285,25 @@ public class ImportTaskService extends ServiceImpl<ImportTaskMapper, ImportTask>
 
         //查询项目名称
         if (projectIds.size() != 0) {
-            LambdaQueryWrapper<Project> queryWrapper =new LambdaQueryWrapper<>();
-            queryWrapper.in(Project::getId,projectIds);
-            projects =projectService.list(queryWrapper);
+            LambdaQueryWrapper<Project> queryWrapper = new LambdaQueryWrapper<>();
+            queryWrapper.in(Project::getId, projectIds);
+            projects = projectService.list(queryWrapper);
         }
 
         //查询产品名称
         if (productIds.size() != 0) {
-            LambdaQueryWrapper<Product> queryWrapper =new LambdaQueryWrapper<>();
-            queryWrapper.in(Product::getId,productIds);
-            products =productService.list(queryWrapper);
+            LambdaQueryWrapper<Product> queryWrapper = new LambdaQueryWrapper<>();
+            queryWrapper.in(Product::getId, productIds);
+            products = productService.list(queryWrapper);
+        }
+
+        //查询文件
+        if (guids.size() != 0) {
+            String res = fileManagerService.getSystemFileFromFMS(guids);
+            systemFiles = JSONObject.parseArray(res, SystemFile.class);
+            if (systemFiles == null) {
+                systemFiles = new ArrayList<>();
+            }
         }
 
         LambdaQueryWrapper<SystemDict> lambdaQueryWrapper = new LambdaQueryWrapper<>();
@@ -327,12 +315,10 @@ public class ImportTaskService extends ServiceImpl<ImportTaskMapper, ImportTask>
             if (personnel != null) {
                 importTaskVO.setCreateName(personnel.getPersonnelName());
             }
-
             //装载状态
             SystemDict systemDict1 = systemDictList.stream()
                     .filter(item -> item.getType().equals("IMPORT_TASK_TYPE") && item.getType()
                             .equals(importTaskVO.getType().toString())).findFirst().orElse(null);
-
             SystemDict systemDict2 = systemDictList.stream()
                     .filter(item -> item.getType().equals("IMPORT_TASk_STATE") && item.getType()
                             .equals(importTaskVO.getState().toString())).findFirst().orElse(null);
@@ -352,28 +338,37 @@ public class ImportTaskService extends ServiceImpl<ImportTaskMapper, ImportTask>
             long percentage = (long) Math.floor((importTaskVO.getDoneNum() + 0D) / importTaskVO.getAllNum() * 100D);
             importTaskVO.setPercentage(percentage);
 
-
             //装载目标名称
-          if(projects.size()>0&&importTaskVO.getProjectId()!=null){
-          Project project =projects.stream().filter(item->item.getId().equals(importTaskVO.getProjectId())).findFirst().orElse(null);
-          if(project!=null){
-              importTaskVO.setImportToId(project.getId());
-              importTaskVO.setImportToType(project.getType()-1);
-              importTaskVO.setImportToName(project.getName());
-          }
-          }
-          else if(products.size()>0&&importTaskVO.getProductId()!=null){
-           Product product =products.stream().filter(item->item.getId().equals(importTaskVO.getProductId())).findFirst().orElse(null);
-           if(product!=null){
-               importTaskVO.setImportToId(product.getId());
-               importTaskVO.setImportToType(2);
-               importTaskVO.setImportToName(product.getName());
-           }
+            if (projects.size() > 0 && importTaskVO.getProjectId() != null) {
+                Project project = projects.stream().filter(item -> item.getId().equals(importTaskVO.getProjectId())).findFirst().orElse(null);
+                if (project != null) {
+                    importTaskVO.setImportToId(project.getId());
+                    importTaskVO.setImportToType(project.getType() - 1);
+                    if (project.getType().equals(1)) {
+                        importTaskVO.setImportToName(project.getName() + "-专利数据库");
+                    } else {
+                        importTaskVO.setImportToName(project.getName() + "-报告");
+                    }
+                }
+            } else if (products.size() > 0 && importTaskVO.getProductId() != null) {
+                Product product = products.stream().filter(item -> item.getId().equals(importTaskVO.getProductId())).findFirst().orElse(null);
+                if (product != null) {
+                    importTaskVO.setImportToId(product.getId());
+                    importTaskVO.setImportToType(2);
+                    importTaskVO.setImportToName(product.getName());
+                }
+            }
 
-          }
+            if (importTaskVO.getFileGuid() != null) {
+                SystemFile systemFile = systemFiles.stream().filter(item -> item.getGuid().equals(importTaskVO.getFileGuid())).findFirst().orElse(null);
+                importTaskVO.setSystemFile(systemFile);
+            }
+           if(importTaskVO.getImportContent()!=null){
+               String icn=this.getImportContentStr(importTaskVO.getImportContent(),importTaskVO.getType());
+               importTaskVO.setImportContentName(icn);
+           }
 
         }
-
     }
 
 
@@ -435,6 +430,7 @@ public class ImportTaskService extends ServiceImpl<ImportTaskMapper, ImportTask>
 
     }
 
+
     public Integer addExportTask(ExportTaskDTO exportTaskDTO) {
         if (exportTaskDTO == null) {
             throw new XiaoShiException("入参不能为空");
@@ -523,30 +519,117 @@ public class ImportTaskService extends ServiceImpl<ImportTaskMapper, ImportTask>
         } else if ((sqls.get(0) == null || sqls.get(0).equals("")) && !rootSql.equals("")) {
             sqls.set(0, rootSql);
         }
-
         return sqls;
-
     }
 
-
-
-    public  Integer addPdfTask(AddImportPDFTaskDTO addImportPDFTaskDTO){
-        String fileGuid =addImportPDFTaskDTO.getFileGuid();
-        Integer pdfType =addImportPDFTaskDTO.getPdfType();
-        String remark =addImportPDFTaskDTO.getRemark();
-        ImportTaskCondition importTaskCondition =new ImportTaskCondition();
+    public Integer addPdfTask(AddImportPDFTaskDTO addImportPDFTaskDTO) {
+        String fileGuid = addImportPDFTaskDTO.getFileGuid();
+        Integer pdfType = addImportPDFTaskDTO.getPdfType();
+        String remark = addImportPDFTaskDTO.getRemark();
+        ImportTaskCondition importTaskCondition = new ImportTaskCondition();
         importTaskCondition.setFileGuid(fileGuid);
         importTaskCondition.setType(5);
         importTaskCondition.setPdfType(pdfType);
         importTaskCondition.setCreateId("1");
         importTaskCondition.insert();
-        ImportTask importTask =new ImportTask();
+        ImportTask importTask = new ImportTask();
         importTask.setImportTaskConditionId(importTaskCondition.getId());
-         importTask.setRemark(remark);
-         importTask.setCreateId("1");
-         importTask.setType(5);
-         importTask.insert();
+        importTask.setRemark(remark);
+        importTask.setCreateId("1");
+        importTask.setType(5);
+        importTask.insert();
         schedulingTaskService.startTask();
-        return  importTask.getId();
+        return importTask.getId();
+    }
+
+    public void addImportTaskByCondition(ImportTaskCondition importTaskCondition) {
+        //根据id查询最近更新的任务
+        LambdaQueryWrapper<ImportTask> queryWrapper = new LambdaQueryWrapper<>();
+        queryWrapper.eq(ImportTask::getImportTaskConditionId, importTaskCondition.getId())
+                .orderByDesc(ImportTask::getUpdateToDate);
+        ImportTask lastImportTask = this.getOne(queryWrapper, false);
+        String condition = importTaskCondition.getSearchCondition();
+        Date date = new Date();
+        Date toDate = DateUtils.getDate(date, -7);
+        if (lastImportTask == null) {
+            String toDateStr = DateUtils2.dateTimeToPatentStr(toDate);
+            condition = condition + " and PD<" + toDateStr;
+        } else if (lastImportTask != null && lastImportTask.getUpdateToDate() != null) {
+            Date fromDate = DateUtils.getDate(lastImportTask.getUpdateToDate(), 1);
+            String fromDateStr = DateUtils2.dateTimeToPatentStr(fromDate);
+            String todateStr = DateUtils2.dateTimeToPatentStr(toDate);
+            condition = condition + " and (PD=" + fromDateStr + "~" + todateStr + " or GD=" + fromDateStr + "~" + todateStr + ")";
+        } else if (lastImportTask != null && lastImportTask.getUpdateToDate() == null) {
+            Date fromDate = DateUtils.getDate(lastImportTask.getCreateTime(), -7);
+            String fromDateStr = DateUtils2.dateTimeToPatentStr(fromDate);
+            String todateStr = DateUtils2.dateTimeToPatentStr(toDate);
+            condition = condition + " and (PD=" + fromDateStr + "~" + todateStr + " or GD=" + fromDateStr + "~" + todateStr + ")";
+        }
+        PatentStarListDTO patentStarListDto = new PatentStarListDTO()
+                .setCurrentQuery(condition)
+                .setPageNum(1)
+                .setRowCount(10)
+                .setDBType(importTaskCondition.getDbType());
+        //调用一般接口返回一批专利著录相关数据
+        ImportTask importTask = new ImportTask();
+        try {
+            Map<String, Object> resultMap = patentStarApiService.patentStarSearchApi(patentStarListDto);
+            if (resultMap == null || (Integer) resultMap.get("total") == 0) {
+                return;
+            } else {
+                importTask.setAllNum((Integer) resultMap.get("total"));
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+
+        }
+
+        importTask.setImportTaskConditionId(importTaskCondition.getId());
+        importTask.setType(importTaskCondition.getType());
+        importTask.setSearchCondition(condition);
+        importTask.setCreateId(importTaskCondition.getCreateId());
+        importTask.setUpdateToDate(toDate);
+        importTask.insert();
+        schedulingTaskService.startTask();
+    }
+
+    public String getImportContentStr(Integer importContent, Integer taskType) {
+        List<String> contents = new ArrayList<>();
+        String imContents = "0000";
+        //当任务为excel导入
+        if (taskType.equals(1)) {
+            imContents = "1100";
+        }
+        //当任务为pdf导入
+        else if (taskType.equals(5)) {
+            imContents = "0001";
+        } else if (!importContent.equals(0)) {
+            imContents = MathUtils.fun(2, importContent);
+        }
+        //下载字段
+        char[] importCells = imContents.toCharArray();
+        char ifCataloguing = importCells[0];
+        char ifAddPicture = importCells[1];
+        char ifFullText = importCells[2];
+        char ifPdf = importCells[3];
+        if (ifCataloguing == '1') {
+            contents.add("著录信息");
+        }
+        if (ifAddPicture == '1') {
+            contents.add("摘要附图");
+
+        }
+        if (ifFullText == '1') {
+            contents.add("权要或说明书");
+
+        }
+        if (ifPdf == '1') {
+            contents.add("pdf或外观附图");
+        }
+        String contentStr = "";
+        if (contents.size() > 0) {
+            contentStr = StringUtils.join(contents, " ");
+        }
+        return contentStr;
     }
 }

+ 69 - 0
src/main/java/cn/cslg/pas/service/business/PatentImportErrorLogService.java

@@ -1,14 +1,83 @@
 package cn.cslg.pas.service.business;
 
 
+import cn.cslg.pas.common.PatentImportErrorLog.ImportErrorLogQueryDTO;
+import cn.cslg.pas.common.PatentImportErrorLog.ImportErrorLogQueryVO;
+import cn.cslg.pas.common.model.cronModel.Records;
 import cn.cslg.pas.domain.business.AssoEventFile;
 import cn.cslg.pas.domain.business.PatentImportErrorLog;
 import cn.cslg.pas.mapper.AssoEventFileMapper;
 import cn.cslg.pas.mapper.PatentImportErrorLogMapper;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.beans.BeanUtils;
 import org.springframework.stereotype.Service;
 
+import java.util.ArrayList;
+import java.util.List;
+
 @Service
 public class PatentImportErrorLogService extends ServiceImpl<PatentImportErrorLogMapper, PatentImportErrorLog> {
 
+    public Records getPatentImportLog(ImportErrorLogQueryDTO importErrorLogQueryDTO) {
+        Records records = new Records();
+        Long size = importErrorLogQueryDTO.getSize();
+        Long current = importErrorLogQueryDTO.getCurrent();
+        records.setSize(size);
+        records.setCurrent(current);
+        Integer taskId = importErrorLogQueryDTO.getTaskId();
+        LambdaQueryWrapper<PatentImportErrorLog> queryWrapper = new LambdaQueryWrapper<>();
+        queryWrapper.eq(PatentImportErrorLog::getTaskId, taskId);
+        List<PatentImportErrorLog> logList = new ArrayList<>();
+        if (size != null && current != null) {
+            IPage<PatentImportErrorLog> page = this.page(new Page<>(current, size), queryWrapper);
+            logList = page.getRecords();
+            List<ImportErrorLogQueryVO> importErrorLogQueryVOS = this.loadRecord(logList);
+            records.setData(importErrorLogQueryVOS);
+            records.setTotal(page.getTotal());
+        } else {
+            logList = this.list(queryWrapper);
+            List<ImportErrorLogQueryVO> importErrorLogQueryVOS = this.loadRecord(logList);
+            records.setData(importErrorLogQueryVOS);
+        }
+        return records;
+
+    }
+
+    public List<ImportErrorLogQueryVO> loadRecord(List<PatentImportErrorLog> errorLogs) {
+        List<ImportErrorLogQueryVO> importErrorLogQueryVOS = new ArrayList<>();
+        for (PatentImportErrorLog log : errorLogs) {
+            ImportErrorLogQueryVO importErrorLogQueryVO = new ImportErrorLogQueryVO();
+            BeanUtils.copyProperties(log, importErrorLogQueryVO);
+
+            if (importErrorLogQueryVO.getErrorType() != null) {
+                switch (importErrorLogQueryVO.getErrorType()) {
+                    case -1:
+                        importErrorLogQueryVO.setErrorName("未查询到专利");
+                        break;
+                    case 1:
+                        importErrorLogQueryVO.setErrorName("未查询到说明书");
+                        break;
+
+                    case 2:
+                        importErrorLogQueryVO.setErrorName("未查询到权要");
+                        break;
+
+                    case 3:
+                        importErrorLogQueryVO.setErrorName("未查询到摘要附图");
+                        break;
+
+                    case 4:
+                        importErrorLogQueryVO.setErrorName("未查询到pdf或外观附图");
+                        break;
+
+                }
+
+            }
+            importErrorLogQueryVOS.add(importErrorLogQueryVO);
+        }
+        return importErrorLogQueryVOS;
+    }
 }

+ 191 - 21
src/main/java/cn/cslg/pas/service/business/PatentProjectService.java

@@ -2,11 +2,15 @@ package cn.cslg.pas.service.business;
 
 import cn.cslg.pas.common.dto.ClientDTO;
 import cn.cslg.pas.common.dto.business.*;
+import cn.cslg.pas.common.importTask.ProjectQuartzQueryDTO;
+import cn.cslg.pas.common.importTask.ProjectQuartzSetDTO;
 import cn.cslg.pas.common.model.cronModel.*;
 import cn.cslg.pas.common.model.request.GroupRequest;
 import cn.cslg.pas.common.model.request.QueryRequest;
 import cn.cslg.pas.common.model.request.StringRequest;
+import cn.cslg.pas.common.patentProject.ProjectQuartzDTO;
 import cn.cslg.pas.common.utils.CacheUtils;
+import cn.cslg.pas.common.utils.CronUtil;
 import cn.cslg.pas.common.utils.LoginUtils;
 import cn.cslg.pas.common.vo.DepartmentVO;
 
@@ -15,6 +19,7 @@ import cn.cslg.pas.common.vo.business.PatentProjectVO;
 import cn.cslg.pas.common.vo.business.ReportCountVO;
 import cn.cslg.pas.domain.business.*;
 
+import cn.cslg.pas.exception.ExceptionEnum;
 import cn.cslg.pas.exception.UnLoginException;
 import cn.cslg.pas.exception.XiaoShiException;
 import cn.cslg.pas.factorys.businessFactory.Business;
@@ -23,6 +28,9 @@ import cn.cslg.pas.factorys.reGroupFactory.QueryGroupImp;
 import cn.cslg.pas.mapper.PatentProjectMapper;
 import cn.cslg.pas.service.common.FileManagerService;
 import cn.cslg.pas.service.permissions.PermissionService;
+import cn.cslg.pas.service.quartzService.JobService;
+import cn.cslg.pas.service.quartzService.QrtzTaskDTO;
+import cn.cslg.pas.service.quartzService.QuartzVO;
 import cn.cslg.pas.service.query.FormatQueryService;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
@@ -100,6 +108,9 @@ public class PatentProjectService extends ServiceImpl<PatentProjectMapper, Paten
     @Autowired
     private AssoProjectScenarioService assoProjectScenarioService;
 
+    @Autowired
+    private JobService jobService;
+
     @Override
     @Transactional(rollbackFor = Exception.class)
     public Object queryMessage(QueryRequest queryRequest) throws Exception {
@@ -173,6 +184,7 @@ public class PatentProjectService extends ServiceImpl<PatentProjectMapper, Paten
         //TODO 根据id删除导入任务信息(导入任务模块未完成,暂时不做)
 
         //删除专利数据库
+        this.removeQuartz(ids);
         LambdaQueryWrapper<PatentProject> patentProjectLambdaQueryWrapper = new LambdaQueryWrapper<>();
         patentProjectLambdaQueryWrapper.in(PatentProject::getProjectId, ids);
         this.remove(patentProjectLambdaQueryWrapper);
@@ -244,7 +256,7 @@ public class PatentProjectService extends ServiceImpl<PatentProjectMapper, Paten
         PatentProjectDTO patentProjectDTO = (PatentProjectDTO) object;
         //判断是否选择更新并且上传了cron表达式
         if (patentProjectDTO.getIfUpdate() != false) {
-            if (patentProjectDTO.getCrons() == null && patentProjectDTO.getCrons().equals("")) {
+            if (patentProjectDTO.getUpdateCycle() == null && patentProjectDTO.getUpdateCycle().equals("")) {
                 throw new XiaoShiException("选择更新,则cron表达式不能为空!");
             }
         }
@@ -254,11 +266,10 @@ public class PatentProjectService extends ServiceImpl<PatentProjectMapper, Paten
         }
         //获取登陆人信息 用于设置创建人
         PersonnelVO personnelVO = new PersonnelVO();
-        if(patentProjectDTO.getPersonId()==null) {
-                personnelVO = cacheUtils.getLoginUser(loginUtils.getId());
+        if (patentProjectDTO.getPersonId() == null) {
+            personnelVO = cacheUtils.getLoginUser(loginUtils.getId());
 
-        }
-        else {
+        } else {
             personnelVO.setId(patentProjectDTO.getPersonId());
             personnelVO.setTenantType("1");
             personnelVO.setTenantId(1);
@@ -311,10 +322,13 @@ public class PatentProjectService extends ServiceImpl<PatentProjectMapper, Paten
         /**
          * 装载patentProject
          */
-        PatentProject patentProject = new PatentProject();
-        BeanUtils.copyProperties(patentProjectDTO, patentProject);
-        patentProject.setProjectId(project.getId());
-        patentProject.insert();
+        if(patentProjectDTO.getIfUpdate()!=null&&patentProjectDTO.getIfUpdate()){
+            ProjectQuartzSetDTO projectQuartzSetDTO =new ProjectQuartzSetDTO();
+            projectQuartzSetDTO.setProjectId(project.getId());
+            projectQuartzSetDTO.setIfUpdate(patentProjectDTO.getIfUpdate());
+            projectQuartzSetDTO.setUpdateCycle(patentProjectDTO.getUpdateCycle());
+            this.setProjectQuartz(projectQuartzSetDTO);
+        }
 
         /**
          * 装载事件与project关联
@@ -426,7 +440,7 @@ public class PatentProjectService extends ServiceImpl<PatentProjectMapper, Paten
         UpdatePatentProjectDTO updatePatentProjectDTO = (UpdatePatentProjectDTO) object;
         //判断是否选择更新并且上传了cron表达式
         if (updatePatentProjectDTO.getIfUpdate() != false) {
-            if (updatePatentProjectDTO.getCrons() == null && updatePatentProjectDTO.getCrons().equals("")) {
+            if (updatePatentProjectDTO.getUpdateCycle() == null && updatePatentProjectDTO.getUpdateCycle().equals("")) {
                 throw new XiaoShiException("选择更新,则cron表达式不能为空!");
             }
         }
@@ -437,7 +451,7 @@ public class PatentProjectService extends ServiceImpl<PatentProjectMapper, Paten
         //获取登陆人信息 用于设置创建人
         PersonnelVO personnelVO = new PersonnelVO();
 
-            personnelVO = cacheUtils.getLoginUser(loginUtils.getId());
+        personnelVO = cacheUtils.getLoginUser(loginUtils.getId());
 
         //TODO 更新基本信息
         //根据传入对象id查询project对象
@@ -481,6 +495,12 @@ public class PatentProjectService extends ServiceImpl<PatentProjectMapper, Paten
          * 装载patentProject
          */
         //根据projectId查询出patentProject
+            ProjectQuartzSetDTO projectQuartzSetDTO =new ProjectQuartzSetDTO();
+            projectQuartzSetDTO.setProjectId(project.getId());
+            projectQuartzSetDTO.setIfUpdate(updatePatentProjectDTO.getIfUpdate());
+            projectQuartzSetDTO.setUpdateCycle(updatePatentProjectDTO.getUpdateCycle());
+            this.setProjectQuartz(projectQuartzSetDTO);
+
         LambdaQueryWrapper<PatentProject> queryWrapper = new LambdaQueryWrapper<>();
         queryWrapper.eq(PatentProject::getProjectId, project.getId());
         PatentProject patentProject = this.list(queryWrapper).get(0);
@@ -685,8 +705,8 @@ public class PatentProjectService extends ServiceImpl<PatentProjectMapper, Paten
             String res = fileManagerService.getSystemFileFromFMS(guids);
 
             systemFiles = JSONObject.parseArray(res, SystemFile.class);
-            if(systemFiles==null){
-                systemFiles=new ArrayList<>();
+            if (systemFiles == null) {
+                systemFiles = new ArrayList<>();
             }
         }
 
@@ -929,13 +949,163 @@ public class PatentProjectService extends ServiceImpl<PatentProjectMapper, Paten
         sqls.add(null);
         sqls.add(null);
         List<PatentProjectVO> patentProjectVOS = patentProjectMapper.getPatentProject(sqls.get(0), sqls.get(1), sqls.get(2));
-       try {
-           this.loadPatentProject(patentProjectVOS);
-       }
-    catch (Exception e){}
-       if(patentProjectVOS!=null&&patentProjectVOS.size()>0){
-           return  patentProjectVOS.get(0);
-       }
-       return null;
+        try {
+            this.loadPatentProject(patentProjectVOS);
+        } catch (Exception e) {
+        }
+        if (patentProjectVOS != null && patentProjectVOS.size() > 0) {
+            return patentProjectVOS.get(0);
+        }
+        return null;
+    }
+
+    /**
+     * 设置定时周期
+     *
+     * @param projectQuartzDTO
+     */
+    public void setProjectQuartz(ProjectQuartzDTO projectQuartzDTO) {
+        Integer projectId = projectQuartzDTO.getProjectId();
+        Boolean ifUpdate = projectQuartzDTO.getIfUpdate();
+        String crons = projectQuartzDTO.getCrons();
+        PatentProject patentProject = this.getProjectQuartz(projectId);
+        patentProject.setIfUpdate(ifUpdate);
+        patentProject.setCrons(crons);
+        patentProject.updateById();
+    }
+
+    /**
+     * 获取项目定时配置
+     *
+     * @param projectId
+     */
+    public PatentProject getProjectQuartz(Integer projectId) {
+        LambdaQueryWrapper<PatentProject> queryWrapper = new LambdaQueryWrapper<>();
+        queryWrapper.eq(PatentProject::getProjectId, projectId);
+        PatentProject patentProject = this.getOne(queryWrapper);
+        return patentProject;
+    }
+
+    public PatentProject addProjectQuartz(ProjectQuartzSetDTO projectQuartzSetDTO) {
+        Integer projectId = projectQuartzSetDTO.getProjectId();
+        String updateCycle = projectQuartzSetDTO.getUpdateCycle();
+        Boolean ifUpdate = projectQuartzSetDTO.getIfUpdate();
+        PatentProject project = new PatentProject();
+        project.setProjectId(projectId);
+        project.setIfUpdate(projectQuartzSetDTO.getIfUpdate());
+        project.setUpdateCycle(updateCycle);
+        if (ifUpdate != null && ifUpdate) {
+            String crons = CronUtil.getCron(updateCycle);
+            if (crons == null) {
+                throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, "请输入周期");
+            }
+            project.setCrons(crons);
+            QuartzVO quartzVO = jobService.getPatentProjectVO(projectId);
+            QrtzTaskDTO qrtzTaskDTO = new QrtzTaskDTO();
+            qrtzTaskDTO.setCron(crons);
+            qrtzTaskDTO.setId(projectId);
+            qrtzTaskDTO.setQuartzVO(quartzVO);
+            qrtzTaskDTO.setJobClass("cn.cslg.pas.service.quartzService.ImportPatentJobService");
+            try {
+                jobService.addJob(qrtzTaskDTO);
+            } catch (Exception e) {
+                throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, "新建定时任务错误");
+            }
+            project.insert();
+        }
+        return project;
+    }
+
+    public PatentProject updateProjectQuartz(ProjectQuartzSetDTO projectQuartzSetDTO) {
+        Integer projectId = projectQuartzSetDTO.getProjectId();
+        String updateCycle = projectQuartzSetDTO.getUpdateCycle();
+        Boolean ifUpdate = projectQuartzSetDTO.getIfUpdate();
+        PatentProject project = this.getProjectQuartz(projectId);
+        String crons = null;
+        if (ifUpdate != null && ifUpdate) {
+            crons = CronUtil.getCron(updateCycle);
+            project.setCrons(crons);
+        }
+
+        if (project.getIfUpdate() != null && project.getIfUpdate() && (ifUpdate == null || !ifUpdate)) {
+            QuartzVO quartzVO = jobService.getPatentProjectVO(projectId);
+            try {
+                jobService.deleteJob(quartzVO);
+            } catch (Exception e) {
+                throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, "新建定时任务错误");
+            }
+        } else if (project.getIfUpdate() != null && project.getIfUpdate() && ifUpdate != null && ifUpdate == true) {
+            if (project.getUpdateCycle().equals(updateCycle)) {
+                return project;
+            }
+            QuartzVO quartzVO = jobService.getPatentProjectVO(projectId);
+            QrtzTaskDTO qrtzTaskDTO = new QrtzTaskDTO();
+            qrtzTaskDTO.setCron(crons);
+            qrtzTaskDTO.setQuartzVO(quartzVO);
+            qrtzTaskDTO.setId(projectId);
+            jobService.updateJob(qrtzTaskDTO);
+        } else if ((project.getIfUpdate() == null || !project.getIfUpdate()) && (ifUpdate != null && ifUpdate)) {
+            QuartzVO quartzVO = jobService.getPatentProjectVO(projectId);
+            QrtzTaskDTO qrtzTaskDTO = new QrtzTaskDTO();
+            qrtzTaskDTO.setCron(crons);
+            qrtzTaskDTO.setQuartzVO(quartzVO);
+            qrtzTaskDTO.setJobClass("cn.cslg.pas.service.quartzService.ImportPatentJobService");
+            try {
+                jobService.addJob(qrtzTaskDTO);
+            } catch (Exception e) {
+                throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, "新建定时任务错误");
+            }
+        }
+        project.setUpdateCycle(updateCycle);
+        project.setIfUpdate(ifUpdate);
+        project.updateById();
+        return project;
+    }
+
+    /**
+     * 设置项目定时配置
+     *
+     * @param projectQuartzSetDTO
+     */
+    public PatentProject setProjectQuartz(ProjectQuartzSetDTO projectQuartzSetDTO) {
+        Integer projectId = projectQuartzSetDTO.getProjectId();
+        PatentProject project = this.getProjectQuartz(projectId);
+        if (project == null) {
+            this.addProjectQuartz(projectQuartzSetDTO);
+        } else {
+            this.updateProjectQuartz(projectQuartzSetDTO);
+        }
+        return project;
+    }
+
+    public Boolean checkIfHaveQuartz(Integer projectId) {
+        PatentProject project = this.getProjectQuartz(projectId);
+        return project.getIfUpdate();
+    }
+
+    public void removeQuartz(List<Integer> ids) {
+        for (Integer id : ids) {
+            PatentProject project = this.getProjectQuartz(id);
+            if (project.getIfUpdate() != null && project.getIfUpdate()) {
+                QuartzVO quartzVO = jobService.getPatentProjectVO(id);
+          try {
+              jobService.deleteJob(quartzVO);
+
+          }
+          catch (Exception e){
+              throw  new XiaoShiException(ExceptionEnum.BUSINESS_ERROR,"创建定时任务错误");
+          }
+            }
+        }
+
+    }
+
+
+    public PatentProject queryProjectQuartz(ProjectQuartzQueryDTO projectQuartzQueryDTO) {
+        Integer projectId =projectQuartzQueryDTO.getProjectId();
+        LambdaQueryWrapper<PatentProject> queryWrapper = new LambdaQueryWrapper<>();
+        queryWrapper.eq(PatentProject::getProjectId, projectId);
+        PatentProject patentProject = this.getOne(queryWrapper);
+        return patentProject;
     }
 }

+ 3 - 3
src/main/java/cn/cslg/pas/service/business/TreeNodeService.java

@@ -768,7 +768,7 @@ public class TreeNodeService extends ServiceImpl<TreeNodeMapper, TreeNode> imple
     }
 
     //
-    public List<String> getIdByNames(List<String> values, Integer fieldId) {
+    public List<String> getIdByNames2(List<String> values, Integer fieldId,Integer conditionId) {
 
         List<String> valuesIds = new ArrayList<>();
         for (String value : values) {
@@ -776,7 +776,7 @@ public class TreeNodeService extends ServiceImpl<TreeNodeMapper, TreeNode> imple
             TreeNode treeNode = null;
             for (int i = 0; i < valueQs.length; i++) {
                 String valueQ = valueQs[i];
-                treeNode = this.getTreeNodeByName(valueQ, i, fieldId, treeNode);
+                treeNode = this.getTreeNodeByName(valueQ, i, fieldId, treeNode,conditionId);
                 if (i == valueQs.length - 1) {
                     if (!valuesIds.contains(treeNode.getId())) {
                         valuesIds.add(treeNode.getId().toString());
@@ -788,7 +788,7 @@ public class TreeNodeService extends ServiceImpl<TreeNodeMapper, TreeNode> imple
     }
 
 
-    public TreeNode getTreeNodeByName(String value, Integer level, Integer fieldId, TreeNode parentTreeNode) {
+    public TreeNode getTreeNodeByName(String value, Integer level, Integer fieldId, TreeNode parentTreeNode,Integer conditionId) {
         Integer parentId = 0;
         if (parentTreeNode != null) {
             parentId = parentTreeNode.getId();

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

@@ -1,5 +1,6 @@
 package cn.cslg.pas.service.business.es;
 
+import cn.cslg.pas.common.core.base.FamilyType;
 import cn.cslg.pas.common.core.base.IfConstant;
 import cn.cslg.pas.common.dto.PatentDetailDTO;
 import cn.cslg.pas.common.dto.PatentKinDTO;
@@ -19,12 +20,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 +72,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 +84,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 +101,44 @@ public class EsFamilyService {
         return reFamilies;
     }
 
+
+    public void updatePatentFamilyByQuery(String patentFamilyType, String patentFamilyId, Integer patentFamilyCount, List<String> nos) {
+        String familyNum = "";
+        String familyName="";
+        if(patentFamilyType.equals(FamilyType.INPADOC)) {
+            familyName = "inpadoc_family_id";
+            familyNum = "inpadoc_family_num";
+        }
+        else if(patentFamilyType.equals(FamilyType.PATSNAP))
+        {
+            familyName = "patsnap_family_id";
+            familyNum = "patsnap_family_num";
+        }
+        else {
+            familyName = "simple_family_id";
+            familyNum = "simple_family_num";
+        }
+        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) {
+        }
+
+    }
+
 }

+ 95 - 5
src/main/java/cn/cslg/pas/service/business/es/EsLegalEventService.java

@@ -1,20 +1,28 @@
 package cn.cslg.pas.service.business.es;
 
-import cn.cslg.pas.domain.es.LegalEvent;
-import cn.cslg.pas.domain.es.PatentQuoteMessage;
-import cn.cslg.pas.domain.es.QuotePatent;
+import cn.cslg.pas.common.vo.ChinaLeagalStatus;
+import cn.cslg.pas.common.vo.StarPatentVO;
+import cn.cslg.pas.domain.es.*;
+import cn.cslg.pas.exception.ExceptionEnum;
 import cn.cslg.pas.exception.XiaoShiException;
+import cn.cslg.pas.service.common.PatentStarApiService;
+import cn.cslg.pas.service.importPatent.WebVOTransformService;
 import co.elastic.clients.elasticsearch.ElasticsearchClient;
+import co.elastic.clients.elasticsearch._types.InlineScript;
+import co.elastic.clients.elasticsearch._types.Refresh;
+import co.elastic.clients.elasticsearch._types.Script;
+import co.elastic.clients.elasticsearch._types.WaitForActiveShards;
 import co.elastic.clients.elasticsearch._types.query_dsl.Query;
 import co.elastic.clients.elasticsearch._types.query_dsl.QueryBuilders;
-import co.elastic.clients.elasticsearch.core.SearchRequest;
-import co.elastic.clients.elasticsearch.core.SearchResponse;
+import co.elastic.clients.elasticsearch.core.*;
 import co.elastic.clients.elasticsearch.core.search.Hit;
+import com.alibaba.fastjson.JSON;
 import lombok.RequiredArgsConstructor;
 import org.springframework.context.annotation.Lazy;
 import org.springframework.stereotype.Service;
 import org.springframework.util.CollectionUtils;
 
+import java.io.IOException;
 import java.util.*;
 import java.util.stream.Collectors;
 
@@ -22,6 +30,8 @@ import java.util.stream.Collectors;
 @RequiredArgsConstructor(onConstructor_ = {@Lazy})
 public class EsLegalEventService {
     private final ElasticsearchClient client;
+    private final PatentStarApiService patentStarApiService;
+    private final WebVOTransformService webVOTransformService;
 
     //根据专利号查询同族专利号
     public List<LegalEvent> getEsQutePatentByNos(String patentNo) throws Exception {
@@ -64,4 +74,84 @@ public class EsLegalEventService {
         }
         return stringList;
     }
+
+
+    /**
+     * 添加法律事务
+     *
+     * @param
+     * @return
+     * @throws Exception
+     */
+    public String addLegalEvent(LegalEvent legalEvent) throws Exception {
+        IndexResponse indexResponse = client.index(i -> i
+                .index("legal_event")
+                .document(legalEvent).refresh(Refresh.True).waitForActiveShards(WaitForActiveShards.of(t -> t.count(1)))
+        );
+        return indexResponse.id();
+
+    }
+
+    public String addEsLegalEvent(Patent patent, String ANO) {
+        //根据专利号查询
+        if (patent == null) {
+            return null;
+        }
+        String cnLegalApiStr = patentStarApiService.getCnLegalApi(ANO);
+        if (cnLegalApiStr != null && !cnLegalApiStr.equals("")) {
+            try {
+                this.deleteByPatentNo(patent.getPatentNo());
+
+            } catch (Exception e) {
+            }
+            List<LegalEvent> legalEvents = new ArrayList<>();
+            //根据专利号查询是否有引用信息
+            try {
+                this.deleteByPatentNo(patent.getPatentNo());
+
+            } catch (Exception e) {
+                e.printStackTrace();
+                throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR,"删除事务错误");
+            }
+            List<ChinaLeagalStatus> chinaLeagalStatuses = JSON.parseArray(cnLegalApiStr, ChinaLeagalStatus.class);
+            chinaLeagalStatuses.forEach(item -> {
+                LegalEvent legalEvent1 = new LegalEvent();
+                legalEvent1.setEventDate(item.getLegalDate());
+                legalEvent1.setCode(item.getLegalCode());
+                legalEvent1.setAppNo(patent.getAppNo());
+                legalEvent1.setGrantNo(patent.getGrantNo());
+                legalEvent1.setPublicNo(patent.getPublicNo());
+                legalEvent1.setDescription(item.getLegalStatusInfo());
+                legalEvent1.setName(item.getLegalStatus());
+                legalEvents.add(legalEvent1);
+                try {
+                    String reId = this.addLegalEvent(legalEvent1);
+                } catch (Exception e) {
+                    throw new XiaoShiException(e.getMessage());
+                }
+            });
+            webVOTransformService.transLegalEvent(patent, legalEvents);
+        }
+        return "";
+    }
+
+    public Integer deleteByPatentNo(String patentNo) throws IOException {
+        SearchRequest.Builder builder = new SearchRequest.Builder();
+        //设置查询索引
+        builder.index("legal_event");
+
+        Query q1 = QueryBuilders.term(t -> t.field("app_no").value(patentNo));
+        //公开号
+        Query q2 = QueryBuilders.term(t -> t.field("public_no").value(patentNo));
+        //授权号
+        Query q3 = QueryBuilders.term(t -> t.field("grant_no").value(patentNo));
+        Query query = QueryBuilders.bool(i -> i.should(q1, q2, q3));
+        DeleteByQueryRequest request = DeleteByQueryRequest.of(i -> i.index("legal_event").refresh(true).query(query));
+        try {
+            client.deleteByQuery(request);
+            return 1;
+        } catch (IOException e) {
+            return -1;
+        }
+    }
 }

+ 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();
+        }
+
+    }
 }

+ 80 - 185
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
@@ -853,6 +855,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);
@@ -889,32 +892,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 = "";
@@ -931,10 +918,8 @@ 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())
-                        || grantNo1.equals(item.getGrantNo())
+                publicNo1.equals(item.getPublicNo()) || publicNo1.equals(item.getGrantNo()) || publicNo1.equals(item.getAppNo()) || grantNo1.equals(item.getPublicNo())
+                        || grantNo1.equals(item.getGrantNo()) || grantNo1.equals(item.getAppNo()) || appNo1.equals(item.getAppNo()) || appNo1.equals(item.getPublicNo()) || appNo1.equals(item.getGrantNo())
         ).findFirst().orElse(null);
         if (patent1 == null) {
             patent1 = new FamilyPatent();
@@ -948,60 +933,84 @@ 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);
+            FamilyPatent familyPatentNew = familyPatentsNew.stream().filter(item -> (item.getPublicNo() != null && (item.getPublicNo().equals(familyPatent.getPublicNo()) || item.getPublicNo().equals(familyPatent.getAppNo()) || item.getPublicNo().equals(familyPatent.getGrantNo())))
+                    || (item.getGrantNo() != null && (item.getGrantNo().equals(familyPatent.getGrantNo()) || item.getGrantNo().equals(familyPatent.getPublicNo()) || item.getGrantNo().equals(familyPatent.getAppNo())) || (item.getAppNo() != null && (item.getAppNo().equals(familyPatent.getGrantNo()) || item.getAppNo().equals(familyPatent.getPublicNo()) || item.getAppNo().equals(familyPatent.getAppNo()))))).findFirst().orElse(null);
             if (familyPatentNew == null) {
                 familyPatentsNew.add(familyPatent);
             } else {
-                if (familyPatentNew.getGrantNo() == null && familyPatent.getAppNo() == null) {
+                if (familyPatentNew.getAppNo() == null && familyPatent.getGrantNo() == 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) || (item.getAppNo() != null && item.getAppNo().equals(no)))).findFirst().orElse(null);
+            if (familyPatentNew == null) {
+                familyPatentNew = new FamilyPatent();
+                familyPatentNew.setPublicNo(nos.get(i));
+                familyPatents.add(familyPatentNew);
+            }
+        }
+        return familyPatents;
+    }
+
     /**
      * 添加同族
      *
@@ -1062,21 +1071,6 @@ public class EsService {
         }
     }
 
-    /**
-     * 添加法律事务
-     *
-     * @param
-     * @return
-     * @throws Exception
-     */
-    public String addLegalEvent(LegalEvent legalEvent) throws Exception {
-        IndexResponse indexResponse = client.index(i -> i
-                .index("legal_event")
-                .document(legalEvent).refresh(Refresh.True).waitForActiveShards(WaitForActiveShards.of(t -> t.count(1)))
-        );
-        return indexResponse.id();
-
-    }
 
     /**
      * 更新专利事务
@@ -1117,11 +1111,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 = "";
@@ -1131,7 +1125,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);
@@ -1144,7 +1138,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);
@@ -1154,18 +1147,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();
@@ -1179,44 +1166,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;
     }
 
@@ -1239,76 +1204,6 @@ public class EsService {
         return quotePatent;
     }
 
-    public String addEsLegalEvent(StarPatentVO starPatentVO) {
-        LegalEvent legalEvent = null;
-        String id = "";
-
-        //根据专利号查询
-        if (starPatentVO == null) {
-            return null;
-        }
-        String cnLegalApiStr = patentStarApiService.getCnLegalApi(starPatentVO.getRowApplicationNo());
-        if (cnLegalApiStr != null && !cnLegalApiStr.equals("")) {
-            List<LegalEvent> legalEvents = new ArrayList<>();
-            //根据专利号查询是否有引用信息
-            SearchRequest.Builder builder = new SearchRequest.Builder();
-            //设置查询索引
-            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()));
-                queries.add(q1);
-            }
-            if (starPatentVO.getPublicAccreditNo() != null) {
-                Query q2 = QueryBuilders.term((t -> t.field("grant_no").value(starPatentVO.getPublicAccreditNo())));
-                queries.add(q2);
-            }
-            if (starPatentVO.getPublicNo() != null) {
-                Query q3 = QueryBuilders.term((t -> t.field("public_no").value(starPatentVO.getPublicNo())));
-                queries.add(q3);
-            }
-
-            Query bool = QueryBuilders.bool(i -> i.should(queries));
-            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) {
-                response.hits().hits().forEach(item -> {
-                    legalEvents.add(item.source());
-                });
-            }
-            if (!cnLegalApiStr.contains("408")) {
-                List<ChinaLeagalStatus> chinaLeagalStatuses = JSON.parseArray(cnLegalApiStr, ChinaLeagalStatus.class);
-                chinaLeagalStatuses.forEach(item -> {
-                    LegalEvent tem = legalEvents.stream().filter(em -> em.getEventDate() != null && em.getEventDate().compareTo(item.getLegalDate()) == 0).findFirst().orElse(null);
-                    if (tem == null) {
-                        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.setDescription(item.getLegalStatusInfo());
-                        legalEvent1.setName(item.getLegalStatus());
-                        try {
-                            String reId = this.addLegalEvent(legalEvent1);
-                        } catch (Exception e) {
-                            throw new XiaoShiException(e.getMessage());
-                        }
-                    }
-
-                });
-            }
-
-        }
-        return "";
-    }
 
     /**
      * 查询权利要求
@@ -1396,7 +1291,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()));
@@ -1407,7 +1302,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()));
@@ -1417,7 +1312,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()));

+ 158 - 207
src/main/java/cn/cslg/pas/service/common/PatentStarApiService.java

@@ -10,19 +10,16 @@ import cn.cslg.pas.common.model.cronModel.Records;
 import cn.cslg.pas.common.model.importTaskModel.PatentApplicant;
 import cn.cslg.pas.common.utils.*;
 import cn.cslg.pas.common.vo.ContentVO;
-import cn.cslg.pas.common.vo.NoCacheVO;
 import cn.cslg.pas.common.vo.QueryExternalFamilyVO;
 import cn.cslg.pas.common.vo.StarPatentVO;
 import cn.cslg.pas.common.vo.business.PatentNoVO;
 import cn.cslg.pas.domain.WebLoginConfig;
 import cn.cslg.pas.domain.business.RetrieveRecord;
 import cn.cslg.pas.domain.es.*;
-import cn.cslg.pas.exception.XiaoShiException;
 import cn.cslg.pas.service.WebLoginConfigService;
 
 
 import cn.cslg.pas.service.query.FormatQueryService;
-import cn.hutool.core.util.IdUtil;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import lombok.RequiredArgsConstructor;
@@ -67,7 +64,10 @@ import java.util.stream.Collectors;
 @RequiredArgsConstructor
 @Slf4j
 @Service
+
 public class PatentStarApiService {
+    private ApplicationContext applicationContext;
+    private PatentStarApiService patentStarApiService;
     @Autowired
     private RetrieveRecordService retrieveRecordService;
     @Autowired
@@ -78,48 +78,29 @@ public class PatentStarApiService {
     private WebLoginConfigService webLoginConfigService;
     @Autowired
     private FormatQueryService formatQueryService;
-    @Autowired
-    private NOSCacheService cacheService;
 
     public Records patentStarSearchLocal(PatentStarListDTO patentStarListDTO) throws IOException {
         RetrieveRecord retrieveRecord = new RetrieveRecord();
         retrieveRecord.setConditions(patentStarListDTO.getCurrentQuery());
-        retrieveRecord.setSearchType(0);
+
         if (patentStarListDTO.getRetrieveRecordId() != null) {
             retrieveRecord = retrieveRecordService.getById(patentStarListDTO.getRetrieveRecordId());
             patentStarListDTO.setCurrentQuery(retrieveRecord.getConditions());
             patentStarListDTO.setDBType(retrieveRecord.getDbType());
         }
-
-        String redisKey = patentStarListDTO.getRedisKey();
-        List<String> nos = new ArrayList<>();
-        Long total = 0L;
-        if (StringUtils.isNotEmpty(patentStarListDTO.getNumberQuery())) {
-            NoCacheVO cacheVO = cacheService.savaByList(patentStarListDTO);
-            retrieveRecord.setConditions(patentStarListDTO.getNumberQuery());
-            retrieveRecord.setSearchType(1);
-            redisKey = cacheVO.getKey();
-            total = cacheVO.getTotal();
-            nos.addAll(cacheVO.getList());
-        }
-        if (Boolean.TRUE.equals(StringUtils.isEmpty(patentStarListDTO.getNumberQuery())) && StringUtils.isNotEmpty(redisKey)) {
-            NoCacheVO cacheVO = cacheService.getByList(patentStarListDTO);
-            retrieveRecord.setConditions(patentStarListDTO.getNumberQuery());
-            retrieveRecord.setSearchType(1);
-            nos.addAll(cacheVO.getList());
-            total = cacheVO.getTotal();
-            redisKey = cacheVO.getKey();
-        }
-
+    long start =    System.currentTimeMillis();
         Map<String, Object> map = this.patentStarSearchApi(patentStarListDTO);
+long end =System.currentTimeMillis();
+System.out.println("search time:"+(end-start));
         if (map == null) {
-            throw new XiaoShiException("检索失败,请检查检索式");
+            ThrowException.throwXiaoShiException("检索失败,请检查检索式");
         }
 
         //记录检索历史
         retrieveRecord.setRetrieveTime(new Date());
         retrieveRecord.setTotalNum(Integer.parseInt(map.get("total").toString()));
         retrieveRecord.setDbType(patentStarListDTO.getDBType());
+
         if (patentStarListDTO.getRetrieveRecordId() == null) {
             //获取创建人信息
             PersonnelVO personnelVO = cacheUtils.getLoginUser(loginUtils.getId());
@@ -137,23 +118,12 @@ public class PatentStarApiService {
         records.setRetrieveRecordId(retrieveRecord.getId());
         records.setCurrent(Long.parseLong(map.get("current").toString()));
         records.setSize(Long.parseLong(map.get("size").toString()));
-        List<PatentColumnDTO> columnDTOS = this.loadPatent(starPatentVOS);
-        records.setData(this.loadPatentList(columnDTOS, nos, patentStarListDTO.getDBType()));
-        if (total != 0) {
-            records.setTotal(total);
-        } else {
-            records.setTotal(Long.parseLong(map.get("total").toString()));
-        }
-        records.setRedisKey(redisKey);
+        records.setData(this.loadPatent(starPatentVOS));
+        records.setTotal(Long.parseLong(map.get("total").toString()));
         return records;
     }
 
-    /**
-     * 格式化条件后并请求外部接口
-     * @param PatentStarListDTO
-     * @return
-     * @throws IOException
-     */
+
     public Map<String, Object> patentStarSearchApi(PatentStarListDTO PatentStarListDTO) throws IOException {
         try {
             if (PatentStarListDTO.getFormed() == null || PatentStarListDTO.getFormed() == false) {
@@ -163,7 +133,6 @@ public class PatentStarApiService {
                     StringBuilder stringBuilder = new StringBuilder(PatentStarListDTO.getCurrentQuery());
                     stringBuilder.insert(PatentStarListDTO.getCurrentQuery().length() - 1, "-CN/GJ");
                     PatentStarListDTO.setCurrentQuery(stringBuilder.toString());
-
                 }
                 PatentStarListDTO.setFormed(true);
             }
@@ -176,6 +145,12 @@ public class PatentStarApiService {
         String appKey = configObject.getString("appKey");
         PatentStarDTO patentStarDto = new PatentStarDTO();
         BeanUtils.copyProperties(PatentStarListDTO, patentStarDto);
+
+        if(patentStarDto.getOrderBy()==null){
+            patentStarDto.setOrderBy("AD");
+            patentStarDto.setOrderByType("DESC");
+        }
+
         String json = JSONObject.toJSONString(patentStarDto);
         String url = "http://s.patentstar.com.cn/SearchAPI/PatentSearch/ResultGet";
         Long currentTimeMillis = System.currentTimeMillis() / 1000;
@@ -199,7 +174,12 @@ public class PatentStarApiService {
         Request request = new Request.Builder().url(url).post(requestBody).build();
         // 发送请求获取响应
         try {
+            long start =    System.currentTimeMillis();
+
             Response response = okHttpClient.newCall(request).execute();
+
+            long end =System.currentTimeMillis();
+            System.out.println("search11time:"+(end-start));
             // 判断请求是否成功
             if (response.isSuccessful()) {
                 JSONObject jsonObject = JSONObject.parseObject(Objects.requireNonNull(response.body()).string());
@@ -216,70 +196,26 @@ public class PatentStarApiService {
                 return reMap;
             }
         } catch (IOException e) {
-//            e.printStackTrace();
-//            return null;
-            throw new XiaoShiException("外部接口检索超时");
+            e.printStackTrace();
+            return null;
         }
         return null;
     }
 
-    //封装patent column数据返回
-    private List<PatentColumnDTO> loadPatentList(List<PatentColumnDTO> columnDTOS, List<String> list, String dbType) {
-        if (CollectionUtils.isEmpty(list) || CollectionUtils.isEmpty(columnDTOS)) {
-            return list.isEmpty() ? columnDTOS : createNewDTOs(list);
-        }
-
-        List<PatentColumnDTO> result = new ArrayList<>(columnDTOS.size());
-        Set<String> searchedNumbers = new HashSet<>(); // 用于跟踪已搜索的专利号
-
-        for (String patentNo : list) {
-            boolean found = false;
-            String formattedNo = dbType.equals("CN") ? PatentNoUtil.formatApNo(patentNo) : patentNo;
-
-            for (PatentColumnDTO columnDTO : columnDTOS) {
-                if (containsNumber(columnDTO, formattedNo)) {
-                    PatentColumnDTO dto = new PatentColumnDTO();
-                    BeanUtils.copyProperties(columnDTO,dto);
-                    dto.setSearchNo(patentNo);
-                    result.add(dto);
-                    searchedNumbers.add(patentNo); // 标记为已搜索
-                    found = true;
-                    break; // 找到匹配项后跳出内层循环
-                }
-            }
-
-            if (!found) {
-                // 如果没有在columnDTOS中找到匹配项,则创建一个新的DTO
-                PatentColumnDTO newDTO = new PatentColumnDTO();
-                newDTO.setPatentNo(patentNo);
-                newDTO.setSearchNo(patentNo);
-                newDTO.setIfSearch(false);
-                result.add(newDTO);
+    public String getFormatCondition(String condition) {
+        String s = condition.substring(condition.indexOf("=") + 1);
+        String s1 = s.replaceAll("[()]", "");
+        String[] valueStrs = s1.split("[,,]|(\\r\\n)+|\\r+|\\n+");
+        StringBuilder stringBuilder = new StringBuilder();
+        for (int i = 0; i < valueStrs.length; i++) {
+            final String value = valueStrs[i];
+            if (i != valueStrs.length - 1) {
+                stringBuilder.append(value).append(",");
+            } else {
+                stringBuilder.append(value);
             }
         }
-
-        return result;
-    }
-
-    private boolean containsNumber(PatentColumnDTO dto, String number) {
-        String appNo = StringUtils.isNotEmpty(dto.getAppNo()) ? dto.getAppNo() : "";
-        String publicNo = StringUtils.isNotEmpty(dto.getPublicNo()) ? dto.getPublicNo() : "";
-        String grantNo = StringUtils.isNotEmpty(dto.getGrantNo()) ? dto.getGrantNo() : "";
-        String rowAppNo = StringUtils.isNotEmpty(dto.getRowApplicationNo()) ? dto.getRowApplicationNo() : "";
-        return appNo.contains(number) || publicNo.contains(number)
-                || grantNo.contains(number) || rowAppNo.contains(number);
-    }
-
-    private List<PatentColumnDTO> createNewDTOs(List<String> list) {
-        List<PatentColumnDTO> newDTOs = new ArrayList<>();
-        for (String s : list) {
-            PatentColumnDTO dto = new PatentColumnDTO();
-            dto.setPatentNo(s);
-            dto.setSearchNo(s);
-            dto.setIfSearch(false);
-            newDTOs.add(dto);
-        }
-        return newDTOs;
+        return stringBuilder.toString();
     }
 
     public List<PatentStarListDTO> getSplitedConditions(PatentStarListDTO patentStarListDTO, int patentNum) throws IOException {
@@ -392,6 +328,7 @@ public class PatentStarApiService {
      * 从专利之星获取中国专利摘要附图
      */
     public String getPictureApi(String appNo) {
+
         String url = "https://api.patentstar.com.cn/api/Patent/CnMainImage/" + appNo;
         JSONObject configObject = this.getConfigObject(4, 2);
         String appId = configObject.getString("appId");
@@ -435,7 +372,6 @@ public class PatentStarApiService {
      * 从专利之星获取中国专利外观图
      */
     public String getWGPictureApi(String appNo) throws IOException {
-
         String url = "https://api.patentstar.com.cn/api/Patent/CnWGImage/" + appNo;
         JSONObject configObject = this.getConfigObject(4, 2);
         String appId = configObject.getString("appId");
@@ -463,7 +399,8 @@ public class PatentStarApiService {
             if (response.isSuccessful()) {
                 // 打印服务端返回结果
                 return Objects.requireNonNull(response.body()).string();
-            } else {
+            }
+            else {
                 response.close();
             }
         } catch (IOException e) {
@@ -549,7 +486,8 @@ public class PatentStarApiService {
             if (response.isSuccessful()) {
                 // 打印服务端返回结果
                 return Objects.requireNonNull(response.body()).string();
-            } else {
+            }
+            else {
                 response.close();
             }
 
@@ -642,8 +580,11 @@ public class PatentStarApiService {
         }
         List<String> reStrs = new ArrayList<>();
         Integer count = 1;
+
         for (Element item : elements) {
             String claim = item.getText().replaceAll("<br/>", "");
+
+
             if (!claim.trim().equals("技术领域")
                     && !claim.trim().equals("发明内容")
                     && !claim.trim().equals("附图说明")
@@ -699,7 +640,8 @@ public class PatentStarApiService {
             if (response.isSuccessful()) {
                 // 打印服务端返回结果
                 return Objects.requireNonNull(response.body()).string();
-            } else {
+            }
+            else {
                 response.close();
             }
         } catch (IOException e) {
@@ -758,6 +700,7 @@ public class PatentStarApiService {
      * 从专利之星获取同族专利
      */
     public String getFamilyByPubNoApi(String patentNo) {
+        patentNo="CN217038881U";
         String url = "https://api.patentstar.com.cn/api/Patent/FamilyByPubNo/" + patentNo;
         JSONObject configObject = this.getConfigObject(4, 2);
         String appId = configObject.getString("appId");
@@ -936,30 +879,30 @@ public class PatentStarApiService {
         starPatentVOS.forEach(item -> {
             PatentColumnDTO patentColumnDTO = new PatentColumnDTO();
             //申请号
-            patentColumnDTO.setAppNo(item.getApplicationNo());
+            patentColumnDTO.setAppNo(item.getAN());
             //装载公开号
-            patentColumnDTO.setPublicNo(item.getPublicNo());
+            patentColumnDTO.setPublicNo(item.getPN());
             //装载公告号
-            patentColumnDTO.setGrantNo(item.getPublicAccreditNo());
+            patentColumnDTO.setGrantNo(item.getGN());
             //装载专利状态
             if (item.getLG() != null) {
                 patentColumnDTO.setSimpleStatus(item.getLG().toString());
             }
             //装载专利类型
-            if (item.getPatentType() != null) {
-                patentColumnDTO.setPatentType(item.getPatentType().toString());
+            if (item.getPT() != null) {
+                patentColumnDTO.setPatentType(item.getPT().toString());
             }
             //装载摘要
             List<Text> abstractList = new ArrayList<>();
             Text text = new Text();
-            text.setTextContent(item.getAbstractStr());
+            text.setTextContent(item.getAB());
             text.setIfOrigin(true);
             abstractList.add(text);
             patentColumnDTO.setAbstractStr(abstractList);
             //装载标题
             List<Text> titleList = new ArrayList<>();
             Text title = new Text();
-            title.setTextContent(item.getName());
+            title.setTextContent(item.getTI());
             title.setIfOrigin(true);
             titleList.add(title);
 //            text.setLanguage(patent.getAppCountry());
@@ -967,7 +910,7 @@ public class PatentStarApiService {
             //装载权利要求
             List<Text> claimList = new ArrayList<>();
             Text claim = new Text();
-            claim.setTextContent(item.getClaimStr());
+            claim.setTextContent(item.getCL());
             claim.setIfOrigin(true);
             claimList.add(claim);
             patentColumnDTO.setClaim(claimList);
@@ -986,90 +929,94 @@ public class PatentStarApiService {
                 }
             }
 
-            //装载申请日
-            if (item.getApplicationDate() != null && !item.getApplicationDate().trim().equals("")) {
-                patentColumnDTO.setAppDate(DateUtils.strToDate(item.getApplicationDate()));
-            }
+//            //装载申请日
+//            if (item.getAD() != null && !item.getAD().trim().equals("")) {
+//                patentColumnDTO.setAppDate(DateUtils.strToDate(item.getAD()));
+//            }
+////            patentColumnDTO.setAppCountry(item.getBureau());
+//            //装载申请人地址
+//            PersonAddress appAddress = new PersonAddress();
+//            appAddress.setAddress(item.getApplicationAddress());
+//            appAddress.setProvince(item.getProvinceStr());
+//            patentColumnDTO.setApplicantAddr(appAddress);
+//            patentColumnDTO.setAppAddress(item.getApplicationAddress());
+////            patentColumnDTO.setApplicantCountry(item.getProvinceStr());
+//            String provinceStr = item.getProvinceStr();
+//            if (provinceStr.contains("(") && provinceStr.contains(")")) {
+//                String substring = provinceStr.substring(provinceStr.indexOf("(") + 1, provinceStr.indexOf(")"));
+//                patentColumnDTO.setAppProvince(substring);
+//            }
+//            //装载ipc(主)分类号
+//            PatentClassify mipcClassify = new PatentClassify();
+//            mipcClassify.setLevel5(item.getMainIpc());
+//            patentColumnDTO.setMipc(mipcClassify);
+//            //装载ipc分类号
+//            List<PatentClassify> classifies = new ArrayList<>();
+//            String[] split = item.getIpcListStr().split(";");
+//            for (String ipc : split) {
+//                PatentClassify ipcClassify = new PatentClassify();
+//                ipcClassify.setLevel5(ipc);
+//            }
+//            patentColumnDTO.setIpc(classifies);
+//            //获取摘要附图
+////            String pictureApi = this.getPictureApi(item.getRowApplicationNo());
+////            patentColumnDTO.setPictureGuid(pictureApi);
+//            //获取外部专利原始申请号
+//            patentColumnDTO.setRowApplicationNo(item.getRowApplicationNo());
+//            //获取法律状态
+////            String cnLegalApi = this.getCnLegalApi(item.getRowApplicationNo());
+////            patentColumnDTO.setLegalStatus(Arrays.asList(cnLegalApi));
+//            //获取被引用次数
+//            //装载公开日
+//            if (item.getPublicDate() != null && !item.getPublicDate().trim().equals("")) {
+//                patentColumnDTO.setPublicDate(DateUtils.strToDate(item.getPublicDate()));
+//            }
+//
+//            //装载公开日
+//            if (item.getPublicAccreditDate() != null && !item.getPublicAccreditDate().trim().equals("")) {
+//                patentColumnDTO.setGrantDate(DateUtils.strToDate(item.getPublicAccreditDate()));
+//            }
+//
+//            //装载申请人
+//            if (item.getApplicantStr() != null && !item.getApplicantStr().trim().equals("")) {
+//                List<String> names = Arrays.asList(item.getApplicantStr().split(";"));
+//                patentColumnDTO.setApplicant(names);
+//            } else {
+//                patentColumnDTO.setApplicant(new ArrayList<>());
+//            }
+//
+//            //装载发明人
+//            if (item.getInventorStr() != null && !item.getInventorStr().trim().equals("")) {
+//                List<String> names = Arrays.asList(item.getInventorStr().split(";"));
+//                patentColumnDTO.setInventor(names);
+//            } else {
+//                patentColumnDTO.setInventor(new ArrayList<>());
+//            }
+//
+//            //装载权利人
+//            if (item.getCurrentApplicantStr() != null && !item.getCurrentApplicantStr().trim().equals("")) {
+//                List<String> names = Arrays.asList(item.getCurrentApplicantStr().split(";"));
+//                patentColumnDTO.setRightHolder(names);
+//            } else {
+//                patentColumnDTO.setRightHolder(new ArrayList<>());
+//            }
+//
+//            //装载代理人
+//            if (item.getAgentStr() != null && !item.getAgentStr().trim().equals("")) {
+//                List<String> names = Arrays.asList(item.getAgentStr().split(";"));
+//                patentColumnDTO.setAgent(names);
+//            } else {
+//                patentColumnDTO.setAgent(new ArrayList<>());
+//            }
+//
+//            //装载代理机构
+//            if (item.getAgencyStr() != null && !item.getAgencyStr().trim().equals("")) {
+//                patentColumnDTO.setAgency(item.getAgencyStr());
+//            }
+//            //装载优先权
+//            patentColumnDTO.setPriorityNo(item.getPriorityNo());
+//            patentColumnDTO.setPriorityDate(item.getPriorityDate());
 //            patentColumnDTO.setAppCountry(item.getBureau());
-            //装载申请人地址
-            patentColumnDTO.setAppAddress(item.getApplicationAddress());
-//            patentColumnDTO.setApplicantCountry(item.getProvinceStr());
-            String provinceStr = item.getProvinceStr();
-            if (provinceStr.contains("(") && provinceStr.contains(")")) {
-                String substring = provinceStr.substring(provinceStr.indexOf("(") + 1, provinceStr.indexOf(")"));
-                patentColumnDTO.setAppProvince(substring);
-            }
-            //装载ipc(主)分类号
-            PatentClassify mipcClassify = new PatentClassify();
-            mipcClassify.setLevel5(item.getMainIpc());
-            patentColumnDTO.setMipc(mipcClassify);
-            //装载ipc分类号
-            List<PatentClassify> classifies = new ArrayList<>();
-            String[] split = item.getIpcListStr().split(";");
-            for (String ipc : split) {
-                PatentClassify ipcClassify = new PatentClassify();
-                ipcClassify.setLevel5(ipc);
-            }
-            patentColumnDTO.setIpc(classifies);
-            //获取摘要附图
-//            String pictureApi = this.getPictureApi(item.getRowApplicationNo());
-//            patentColumnDTO.setPictureGuid(pictureApi);
-            //获取外部专利原始申请号
-            patentColumnDTO.setRowApplicationNo(item.getRowApplicationNo());
-            //获取法律状态
-//            String cnLegalApi = this.getCnLegalApi(item.getRowApplicationNo());
-//            patentColumnDTO.setLegalStatus(Arrays.asList(cnLegalApi));
-            //获取被引用次数
-            //装载公开日
-            if (item.getPublicDate() != null && !item.getPublicDate().trim().equals("")) {
-                patentColumnDTO.setPublicDate(DateUtils.strToDate(item.getPublicDate()));
-            }
-
-            //装载公开日
-            if (item.getPublicAccreditDate() != null && !item.getPublicAccreditDate().trim().equals("")) {
-                patentColumnDTO.setGrantDate(DateUtils.strToDate(item.getPublicAccreditDate()));
-            }
-
-            //装载申请人
-            if (item.getApplicantStr() != null && !item.getApplicantStr().trim().equals("")) {
-                List<String> names = Arrays.asList(item.getApplicantStr().split(";"));
-                patentColumnDTO.setApplicant(names);
-            } else {
-                patentColumnDTO.setApplicant(new ArrayList<>());
-            }
-
-            //装载发明人
-            if (item.getInventorStr() != null && !item.getInventorStr().trim().equals("")) {
-                List<String> names = Arrays.asList(item.getInventorStr().split(";"));
-                patentColumnDTO.setInventor(names);
-            } else {
-                patentColumnDTO.setInventor(new ArrayList<>());
-            }
-
-            //装载权利人
-            if (item.getCurrentApplicantStr() != null && !item.getCurrentApplicantStr().trim().equals("")) {
-                List<String> names = Arrays.asList(item.getCurrentApplicantStr().split(";"));
-                patentColumnDTO.setRightHolder(names);
-            } else {
-                patentColumnDTO.setRightHolder(new ArrayList<>());
-            }
-
-            //装载代理人
-            if (item.getAgentStr() != null && !item.getAgentStr().trim().equals("")) {
-                List<String> names = Arrays.asList(item.getAgentStr().split(";"));
-                patentColumnDTO.setAgent(names);
-            } else {
-                patentColumnDTO.setAgent(new ArrayList<>());
-            }
-
-            //装载代理机构
-            if (item.getAgencyStr() != null && !item.getAgencyStr().trim().equals("")) {
-                patentColumnDTO.setAgency(item.getAgencyStr());
-            }
-            //装载优先权
-            patentColumnDTO.setPriorityNo(item.getPriorityNo());
-            patentColumnDTO.setPriorityDate(item.getPriorityDate());
-            patentColumnDTO.setAppCountry(item.getBureau());
             patentColumnDTOS.add(patentColumnDTO);
         });
 
@@ -1199,6 +1146,7 @@ public class PatentStarApiService {
      * @return
      */
     public List<Text> getCnFullText(String appNo) {
+        appNo="202410796708";
         List<Text> pubTextList = new ArrayList<>();
         //获取公开说明书
         String cnFullXmlApi = null;
@@ -1262,20 +1210,21 @@ public class PatentStarApiService {
                         dto.setType(0);
                         list.add(dto);
                     }
-                } else {  //若只有一个
+                }
+                else {  //若只有一个
                     pdfUrl1 = pdfUrlStr.substring(pdfUrlStr.indexOf("http"));
                     if (pdfUrl1.contains("0A_CN_0.pdf")) {
 
-                        InnerPatentPdfDTO dto = new InnerPatentPdfDTO();
-                        dto.setPdfGuid(pdfUrl1);
-                        dto.setType(0);
-                        list.add(dto);
+                            InnerPatentPdfDTO dto = new InnerPatentPdfDTO();
+                            dto.setPdfGuid(pdfUrl1);
+                            dto.setType(0);
+                            list.add(dto);
 
                     } else {
-                        InnerPatentPdfDTO dto = new InnerPatentPdfDTO();
-                        dto.setPdfGuid(pdfUrl1);
-                        dto.setType(1);
-                        list.add(dto);
+                            InnerPatentPdfDTO dto = new InnerPatentPdfDTO();
+                            dto.setPdfGuid(pdfUrl1);
+                            dto.setType(1);
+                            list.add(dto);
 
                     }
                 }
@@ -1283,11 +1232,11 @@ public class PatentStarApiService {
         } else {
             String usedPatentNo;
             if (publicNo != null && !publicNo.equals("")) {
-                usedPatentNo = publicNo;
+                usedPatentNo =publicNo;
             } else {
                 usedPatentNo = grantNo;
             }
-            if (usedPatentNo != null) {
+            if(usedPatentNo!=null){
                 pdfUrl = this.getEnPdfApi(usedPatentNo);
                 if (!pdfUrl.equals("")) {
                     InnerPatentPdfDTO dto = new InnerPatentPdfDTO();
@@ -1394,4 +1343,6 @@ public class PatentStarApiService {
         }
         return dto;
     }
+
+
 }

+ 22 - 3
src/main/java/cn/cslg/pas/service/common/PersonFieldService.java

@@ -15,6 +15,7 @@ import cn.cslg.pas.common.vo.QueryFieldsVO;
 import cn.cslg.pas.common.vo.PersonSelfFieldVO;
 import cn.cslg.pas.common.vo.business.AllCustomFieldVO;
 import cn.cslg.pas.common.vo.patentCount.GetAllPatentCountVO;
+import cn.cslg.pas.domain.business.CustomField;
 import cn.cslg.pas.domain.business.ReportProject;
 import cn.cslg.pas.exception.UnLoginException;
 import cn.cslg.pas.exception.XiaoShiException;
@@ -477,9 +478,27 @@ public class PersonFieldService {
             throw new XiaoShiException("不存在此表");
         }
         Boolean flag = true;
-        List<GetAllPatentCountVO> fieldVOS = JSON.parseArray(fieldJson, GetAllPatentCountVO.class);
-        fieldVOS = fieldVOS.stream().filter(item -> flag.equals(item.getIfStats()) && flag.equals(item.getDefaultShowStats())).collect(Collectors.toList());
-        fieldVOS.forEach(item -> item.setFiledKind(-1));
+
+        //查询栏位
+        LambdaQueryWrapper<CustomField> queryWrapper =new LambdaQueryWrapper<>();
+        queryWrapper.eq(CustomField::getProjectId,projectId)
+                     .eq(CustomField::getName,"监控周期")
+                     .eq(CustomField::getType,4);
+CustomField customField =customFieldService.getOne(queryWrapper,false);
+        List<GetAllPatentCountVO> fieldVOS =new ArrayList<>();
+if(customField!=null){
+    GetAllPatentCountVO getAllPatentCountVO =new GetAllPatentCountVO();
+    getAllPatentCountVO.setType("Array");
+    getAllPatentCountVO.setValue(customField.getId().toString());
+    getAllPatentCountVO.setName(customField.getName());
+    getAllPatentCountVO.setFiledKind(0);
+    fieldVOS.add(getAllPatentCountVO);
+}
+        List<GetAllPatentCountVO> fieldVOS2 = JSON.parseArray(fieldJson, GetAllPatentCountVO.class);
+
+        fieldVOS2 = fieldVOS2.stream().filter(item -> flag.equals(item.getIfStats()) && flag.equals(item.getDefaultShowStats())).collect(Collectors.toList());
+        fieldVOS2.forEach(item -> item.setFiledKind(-1));
+        fieldVOS.addAll(fieldVOS2);
         redisUtil.set(RedisConf.FIELD_COUNT + RedisConf.SYMBOL_COLON + key, JsonUtils.objectToJson(fieldVOS));
         return fieldVOS;
     }

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

@@ -9,6 +9,8 @@ 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.EsLegalEventService;
+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 +49,6 @@ public class GetCataloguingFromWebThread extends Thread {
 
     @Override
     public void run() {
-
         while ((!ifProductAll || uploadPatentWebDTOs.size() > 0) && importTaskAMVO.getState().equals(1)) {
             try {
                 //判断任务队列是否有任务,若没有则线程等待唤醒
@@ -58,44 +59,36 @@ public class GetCataloguingFromWebThread extends Thread {
             } catch (Exception e) {
 
             }
+            if (uploadPatentWebDTOs.size() == 0) {
+                break;
+            }
             UploadPatentWebDTO uploadPatentWebDTO = uploadPatentWebDTOs.remove(0);
             try {
                 //根据专利申请号查询著录并装载信息
                 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.getAN().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());
-                        }
+                    if (starPatentVO.getAN().startsWith("CN")) {
+                        webVOTransformService.loadCNPatent(patentZhuLuStr, uploadPatentWebDTO);
                     } 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);
                     }
                 }
 
                 EsService esService = applicationContext.getBean(EsService.class);
+ //添加事务
+                if (uploadPatentWebDTO.getStarPatentVO().getAN().contains("CN")) {
+                    EsLegalEventService esLegalEventService =applicationContext.getBean(EsLegalEventService.class);
+                    //添加法律事务
+                    esLegalEventService.addEsLegalEvent(uploadPatentWebDTO.getPatent(), starPatentVO.getANO());
+                }
 
                 // 添加同族专利
                 String familyPatentNoStr = patentStarApiService.getFamilyByPubNoApi(uploadPatentWebDTO.getPatent().getPublicNo());
@@ -111,32 +104,38 @@ public class GetCataloguingFromWebThread extends Thread {
                         }
                     }
                 }
-                familyPatentNos.add(uploadPatentWebDTO.getPatent().getAppNo());
 
-                if (familyPatentNos.size() != 0) {
+
                     EsPatentFamilyDTO esPatentFamilyDTO = esService.addEsPatentFamily(uploadPatentWebDTO.getPatent(), familyPatentNos, "inpadoc");
                     uploadPatentWebDTO.getPatent().setInpadocFamilyNum(esPatentFamilyDTO.getFamilyNum());
                     uploadPatentWebDTO.getPatent().setInpadocFamilyId(esPatentFamilyDTO.getPatentFamilyId());
-                }
-                if (uploadPatentWebDTO.getStarPatentVO().getApplicationNo().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();
             }
         }
-        importFromWebToEsService.setPatentToEsProductAll("catalogDone");
+        this.sendDone();
     }
 
 
@@ -167,372 +166,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,11 +175,32 @@ 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);
+        }
     }
 
 
+    public void sendDone() {
+        GetRightAndFullTextFromWebThread getRightAndFullTextFromWebThread = importFromWebToEsService.getRightAndFullTextFromWebThreadObject();
+        SavePatentToEsThread savePatentToEsThread = importFromWebToEsService.getSavePatentToEsThreadObject();
+        if (getRightAndFullTextFromWebThread != null) {
+            getRightAndFullTextFromWebThread.setIfProductAll(true);
+        } else {
+            savePatentToEsThread.setIfProductAll(true);
+        }
+    }
+
 }

+ 30 - 96
src/main/java/cn/cslg/pas/service/importPatent/GetPatentFromExcelThread.java

@@ -29,6 +29,7 @@ import java.io.*;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
+import java.util.stream.Collectors;
 
 @Configurable
 public class GetPatentFromExcelThread extends Thread {
@@ -85,7 +86,7 @@ public class GetPatentFromExcelThread extends Thread {
                 uploadPatentWebDTO.setPatent(uploadParamsVO.getPatent());
                 if (uploadParamsVO.getCustomerFieldList() != null && uploadParamsVO.getCustomerFieldList().size() != 0) {
                     CustomFieldService customFieldService = applicationContext.getBean(CustomFieldService.class);
-                    List<EsCustomFieldDTO> esCustomFieldDTOList = customFieldService.getFieldDTOByStrings(uploadParamsVO.getCustomerFieldList(), importTaskAMVO.getProjectId());
+                    List<EsCustomFieldDTO> esCustomFieldDTOList = customFieldService.getFieldDTOByStrings(uploadParamsVO.getCustomerFieldList(), importTaskAMVO.getProjectId(), null);
                     uploadPatentWebDTO.setEsCustomFieldDTOList(esCustomFieldDTOList);
                 }
                 //专利丢入消费者队列,并唤醒消费者线程
@@ -113,34 +114,21 @@ public class GetPatentFromExcelThread extends Thread {
 
 
     public void loadPatent(UploadParamsVO uploadParamsVO) {
+        WebVOTransformService webVOTransformService = applicationContext.getBean(WebVOTransformService.class);
+
         Patent patent = uploadParamsVO.getPatent();
-        String patentNo = patent.getPatentNo();
-        String appNo = patent.getAppNo();
-        String publicNo = patent.getPublicNo();
-        String grantNo = patent.getGrantNo();
-        String usedNo = null;
-        if (appNo != null) {
-            usedNo = appNo;
-        } else if (publicNo != null) {
-            usedNo = publicNo;
-        } else if (grantNo != null) {
-            usedNo = grantNo;
-        }
-        //获取专利前缀
-        String contry = usedNo.substring(0, 2);
-        //根据前缀判断如何设置专利号,中国专利为申请号,外国专利为公开号,若公开号不存在则为公告号
-        if (contry.equals("CN")) {
-            patentNo = appNo;
+
+        this.loadPatentType(patent);
+        webVOTransformService.loadGrantNo(patent, patent.getPublicNo(), patent.getGrantNo());
+        webVOTransformService.loadCountry(patent, false);
+        if (patent.getAppCountry() != null && patent.getAppCountry().equals("CN")) {
+            patent.setPatentNo(patent.getAppNo());
         } else {
-            if (publicNo != null) {
-                patentNo = publicNo;
-            } else if (grantNo != null) {
-                patentNo = grantNo;
-            }
+            webVOTransformService.loadWorldPatentNo(patent);
+
         }
-        patent.setPatentNo(patentNo);
-        //装载国家
-        patent.setAppCountry(contry);
+
+
         //装载标题原文
         if (uploadParamsVO.getTitle() != null) {
             List<Text> texts = new ArrayList<>();
@@ -148,7 +136,7 @@ public class GetPatentFromExcelThread extends Thread {
                 Text text = new Text();
                 text.setTextContent(uploadParamsVO.getTitle().getName());
                 text.setIfOrigin(true);
-                text.setLanguage(contry);
+                text.setLanguage(patent.getAppCountry());
                 texts.add(text);
             }
             //装载标题译文
@@ -173,7 +161,7 @@ public class GetPatentFromExcelThread extends Thread {
                 Text text = new Text();
                 text.setTextContent(uploadParamsVO.getAbstractStr().getName());
                 text.setIfOrigin(true);
-                text.setLanguage(contry);
+                text.setLanguage(patent.getAppCountry());
                 texts.add(text);
             }
             //装载摘要译文
@@ -197,7 +185,7 @@ public class GetPatentFromExcelThread extends Thread {
                 Text text = new Text();
                 text.setTextContent(uploadParamsVO.getPatentRight().getName());
                 text.setIfOrigin(true);
-                text.setLanguage(contry);
+                text.setLanguage(patent.getAppCountry());
                 texts.add(text);
             }
             //装载权利要求译文
@@ -252,82 +240,28 @@ public class GetPatentFromExcelThread extends Thread {
             }
         }
 
-        List<String> applicantNames = uploadParamsVO.getPatentApplicantOriginalName();
-
-        //申请人
-        if (applicantNames != null && applicantNames.size() != 0) {
-            List<PatentPerson> patentPeople = new ArrayList<>();
-            for (int i = 0; i < applicantNames.size(); i++) {
-                PatentPerson patentPerson = new PatentPerson();
-                patentPerson.setOrder(i + 1);
-                patentPerson.setType("1");
-                patentPerson.setName(applicantNames.get(i));
-                patentPeople.add(patentPerson);
-            }
-            patent.setApplicant(patentPeople);
+        //发明人
+        List<PatentInventor> patentInventorList = uploadParamsVO.getPatentInventorList();
+        if (patentInventorList != null) {
+            List<String> invetorNames = patentInventorList.stream().map(PatentInventor::getName).collect(Collectors.toList());
+            webVOTransformService.loadInventor(patent, invetorNames);
         }
 
+        List<String> applicantNames = uploadParamsVO.getPatentApplicantOriginalName();
+        webVOTransformService.loadApplicant(patent, applicantNames);
+
         //权利人
         List<String> rightNames = uploadParamsVO.getPatentApplicantCurrentName();
-        if (rightNames != null && rightNames.size() != 0) {
-            List<PatentPerson> patentPeople = new ArrayList<>();
-            for (int i = 0; i < rightNames.size(); i++) {
-                PatentPerson patentPerson = new PatentPerson();
-                patentPerson.setOrder(i + 1);
-                patentPerson.setType("1");
-                patentPerson.setName(rightNames.get(i));
-                patentPeople.add(patentPerson);
-            }
-            patent.setRightHolder(patentPeople);
-        }
-
-        //发明人
-        List<PatentInventor> patentInventorList = uploadParamsVO.getPatentInventorList();
-        if (patentInventorList != null && patentInventorList.size() > 0) {
-            List<PatentPerson> patentPeople = new ArrayList<>();
-            for (int i = 0; i < patentInventorList.size(); i++) {
-                PatentPerson patentPerson = new PatentPerson();
-                patentPerson.setOrder(i + 1);
-                patentPerson.setType("1");
-                patentPerson.setName(patentInventorList.get(i).getName());
-                patentPeople.add(patentPerson);
-            }
-            patent.setInventor(patentPeople);
-        }
+        webVOTransformService.loadRightHolder(patent, rightNames);
 
         List<String> ipcList = uploadParamsVO.getIpcList();
         String mainIpc = uploadParamsVO.getMainIpc();
 
-        //装载IPC分类号
-        if (ipcList == null && mainIpc != null) {
-            ipcList = new ArrayList<>();
-            ipcList.add(uploadParamsVO.getMainIpc());
-        }
-
-        if (ipcList != null && ipcList.size() > 0) {
-            List<PatentClassify> patentClassifies = new ArrayList<>();
-            for (int i = 0; i < ipcList.size(); i++) {
-                PatentClassify patentClassify = PatentClassifySplitter.split(ipcList.get(i));
-                if (patentClassify != null) {
-                    patentClassifies.add(patentClassify);
-                    if (i == 0) {
-                        patent.setMipc(patentClassify);
-                    }
-                }
-            }
-            patent.setIpc(patentClassifies);
-        }
+        webVOTransformService.loadPatentIPC(patent, mainIpc, ipcList);
 
         //装载CPC分类号
         List<String> cpcList = uploadParamsVO.getCpcList();
-        if (cpcList != null && cpcList.size() > 0) {
-            List<PatentClassify> patentClassifies = new ArrayList<>();
-            for (int i = 0; i < cpcList.size(); i++) {
-                PatentClassify patentClassify = PatentClassifySplitter.split(cpcList.get(i));
-                patentClassifies.add(patentClassify);
-            }
-            patent.setCpc(patentClassifies);
-        }
+        webVOTransformService.loadPatentCPC(patent, cpcList);
 
         //装载说明书
         if (uploadParamsVO.getPatentInstructionText() != null) {
@@ -336,7 +270,7 @@ public class GetPatentFromExcelThread extends Thread {
                 Text text = new Text();
                 text.setTextContent(uploadParamsVO.getPatentInstructionText().getManual());
                 text.setIfOrigin(true);
-                text.setLanguage(contry);
+                text.setLanguage(patent.getAppCountry());
                 texts.add(text);
             }
             if (uploadParamsVO.getPatentInstructionText().getManualOut() != null) {
@@ -373,7 +307,7 @@ public class GetPatentFromExcelThread extends Thread {
         }
 
         this.loadLegalStatus(patent);
-        this.loadPatentType(patent);
+
         this.loadLegalStatusBySta(uploadParamsVO);
 
     }

+ 52 - 83
src/main/java/cn/cslg/pas/service/importPatent/GetPatentPDFFromWebThread.java

@@ -47,95 +47,30 @@ public class GetPatentPDFFromWebThread extends Thread {
         while ((!ifProductAll || uploadPatentWebDTOs.size() > 0) && importTaskAMVO.getState().equals(1)) {
 
             try {
-
                 if (uploadPatentWebDTOs.size() == 0) {
                     taskLock.lock();
                     taskCondition.await();
                 }
             } catch (Exception e) {
-
+                e.printStackTrace();
+            }
+            if (uploadPatentWebDTOs.size() == 0) {
+                break;
             }
             UploadPatentWebDTO uploadPatentWebDTO = uploadPatentWebDTOs.remove(0);
             try {
-                String usedPatentNo;
-                StarPatentVO starPatentVO = uploadPatentWebDTO.getStarPatentVO();
-                if (starPatentVO.getPublicNo() != null && !starPatentVO.getPublicNo().equals("")) {
-                    usedPatentNo = starPatentVO.getPublicNo();
-                } else {
-                    usedPatentNo = starPatentVO.getPublicAccreditNo();
-                }
-
-                String pdfUrl = "", pdfUrl1 = "", pdfUrl2 = "";
-                //先根据公开号判断国家,若没有公开号再根据申请号判断,调用"获得中国专利pdf"接口,获得1个或2个pdf的url地址
-                if ((starPatentVO.getPublicNo() != null && starPatentVO.getPublicNo().contains("CN")) || (starPatentVO.getPublicNo() == null && starPatentVO.getPatentNo().contains("CN"))) {
-
-                    String pdfUrlStr = patentStarApiService.getCnPdfApi(starPatentVO.getRowApplicationNo());
-
-                    //若没有取到说明书pdf,则将当前申请号和备注信息存入问题记录表,并返回空对象
-                    if (!pdfUrlStr.equals("")) {
-
-                    if (pdfUrlStr.contains("|http")) {  //若包含公开和授权两个pdf
-                        String[] pdfUrlArr = pdfUrlStr.split("\\|http");
-                        pdfUrl1 = pdfUrlArr[0].substring(pdfUrlArr[0].indexOf("http"), pdfUrlArr[0].indexOf("?"));
-                        pdfUrlArr[1] = "http" + pdfUrlArr[1];
-                        pdfUrl2 = pdfUrlArr[1].substring(pdfUrlArr[1].indexOf("http"), pdfUrlArr[1].indexOf("?"));
-
-                        if (pdfUrl1.contains("0A_CN_0.pdf")) {
-                            String guid1 = FormatUtil.getPDFFormat(starPatentVO.getApplicationNo(), 0);
-                            File file1 = FileUtils.getFileByUrl(pdfUrl1);
-                            fileManagerService.uploadFileWithGuid(file1, guid1);
-                            String guid2 = FormatUtil.getPDFFormat(starPatentVO.getApplicationNo(), 1);
-                            File file2 = FileUtils.getFileByUrl(pdfUrl2);
-                            fileManagerService.uploadFileWithGuid(file2, guid2);
-                        } else {
-                            String guid1 = FormatUtil.getPDFFormat(starPatentVO.getApplicationNo(), 1);
-                            File file1 = FileUtils.getFileByUrl(pdfUrl1);
-                            fileManagerService.uploadFileWithGuid(file1, guid1);
-                            String guid2 = FormatUtil.getPDFFormat(starPatentVO.getApplicationNo(), 0);
-                            File file2 = FileUtils.getFileByUrl(pdfUrl2);
-                            fileManagerService.uploadFileWithGuid(file2, guid2);
-                        }
-                    } else {  //若只有一个
-                        if(pdfUrlStr.contains("?")) {
-                            pdfUrl1 = pdfUrlStr.substring(pdfUrlStr.indexOf("http"), pdfUrlStr.indexOf("?"));
-                        }
-                        else {
-                            pdfUrl1 = pdfUrlStr.substring(pdfUrlStr.indexOf("http"));
-                        }
-                        if (pdfUrl1.contains("0A_CN_0.pdf")) {
-                            String guid1 = FormatUtil.getPDFFormat(starPatentVO.getApplicationNo(), 0);
-                            File file1 = FileUtils.getFileByUrl(pdfUrl1);
-                            fileManagerService.uploadFileWithGuid(file1, guid1);
-                        } else {
-                            String guid1 = FormatUtil.getPDFFormat(starPatentVO.getApplicationNo(), 1);
-                            File file1 = FileUtils.getFileByUrl(pdfUrl1);
-                            fileManagerService.uploadFileWithGuid(file1, guid1);
-                        }
-                    }
-                    //根据专利号调用"获得世界专利pdf"接口,获得pdf的url地址
-                }
-                    else {
-
-                        recordQuestionPatent(starPatentVO.getApplicationNo());
-                    }
-                }
-                else {
-                    pdfUrl = patentStarApiService.getEnPdfApi(usedPatentNo);
-                    //若没有取到说明书pdf,则将当前申请号和备注信息存入问题记录表,并返回空对象
-
-                    if (!pdfUrl.equals("")) {
-                        String guid1 = FormatUtil.getPDFFormat(usedPatentNo, 0);
-                        File file1 = FileUtils.getFileByUrl(pdfUrl);
-                        fileManagerService.uploadFileWithGuid(file1, guid1);
-                    }
-                    else{
-                        recordQuestionPatent(starPatentVO.getApplicationNo());
-
-                    }
-                }
-                taskThread.updateProcess(false,4,"");
+               StarPatentVO starPatentVO =uploadPatentWebDTO.getStarPatentVO();
+            Integer patentType =   starPatentVO.getPT();
+               if(patentType.equals(3)){
+                   WebVOTransformService webVOTransformService =applicationContext.getBean(WebVOTransformService.class);
+                   webVOTransformService.getCNPatentPicture(uploadPatentWebDTO,importTaskAMVO.getId());
+               }
+               else {
+                   this.addPDF(uploadPatentWebDTO);
+               }
+                taskThread.updateProcess(false, 4, "");
             } catch (Exception e) {
-                taskThread.updateProcess(true,4,"");
+                taskThread.updateProcess(true, 4, "");
                 e.printStackTrace();
             }
         }
@@ -153,8 +88,8 @@ public class GetPatentPDFFromWebThread extends Thread {
     }
 
     public void awakeTask(UploadPatentWebDTO uploadPatentWebDTO) {
-        UploadPatentWebDTO uploadPatentWebDTO1=new UploadPatentWebDTO();
-        BeanUtils.copyProperties(uploadPatentWebDTO,uploadPatentWebDTO1);
+        UploadPatentWebDTO uploadPatentWebDTO1 = new UploadPatentWebDTO();
+        BeanUtils.copyProperties(uploadPatentWebDTO, uploadPatentWebDTO1);
         uploadPatentWebDTOs.add(uploadPatentWebDTO1);
         if (taskLock.tryLock()) {
             taskCondition.signalAll();
@@ -172,11 +107,45 @@ public class GetPatentPDFFromWebThread extends Thread {
 
     }
 
-    public void recordQuestionPatent(String appNo){
+    public void recordQuestionPatent(String appNo) {
         PatentImportErrorLog patentImportErrorLog = new PatentImportErrorLog();
         patentImportErrorLog.setPatentNo(appNo);
         patentImportErrorLog.setErrorType(4);
         patentImportErrorLog.setTaskId(importTaskAMVO.getId());
         patentImportErrorLog.insert();
     }
+
+    public void addPDF(UploadPatentWebDTO uploadPatentWebDTO) throws Exception{
+        StarPatentVO starPatentVO = uploadPatentWebDTO.getStarPatentVO();
+
+        WebVOTransformService webVOTransformService = applicationContext.getBean(WebVOTransformService.class);
+        String pdfUrl = "", pdfUrl1 = "", pdfUrl2 = "";
+        //先根据公开号判断国家,若没有公开号再根据申请号判断,调用"获得中国专利pdf"接口,获得1个或2个pdf的url地址
+        if ((starPatentVO.getPN() != null && starPatentVO.getPN().contains("CN")) || (starPatentVO.getPN() == null && starPatentVO.getPatentNo().contains("CN"))) {
+
+            String pdfUrlStr = patentStarApiService.getCnPdfApi(starPatentVO.getANO());
+            //若没有取到说明书pdf,则将当前申请号和备注信息存入问题记录表,并返回空对象
+            if (!pdfUrlStr.equals("")) {
+                webVOTransformService.getCnPatentPDF(pdfUrlStr, starPatentVO);
+                //根据专利号调用"获得世界专利pdf"接口,获得pdf的url地址
+            } else {
+                recordQuestionPatent(starPatentVO.getAN());
+            }
+        } else {
+            String usedPatentNo;
+            if (starPatentVO.getPN() != null && !starPatentVO.getPN().equals("")) {
+                usedPatentNo = starPatentVO.getPN();
+            } else {
+                usedPatentNo = starPatentVO.getGN();
+            }
+            pdfUrl = patentStarApiService.getEnPdfApi(usedPatentNo);
+            //若没有取到说明书pdf,则将当前申请号和备注信息存入问题记录表,并返回空对象
+            if (!pdfUrl.equals("")) {
+                webVOTransformService.getWdPatentPDF(pdfUrl, usedPatentNo);
+            } else {
+                recordQuestionPatent(starPatentVO.getAN());
+            }
+        }
+
+    }
 }

+ 13 - 10
src/main/java/cn/cslg/pas/service/importPatent/GetPatentPictureFromWebThread.java

@@ -14,7 +14,6 @@ import cn.cslg.pas.service.common.PatentStarApiService;
 import cn.hutool.core.util.IdUtil;
 import org.apache.commons.fileupload.FileItem;
 import org.apache.commons.fileupload.disk.DiskFileItemFactory;
-import org.apache.commons.lang3.StringUtils;
 import org.dom4j.Document;
 import org.dom4j.Element;
 import org.dom4j.XPath;
@@ -56,36 +55,40 @@ public class GetPatentPictureFromWebThread extends Thread {
                 }
             } catch (Exception e) {
             }
+            if (uploadPatentWebDTOs.size() == 0) {
+                break;
+            }
             UploadPatentWebDTO uploadPatentWebDTO = uploadPatentWebDTOs.remove(0);
             try {
-                String usedNo = uploadPatentWebDTO.getStarPatentVO().getPublicNo();
-                if (StringUtils.isEmpty(usedNo)) {
-                    usedNo = uploadPatentWebDTO.getStarPatentVO().getPublicAccreditNo();
+                String usedNo = uploadPatentWebDTO.getStarPatentVO().getPN();
+                if (usedNo == null||usedNo.trim().equals("")) {
+                    usedNo = uploadPatentWebDTO.getStarPatentVO().getGN();
                 }
                 if (usedNo.contains("CN")) {
                     PatentStarApiService patentStarApiService = applicationContext.getBean(PatentStarApiService.class);
 
-                    String pictureUrl = patentStarApiService.getPictureApi(uploadPatentWebDTO.getStarPatentVO().getRowApplicationNo());
+                    String pictureUrl = patentStarApiService.getPictureApi(uploadPatentWebDTO.getStarPatentVO().getANO());
 
                     if (pictureUrl != null && !pictureUrl.contains("408")) {
                         File file = FileUtils.getPictureFileByUrl(pictureUrl);
                         FileManagerService fileManagerService = applicationContext.getBean(FileManagerService.class);
-                        String guid = FormatUtil.getPictureFormat(uploadPatentWebDTO.getStarPatentVO().getApplicationNo());
+                        String guid = FormatUtil.getPictureFormat(uploadPatentWebDTO.getStarPatentVO().getANO());
                         fileManagerService.uploadFileWithGuid(file, guid);
                     } else {
-                        recordQuestionPatent(uploadPatentWebDTO.getStarPatentVO().getApplicationNo());
+                        recordQuestionPatent(uploadPatentWebDTO.getStarPatentVO().getANO());
                     }
+
                 } else {
                     ImportSinglePatentService importSinglePatentService = applicationContext.getBean(ImportSinglePatentService.class);
                     byte[] bytes = importSinglePatentService.getImages(usedNo);
                     if (bytes != null) {
                         File file = FileUtils.getFileByBytes(bytes, usedNo, "jpg");
                         FileManagerService fileManagerService = applicationContext.getBean(FileManagerService.class);
-                        String guid = FormatUtil.getPictureFormat(uploadPatentWebDTO.getStarPatentVO().getApplicationNo());
+                        String guid = FormatUtil.getPictureFormat(uploadPatentWebDTO.getStarPatentVO().getANO());
                         fileManagerService.uploadFileWithGuid(file, guid);
                         file.delete();
                     } else {
-                        recordQuestionPatent(uploadPatentWebDTO.getStarPatentVO().getApplicationNo());
+                        recordQuestionPatent(uploadPatentWebDTO.getStarPatentVO().getANO());
 
                     }
 
@@ -93,7 +96,7 @@ public class GetPatentPictureFromWebThread extends Thread {
                 taskThread.updateProcess(false, 2, "");
             } catch (Exception e) {
                 taskThread.updateProcess(true, 2, "");
-                recordQuestionPatent(uploadPatentWebDTO.getStarPatentVO().getApplicationNo());
+                recordQuestionPatent(uploadPatentWebDTO.getStarPatentVO().getAN());
 
                 e.printStackTrace();
             }

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

@@ -43,9 +43,7 @@ public class GetRightAndFullTextFromWebThread extends Thread {
 
     @Override
     public void run() {
-
         while ((!ifProductAll || uploadPatentWebDTOs.size() > 0) && importTaskAMVO.getState().equals(1)) {
-
             try {
                 if (uploadPatentWebDTOs.size() == 0) {
                     taskLock.lock();
@@ -54,32 +52,33 @@ public class GetRightAndFullTextFromWebThread extends Thread {
             } catch (Exception e) {
 
             }
-            if(uploadPatentWebDTOs.size()==0){
+            if (uploadPatentWebDTOs.size() == 0) {
                 break;
             }
             UploadPatentWebDTO uploadPatentWebDTO = uploadPatentWebDTOs.remove(0);
             try {
                 StarPatentVO starPatentVO = uploadPatentWebDTO.getStarPatentVO();
-
-                if ((starPatentVO.getPublicNo() != null && starPatentVO.getPublicNo().contains("CN")) || (starPatentVO.getApplicationNo() != null && starPatentVO.getApplicationNo().contains("CN"))|| (starPatentVO.getPublicAccreditNo() != null && starPatentVO.getPublicAccreditNo().contains("CN"))) {
-                    patentStarApiService = applicationContext.getBean(PatentStarApiService.class);
-                    String cnFullXmlStr = patentStarApiService.getCnFullXmlApi(starPatentVO.getRowApplicationNo());
-                    this.loadClaim(uploadPatentWebDTO, cnFullXmlStr);
-                    ImportSinglePatentService importSinglePatentService =applicationContext.getBean(ImportSinglePatentService.class);
-                    importSinglePatentService.loadFullText(uploadPatentWebDTO, cnFullXmlStr);
+                Patent patent = uploadPatentWebDTO.getPatent();
+                if (!patent.getPatentType().equals("3")) {
+                    if ((starPatentVO.getPN() != null && starPatentVO.getPN().contains("CN")) || (starPatentVO.getAN() != null && starPatentVO.getAN().contains("CN")) || (starPatentVO.getGN() != null && starPatentVO.getGN().contains("CN"))) {
+                        patentStarApiService = applicationContext.getBean(PatentStarApiService.class);
+                        String cnFullXmlStr = patentStarApiService.getCnFullXmlApi(starPatentVO.getANO());
+                        WebVOTransformService webVOTransformService = applicationContext.getBean(WebVOTransformService.class);
+                        webVOTransformService.loadClaim(patent, cnFullXmlStr,importTaskAMVO.getId());
+                        webVOTransformService.loadFullText(patent, cnFullXmlStr,importTaskAMVO.getId());
+                    }
                 }
-                //加入es保存队列
-                importFromWebToEsService.loadPatentMessageDone(uploadPatentWebDTO);
+                    //加入es保存队列
+                    this.addPatent(uploadPatentWebDTO);
+
             } catch (Exception e) {
-                importFromWebToEsService.loadPatentMessageDone(uploadPatentWebDTO);
+                this.addPatent(uploadPatentWebDTO);
                 e.printStackTrace();
             }
-            System.out.println("rightDone" + ifProductAll);
         }
-        importFromWebToEsService.setPatentToEsProductAll("rightDone");
+        this.sendDone();
     }
 
-
     public GetRightAndFullTextFromWebThread(TaskThread taskThread, ImportFromWebToEsService importFromWebToEsService) {
         this.importTaskAMVO = taskThread.getImportTaskAMVO();
         this.importFromWebToEsService = importFromWebToEsService;
@@ -100,46 +99,6 @@ public class GetRightAndFullTextFromWebThread extends Thread {
     }
 
 
-    //装载权利要求
-    private void loadClaim(UploadPatentWebDTO uploadPatentWebDTO, String cnFullXmlStr) {
-        Patent patent = uploadPatentWebDTO.getPatent();
-        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 void setIfProductAll(Boolean ifProductAll) {
         this.ifProductAll = ifProductAll;
         if (taskLock.tryLock()) {
@@ -147,4 +106,17 @@ public class GetRightAndFullTextFromWebThread extends Thread {
             taskLock.unlock();
         }
     }
-}
+
+    /**
+     * @param uploadPatentWebDTO
+     */
+    public void addPatent(UploadPatentWebDTO uploadPatentWebDTO) {
+        SavePatentToEsThread savePatentToEsThread = importFromWebToEsService.getSavePatentToEsThreadObject();
+        savePatentToEsThread.awakeTask(uploadPatentWebDTO);
+    }
+
+    public void sendDone() {
+        SavePatentToEsThread savePatentToEsThread = importFromWebToEsService.getSavePatentToEsThreadObject();
+        savePatentToEsThread.setIfProductAll(true);
+    }
+}

+ 46 - 54
src/main/java/cn/cslg/pas/service/importPatent/ImportFromWebToEsService.java

@@ -44,16 +44,34 @@ 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;
+    }
 
-    private GetPatentPDFFromWebThread getPatentPDFFromWebThread;
-    private GetPatentPictureFromWebThread getPatentPictureFromWebThread;
-    private GetRightAndFullTextFromWebThread getRightAndFullTextFromWebThread;
-    private ApplicationContext applicationContext;
-    private List<UploadPatentWebDTO> uploadPatentWebDTOS = new ArrayList<>();
+    public GetPatentPDFFromWebThread getPatentPDFFromWebThreadObject() {
+        return getPatentPDFFromWebThread;
+    }
+
+    public GetPatentPictureFromWebThread getPatentPictureFromWebThreadObject() {
+        return getPatentPictureFromWebThread;
+    }
+
+    public GetRightAndFullTextFromWebThread getRightAndFullTextFromWebThreadObject() {
+        return getRightAndFullTextFromWebThread;
+    }
+
+    public SavePatentToEsThread getSavePatentToEsThreadObject() {
+        return savePatentToEsThread;
+    }
 
     @Override
     public Boolean startPatentThread() {
@@ -67,6 +85,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 +104,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);
     }
 
 
@@ -218,19 +239,26 @@ public class ImportFromWebToEsService implements PatentImportImp {
 
 
                     Integer pageStartNum = (i * 50) >= startNum ? 0 : startNum - (i * 50);
+
                     Integer pageEndNum = starPatents.size();
+
                     //遍历这一页的专利
                     for (int j = pageStartNum; j < pageEndNum; j++) {
                         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()));
+                            String no = nos.stream().filter(item -> item.equals(starPatentVO.getAN())
+                                    || item.equals(starPatentVO.getPN())
+                                    || item.equals(starPatentVO.getGN())
+                                    || item.equals(starPatentVO.getANO())).findFirst().orElse(null);
+                            if (no != null) {
+                                nos.remove(no);
+                            }
                         }
+
                         UploadPatentWebDTO uploadPatentWebDTO = new UploadPatentWebDTO();
                         Patent patent = new Patent();
+
                         //装载start
                         uploadPatentWebDTO.setStarPatentVO(starPatentVO);
                         uploadPatentWebDTO.setPatent(patent);
@@ -242,15 +270,9 @@ public class ImportFromWebToEsService implements PatentImportImp {
                         if (ifCataloguing == '1') {
                             getCataloguingFromWebThread.awakeTask(uploadPatentWebDTO);
                         }
-
                         if (ifAddPicture == '1') {
                             getPatentPictureFromWebThread.awakeTask(uploadPatentWebDTO);
                         }
-
-                        if (ifAddFullText == '1') {
-                            getRightAndFullTextFromWebThread.awakeTask(uploadPatentWebDTO);
-                        }
-
                         if (ifPdf == '1') {
                             getPatentPDFFromWebThread.awakeTask(uploadPatentWebDTO);
                         }
@@ -280,19 +302,15 @@ public class ImportFromWebToEsService implements PatentImportImp {
             if (ifAddPicture == '1') {
                 getPatentPictureFromWebThread.setIfProductAll(true);
             }
-            if (ifAddFullText == '1') {
-                getRightAndFullTextFromWebThread.setIfProductAll(true);
-                System.out.println("fullTextawake");
-            }
             if (ifPdf == '1') {
                 getPatentPDFFromWebThread.setIfProductAll(true);
             }
 
-        return ifHaveGet;
+            return ifHaveGet;
         } catch (Exception e) {
             e.printStackTrace();
             //生产消费到一半时,发生错误异常,将任务状态置为完成
-           return  ifHaveGet;
+            return ifHaveGet;
         }
     }
 
@@ -305,29 +323,6 @@ public class ImportFromWebToEsService implements PatentImportImp {
     }
 
 
-    public void loadPatentMessageDone(UploadPatentWebDTO uploadPatentWebDTO) {
-        synchronized ("装载专利信息") {
-            if (importTaskAMVO.getMessageThreadCounter() > 1) {
-                // 根据index查询是否有相同的
-                List<UploadPatentWebDTO> dtos = uploadPatentWebDTOS.stream()
-                        .filter(item -> item.getIndex().equals(uploadPatentWebDTO.getIndex())).collect(Collectors.toList());
-                if (dtos.size() > 0) {
-                    Patent orgPatent = uploadPatentWebDTO.getPatent();
-                    Patent patent = dtos.get(0).getPatent();
-                    BeanUtils.copyProperties(patent, orgPatent, FormatUtil.getNullPropertyNames(patent));
-                    uploadPatentWebDTO.setPatent(orgPatent);
-                    uploadPatentWebDTOS.removeIf(i -> i.getIndex().equals(uploadPatentWebDTO.getIndex()));
-                    savePatentToEsThread.awakeTask(uploadPatentWebDTO);
-                } else {
-                    uploadPatentWebDTOS.add(uploadPatentWebDTO);
-                }
-            } else {
-                savePatentToEsThread.awakeTask(uploadPatentWebDTO);
-            }
-        }
-    }
-
-
     public void setPatentToEsProductAll(String message) {
         synchronized ("装载专利信息") {
             System.out.println(message);
@@ -338,8 +333,5 @@ public class ImportFromWebToEsService implements PatentImportImp {
         }
     }
 
-    private void loadPatent(StarPatentVO starPatentVO, Patent patent) {
 
-
-    }
 }

+ 28 - 420
src/main/java/cn/cslg/pas/service/importPatent/ImportSinglePatentService.java

@@ -74,6 +74,8 @@ public class ImportSinglePatentService {
     private OPSService opsService;
     @Autowired
     private PatentNoUtil patentNoUtil;
+    @Autowired
+    private WebVOTransformService webVOTransformService;
 
     public StarPatentVO getPatentFromWeb(String patentNo) {
         StarPatentVO starPatentVO = null;
@@ -109,7 +111,7 @@ public class ImportSinglePatentService {
 
 
     public PatentWithIdVO addSinglePatent(String patentNo) {
-        PatentWithIdVO patentWithIdVO =new PatentWithIdVO();
+        PatentWithIdVO patentWithIdVO = new PatentWithIdVO();
         StarPatentVO starPatentVO = new StarPatentVO();
         starPatentVO = this.getPatentFromWeb(patentNo);
         if (starPatentVO == null) {
@@ -121,11 +123,11 @@ public class ImportSinglePatentService {
         patentJoin.setName("patent");
         patent.setPatentJoin(patentJoin);
         try {
-             patentWithIdVO = esService.getIdByPatentNo(patent.getPatentNo());
+            patentWithIdVO = esService.getIdByPatentNo(patent.getPatentNo());
             if (patentWithIdVO != null) {
                 return patentWithIdVO;
             }
-            patentWithIdVO =new PatentWithIdVO();
+            patentWithIdVO = new PatentWithIdVO();
             String patentId = esService.addPatent(patent);
             patentWithIdVO.setPatent(patent);
             patentWithIdVO.setId(patentId);
@@ -143,418 +145,28 @@ public class ImportSinglePatentService {
      */
     public Patent getPatentCataloguingFromWeb(StarPatentVO starPatentVO) {
         String patentZhuLuStr = "";
-        if (starPatentVO.getApplicationNo().startsWith("CN")) {
-            patentZhuLuStr = patentStarApiService.getCnBibApi(starPatentVO.getRowApplicationNo());
+        if (starPatentVO.getAN().startsWith("CN")) {
+            patentZhuLuStr = patentStarApiService.getCnBibApi(starPatentVO.getANO());
         } else {
-            patentZhuLuStr = patentStarApiService.getENBibApi(starPatentVO.getPublicNo());
+            patentZhuLuStr = patentStarApiService.getENBibApi(starPatentVO.getPN());
         }
         UploadPatentWebDTO uploadPatentWebDTO = new UploadPatentWebDTO();
         uploadPatentWebDTO.setPatent(new Patent());
         uploadPatentWebDTO.setStarPatentVO(starPatentVO);
-        this.loadPatent(uploadPatentWebDTO);
+
         if (patentZhuLuStr != null && !patentZhuLuStr.trim().equals("") && !patentZhuLuStr.equals("{}") && !patentZhuLuStr.contains("请求不合法")) {
-            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());
-                }
+            if (starPatentVO.getAN().startsWith("CN")) {
+                webVOTransformService.loadCNPatent(patentZhuLuStr, uploadPatentWebDTO);
             } 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);
             }
         }
         return uploadPatentWebDTO.getPatent();
     }
 
-    //装载专利信息
-    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("1");  //实用新型
-            } else if (patentType.equals(1) || patentType.equals(8)) {
-                patent.setPatentType("2");  //发明
-            } 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("")) {
-//
-//            patent.setGrantDate();
-            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());
-        }
-
-        if (starPatentVO.getPublicAccreditNo() != null && !starPatentVO.getPublicAccreditNo().equals("")) {
-            patent.setGrantNo(starPatentVO.getPublicAccreditNo());
-        }
-
-        if (patent.getAppNo().startsWith("CN")) {
-            patent.setPatentNo(patent.getAppNo());
-        } else {
-            if (patent.getPublicNo() != null) {
-                patent.setPatentNo(patent.getPublicNo());
-            } else if (patent.getGrantNo() != null) {
-                patent.setPatentNo(patent.getGrantNo());
-            }
-        }
-        //装载申请人
-        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("3");
-                //失效(无权)
-            } else if (status == 2) {
-                patent.setSimpleStatus("2");
-                //审中(审中)
-            } else if (status == 3) {
-                patent.setSimpleStatus("1");
-            }
-        }
-
-        //装载优先权
-        if (starPatentVO.getPriorityNo() != null && !starPatentVO.getPriorityNo().equals("")) {
-            Priorities priorities = new Priorities();
-            priorities.setPriorityNo(starPatentVO.getPriorityNo());
-            String pCountry = starPatentVO.getApplicationNo().substring(0, 2);
-            priorities.setPriorityCountry(pCountry);
-            //装载优先权日
-            if (starPatentVO.getPriorityDate() != null && !starPatentVO.getPriorityDate().equals("")) {
-                DateUtils.str2Date(starPatentVO.getPriorityDate());
-            }
-            patent.setPriorities(Arrays.asList(priorities));
-        }
-
-        //装载受理局
-        if (starPatentVO.getBureau() != null && !starPatentVO.getBureau().equals("")) {
-            patent.setAppCountry(starPatentVO.getBureau());
-        }
-    }
-
-
-    //装载中国专利
-    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 (patent.getPriorities() == null && chinaPatentZhuLu.getPR() != null && chinaPatentZhuLu.getPR() != "") {
-                Priorities priorities = new Priorities();
-                priorities.setPriorityNo(chinaPatentZhuLu.getPR());
-                String pCountry = chinaPatentZhuLu.getPR().substring(0, 2);
-                priorities.setPriorityCountry(pCountry);
-                patent.setPriorities(Arrays.asList(priorities));
-            }
-
-        }
-    }
-
-    /**
-     * 装载世界专利著录
-     *
-     * @param worldPatentZhuLuStr
-     * @param patent
-     */
-    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) {
-            if (worldPatentZhuLu.getAppDate() != null && !worldPatentZhuLu.getAppDate().equals("")) {
-                Date date = DateUtils.strToDate(worldPatentZhuLu.getAppDate());
-                patent.setAppDate(date);
-            }
-
-        }
-        //装载公开日
-        if (patent.getPublicDate() == null) {
-            if (worldPatentZhuLu.getPubDate() != null && !worldPatentZhuLu.getPubDate().equals("")) {
-                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() != "") {
-            Priorities priorities = new Priorities();
-            priorities.setPriorityNo(worldPatentZhuLu.getPr());
-            String pCountry = worldPatentZhuLu.getPr().substring(0, 2);
-            priorities.setPriorityCountry(pCountry);
-            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 void getFullXmlStr(Patent patent, StarPatentVO starPatentVO, List<Integer> contents) throws Exception {
-        String cnFullXmlStr = patentStarApiService.getCnFullXmlApi(starPatentVO.getRowApplicationNo());
+        String cnFullXmlStr = patentStarApiService.getCnFullXmlApi(starPatentVO.getANO());
         if (contents.contains(3)) {
             this.loadClaim(patent, cnFullXmlStr);
 
@@ -583,7 +195,6 @@ public class ImportSinglePatentService {
                     String claim = item.getText();
                     claim = claim.replaceAll("\r\n|\r|\n|\t| ", "");
                     reClaims.add(claim);
-
                 });
                 String reClaim = "";
                 if (reClaims.size() != 0) {
@@ -661,21 +272,21 @@ public class ImportSinglePatentService {
     public void getPDFFromWeb(StarPatentVO starPatentVO) throws Exception {
 
         String usedPatentNo;
-        if (starPatentVO.getPublicNo() != null && !starPatentVO.getPublicNo().equals("")) {
-            usedPatentNo = starPatentVO.getPublicNo();
+        if (starPatentVO.getPN() != null && !starPatentVO.getPN().equals("")) {
+            usedPatentNo = starPatentVO.getPN();
         } else {
-            usedPatentNo = starPatentVO.getPublicAccreditNo();
+            usedPatentNo = starPatentVO.getGN();
         }
 
         String pdfUrl = "", pdfUrl1 = "", pdfUrl2 = "";
         //先根据公开号判断国家,若没有公开号再根据申请号判断,调用"获得中国专利pdf"接口,获得1个或2个pdf的url地址
-        if ((starPatentVO.getPublicNo() != null && starPatentVO.getPublicNo().contains("CN")) || (starPatentVO.getPublicNo() == null && starPatentVO.getPatentNo().contains("CN")) || (starPatentVO.getPublicAccreditNo() != null && starPatentVO.getPublicAccreditNo().contains("CN"))) {
+        if ((starPatentVO.getPN() != null && starPatentVO.getPN().contains("CN")) || (starPatentVO.getPN() == null && starPatentVO.getPatentNo().contains("CN")) || (starPatentVO.getGN() != null && starPatentVO.getGN().contains("CN"))) {
 
-            String pdfUrlStr = patentStarApiService.getCnPdfApi(starPatentVO.getRowApplicationNo());
+            String pdfUrlStr = patentStarApiService.getCnPdfApi(starPatentVO.getANO());
 
             //若没有取到说明书pdf,则将当前申请号和备注信息存入问题记录表,并返回空对象
             if (!pdfUrlStr.equals("")) {
-//                        recordQuestionPatent(starPatent.getApplicationNo(), task.getId(), 4);
+//                        recordQuestionPatent(starPatent.getAN(), task.getId(), 4);
 
 
                 if (pdfUrlStr.contains("|http")) {  //若包含公开和授权两个pdf
@@ -686,17 +297,17 @@ public class ImportSinglePatentService {
 
 
                     if (pdfUrl1.contains("0A_CN_0.pdf")) {
-                        String guid1 = FormatUtil.getPDFFormat(starPatentVO.getApplicationNo(), 0);
+                        String guid1 = FormatUtil.getPDFFormat(starPatentVO.getAN(), 0);
                         File file1 = FileUtils.getFileByUrl(pdfUrl1);
                         fileManagerService.uploadFileWithGuid(file1, guid1);
-                        String guid2 = FormatUtil.getPDFFormat(starPatentVO.getApplicationNo(), 1);
+                        String guid2 = FormatUtil.getPDFFormat(starPatentVO.getAN(), 1);
                         File file2 = FileUtils.getFileByUrl(pdfUrl2);
                         fileManagerService.uploadFileWithGuid(file2, guid2);
                     } else {
-                        String guid1 = FormatUtil.getPDFFormat(starPatentVO.getApplicationNo(), 1);
+                        String guid1 = FormatUtil.getPDFFormat(starPatentVO.getAN(), 1);
                         File file1 = FileUtils.getFileByUrl(pdfUrl1);
                         fileManagerService.uploadFileWithGuid(file1, guid1);
-                        String guid2 = FormatUtil.getPDFFormat(starPatentVO.getApplicationNo(), 0);
+                        String guid2 = FormatUtil.getPDFFormat(starPatentVO.getAN(), 0);
                         File file2 = FileUtils.getFileByUrl(pdfUrl2);
                         fileManagerService.uploadFileWithGuid(file2, guid2);
                     }
@@ -707,11 +318,11 @@ public class ImportSinglePatentService {
                         pdfUrl1 = pdfUrlStr.substring(pdfUrlStr.indexOf("http"));
                     }
                     if (pdfUrl1.contains("0A_CN_0.pdf")) {
-                        String guid1 = FormatUtil.getPDFFormat(starPatentVO.getApplicationNo(), 0);
+                        String guid1 = FormatUtil.getPDFFormat(starPatentVO.getAN(), 0);
                         File file1 = FileUtils.getFileByUrl(pdfUrl1);
                         fileManagerService.uploadFileWithGuid(file1, guid1);
                     } else {
-                        String guid1 = FormatUtil.getPDFFormat(starPatentVO.getApplicationNo(), 1);
+                        String guid1 = FormatUtil.getPDFFormat(starPatentVO.getAN(), 1);
                         File file1 = FileUtils.getFileByUrl(pdfUrl1);
                         fileManagerService.uploadFileWithGuid(file1, guid1);
                     }
@@ -722,7 +333,7 @@ public class ImportSinglePatentService {
             pdfUrl = patentStarApiService.getEnPdfApi(usedPatentNo);
             //若没有取到说明书pdf,则将当前申请号和备注信息存入问题记录表,并返回空对象
 //                    if (pdfUrl.equals("") || pdfUrl.equals("{}")) {
-//                        recordQuestionPatent(starPatent.getApplicationNo(), task.getId(), 4);
+//                        recordQuestionPatent(starPatent.getAN(), task.getId(), 4);
 //                        return;
 //                    }
             if (!pdfUrl.equals("")) {
@@ -734,12 +345,10 @@ public class ImportSinglePatentService {
     }
 
     public void getPictureFromWeb(StarPatentVO starPatentVO) throws Exception {
-
-
-        String pictureUrl = patentStarApiService.getPictureApi(starPatentVO.getRowApplicationNo());
+        String pictureUrl = patentStarApiService.getPictureApi(starPatentVO.getANO());
         if (pictureUrl != null && pictureUrl != "{}") {
             File file = FileUtils.getPictureFileByUrl(pictureUrl);
-            String guid = FormatUtil.getPictureFormat(starPatentVO.getApplicationNo());
+            String guid = FormatUtil.getPictureFormat(starPatentVO.getAN());
             fileManagerService.uploadFileWithGuid(file, guid);
         }
 
@@ -786,7 +395,6 @@ public class ImportSinglePatentService {
         }
         //添加法律事务
         if (contents.contains(6)) {
-            esService.addEsLegalEvent(starPatentVO);
         }
 
         //装载权利要求

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

@@ -139,6 +139,8 @@ public class SavePatentToEsThread extends Thread {
                     esProductPatentService.addProductPatent(patentId, importTaskAMVO.getProductId());
                 }
 
+
+
                 //保存和自定义字段关联
                 if (importTaskAMVO.getFieldDTOS() != null && importTaskAMVO.getFieldDTOS().size() > 0) {
                     for (EsCustomFieldDTO esCustomFieldDTO : importTaskAMVO.getFieldDTOS()
@@ -161,7 +163,6 @@ public class SavePatentToEsThread extends Thread {
                         EsCustomFieldService esCustomFieldService = applicationContext.getBean(EsCustomFieldService.class);
                         esCustomFieldService.addCustomField(esCustomFieldDTO);
                     }
-
                 }
 
                 //导入完成,通知前台
@@ -181,6 +182,7 @@ public class SavePatentToEsThread extends Thread {
         this.importTaskAMVO = taskThread.getImportTaskAMVO();
     }
 
+
     public void awakeTask(UploadPatentWebDTO uploadPatentWebDTO) {
         synchronized ("") {
             UploadPatentWebDTO uploadPatentWebDTO1 = new UploadPatentWebDTO();
@@ -195,8 +197,8 @@ public class SavePatentToEsThread extends Thread {
         }
     }
 
-    public void setIfProductAll(Boolean ifProductAll) {
 
+    public void setIfProductAll(Boolean ifProductAll) {
         this.ifProductAll = ifProductAll;
         System.out.println("专利导入全部结束" + this.ifProductAll + importTaskAMVO.getId());
         if (taskLock.tryLock()) {
@@ -221,10 +223,8 @@ public class SavePatentToEsThread extends Thread {
                     publicNo = patent.getGrantNo();
                 }
             }
-
             patent.setPublicNo(publicNo);
             patent.setGrantNo(grantNo);
-
             if (orgPatent.getClaim() != null && orgPatent.getClaim().size() > 0 && orgPatent.getGrantNo() != null && patent.getGrantNo() == null) {
                 patent.setClaim(orgPatent.getClaim());
             }
@@ -233,8 +233,8 @@ public class SavePatentToEsThread extends Thread {
                 patent.setPublicFullText(null);
             }
         }
-
 return  patent;
     }
 
+
 }

+ 24 - 5
src/main/java/cn/cslg/pas/service/importPatent/SchedulingTaskService.java

@@ -6,9 +6,11 @@ import cn.cslg.pas.common.vo.ImportTaskAMVO;
 import cn.cslg.pas.common.vo.ProgressVO;
 import cn.cslg.pas.domain.business.ImportTask;
 import cn.cslg.pas.domain.business.ImportTaskCondition;
+import cn.cslg.pas.domain.business.PatentProject;
 import cn.cslg.pas.domain.business.ReportProject;
 import cn.cslg.pas.service.business.ImportTaskConditionService;
 import cn.cslg.pas.service.business.ImportTaskService;
+import cn.cslg.pas.service.business.PatentProjectService;
 import cn.cslg.pas.service.business.ReportProjectService;
 import com.alibaba.fastjson.JSONArray;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
@@ -40,7 +42,10 @@ public class SchedulingTaskService {
     @Autowired
     private ReportProjectService reportProjectService;
     private List<ImportTaskAMVO> importTaskAMVOS;
-
+    @Autowired
+    private WebVOTransformService webVOTransformService;
+   @Autowired
+   private PatentProjectService patentProjectService;
     public void startTask() {
         Integer freeCount = Constants.MAX_IMPORT_TASK_COUNT - threadPoolTaskExecutor.getActiveCount();
         if (importTaskAMVOS == null) {
@@ -83,22 +88,26 @@ public class SchedulingTaskService {
     }
 
     public List<ImportTaskAMVO> loadTaskAMVOS(List<ImportTask> importTaskList) {
-        //根据projectId 获得报告类型
 
+        //根据projectId 获得报告类型
         List<ImportTaskAMVO> importTaskAMVOS = new ArrayList<>();
         List<Integer> taskConditionIds = new ArrayList<>();
         List<ImportTaskCondition> importTaskConditions = new ArrayList<>();
         taskConditionIds = importTaskList.stream().map(ImportTask::getImportTaskConditionId).collect(Collectors.toList());
+
         //根据taskid查询taskCondition
         if (taskConditionIds.size() != 0) {
             LambdaQueryWrapper<ImportTaskCondition> queryWrapper = new LambdaQueryWrapper<>();
             queryWrapper.in(ImportTaskCondition::getId, taskConditionIds);
             importTaskConditions = importTaskConditionService.list(queryWrapper);
-
         }
+
         for (ImportTask importTask : importTaskList) {
 
             ImportTaskCondition importTaskCondition = importTaskConditions.stream().filter(item -> item.getId().equals(importTask.getImportTaskConditionId())).findFirst().orElse(null);
+            LambdaQueryWrapper<PatentProject> queryWrapper =new LambdaQueryWrapper<>();
+            queryWrapper.eq(PatentProject::getProjectId,importTaskCondition.getProjectId());
+            PatentProject project = patentProjectService.getOne(queryWrapper);
             ImportTaskAMVO importTaskAMVO = new ImportTaskAMVO();
             BeanUtils.copyProperties(importTask, importTaskAMVO);
             if (importTaskCondition != null) {
@@ -113,12 +122,23 @@ public class SchedulingTaskService {
                 importTaskAMVO.setProjectType(importTaskCondition.getProjectType());
                 importTaskAMVO.setPatentNoStr(importTaskCondition.getPatentNos());
                 importTaskAMVO.setPdfType(importTaskCondition.getPdfType());
+                importTaskAMVO.setUpdateCycle(project.getUpdateCycle());
                 if (importTaskCondition.getCustomFields() != null) {
-
                     JSONArray jsonArray = JSONArray.parseArray(importTaskCondition.getCustomFields());
                     List<EsCustomFieldDTO> dtos = jsonArray.toJavaList(EsCustomFieldDTO.class);
                     importTaskAMVO.setFieldDTOS(dtos);
                 }
+
+                //定时任务
+                if (importTaskCondition.getIfCycle()!= null && importTaskCondition.getIfCycle()&&importTask.getUpdateToDate()!=null) {
+                    List<EsCustomFieldDTO> dtoList = webVOTransformService.getEsCustomFieldDTOList(importTaskAMVO);
+                    if (importTaskAMVO.getFieldDTOS() == null) {
+                        importTaskAMVO.setFieldDTOS(dtoList);
+                    } else {
+                        importTaskAMVO.getFieldDTOS().addAll(dtoList);
+                    }
+                }
+
                 LambdaQueryWrapper<ReportProject> rQueryWrapper = new LambdaQueryWrapper<>();
                 rQueryWrapper.eq(ReportProject::getProjectId, importTaskCondition.getProjectId());
                 ReportProject reportProject = reportProjectService.getOne(rQueryWrapper, false);
@@ -131,7 +151,6 @@ public class SchedulingTaskService {
             importTaskAMVO.setProgressVO(progressVO);
             importTaskAMVOS.add(importTaskAMVO);
 
-
         }
         return importTaskAMVOS;
 

+ 5 - 3
src/main/java/cn/cslg/pas/service/importPatent/TaskThread.java

@@ -136,13 +136,15 @@ public class TaskThread extends Thread {
             task.setState(2);
             importTaskAMVO.setState(2);
             MailSendService mailSendService = applicationContext.getBean(MailSendService.class);
-
-//            mailSendService.sendImportTaskDoneEmail("导入任务",task.getName(),task.getCreateId());
+            task.setDoneNum(task.getAllNum());
+            mailSendService.sendImportTaskDoneEmail("导入任务",task.getName(),task.getCreateId());
 
         } else {
             task.setState(importTaskAMVO.getState());
+            task.setDoneNum(this.patentProcess.getPatentDoneNum());
         }
-        task.setDoneNum(this.patentProcess.getPatentDoneNum());
+
+
         importTaskAMVO.setDoneNum(this.patentProcess.getPatentDoneNum());
         task.updateById();
         MessageService messageService = applicationContext.getBean(MessageService.class);

Failā izmaiņas netiks attēlotas, jo tās ir par lielu
+ 1066 - 0
src/main/java/cn/cslg/pas/service/importPatent/WebVOTransformService.java


+ 0 - 24
src/main/java/cn/cslg/pas/service/quartzService/ImportJobService.java

@@ -1,24 +0,0 @@
-package cn.cslg.pas.service.quartzService;
-
-import lombok.RequiredArgsConstructor;
-import org.quartz.DisallowConcurrentExecution;
-import org.quartz.JobDataMap;
-import org.quartz.JobExecutionContext;
-import org.quartz.JobExecutionException;
-import org.springframework.scheduling.quartz.QuartzJobBean;
-
-
-@DisallowConcurrentExecution
-@RequiredArgsConstructor
-public class ImportJobService extends QuartzJobBean {
-
-
-    @Override
-    public void executeInternal(JobExecutionContext context) throws JobExecutionException {
-        JobDataMap jobDataMap = context.getTrigger().getJobDataMap();
-        QrtzTaskDTO qrtzTask = (QrtzTaskDTO) jobDataMap.get("qrtzTask");
-        String parameter = qrtzTask.getParameter();
-
-
-    }
-}

+ 38 - 0
src/main/java/cn/cslg/pas/service/quartzService/ImportPatentJobService.java

@@ -0,0 +1,38 @@
+package cn.cslg.pas.service.quartzService;
+
+import cn.cslg.pas.domain.business.ImportTaskCondition;
+import cn.cslg.pas.service.business.ImportTaskConditionService;
+import cn.cslg.pas.service.business.ImportTaskService;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import lombok.RequiredArgsConstructor;
+import org.quartz.DisallowConcurrentExecution;
+import org.quartz.JobDataMap;
+import org.quartz.JobExecutionContext;
+import org.quartz.JobExecutionException;
+import org.springframework.scheduling.quartz.QuartzJobBean;
+
+import java.util.List;
+
+
+@DisallowConcurrentExecution
+@RequiredArgsConstructor
+public class ImportPatentJobService extends QuartzJobBean {
+private final ImportTaskConditionService  importTaskConditionService;
+private final ImportTaskService importTaskService;
+    @Override
+    public void executeInternal(JobExecutionContext context) throws JobExecutionException {
+        JobDataMap jobDataMap = context.getTrigger().getJobDataMap();
+        QrtzTaskDTO qrtzTask = (QrtzTaskDTO) jobDataMap.get("qrtzTask");
+             Integer projectId =qrtzTask.getId();
+             //根据id查询检索条件
+        LambdaQueryWrapper<ImportTaskCondition> queryWrapper =new LambdaQueryWrapper<>();
+        queryWrapper.eq(ImportTaskCondition::getProjectId,projectId);
+        queryWrapper.eq(ImportTaskCondition::getIfCycle,true)
+                    .eq(ImportTaskCondition::getIfUpdate,true);
+        List<ImportTaskCondition> importTaskConditions =importTaskConditionService.list(queryWrapper);
+            importTaskConditions.forEach(item->{
+                importTaskService.addImportTaskByCondition(item);
+            });
+
+    }
+}

+ 26 - 24
src/main/java/cn/cslg/pas/service/quartzService/JobService.java

@@ -2,6 +2,7 @@ package cn.cslg.pas.service.quartzService;
 
 import cn.cslg.pas.exception.ExceptionEnum;
 import cn.cslg.pas.exception.XiaoShiException;
+import cn.cslg.pas.service.exportProject.SavePatentToEsService;
 import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import org.quartz.*;
@@ -13,17 +14,14 @@ import org.springframework.transaction.annotation.Transactional;
 @Slf4j
 @RequiredArgsConstructor(onConstructor_ = {@Lazy})
 public class JobService {
-
     private final Scheduler scheduler;
-
-
+    private final  static  String PATENT_PROJECT="patent_project";
     /**
      * 删除job
      *
      * @throws SchedulerException
      */
-    public void deleteJob(Integer taskId) throws SchedulerException {
-        QuartzVO quartzVO = this.generateQuartzVO(taskId);
+    public void deleteJob(QuartzVO quartzVO) throws SchedulerException {
         TriggerKey triggerKey = TriggerKey.triggerKey(quartzVO.getTriggerName(), quartzVO.getTriggerGroupName());
         scheduler.pauseTrigger(triggerKey);
         scheduler.unscheduleJob(triggerKey);
@@ -36,8 +34,7 @@ public class JobService {
      *
      * @throws SchedulerException
      */
-    public void pauseJob(Integer taskId) throws SchedulerException {
-        QuartzVO quartzVO = this.generateQuartzVO(taskId);
+    public void pauseJob(QuartzVO quartzVO) throws SchedulerException {
         //更新任务条件状态
         JobKey jobKey = JobKey.jobKey(quartzVO.getJobName(), quartzVO.getJobGroupName());
         scheduler.pauseJob(jobKey);
@@ -48,8 +45,7 @@ public class JobService {
      *
      * @throws SchedulerException
      */
-    public void resumeJob(Integer taskId) throws SchedulerException {
-        QuartzVO quartzVO = this.generateQuartzVO(taskId);
+    public void resumeJob(QuartzVO quartzVO) throws SchedulerException {
         JobKey jobKey = JobKey.jobKey(quartzVO.getJobName(), quartzVO.getJobGroupName());
         scheduler.resumeJob(jobKey);
     }
@@ -61,8 +57,7 @@ public class JobService {
      */
     public void updateJob(QrtzTaskDTO qrtzTask) {
         //更新任务
-
-        QuartzVO quartzVO = this.generateQuartzVO(qrtzTask.getId());
+        QuartzVO quartzVO = qrtzTask.getQuartzVO();
         JobDataMap jobDataMap = new JobDataMap();
         jobDataMap.put("qrtzTask", qrtzTask);
         TriggerKey oldTriggerKey = TriggerKey.triggerKey(quartzVO.getTriggerName(), quartzVO.getTriggerGroupName());
@@ -82,17 +77,15 @@ public class JobService {
      * @throws SchedulerException
      */
     @Transactional
-    public void addJob(QrtzTaskDTO qrtzTask) throws SchedulerException {
+    public void addJob (QrtzTaskDTO qrtzTask) throws SchedulerException {
         //添加一条任务记录
-        Class  jobClass= null;
+        Class jobClass = null;
         try {
-              jobClass  = Class.forName(qrtzTask.getJobClass());
-
-        }
-        catch (Exception e){
-            throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR,"未找到类");
+            jobClass = Class.forName(qrtzTask.getJobClass());
+        } catch (Exception e) {
+            throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, "未找到类");
         }
-        QuartzVO quartzVO = this.generateQuartzVO(qrtzTask.getId());
+        QuartzVO quartzVO = qrtzTask.getQuartzVO();
         JobDataMap jobDataMap = new JobDataMap();
         jobDataMap.put("qrtzTask", qrtzTask);
         CronScheduleBuilder cronScheduleBuilder = CronScheduleBuilder.cronSchedule(qrtzTask.getCron());
@@ -107,7 +100,6 @@ public class JobService {
                 .usingJobData(jobDataMap)
                 .build();
         scheduler.scheduleJob(jobDetail, trigger);
-
     }
 
 
@@ -118,7 +110,6 @@ public class JobService {
         quartzVO.setTriggerName("Trigger_" + taskId);
         quartzVO.setTriggerGroupName("Default");
         return quartzVO;
-
     }
 
     /**
@@ -126,9 +117,20 @@ public class JobService {
      *
      * @throws SchedulerException
      */
-    public void interruptJob(Integer taskId) throws SchedulerException {
-        QuartzVO quartzVO = this.generateQuartzVO(taskId);
+    public void interruptJob(QuartzVO quartzVO) throws SchedulerException {
         JobKey jobKey = JobKey.jobKey(quartzVO.getJobName(), quartzVO.getJobGroupName());
         scheduler.interrupt(jobKey);
     }
-}
+
+    public QuartzVO getPatentProjectVO(Integer projectId) {
+        QuartzVO quartzVO = new QuartzVO();
+        quartzVO.setJobName("Job_" +PATENT_PROJECT+"_"+ projectId);
+        quartzVO.setJobGroupName("Default_"+PATENT_PROJECT);
+        quartzVO.setTriggerName("Trigger_" + PATENT_PROJECT+"_"+projectId);
+        quartzVO.setTriggerGroupName("Default_"+PATENT_PROJECT);
+        return quartzVO;
+    }
+
+
+
+    }

+ 3 - 0
src/main/java/cn/cslg/pas/service/quartzService/QrtzTaskDTO.java

@@ -28,6 +28,9 @@ public class QrtzTaskDTO  implements Serializable {
      */
     private Integer taskType;
 
+
+     private QuartzVO quartzVO;
+
     /**
      * 参数
      */

+ 3 - 1
src/main/java/cn/cslg/pas/service/quartzService/QuartzVO.java

@@ -2,8 +2,10 @@ package cn.cslg.pas.service.quartzService;
 
 import lombok.Data;
 
+import java.io.Serializable;
+
 @Data
-public class QuartzVO {
+public class QuartzVO   implements Serializable {
     /**
      * 任务名称
      */

+ 1 - 1
src/main/resources/application-testNetIn.yml

@@ -58,7 +58,7 @@ spring:
 
     #数据库方式
     job-store-type: jdbc
-    #初始化表结构
+    #初始化表结构`
     jdbc:
       initialize-schema: always
 authorUrl: http://localhost:8880

+ 1 - 1
src/main/resources/mapper/ImportTaskMapper.xml

@@ -4,7 +4,7 @@
     <select id="getImportTask" resultType="cn.cslg.pas.common.vo.business.ImportTaskVO">
         select it.name as name, it.id,it.search_condition as searchCondition,it.all_num as allNum,
                it.default_num as defaultNum,it.type as type,it.create_id as
-        createId,it.create_time as createTime ,it.state as  state,it.done_num as doneNum ,itc.file_guid as fileGuid,itc.project_type as projectType ,itc.project_id as projectId from import_task it left join import_task_condition itc on
+        createId,it.create_time as createTime ,it.state as  state,it.done_num as doneNum ,itc.file_guid as fileGuid,itc.project_type as projectType ,itc.project_id as projectId,itc.import_content as importContent from import_task it left join import_task_condition itc on
         it.import_task_condition_id=itc.id
         <if test="sql1!=''">
 

+ 2 - 2
src/main/resources/mapper/PatentProjectMapper.xml

@@ -4,7 +4,7 @@
     <select id="getPatentProject" resultType="cn.cslg.pas.common.vo.business.PatentProjectVO">
         select * from ( select p.id as id,p.name as name ,p.contract_no as contract_no,p.volume_number as
         volumeNumber,p.tenant_id as tenantId,p.commission_case_day as commissionCaseDay,p.description as description,p.create_id as
-        createId,p.create_time as createTime,pp.if_update as ifUpdate,pp.crons as crons,pp.status as status,
+        createId,p.create_time as createTime,pp.if_update as ifUpdate,pp.crons as crons,pp.status as status,pp.update_cycle as updateCycle,
         p.entrust_type as entrustType,p.entrust_id as entrustId,p.head_id as headId,p.department_id as departmentId,
         asps.scenario_id as scenarioId,aspe.event_id as eventId,aspt.tree_type as treeType,aspt.field_id as fieldId,
         aspm.matter_id as matterId from patent_project as pp
@@ -24,7 +24,7 @@
     <select id="getPatentProjectCount" resultType="java.lang.Long">
         select count(*) from (select p.id as id,p.name as name ,p.contract_no as contract_no,p.volume_number as
         volumeNumber,p.tenant_id as tenantId,p.commission_case_day as commissionCaseDay,p.description as description,p.create_id as
-        createId,p.create_time as createTime,pp.if_update as ifUpdate,pp.crons as crons,pp.status as status,
+        createId,p.create_time as createTime,pp.if_update as ifUpdate,pp.crons as crons,pp.status as status,pp.update_cycle as updateCycle,
         p.entrust_type as entrustType,p.entrust_id as entrustId,p.head_id as headId,p.department_id as departmentId,
         asps.scenario_id as scenarioId,aspe.event_id as eventId,aspt.tree_type as treeType,aspt.field_id as fieldId,
         aspm.matter_id as matterId from patent_project as pp left join project as p

+ 8 - 6
src/test/java/cn/cslg/pas/service/ClaimTextTests.java

@@ -14,6 +14,7 @@ import cn.cslg.pas.service.common.TranslateService;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
 import org.junit.jupiter.api.Test;
+import org.quartz.TriggerKey;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.boot.test.context.SpringBootTest;
 import org.thymeleaf.templateparser.text.TextTemplateParser;
@@ -90,11 +91,12 @@ public class ClaimTextTests {
 
     @Test
     public void testTranslate() {
-        try {
-            String a = translateService.getTranslateContent("where are you from");
-            System.out.println(a);
-        } catch (Exception e) {
-            e.printStackTrace();
-        }
+
+        TriggerKey oldTriggerKey1 = TriggerKey.triggerKey("111", "1");
+
+        TriggerKey oldTriggerKey = TriggerKey.triggerKey("Trigger_patent_project_469", "Default_patent_project");
+ System.out.println(oldTriggerKey);
+
+ System.out.println(oldTriggerKey1);
     }
 }

+ 10 - 30
src/test/java/cn/cslg/pas/service/EsServiceTests.java

@@ -9,6 +9,7 @@ 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.PatentService;
+import cn.cslg.pas.service.business.es.EsLegalEventService;
 import cn.cslg.pas.service.business.es.EsService;
 
 import cn.cslg.pas.service.importPatent.SchedulingTaskService;
@@ -37,8 +38,8 @@ public class EsServiceTests {
 
     @Autowired
     private EsService esService;
-
-
+ @Autowired
+ private EsLegalEventService esLegalEventService;
     @Test
     public void addPatent() throws Exception {
         Patent patent = new Patent();
@@ -63,27 +64,7 @@ public class EsServiceTests {
        esService.updatePatent(patent,"oYVFzowBmzIo81_4q-kr");
     }
 
-    @Test
-    public void search() throws Exception {
-        StringRequest stringRequest = new StringRequest();
-        stringRequest.setSearchQuery("patentNo=CN201199922Y and (simpleFamilyNum>1 or simpleFamilyNum=0)");
-        stringRequest.setCurrent(0L);
-        stringRequest.setSize(50L);
-        stringRequest.setProjectId(1);
-        PatentDTO patentDTO = esService.esSearch(stringRequest);
-        System.out.println(patentDTO);
-//        Object o = patentService.queryMessage(stringRequest);
-//        System.out.println(o);
-//        List<PatentDTO> list = esService.esSearch("patentNo=CN201199922Y and simpleFamilyNum>1 or simpleFamilyNum=0", 0, 50,null);
-//        List<Patent> list = esService.Search("titleTextContent=电子 or projectId=1", 0, 50,null);
-//        List<Patent> list = esService.Search("patentNo=CN201199922Y and simpleFamilyNum>1", 0, 50,null);
-//        List<Patent> list = esService.Search("publicDate=2009-03", 0, 50,null);
-//        List<Patent> list = esService.Search("simpleFamilyNum>1", 0, 50,null);
-//        List<Patent> list = esService.Search("titleTextContent=电子", 0, 50,null);
-//        List<Patent> list = esService.Search("projectId=1", 0, 50,null);
-//        List<Patent> list = esService.search("patentNo=CN201199922Y", 0, 50);
-//        System.out.println(list);
-    }
+
 
     @Test
     public void addQuotePatent() throws Exception {
@@ -126,18 +107,17 @@ public class EsServiceTests {
         List<String> nos = new ArrayList<>();
         nos.add("CN201920033236.3");
         nos.add("CN202010306989.4");
-        esService.addEsLegalEvent(new StarPatentVO());
         System.out.println("aa");
     }
 
     @Test
     public void addNet() throws Exception {
-        List<String> patents = new ArrayList<>();
-        patents.add("aa");
-        patents.add("vbb");
-        String aa = JSONObject.toJSON(patents).toString();
-        List<String> abv =JSONArray.parseArray(aa);
-        System.out.println(abv);
+        Patent patent =new Patent();
+        patent.setPatentNo("CN201680059185.0");
+        patent.setPublicNo("CN108135256A");
+        patent.setAppNo("CN201680059185.0");
+        patent.setGrantNo("CN108135256B");
+        esLegalEventService.addEsLegalEvent(patent,"202410929065");
 
     }
 

Failā izmaiņas netiks attēlotas, jo tās ir par lielu
+ 430 - 0
src/test/java/cn/cslg/pas/service/WebVoTransformServiceTests.java