Преглед изворни кода

Merge remote-tracking branch 'origin/master'

xiexiang пре 1 година
родитељ
комит
2310881454

+ 6 - 0
src/main/java/cn/cslg/pas/common/dto/PatentColumnDTO.java

@@ -3,6 +3,7 @@ package cn.cslg.pas.common.dto;
 import cn.cslg.pas.common.vo.ContentVO;
 import cn.cslg.pas.domain.es.*;
 import com.fasterxml.jackson.annotation.JsonFormat;
+import com.fasterxml.jackson.annotation.JsonProperty;
 import lombok.AllArgsConstructor;
 import lombok.Data;
 import lombok.NoArgsConstructor;
@@ -15,6 +16,11 @@ import java.util.List;
 @AllArgsConstructor
 public class PatentColumnDTO {
     /**
+     * 专利id
+     */
+    @JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
+    private String patentId;
+    /**
      * 专利号
      */
     private String patentNo;

+ 30 - 73
src/main/java/cn/cslg/pas/common/utils/parseQueryToTree/expressManager.java

@@ -162,13 +162,6 @@ public class expressManager {
     /// <returns>表达式树节点</returns>
     public treeNode Parse(String strExpress, boolean isAnd) throws Exception {
         ArrayList<String> Tokens = GetTokens(strExpress);
-//        ArrayList<String> Tokens = new ArrayList<>();
-//        if (!CollectionUtils.isEmpty(tokens)) {
-//            for (String token : tokens) {
-//                String s = token.replaceAll("^\"*|\"*$", "");
-//                Tokens.add(s);
-//            }
-//        }
         Stack<Symbol> symbolStack = new Stack<Symbol>();
         Stack<treeNode> valueStack = new Stack<treeNode>();
         for (String strTem : Tokens) {
@@ -365,28 +358,42 @@ public class expressManager {
                         break;
                     case '(':
                     case '[':
-                        if (i == 0 || strTem.charAt(i - 1) == ' ' || (Tokens.size() > 0 && Tokens.get(Tokens.size() - 1) == String.valueOf(c)) || strTem.charAt(i - 1) == '=') {
-                            Tokens.add(String.valueOf(c));
-                            step = i;
+                        if (!isFindingEndYinHao) {
+                            if (step == (i - 1)) {
+                                Tokens.add(String.valueOf(c));
+                                step = i;
+                            } else {
+                                if (i == 0 || strTem.charAt(i - 1) == ' ' || (Tokens.size() > 0 && Tokens.get(Tokens.size() - 1) == String.valueOf(c)) || strTem.charAt(i - 1) == '=') {
+                                    Tokens.add(String.valueOf(c));
+                                    step = i;
+                                }
+                            }
                         }
                         break;
                     case ')':
                     case ']':
-                        if ((i < strTem.length() - 1 && (strTem.charAt(i + 1) == ' ' || strTem.charAt(i + 1) == c)) || i == strTem.length() - 1) {
-                            Boolean isAdd = false;
-                            for (int index = Tokens.size() - 1; index >= 0; index--) {
-                                if ((c == ')' && Tokens.get(index).equals("(")) || (c == ']' && Tokens.get(index).equals("["))) {
-                                    isAdd = true;
-                                    break;
-                                }
-                            }
-                            if (isAdd) {
-                                strTemToken = strTem.substring(step + 1, i);
-                                if (strTemToken != null && !strTemToken.equals("")) {
-                                    Tokens.add(strTemToken);
-                                }
+                        if (!isFindingEndYinHao) {
+                            if (step == (i - 1)) {
                                 Tokens.add(String.valueOf(c));
                                 step = i;
+                            } else {
+                                if ((i < strTem.length() - 1 && (strTem.charAt(i + 1) == ' ' || strTem.charAt(i + 1) == c)) || i == strTem.length() - 1) {
+                                    Boolean isAdd = false;
+                                    for (int index = Tokens.size() - 1; index >= 0; index--) {
+                                        if ((c == ')' && Tokens.get(index).equals("(")) || (c == ']' && Tokens.get(index).equals("["))) {
+                                            isAdd = true;
+                                            break;
+                                        }
+                                    }
+                                    if (isAdd) {
+                                        strTemToken = strTem.substring(step + 1, i);
+                                        if (strTemToken != null && !strTemToken.equals("")) {
+                                            Tokens.add(strTemToken);
+                                        }
+                                        Tokens.add(String.valueOf(c));
+                                        step = i;
+                                    }
+                                }
                             }
                         }
                         break;
@@ -424,54 +431,4 @@ public class expressManager {
         }
     }
 
-    public ArrayList<String> getTokens(String strExpression) {
-        if (strExpression != null && !strExpression.isEmpty()) {
-            ArrayList<String> tokens = new ArrayList<>();
-            String trimmedExpression = strExpression.trim();
-            StringBuilder currentToken = new StringBuilder();
-            boolean isInsideQuotes = false;
-
-            for (int i = 0; i < trimmedExpression.length(); i++) {
-                char currentChar = trimmedExpression.charAt(i);
-
-                if (currentChar == '"') {
-                    if (!isInsideQuotes) {
-                        isInsideQuotes = true;
-                        currentToken.append(currentChar); // 添加双引号到当前单词
-                    } else {
-                        isInsideQuotes = false;
-                        currentToken.append(currentChar); // 添加双引号到当前单词
-                        tokens.add(currentToken.toString());
-                        currentToken.setLength(0); // 清空 StringBuilder
-                    }
-                } else if (currentChar == ' ' && !isInsideQuotes) {
-                    if (currentToken.length() > 0) {
-                        tokens.add(currentToken.toString());
-                        currentToken.setLength(0); // Clear StringBuilder
-                    }
-                } else if (currentChar == '(' || currentChar == '[' || currentChar == ')' || currentChar == ']') {
-                    if (!isInsideQuotes) {
-                        if (currentToken.length() > 0) {
-                            tokens.add(currentToken.toString());
-                            currentToken.setLength(0); // Clear StringBuilder
-                        }
-                        tokens.add(String.valueOf(currentChar));
-                    } else {
-                        currentToken.append(currentChar);
-                    }
-                } else {
-                    currentToken.append(currentChar);
-                }
-            }
-
-            if (currentToken.length() > 0) {
-                tokens.add(currentToken.toString());
-            }
-
-            return tokens;
-        } else {
-            return null;
-        }
-    }
-
 }

+ 2 - 1
src/main/java/cn/cslg/pas/common/vo/business/EsAllCountVO.java

@@ -8,8 +8,9 @@ import java.util.List;
 @Data
 public class EsAllCountVO {
     private String condition;
+    private String groupField;
     private Integer projectId;
-    private List<EsCustomFieldValueDTO> customFields;
     private Integer taskId;
+    private List<EsCustomFieldValueDTO> customFields;
     private List<EsCountVO> countVOS;
 }

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

@@ -25,6 +25,8 @@ public class EsCustomFieldBatchVO {
 
     private String searchQuery;
 
+    private String groupField;
+
     private List<OrderDTO> orderDTOList;
 
     private List<EsCustomFieldValueDTO> customFields;

+ 31 - 0
src/main/java/cn/cslg/pas/common/vo/es/EsPatentCommonVO.java

@@ -0,0 +1,31 @@
+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 EsPatentCommonVO {
+
+    private Integer taskId;
+
+    private Integer projectId;
+
+    private Integer productId;
+
+    private String productFrom;
+
+    private String searchCondition;
+
+    private String esField;
+
+    private Long current;
+
+    private Long size;
+
+    private List<OrderDTO> orderDTOList;
+
+    private List<EsCustomFieldValueDTO> customFields;
+}

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

@@ -23,6 +23,8 @@ public class EsValueCurveVO {
 
     private String searchQuery;
 
+    private String groupField;
+
     private List<OrderDTO> orderDTOList;
 
     private List<EsCustomFieldValueDTO> customFields;

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

@@ -100,7 +100,12 @@ public class PatentController {
     @PostMapping("/queryPatent")
     public Response queryPatent(@RequestBody StringRequest stringRequest) throws Exception {
         Business business = businessFactory.getClass("patentService");
-        Records records = (Records) business.queryMessage(stringRequest);
+        Records records = null;
+        try {
+            records = (Records) business.queryMessage(stringRequest);
+        } catch (Exception e) {
+            return Response.error(e.getMessage());
+        }
         return Response.success(records);
     }
 
@@ -172,7 +177,12 @@ public class PatentController {
     @Operation(summary = "专利的聚合统计")
     @PostMapping("/esCountAnalysis")
     public Response esCountAnalysis(@RequestBody EsAllCountVO countVO) throws Exception {
-        EsCountDTO dto = esCountService.esCountAnalysis(countVO);
+        EsCountDTO dto = null;
+        try {
+            dto = esCountService.esCountAnalysis(countVO);
+        } catch (Exception e) {
+            return Response.error(e.getMessage());
+        }
         return Response.success(dto);
     }
 

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

@@ -39,8 +39,7 @@ public class PatentService extends ServiceImpl<PatentMapper, Patent> implements
             records.setSize(queryRequest.getSize());
             records.setData(patentDTO.getPatents());
             records.setTotal(patentDTO.getTotal());
-        }
-       catch (Exception e){
+        } catch (Exception e){
             e.printStackTrace();
        }
         return records;

+ 135 - 65
src/main/java/cn/cslg/pas/service/business/es/EsCountService.java

@@ -1,6 +1,7 @@
 package cn.cslg.pas.service.business.es;
 
 import cn.cslg.pas.common.dto.GetUnselectedDTO;
+import cn.cslg.pas.common.dto.PatentColumnDTO;
 import cn.cslg.pas.common.dto.business.EsCountDTO;
 import cn.cslg.pas.common.dto.business.EsCountDetailDTO;
 import cn.cslg.pas.common.dto.es.EsCustomFieldValueDTO;
@@ -18,6 +19,8 @@ import cn.cslg.pas.factorys.EsCountAnalyseBuilderFactory.IEsCountAnalysisBuilder
 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.SortOptions;
+import co.elastic.clients.elasticsearch._types.SortOrder;
 import co.elastic.clients.elasticsearch._types.aggregations.*;
 import co.elastic.clients.elasticsearch._types.query_dsl.Query;
 import co.elastic.clients.elasticsearch._types.query_dsl.QueryBuilders;
@@ -71,6 +74,7 @@ public class EsCountService {
         List<EsCustomFieldValueDTO> customFields = vo.getCustomFields();
         Integer taskId = vo.getTaskId();
         Integer projectId = vo.getProjectId();
+        String groupField = vo.getGroupField();
         EsCountDTO esCountDTO = new EsCountDTO();
         HashMap<String, List<EsCountDetailDTO>> map = new HashMap<>();
         List<EsCountDetailDTO> detailDTOS = new ArrayList<>();
@@ -88,7 +92,7 @@ public class EsCountService {
                         valueDTO.setFieldValue(Arrays.asList("\""+value+"\""));
                         customFields.add(valueDTO);
                         this.getDatas(searchCondition, "",customFields, taskId, projectId,
-                                esCountVOS, detailDTOS, esCountDTO, value, map);
+                                esCountVOS, detailDTOS, esCountDTO, value, map,groupField);
                     }
                 }
             } else {
@@ -100,12 +104,12 @@ public class EsCountService {
                         condition = countVO.getField() + " = " + "\""+value+"\"";
                     }
                     this.getDatas(searchCondition, condition, customFields, taskId, projectId,
-                            esCountVOS, detailDTOS, esCountDTO, value, map);
+                            esCountVOS, detailDTOS, esCountDTO, value, map,groupField);
                 }
             }
         } else {
             this.getDatas(searchCondition, "", customFields, taskId, projectId, countVOS,
-                    detailDTOS, esCountDTO, "", map);
+                    detailDTOS, esCountDTO, "", map,groupField);
         }
         esCountDTO.setDetailDTOS(detailDTOS);
         return esCountDTO;
@@ -113,7 +117,7 @@ public class EsCountService {
 
     public void getDatas(String searchCondition,String condition, List<EsCustomFieldValueDTO> customFields, Integer taskId,
                               Integer projectId, List<EsCountVO> countVOS, List<EsCountDetailDTO> detailDTOS,
-                              EsCountDTO esCountDTO, String firstName, Map<String, List<EsCountDetailDTO>> map) throws Exception {
+                              EsCountDTO esCountDTO, String firstName, Map<String, List<EsCountDetailDTO>> map,String groupField) throws Exception {
 
         if (StringUtils.isNotEmpty(condition)) {
             if (searchCondition != null && !"".equals(searchCondition.trim())) {
@@ -132,6 +136,16 @@ public class EsCountService {
             }
         }
         searchCondition = this.getCondition(searchCondition, taskId, projectId);
+        if (StringUtils.isNotEmpty(groupField) && !groupField.equals("0")) {
+            String groupIdsStr = this.getGroupIds(searchCondition, groupField, projectId);
+            if (StringUtils.isNotEmpty(searchCondition)) {
+                if (StringUtils.isNotEmpty(groupIdsStr) && !groupIdsStr.equals("ids = ")) {
+                    searchCondition = searchCondition + " AND " + groupIdsStr;
+                }
+            } else {
+                searchCondition = groupIdsStr;
+            }
+        }
 
         SearchRequest.Builder builder = new SearchRequest.Builder();
         //设置查询索引
@@ -145,77 +159,133 @@ public class EsCountService {
             query = formatQueryService.EsQueryToQuery((operateNode) tree, "patent",projectId);
             builder.query(query);
         }
+        if (query != null) {
+            for (EsCountVO countVO : countVOS) {
+                String field = countVO.getField();
+                String fieldId = countVO.getFieldId();
+                Integer topN = countVO.getTopN();
+                String valueOne = countVO.getValueOne();
+                String valueTwo = countVO.getValueTwo();
+                Integer fieldType = null;
+                String type = countVO.getFieldType();
+                if (StringUtils.isNotEmpty(type) && type.equals("tree")) {
+                    fieldType = 6;
+                }
+                String format = countVO.getFormat();
+                List<String> values = countVO.getValues();
+                Aggregation aggregation = this.getAggregation(countVO, projectId, taskId);
+                builder.aggregations("Agg", aggregation);
+                //解除最大条数限制
+                builder.trackTotalHits(i -> i.enabled(true));
+                SearchResponse<Patent> response = client.search(builder.build(), Patent.class);
+                Aggregate agg = response.aggregations().get("Agg");
 
-        for (EsCountVO countVO : countVOS) {
-            String field = countVO.getField();
-            String fieldId = countVO.getFieldId();
-            Integer topN = countVO.getTopN();
-            String valueOne = countVO.getValueOne();
-            String valueTwo = countVO.getValueTwo();
-            Integer fieldType = null;
-            String type = countVO.getFieldType();
-            if (StringUtils.isNotEmpty(type) && type.equals("tree")) {
-                fieldType = 6;
-            }
-            String format = countVO.getFormat();
-            List<String> values = countVO.getValues();
-            Aggregation aggregation = this.getAggregation(countVO, projectId, taskId);
-            builder.aggregations("Agg", aggregation);
-            //解除最大条数限制
-            builder.trackTotalHits(i -> i.enabled(true));
-            SearchResponse<Patent> response = client.search(builder.build(), Patent.class);
-            Aggregate agg = response.aggregations().get("Agg");
-
-            if (StringUtils.isNotEmpty(field)) {
-                if (dateList.contains(field)) {
-                    if (CollectionUtils.isEmpty(values)) {
-                        this.getDateCountDTOS(agg, field, topN, format, detailDTOS, esCountDTO,valueOne,valueTwo);
-                    } else {
-                        this.getDateAnalysisDTOS(agg, field, topN, detailDTOS, esCountDTO, firstName, map, values);
-                    }
-                } else if (nestedList.contains(field)) {
-                    this.getNestedCountDTOS(agg, field, topN, detailDTOS, esCountDTO, firstName, map, values,valueOne);
-                    if (!CollectionUtils.isEmpty(values)) {
-                        esCountDTO.setAllNumber(agg.nested().docCount());
-                    }
-                } else if (nestDateList.contains(field)) {
-                    if (CollectionUtils.isEmpty(values)) {
-                        Aggregate termsAgg = agg.nested().aggregations().get("terms_agg");
-                        this.getDateCountDTOS(termsAgg, field, topN, format, detailDTOS, esCountDTO,valueOne,valueTwo);
-                    } else {
-                        Aggregate termsAgg = agg.nested().aggregations().get("terms_agg");
-                        this.getDateAnalysisDTOS(termsAgg, field, topN, detailDTOS, esCountDTO, firstName, map, values);
-                    }
-                } else if (nestChildList.contains(field)) {
-                    Aggregate childAgg = agg.children().aggregations().get("childAgg");
-                    this.getNestedCountDTOS(childAgg, field, topN, detailDTOS, esCountDTO, firstName, map, values,valueOne);
-                    if (!CollectionUtils.isEmpty(values)) {
-                        esCountDTO.setAllNumber(childAgg.nested().docCount());
-                    }
-                } else if (childList.contains(field)) {
-                    if (CollectionUtils.isEmpty(values)) {
-                        this.getChildCountDTOS(agg, field, fieldType, topN, detailDTOS, esCountDTO,projectId,fieldId,query);
-                    } else {
-                        this.getChildAnalysisDTOS(agg, field, fieldType, topN,
-                                detailDTOS, esCountDTO, firstName, map, values);
-                    }
-                } else if (numberList.contains(field)) {
-                    if (CollectionUtils.isEmpty(values)) {
+                if (StringUtils.isNotEmpty(field)) {
+                    if (dateList.contains(field)) {
+                        if (CollectionUtils.isEmpty(values)) {
+                            this.getDateCountDTOS(agg, field, topN, format, detailDTOS, esCountDTO,valueOne,valueTwo);
+                        } else {
+                            this.getDateAnalysisDTOS(agg, field, topN, detailDTOS, esCountDTO, firstName, map, values);
+                        }
+                    } else if (nestedList.contains(field)) {
+                        this.getNestedCountDTOS(agg, field, topN, detailDTOS, esCountDTO, firstName, map, values,valueOne);
+                        if (!CollectionUtils.isEmpty(values)) {
+                            esCountDTO.setAllNumber(agg.nested().docCount());
+                        }
+                    } else if (nestDateList.contains(field)) {
+                        if (CollectionUtils.isEmpty(values)) {
+                            Aggregate termsAgg = agg.nested().aggregations().get("terms_agg");
+                            this.getDateCountDTOS(termsAgg, field, topN, format, detailDTOS, esCountDTO,valueOne,valueTwo);
+                        } else {
+                            Aggregate termsAgg = agg.nested().aggregations().get("terms_agg");
+                            this.getDateAnalysisDTOS(termsAgg, field, topN, detailDTOS, esCountDTO, firstName, map, values);
+                        }
+                    } else if (nestChildList.contains(field)) {
+                        Aggregate childAgg = agg.children().aggregations().get("childAgg");
+                        this.getNestedCountDTOS(childAgg, field, topN, detailDTOS, esCountDTO, firstName, map, values,valueOne);
+                        if (!CollectionUtils.isEmpty(values)) {
+                            esCountDTO.setAllNumber(childAgg.nested().docCount());
+                        }
+                    } else if (childList.contains(field)) {
+                        if (CollectionUtils.isEmpty(values)) {
+                            this.getChildCountDTOS(agg, field, fieldType, topN, detailDTOS, esCountDTO,projectId,fieldId,query);
+                        } else {
+                            this.getChildAnalysisDTOS(agg, field, fieldType, topN,
+                                    detailDTOS, esCountDTO, firstName, map, values);
+                        }
+                    } else if (numberList.contains(field)) {
+                        if (CollectionUtils.isEmpty(values)) {
 
+                        } else {
+                            this.getNumberAnalysisDTOS(agg, field, topN, detailDTOS, esCountDTO, firstName, map, values);
+                        }
                     } else {
-                        this.getNumberAnalysisDTOS(agg, field, topN, detailDTOS, esCountDTO, firstName, map, values);
+                        this.getTermCountDTOS(agg, field, topN, detailDTOS, esCountDTO, firstName, map, values,valueOne);
                     }
                 } else {
-                    this.getTermCountDTOS(agg, field, topN, detailDTOS, esCountDTO, firstName, map, values,valueOne);
+                    this.getFilterCountDTO(agg, searchCondition, detailDTOS);
                 }
-            } else {
-                this.getFilterCountDTO(agg, searchCondition, detailDTOS);
+                esCountDTO.setCondition(searchCondition);
+                esCountDTO.setAnalyseMap(map);
             }
-            esCountDTO.setCondition(searchCondition);
-            esCountDTO.setAnalyseMap(map);
         }
     }
 
+    public String getGroupIds(String searchCondition, String groupField, Integer projectId) throws Exception {
+        String result = "";
+        //判断同族分组
+        String esField = "";
+        switch (groupField) {
+            case "simpleFamilyId":
+                esField = "simple_family_id";
+                break;
+            case "inpadocFamilyId":
+                esField = "inpadoc_family_id";
+                break;
+            case "patsnapFamilyId":
+                esField = "patsnap_family_id";
+                break;
+        }
+
+        SearchRequest.Builder builder = new SearchRequest.Builder();
+        //设置查询索引
+        builder.index("patent");
+
+        //1. 解析检索条件
+        treeNode tree = expressManager.getInstance().Parse(searchCondition, false);
+        //格式化检索式
+        //3. 从es中检索数据
+        Query query = formatQueryService.EsQueryToQuery((operateNode) tree, "patent", projectId);
+        builder.query(query);
+        //判断同族分组
+        if (StringUtils.isNotEmpty(esField)) {
+            List<SortOptions> options = new ArrayList<>();
+            SortOptions appDate = SortOptions.of(i -> i.field(j -> j.field("app_date").order(SortOrder.Asc)));
+            options.add(appDate);
+            Aggregation bucketSort = AggregationBuilders.bucketSort(i -> i.from(0).size(9999999));
+            Aggregation aggregation = new Aggregation.Builder().terms(new TermsAggregation.Builder()
+                    .field(esField).size(100000).build())
+                    .aggregations(new HashMap() {{
+                        put("hitAgg", bucketSort);
+                    }}).build();
+            builder.aggregations("Agg", aggregation);
+        }
+        builder.size(100);
+        //解除最大条数限制
+        builder.trackTotalHits(i -> i.enabled(true));
+        SearchResponse<Patent> response = client.search(builder.build(), Patent.class);
+        Aggregate agg = response.aggregations().get("Agg");
+        List<StringTermsBucket> termsBuckets = agg.sterms().buckets().array();
+        List<String> list = new ArrayList<>();
+        for (StringTermsBucket termsBucket : termsBuckets) {
+            String key = termsBucket.key().stringValue();
+            PatentColumnDTO columnDTO = esService.getPatentColumnDTO(key, projectId, esField);
+            list.add(columnDTO.getPatentId());
+        }
+        result = esService.appendIds(list);
+        return result;
+    }
+
     public EsDateRangeDTO getFieldRange(EsDateRangeVO rangeVO) throws Exception {
         String searchCondition = rangeVO.getCondition();
         String field = rangeVO.getField();

+ 42 - 75
src/main/java/cn/cslg/pas/service/business/es/EsCustomFieldService.java

@@ -1,13 +1,8 @@
 package cn.cslg.pas.service.business.es;
 
-import cn.cslg.pas.common.core.base.IfConstant;
+import cn.cslg.pas.common.dto.PatentColumnDTO;
 import cn.cslg.pas.common.dto.es.*;
-import cn.cslg.pas.common.model.request.OrderDTO;
 import cn.cslg.pas.common.utils.FormatUtil;
-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.FieldValueVO;
 import cn.cslg.pas.common.vo.PatentWithIdVO;
 import cn.cslg.pas.common.vo.es.*;
@@ -17,27 +12,20 @@ import cn.cslg.pas.domain.business.CustomOption;
 import cn.cslg.pas.domain.business.TreeNode;
 import cn.cslg.pas.domain.es.*;
 import cn.cslg.pas.exception.XiaoShiException;
-import cn.cslg.pas.service.business.CommonService;
 import cn.cslg.pas.service.business.CustomOptionService;
 import cn.cslg.pas.service.business.TreeNodeService;
 import cn.cslg.pas.service.query.FormatQueryService;
 import co.elastic.clients.elasticsearch.ElasticsearchClient;
-import co.elastic.clients.elasticsearch._types.SortOptions;
 import co.elastic.clients.elasticsearch._types.SortOrder;
-import co.elastic.clients.elasticsearch._types.aggregations.Aggregation;
-import co.elastic.clients.elasticsearch._types.aggregations.AggregationBuilders;
-import co.elastic.clients.elasticsearch._types.aggregations.NestedAggregation;
+import co.elastic.clients.elasticsearch._types.aggregations.*;
 import co.elastic.clients.elasticsearch._types.query_dsl.Query;
 import co.elastic.clients.elasticsearch._types.query_dsl.QueryBuilders;
 import co.elastic.clients.elasticsearch.core.IndexResponse;
 import co.elastic.clients.elasticsearch.core.SearchRequest;
 import co.elastic.clients.elasticsearch.core.SearchResponse;
 import co.elastic.clients.elasticsearch.core.search.Hit;
-import co.elastic.clients.json.JsonData;
-import com.alibaba.fastjson.JSON;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import lombok.RequiredArgsConstructor;
-import lombok.Value;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -45,9 +33,6 @@ import org.springframework.context.annotation.Lazy;
 import org.springframework.stereotype.Service;
 import org.springframework.util.CollectionUtils;
 
-import java.io.IOException;
-import java.lang.reflect.Array;
-import java.text.ParseException;
 import java.util.*;
 import java.util.stream.Collectors;
 
@@ -321,6 +306,8 @@ public class EsCustomFieldService {
         Integer projectId = vo.getProjectId();
         Integer startNum = vo.getStartNumber();
         Integer endNum = vo.getEndNumber();
+        int number = endNum - startNum + 1;
+        String groupField = vo.getGroupField();
         List<String> isAdd = new ArrayList<>();
         if (!CollectionUtils.isEmpty(vo.getIsAdd())) {
             isAdd = vo.getIsAdd();
@@ -329,74 +316,54 @@ public class EsCustomFieldService {
         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,projectId,taskId);
-        }
-        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",null);
-        builder.query(q);
 
-        //排序
-        List<SortOptions> optionsList = new ArrayList<>();
-        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)) {
-                        SortOptions sortOptions = SortOptions.of(i -> i.field(j -> j.field(configVO.getEsField()).order(SortOrder.Asc).missing(-1)));
-                        optionsList.add(sortOptions);
-                    } else {
-                        SortOptions sortOptions = SortOptions.of(i -> i.field(j -> j.field(configVO.getEsField()).order(SortOrder.Desc).missing(-1)));
-                        optionsList.add(sortOptions);
-                    }
-                }
+        //判断同族分组
+        String str = "";
+        if (StringUtils.isNotEmpty(groupField)) {
+            switch (groupField) {
+                case "simpleFamilyId":
+                    str = "simple_family_id";
+                    break;
+                case "inpadocFamilyId":
+                    str = "inpadoc_family_id";
+                    break;
+                case "patsnapFamilyId":
+                    str = "patsnap_family_id";
+                    break;
             }
-        } else {
-            SortOptions sortOptions = SortOptions.of(i -> i.field(j -> j.field("patent_no.keyword").order(SortOrder.Desc).missing(-1)));
-            optionsList.add(sortOptions);
         }
-        builder.sort(optionsList);
+        String esField = str;
+        EsPatentCommonVO commonVO = new EsPatentCommonVO();
+        commonVO.setTaskId(taskId);
+        commonVO.setProjectId(projectId);
+        commonVO.setSearchCondition(vo.getSearchQuery());
+        commonVO.setCurrent(startNum.longValue());
+        commonVO.setSize(Integer.valueOf(number).longValue());
+        commonVO.setEsField(esField);
+        commonVO.setCustomFields(vo.getCustomFields());
+        commonVO.setOrderDTOList(vo.getOrderDTOList());
+        SearchRequest.Builder builder = esService.getCommonPatentByGroup(commonVO);
 
-        int number = endNum - startNum + 1;
         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());
+        if (StringUtils.isNotEmpty(esField)) {
+            Aggregate agg = response.aggregations().get("Agg");
+            List<StringTermsBucket> termsBuckets = agg.sterms().buckets().array();
+            for (StringTermsBucket termsBucket : termsBuckets) {
+                String key = termsBucket.key().stringValue();
+                PatentColumnDTO columnDTO = esService.getPatentColumnDTO(key, projectId, esField);
+                patentNos.add(columnDTO.getPatentNo());
+            }
+        } else {
+            List<Hit<Patent>> hits = response.hits().hits();
+            for (Hit<Patent> hit : hits) {
+                Patent patent = hit.source();
+                patentNos.add(patent.getPatentNo());
+            }
         }
         patentNos.addAll(isAdd);
         patentNos.removeAll(isDel);

+ 170 - 49
src/main/java/cn/cslg/pas/service/business/es/EsService.java

@@ -21,6 +21,7 @@ import cn.cslg.pas.common.utils.parseQueryToTree.operateNode;
 import cn.cslg.pas.common.utils.parseQueryToTree.treeNode;
 import cn.cslg.pas.common.vo.*;
 import cn.cslg.pas.common.vo.es.EsCustomFieldBatchVO;
+import cn.cslg.pas.common.vo.es.EsPatentCommonVO;
 import cn.cslg.pas.common.vo.es.PatentFamilyMessageWithId;
 import cn.cslg.pas.domain.es.*;
 import cn.cslg.pas.exception.XiaoShiException;
@@ -165,7 +166,87 @@ public class EsService {
             }
             searchCondition = stringBuilder.toString();
         }
-        List<EsCustomFieldValueDTO> customFields = queryRequest.getCustomFields();
+        //判断同族分组
+        String str = "";
+        if (StringUtils.isNotEmpty(groupField)) {
+            switch (groupField) {
+                case "simpleFamilyId":
+                    str = "simple_family_id";
+                    break;
+                case "inpadocFamilyId":
+                    str = "inpadoc_family_id";
+                    break;
+                case "patsnapFamilyId":
+                    str = "patsnap_family_id";
+                    break;
+            }
+        }
+        String esField = str;
+        EsPatentCommonVO commonVO = new EsPatentCommonVO();
+        commonVO.setTaskId(taskId);
+        commonVO.setProjectId(projectId);
+        commonVO.setProductId(productId);
+        commonVO.setSearchCondition(searchCondition);
+        commonVO.setProductFrom(productFrom);
+        commonVO.setCurrent(current);
+        commonVO.setSize(size);
+        commonVO.setEsField(esField);
+        commonVO.setCustomFields(queryRequest.getCustomFields());
+        commonVO.setOrderDTOList(queryRequest.getOrderDTOList());
+        SearchRequest.Builder builder = this.getCommonPatent(commonVO);
+
+        //分页
+        if (current != null && size != null && current > 0 && size > 0) {
+            builder.from((current.intValue() - 1) * size.intValue()).size(size.intValue());
+        } else {
+            builder.from(0).size(99999);
+        }
+
+        //解除最大条数限制
+        builder.trackTotalHits(i -> i.enabled(true));
+        SearchResponse<Patent> response = client.search(builder.build(), Patent.class);
+        List<PatentColumnDTO> list = new ArrayList<>();
+        long total = 0L;
+        if (StringUtils.isNotEmpty(esField)) {
+            Aggregate statsAgg = response.aggregations().get("statsBucket");
+            total = statsAgg.statsBucket().count();
+            Aggregate agg = response.aggregations().get("Agg");
+            List<StringTermsBucket> termsBuckets = agg.sterms().buckets().array();
+            for (StringTermsBucket termsBucket : termsBuckets) {
+                String key = termsBucket.key().stringValue();
+                PatentColumnDTO columnDTO = this.getPatentColumnDTO(key, projectId, esField);
+                list.add(columnDTO);
+            }
+        } else {
+            List<Hit<Patent>> hits = response.hits().hits();
+            total = response.hits().total().value();
+            for (Hit<Patent> hit : hits) {
+                String id = hit.id();
+                Patent esMess = hit.source();
+                PatentColumnDTO columnDTO = this.getPatentColumnDTO(esMess, projectId, id);
+                list.add(columnDTO);
+            }
+        }
+        this.loadCoulumnDTO(list);
+        dto.setTotal(total);
+        dto.setPatents(list);
+        dto.setPageNum(current);
+        dto.setPageSize(size);
+        return dto;
+    }
+
+    //获取通用部分方法--检索专利
+    public SearchRequest.Builder getCommonPatent(EsPatentCommonVO commonVO) throws Exception {
+        Integer taskId = commonVO.getTaskId();
+        Integer projectId = commonVO.getProjectId();
+        Integer productId = commonVO.getProductId();
+        String searchCondition = commonVO.getSearchCondition();
+        String productFrom = commonVO.getProductFrom();
+        String esField = commonVO.getEsField();
+        Long current = commonVO.getCurrent();
+        Long size = commonVO.getSize();
+
+        List<EsCustomFieldValueDTO> customFields = commonVO.getCustomFields();
         if (!CollectionUtils.isEmpty(customFields)) {
             String customFieldCondition = this.parseCustomField(customFields, projectId, taskId);
             if (StringUtils.isNotEmpty(searchCondition)) {
@@ -185,21 +266,6 @@ public class EsService {
         Query q = formatQueryService.EsQueryToQuery((operateNode) tree, "patent", projectId);
         builder.query(q);
         //判断同族分组
-        String str = "";
-        if (StringUtils.isNotEmpty(groupField)) {
-            switch (groupField) {
-                case "simpleFamilyId":
-                    str = "simple_family_id";
-                    break;
-                case "inpadocFamilyId":
-                    str = "inpadoc_family_id";
-                    break;
-                case "patsnapFamilyId":
-                    str = "patsnap_family_id";
-                    break;
-            }
-        }
-        String esField = str;
         if (StringUtils.isNotEmpty(esField)) {
             List<SortOptions> options = new ArrayList<>();
             SortOptions appDate = SortOptions.of(i -> i.field(j -> j.field("app_date").order(SortOrder.Asc)));
@@ -221,7 +287,7 @@ public class EsService {
 
         //排序
         List<SortOptions> optionsList = new ArrayList<>();
-        List<OrderDTO> dtoList = queryRequest.getOrderDTOList();
+        List<OrderDTO> dtoList = commonVO.getOrderDTOList();
         if (!CollectionUtils.isEmpty(dtoList)) {
             String json = CommonService.readJsonFile("patent.json");
             List<EsConfigVO> esConfigVOS = JSON.parseArray(json, EsConfigVO.class);
@@ -242,45 +308,77 @@ public class EsService {
             optionsList.add(sortOptions);
         }
         builder.sort(optionsList);
+        return builder;
+    }
 
-        //分页
-        if (current != null && size != null && current > 0 && size > 0) {
-            builder.from((current.intValue() - 1) * size.intValue()).size(size.intValue());
-        } else {
-            builder.from(0).size(99999);
+    //获取通用部分方法--批量删除、标引、查询价值曲线
+    public SearchRequest.Builder getCommonPatentByGroup(EsPatentCommonVO commonVO) throws Exception {
+        Integer taskId = commonVO.getTaskId();
+        Integer projectId = commonVO.getProjectId();
+        Integer productId = commonVO.getProductId();
+        String searchCondition = commonVO.getSearchCondition();
+        String productFrom = commonVO.getProductFrom();
+        String esField = commonVO.getEsField();
+        Long current = commonVO.getCurrent();
+        Long size = commonVO.getSize();
+
+        List<EsCustomFieldValueDTO> customFields = commonVO.getCustomFields();
+        if (!CollectionUtils.isEmpty(customFields)) {
+            String customFieldCondition = this.parseCustomField(customFields, projectId, taskId);
+            if (StringUtils.isNotEmpty(searchCondition)) {
+                searchCondition = searchCondition + " AND " + customFieldCondition;
+            } else {
+                searchCondition = customFieldCondition;
+            }
         }
+        String condition = this.appendIdsCondition(searchCondition, taskId, productFrom, projectId, productId);
 
-        //解除最大条数限制
-        builder.trackTotalHits(i -> i.enabled(true));
-        SearchResponse<Patent> response = client.search(builder.build(), Patent.class);
-        List<PatentColumnDTO> list = new ArrayList<>();
-        long total = 0L;
+        SearchRequest.Builder builder = new SearchRequest.Builder();
+        //设置查询索引
+        builder.index("patent");
+        //1. 解析检索条件
+        treeNode tree = expressManager.getInstance().Parse(condition, false);
+        //3. 从es中检索数据
+        Query q = formatQueryService.EsQueryToQuery((operateNode) tree, "patent", projectId);
+        builder.query(q);
+        //判断同族分组
         if (StringUtils.isNotEmpty(esField)) {
-            Aggregate statsAgg = response.aggregations().get("statsBucket");
-            total = statsAgg.statsBucket().count();
-            Aggregate agg = response.aggregations().get("Agg");
-            List<StringTermsBucket> termsBuckets = agg.sterms().buckets().array();
-            for (StringTermsBucket termsBucket : termsBuckets) {
-                String key = termsBucket.key().stringValue();
-                PatentColumnDTO columnDTO = this.getPatentColumnDTO(key, projectId, esField);
-                list.add(columnDTO);
+            List<SortOptions> options = new ArrayList<>();
+            SortOptions appDate = SortOptions.of(i -> i.field(j -> j.field("app_date").order(SortOrder.Asc)));
+            options.add(appDate);
+            Aggregation bucketSort = AggregationBuilders.bucketSort(i -> i.from(current.intValue() - 1).size(size.intValue()));
+            Aggregation aggregation = new Aggregation.Builder().terms(new TermsAggregation.Builder()
+                    .field(esField).size(100000).build())
+                    .aggregations(new HashMap() {{
+                        put("hitAgg", bucketSort);
+                    }}).build();
+            builder.aggregations("Agg", aggregation);
+        }
+
+        //排序
+        List<SortOptions> optionsList = new ArrayList<>();
+        List<OrderDTO> dtoList = commonVO.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)) {
+                        SortOptions sortOptions = SortOptions.of(i -> i.field(j -> j.field(configVO.getEsField()).order(SortOrder.Asc).missing(-1)));
+                        optionsList.add(sortOptions);
+                    } else {
+                        SortOptions sortOptions = SortOptions.of(i -> i.field(j -> j.field(configVO.getEsField()).order(SortOrder.Desc).missing(-1)));
+                        optionsList.add(sortOptions);
+                    }
+                }
             }
         } else {
-            List<Hit<Patent>> hits = response.hits().hits();
-            total = response.hits().total().value();
-            for (Hit<Patent> hit : hits) {
-                String id = hit.id();
-                Patent esMess = hit.source();
-                PatentColumnDTO columnDTO = this.getPatentColumnDTO(esMess, projectId, id);
-                list.add(columnDTO);
-            }
+            SortOptions sortOptions = SortOptions.of(i -> i.field(j -> j.field("patent_no.keyword").order(SortOrder.Desc).missing(-1)));
+            optionsList.add(sortOptions);
         }
-        this.loadCoulumnDTO(list);
-        dto.setTotal(total);
-        dto.setPatents(list);
-        dto.setPageNum(current);
-        dto.setPageSize(size);
-        return dto;
+        builder.sort(optionsList);
+        return builder;
     }
 
     //封装专利清单的同族分组
@@ -297,6 +395,7 @@ public class EsService {
             String id = hits.get(0).id();
             Patent patent = hits.get(0).source();
             dto = this.getPatentColumnDTO(patent, projectId, id);
+            dto.setPatentId(id);
         }
         return dto;
     }
@@ -500,6 +599,28 @@ public class EsService {
         return str;
     }
 
+    //拼接NOS
+    public String appendNOS(List<String> nos) {
+        String str = "NO = ";
+        if (nos.size() > 1) {
+            str = str + "(";
+            for (int i = 0; i < nos.size(); i++) {
+                String s = nos.get(i);
+                if (i != nos.size() - 1) {
+                    str = str + s  + " " + "OR" + " ";
+                } else {
+                    str = str + s + ")";
+                }
+            }
+        } else {
+            for (String no : nos) {
+                str = str + no;
+            }
+        }
+        return str;
+    }
+
+
     //更新patent
     public Integer updatePatent(Patent patent, String id) {
         UpdateRequest<Patent, Patent> req;

+ 7 - 95
src/main/java/cn/cslg/pas/service/business/es/EsValueCurveService.java

@@ -37,6 +37,7 @@ 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.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.context.annotation.Lazy;
 import org.springframework.stereotype.Service;
@@ -78,6 +79,9 @@ public class EsValueCurveService {
     @Autowired
     private ProductMapper productMapper;
 
+    @Autowired
+    private EsCustomFieldService esCustomFieldService;
+
     /**
      * 查询价值曲线
      * @param vo
@@ -103,7 +107,9 @@ public class EsValueCurveService {
             isAdd.removeAll(isDel);
             map = this.getProductIdByPatentNo(isAdd,tenantId);
         } else if (startNum >= 1 && endNum > 0) {
-            List<String> patentNos = this.getPatentNos(vo);
+            EsCustomFieldBatchVO batchVO = new EsCustomFieldBatchVO();
+            BeanUtils.copyProperties(vo, batchVO);
+            List<String> patentNos = esCustomFieldService.getPatentNos(batchVO);
             map = this.getProductIdByPatentNo(patentNos,tenantId);
         }
         return this.getValueCurveList(map, timeType,tenantId);
@@ -317,100 +323,6 @@ public class EsValueCurveService {
     }
 
     /**
-     * 获取专利号列表
-     *
-     * @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, projectId, taskId);
-        }
-        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",null);
-        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

Разлика између датотеке није приказан због своје велике величине
+ 4 - 0
src/test/java/cn/cslg/pas/service/EventServiceTests.java