Kaynağa Gözat

Merge remote-tracking branch 'origin/master'

xiexiang 1 yıl önce
ebeveyn
işleme
24282d695c
55 değiştirilmiş dosya ile 1543 ekleme ve 244 silme
  1. 4 4
      src/main/java/cn/cslg/pas/common/config/WebSocketConfig.java
  2. 8 6
      src/main/java/cn/cslg/pas/common/core/base/RedisConf.java
  3. 1 0
      src/main/java/cn/cslg/pas/common/dto/AddSelfFieldDTO.java
  4. 1 0
      src/main/java/cn/cslg/pas/common/dto/ImportTaskDTO.java
  5. 2 2
      src/main/java/cn/cslg/pas/common/dto/RetrieveRecordQueryDTO.java
  6. 1 0
      src/main/java/cn/cslg/pas/common/dto/business/QueryTreeNodeDTO.java
  7. 28 0
      src/main/java/cn/cslg/pas/common/dto/es/EsValueCurveDTO.java
  8. 28 0
      src/main/java/cn/cslg/pas/common/dto/es/SelectValueCurveDTO.java
  9. 6 0
      src/main/java/cn/cslg/pas/common/model/request/QueryRequest.java
  10. 22 3
      src/main/java/cn/cslg/pas/common/utils/PatentRightUtils.java
  11. 1 0
      src/main/java/cn/cslg/pas/common/vo/PatentRightParams.java
  12. 3 1
      src/main/java/cn/cslg/pas/common/vo/ProductOrCategoryVO.java
  13. 2 0
      src/main/java/cn/cslg/pas/common/vo/ReTreeNodeVO.java
  14. 4 0
      src/main/java/cn/cslg/pas/common/vo/business/ProductVO.java
  15. 12 0
      src/main/java/cn/cslg/pas/common/vo/business/SelectProductVO.java
  16. 3 0
      src/main/java/cn/cslg/pas/common/vo/business/TreeNodeVO.java
  17. 34 0
      src/main/java/cn/cslg/pas/common/vo/es/EsValueCurveVO.java
  18. 2 2
      src/main/java/cn/cslg/pas/controller/FeatureController.java
  19. 26 6
      src/main/java/cn/cslg/pas/controller/PatentController.java
  20. 19 1
      src/main/java/cn/cslg/pas/controller/ProjectShareController.java
  21. 6 6
      src/main/java/cn/cslg/pas/controller/ReportProjectController.java
  22. 67 0
      src/main/java/cn/cslg/pas/controller/RetrieveRecordController.java
  23. 1 1
      src/main/java/cn/cslg/pas/factorys/EsBuilderFactory/ProductQueryBuilder.java
  24. 9 0
      src/main/java/cn/cslg/pas/mapper/PermissionRecordMapper.java
  25. 7 0
      src/main/java/cn/cslg/pas/mapper/ProductMarketDataMapper.java
  26. 1 2
      src/main/java/cn/cslg/pas/service/PatentLabelService.java
  27. 38 2
      src/main/java/cn/cslg/pas/service/business/FeatureService.java
  28. 1 0
      src/main/java/cn/cslg/pas/service/business/ImportTaskService.java
  29. 2 2
      src/main/java/cn/cslg/pas/service/business/InvalidStatutesService.java
  30. 11 3
      src/main/java/cn/cslg/pas/service/business/PatentProjectService.java
  31. 1 1
      src/main/java/cn/cslg/pas/service/business/ProductCategoryService.java
  32. 93 33
      src/main/java/cn/cslg/pas/service/business/ProductService.java
  33. 54 1
      src/main/java/cn/cslg/pas/service/business/ProjectService.java
  34. 35 6
      src/main/java/cn/cslg/pas/service/business/TreeNodeService.java
  35. 3 1
      src/main/java/cn/cslg/pas/service/business/es/EsCustomFieldService.java
  36. 72 0
      src/main/java/cn/cslg/pas/service/business/es/EsMergePersonService.java
  37. 88 5
      src/main/java/cn/cslg/pas/service/business/es/EsPatentService.java
  38. 93 14
      src/main/java/cn/cslg/pas/service/business/es/EsProductPatentService.java
  39. 2 0
      src/main/java/cn/cslg/pas/service/business/es/EsScratchWordsService.java
  40. 32 6
      src/main/java/cn/cslg/pas/service/business/es/EsService.java
  41. 429 0
      src/main/java/cn/cslg/pas/service/business/es/EsValueCurveService.java
  42. 23 18
      src/main/java/cn/cslg/pas/service/business/stabilityReport/CompareRecordService.java
  43. 40 5
      src/main/java/cn/cslg/pas/service/common/PatentStarApiService.java
  44. 45 61
      src/main/java/cn/cslg/pas/service/common/PersonFieldService.java
  45. 38 32
      src/main/java/cn/cslg/pas/service/common/RetrieveRecordService.java
  46. 1 1
      src/main/java/cn/cslg/pas/service/importPatent/GetCataloguingFromWebThread.java
  47. 2 2
      src/main/java/cn/cslg/pas/service/importPatent/GetRightAndFullTextFromWebThread.java
  48. 12 1
      src/main/java/cn/cslg/pas/service/importPatent/SavePatentToEsThread.java
  49. 0 1
      src/main/java/cn/cslg/pas/service/importPatent/SchedulingTaskService.java
  50. 14 0
      src/main/resources/jsons/importTask.json
  51. 28 0
      src/main/resources/mapper/PermissionRecordMapper.xml
  52. 49 0
      src/main/resources/mapper/ProductMarketDataMapper.xml
  53. 6 9
      src/test/java/cn/cslg/pas/service/CommonServiceTests.java
  54. 15 0
      src/test/java/cn/cslg/pas/service/EsPatentServiceTests.java
  55. 18 6
      src/test/java/cn/cslg/pas/service/EventServiceTests.java

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

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

+ 8 - 6
src/main/java/cn/cslg/pas/common/core/base/RedisConf.java

@@ -17,10 +17,12 @@ public class RedisConf {
     public final static String USER_FIELD = "user-field";
     public final static String FIELD_ORDER = "field-order";
     public final static String USER_IMPORT = "user-import";
-    public final static String PROJECT_FIELD_ORDER="project_field_order";
-    public final static String TASK_FIELD_ORDER="task_field_order";
-    public final static  String PATENT_COUNT="patent-count";
-    public final static String TASK_FIELD_COUNT="task_field_count";
-    public final static String PROJECT_FIELD_COUNT="project_field_count";
-    public final static String FIELD_COUNT="field_count";
+    public final static String PROJECT_FIELD_ORDER = "project_field_order";
+    public final static String TASK_FIELD_ORDER = "task_field_order";
+    public final static String PATENT_COUNT = "patent-count";
+    public final static String TASK_FIELD_COUNT = "task_field_count";
+    public final static String PROJECT_FIELD_COUNT = "project_field_count";
+    public final static String FIELD_COUNT = "field_count";
+    public final static String PROJECT = "project";
+    public final static String PRODUCT = "product";
 }

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

@@ -13,5 +13,6 @@ public class AddSelfFieldDTO {
     private String tableName;
     private List<PersonSelfFieldVO> value;
     private Integer projectId;
+    private Integer productId;
 
 }

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

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

+ 2 - 2
src/main/java/cn/cslg/pas/common/dto/RetrieveRecordQueryDTO.java

@@ -7,12 +7,12 @@ public class RetrieveRecordQueryDTO {
     /**
      * 每页条数
      */
-    private Integer size;
+    private Long size;
 
     /**
      * 当前页数
      */
-    private Integer current;
+    private Long current;
 
     /**
      * 数据总数

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

@@ -25,5 +25,6 @@ public class QueryTreeNodeDTO {
      * 节点名称
      */
     private String name;
+    private Integer projectId;
 
 }

+ 28 - 0
src/main/java/cn/cslg/pas/common/dto/es/EsValueCurveDTO.java

@@ -0,0 +1,28 @@
+package cn.cslg.pas.common.dto.es;
+
+import lombok.Data;
+
+import java.util.Date;
+
+@Data
+public class EsValueCurveDTO {
+
+    //0月  1季  2年
+    private Integer timeType;
+
+    //营销时间
+    private String time;
+
+    //营销地区
+    private String saleArea;
+
+    //销售额(万元)
+    private Double saleMoney;
+
+    //自定义许可费
+    private Double customLicense;
+
+    //许可费用(万元)
+    private Double licenseFee;
+
+}

+ 28 - 0
src/main/java/cn/cslg/pas/common/dto/es/SelectValueCurveDTO.java

@@ -0,0 +1,28 @@
+package cn.cslg.pas.common.dto.es;
+
+import lombok.Data;
+
+@Data
+public class SelectValueCurveDTO {
+
+    //0月  1季  2年
+    private Integer timeType;
+
+    //营销时间
+    private String saleTime;
+
+    //营销地区
+    private String saleArea;
+
+    //销售额(万元)
+    private Double saleMoney;
+
+    //自定义许可费
+    private Double customLicense;
+
+    //许可费用(万元)
+    private Double licenseFee;
+
+    //许可时间
+    private String licenseTime;
+}

+ 6 - 0
src/main/java/cn/cslg/pas/common/model/request/QueryRequest.java

@@ -20,4 +20,10 @@ public class QueryRequest {
     private List<EsCustomFieldValueDTO> customFields;
     private Integer taskId;
     private List<String> patentNos;
+    //商品化专利
+    private Integer productId;
+    //商品化专利标识
+    private String from;
+    //专利详情中商品化专用ids
+    private List<Integer> productIds;
 }

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

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

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

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

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

@@ -3,6 +3,8 @@ package cn.cslg.pas.common.vo;
 import lombok.Data;
 import lombok.experimental.Accessors;
 
+import java.util.List;
+
 /**
  * @author 李仁杰
  * @date 2023-11-12
@@ -29,6 +31,6 @@ public class ProductOrCategoryVO {
      * Back:数据权限描述
      */
     private Integer type;
-
+    private List<Integer> valueIds;
 
 }

+ 2 - 0
src/main/java/cn/cslg/pas/common/vo/ReTreeNodeVO.java

@@ -46,4 +46,6 @@ public class ReTreeNodeVO {
     private String description;
     @Schema(description = "文件信息")
     private List<SystemFile> systemFileList;
+    @Schema(description = "专利相关数量")
+    private Long relevantProductNum;
 }

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

@@ -56,4 +56,8 @@ public class ProductVO {
     private String companyName;
     @Schema(description = "文件信息")
     private List<SystemFile> systemFileList;
+    @Schema(description = "商品化专利数量")
+    private Long productNum;
+    @Schema(description = "商品化专利相关数量")
+    private Long relevantProductNum;
 }

+ 12 - 0
src/main/java/cn/cslg/pas/common/vo/business/SelectProductVO.java

@@ -0,0 +1,12 @@
+package cn.cslg.pas.common.vo.business;
+
+import cn.cslg.pas.common.model.request.StringRequest;
+import lombok.Data;
+
+@Data
+public class SelectProductVO {
+
+    private String patentNo;
+
+    private StringRequest queryRequest;
+}

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

@@ -57,4 +57,7 @@ public class TreeNodeVO {
 
     @Schema(description = "文件信息")
     private List<SystemFile> systemFileList;
+
+    @Schema(description = "商品化专利相关数量")
+    private Long relevantProductNum;
 }

+ 34 - 0
src/main/java/cn/cslg/pas/common/vo/es/EsValueCurveVO.java

@@ -0,0 +1,34 @@
+package cn.cslg.pas.common.vo.es;
+
+import cn.cslg.pas.common.dto.es.EsCustomFieldValueDTO;
+import cn.cslg.pas.common.model.request.OrderDTO;
+import lombok.Data;
+
+import java.util.List;
+
+@Data
+public class EsValueCurveVO {
+
+    private Integer projectId;
+
+    private Integer taskId;
+
+    private List<String> isAdd;
+
+    private List<String> isDelete;
+
+    private Integer startNumber;
+
+    private Integer endNumber;
+
+    private String searchQuery;
+
+    private List<OrderDTO> orderDTOList;
+
+    private List<EsCustomFieldValueDTO> customFields;
+
+    //0月  1季  2年
+    private Integer timeType;
+    //地区
+    private String area;
+}

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

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

+ 26 - 6
src/main/java/cn/cslg/pas/controller/PatentController.java

@@ -7,6 +7,7 @@ import cn.cslg.pas.common.dto.PatentExport.TaskParams;
 import cn.cslg.pas.common.dto.business.EsCountDTO;
 import cn.cslg.pas.common.dto.business.SelectClaimDTO;
 import cn.cslg.pas.common.dto.es.EsDateRangeDTO;
+import cn.cslg.pas.common.dto.es.EsValueCurveDTO;
 import cn.cslg.pas.common.model.cronModel.PersonnelVO;
 import cn.cslg.pas.common.model.cronModel.Records;
 import cn.cslg.pas.common.model.request.StringRequest;
@@ -21,7 +22,9 @@ import cn.cslg.pas.common.vo.business.PatentNoVO;
 import cn.cslg.pas.common.vo.es.EsCustomFieldBatchVO;
 import cn.cslg.pas.common.vo.es.EsDateRangeVO;
 import cn.cslg.pas.common.vo.es.EsProductPatentVO;
+import cn.cslg.pas.common.vo.es.EsValueCurveVO;
 import cn.cslg.pas.domain.business.ImportTask;
+import cn.cslg.pas.domain.business.Product;
 import cn.cslg.pas.exception.XiaoShiException;
 import cn.cslg.pas.factorys.businessFactory.Business;
 import cn.cslg.pas.factorys.businessFactory.BusinessFactory;
@@ -30,10 +33,7 @@ import cn.cslg.pas.service.business.ImportTaskService;
 import cn.cslg.pas.service.business.PDFExportFirstPageService;
 import cn.cslg.pas.service.business.PatentExportService;
 import cn.cslg.pas.service.business.MergePersonService;
-import cn.cslg.pas.service.business.es.EsCountService;
-import cn.cslg.pas.service.business.es.EsPatentService;
-import cn.cslg.pas.service.business.es.EsProductPatentService;
-import cn.cslg.pas.service.business.es.EsService;
+import cn.cslg.pas.service.business.es.*;
 import cn.cslg.pas.service.common.FileManagerService;
 import cn.cslg.pas.service.common.PatentStarApiService;
 import cn.hutool.core.util.IdUtil;
@@ -76,6 +76,9 @@ public class PatentController {
     private EsProductPatentService esProductPatentService;
 
     @Autowired
+    private EsValueCurveService esValueCurveService;
+
+    @Autowired
     private PatentStarApiService patentStarApiService;
 
     @Autowired
@@ -301,17 +304,34 @@ public class PatentController {
     }
 
     //---------------------------------商品化专利----------------
+    @Operation(summary = "根据专利号查询商品化专利")
+    @PostMapping("/selectProductByPatentNo")
+    public Response selectProductByPatentNo(@RequestBody SelectProductVO vo) throws Exception {
+        Records records = (Records) patentService.selectProductByPatentNo(vo);
+        return Response.success(records);
+    }
+
     @Operation(summary = "添加商品化专利")
     @PostMapping("/addProductPatent")
-    public Response addProductPatent(EsProductPatentVO vo) throws Exception {
+    public Response addProductPatent(@RequestBody EsProductPatentVO vo) throws Exception {
         List<Integer> ids = esProductPatentService.addProductPatent(vo);
         return Response.success(ids);
     }
 
     @Operation(summary = "删除商品化专利")
     @PostMapping("/delProductPatent")
-    public Response delProductPatent(EsProductPatentVO vo) throws Exception {
+    public Response delProductPatent(@RequestBody EsProductPatentVO vo) throws Exception {
         List<Integer> ids = esProductPatentService.delProductPatent(vo);
         return Response.success(ids);
     }
+
+    //---------------------------价值曲线---------------------
+    @PostMapping("/selectValueCurve")
+    @Operation(summary = "查询价值曲线")
+    public Response selectValueCurve(@RequestBody EsValueCurveVO vo) throws Exception {
+        List<EsValueCurveDTO> list = esValueCurveService.selectValueCurve(vo);
+        Records records = new Records();
+        records.setData(list);
+        return Response.success(records);
+    }
 }

+ 19 - 1
src/main/java/cn/cslg/pas/controller/ProjectShareController.java

@@ -14,6 +14,7 @@ import cn.cslg.pas.exception.XiaoShiException;
 import cn.cslg.pas.service.business.AssoProjectPersonService;
 import cn.cslg.pas.service.business.AvoidDesignService;
 import cn.cslg.pas.service.business.AvoidDesignWholeService;
+import cn.cslg.pas.service.business.ProjectService;
 import io.swagger.v3.oas.annotations.Operation;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -24,6 +25,7 @@ import org.springframework.web.bind.annotation.RestController;
 
 import java.util.ArrayList;
 import java.util.List;
+import java.util.Map;
 
 /**
  * 项目分享管理
@@ -37,7 +39,8 @@ import java.util.List;
 public class ProjectShareController {
     @Autowired
     private AssoProjectPersonService assoProjectPersonService;
-
+@Autowired
+private ProjectService projectService;
 
     @Operation(summary = "新增项目分享")
     @PostMapping("/addProjectShare")
@@ -86,4 +89,19 @@ public class ProjectShareController {
 
         return Response.success(records);
     }
+
+    @Operation(summary = "查询人员在项目里的角色")
+    @PostMapping("/getProjectPermissions")
+    public Response getProjectPermissions(@RequestBody List<Integer> projectIds) throws Exception {
+        Records records = new Records();
+        try {
+            Map<Integer,List<String>> map= projectService.getProjectPermissions(projectIds);
+        records.setData(map);
+        } catch (Exception e) {
+            return Response.error(e.getMessage());
+
+        }
+
+        return Response.success(records);
+    }
 }

+ 6 - 6
src/main/java/cn/cslg/pas/controller/ReportProjectController.java

@@ -44,7 +44,7 @@ public class ReportProjectController {
 
     @Operation(summary = "查询报告")
     @PostMapping("/queryReportProject")
-    @checkAuth(FunId = "xiaoshi/report")
+//    @checkAuth(FunId = "xiaoshi/report")
     public Response queryPatentProject(@RequestBody StringRequest stringRequest) throws Exception {
         Business business = businessFactory.getClass("reportProjectService");
         Records records = (Records) business.queryMessage(stringRequest);
@@ -54,7 +54,7 @@ public class ReportProjectController {
 
     @Operation(summary = "添加报告")
     @PostMapping("/addReportProject")
-    @checkAuth(FunId = "xiaoshi/report")
+//    @checkAuth(FunId = "xiaoshi/report")
     public Response addReportProject(@RequestBody ReportProjectDTO reportProjectDTO) throws Exception {
         if (reportProjectDTO != null) {
             Business business = businessFactory.getClass("reportProjectService");
@@ -78,7 +78,7 @@ public class ReportProjectController {
 
     @Operation(summary = "更新报告")
     @PostMapping("/updateReportProject")
-    @checkAuth(FunId = "xiaoshi/report")
+//    @checkAuth(FunId = "xiaoshi/report")
     public Response updatePatentProject(@RequestBody UpdateReportProjectDTO updateReportProjectDTO) throws Exception {
         if (updateReportProjectDTO != null) {
             Business business = businessFactory.getClass("reportProjectService");
@@ -91,7 +91,7 @@ public class ReportProjectController {
 
     @Operation(summary = "删除报告")
     @PostMapping("/deleteReportProject")
-    @checkAuth(FunId = "xiaoshi/report")
+//    @checkAuth(FunId = "xiaoshi/report")
     public String deletePatentProject(@RequestBody List<Integer> ids) throws Exception {
         Business business = businessFactory.getClass("reportProjectService");
         business.deleteMessage(ids);
@@ -100,7 +100,7 @@ public class ReportProjectController {
 
     @Operation(summary = "分组报告")
     @PostMapping("/groupReportProject")
-    @checkAuth(FunId = "xiaoshi/report")
+//    @checkAuth(FunId = "xiaoshi/report")
     public Response groupPatentProject(@RequestBody StringGroupRequest stringGroupRequest) throws Exception {
         Business business = businessFactory.getClass("reportProjectService");
         Records records = (Records) business.getGroup(stringGroupRequest, "reportProject");
@@ -110,7 +110,7 @@ public class ReportProjectController {
 
     @Operation(summary = "更新是否第二次无效")
     @PostMapping("/updateIfSecondInvalid")
-    @checkAuth(FunId = "xiaoshi/report")
+//    @checkAuth(FunId = "xiaoshi/report")
     public Response updateIfSecondInvalid(@RequestBody UpdateIfSecondInvalidDTO updateIfSecondInvalidDTO) throws Exception {
         try {
             reportProjectService.updateIfSecondInvalid(updateIfSecondInvalidDTO);

+ 67 - 0
src/main/java/cn/cslg/pas/controller/RetrieveRecordController.java

@@ -0,0 +1,67 @@
+package cn.cslg.pas.controller;
+
+/**
+ * 检索历史的控制层
+ * @Author xiexiang
+ * @Date 2023/7/10
+ */
+
+import cn.cslg.pas.common.core.base.Constants;
+import cn.cslg.pas.common.dto.RetrieveRecordDTO;
+import cn.cslg.pas.common.dto.RetrieveRecordDeDTO;
+import cn.cslg.pas.common.dto.RetrieveRecordQueryDTO;
+import cn.cslg.pas.common.model.cronModel.Records;
+import cn.cslg.pas.common.utils.Response;
+
+import cn.cslg.pas.service.common.RetrieveRecordService;
+import io.swagger.v3.oas.annotations.Operation;
+import io.swagger.v3.oas.annotations.tags.Tag;
+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;
+
+import java.util.List;
+
+@Tag(name = "无效理由和证据管理")
+@Slf4j
+@RequiredArgsConstructor
+@RestController
+@RequestMapping(Constants.API_XiaoSHI + "/retrieveRecord")
+public class RetrieveRecordController {
+    private final RetrieveRecordService retrieveRecordService;
+
+    @Operation(summary = "添加检索历史")
+    @PostMapping("/addRetrieveRecord")
+    public Response addRetrieveRecord(@RequestBody RetrieveRecordDTO retrieveRecordDTO){
+      Integer id=  retrieveRecordService.addRetrieveRecord(retrieveRecordDTO);
+        Records records =new Records();
+        records.setData(id);
+        return Response.success(records);
+    }
+
+    @Operation(summary = "修改检索历史")
+    @PostMapping("/updateRetrieveRecord")
+    public String updateRetrieveRecord(@RequestBody RetrieveRecordDTO retrieveRecordDTO){
+        retrieveRecordService.updateRetrieveRecord(retrieveRecordDTO);
+        return Response.success();
+    }
+
+    @Operation(summary = "查询检索历史")
+    @PostMapping("/queryRetrieveRecord")
+    public Response queryRetrieveRecord(@RequestBody RetrieveRecordQueryDTO retrieveRecordQueryDTO){
+       Records records =retrieveRecordService.queryRetrieveRecord(retrieveRecordQueryDTO);
+        return Response.success(records);
+    }
+
+    @Operation(summary = "删除检索历史")
+    @PostMapping("/deleteRetrieveRecord")
+    public Response deleteRetrieveRecord(@RequestBody RetrieveRecordDeDTO retrieveRecordDeDTO){
+      List<Integer> ids=  retrieveRecordService.deleteRetrieveRecord(retrieveRecordDeDTO);
+      Records records =new Records();
+      records.setData(ids);
+        return Response.success(records);
+    }
+}

+ 1 - 1
src/main/java/cn/cslg/pas/factorys/EsBuilderFactory/ProductQueryBuilder.java

@@ -15,7 +15,7 @@ public class ProductQueryBuilder implements IQueryBuilder {
 
     @Override
     public Query creteQuery() throws ParseException {
-        return QueryBuilders.hasChild(child -> child.type("product").query(i -> i.match(j -> j.field(field).query(value))));
+        return QueryBuilders.hasChild(child -> child.type("product").query(i -> i.term(j -> j.field(field).value(value))));
     }
 
     @Override

+ 9 - 0
src/main/java/cn/cslg/pas/mapper/PermissionRecordMapper.java

@@ -1,13 +1,22 @@
 package cn.cslg.pas.mapper;
 
+import cn.cslg.pas.common.dto.es.SelectValueCurveDTO;
 import cn.cslg.pas.domain.business.PermissionRecord;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import org.springframework.stereotype.Repository;
 
+import java.util.List;
+
 /**
  * @Author xiexiang
  * @Date 2024/1/16
  */
 @Repository
 public interface PermissionRecordMapper extends BaseMapper<PermissionRecord> {
+
+    public List<SelectValueCurveDTO> selectLicenseeMonthList(String patentNo);
+
+    public List<SelectValueCurveDTO> selectLicenseeYearList(String patentNo);
+
+    public List<SelectValueCurveDTO> selectLicenseeQuarterList(String patentNo);
 }

+ 7 - 0
src/main/java/cn/cslg/pas/mapper/ProductMarketDataMapper.java

@@ -1,5 +1,6 @@
 package cn.cslg.pas.mapper;
 
+import cn.cslg.pas.common.dto.es.SelectValueCurveDTO;
 import cn.cslg.pas.common.vo.GroupMarketDataVO;
 import cn.cslg.pas.common.vo.business.ProductMarketDataVO;
 import cn.cslg.pas.domain.business.ProductMarketData;
@@ -19,4 +20,10 @@ public interface ProductMarketDataMapper extends BaseMapper<ProductMarketData> {
     public Long getProductMarketDataCount(String sql);
     public List<GroupMarketDataVO> getGroups(List<String> sqls, String tableName, String groupField, String selectField);
     public List<GroupMarketDataVO> getPartGroups(List<String> sqls, String tableName, String groupField, String selectField);
+
+    public List<SelectValueCurveDTO> selectSaleMonthList(List<Integer> productIds);
+
+    public List<SelectValueCurveDTO> selectSaleYearList(List<Integer> productIds);
+
+    public List<SelectValueCurveDTO> selectSaleQuarterList(List<Integer> productIds);
 }

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

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

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

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

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

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

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

@@ -82,7 +82,7 @@ public class InvalidStatutesService extends ServiceImpl<InvalidStatutesMapper, I
                     //涉及内容为说明书或者附图
                     InvalidStatutes invalidStatutes = new InvalidStatutes();
                     BeanUtils.copyProperties(invalidStatutesDTO, invalidStatutes);
-                    if (invalidStatutesDTO.getRelatedContent().equals(2)) {
+
                         PersonnelVO personnelVO = cacheUtils.getLoginUser(loginUtils.getId());
                         PatentClaim patentClaim = new PatentClaim();
                         patentClaim.setCreateId(personnelVO.getId());
@@ -90,7 +90,7 @@ public class InvalidStatutesService extends ServiceImpl<InvalidStatutesMapper, I
                         patentClaim.setProjectId(projectId);
                         patentClaim.insert();
                         invalidStatutes.setClaimId(patentClaim.getId());
-                    }
+
 
                     invalidStatutes.insert();
                     Integer id = invalidStatutes.getId();

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

@@ -37,6 +37,7 @@ import org.springframework.web.multipart.MultipartFile;
 
 import java.io.IOException;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.List;
 import java.util.stream.Collectors;
 
@@ -377,6 +378,9 @@ public class PatentProjectService extends ServiceImpl<PatentProjectMapper, Paten
             //遍历传入的树
             for (ProjectTreesDTO projectTreesDTO : trees) {
                 List<Integer> valueIds = projectTreesDTO.getValueIds();
+                if(valueIds==null||valueIds.size()==0){
+                    valueIds = Arrays.asList(0);
+                }
                 //遍历值id集合
                 for (Integer valueId : valueIds) {
                     AssoProjectTreeNode assoProjectTreeNode = new AssoProjectTreeNode();
@@ -547,6 +551,9 @@ public class PatentProjectService extends ServiceImpl<PatentProjectMapper, Paten
             //遍历传入的树
             for (ProjectTreesDTO projectTreesDTO : trees) {
                 List<Integer> valueIds = projectTreesDTO.getValueIds();
+                if(valueIds==null||valueIds.size()==0){
+                    valueIds = Arrays.asList(0);
+                }
                 //遍历值id集合
                 for (Integer valueId : valueIds) {
                     AssoProjectTreeNode assoProjectTreeNode = new AssoProjectTreeNode();
@@ -845,10 +852,12 @@ public class PatentProjectService extends ServiceImpl<PatentProjectMapper, Paten
                 AssoProjectTreeNode assoProjectTreeNode = assoProjectTreeNodes.stream().filter(item -> item.getProjectId().equals(patentProjectVO.getId()) && (item.getTreeType().equals(2) || item.getTreeType().equals(3))).
                         findFirst().orElse(null);
                 if (assoProjectTreeNode != null) {
+                    ProductOrCategoryVO productOrCategoryVO = new ProductOrCategoryVO();
+                    productOrCategoryVO.setValueIds(Arrays.asList(assoProjectTreeNode.getValueId()));
                     if (assoProjectTreeNode.getTreeType().equals(2)) {
                         Product product = products.stream().filter(item -> item.getId().equals(assoProjectTreeNode.getFieldId())).findFirst().orElse(null);
                         if (product != null) {
-                            ProductOrCategoryVO productOrCategoryVO = new ProductOrCategoryVO();
+
                             productOrCategoryVO.setName(product.getName());
                             productOrCategoryVO.setId(product.getId());
                             productOrCategoryVO.setType(2);
@@ -857,7 +866,6 @@ public class PatentProjectService extends ServiceImpl<PatentProjectMapper, Paten
                     } else if (assoProjectTreeNode.getTreeType().equals(3)) {
                         ProductCategory productCategory = productCategories.stream().filter(item -> item.getId().equals(assoProjectTreeNode.getFieldId())).findFirst().orElse(null);
                         if (productCategory != null) {
-                            ProductOrCategoryVO productOrCategoryVO = new ProductOrCategoryVO();
                             productOrCategoryVO.setName(productCategory.getName());
                             productOrCategoryVO.setId(productCategory.getId());
                             productOrCategoryVO.setType(3);
@@ -876,7 +884,7 @@ public class PatentProjectService extends ServiceImpl<PatentProjectMapper, Paten
         String rootSql ="(p.create_id ="+id+" or p.head_id="+id+" or p.id in (select project_id from asso_project_person where person_id ="+id+"))";
         if(sqls.get(0)!=null&&!sqls.get(0).equals(""))
         {
-            sqls.set(0,rootSql+" and"+"("+sqls.get(0)+")");
+            sqls.set(0,"("+rootSql+") and"+"("+sqls.get(0)+")");
 
         }
         else {

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

@@ -515,7 +515,7 @@ public class ProductCategoryService extends ServiceImpl<ProductCategoryMapper, P
                 " person_id="+id+" and role=2))";
         if(sqls.get(0)!=null&&!sqls.get(0).equals(""))
         {
-            sqls.set(0,rootSql+" and"+"("+sqls.get(0)+")");
+            sqls.set(0,"("+rootSql+") and"+"("+sqls.get(0)+")");
 
         }
         else {

+ 93 - 33
src/main/java/cn/cslg/pas/service/business/ProductService.java

@@ -7,6 +7,7 @@ import cn.cslg.pas.common.model.request.GroupRequest;
 import cn.cslg.pas.common.model.request.QueryRequest;
 import cn.cslg.pas.common.utils.CacheUtils;
 import cn.cslg.pas.common.utils.LoginUtils;
+import cn.cslg.pas.common.utils.StringUtils;
 import cn.cslg.pas.common.vo.business.PersonVO;
 import cn.cslg.pas.common.vo.business.ProductVO;
 import cn.cslg.pas.domain.business.*;
@@ -14,9 +15,11 @@ import cn.cslg.pas.exception.UnLoginException;
 import cn.cslg.pas.exception.XiaoShiException;
 import cn.cslg.pas.factorys.businessFactory.Business;
 import cn.cslg.pas.mapper.ProductMapper;
+import cn.cslg.pas.service.business.es.EsProductPatentService;
 import cn.cslg.pas.service.common.FileManagerService;
 import cn.cslg.pas.service.permissions.PermissionService;
 import cn.cslg.pas.service.query.FormatQueryService;
+import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@@ -24,8 +27,10 @@ import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.ObjectUtils;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Lazy;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
+import org.springframework.util.CollectionUtils;
 import org.springframework.web.multipart.MultipartFile;
 
 import java.io.IOException;
@@ -35,6 +40,7 @@ import java.util.stream.Collectors;
 
 /**
  * 产品的Service层
+ *
  * @Author xiexiang
  * @Date 2023/10/26
  */
@@ -66,11 +72,45 @@ public class ProductService extends ServiceImpl<ProductMapper, Product> implemen
     @Autowired
     private AssoProductPersonService assoProductPersonService;
 
+    @Autowired
+    @Lazy
+    private EsProductPatentService esProductPatentService;
+
     @Override
     @Transactional(rollbackFor = Exception.class)
     public Object queryMessage(QueryRequest queryRequest) throws Exception {
-        List<String> sqls = formatQueryService.reSqls(queryRequest,"product");
-       sqls= this.loadSearchSql(sqls);
+        List<String> sqls = formatQueryService.reSqls(queryRequest, "product");
+        sqls = this.loadSearchSql(sqls);
+        //根据sql查询产品信息
+        List<ProductVO> productVOS = productMapper.getProduct(sqls.get(0), sqls.get(1), sqls.get(2));
+        if (!CollectionUtils.isEmpty(productVOS)) {
+            for (ProductVO productVO : productVOS) {
+                Integer productId = productVO.getId();
+                Long productNum = esProductPatentService.selectProductNum(productId);
+                productVO.setProductNum(productNum);
+                Long relevantProductNum = esProductPatentService.selectRelevantProductNum(productId);
+                productVO.setRelevantProductNum(relevantProductNum);
+            }
+        }
+        //查询总数
+        Long total = productMapper.getProductCount(sqls.get(0));
+        //装载产品信息
+        this.loadProduct(productVOS);
+        //装载返回信息
+        Records records = new Records();
+        records.setCurrent(queryRequest.getCurrent());
+        records.setSize(queryRequest.getSize());
+        records.setData(productVOS);
+        records.setTotal(total);
+        return records;
+    }
+
+    @Transactional(rollbackFor = Exception.class)
+    public Object selectProduct(QueryRequest queryRequest) throws Exception {
+        List<String> sqls = formatQueryService.reSqls(queryRequest, "product");
+        sqls = this.loadSearchSql(sqls);
+        sqls = this.loadProductIdsSql(sqls, queryRequest.getProductIds());
+
         //根据sql查询产品信息
         List<ProductVO> productVOS = productMapper.getProduct(sqls.get(0), sqls.get(1), sqls.get(2));
         //查询总数
@@ -88,6 +128,7 @@ public class ProductService extends ServiceImpl<ProductMapper, Product> implemen
 
     /**
      * 新增产品
+     *
      * @param object
      * @param files
      * @return
@@ -140,10 +181,10 @@ public class ProductService extends ServiceImpl<ProductMapper, Product> implemen
         }
         //判断可见类型:
         Integer showType = productDTO.getShowType();
-        if(showType != 0 && showType != 1){
+        if (showType != 0 && showType != 1) {
             List<String> showPersonIds = productDTO.getShowPersonIds();
             //0所有人可见,1本人可见
-            if(showPersonIds != null && showPersonIds.size() != 0){
+            if (showPersonIds != null && showPersonIds.size() != 0) {
                 for (String showPersonId : showPersonIds) {
                     AssoProductPerson assoProductPerson = new AssoProductPerson();
                     assoProductPerson.setProductId(product.getId());
@@ -161,11 +202,11 @@ public class ProductService extends ServiceImpl<ProductMapper, Product> implemen
                 }
             }
         }
-        if(assoProductPeople != null && assoProductPeople.size() != 0){
+        if (assoProductPeople != null && assoProductPeople.size() != 0) {
             assoProductPersonService.saveBatch(assoProductPeople);
         }
         //判断文件是否为空
-        if(files != null && files.size() != 0) {
+        if (files != null && files.size() != 0) {
             try {
                 //调用上传文件接口
                 List<String> guids = fileManagerService.uploadFileGetGuid(files);
@@ -190,6 +231,7 @@ public class ProductService extends ServiceImpl<ProductMapper, Product> implemen
 
     /**
      * 删除产品
+     *
      * @param ids
      * @return
      */
@@ -218,6 +260,7 @@ public class ProductService extends ServiceImpl<ProductMapper, Product> implemen
 
     /**
      * 更新产品
+     *
      * @param object
      * @param files
      * @return
@@ -226,7 +269,7 @@ public class ProductService extends ServiceImpl<ProductMapper, Product> implemen
     public Object updateMessage(Object object, List<MultipartFile> files) {
         //object to updateProductDTO
         UpdateProductDTO updateProductDTO = (UpdateProductDTO) object;
-        if(updateProductDTO == null || updateProductDTO.getId() == null){
+        if (updateProductDTO == null || updateProductDTO.getId() == null) {
             throw new XiaoShiException("参数错误");
         }
         //获取登陆人信息 用于设置创建人
@@ -244,7 +287,7 @@ public class ProductService extends ServiceImpl<ProductMapper, Product> implemen
         LambdaQueryWrapper<Product> queryWrapper = new LambdaQueryWrapper<>();
         queryWrapper.eq(Product::getName, name);
         List<Product> products = this.list(queryWrapper);
-        if(!updateProductDTO.getName().equals(product.getName()) && products.size() != 0){
+        if (!updateProductDTO.getName().equals(product.getName()) && products.size() != 0) {
             throw new XiaoShiException("名称重复");
         }
         BeanUtils.copyProperties(updateProductDTO, product);
@@ -279,10 +322,10 @@ public class ProductService extends ServiceImpl<ProductMapper, Product> implemen
         }
         //判断可见类型:
         Integer showType = updateProductDTO.getShowType();
-        if(showType != 0 && showType != 1){
+        if (showType != 0 && showType != 1) {
             List<String> showPersonIds = updateProductDTO.getShowPersonIds();
             //0所有人可见,1本人可见
-            if(showPersonIds != null && showPersonIds.size() != 0){
+            if (showPersonIds != null && showPersonIds.size() != 0) {
                 for (String showPersonId : showPersonIds) {
                     AssoProductPerson assoProductPerson = new AssoProductPerson();
                     assoProductPerson.setProductId(product.getId());
@@ -300,7 +343,7 @@ public class ProductService extends ServiceImpl<ProductMapper, Product> implemen
                 }
             }
         }
-        if(assoProductPeople != null && assoProductPeople.size() != 0){
+        if (assoProductPeople != null && assoProductPeople.size() != 0) {
             assoProductPersonService.saveBatch(assoProductPeople);
         }
         /**
@@ -313,20 +356,20 @@ public class ProductService extends ServiceImpl<ProductMapper, Product> implemen
         List<String> fileGuIds = assoFiles.stream().map(AssoProductFile::getFileGuid).collect(Collectors.toList());
         //获取更新后的附件ids
         List<String> updateFileGuIds = new ArrayList<>();
-        if(updateProductDTO.getGuids() != null && updateProductDTO.getGuids().size() != 0){
+        if (updateProductDTO.getGuids() != null && updateProductDTO.getGuids().size() != 0) {
             updateFileGuIds = updateProductDTO.getGuids();
             fileGuIds.retainAll(updateFileGuIds);
         }
         //做差获得被删除的文件id
-        if(fileGuIds.size() != 0){
+        if (fileGuIds.size() != 0) {
             //根据文件id删除产品与文件关联表记录
             LambdaQueryWrapper<AssoProductFile> deleteWrapper = new LambdaQueryWrapper<>();
             deleteWrapper.in(AssoProductFile::getFileGuid, fileGuIds);
             assoProductFileService.remove(deleteWrapper);
             //远程删除服务器上的文件
-            try{
+            try {
                 fileManagerService.deleteFileFromFMS(fileGuIds);
-            } catch (Exception e){
+            } catch (Exception e) {
 
             }
         }
@@ -353,7 +396,7 @@ public class ProductService extends ServiceImpl<ProductMapper, Product> implemen
     }
 
     @Override
-    public GroupVO getGroup(GroupRequest groupRequest,String tableName) throws Exception {
+    public GroupVO getGroup(GroupRequest groupRequest, String tableName) throws Exception {
         return null;
     }
 
@@ -369,6 +412,7 @@ public class ProductService extends ServiceImpl<ProductMapper, Product> implemen
 
     /**
      * 装载productVO
+     *
      * @param productVOS
      * @throws IOException
      */
@@ -377,7 +421,7 @@ public class ProductService extends ServiceImpl<ProductMapper, Product> implemen
         List<Integer> ids = new ArrayList<>();
         productVOS.forEach(
                 item -> {
-                    if(item.getCreateId() != null){
+                    if (item.getCreateId() != null) {
                         createIds.add(item.getCreateId());
                     }
                     if (item.getId() != null) {
@@ -409,8 +453,8 @@ public class ProductService extends ServiceImpl<ProductMapper, Product> implemen
         if (guids.size() != 0) {
             String res = fileManagerService.getSystemFileFromFMS(guids);
             systemFiles = JSONObject.parseArray(res, SystemFile.class);
-            if(systemFiles==null){
-                systemFiles=new ArrayList<>();
+            if (systemFiles == null) {
+                systemFiles = new ArrayList<>();
             }
         }
 
@@ -418,7 +462,7 @@ public class ProductService extends ServiceImpl<ProductMapper, Product> implemen
         for (ProductVO productVO : productVOS) {
             //装载人员信息
             Personnel personnel = personnels.stream().filter(item -> item.getId().toString().equals(productVO.getCreateId())).findFirst().orElse(null);
-            if(personnel != null){
+            if (personnel != null) {
                 productVO.setCreateName(personnel.getPersonnelName());
             } else {
                 throw new XiaoShiException("未获取到当前登陆人信息");
@@ -497,23 +541,39 @@ public class ProductService extends ServiceImpl<ProductMapper, Product> implemen
 
     //装载查询语句
     //装载查询语句
-    private List<String> loadSearchSql(List<String> sqls){
-        PersonnelVO personnelVO =cacheUtils.getLoginUser(loginUtils.getId());
-        String id =personnelVO.getId();
-        Integer tenantId =personnelVO.getTenantId();
-        String rootSql ="product.create_id="+id+" or(product.show_type =0 and product.tenant_id ="+tenantId+") or ( product.id in (select product_id from asso_product_person where" +
-                " person_id="+id+" and role=0)) or (product.show_type=2 and  product.id in (select product_id from asso_product_person where" +
-                " person_id="+id+" and role=1)) or(product.show_type =3 and product.id not in(select product_id from asso_product_person where" +
-                " person_id="+id+" and role=2))";
-        if(sqls.get(0)!=null&&!sqls.get(0).equals(""))
-        {
-            sqls.set(0,rootSql+" and"+"("+sqls.get(0)+")");
+    private List<String> loadSearchSql(List<String> sqls) {
+        PersonnelVO personnelVO = cacheUtils.getLoginUser(loginUtils.getId());
+        String id = personnelVO.getId();
+        Integer tenantId = personnelVO.getTenantId();
+        String rootSql = "product.create_id=" + id + " or(product.show_type =0 and product.tenant_id =" + tenantId + ") or ( product.id in (select product_id from asso_product_person where" +
+                " person_id=" + id + " and role=0)) or (product.show_type=2 and  product.id in (select product_id from asso_product_person where" +
+                " person_id=" + id + " and role=1)) or(product.show_type =3 and product.id not in(select product_id from asso_product_person where" +
+                " person_id=" + id + " and role=2))";
+        if (sqls.get(0) != null && !sqls.get(0).equals("")) {
+            sqls.set(0, "(" + rootSql + ")" + " and " + "(" + sqls.get(0) + ")");
 
+        } else {
+            sqls.set(0, rootSql);
         }
-        else {
-            sqls.set(0,rootSql);
+
+        return sqls;
+
+    }
+
+    //装载查询产品语句
+    private List<String> loadProductIdsSql(List<String> sqls, List<Integer> ids) {
+        String rootSql = "";
+        if (CollectionUtils.isEmpty(ids)) {
+            rootSql = "product.id in " + "(" + 0 + ")";
+        } else {
+            rootSql = "product.id in " + "(" + String.join(",", ids.stream().map(Object::toString).collect(Collectors.toList())) + ")";
         }
 
+        if (sqls.get(0) != null && !sqls.get(0).equals("")) {
+            sqls.set(0, "(" + rootSql + ")" + " and " + "(" + sqls.get(0) + ")");
+        } else {
+            sqls.set(0, rootSql);
+        }
         return sqls;
 
     }

+ 54 - 1
src/main/java/cn/cslg/pas/service/business/ProjectService.java

@@ -1,14 +1,20 @@
 package cn.cslg.pas.service.business;
 
+import cn.cslg.pas.common.model.cronModel.PersonnelVO;
+import cn.cslg.pas.common.utils.CacheUtils;
+import cn.cslg.pas.common.utils.LoginUtils;
 import cn.cslg.pas.domain.business.AssoProductPerson;
+import cn.cslg.pas.domain.business.AssoProjectPerson;
 import cn.cslg.pas.domain.business.Project;
 import cn.cslg.pas.mapper.AssoProductPersonMapper;
 import cn.cslg.pas.mapper.ProjectMapper;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
-import java.util.Optional;
+import java.util.*;
+import java.util.stream.Collectors;
 
 /**
  * 项目业务层
@@ -20,8 +26,55 @@ public class ProjectService extends ServiceImpl<ProjectMapper, Project> {
     @Autowired
     private ProjectMapper projectMapper;
 
+    @Autowired
+    private CacheUtils cacheUtils;
+    @Autowired
+    private LoginUtils loginUtils;
+    @Autowired
+    private  AssoProjectPersonService assoProjectPersonService;
     public Optional<Project> getByIdOpt(Integer id) {
         Project project = projectMapper.selectById(id);
         return Optional.ofNullable(project);
     }
+
+    public Map<Integer,List<String>> getProjectPermissions(List<Integer> projectIds){
+        Map<Integer,List<String>> map =new HashMap<>();
+        if(projectIds==null||projectIds.size()==0){
+            return map;
+        }
+        projectIds.forEach(
+              item->{
+                  map.put(item,new ArrayList<>());
+              }
+        );
+        PersonnelVO personnelVO=cacheUtils.getLoginUser(loginUtils.getId());
+        String id =personnelVO.getId();
+        LambdaQueryWrapper<Project> queryWrapper =new LambdaQueryWrapper<>();
+        queryWrapper.select(Project::getId,Project::getCreateId,Project::getHeadId);
+        queryWrapper.in(Project::getId,projectIds);
+        List<Project> projects =this.list(queryWrapper);
+
+        projects.forEach(item->{
+            Integer projectId= item.getId();
+            String createId =item.getCreateId();
+            String headId =item.getHeadId();
+            List<String> roles =map.get(projectId);
+            if(id.equals(createId))
+            {roles.add("0");}
+            if(id.equals(headId)){
+                roles.add("1");
+            }
+        });
+        LambdaQueryWrapper<AssoProjectPerson> queryWrapper1 =new LambdaQueryWrapper<>();
+        queryWrapper1.in(AssoProjectPerson::getProjectId,projectIds);
+        queryWrapper1.eq(AssoProjectPerson::getPersonId,id);
+        List<AssoProjectPerson> assoProjectPersonList =assoProjectPersonService.list(queryWrapper1);
+        assoProjectPersonList.forEach(item->{
+            Integer projectId =item.getProjectId();
+            List<String> roles =map.get(projectId);
+            roles.add("2");
+        });
+
+return map;
+    }
 }

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

@@ -14,12 +14,14 @@ import cn.cslg.pas.common.vo.ReTreeNodeVO;
 import cn.cslg.pas.common.vo.business.ProductVO;
 import cn.cslg.pas.common.vo.business.TreeNodeVO;
 import cn.cslg.pas.common.vo.business.TreePathVO;
+import cn.cslg.pas.domain.business.AssoProjectTreeNode;
 import cn.cslg.pas.domain.business.AssoTreeNodeFile;
 import cn.cslg.pas.domain.business.TreeNode;
 import cn.cslg.pas.exception.UnLoginException;
 import cn.cslg.pas.exception.XiaoShiException;
 import cn.cslg.pas.factorys.businessFactory.Business;
 import cn.cslg.pas.mapper.TreeNodeMapper;
+import cn.cslg.pas.service.business.es.EsProductPatentService;
 import cn.cslg.pas.service.common.FileManagerService;
 import cn.cslg.pas.service.permissions.PermissionService;
 import cn.cslg.pas.service.query.FormatQueryService;
@@ -32,6 +34,7 @@ import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
+import org.springframework.util.CollectionUtils;
 import org.springframework.web.multipart.MultipartFile;
 
 import java.io.IOException;
@@ -71,6 +74,12 @@ public class TreeNodeService extends ServiceImpl<TreeNodeMapper, TreeNode> imple
     @Autowired
     private PermissionService permissionService;
 
+    @Autowired
+    private AssoProjectTreeNodeService assoProjectTreeNodeService;
+
+    @Autowired
+    private EsProductPatentService esProductPatentService;
+
     @Override
     public Object queryMessage(QueryRequest queryRequest) throws Exception {
         List<String> sqls = formatQueryService.reSqls(queryRequest, "treeNode");
@@ -102,17 +111,24 @@ public class TreeNodeService extends ServiceImpl<TreeNodeMapper, TreeNode> imple
     public Records queryMessage(QueryTreeNodeDTO queryTreeNodeDTO) throws Exception {
         //返回数据
         Records records = new Records();
-
         List<ReTreeNodeVO> reTreeNodeVOS = new ArrayList<>();
         Integer type = queryTreeNodeDTO.getType();
         Integer typeId = queryTreeNodeDTO.getTypeId();
-
+        Integer projectId = queryTreeNodeDTO.getProjectId();
         //校验格式
         if (type == null || typeId == null) {
             throw new XiaoShiException("参数错误");
         }
-
-        //
+        if (projectId != null) {
+            LambdaQueryWrapper<AssoProjectTreeNode> queryWrapper = new LambdaQueryWrapper<>();
+            queryWrapper.eq(AssoProjectTreeNode::getProjectId, projectId);
+            AssoProjectTreeNode assoProjectTreeNode = assoProjectTreeNodeService.getOne(queryWrapper, false);
+            if (assoProjectTreeNode != null) {
+                if (!assoProjectTreeNode.getValueId().equals(0)) {
+                    queryTreeNodeDTO.setId(assoProjectTreeNode.getValueId());
+                }
+            }
+        }
         List<TreeNodeVO> treeNodes = treeNodeMapper.getTreeNode(queryTreeNodeDTO);
 
         //如果根据名称查询
@@ -146,7 +162,6 @@ public class TreeNodeService extends ServiceImpl<TreeNodeMapper, TreeNode> imple
                 return records;
             }
         }
-
         //返回树
         this.loadTreeNode(treeNodes);
         reTreeNodeVOS = this.reTrees(treeNodes);
@@ -442,7 +457,7 @@ public class TreeNodeService extends ServiceImpl<TreeNodeMapper, TreeNode> imple
     }
 
 
-    private void loadTreeNode(List<TreeNodeVO> treeNodeVOS) throws IOException {
+    private void loadTreeNode(List<TreeNodeVO> treeNodeVOS) throws Exception {
         List<String> createIds = new ArrayList<>();
         List<Integer> ids = new ArrayList<>();
         treeNodeVOS.forEach(
@@ -456,6 +471,20 @@ public class TreeNodeService extends ServiceImpl<TreeNodeMapper, TreeNode> imple
                 }
         );
 
+        if (!CollectionUtils.isEmpty(treeNodeVOS)) {
+            for (TreeNodeVO nodeVO : treeNodeVOS) {
+                Integer type = nodeVO.getType();
+                if (type != null) {
+                    if (type == 1 || type == 2) {
+                        Long relevantProductNum = esProductPatentService.selectRelevantProductNum(nodeVO.getId());
+                        nodeVO.setRelevantProductNum(relevantProductNum);
+                    }
+                }
+            }
+        }
+
+
+
         List<Personnel> personnels = new ArrayList<>();
         List<String> guids = new ArrayList<>();
         List<SystemFile> systemFiles = new ArrayList<>();

+ 3 - 1
src/main/java/cn/cslg/pas/service/business/es/EsCustomFieldService.java

@@ -292,7 +292,6 @@ public class EsCustomFieldService {
                     String field = this.addCustomField(fieldDTO);
                     ids.add(field);
                 }
-
             }
         } else if (startNum >= 1 && endNum > 0) {
             List<String> patentNos = this.getPatentNos(vo);
@@ -786,6 +785,7 @@ public class EsCustomFieldService {
             case 0:
             case 1:
             case 2:
+            case 10:
                 value.forEach(item -> {
                     FieldValueVO fieldValueVO = new FieldValueVO();
                     fieldValueVO.setValue(item);
@@ -866,4 +866,6 @@ public class EsCustomFieldService {
 
         return patentWithIdVOS;
     }
+
+
 }

+ 72 - 0
src/main/java/cn/cslg/pas/service/business/es/EsMergePersonService.java

@@ -0,0 +1,72 @@
+package cn.cslg.pas.service.business.es;
+
+import cn.cslg.pas.domain.es.Patent;
+import cn.cslg.pas.domain.es.PatentJoin;
+import cn.cslg.pas.domain.es.PatentMergePerson;
+import cn.cslg.pas.domain.es.PatentPerson;
+import lombok.RequiredArgsConstructor;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Lazy;
+import org.springframework.stereotype.Service;
+
+import java.util.ArrayList;
+import java.util.List;
+
+@Service
+public class EsMergePersonService {
+    @Autowired
+    private EsService esService;
+
+    public void addDefaultMergePerson(Patent patent, String patentId, Integer projectId) {
+        List<PatentPerson> applicant = patent.getApplicant();
+        List<PatentPerson> rightHolder = patent.getRightHolder();
+        List<PatentPerson> inventor = patent.getInventor();
+        if (applicant != null && applicant.size() != 0) {
+           this.addMergePersonToEs(applicant,patentId,projectId,"merge_applicat");
+        }
+        if (rightHolder != null && rightHolder.size() != 0) {
+            this.addMergePersonToEs(rightHolder,patentId,projectId,"merge_right_holder");
+        }
+        if (inventor != null && inventor.size() != 0) {
+            this.addMergePersonToEs(inventor,patentId,projectId,"merge_inventor");
+        }
+    }
+
+    public void addMergePersonToEs(List<PatentPerson> personList, String patentId, Integer projectId, String mergeType) {
+        if (personList != null && personList.size() != 0) {
+            List<PatentMergePerson> patentMergePersons = new ArrayList<>();
+            personList.forEach(item -> {
+                PatentMergePerson patentMergePerson = new PatentMergePerson();
+                patentMergePerson.setName(item.getName());
+                patentMergePerson.setOrder(item.getOrder());
+                patentMergePerson.setProjectId(projectId.toString());
+                patentMergePerson.setType(item.getType());
+                patentMergePersons.add(patentMergePerson);
+            });
+            Patent patent = new Patent();
+            if (patentMergePersons.size() != 0) {
+                switch (mergeType) {
+                    case "merge_applicat":
+                        patent.setMergeApplicant(patentMergePersons);
+                        break;
+                    case "merge_right_holder":
+                        patent.setMergeRightHolder(patentMergePersons);
+                        break;
+                    case "merge_inventor":
+                        patent.setMergeInventor(patentMergePersons);
+                        break;
+                }
+            }
+            PatentJoin patentJoin = new PatentJoin();
+            patentJoin.setParent(patentId);
+            patentJoin.setName(mergeType);
+            patent.setPatentJoin(patentJoin);
+            try {
+                esService.addChildPatent(patent, patentId);
+            } catch (Exception e) {
+            }
+        }
+
+
+    }
+}

+ 88 - 5
src/main/java/cn/cslg/pas/service/business/es/EsPatentService.java

@@ -3,12 +3,16 @@ package cn.cslg.pas.service.business.es;
 import cn.cslg.pas.common.core.base.IfConstant;
 import cn.cslg.pas.common.dto.*;
 import cn.cslg.pas.common.dto.business.ContentDetailDTO;
+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.model.request.MapRequest;
 import cn.cslg.pas.common.model.request.OrderDTO;
 import cn.cslg.pas.common.model.request.QueryRequest;
 import cn.cslg.pas.common.model.request.StringRequest;
+import cn.cslg.pas.common.utils.CacheUtils;
 import cn.cslg.pas.common.utils.FormatUtil;
+import cn.cslg.pas.common.utils.PatentRightUtils;
 import cn.cslg.pas.common.utils.parseQueryToTree.expressManager;
 import cn.cslg.pas.common.utils.parseQueryToTree.operateNode;
 import cn.cslg.pas.common.utils.parseQueryToTree.treeNode;
@@ -19,14 +23,23 @@ import cn.cslg.pas.common.vo.PatentWithIdVO;
 import cn.cslg.pas.common.vo.business.PatentKinDetailVO;
 import cn.cslg.pas.common.vo.business.PatentKinVO;
 import cn.cslg.pas.common.vo.business.PatentNoVO;
+import cn.cslg.pas.common.vo.business.SelectProductVO;
+import cn.cslg.pas.domain.business.PatentClaim;
+import cn.cslg.pas.domain.business.Product;
+import cn.cslg.pas.domain.business.ProductCategory;
 import cn.cslg.pas.domain.es.*;
+import cn.cslg.pas.mapper.ProductCategoryMapper;
+import cn.cslg.pas.mapper.ProductMapper;
 import cn.cslg.pas.service.business.CommonService;
+import cn.cslg.pas.service.business.ProductService;
 import cn.cslg.pas.service.common.FileManagerService;
+import cn.cslg.pas.service.permissions.PermissionService;
 import cn.cslg.pas.service.query.FormatQueryService;
 import co.elastic.clients.elasticsearch.ElasticsearchClient;
 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.core.DeleteResponse;
 import co.elastic.clients.elasticsearch.core.SearchRequest;
 import co.elastic.clients.elasticsearch.core.SearchResponse;
 import co.elastic.clients.elasticsearch.core.search.Hit;
@@ -38,6 +51,7 @@ import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson2.JSONObject;
 import lombok.RequiredArgsConstructor;
+import org.apache.commons.lang3.ObjectUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -46,10 +60,7 @@ import org.springframework.stereotype.Service;
 import org.springframework.util.CollectionUtils;
 
 import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 import java.util.stream.Collectors;
 
 @Service
@@ -60,8 +71,20 @@ public class EsPatentService {
     private final FormatQueryService formatQueryService;
 
     @Autowired
+    private PermissionService permissionService;
+
+    @Autowired
     private FileManagerService fileManagerService;
 
+    @Autowired
+    private ProductMapper productMapper;
+
+    @Autowired
+    private ProductCategoryMapper productCategoryMapper;
+
+    @Autowired
+    private ProductService productService;
+
     /**
      * 根据专利号查询专利详情
      *
@@ -82,6 +105,13 @@ public class EsPatentService {
         for (Hit<Patent> hit : hits) {
             Patent esMess = hit.source();
             BeanUtils.copyProperties(esMess, dto);
+            //格式化权利要求
+            List<Text> claims =dto.getClaim();
+            if(claims!=null&&claims.size()>0){
+                claims.forEach(item->{
+                    item.setTextContent(PatentRightUtils.getFormatClaim(item.getTextContent(),item.getLanguage()));
+                });
+            }
             dto.setRightHolderAddr(esMess.getRightHolderAddr());
             dto.setApplicantAddr(esMess.getApplicantAddr());
             if (!CollectionUtils.isEmpty(esMess.getApplicant())) {
@@ -298,6 +328,48 @@ public class EsPatentService {
     }
 
     /**
+     * 根据专利号查询出商品化专利
+     *
+     * @param vo
+     * @return
+     * @throws IOException
+     */
+    public Object selectProductByPatentNo(SelectProductVO vo) throws Exception {
+        String patentNo = vo.getPatentNo();
+        QueryRequest queryRequest = new QueryRequest();
+        if (ObjectUtils.isNotEmpty(vo.getQueryRequest())) {
+            queryRequest = vo.getQueryRequest();
+        }
+        List<Integer> productIds = new ArrayList<>();
+        SearchRequest.Builder builder = new SearchRequest.Builder();
+        //设置查询索引
+        builder.index("patent");
+        //申请号
+        Query q1 = QueryBuilders.term(t -> t.field("app_no.keyword").value(patentNo));
+        //公开号
+        Query q2 = QueryBuilders.term(t -> t.field("public_no.keyword").value(patentNo));
+        //授权号
+        Query q3 = QueryBuilders.term(t -> t.field("grant_no.keyword").value(patentNo));
+        Query bool = QueryBuilders.bool(i -> i.should(q1, q2, q3));
+        Query q = QueryBuilders.exists(i -> i.field("product_id"));
+        Query query = QueryBuilders.hasParent(parent -> parent.parentType("patent").query(bool));
+        Query bool1 = QueryBuilders.bool(i -> i.must(q,query));
+        builder.query(bool1);
+
+        SearchResponse<Patent> response = client.search(builder.build(), Patent.class);
+        List<Hit<Patent>> hits = response.hits().hits();
+        for (Hit<Patent> hit : hits) {
+            Patent patent = hit.source();
+            if (patent.getProductId() != null) {
+                productIds.add(patent.getProductId());
+            }
+        }
+
+        queryRequest.setProductIds(productIds.stream().distinct().collect(Collectors.toList()));
+        return productService.selectProduct(queryRequest);
+    }
+
+    /**
      * 根据专利号批量查询专利
      *
      * @param patentNos
@@ -524,7 +596,12 @@ public class EsPatentService {
     }
 
 
-
+    /**
+     * 根据id查询
+     * @param ids
+     * @return
+     * @throws Exception
+     */
     public List<Hit<Patent>>  getById(List<String> ids) throws Exception {
         List<Hit<Patent>> patents =new ArrayList<>();
         SearchRequest.Builder builder = new SearchRequest.Builder();
@@ -539,4 +616,10 @@ public class EsPatentService {
         return patents;
         }
 
+    public void removeById(String id) throws IOException {
+        DeleteResponse deleteResponse = client.delete(deleteRequest ->
+                deleteRequest.index("patent").id(id)
+        );
+    }
+
 }

+ 93 - 14
src/main/java/cn/cslg/pas/service/business/es/EsProductPatentService.java

@@ -6,13 +6,17 @@ import cn.cslg.pas.common.vo.PatentWithIdVO;
 import cn.cslg.pas.common.vo.es.EsProductPatentVO;
 import cn.cslg.pas.domain.es.Patent;
 import cn.cslg.pas.domain.es.PatentJoin;
+import cn.cslg.pas.exception.XiaoShiException;
 import cn.cslg.pas.service.query.FormatQueryService;
 import co.elastic.clients.elasticsearch.ElasticsearchClient;
+import co.elastic.clients.elasticsearch._types.InlineScript;
+import co.elastic.clients.elasticsearch._types.Script;
+import co.elastic.clients.elasticsearch._types.query_dsl.IdsQuery;
 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 co.elastic.clients.json.JsonData;
 import lombok.RequiredArgsConstructor;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.context.annotation.Lazy;
@@ -20,6 +24,7 @@ import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Propagation;
 import org.springframework.transaction.annotation.Transactional;
 
+import java.io.IOException;
 import java.util.ArrayList;
 import java.util.List;
 
@@ -56,23 +61,97 @@ public class EsProductPatentService {
 
     @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Throwable.class)
     public List<Integer> delProductPatent(EsProductPatentVO vo) throws Exception {
-        List<Integer> ids = new ArrayList<>();
         List<Integer> productIds = vo.getProductIds();
+        List<Integer> ids = new ArrayList<>(productIds);
+        List<String> patentNos = vo.getPatentNos();
         for (Integer productId : productIds) {
-            SearchRequest.Builder builder = new SearchRequest.Builder();
-            //设置查询索引
-            builder.index("patent");
-            Query q = QueryBuilders.term(n -> n.field("product_id").value(productId));
-            Query query = QueryBuilders.hasChild(i -> i.type("product").query(q));
-            builder.query(query);
-            SearchResponse<Patent> response = client.search(builder.build(), Patent.class);
-            List<Hit<Patent>> hits = response.hits().hits();
-            for (Hit<Patent> hit : hits) {
-                Patent patent = hit.source();
+            List<String> productIdList = new ArrayList<>();
+            for (String patentNo : patentNos) {
+                SearchRequest.Builder builder = new SearchRequest.Builder();
+                //设置查询索引
+                builder.index("patent");
+                Query q = QueryBuilders.term(n -> n.field("product_id").value(productId));
+                //申请号
+                Query q1 = QueryBuilders.term(t -> t.field("app_no.keyword").value(patentNo));
+                //公开号
+                Query q2 = QueryBuilders.term(t -> t.field("public_no.keyword").value(patentNo));
+                //授权号
+                Query q3 = QueryBuilders.term(t -> t.field("grant_no.keyword").value(patentNo));
+                Query bool = QueryBuilders.bool(i -> i.should(q1, q2, q3));
+                Query query = QueryBuilders.hasParent(parent -> parent.parentType("patent").query(bool));
+                Query bool1 = QueryBuilders.bool(i -> i.must(q, query));
+                builder.query(bool1);
 
+                SearchResponse<Patent> response = client.search(builder.build(), Patent.class);
+                List<Hit<Patent>> hits = response.hits().hits();
+                for (Hit<Patent> hit : hits) {
+                    String id = hit.id();
+                    productIdList.add(id);
+                }
             }
+            this.delProduct(productIdList);
         }
-
         return ids;
     }
+
+    public Integer delProduct(List<String> ids) {
+        Query query = QueryBuilders.ids(n -> n.values(ids));
+        DeleteByQueryRequest request = DeleteByQueryRequest.of(i -> i.index("patent").query(query));
+        try {
+            client.deleteByQuery(request);
+            return 1;
+        } catch (IOException e) {
+            throw new XiaoShiException("删除失败");
+        }
+    }
+
+
+    /**
+     * 查询商品化专利数量
+     * @param productId
+     * @return
+     * @throws Exception
+     */
+    public Long selectProductNum(Integer productId) throws Exception {
+        SearchRequest.Builder builder = new SearchRequest.Builder();
+        //设置查询索引
+        builder.index("patent");
+        Query q1 = QueryBuilders.term(t -> t.field("product_id").value(productId));
+        Query query = QueryBuilders.hasChild(n -> n.type("product").query(q1));
+        builder.query(query);
+        SearchResponse<Patent> response = client.search(builder.build(), Patent.class);
+        return response.hits().total().value();
+    }
+
+    /**
+     * 查询商品化专利架构相关数量
+     * @param id
+     * @return
+     * @throws Exception
+     */
+    public Long selectRelevantProductNum(Integer id) throws Exception {
+        SearchRequest.Builder builder = new SearchRequest.Builder();
+        //设置查询索引
+        builder.index("patent");
+        Query q1 = QueryBuilders.term(t -> t.field("custom_field.field").value(id));
+        Query q2 = QueryBuilders.term(t -> t.field("custom_field.field_type").value("9"));
+        Query bool = QueryBuilders.bool(i -> i.must(q1,q2));
+        Query query = QueryBuilders.hasChild(n -> n.type("product").query(bool));
+        builder.query(query);
+        SearchResponse<Patent> response = client.search(builder.build(), Patent.class);
+        return response.hits().total().value();
+    }
+
+//添加
+    @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Throwable.class)
+    public String addProductPatent(String patentId, Integer productId) throws Exception {
+        Patent patent = new Patent();
+        PatentJoin patentJoin = new PatentJoin();
+        patentJoin.setParent(patentId);
+        patentJoin.setName("product");
+        patent.setPatentJoin(patentJoin);
+        patent.setProductId(productId);
+      String id=  esService.addChildPatent(patent,patentId);
+        return id;
+    }
 }

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

@@ -30,6 +30,7 @@ import co.elastic.clients.elasticsearch._types.query_dsl.QueryBuilders;
 import co.elastic.clients.elasticsearch.core.*;
 import co.elastic.clients.elasticsearch.core.search.Hit;
 import co.elastic.clients.elasticsearch.nodes.Stats;
+import co.elastic.clients.elasticsearch.sql.QueryResponse;
 import co.elastic.clients.json.JsonData;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
@@ -215,6 +216,7 @@ public class EsScratchWordsService {
                 deleteRequest.index("patent_marking").id(id)
         );
 
+
     }
 
 

+ 32 - 6
src/main/java/cn/cslg/pas/service/business/es/EsService.java

@@ -139,6 +139,8 @@ public class EsService {
         Integer taskId = queryRequest.getTaskId();
         String searchCondition = "";
         Integer projectId = queryRequest.getProjectId();
+        Integer productId = queryRequest.getProductId();
+        String productFrom = queryRequest.getFrom();
         Long current = queryRequest.getCurrent();
         Long size = queryRequest.getSize();
         String groupField = queryRequest.getGroupField();
@@ -169,15 +171,26 @@ public class EsService {
                 searchCondition = "taskId = " + taskId;
             }
         } else {
-            if (projectId != null) {
-                if (searchCondition != null && !"".equals(searchCondition.trim())) {
-                    searchCondition = "projectId = " + projectId + " AND " + searchCondition;
-                } else {
-                    searchCondition = "projectId = " + projectId;
+            if (StringUtils.isNotEmpty(productFrom)) {
+                if (productId != null) {
+                    if (searchCondition != null && !"".equals(searchCondition.trim())) {
+                        searchCondition = "productId = " + productId + " AND " + searchCondition;
+                    } else {
+                        searchCondition = "productId = " + productId;
+                    }
+                }
+            } else {
+                if (projectId != null) {
+                    if (searchCondition != null && !"".equals(searchCondition.trim())) {
+                        searchCondition = "projectId = " + projectId + " AND " + searchCondition;
+                    } else {
+                        searchCondition = "projectId = " + projectId;
+                    }
                 }
             }
         }
 
+
         SearchRequest.Builder builder = new SearchRequest.Builder();
         //设置查询索引
         builder.index("patent");
@@ -416,7 +429,7 @@ public class EsService {
 
     //更新patent
     public Integer updatePatent(Patent patent, String id) {
-        UpdateRequest<Patent, Patent> req;
+        UpdateRequest<Patent,Patent> req;
         req = UpdateRequest.of(
                 b -> b.index("patent").id(id)
                         .doc(patent)
@@ -429,6 +442,19 @@ public class EsService {
         }
     }
 
+    //更新patent
+    public Integer updatePatentById(Patent patent, String id) {
+        UpdateRequest<Patent,Patent> req;
+        req = UpdateRequest.of(
+                b -> b.index("patent").id(id)
+                        .doc(patent));
+        try {
+            client.update(req, Patent.class);
+            return 1;
+        } catch (IOException e) {
+            return -1;
+        }
+    }
     /*POST /patent/_update_by_query
     {
         "script": {

+ 429 - 0
src/main/java/cn/cslg/pas/service/business/es/EsValueCurveService.java

@@ -0,0 +1,429 @@
+package cn.cslg.pas.service.business.es;
+
+import cn.cslg.pas.common.core.base.IfConstant;
+import cn.cslg.pas.common.dto.es.EsCustomFieldValueDTO;
+import cn.cslg.pas.common.dto.es.EsValueCurveDTO;
+import cn.cslg.pas.common.dto.es.SelectValueCurveDTO;
+import cn.cslg.pas.common.model.cronModel.Records;
+import cn.cslg.pas.common.model.request.OrderDTO;
+import cn.cslg.pas.common.utils.parseQueryToTree.expressManager;
+import cn.cslg.pas.common.utils.parseQueryToTree.operateNode;
+import cn.cslg.pas.common.utils.parseQueryToTree.treeNode;
+import cn.cslg.pas.common.vo.EsConfigVO;
+import cn.cslg.pas.common.vo.es.EsCustomFieldBatchVO;
+import cn.cslg.pas.common.vo.es.EsValueCurveVO;
+import cn.cslg.pas.domain.business.PermissionRecord;
+import cn.cslg.pas.domain.business.ProductMarketData;
+import cn.cslg.pas.domain.es.Patent;
+import cn.cslg.pas.mapper.PermissionRecordMapper;
+import cn.cslg.pas.mapper.ProductMarketDataMapper;
+import cn.cslg.pas.service.business.CommonService;
+import cn.cslg.pas.service.query.FormatQueryService;
+import co.elastic.clients.elasticsearch.ElasticsearchClient;
+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.core.SearchRequest;
+import co.elastic.clients.elasticsearch.core.SearchResponse;
+import co.elastic.clients.elasticsearch.core.search.Hit;
+import com.alibaba.fastjson.JSON;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import lombok.RequiredArgsConstructor;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Lazy;
+import org.springframework.stereotype.Service;
+import org.springframework.util.CollectionUtils;
+
+import java.io.IOException;
+import java.math.BigDecimal;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
+
+@Service
+@RequiredArgsConstructor(onConstructor_ = {@Lazy})
+public class EsValueCurveService {
+
+    private final ElasticsearchClient client;
+
+    @Autowired
+    private EsService esService;
+
+    @Autowired
+    private FormatQueryService formatQueryService;
+
+    @Autowired
+    private ProductMarketDataMapper productMarketDataMapper;
+
+    @Autowired
+    private PermissionRecordMapper permissionRecordMapper;
+
+    /**
+     * 查询价值曲线
+     * @param vo
+     * @return
+     * @throws Exception
+     */
+    public List<EsValueCurveDTO> selectValueCurve(EsValueCurveVO vo) throws Exception {
+        List<String> isAdd = vo.getIsAdd();
+        List<String> isDel = vo.getIsDelete();
+        Integer startNum = vo.getStartNumber();
+        Integer endNum = vo.getEndNumber();
+        Integer timeType = vo.getTimeType();
+        Map<String, List<Integer>> map = new HashMap<>();
+        if (!CollectionUtils.isEmpty(isAdd) && startNum <= 1 && endNum < 1) {
+            isAdd.removeAll(isDel);
+            map = this.getProductIdByPatentNo(isAdd);
+        } else if (startNum >= 1 && endNum > 0) {
+            List<String> patentNos = this.getPatentNos(vo);
+            map = this.getProductIdByPatentNo(patentNos);
+        }
+        return this.getValueCurveList(map, timeType);
+    }
+
+    /**
+     * 提取返回数据
+     * @param map
+     * @param timeType
+     * @return
+     */
+    public List<EsValueCurveDTO> getValueCurveList(Map<String, List<Integer>> map, Integer timeType) {
+        List<EsValueCurveDTO> curveDTOS = new ArrayList<>();
+        if (!CollectionUtils.isEmpty(map)) {
+            for (String patentNo : map.keySet()) {
+                List<SelectValueCurveDTO> listLicensee = new ArrayList<>();
+                List<SelectValueCurveDTO> listSale = new ArrayList<>();
+                //获取许可记录
+                List<SelectValueCurveDTO> licenseeList = this.selectLicensee(patentNo, timeType);
+                if (!CollectionUtils.isEmpty(licenseeList)) {
+                    Map<String, List<SelectValueCurveDTO>> licenseeMap = licenseeList.stream().collect(Collectors.groupingBy(SelectValueCurveDTO::getLicenseTime));
+                    for (String key : licenseeMap.keySet()) {
+                        List<SelectValueCurveDTO> licenseeDTOS = licenseeMap.get(key);
+                        BigDecimal sum = new BigDecimal(0);
+                        for (SelectValueCurveDTO licenseeDTO : licenseeDTOS) {
+                            BigDecimal licenseeFee = new BigDecimal(String.valueOf(licenseeDTO.getLicenseFee()));
+                            sum = sum.add(licenseeFee);
+                        }
+                        SelectValueCurveDTO curveDTO = new SelectValueCurveDTO();
+                        if (sum.compareTo(new BigDecimal(0)) > 0) {
+                            curveDTO.setLicenseFee(sum.doubleValue());
+                        }
+                        curveDTO.setLicenseTime(key);
+                        curveDTO.setTimeType(licenseeDTOS.get(0).getTimeType());
+                        listLicensee.add(curveDTO);
+                    }
+                }
+                //获取营销数据
+                List<Integer> productIds = map.get(patentNo);
+                if (!CollectionUtils.isEmpty(productIds)) {
+                    List<SelectValueCurveDTO> saleList = this.selectSale(productIds, timeType);
+                    if (!CollectionUtils.isEmpty(saleList)) {
+                        Map<String, List<SelectValueCurveDTO>> saleMap = saleList.stream().collect(Collectors.groupingBy(SelectValueCurveDTO::getSaleTime));
+                        for (String key : saleMap.keySet()) {
+                            List<SelectValueCurveDTO> saleLDTOS = saleMap.get(key);
+                            //销售额
+                            BigDecimal count = new BigDecimal(0);
+                            //自定义许可费
+                            BigDecimal sum = new BigDecimal(0);
+                            for (SelectValueCurveDTO saleLDTO : saleLDTOS) {
+                                BigDecimal customLicensee = new BigDecimal(String.valueOf(saleLDTO.getCustomLicense()));
+                                sum = sum.add(customLicensee);
+                                BigDecimal saleMoney = new BigDecimal(String.valueOf(saleLDTO.getSaleMoney()));
+                                count = count.add(saleMoney);
+                            }
+                            SelectValueCurveDTO curveDTO = new SelectValueCurveDTO();
+                            if (sum.compareTo(new BigDecimal(0)) > 0) {
+                                curveDTO.setLicenseFee(sum.doubleValue());
+                            }
+                            if (count.compareTo(new BigDecimal(0)) > 0) {
+                                curveDTO.setCustomLicense(count.doubleValue());
+                            }
+                            curveDTO.setSaleTime(key);
+                            curveDTO.setSaleArea(saleLDTOS.get(0).getSaleArea());
+                            curveDTO.setTimeType(saleLDTOS.get(0).getTimeType());
+                            listSale.add(curveDTO);
+                        }
+                    }
+                }
+                List<EsValueCurveDTO> data = this.mergeData(listLicensee, listSale);
+                curveDTOS.addAll(data);
+            }
+        }
+        return curveDTOS;
+    }
+
+    /**
+     * 提取合并数据
+     * @param listLicensee
+     * @param listSale
+     * @return
+     */
+    public List<EsValueCurveDTO> mergeData(List<SelectValueCurveDTO> listLicensee,List<SelectValueCurveDTO> listSale) {
+        List<EsValueCurveDTO> list = new ArrayList<>();
+
+        if (!CollectionUtils.isEmpty(listLicensee) && !CollectionUtils.isEmpty(listSale)) {
+            for (SelectValueCurveDTO licensee : listLicensee) {
+                String licenseTime = licensee.getLicenseTime();
+                for (SelectValueCurveDTO sale : listSale) {
+                    String saleTime = sale.getSaleTime();
+                    if (licenseTime.equals(saleTime)) {
+                        EsValueCurveDTO dto = new EsValueCurveDTO();
+                        dto.setSaleArea(sale.getSaleArea());
+                        dto.setSaleMoney(sale.getSaleMoney());
+                        dto.setCustomLicense(sale.getCustomLicense());
+                        dto.setTime(saleTime);
+                        dto.setLicenseFee(licensee.getLicenseFee());
+                        dto.setTimeType(sale.getTimeType());
+                        list.add(dto);
+                    }
+                }
+            }
+        } else if (!CollectionUtils.isEmpty(listLicensee) && CollectionUtils.isEmpty(listSale)) {
+            for (SelectValueCurveDTO licensee : listLicensee) {
+                EsValueCurveDTO dto = new EsValueCurveDTO();
+                dto.setTime(licensee.getLicenseTime());
+                dto.setLicenseFee(licensee.getLicenseFee());
+                dto.setTimeType(licensee.getTimeType());
+                list.add(dto);
+            }
+        } else if (!CollectionUtils.isEmpty(listSale) && CollectionUtils.isEmpty(listLicensee)) {
+            for (SelectValueCurveDTO sale : listSale) {
+                EsValueCurveDTO dto = new EsValueCurveDTO();
+                dto.setSaleArea(sale.getSaleArea());
+                dto.setSaleMoney(sale.getSaleMoney());
+                dto.setCustomLicense(sale.getCustomLicense());
+                dto.setTime(sale.getSaleTime());
+                dto.setTimeType(sale.getTimeType());
+                list.add(dto);
+            }
+        }
+
+        if (!CollectionUtils.isEmpty(list)) {
+            for (EsValueCurveDTO dto : list) {
+                listLicensee.removeIf(licensee -> licensee.getLicenseTime().equals(dto.getTime()));
+            }
+
+            for (EsValueCurveDTO dto : list) {
+                listSale.removeIf(sale -> sale.getSaleTime().equals(dto.getTime()));
+            }
+
+            if (!CollectionUtils.isEmpty(listLicensee)) {
+                for (SelectValueCurveDTO licensee : listLicensee) {
+                    EsValueCurveDTO dto = new EsValueCurveDTO();
+                    dto.setTime(licensee.getLicenseTime());
+                    dto.setLicenseFee(licensee.getLicenseFee());
+                    dto.setTimeType(licensee.getTimeType());
+                    list.add(dto);
+                }
+            }
+
+            if (!CollectionUtils.isEmpty(listSale)) {
+                for (SelectValueCurveDTO sale : listSale) {
+                    EsValueCurveDTO dto = new EsValueCurveDTO();
+                    dto.setSaleArea(sale.getSaleArea());
+                    dto.setSaleMoney(sale.getSaleMoney());
+                    dto.setCustomLicense(sale.getCustomLicense());
+                    dto.setTime(sale.getSaleTime());
+                    dto.setTimeType(sale.getTimeType());
+                    list.add(dto);
+                }
+            }
+        }
+
+        return list;
+    }
+
+    /**
+     * 查询营销数据
+     * @param productIds
+     * @param timeType
+     * @return
+     */
+    public List<SelectValueCurveDTO> selectSale(List<Integer> productIds, Integer timeType) {
+        List<SelectValueCurveDTO> curveDTOS = new ArrayList<>();
+        if (timeType == 0) {
+            curveDTOS = productMarketDataMapper.selectSaleMonthList(productIds);
+            if (!CollectionUtils.isEmpty(curveDTOS)) {
+                curveDTOS.forEach(i -> i.setTimeType(timeType));
+            }
+        } else if (timeType == 0) {
+            curveDTOS = productMarketDataMapper.selectSaleYearList(productIds);
+            if (!CollectionUtils.isEmpty(curveDTOS)) {
+                curveDTOS.forEach(i -> i.setTimeType(timeType));
+            }
+        } else {
+            curveDTOS = productMarketDataMapper.selectSaleQuarterList(productIds);
+            if (!CollectionUtils.isEmpty(curveDTOS)) {
+                curveDTOS.forEach(i -> i.setTimeType(timeType));
+            }
+        }
+        return curveDTOS;
+    }
+
+    /**
+     * 查询许可记录
+     * @param patentNo
+     * @param timeType
+     * @return
+     */
+    public List<SelectValueCurveDTO> selectLicensee(String patentNo, Integer timeType) {
+        List<SelectValueCurveDTO> curveDTOS = new ArrayList<>();
+        if (timeType == 0) {
+            curveDTOS = permissionRecordMapper.selectLicenseeMonthList(patentNo);
+            if (!CollectionUtils.isEmpty(curveDTOS)) {
+                curveDTOS.forEach(i -> i.setTimeType(timeType));
+            }
+        } else if (timeType == 2) {
+            curveDTOS = permissionRecordMapper.selectLicenseeYearList(patentNo);
+            if (!CollectionUtils.isEmpty(curveDTOS)) {
+                curveDTOS.forEach(i -> i.setTimeType(timeType));
+            }
+        } else {
+            curveDTOS = permissionRecordMapper.selectLicenseeQuarterList(patentNo);
+            if (!CollectionUtils.isEmpty(curveDTOS)) {
+                curveDTOS.forEach(i -> i.setTimeType(timeType));
+            }
+        }
+        return curveDTOS;
+    }
+
+    /**
+     * 获取专利号列表
+     *
+     * @param vo
+     * @return
+     * @throws Exception
+     */
+    public List<String> getPatentNos(EsValueCurveVO vo) throws Exception {
+        Integer taskId = vo.getTaskId();
+        Integer projectId = vo.getProjectId();
+        Integer startNum = vo.getStartNumber();
+        Integer endNum = vo.getEndNumber();
+        List<String> isAdd = new ArrayList<>();
+        if (!CollectionUtils.isEmpty(vo.getIsAdd())) {
+            isAdd = vo.getIsAdd();
+        }
+        List<String> isDel = new ArrayList<>();
+        if (!CollectionUtils.isEmpty(vo.getIsDelete())) {
+            isDel = vo.getIsDelete();
+        }
+        String searchCondition = "";
+        if (StringUtils.isNotEmpty(vo.getSearchQuery())) {
+            searchCondition = vo.getSearchQuery();
+        }
+        List<EsCustomFieldValueDTO> customFields = vo.getCustomFields();
+        if (!CollectionUtils.isEmpty(customFields)) {
+            searchCondition = esService.parseCustomField(customFields);
+        }
+        if (taskId != null) {
+            if (searchCondition != null && !"".equals(searchCondition.trim())) {
+                searchCondition = "taskId = " + taskId + " AND " + searchCondition;
+            } else {
+                searchCondition = "taskId = " + taskId;
+            }
+        } else {
+            if (projectId != null) {
+                if (searchCondition != null && !"".equals(searchCondition.trim())) {
+                    searchCondition = "projectId = " + projectId + " AND " + searchCondition;
+                } else {
+                    searchCondition = "projectId = " + projectId;
+                }
+            }
+        }
+        SearchRequest.Builder builder = new SearchRequest.Builder();
+        //设置查询索引
+        builder.index("patent");
+        //1. 解析检索条件
+        treeNode tree = expressManager.getInstance().Parse(searchCondition, false);
+        //格式化检索式
+        //3. 从es中检索数据
+        Query q = formatQueryService.EsQueryToQuery((operateNode) tree, "patent");
+        builder.query(q);
+
+        List<OrderDTO> dtoList = vo.getOrderDTOList();
+        if (!CollectionUtils.isEmpty(dtoList)) {
+            String json = CommonService.readJsonFile("patent.json");
+            List<EsConfigVO> esConfigVOS = JSON.parseArray(json, EsConfigVO.class);
+            for (OrderDTO orderDTO : dtoList) {
+                EsConfigVO configVO = esConfigVOS.stream().filter(item -> item.getField().equals(orderDTO.getOrderBy())).findFirst().orElse(null);
+                if (configVO != null) {
+                    if (orderDTO.getOrderType().equals(IfConstant.NO)) {
+                        builder.sort(sortOptionsBuilder -> sortOptionsBuilder
+                                .field(fieldSortBuilder -> fieldSortBuilder
+                                        .field(configVO.getEsField()).order(SortOrder.Asc)));
+                    } else {
+                        builder.sort(sortOptionsBuilder -> sortOptionsBuilder
+                                .field(fieldSortBuilder -> fieldSortBuilder
+                                        .field(configVO.getEsField()).order(SortOrder.Desc)));
+                    }
+                }
+            }
+        } else {
+            builder.sort(sortOptionsBuilder -> sortOptionsBuilder
+                    .field(fieldSortBuilder -> fieldSortBuilder
+                            .field("patent_no.keyword").order(SortOrder.Desc)));
+        }
+
+        int number = endNum - startNum;
+        if (startNum > 0 && endNum > startNum) {
+            builder.from(startNum - 1).size(number);
+        }
+
+        SearchResponse<Patent> response = client.search(builder.build(), Patent.class);
+        List<Hit<Patent>> hits = response.hits().hits();
+        List<String> patentNos = new ArrayList<>();
+        for (Hit<Patent> hit : hits) {
+            Patent patent = hit.source();
+            patentNos.add(patent.getPatentNo());
+        }
+        patentNos.addAll(isAdd);
+        patentNos.removeAll(isDel);
+        return patentNos.stream().distinct().collect(Collectors.toList());
+    }
+
+    /**
+     * 根据专利号获取productId
+     * @param list
+     * @return
+     * @throws IOException
+     */
+    public Map<String, List<Integer>> getProductIdByPatentNo(List<String> list) throws IOException {
+        Map<String, List<Integer>> map = new HashMap<>();
+        if (!CollectionUtils.isEmpty(list)) {
+            for (String patentNo : list) {
+                List<Integer> productIds = new ArrayList<>();
+                SearchRequest.Builder builder = new SearchRequest.Builder();
+                //设置查询索引
+                builder.index("patent");
+                //申请号
+                Query q1 = QueryBuilders.term(t -> t.field("app_no.keyword").value(patentNo));
+                //公开号
+                Query q2 = QueryBuilders.term(t -> t.field("public_no.keyword").value(patentNo));
+                //授权号
+                Query q3 = QueryBuilders.term(t -> t.field("grant_no.keyword").value(patentNo));
+                Query bool = QueryBuilders.bool(i -> i.should(q1, q2, q3));
+                Query q = QueryBuilders.exists(i -> i.field("product_id"));
+                Query query = QueryBuilders.hasParent(parent -> parent.parentType("patent").query(bool));
+                Query bool1 = QueryBuilders.bool(i -> i.must(q,query));
+                builder.query(bool1);
+
+                SearchResponse<Patent> response = client.search(builder.build(), Patent.class);
+                List<Hit<Patent>> hits = response.hits().hits();
+                for (Hit<Patent> hit : hits) {
+                    Patent patent = hit.source();
+                    if (patent.getProductId() != null) {
+                        productIds.add(patent.getProductId());
+                    }
+                }
+                List<Integer> collect = productIds.stream().distinct().collect(Collectors.toList());
+                map.put(patentNo, collect);
+            }
+        }
+        return map;
+    }
+
+}

+ 23 - 18
src/main/java/cn/cslg/pas/service/business/stabilityReport/CompareRecordService.java

@@ -216,11 +216,13 @@ public class CompareRecordService {
         }
 
         //根据特征id 查询对比记录
-        LambdaQueryWrapper<AssoGroupReason> queryWrapper = new LambdaQueryWrapper<>();
-        queryWrapper.in(AssoGroupReason::getFeatureId, ids)
-                .isNull(AssoGroupReason::getGroupId);
-        List<AssoGroupReason> assoGroupReasons = assoGroupReasonService.list(queryWrapper);
-
+        List<AssoGroupReason> assoGroupReasons = new ArrayList<>();
+        if (ids.size() > 0) {
+            LambdaQueryWrapper<AssoGroupReason> queryWrapper = new LambdaQueryWrapper<>();
+            queryWrapper.in(AssoGroupReason::getFeatureId, ids)
+                    .isNull(AssoGroupReason::getGroupId);
+            assoGroupReasons = assoGroupReasonService.list(queryWrapper);
+        }
         //遍历特征获得内容
         for (Feature feature : features) {
 
@@ -276,8 +278,8 @@ public class CompareRecordService {
                 evidenceReason.setCommon(item.getDescription());
                 evidenceReason.setEvidenceId(item.getId());
                 evidenceReason.setFileGuid(item.getFileGuid());
-                AssoGroupReason assoGroupReason =assoGroupReasons1.stream().filter(i->i.getReasonId().equals(item.getId())).findFirst().orElse(null);
-                if(assoGroupReason!=null){
+                AssoGroupReason assoGroupReason = assoGroupReasons1.stream().filter(i -> i.getReasonId().equals(item.getId())).findFirst().orElse(null);
+                if (assoGroupReason != null) {
                     evidenceReason.setConclusion(assoGroupReason.getConclusion());
                 }
 
@@ -315,7 +317,7 @@ public class CompareRecordService {
         //根据ProjectId查询对比组合
         LambdaQueryWrapper<ProofGroup> queryWrapper = new LambdaQueryWrapper<>();
         queryWrapper.eq(ProofGroup::getProjectId, projectId)
-                    .orderByAsc(ProofGroup::getClaimSort);
+                .orderByAsc(ProofGroup::getClaimSort);
         List<ProofGroup> proofGroups = proofGroupService.list(queryWrapper);
 
         //查询标的专利号
@@ -398,12 +400,12 @@ public class CompareRecordService {
                             evidenceReason.setEvidenceText(item.getEvidenceText());
                             evidenceReason.setCommon(item.getDescription());
                             evidenceReason.setEvidenceId(item.getId());
-                            LambdaQueryWrapper<AssoGroupReason> queryWrapper4 =new LambdaQueryWrapper<>();
-                            queryWrapper4.eq(AssoGroupReason::getReasonId,item.getId())
-                                         .eq(AssoGroupReason::getFeatureId,feature.getId())
-                                         .isNull(AssoGroupReason::getGroupId);
-                           AssoGroupReason assoGroupReason= assoGroupReasonService.getOne(queryWrapper4,false);
-                                evidenceReason.setConclusion(assoGroupReason.getConclusion());
+                            LambdaQueryWrapper<AssoGroupReason> queryWrapper4 = new LambdaQueryWrapper<>();
+                            queryWrapper4.eq(AssoGroupReason::getReasonId, item.getId())
+                                    .eq(AssoGroupReason::getFeatureId, feature.getId())
+                                    .isNull(AssoGroupReason::getGroupId);
+                            AssoGroupReason assoGroupReason = assoGroupReasonService.getOne(queryWrapper4, false);
+                            evidenceReason.setConclusion(assoGroupReason.getConclusion());
 
                             //根据无效理由id 查询无效理由和文献关联
                             AssoReasonLiterature assoReasonLiteratureTmp = assoReasonLiteratures.stream()
@@ -428,7 +430,7 @@ public class CompareRecordService {
                             evidenceReasons.add(evidenceReason);
                         }
                         //装载公识
-                        if(reasonIds.contains(0)){
+                        if (reasonIds.contains(0)) {
                             AllCompareGroupVO.EvidenceReason evidenceReason = new AllCompareGroupVO.EvidenceReason();
                             evidenceReason.setEvidenceId(0);
                             evidenceReasons.add(evidenceReason);
@@ -489,9 +491,12 @@ public class CompareRecordService {
         splitVO.setProjectId(projectId);
         List<Feature> features = featureService.getSplitedFeature(splitVO);
         List<Integer> ids = features.stream().map(Feature::getId).collect(Collectors.toList());
-        LambdaQueryWrapper<AssoGroupReason> queryWrapper = new LambdaQueryWrapper<>();
-        queryWrapper.in(AssoGroupReason::getFeatureId, ids);
-        List<AssoGroupReason> assoGroupReasons = assoGroupReasonService.list(queryWrapper);
+        List<AssoGroupReason> assoGroupReasons =new ArrayList<>();
+        if(ids.size()>0) {
+            LambdaQueryWrapper<AssoGroupReason> queryWrapper = new LambdaQueryWrapper<>();
+            queryWrapper.in(AssoGroupReason::getFeatureId, ids);
+            assoGroupReasons = assoGroupReasonService.list(queryWrapper);
+        }
         if (assoGroupReasons != null && assoGroupReasons.size() != 0) {
             List<Integer> reasonIds = assoGroupReasons.stream().map(AssoGroupReason::getReasonId).collect(Collectors.toList());
             //根据reasonIds查询对比文献id

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

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

+ 45 - 61
src/main/java/cn/cslg/pas/service/common/PersonFieldService.java

@@ -26,6 +26,7 @@ import org.springframework.stereotype.Service;
 import org.springframework.util.CollectionUtils;
 
 import java.util.ArrayList;
+import java.util.Comparator;
 import java.util.List;
 import java.util.stream.Collectors;
 
@@ -177,7 +178,7 @@ public class PersonFieldService {
                     });
                 }
                 //当是专利的配置时
-                if (item.getTableName().trim().equals(PatentDictionary.NAME)) {
+                if (item.getTableName().trim().equals(PatentDictionary.NAME)&&item.getProjectId()!=null) {
                     //根据专题库id 查询所有自定义字段
                     List<AllCustomFieldVO> allCustomFieldVOS = customFieldService.getAllProjectCustomField(item.getProjectId());
                     //遍历装载
@@ -254,6 +255,7 @@ public class PersonFieldService {
         Integer projectId = getTabelColumDTO.getProjectId();
         Integer taskId = getTabelColumDTO.getTaskId();
         String tableName = getTabelColumDTO.getTableName();
+        Integer productId = getTabelColumDTO.getProductId();
         //根据登录人id和type查询
         PersonnelVO personnelVO = new PersonnelVO();
         try {
@@ -265,19 +267,23 @@ public class PersonFieldService {
         String key = "";
 
         if (projectId == null) {
-            key = SecureUtil.md5(tableName + RedisConf.SYMBOL_COLON + userId);
+            if (productId != null) {
+                key = SecureUtil.md5(tableName + RedisConf.SYMBOL_COLON + userId + RedisConf.SYMBOL_COLON + RedisConf.PRODUCT + RedisConf.SYMBOL_COLON + productId);
+            } else {
+                key = SecureUtil.md5(tableName + RedisConf.SYMBOL_COLON + userId);
+            }
         } else {
-            key = SecureUtil.md5(tableName + RedisConf.SYMBOL_COLON + userId + RedisConf.SYMBOL_COLON + projectId);
+            key = SecureUtil.md5(tableName + RedisConf.SYMBOL_COLON + userId + RedisConf.SYMBOL_COLON + RedisConf.PROJECT + RedisConf.SYMBOL_COLON + projectId);
         }
+        String redisKey = RedisConf.USER_FIELD + RedisConf.SYMBOL_COLON + key;
+        String json = redisUtil.get(redisKey);
 
-        String json = redisUtil.get(RedisConf.USER_FIELD + RedisConf.SYMBOL_COLON + key);
-
+        String fieldJson = "";
         //如果查到
+        List<PersonSelfFieldVO> reFieldVos =new ArrayList<>();
         if (StringUtils.isNotEmpty(json)) {
-            return JsonUtils.jsonToList(json, PersonSelfFieldVO.class);
+            reFieldVos =JsonUtils.jsonToList(json, PersonSelfFieldVO.class);
         }
-        String fieldJson = "";
-        //如果没查询到,则获取所有栏位添加到redis里
         try {
             fieldJson = CommonService.readJsonFile(tableName + ".json");
         } catch (Exception e) {
@@ -292,15 +298,14 @@ public class PersonFieldService {
         if (fieldVOS == null || fieldVOS.size() == 0) {
             throw new XiaoShiException("表中无字段");
         }
-        fieldVOS.forEach(item -> {
-            item.setCreateType(1);
-        });
+
+
 
         //当tableName是patent时
-        if (PatentDictionary.NAME.equals(tableName)) {
+        if (PatentDictionary.NAME.equals(tableName)&&projectId!=null) {
             //获得所有自定义字段
             List<AllCustomFieldVO> allCustomFieldVOS = customFieldService.getAllProjectCustomField(projectId);
-            AllCustomFieldVO allCustomFieldVO =new AllCustomFieldVO();
+            AllCustomFieldVO allCustomFieldVO = new AllCustomFieldVO();
             allCustomFieldVO.setName("标签");
             allCustomFieldVO.setId(0);
             allCustomFieldVO.setType(10);
@@ -320,20 +325,25 @@ public class PersonFieldService {
 
         }
         //装载顺序
-        Integer order = 0;
         for (PersonSelfFieldVO item : fieldVOS) {
-            item.setOrder(order);
-            if (item.getDefaultHidden() != null && item.getDefaultHidden().equals(true)) {
-                item.setIfHidden(true);
-            } else {
-                item.setIfHidden(false);
+            PersonSelfFieldVO personSelfFieldVO =reFieldVos.stream().filter(t->t.getValue().equals(item.getValue())&&t.getType().equals(item.getType())).findFirst().orElse(null);
+
+            if(personSelfFieldVO==null) {
+                if(StringUtils.isNotEmpty(json))
+                {
+                    item.setIfHidden(true);
+                }
+                else {
+                    if (item.getDefaultHidden() != null && item.getDefaultHidden().equals(true)) {
+                        item.setIfHidden(true);
+                    } else {
+                        item.setIfHidden(false);
+                    }
+                }
+                reFieldVos.add(item);
             }
-            order++;
         }
-
-        //保存到redis
-        redisUtil.set(RedisConf.USER_FIELD + RedisConf.SYMBOL_COLON + key, JsonUtils.objectToJson(fieldVOS));
-        return fieldVOS;
+        return reFieldVos;
     }
 
     public List<PersonSelfFieldVO> setTableColumns(AddSelfFieldDTO addSelfFieldDTO) {
@@ -346,49 +356,23 @@ public class PersonFieldService {
         String userId = personnelVO.getId();
         String tableName = addSelfFieldDTO.getTableName();
         Integer projectId = addSelfFieldDTO.getProjectId();
+        Integer productId =addSelfFieldDTO.getProductId();
+        List<PersonSelfFieldVO> personSelfFieldVOS =addSelfFieldDTO.getValue();
+        personSelfFieldVOS= personSelfFieldVOS.stream().filter(item->item.getIfHidden()!=null&&item.getIfHidden().equals(false)).collect(Collectors.toList());
         String key = "";
         if (projectId == null) {
-            key = SecureUtil.md5(tableName + RedisConf.SYMBOL_COLON + userId);
-        } else {
-            key = SecureUtil.md5(tableName + RedisConf.SYMBOL_COLON + userId + RedisConf.SYMBOL_COLON + projectId);
-        }
-        String fieldJson = CommonService.readJsonFile(addSelfFieldDTO.getTableName() + ".json");
-        List<PersonSelfFieldVO> fieldVOS = JSON.parseArray(fieldJson, PersonSelfFieldVO.class);
-        fieldVOS = fieldVOS.stream().filter(item -> item.getIfShow().equals(true)).collect(Collectors.toList());
-        //当tableName是patent时
-        if (PatentDictionary.NAME.equals(tableName)) {
-            //获得所有自定义字段
-            List<AllCustomFieldVO> allCustomFieldVOS = customFieldService.getAllProjectCustomField(projectId);
-            if (allCustomFieldVOS.size() != 0) {
-                for (AllCustomFieldVO item : allCustomFieldVOS) {
-                    PersonSelfFieldVO personSelfFieldVO = new PersonSelfFieldVO();
-                    personSelfFieldVO.setIfHidden(true);
-                    personSelfFieldVO.setName(item.getName());
-                    personSelfFieldVO.setType(item.getType().toString());
-                    personSelfFieldVO.setValue(item.getId().toString());
-                    personSelfFieldVO.setDefaultHidden(true);
-                    fieldVOS.add(personSelfFieldVO);
-                }
-            }
-        }
-        for (PersonSelfFieldVO item : fieldVOS) {
-            PersonSelfFieldVO temVO = addSelfFieldDTO.getValue().stream().filter(tem -> tem.getValue().equals(item.getValue())).findFirst().orElse(null);
-            if (temVO == null) {
-                item.setIfHidden(true);
+            if (productId != null) {
+                key = SecureUtil.md5(tableName + RedisConf.SYMBOL_COLON + userId + RedisConf.SYMBOL_COLON + RedisConf.PRODUCT + RedisConf.SYMBOL_COLON + productId);
             } else {
-                item.setIfHidden(temVO.getIfHidden());
+                key = SecureUtil.md5(tableName + RedisConf.SYMBOL_COLON + userId);
             }
+        } else {
+            key = SecureUtil.md5(tableName + RedisConf.SYMBOL_COLON + userId + RedisConf.SYMBOL_COLON + RedisConf.PROJECT + RedisConf.SYMBOL_COLON + projectId);
         }
+        String redisKey = RedisConf.USER_FIELD + RedisConf.SYMBOL_COLON + key;
+        redisUtil.set(redisKey, JsonUtils.objectToJson(personSelfFieldVOS));
 
-        Integer order = 0;
-
-        for (PersonSelfFieldVO item : fieldVOS) {
-            item.setOrder(order);
-            order++;
-        }
-        redisUtil.set(RedisConf.USER_FIELD + RedisConf.SYMBOL_COLON + key, JsonUtils.objectToJson(fieldVOS));
-
-        return fieldVOS;
+        return personSelfFieldVOS;
     }
 
     /**

+ 38 - 32
src/main/java/cn/cslg/pas/service/common/RetrieveRecordService.java

@@ -5,6 +5,7 @@ import cn.cslg.pas.common.dto.RetrieveRecordDTO;
 import cn.cslg.pas.common.dto.RetrieveRecordDeDTO;
 import cn.cslg.pas.common.dto.RetrieveRecordQueryDTO;
 import cn.cslg.pas.common.model.cronModel.PersonnelVO;
+import cn.cslg.pas.common.model.cronModel.Records;
 import cn.cslg.pas.common.utils.CacheUtils;
 import cn.cslg.pas.common.utils.LoginUtils;
 import cn.cslg.pas.common.utils.Response;
@@ -38,11 +39,13 @@ public class RetrieveRecordService extends ServiceImpl<RetrieveRecordMapper, Ret
 
     /**
      * 新增检索记录
+     *
      * @param retrieveRecordDTO
      */
-    public Response addRetrieveRecord(RetrieveRecordDTO retrieveRecordDTO){
+    public Integer addRetrieveRecord(RetrieveRecordDTO retrieveRecordDTO) {
+        Integer id = null;
         //判空
-        if(retrieveRecordDTO != null){
+        if (retrieveRecordDTO != null) {
             //新建实体类
             RetrieveRecord retrieveRecord = new RetrieveRecord();
             //复制
@@ -56,68 +59,71 @@ public class RetrieveRecordService extends ServiceImpl<RetrieveRecordMapper, Ret
             retrieveRecord.setTenantId(personnelVO.getTenantId());
             //数据入表
             retrieveRecord.insert();
-            return Response.success("新增成功");
-        } else {
-            return Response.error("传入参数不能为空");
+
         }
+        return retrieveRecordDTO.getId();
     }
 
     /**
      * 更新检索记录表
+     *
      * @param retrieveRecordDTO
      * @return
      */
-    public Response updateRetrieveRecord(RetrieveRecordDTO retrieveRecordDTO){
+    public Integer updateRetrieveRecord(RetrieveRecordDTO retrieveRecordDTO) {
+        Integer id = null;
         //判空
-        if(retrieveRecordDTO != null){
-            Integer id = retrieveRecordDTO.getId();
+        if (retrieveRecordDTO != null) {
+            id = retrieveRecordDTO.getId();
             //根据传入对象的id查询出实体类
             RetrieveRecord retrieveRecord = this.getById(id);
             retrieveRecord.setDbType(retrieveRecordDTO.getDbType());
             retrieveRecord.setConditions(retrieveRecordDTO.getConditions());
             retrieveRecord.setUpdateTime(new Date());
             retrieveRecord.updateById();
-            return Response.success("更新成功");
-        } else {
-            return Response.error("更新失败");
+            return retrieveRecord.getId();
         }
+        return id;
     }
 
     /**
      * 删除检索历史
+     *
      * @return
      */
-    public Response deleteRetrieveRecord(RetrieveRecordDeDTO retrieveRecordDeDTO){
-       List<Integer> ids = retrieveRecordDeDTO.getIds();
-       Boolean isAll =retrieveRecordDeDTO.getIsAll();
-       if(isAll!=null&& isAll){
-           this.remove(new LambdaQueryWrapper<RetrieveRecord>());
-       }
-       else {
-           //判空
-           if (ids != null && ids.size() > 0) {
-               this.removeByIds(ids);
-               return Response.success("删除成功");
-           } else {
-               return Response.error("删除错误");
-           }
-       }
-        return Response.success("删除成功");
+    public List<Integer> deleteRetrieveRecord(RetrieveRecordDeDTO retrieveRecordDeDTO) {
+        List<Integer> ids = retrieveRecordDeDTO.getIds();
+        Boolean isAll = retrieveRecordDeDTO.getIsAll();
+        if (isAll != null && isAll) {
+            this.remove(new LambdaQueryWrapper<RetrieveRecord>());
+        } else {
+            //判空
+            if (ids != null && ids.size() > 0) {
+                this.removeByIds(ids);
+            }
+        }
+        return ids;
     }
 
     /**
      * 查询检索历史
+     *
      * @return
      */
-    public IPage<RetrieveRecord> queryRetrieveRecord(RetrieveRecordQueryDTO retrieveRecordQueryDTO){
+    public Records queryRetrieveRecord(RetrieveRecordQueryDTO retrieveRecordQueryDTO) {
+        Records records = new Records();
         //获取当前登陆人信息
         PersonnelVO personnelVO = cacheUtils.getLoginUser(loginUtils.getId());
         String createId = personnelVO.getId();
         LambdaQueryWrapper<RetrieveRecord> queryWrapper = new LambdaQueryWrapper<>();
         queryWrapper.eq(RetrieveRecord::getCreateId, createId)
-        .orderByDesc(RetrieveRecord::getUpdateTime);
-        IPage<RetrieveRecord> retrieveRecords = this.page(new Page<>(retrieveRecordQueryDTO.getCurrent(),retrieveRecordQueryDTO.getSize()),queryWrapper);
-        List<RetrieveRecord> retrieveRecordList =retrieveRecords.getRecords();
-        return retrieveRecords;
+                .orderByDesc(RetrieveRecord::getUpdateTime);
+        IPage<RetrieveRecord> retrieveRecords = this.page(new Page<>(retrieveRecordQueryDTO.getCurrent(), retrieveRecordQueryDTO.getSize()), queryWrapper);
+        List<RetrieveRecord> retrieveRecordList = retrieveRecords.getRecords();
+        records.setData(retrieveRecordList);
+        records.setCurrent(retrieveRecordQueryDTO.getCurrent());
+        records.setSize(retrieveRecordQueryDTO.getSize());
+        records.setTotal(retrieveRecords.getTotal());
+        return records;
     }
 }

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

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

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

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

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

@@ -10,6 +10,8 @@ import cn.cslg.pas.domain.es.Patent;
 import cn.cslg.pas.domain.es.PatentJoin;
 import cn.cslg.pas.service.business.CompareLiteratureService;
 import cn.cslg.pas.service.business.ImportTaskService;
+import cn.cslg.pas.service.business.es.EsMergePersonService;
+import cn.cslg.pas.service.business.es.EsProductPatentService;
 import cn.cslg.pas.service.business.es.EsService;
 import cn.cslg.pas.service.common.FileManagerService;
 import cn.cslg.pas.service.common.MessageService;
@@ -80,15 +82,21 @@ public class SavePatentToEsThread extends Thread {
                             patentChild.setPatentJoin(patentJoin);
                             patentChild.setProjectId(importTaskAMVO.getProjectId());
                             esService.addChildPatent(patentChild, patentId);
+                            //当导入专题库时添加默认合并申请人
+                            if (importTaskAMVO.getProjectType() != null && importTaskAMVO.getProjectType().equals(0)) {
+                                EsMergePersonService esMergePersonService = applicationContext.getBean(EsMergePersonService.class);
+                                esMergePersonService.addDefaultMergePerson(patent, patentId, importTaskAMVO.getProjectId());
+                            }
                         }
 
                         //添加报告对比文件
                         if (importTaskAMVO.getProjectType() != null && importTaskAMVO.getProjectType().equals(1)) {
-                            if (importTaskAMVO.getReportType().equals(7)||importTaskAMVO.getReportType().equals(1)||importTaskAMVO.getReportType().equals(2)) {
+                            if (importTaskAMVO.getReportType().equals(7) || importTaskAMVO.getReportType().equals(1) || importTaskAMVO.getReportType().equals(2)) {
                                 CompareLiteratureService compareLiteratureService = applicationContext.getBean(CompareLiteratureService.class);
                                 compareLiteratureService.addPatentCompareLiterature(patent, importTaskAMVO.getProjectId(), importTaskAMVO.getCreateId());
                             }
                         }
+
                     }
                     //和任务关联
                     if (importTaskAMVO.getId() != null) {
@@ -110,6 +118,9 @@ public class SavePatentToEsThread extends Thread {
                         }
 
                     }
+                } else if (importTaskAMVO.getProductId() != null && patentId != null) {
+                    EsProductPatentService esProductPatentService = applicationContext.getBean(EsProductPatentService.class);
+                    esProductPatentService.addProductPatent(patentId, importTaskAMVO.getProductId());
                 }
                 //导入完成,通知前台
                 taskThread.updateProcess(false, 1, "");

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

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

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

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

+ 28 - 0
src/main/resources/mapper/PermissionRecordMapper.xml

@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
+<mapper namespace="cn.cslg.pas.mapper.PermissionRecordMapper">
+
+    <select id="selectLicenseeMonthList" resultType="cn.cslg.pas.common.dto.es.SelectValueCurveDTO">
+        select sum(license_fee) as licenseFee,
+               DATE_FORMAT(license_time, '%Y-%m') as licenseTime
+        from permission_record
+        where patent_no = #{patentNo}
+        group by DATE_FORMAT(license_time, '%Y-%m');
+    </select>
+
+    <select id="selectLicenseeYearList" resultType="cn.cslg.pas.common.dto.es.SelectValueCurveDTO">
+        select sum(license_fee) as licenseFee,
+               CONCAT(DATE_FORMAT(license_time, '%Y'),'年') as licenseTime
+        from permission_record
+        where patent_no = #{patentNo}
+        group by DATE_FORMAT(license_time, '%Y');
+    </select>
+
+    <select id="selectLicenseeQuarterList" resultType="cn.cslg.pas.common.dto.es.SelectValueCurveDTO">
+        select sum(license_fee) as licenseFee,
+               CONCAT(YEAR(license_time),'年第',quarter(license_time),'季度') as licenseTime
+        from permission_record
+        where patent_no = #{patentNo}
+        group by licenseTime;
+    </select>
+</mapper>

+ 49 - 0
src/main/resources/mapper/ProductMarketDataMapper.xml

@@ -46,4 +46,53 @@
         </if>
         group by ${groupField}
     </select>
+
+    <select id="selectSaleMonthList" resultType="cn.cslg.pas.common.dto.es.SelectValueCurveDTO">
+        select sale_area as saleArea,
+               sum(sale_money) as saleMoney,
+               DATE_FORMAT(sale_time, '%Y-%m') as saleTime,
+               sum(sale_money*custom_license_rate) as customLicense
+        from pas_prod2.product_market_data
+        <where>
+            <if test="productIds != null and productIds.size > 0">
+                <foreach collection="productIds" item="productId" index="index" open="(" separator="," close=")">
+                    #{productId}
+                </foreach>
+            </if>
+        </where>
+        group by DATE_FORMAT(sale_time, '%Y-%m');
+    </select>
+
+    <select id="selectSaleYearList" resultType="cn.cslg.pas.common.dto.es.SelectValueCurveDTO">
+        select sale_area as saleArea,
+               sum(sale_money) as saleMoney,
+               CONCAT(DATE_FORMAT(sale_time, '%Y'),'年') as saleTime,
+               sum(sale_money*custom_license_rate) as customLicense
+               from pas_prod2.product_market_data
+        <where>
+            <if test="productIds != null and productIds.size > 0">
+                <foreach collection="productIds" item="productId" index="index" open="(" separator="," close=")">
+                    #{productId}
+                </foreach>
+            </if>
+        </where>
+        group by DATE_FORMAT(sale_time, '%Y');
+    </select>
+
+    <select id="selectSaleQuarterList" resultType="cn.cslg.pas.common.dto.es.SelectValueCurveDTO">
+        select sale_area as saleArea,
+               sum(sale_money) as saleMoney,
+               CONCAT(YEAR(sale_time),'年第',quarter(sale_time),'季度') as saleTime,
+               sum(sale_money*custom_license_rate) as customLicense
+               from pas_prod2.product_market_data
+        <where>
+            <if test="productIds != null and productIds.size > 0">
+                <foreach collection="productIds" item="productId" index="index" open="(" separator="," close=")">
+                    #{productId}
+                </foreach>
+            </if>
+        </where>
+        group by saleTime;
+    </select>
+
 </mapper>

+ 6 - 9
src/test/java/cn/cslg/pas/service/CommonServiceTests.java

@@ -28,10 +28,7 @@ import org.springframework.boot.test.context.SpringBootTest;
 
 import java.io.File;
 import java.io.IOException;
-import java.util.ArrayList;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 import java.util.stream.Collectors;
 
 /**
@@ -140,10 +137,10 @@ public class CommonServiceTests {
 //李仁杰<2232723707@qq.com>"
     @Test
     public void testEmail() throws Exception{
-//        mailSendService.sendSynery("李仁杰<2232623707@qq.com>",false,1,1,1);
-      //  mailSendService.sentToCCMail("李仁杰<2232623707@qq.com>",false,"刘德华");
-//        mailSendService.sentToCCMail("323",true,"张学友");
-        reportExportService.exportReport(1,1);
-        Thread.sleep(10000);
+ Map<String,List<String>> map =new HashMap<>();
+ map.put("a",new ArrayList<>());
+ List<String> aa =map.get("a");
+ aa.add("111");
+ System.out.println(aa);
     }
     }

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

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

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

@@ -38,6 +38,7 @@ import java.io.File;
 import java.io.FileInputStream;
 import java.io.IOException;
 import java.util.*;
+import java.util.stream.Collectors;
 
 
 /**
@@ -464,12 +465,23 @@ public class EventServiceTests {
 
     @Test
     public void test101() {
-        Date date = new Date();
-        Calendar calendar = Calendar.getInstance();
-        calendar.setTime(date);
-        calendar.add(Calendar.DAY_OF_MONTH, 1);
-        Date date1 = calendar.getTime();
-        System.out.println(date1);
+//        Date date = new Date();
+//        Calendar calendar = Calendar.getInstance();
+//        calendar.setTime(date);
+//        calendar.add(Calendar.DAY_OF_MONTH, 1);
+//        Date date1 = calendar.getTime();
+//        System.out.println(date1);
+//
+//        List<Integer> list = Arrays.asList(1, 2, 3);
+//        String result = String.join(",", String.join(",", list.stream().map(Object::toString).collect(Collectors.toList())));
+//        System.out.println(result); // 输出: 1,2,3
+
+        String s = "((type='1') AND  (type_id='7') ) AND  (parent_id='0') ";
+        if (s.contains("type='1") || s.contains("type='2'")) {
+            System.out.println("Sdggdsgred");
+        } else {
+            System.out.println("end");
+        }
     }
 
 }