Ver código fonte

fixed search

zero 1 ano atrás
pai
commit
f89793ae41

+ 11 - 197
src/main/java/cn/cslg/pas/service/business/es/EsCountService.java

@@ -87,7 +87,7 @@ public class EsCountService {
                         valueDTO.setFieldId(countVO.getFieldId());
                         valueDTO.setFieldValue(Arrays.asList("\""+value+"\""));
                         customFields.add(valueDTO);
-                        this.getDatas(searchCondition, "",customFields, taskId, projectId,
+                        this.getDatas(searchCondition, "",customFields, null, projectId,
                                 esCountVOS, detailDTOS, esCountDTO, value, map);
                     }
                 }
@@ -99,20 +99,19 @@ public class EsCountService {
                     } else {
                         condition = countVO.getField() + " = " + "\""+value+"\"";
                     }
-                    this.getDatas(searchCondition, condition, customFields, taskId, projectId,
+                    this.getDatas(searchCondition, condition, customFields, null, projectId,
                             esCountVOS, detailDTOS, esCountDTO, value, map);
                 }
             }
         } else {
-            this.getDatas(searchCondition, "", customFields, taskId, projectId, countVOS,
+            this.getDatas(searchCondition, "", customFields, null, projectId, countVOS,
                     detailDTOS, esCountDTO, "", map);
         }
         esCountDTO.setDetailDTOS(detailDTOS);
         return esCountDTO;
     }
 
-/*
-    public void getReturnData(String searchCondition,String condition, List<EsCustomFieldValueDTO> customFields, Integer taskId,
+    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 {
 
@@ -124,202 +123,17 @@ public class EsCountService {
             }
         }
 
+//        if (!CollectionUtils.isEmpty(customFields)) {
+//            searchCondition = esService.parseCustomField(customFields,projectId,taskId);
+//        }
         if (!CollectionUtils.isEmpty(customFields)) {
-            searchCondition = esService.parseCustomField(customFields,projectId,taskId);
-        }
-
-        searchCondition = this.getCondition(searchCondition, taskId, projectId);
-
-        SearchRequest.Builder builder = new SearchRequest.Builder();
-        //设置查询索引
-        builder.index("patent");
-        Query query = null;
-        if (StringUtils.isNotEmpty(searchCondition)) {
-            //1. 解析检索条件
-            treeNode tree = expressManager.getInstance().Parse(searchCondition, false);
-            //格式化检索式
-            //3. 从es中检索数据
-            query = formatQueryService.EsQueryToQuery((operateNode) tree, "patent",projectId);
-        }
-
-        for (EsCountVO countVO : countVOS) {
-            String field = countVO.getField();
-            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);
-            if (query != null) {
-                Query finalQuery = query;
-                Aggregation finalAggregation = aggregation;
-                Aggregation filtersAgg = new Aggregation.Builder().filters(new FiltersAggregation.Builder()
-                        .filters(i -> i.array(Arrays.asList(finalQuery))).build())
-                        .aggregations(new HashMap() {{
-                            put("filters_agg", finalAggregation);
-                        }}).build();
-                builder.aggregations("Agg", filtersAgg);
-            } else {
-                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 (query != null) {
-                String finalSearchCondition = searchCondition;
-                if (StringUtils.isNotEmpty(field)) {
-                    List<FiltersBucket> filtersBuckets = agg.filters().buckets().array();
-                    if (dateList.contains(field)) {
-                        if (CollectionUtils.isEmpty(values)) {
-                            filtersBuckets.forEach(filtersBucket -> {
-                                Aggregate filtersAgg = filtersBucket.aggregations().get("filters_agg");
-                                try {
-                                    this.getDateCountDTOS(filtersAgg, field, topN, format, detailDTOS, esCountDTO,valueOne,valueTwo);
-                                } catch (ParseException e) {
-                                    e.printStackTrace();
-                                }
-                            });
-                        } else {
-                            filtersBuckets.forEach(filtersBucket -> {
-                                Aggregate filtersAgg = filtersBucket.aggregations().get("filters_agg");
-                                this.getDateAnalysisDTOS(filtersAgg, field, topN, detailDTOS, esCountDTO, firstName, map, values);
-                            });
-                        }
-                    } else if (nestedList.contains(field)) {
-                        filtersBuckets.forEach(filtersBucket -> {
-                            Aggregate filtersAgg = filtersBucket.aggregations().get("filters_agg");
-                            this.getNestedCountDTOS(filtersAgg, field, topN, detailDTOS, esCountDTO,
-                                    firstName, map, values,valueOne);
-                            if (!CollectionUtils.isEmpty(values)) {
-                                esCountDTO.setAllNumber(filtersAgg.nested().docCount());
-                            }
-                        });
-                    } else if (nestDateList.contains(field)) {
-                        if (CollectionUtils.isEmpty(values)) {
-                            filtersBuckets.forEach(filtersBucket -> {
-                                Aggregate filtersAgg = filtersBucket.aggregations().get("filters_agg");
-                                Aggregate termsAgg = filtersAgg.nested().aggregations().get("terms_agg");
-                                try {
-                                    this.getDateCountDTOS(termsAgg, field, topN, format, detailDTOS, esCountDTO,valueOne,valueTwo);
-                                } catch (ParseException e) {
-                                    e.printStackTrace();
-                                }
-                            });
-                        } else {
-                            filtersBuckets.forEach(filtersBucket -> {
-                                Aggregate filtersAgg = filtersBucket.aggregations().get("filters_agg");
-                                Aggregate termsAgg = filtersAgg.nested().aggregations().get("terms_agg");
-                                this.getDateAnalysisDTOS(termsAgg, field, topN, detailDTOS, esCountDTO, firstName, map, values);
-                            });
-                        }
-                    } else if (nestChildList.contains(field)) {
-                        filtersBuckets.forEach(filtersBucket -> {
-                            Aggregate filtersAgg = filtersBucket.aggregations().get("filters_agg");
-                            Aggregate childAgg = filtersAgg.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)) {
-                            Integer finalFieldType = fieldType;
-                            filtersBuckets.forEach(filtersBucket -> {
-                                Aggregate filtersAgg = filtersBucket.aggregations().get("filters_agg");
-                                try {
-                                    this.getChildCountDTOS(filtersAgg, field, finalFieldType, topN, detailDTOS, esCountDTO,projectId,taskId);
-                                } catch (Exception e) {
-                                    e.printStackTrace();
-                                }
-                            });
-                        } else {
-                            Integer finalFieldType1 = fieldType;
-                            filtersBuckets.forEach(filtersBucket -> {
-                                Aggregate filtersAgg = filtersBucket.aggregations().get("filters_agg");
-                                this.getChildAnalysisDTOS(filtersAgg, field, finalFieldType1, topN,
-                                        detailDTOS, esCountDTO, firstName, map, values);
-                            });
-                        }
-                    } else if (numberList.contains(field)) {
-                        if (CollectionUtils.isEmpty(values)) {
-
-                        } else {
-                            filtersBuckets.forEach(filtersBucket -> {
-                                Aggregate filtersAgg = filtersBucket.aggregations().get("filters_agg");
-                                this.getNumberAnalysisDTOS(filtersAgg, field, topN, detailDTOS, esCountDTO, firstName, map, values);
-                            });
-                        }
-                    } else {
-                        filtersBuckets.forEach(filtersBucket -> {
-                            Aggregate filtersAgg = filtersBucket.aggregations().get("filters_agg");
-                            this.getTermCountDTOS(filtersAgg, field, topN, detailDTOS, esCountDTO, firstName, map, values,valueOne);
-                        });
-                    }
-                } else {
-                    this.getFilterCountDTO(agg, finalSearchCondition, detailDTOS);
-                }
-            } else {
-                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)) {
-                    Aggregate termsAgg = agg.nested().aggregations().get("terms_agg");
-                    this.getDateCountDTOS(termsAgg, field, topN, format, detailDTOS, esCountDTO,valueOne,valueTwo);
-                } 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, taskId);
-                    } else {
-                        this.getChildAnalysisDTOS(agg, field, fieldType, topN,
-                                detailDTOS, esCountDTO, firstName, map, values);
-                    }
-                } else if (numberList.contains(field)) {
-                    this.getNumberAnalysisDTOS(agg, field, topN, detailDTOS, esCountDTO, firstName, map, values);
-                } else {
-                    this.getTermCountDTOS(agg, field, topN, detailDTOS, esCountDTO, firstName, map, values,valueOne);
-                }
-            }
-            esCountDTO.setCondition(searchCondition);
-            esCountDTO.setAnalyseMap(map);
-        }
-    }
-*/
-
-    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 {
-
-        if (StringUtils.isNotEmpty(condition)) {
-            if (searchCondition != null && !"".equals(searchCondition.trim())) {
-                searchCondition = condition + " AND " + searchCondition;
+            String customFieldCondition = esService.parseCustomField(customFields, projectId, taskId);
+            if (StringUtils.isNotEmpty(searchCondition)) {
+                searchCondition = searchCondition + " AND " + customFieldCondition;
             } else {
-                searchCondition = condition;
+                searchCondition = customFieldCondition;
             }
         }
-
-        if (!CollectionUtils.isEmpty(customFields)) {
-            searchCondition = esService.parseCustomField(customFields,projectId,taskId);
-        }
-
         searchCondition = this.getCondition(searchCondition, taskId, projectId);
 
         SearchRequest.Builder builder = new SearchRequest.Builder();

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

@@ -169,7 +169,12 @@ public class EsService {
         }
         List<EsCustomFieldValueDTO> customFields = queryRequest.getCustomFields();
         if (!CollectionUtils.isEmpty(customFields)) {
-            searchCondition = this.parseCustomField(customFields,projectId,taskId);
+            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);
 

+ 6 - 6
src/main/resources/application-dev.yml

@@ -1,12 +1,12 @@
 spring:
   rabbitmq:
-    host: 192.168.1.24
+    host: 192.168.2.24
     port: 5672
     username: admin
     password: 123456
   data:
    redis:
-     host: 192.168.1.24
+     host: 192.168.2.24
      port: 6379
      database: 3
      password: Xx0GWxdWQJxx6Swe
@@ -18,7 +18,7 @@ spring:
          max-wait: -1ms
      timeout: 2000ms
   datasource:
-    url: jdbc:mysql://192.168.1.24:3306/pas_prod2?autoReconnect=true&useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=CONVERT_TO_NULL&useSSL=false&serverTimezone=GMT%2B8
+    url: jdbc:mysql://192.168.2.24:3306/pas_prod2?autoReconnect=true&useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=CONVERT_TO_NULL&useSSL=false&serverTimezone=GMT%2B8
     username: root
     password: rrzTwWAYX8Gxh5JH
     driver-class-name: com.mysql.cj.jdbc.Driver
@@ -51,7 +51,7 @@ spring:
             threadsInheritContextClassLoaderOfInitializingThread: true
           dataSource:
             default:
-              URL: jdbc:mysql://192.168.1.24:3306/pas?autoReconnect=true&useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=CONVERT_TO_NULL&useSSL=false&serverTimezone=GMT%2B8
+              URL: jdbc:mysql://192.168.2.24:3306/pas?autoReconnect=true&useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=CONVERT_TO_NULL&useSSL=false&serverTimezone=GMT%2B8
               user: root
               password: rrzTwWAYX8Gxh5JH
               driver: com.mysql.jdbc.Driver
@@ -63,10 +63,10 @@ spring:
       initialize-schema: always
 authorUrl: http://localhost:8871
 PCSUrl: http://localhost:8871
-#OPSUrl: http://192.168.1.24:5001
+#OPSUrl: http://192.168.2.24:5001
 OPSUrl: http://139.224.24.90:5001
 PASUrl: http://localhost:8877
-FMSUrl: http://localhost:8801
+FMSUrl: http://localhost:8802
 FileSource: 1
 ES:
   patentVector: patent_vector

+ 17 - 13
src/main/resources/application-prodNetOut.yml

@@ -1,17 +1,18 @@
 spring:
  data:
-  redis:
-    host: 47.101.137.223
-    port: 6379
-    database: 3
-    password: Xx0GWxdWQJxx6Swe
-    lettuce:
-      pool:
-        max-active: 20
-        max-idle: 20
-        min-idle: 0
-        max-wait: -1ms
-    timeout: 2000ms
+  data:
+    redis:
+      host: 47.101.137.223
+      port: 6379
+      database: 3
+      password: Xx0GWxdWQJxx6Swe
+      lettuce:
+        pool:
+          max-active: 20
+          max-idle: 20
+          min-idle: 0
+          max-wait: -1ms
+      timeout: 2000ms
   datasource:
     url: jdbc:mysql://47.101.137.223:3306/pas_prod2?autoReconnect=true&useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=CONVERT_TO_NULL&useSSL=false&serverTimezone=GMT%2B8
     username: root
@@ -32,4 +33,7 @@ OPSUrl: http://139.224.24.90:5001
 PASUrl: http://localhost:8877
 RMSUrl: http://localhost:8872
 FMSUrl: http://localhost:8801
-FileSource: 3
+FileSource: 3
+ES:
+  patent: patent
+  config: es-cn-em93o8856000ho9e7.public.elasticsearch.aliyuncs.com

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

@@ -28,7 +28,7 @@ spring:
     date-format: yyyy-MM-dd HH:mm:ss
     time-zone: Asia/Shanghai
 logging:
-  config: classpath:config/
+#  config: classpath:config/
   level:
     cn.cslg.pas.mapper: debug
 #mybatis