zero пре 1 година
родитељ
комит
8099e9817c

+ 2 - 0
src/main/java/cn/cslg/pas/common/dto/business/EsCountDetailDTO.java

@@ -16,5 +16,7 @@ public class EsCountDetailDTO {
     private String name;
     //数量
     private Long number;
+    //限制数量
+    private Integer topN;
 
 }

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

@@ -45,7 +45,7 @@ public class expressManager {
 
         oOR = new operate();
         oOR.Code = "~";
-        oOR.ShowName = ">";
+        oOR.ShowName = "TO";
         oOR.type = enuType.Logic;
         oOR.priorityVale = 13;
         oOR.operateValue = 2;

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

@@ -28,4 +28,5 @@ public class GetAllPatentCountVO {
     //-1专利著录 0自定义字段 7产品 8产品类别 9技术分类
     private Integer filedKind;
     private Boolean defaultShowStats;
+    private String field;
 }

+ 37 - 18
src/main/java/cn/cslg/pas/service/business/es/EsCountService.java

@@ -65,7 +65,7 @@ public class EsCountService {
         }
         Integer taskId = vo.getTaskId();
         Integer projectId = vo.getProjectId();
-        searchCondition = this.getCondition(taskId, projectId);
+        searchCondition = this.getCondition(searchCondition, taskId, projectId);
 
         SearchRequest.Builder builder = new SearchRequest.Builder();
         //设置查询索引
@@ -134,7 +134,7 @@ public class EsCountService {
                         filtersBuckets.forEach(filtersBucket -> {
 //                            this.getFiltersCountDTO(filtersBucket, finalSearchCondition, detailDTOS);
                             Aggregate filtersAgg = filtersBucket.aggregations().get("filters_agg");
-                            this.getNestedCountDTOS(filtersAgg, field, detailDTOS);
+                            this.getNestedCountDTOS(filtersAgg, field,topN, detailDTOS);
                             if (!CollectionUtils.isEmpty(values)) {
                                 esCountDTO.setAllNumber(filtersAgg.nested().docCount());
                             }
@@ -145,14 +145,14 @@ public class EsCountService {
                             filtersBuckets.forEach(filtersBucket -> {
 //                                this.getFiltersCountDTO(filtersBucket, finalSearchCondition, detailDTOS);
                                 Aggregate filtersAgg = filtersBucket.aggregations().get("filters_agg");
-                                this.getChildCountDTOS(filtersAgg, field, finalFieldType, detailDTOS,esCountDTO);
+                                this.getChildCountDTOS(filtersAgg, field, finalFieldType, topN,detailDTOS,esCountDTO);
                             });
                         } else {
                             Integer finalFieldType1 = fieldType;
                             filtersBuckets.forEach(filtersBucket -> {
 //                                this.getFiltersCountDTO(filtersBucket, finalSearchCondition, detailDTOS);
                                 Aggregate filtersAgg = filtersBucket.aggregations().get("filters_agg");
-                                this.getChildAnalysisDTOS(filtersAgg, field, finalFieldType1, detailDTOS, esCountDTO);
+                                this.getChildAnalysisDTOS(filtersAgg, field, finalFieldType1, topN,detailDTOS, esCountDTO);
                             });
                         }
                     } else if (numberList.contains(field)) {
@@ -162,14 +162,14 @@ public class EsCountService {
                             filtersBuckets.forEach(filtersBucket -> {
 //                                this.getFiltersCountDTO(filtersBucket, finalSearchCondition, detailDTOS);
                                 Aggregate filtersAgg = filtersBucket.aggregations().get("filters_agg");
-                                this.getNumberAnalysisDTOS(filtersAgg, field, detailDTOS);
+                                this.getNumberAnalysisDTOS(filtersAgg, field,topN, detailDTOS);
                             });
                         }
                     } else {
                         filtersBuckets.forEach(filtersBucket -> {
 //                            this.getFiltersCountDTO(filtersBucket, finalSearchCondition, detailDTOS);
                             Aggregate filtersAgg = filtersBucket.aggregations().get("filters_agg");
-                            this.getTermCountDTOS(filtersAgg, field, detailDTOS);
+                            this.getTermCountDTOS(filtersAgg, field, topN,detailDTOS);
                         });
                     }
                 } else {
@@ -183,20 +183,20 @@ public class EsCountService {
                         this.getDateAnalysisDTOS(agg, field, topN, detailDTOS,esCountDTO);
                     }
                 } else if (nestedList.contains(field)) {
-                    this.getNestedCountDTOS(agg, field, detailDTOS);
+                    this.getNestedCountDTOS(agg, field,topN, detailDTOS);
                     if (!CollectionUtils.isEmpty(values)) {
                         esCountDTO.setAllNumber(agg.nested().docCount());
                     }
                 } else if (childList.contains(field)) {
                     if (CollectionUtils.isEmpty(values)) {
-                        this.getChildCountDTOS(agg, field, fieldType, detailDTOS, esCountDTO);
+                        this.getChildCountDTOS(agg, field, fieldType,topN, detailDTOS, esCountDTO);
                     } else {
-                        this.getChildAnalysisDTOS(agg, field, fieldType, detailDTOS, esCountDTO);
+                        this.getChildAnalysisDTOS(agg, field, fieldType,topN, detailDTOS, esCountDTO);
                     }
                 } else if (numberList.contains(field)) {
-                    this.getNumberAnalysisDTOS(agg, field, detailDTOS);
+                    this.getNumberAnalysisDTOS(agg, field,topN, detailDTOS);
                 } else {
-                    this.getTermCountDTOS(agg, field, detailDTOS);
+                    this.getTermCountDTOS(agg, field,topN, detailDTOS);
                 }
             }
         }
@@ -256,12 +256,12 @@ public class EsCountService {
 
     /**
      * 获取筛选条件
+     *
      * @param taskId
      * @param projectId
      * @return
      */
-    public String getCondition(Integer taskId, Integer projectId) {
-        String searchCondition = "";
+    public String getCondition(String searchCondition, Integer taskId, Integer projectId) {
         if (taskId != null) {
             if (searchCondition != null && !"".equals(searchCondition.trim())) {
                 searchCondition = "taskId = " + taskId + " AND " + searchCondition;
@@ -304,7 +304,13 @@ public class EsCountService {
      * @param field
      * @param detailDTOS
      */
-    public void getTermCountDTOS(Aggregate agg, String field, List<EsCountDetailDTO> detailDTOS) {
+    public void getTermCountDTOS(Aggregate agg, String field, Integer topN, List<EsCountDetailDTO> detailDTOS) {
+        EsCountDetailDTO countDTO = new EsCountDetailDTO();
+        countDTO.setField(field);
+        countDTO.setName("其他");
+        countDTO.setNumber(agg.sterms().sumOtherDocCount());
+        countDTO.setTopN(topN);
+        detailDTOS.add(countDTO);
         List<StringTermsBucket> list = agg.sterms().buckets().array();
         list.forEach(bucket -> {
             EsCountDetailDTO dto = new EsCountDetailDTO();
@@ -312,6 +318,7 @@ public class EsCountService {
             Aggregate aggregate = bucket.aggregations().get("filter_agg");
             dto.setName(bucket.key().stringValue());
             dto.setNumber(bucket.docCount());
+            dto.setTopN(topN);
             if (aggregate != null) {
                 dto.setNumber(aggregate.filter().docCount());
             }
@@ -328,7 +335,8 @@ public class EsCountService {
      * @param field
      * @param detailDTOS
      */
-    public void getChildCountDTOS(Aggregate agg, String field,Integer fieldType, List<EsCountDetailDTO> detailDTOS, EsCountDTO esCountDTO) {
+    public void getChildCountDTOS(Aggregate agg, String field,Integer fieldType, Integer topN,
+                                  List<EsCountDetailDTO> detailDTOS, EsCountDTO esCountDTO) {
         esCountDTO.setAllNumber(agg.children().docCount());
         Aggregate childAgg = agg.children().aggregations().get("childAgg");
         List<StringTermsBucket> list = childAgg.sterms().buckets().array();
@@ -344,6 +352,7 @@ public class EsCountService {
                     dto.setName(termsBucket.key().stringValue());
                     dto.setNumber(termsBucket.docCount());
                     dto.setNumber(count);
+                    dto.setTopN(topN);
                     if (dto.getNumber() > 0) {
                         detailDTOS.add(dto);
                         if (fieldType == null || fieldType != 6) {
@@ -352,6 +361,7 @@ public class EsCountService {
                             detail.setField(field);
                             detail.setName("未选择");
                             detail.setNumber(docCount);
+                            detail.setTopN(topN);
                             if (!detailDTOS.contains(detail)) {
                                 detailDTOS.add(detail);
                             }
@@ -369,7 +379,8 @@ public class EsCountService {
      * @param field
      * @param detailDTOS
      */
-    public void getChildAnalysisDTOS(Aggregate agg, String field,Integer fieldType, List<EsCountDetailDTO> detailDTOS, EsCountDTO esCountDTO) {
+    public void getChildAnalysisDTOS(Aggregate agg, String field,Integer fieldType,Integer topN,
+                                     List<EsCountDetailDTO> detailDTOS, EsCountDTO esCountDTO) {
         Aggregate childAgg = agg.children().aggregations().get("childAgg");
         List<StringTermsBucket> list = childAgg.sterms().buckets().array();
         list.forEach(bucket -> {
@@ -381,6 +392,7 @@ public class EsCountService {
                 dto.setField(field);
                 dto.setName(termsBucket.key().stringValue());
                 dto.setNumber(termsBucket.docCount());
+                dto.setTopN(topN);
                 if (dto.getNumber() > 0) {
                     detailDTOS.add(dto);
                     if (fieldType == null || fieldType != 6) {
@@ -389,6 +401,7 @@ public class EsCountService {
                         detail.setField(field);
                         detail.setName("未选择");
                         detail.setNumber(docCount);
+                        detail.setTopN(topN);
                         if (!detailDTOS.contains(detail)) {
                             detailDTOS.add(detail);
                         }
@@ -405,13 +418,14 @@ public class EsCountService {
      * @param field
      * @param detailDTOS
      */
-    public void getNumberAnalysisDTOS(Aggregate agg, String field, List<EsCountDetailDTO> detailDTOS) {
+    public void getNumberAnalysisDTOS(Aggregate agg, String field,Integer topN, List<EsCountDetailDTO> detailDTOS) {
         List<RangeBucket> list = agg.range().buckets().array();
         for (RangeBucket bucket : list) {
             EsCountDetailDTO dto = new EsCountDetailDTO();
             dto.setField(field);
             dto.setName(bucket.key());
             dto.setNumber(bucket.docCount());
+            dto.setTopN(topN);
             if (dto.getNumber() > 0) {
                 detailDTOS.add(dto);
             }
@@ -451,10 +465,12 @@ public class EsCountService {
                     dto.setField(field);
                     dto.setName(year + "-H1");
                     dto.setNumber(h1Count);
+                    dto.setTopN(topN);
                     EsCountDetailDTO dto2 = new EsCountDetailDTO();
                     dto2.setField(field);
                     dto2.setName(year + "-H2");
                     dto2.setNumber(h2Count);
+                    dto2.setTopN(topN);
                     if (month.before(halfYearDate)) {
                         h1Count += histogramBucket.docCount();
                         dto.setNumber(h1Count);
@@ -482,6 +498,7 @@ public class EsCountService {
                 Aggregate aggregate = bucket.aggregations().get("filter_agg");
                 dto.setName(bucket.keyAsString());
                 dto.setNumber(bucket.docCount());
+                dto.setTopN(topN);
                 if (aggregate != null) {
                     dto.setNumber(aggregate.filter().docCount());
                 }
@@ -515,6 +532,7 @@ public class EsCountService {
             dto.setField(field);
             dto.setName(bucket.key());
             dto.setNumber(bucket.docCount());
+            dto.setTopN(topN);
             if (dto.getNumber() > 0) {
                 esCountDetailDTOS.add(dto);
             }
@@ -533,7 +551,7 @@ public class EsCountService {
      * @param field
      * @param detailDTOS
      */
-    public void getNestedCountDTOS(Aggregate agg, String field, List<EsCountDetailDTO> detailDTOS) {
+    public void getNestedCountDTOS(Aggregate agg, String field,Integer topN, List<EsCountDetailDTO> detailDTOS) {
         Aggregate termsAgg = agg.nested().aggregations().get("terms_agg");
         List<StringTermsBucket> list = termsAgg.sterms().buckets().array();
         list.forEach(bucket -> {
@@ -542,6 +560,7 @@ public class EsCountService {
             Aggregate aggregate = bucket.aggregations().get("filter_agg");
             dto.setName(bucket.key().stringValue());
             dto.setNumber(bucket.docCount());
+            dto.setTopN(topN);
             if (aggregate != null) {
                 dto.setNumber(aggregate.filter().docCount());
             }

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

@@ -38,16 +38,13 @@ 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.*;
 
 
 @Service
 @RequiredArgsConstructor(onConstructor_ = {@Lazy})
 public class EsService {
-
+    public final List<String> dateList = Arrays.asList("AD", "PD", "GD", "EXD", "PAD", "PED", "PPD", "EPD");
     private final ElasticsearchClient client;
 
     @Autowired
@@ -126,7 +123,7 @@ public class EsService {
      */
     public PatentDTO esSearch(QueryRequest queryRequest) throws Exception {
         PatentDTO dto = new PatentDTO();
-        Integer taskId =queryRequest.getTaskId();
+        Integer taskId = queryRequest.getTaskId();
         String searchCondition = "";
         Integer projectId = queryRequest.getProjectId();
         Long current = queryRequest.getCurrent();
@@ -134,6 +131,9 @@ public class EsService {
         //判断表达式
         if (queryRequest instanceof StringRequest) {
             searchCondition = ((StringRequest) queryRequest).getSearchQuery();
+//            if (searchCondition.contains("~")) {
+//                searchCondition = this.getDateRangeStr(searchCondition);
+//            }
         } else if (queryRequest instanceof MapRequest) {
             Map<String, Object> map = ((MapRequest) queryRequest).getSearchQuery();
             StringBuilder stringBuilder = new StringBuilder();
@@ -151,14 +151,13 @@ public class EsService {
         if (!CollectionUtils.isEmpty(customFields)) {
             searchCondition = this.parseCustomField(customFields);
         }
-        if( taskId != null){
+        if (taskId != null) {
             if (searchCondition != null && !"".equals(searchCondition.trim())) {
                 searchCondition = "taskId = " + taskId + " AND " + searchCondition;
             } else {
                 searchCondition = "taskId = " + taskId;
             }
-        }
-        else {
+        } else {
             if (projectId != null) {
                 if (searchCondition != null && !"".equals(searchCondition.trim())) {
                     searchCondition = "projectId = " + projectId + " AND " + searchCondition;
@@ -228,6 +227,63 @@ public class EsService {
         return dto;
     }
 
+    public String getDateRangeStr(String str) {
+        String condition = "";
+        if (str.contains("AD")) {
+            String s = str.substring(str.indexOf("AD")).toUpperCase(Locale.ROOT);
+            String key = s.substring(0, s.indexOf("="));
+            String s1 = s.substring(s.indexOf("=") + 1, s.indexOf("~"));
+            String s2 = "";
+            if (s.contains("AND")) {
+                s2 = s.substring(s.indexOf("~") + 1, s.indexOf("AND"));
+            } else {
+                s2 = s.substring(s.indexOf("~") + 1).trim();
+            }
+            int index = str.indexOf(key);
+            int index1 = str.indexOf(s2) + s2.length();
+            String substring = str.substring(index, index1);
+            String concat = key.concat(">=").concat(s1).concat(" and ").concat(key).concat("<=").concat(s2);
+            String replace = str.replace(substring, concat);
+            str = replace;
+        }
+        if (str.contains("PD")) {
+            String s = str.substring(str.indexOf("PD")).toUpperCase(Locale.ROOT);
+            String key = s.substring(0, s.indexOf("="));
+            String s1 = s.substring(s.indexOf("=") + 1, s.indexOf("~"));
+            String s2 = "";
+            if (s.contains("AND")) {
+                s2 = s.substring(s.indexOf("~") + 1, s.indexOf("AND"));
+            } else {
+                s2 = s.substring(s.indexOf("~") + 1).trim();
+            }
+            int index = str.indexOf(key);
+            int index1 = str.indexOf(s2) + s2.length();
+            String substring = str.substring(index, index1);
+            String concat = key.concat(">=").concat(s1).concat(" and ").concat(key).concat("<=").concat(s2);
+            String replace = str.replace(substring, concat);
+            str = replace;
+        }
+        if (str.contains("GD")) {
+            String s = str.substring(str.indexOf("GD")).toUpperCase(Locale.ROOT);
+            String key = s.substring(0, s.indexOf("="));
+            String s1 = s.substring(s.indexOf("=") + 1, s.indexOf("~"));
+            String s2 = "";
+            if (s.contains("AND")) {
+                s2 = s.substring(s.indexOf("~") + 1, s.indexOf("AND"));
+            } else {
+                s2 = s.substring(s.indexOf("~") + 1).trim();
+            }
+            int index = str.indexOf(key);
+            int index1 = index + key.length() + s1.length() + 2 + s2.length();
+            String substring = str.substring(index, index1);
+            String concat = key.concat(">=").concat(s1).concat(" and ").concat(key).concat("<=").concat(s2);
+            String replace = str.replace(substring, concat);
+            str = replace;
+        }
+        condition = str;
+        return condition;
+    }
+
     /**
      * 解析自定义栏位和值
      *
@@ -244,10 +300,10 @@ public class EsService {
                 EsCustomFieldValueDTO customField = customFields.get(i);
                 if (i != n) {
                     builder.append(" ").append("and").append(" ").append("(");
-                    this.appendStr(customField, builder, m,customField.getIfHaveChild());
+                    this.appendStr(customField, builder, m, customField.getIfHaveChild());
                 } else {
                     builder.append("(");
-                    this.appendStr(customField, builder, m,customField.getIfHaveChild());
+                    this.appendStr(customField, builder, m, customField.getIfHaveChild());
                 }
             }
         } else {
@@ -255,10 +311,10 @@ public class EsService {
                 EsCustomFieldValueDTO customField = customFields.get(i);
                 if (i != n) {
                     builder.append(" ").append("and").append(" ");
-                    this.appendStr(customField, builder, m,customField.getIfHaveChild());
+                    this.appendStr(customField, builder, m, customField.getIfHaveChild());
                 } else {
                     builder.append("(");
-                    this.appendStr(customField, builder, m,customField.getIfHaveChild());
+                    this.appendStr(customField, builder, m, customField.getIfHaveChild());
                 }
             }
         }
@@ -268,7 +324,7 @@ public class EsService {
         return builder.toString();
     }
 
-    public void appendStr(EsCustomFieldValueDTO customField, StringBuilder builder, int m,boolean ifHaveChild) {
+    public void appendStr(EsCustomFieldValueDTO customField, StringBuilder builder, int m, boolean ifHaveChild) {
         builder.append("field").append("=").append(customField.getFieldId());
         List<String> values = customField.getFieldValue();
         if (!CollectionUtils.isEmpty(values)) {
@@ -789,9 +845,9 @@ public class EsService {
             builder.index("legal_event");
             //申请号
             Query q1 = QueryBuilders.term(t -> t.field("app_no").value(starPatentVO.getApplicationNo()));
-            Query q2 =QueryBuilders.term((t->t.field("grant_no").value(starPatentVO.getPublicAccreditNo())));
-            Query q3 =QueryBuilders.term((t->t.field("public_no").value(starPatentVO.getPublicNo())));
-            Query bool = QueryBuilders.bool(i -> i.should(q1,q2,q3));
+            Query q2 = QueryBuilders.term((t -> t.field("grant_no").value(starPatentVO.getPublicAccreditNo())));
+            Query q3 = QueryBuilders.term((t -> t.field("public_no").value(starPatentVO.getPublicNo())));
+            Query bool = QueryBuilders.bool(i -> i.should(q1, q2, q3));
             builder.query(bool);
             SearchResponse<LegalEvent> response = null;
             try {
@@ -808,21 +864,21 @@ public class EsService {
 
             List<ChinaLeagalStatus> chinaLeagalStatuses = JSON.parseArray(cnLegalApiStr, ChinaLeagalStatus.class);
             chinaLeagalStatuses.forEach(item -> {
-                    LegalEvent tem = legalEvents.stream().filter(em -> em.getEventDate() != null && em.getEventDate().compareTo(item.getLegalDate()) == 0).findFirst().orElse(null);
-                    if (tem == null) {
-                        LegalEvent legalEvent1 = new LegalEvent();
-                        legalEvent1.setEventDate(item.getLegalDate());
-                        legalEvent1.setCode(item.getLegalCode());
-                        legalEvent1.setAppNo(starPatentVO.getApplicationNo());
-                        legalEvent1.setGrantNo(starPatentVO.getPublicAccreditNo());
-                        legalEvent1.setPublicNo(starPatentVO.getPublicNo());
-                        legalEvent1.setDescription(item.getLegalStatusInfo());
-                        legalEvent1.setName(item.getLegalStatus());
-                        try {
-                            this.addLegalEvent(legalEvent1);
-                        } catch (Exception e) {
-                        }
+                LegalEvent tem = legalEvents.stream().filter(em -> em.getEventDate() != null && em.getEventDate().compareTo(item.getLegalDate()) == 0).findFirst().orElse(null);
+                if (tem == null) {
+                    LegalEvent legalEvent1 = new LegalEvent();
+                    legalEvent1.setEventDate(item.getLegalDate());
+                    legalEvent1.setCode(item.getLegalCode());
+                    legalEvent1.setAppNo(starPatentVO.getApplicationNo());
+                    legalEvent1.setGrantNo(starPatentVO.getPublicAccreditNo());
+                    legalEvent1.setPublicNo(starPatentVO.getPublicNo());
+                    legalEvent1.setDescription(item.getLegalStatusInfo());
+                    legalEvent1.setName(item.getLegalStatus());
+                    try {
+                        this.addLegalEvent(legalEvent1);
+                    } catch (Exception e) {
                     }
+                }
 
             });
 
@@ -862,7 +918,7 @@ public class EsService {
                 String claim = StringUtils.strip(JSON.toJSONString(esMess.getClaim()), "[]");
                 ContentDetailDTO contentDetailDTO = JSONObject.parseObject(claim, ContentDetailDTO.class);
                 if (contentDetailDTO.getIfOrigin()) {
-                    dto.setClaim(contentDetailDTO.getTextContent().replaceAll("\t",""));
+                    dto.setClaim(contentDetailDTO.getTextContent().replaceAll("\t", ""));
                 }
             }
         }
@@ -880,6 +936,7 @@ public class EsService {
 
     /**
      * 根据专利号查询出其他专利号
+     *
      * @param patentNos
      * @return
      * @throws IOException

+ 16 - 4
src/main/java/cn/cslg/pas/service/query/FormatQueryService.java

@@ -419,13 +419,15 @@ public class FormatQueryService {
                         case "NOT":
                             Query temQ = (q1 == null) ? q2 : q1;
                             return QueryBuilders.bool(i -> i.mustNot(temQ));
+                        case "TO":
+                            return QueryBuilders.bool(i -> i.must(q1, q2));
                         default:
                             return null;
                     }
 
                 } else {
                     if (operate1.gettype().equals(enuType.Assignment)) {
-                        return HandleValueNode(((valueNode) Left).getvalue(), operate1.getCode(), Right, configName);
+                        return HandleValueNode(((valueNode) Left).getvalue(), operate1.getCode(), Right, configName, "", "");
                     } else {
                         return null;
                     }
@@ -436,15 +438,19 @@ public class FormatQueryService {
         }
     }
 
-    public Query HandleValueNode(String field, String operate, treeNode valeNode, String configName) throws ParseException {
+    public Query HandleValueNode(String field, String operate, treeNode valeNode, String configName,String op,String dp) throws ParseException {
         if (valeNode == null) {
             return null;
         } else {
             if (valeNode instanceof operateNode) {
                 operate operate1 = ((operateNode) valeNode).getoperate();
+                if (operate1.getShowName().equals("TO")) {
+                    op = ">=";
+                    dp = "<=";
+                }
                 if (operate1.gettype().equals(enuType.Logic)) {
-                    Query q1 = this.HandleValueNode(field, operate, ((treeNode) valeNode).getLeft(), configName);
-                    Query q2 = this.HandleValueNode(field, operate, (treeNode) valeNode.getRight(), configName);
+                    Query q1 = this.HandleValueNode(field, operate, ((treeNode) valeNode).getLeft(), configName,op,"");
+                    Query q2 = this.HandleValueNode(field, operate, (treeNode) valeNode.getRight(), configName,"",dp);
                     switch (operate1.getShowName()) {
                         case "AND":
                             return  QueryBuilders.bool(i -> i.must(q1, q2));
@@ -453,6 +459,8 @@ public class FormatQueryService {
                         case "NOT":
                             Query temQ = (q1 == null) ? q2 : q1;
                             return QueryBuilders.bool(i -> i.mustNot(temQ));
+                        case "TO":
+                            return QueryBuilders.bool(i -> i.must(q1, q2));
                         default:
                             return null;
                     }
@@ -460,6 +468,10 @@ public class FormatQueryService {
                     return null;
                 }
             } else {
+                if (StringUtils.isNotEmpty(op)) {
+                    operate = op;
+                } else if (StringUtils.isNotEmpty(dp))
+                    operate = dp;
                 //比较运算符
                 IQueryBuilder iQueryBuilder = null;
                 String json = CommonService.readJsonFile(configName + ".json");

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

@@ -12,6 +12,8 @@ import cn.cslg.pas.common.dto.es.EsCustomFieldValueDTO;
 import cn.cslg.pas.common.model.cronModel.Records;
 import cn.cslg.pas.common.model.request.*;
 import cn.cslg.pas.common.utils.Response;
+import cn.cslg.pas.common.utils.parseQueryToTree.expressManager;
+import cn.cslg.pas.common.utils.parseQueryToTree.treeNode;
 import cn.cslg.pas.common.vo.business.EsCountVO;
 import cn.cslg.pas.common.vo.business.PatentKinVO;
 import cn.cslg.pas.common.vo.business.PatentNoVO;
@@ -66,6 +68,7 @@ public class EventServiceTests {
 
     @Autowired
     private ProductMarketDataService productMarketDataService;
+
     @Test
     void test() throws Exception {
         StringRequest queryRequest = new StringRequest();
@@ -82,17 +85,18 @@ public class EventServiceTests {
         queryRequest.setOrderDTOList(dtos);
         queryRequest.setCurrent(Long.parseLong("1"));
         queryRequest.setSize(Long.parseLong("10"));
-       Response response = eventController.queryEvent(queryRequest);
-       System.out.println(response); }
+        Response response = eventController.queryEvent(queryRequest);
+        System.out.println(response);
+    }
 
     @Test
-        void add() throws Exception {
+    void add() throws Exception {
         JSONObject jsonObj = new JSONObject();
         jsonObj.put("name", "事件4");
         jsonObj.put("description", "描述1");
         jsonObj.put("clientId", 1);
         jsonObj.put("scenarioId", 2);
-        jsonObj.put("eventDate","");
+        jsonObj.put("eventDate", "");
         String json_to_string = JSONObject.toJSONString(jsonObj);
         List<MultipartFile> list = new ArrayList<>();
         File file = new File("C:\\Users\\admin\\Desktop\\test.txt");
@@ -131,7 +135,7 @@ public class EventServiceTests {
         StringGroupRequest groupRequest = new StringGroupRequest();
 
         groupRequest.setGroupBy("groupMonthTime");
-        Records records=(Records) productMarketDataService.getGroup(groupRequest,"productMarketData");
+        Records records = (Records) productMarketDataService.getGroup(groupRequest, "productMarketData");
         System.out.println(records);
     }
 
@@ -175,7 +179,7 @@ public class EventServiceTests {
     }
 
     @Test
-    void getpagetexst() throws  IOException{
+    void getpagetexst() throws IOException {
         //1.添加一批数据(10)
         //2.调用查询取第一页(5笔一页)
         //3.判断5笔数据是正确的;
@@ -189,17 +193,17 @@ public class EventServiceTests {
     @Test
     void add1() throws Exception {
         List<FamilyPatent> list = new ArrayList<>();
-        FamilyPatent patent =new FamilyPatent();
+        FamilyPatent patent = new FamilyPatent();
         patent.setAppNo("CN147258369");
         patent.setGrantNo("CN258369147");
         patent.setPublicNo("CN369258147");
-        FamilyPatent patent1 =new FamilyPatent();
+        FamilyPatent patent1 = new FamilyPatent();
         patent1.setAppNo("US147258369");
         patent1.setGrantNo("US258369147");
         patent1.setPublicNo("US369258147");
         list.add(patent);
         list.add(patent1);
-        PatentFamilyMessage patentFamilyMessage =new PatentFamilyMessage();
+        PatentFamilyMessage patentFamilyMessage = new PatentFamilyMessage();
         patentFamilyMessage.setPatent(list);
         patentFamilyMessage.setFamilyType("test");
         String id = esService.addPatentFamily(patentFamilyMessage);
@@ -290,7 +294,7 @@ public class EventServiceTests {
         dto.setProjectId(83);
         dto.setFieldType(5);
         dto.setFieldId("303");
-        dto.setFieldValue(Arrays.asList("多选1","多选2"));
+        dto.setFieldValue(Arrays.asList("多选1", "多选2"));
         dto.setOptionType(1);
         dto.setPatentNo("CN201910069334.7");
         esCustomFieldService.addCustomField(dto);
@@ -326,6 +330,54 @@ public class EventServiceTests {
 
     @Test
     void test18() {
-//        esService
+        List<String> list = Arrays.asList("AD");
+        if (list.contains("AD")) {
+            String str = "AD=2008~201009";
+            String s = this.get(str);
+            if (s.contains("~")) {
+                int i = s.indexOf("~");
+//                s.substring()
+                String s1 = this.get(s);
+                System.out.println("-------------");
+                System.out.println("s1是:" + s1);
+
+            }
+        } else {
+            System.out.println("DDDDDDDDDDDDDDDDDD");
+        }
+
+    }
+
+    public String get(String str) {
+        int i = str.indexOf("AD");
+        String s = str.substring(str.indexOf("AD")).toUpperCase(Locale.ROOT);
+        int length = s.length();//------
+        String key = s.substring(0, s.indexOf("="));
+        int i2 = s.indexOf("=");
+        String s1 = s.substring(s.indexOf("=") + 1, s.indexOf("~"));
+        String s2 = "";
+        if (s.contains("AND")) {
+            s2 = s.substring(s.indexOf("~") + 1, s.indexOf("AND"));
+        } else {
+            s2 = s.substring(s.indexOf("~") + 1).trim();
+        }
+        int index = str.indexOf(key);
+        int index1 = str.indexOf(s2) + s2.length();
+        int i1 = index + key.length() + 1 + s1.length() + 1 + s2.length();
+        String substring = str.substring(index, i1);
+        String concat = key.concat(">=").concat(s1).concat(" and ").concat(key).concat("<=").concat(s2);
+        System.out.println(concat);
+
+        String replace = str.replace(substring, concat);
+        System.out.println(replace);
+        return replace;
+    }
+
+@Test
+    public void aaaaa() throws Exception {
+        String searchCondition = "AD=[2008~201009]";
+
+        treeNode tree = expressManager.getInstance().Parse(searchCondition, false);
+System.out.println(tree);
     }
 }