zero 1 éve
szülő
commit
b3d4acda2a

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

@@ -11,13 +11,11 @@ public class EsCountVO {
     //栏位
     private String fieldId;
     //自定义栏位类型
-    private Integer fieldType;
+    private String fieldType;
     //过滤条件 ----统计搜索的栏位值1
     private String valueOne;
     //过滤条件 -----统计搜索的栏位值2
     private String valueTwo;
-    //过滤条件
-    private String filterCondition;
     //top
     private Integer topN = 10;
     //开关

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

@@ -75,7 +75,7 @@ public class PatentController {
         return Response.success(records);
     }
 
-    @Operation(summary = "聚合统计")
+    @Operation(summary = "专利的聚合统计")
     @PostMapping("/esCountAnalysis")
     public Response esCountAnalysis(@RequestBody EsAllCountVO countVO) throws Exception {
         EsCountDTO dto = esCountService.esCountAnalysis(countVO);

+ 0 - 1
src/main/java/cn/cslg/pas/factorys/EsCountAnalyseBuilderFactory/ChildCountAnalysisBuilder.java

@@ -8,7 +8,6 @@ import org.apache.commons.lang3.StringUtils;
 import org.springframework.stereotype.Component;
 import org.springframework.util.CollectionUtils;
 
-import java.text.ParseException;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;

+ 3 - 0
src/main/java/cn/cslg/pas/factorys/EsCountAnalyseBuilderFactory/DateCountAnalyssBuilder.java

@@ -1,8 +1,10 @@
 package cn.cslg.pas.factorys.EsCountAnalyseBuilderFactory;
 
+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;
+import co.elastic.clients.util.NamedValue;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.stereotype.Component;
 import org.springframework.util.CollectionUtils;
@@ -29,6 +31,7 @@ public class DateCountAnalyssBuilder implements IEsCountAnalysisBuilder {
     @Override
     public Aggregation createCountAnalyseAgg() throws Exception {
         Aggregation aggregation = null;
+//        NamedValue<SortOrder> orderNamedValue = NamedValue.of(field, SortOrder.Desc);
         if (StringUtils.isNotEmpty(valueOne) && StringUtils.isNotEmpty(valueTwo)) {
             String end = String.valueOf(Integer.parseInt(valueTwo) + 1);
             Query query = QueryBuilders.range(j -> j.field(field).from(valueOne).to(end).format("yyyy"));

+ 108 - 66
src/main/java/cn/cslg/pas/service/business/es/EsCountService.java

@@ -65,21 +65,7 @@ public class EsCountService {
         }
         Integer taskId = vo.getTaskId();
         Integer projectId = vo.getProjectId();
-        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;
-                }
-            }
-        }
+        searchCondition = this.getCondition(taskId, projectId);
 
         SearchRequest.Builder builder = new SearchRequest.Builder();
         //设置查询索引
@@ -100,39 +86,14 @@ public class EsCountService {
         for (EsCountVO countVO : countVOS) {
             String field = countVO.getField();
             Integer topN = countVO.getTopN();
-            Boolean ifHaveChild = countVO.getIfHaveChild();
-            String fieldId = countVO.getFieldId();
-            Integer fieldType = countVO.getFieldType();
+            Integer fieldType = null;
+            String type = countVO.getFieldType();
+            if (StringUtils.isNotEmpty(type) && type.equals("tree")) {
+                fieldType = 6;
+            }
             String format = countVO.getFormat();
-            String valueOne = countVO.getValueOne();
-            String valueTwo = countVO.getValueTwo();
             List<String> values = countVO.getValues();
-
-            IEsCountAnalysisBuilder iEsCountAnalysisBuilder = null;
-            String json = CommonService.readJsonFile("esCountAnalysis.json");
-            List<EsConfigVO> esConfigVOS = JSON.parseArray(json, EsConfigVO.class);
-            EsConfigVO esConfigVO = esConfigVOS.stream().filter(item -> item.getField().equals(field))
-                    .findFirst().orElse(null);
-
-            Aggregation aggregation = null;
-            if (esConfigVO != null) {
-                iEsCountAnalysisBuilder = esCountAnalysisBuilderFactory.getClass(esConfigVO.getEsClass());
-                iEsCountAnalysisBuilder.setField(esConfigVO.getEsField());
-                iEsCountAnalysisBuilder.setValueOne(valueOne);
-                iEsCountAnalysisBuilder.setValueTwo(valueTwo);
-                iEsCountAnalysisBuilder.setValues(values);
-                iEsCountAnalysisBuilder.setFieldId(fieldId);
-                iEsCountAnalysisBuilder.setFieldType(String.valueOf(fieldType));
-                iEsCountAnalysisBuilder.setTopN(topN);
-                iEsCountAnalysisBuilder.setFormat(format);
-                iEsCountAnalysisBuilder.setIfHaveChild(ifHaveChild);
-                if (iEsCountAnalysisBuilder.getField().contains(".")) {
-                    String path = iEsCountAnalysisBuilder.getField()
-                            .substring(0, iEsCountAnalysisBuilder.getField().indexOf("."));
-                    iEsCountAnalysisBuilder.setPath(path);
-                }
-                aggregation = iEsCountAnalysisBuilder.createCountAnalyseAgg();
-            }
+            Aggregation aggregation = this.getAggregation(countVO);
             if (query != null) {
                 Query finalQuery = query;
                 Aggregation finalAggregation = aggregation;
@@ -180,16 +141,18 @@ public class EsCountService {
                         });
                     } else if (childList.contains(field)) {
                         if (CollectionUtils.isEmpty(values)) {
+                            Integer finalFieldType = fieldType;
                             filtersBuckets.forEach(filtersBucket -> {
 //                                this.getFiltersCountDTO(filtersBucket, finalSearchCondition, detailDTOS);
                                 Aggregate filtersAgg = filtersBucket.aggregations().get("filters_agg");
-                                this.getChildCountDTOS(filtersAgg, field, detailDTOS,esCountDTO);
+                                this.getChildCountDTOS(filtersAgg, field, finalFieldType, 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, detailDTOS,esCountDTO);
+                                this.getChildAnalysisDTOS(filtersAgg, field, finalFieldType1, detailDTOS, esCountDTO);
                             });
                         }
                     } else if (numberList.contains(field)) {
@@ -226,9 +189,9 @@ public class EsCountService {
                     }
                 } else if (childList.contains(field)) {
                     if (CollectionUtils.isEmpty(values)) {
-                        this.getChildCountDTOS(agg, field, detailDTOS,esCountDTO);
+                        this.getChildCountDTOS(agg, field, fieldType, detailDTOS, esCountDTO);
                     } else {
-                        this.getChildAnalysisDTOS(agg, field, detailDTOS, esCountDTO);
+                        this.getChildAnalysisDTOS(agg, field, fieldType, detailDTOS, esCountDTO);
                     }
                 } else if (numberList.contains(field)) {
                     this.getNumberAnalysisDTOS(agg, field, detailDTOS);
@@ -243,6 +206,81 @@ public class EsCountService {
     }
 
     /**
+     * 查询共用Aggregation
+     * @param countVO
+     * @return
+     * @throws Exception
+     */
+    public Aggregation getAggregation(EsCountVO countVO) throws Exception {
+        String field = countVO.getField();
+        Integer topN = countVO.getTopN();
+        Boolean ifHaveChild = countVO.getIfHaveChild();
+        String fieldId = countVO.getFieldId();
+        Integer fieldType = null;
+        String type = countVO.getFieldType();
+        if (StringUtils.isNotEmpty(type) && type.equals("tree")) {
+            fieldType = 6;
+        }
+        String format = countVO.getFormat();
+        String valueOne = countVO.getValueOne();
+        String valueTwo = countVO.getValueTwo();
+        List<String> values = countVO.getValues();
+
+        IEsCountAnalysisBuilder iEsCountAnalysisBuilder = null;
+        String json = CommonService.readJsonFile("esCountAnalysis.json");
+        List<EsConfigVO> esConfigVOS = JSON.parseArray(json, EsConfigVO.class);
+        EsConfigVO esConfigVO = esConfigVOS.stream().filter(item -> item.getField().equals(field))
+                .findFirst().orElse(null);
+
+        Aggregation aggregation = null;
+        if (esConfigVO != null) {
+            iEsCountAnalysisBuilder = esCountAnalysisBuilderFactory.getClass(esConfigVO.getEsClass());
+            iEsCountAnalysisBuilder.setField(esConfigVO.getEsField());
+            iEsCountAnalysisBuilder.setValueOne(valueOne);
+            iEsCountAnalysisBuilder.setValueTwo(valueTwo);
+            iEsCountAnalysisBuilder.setValues(values);
+            iEsCountAnalysisBuilder.setFieldId(fieldId);
+            iEsCountAnalysisBuilder.setFieldType(String.valueOf(fieldType));
+            iEsCountAnalysisBuilder.setTopN(topN);
+            iEsCountAnalysisBuilder.setFormat(format);
+            iEsCountAnalysisBuilder.setIfHaveChild(ifHaveChild);
+            if (iEsCountAnalysisBuilder.getField().contains(".")) {
+                String path = iEsCountAnalysisBuilder.getField()
+                        .substring(0, iEsCountAnalysisBuilder.getField().indexOf("."));
+                iEsCountAnalysisBuilder.setPath(path);
+            }
+            aggregation = iEsCountAnalysisBuilder.createCountAnalyseAgg();
+        }
+        return aggregation;
+    }
+
+    /**
+     * 获取筛选条件
+     * @param taskId
+     * @param projectId
+     * @return
+     */
+    public String getCondition(Integer taskId, Integer projectId) {
+        String searchCondition = "";
+        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;
+                }
+            }
+        }
+        return searchCondition;
+    }
+
+    /**
      * 获取Filter聚合返回数据
      *
      * @param agg
@@ -290,7 +328,7 @@ public class EsCountService {
      * @param field
      * @param detailDTOS
      */
-    public void getChildCountDTOS(Aggregate agg, String field, List<EsCountDetailDTO> detailDTOS, EsCountDTO esCountDTO) {
+    public void getChildCountDTOS(Aggregate agg, String field,Integer fieldType, List<EsCountDetailDTO> detailDTOS, EsCountDTO esCountDTO) {
         esCountDTO.setAllNumber(agg.children().docCount());
         Aggregate childAgg = agg.children().aggregations().get("childAgg");
         List<StringTermsBucket> list = childAgg.sterms().buckets().array();
@@ -308,13 +346,15 @@ public class EsCountService {
                     dto.setNumber(count);
                     if (dto.getNumber() > 0) {
                         detailDTOS.add(dto);
-                        Long docCount = aggregate.sterms().sumOtherDocCount();
-                        EsCountDetailDTO detail = new EsCountDetailDTO();
-                        detail.setField(field);
-                        detail.setName("未选择");
-                        detail.setNumber(docCount);
-                        if (!detailDTOS.contains(detail)) {
-                            detailDTOS.add(detail);
+                        if (fieldType != 6) {
+                            Long docCount = aggregate.sterms().sumOtherDocCount();
+                            EsCountDetailDTO detail = new EsCountDetailDTO();
+                            detail.setField(field);
+                            detail.setName("未选择");
+                            detail.setNumber(docCount);
+                            if (!detailDTOS.contains(detail)) {
+                                detailDTOS.add(detail);
+                            }
                         }
                     }
                 }
@@ -329,7 +369,7 @@ public class EsCountService {
      * @param field
      * @param detailDTOS
      */
-    public void getChildAnalysisDTOS(Aggregate agg, String field, List<EsCountDetailDTO> detailDTOS, EsCountDTO esCountDTO) {
+    public void getChildAnalysisDTOS(Aggregate agg, String field,Integer fieldType, List<EsCountDetailDTO> detailDTOS, EsCountDTO esCountDTO) {
         Aggregate childAgg = agg.children().aggregations().get("childAgg");
         List<StringTermsBucket> list = childAgg.sterms().buckets().array();
         list.forEach(bucket -> {
@@ -343,13 +383,15 @@ public class EsCountService {
                 dto.setNumber(termsBucket.docCount());
                 if (dto.getNumber() > 0) {
                     detailDTOS.add(dto);
-                    Long docCount = aggregate.sterms().sumOtherDocCount();
-                    EsCountDetailDTO detail = new EsCountDetailDTO();
-                    detail.setField(field);
-                    detail.setName("未选择");
-                    detail.setNumber(docCount);
-                    if (!detailDTOS.contains(detail)) {
-                        detailDTOS.add(detail);
+                    if (fieldType != 6) {
+                        Long docCount = aggregate.sterms().sumOtherDocCount();
+                        EsCountDetailDTO detail = new EsCountDetailDTO();
+                        detail.setField(field);
+                        detail.setName("未选择");
+                        detail.setNumber(docCount);
+                        if (!detailDTOS.contains(detail)) {
+                            detailDTOS.add(detail);
+                        }
                     }
                 }
             });

+ 4 - 0
src/main/java/cn/cslg/pas/service/common/PersonFieldService.java

@@ -222,6 +222,10 @@ public class PersonFieldService {
                                 queryFieldsVO1.setGroup("technical");
                                 queryFieldsVO1.setType("tree");
                                 break;
+                            default:
+                                queryFieldsVO1.setGroup("nos");
+                                queryFieldsVO1.setType("String");
+                                break;
                         }
                         //装载id
                         queryFieldsVO1.setField(i.getId().toString());

+ 165 - 3
src/main/resources/jsons/patent.json

@@ -62,7 +62,7 @@
     "ifGroup": "false",
     "ifShow": "true",
     "ifAsCondition": "true",
-    "ifStats": "false"
+    "ifStats": "true"
   },
   {
     "name": "申请日",
@@ -75,7 +75,7 @@
     "ifGroup": "false",
     "ifShow": "true",
     "ifAsCondition": "true",
-    "ifStats": "false"
+    "ifStats": "true"
   },
   {
     "name": "授权日",
@@ -88,7 +88,7 @@
     "ifGroup": "false",
     "ifShow": "true",
     "ifAsCondition": "true",
-    "ifStats": "false"
+    "ifStats": "true"
   },
   {
     "name": "家族数量",
@@ -178,6 +178,7 @@
     "ifSearch": "false",
     "ifGroup": "false",
     "ifShow": "true",
+    "ifStats": "true",
     "ifAsCondition": "true"
   },
   {
@@ -190,6 +191,7 @@
     "ifSearch": "false",
     "ifGroup": "false",
     "ifShow": "true",
+    "ifStats": "true",
     "ifAsCondition": "true"
   },
   {
@@ -226,6 +228,7 @@
     "ifSearch": "false",
     "ifGroup": "false",
     "ifShow": "true",
+    "ifStats": "true",
     "ifAsCondition": "true"
   },
   {
@@ -238,6 +241,7 @@
     "ifSearch": "false",
     "ifGroup": "false",
     "ifShow": "true",
+    "ifStats": "true",
     "ifAsCondition": "true"
   },
   {
@@ -286,6 +290,7 @@
     "ifSearch": "false",
     "ifGroup": "false",
     "ifShow": "false",
+    "ifStats": "true",
     "ifAsCondition": "true"
   },
   {
@@ -298,6 +303,7 @@
     "ifSearch": "false",
     "ifGroup": "false",
     "ifShow": "false",
+    "ifStats": "true",
     "ifAsCondition": "true"
   },
   {
@@ -310,6 +316,7 @@
     "ifSearch": "false",
     "ifGroup": "false",
     "ifShow": "false",
+    "ifStats": "true",
     "ifAsCondition": "true"
   },
   {
@@ -322,6 +329,7 @@
     "ifSearch": "false",
     "ifGroup": "false",
     "ifShow": "false",
+    "ifStats": "true",
     "ifAsCondition": "true"
   },
   {
@@ -358,6 +366,7 @@
     "ifSearch": "false",
     "ifGroup": "false",
     "ifShow": "false",
+    "ifStats": "true",
     "ifAsCondition": "true"
   },
   {
@@ -370,6 +379,7 @@
     "ifSearch": "false",
     "ifGroup": "false",
     "ifShow": "false",
+    "ifStats": "true",
     "ifAsCondition": "true"
   },
   {
@@ -382,6 +392,7 @@
     "ifSearch": "false",
     "ifGroup": "false",
     "ifShow": "false",
+    "ifStats": "true",
     "ifAsCondition": "true"
   },
   {
@@ -418,6 +429,7 @@
     "ifSearch": "false",
     "ifGroup": "false",
     "ifShow": "false",
+    "ifStats": "true",
     "ifAsCondition": "true"
   },
   {
@@ -430,6 +442,7 @@
     "ifSearch": "false",
     "ifGroup": "false",
     "ifShow": "false",
+    "ifStats": "true",
     "ifAsCondition": "true"
   },
   {
@@ -442,6 +455,7 @@
     "ifSearch": "false",
     "ifGroup": "false",
     "ifShow": "false",
+    "ifStats": "true",
     "ifAsCondition": "true"
   },
   {
@@ -454,6 +468,7 @@
     "ifSearch": "false",
     "ifGroup": "false",
     "ifShow": "false",
+    "ifStats": "true",
     "ifAsCondition": "true"
   },
   {
@@ -466,6 +481,150 @@
     "ifSearch": "false",
     "ifGroup": "false",
     "ifShow": "false",
+    "ifStats": "true",
+    "ifAsCondition": "true"
+  },
+  {
+    "name": "CPC分类号一级",
+    "type": "String",
+    "value": "cpcLevel1",
+    "field": "cpcLevel1",
+    "esField": "mcpc.level1",
+    "esClass": "keyWordQueryBuilder",
+    "ifSearch": "false",
+    "ifGroup": "false",
+    "ifShow": "true",
+    "ifStats": "true",
+    "ifAsCondition": "true"
+  },
+  {
+    "name": "CPC分类号二级",
+    "type": "String",
+    "value": "cpcLevel2",
+    "field": "cpcLevel2",
+    "esField": "mcpc.level2",
+    "esClass": "keyWordQueryBuilder",
+    "ifSearch": "false",
+    "ifGroup": "false",
+    "ifShow": "true",
+    "ifStats": "true",
+    "ifAsCondition": "true"
+  },
+  {
+    "name": "CPC分类号三级",
+    "type": "String",
+    "value": "cpcLevel3",
+    "field": "cpcLevel3",
+    "esField": "mcpc.level3",
+    "esClass": "keyWordQueryBuilder",
+    "ifSearch": "false",
+    "ifGroup": "false",
+    "ifShow": "true",
+    "ifStats": "true",
+    "ifAsCondition": "true"
+  },
+  {
+    "name": "CPC分类号四级",
+    "type": "String",
+    "value": "cpcLevel4",
+    "field": "cpcLevel4",
+    "esField": "mcpc.level4",
+    "esClass": "keyWordQueryBuilder",
+    "ifSearch": "false",
+    "ifGroup": "false",
+    "ifShow": "true",
+    "ifStats": "true",
+    "ifAsCondition": "true"
+  },
+  {
+    "name": "CPC分类号五级",
+    "type": "String",
+    "value": "cpcLevel5",
+    "field": "cpcLevel5",
+    "esField": "mcpc.level5",
+    "esClass": "keyWordQueryBuilder",
+    "ifSearch": "false",
+    "ifGroup": "false",
+    "ifShow": "true",
+    "ifStats": "true",
+    "ifAsCondition": "true"
+  },
+  {
+    "name": "UPC分类号一级",
+    "type": "String",
+    "value": "upcLevel1",
+    "field": "upcLevel1",
+    "esField": "mupc.level1",
+    "esClass": "keyWordQueryBuilder",
+    "ifSearch": "false",
+    "ifGroup": "false",
+    "ifShow": "true",
+    "ifStats": "true",
+    "ifAsCondition": "true"
+  },
+  {
+    "name": "UPC分类号二级",
+    "type": "String",
+    "value": "upcLevel2",
+    "field": "upcLevel2",
+    "esField": "mupc.level2",
+    "esClass": "keyWordQueryBuilder",
+    "ifSearch": "false",
+    "ifGroup": "false",
+    "ifShow": "true",
+    "ifStats": "true",
+    "ifAsCondition": "true"
+  },
+  {
+    "name": "UPC分类号三级",
+    "type": "String",
+    "value": "upcLevel3",
+    "field": "upcLevel3",
+    "esField": "mupc.level3",
+    "esClass": "keyWordQueryBuilder",
+    "ifSearch": "false",
+    "ifGroup": "false",
+    "ifShow": "true",
+    "ifStats": "true",
+    "ifAsCondition": "true"
+  },
+  {
+    "name": "LOC分类号一级",
+    "type": "String",
+    "value": "locLevel1",
+    "field": "locLevel1",
+    "esField": "mloc.level1",
+    "esClass": "keyWordQueryBuilder",
+    "ifSearch": "false",
+    "ifGroup": "false",
+    "ifShow": "true",
+    "ifStats": "true",
+    "ifAsCondition": "true"
+  },
+  {
+    "name": "LOC分类号二级",
+    "type": "String",
+    "value": "locLevel2",
+    "field": "locLevel2",
+    "esField": "mloc.level2",
+    "esClass": "keyWordQueryBuilder",
+    "ifSearch": "false",
+    "ifGroup": "false",
+    "ifShow": "true",
+    "ifStats": "true",
+    "ifAsCondition": "true"
+  },
+  {
+    "name": "LOC分类号三级",
+    "type": "String",
+    "value": "locLevel3",
+    "field": "locLevel3",
+    "esField": "mloc.level3",
+    "esClass": "keyWordQueryBuilder",
+    "ifSearch": "false",
+    "ifGroup": "false",
+    "ifShow": "true",
+    "ifStats": "true",
     "ifAsCondition": "true"
   },
   {
@@ -491,6 +650,7 @@
     "ifGroup": "false",
     "ifShow": "true",
     "ifAsCondition": "true",
+    "ifStats": "true",
     "fieldOptionQueryParam": "PATENT_SIMPLE_STATUS"
   },
   {
@@ -504,6 +664,7 @@
     "ifGroup": "false",
     "ifShow": "true",
     "ifAsCondition": "true",
+    "ifStats": "true",
     "fieldOptionQueryParam": "PATENT_TYPE"
   },
   {
@@ -516,6 +677,7 @@
     "ifSearch": "false",
     "ifGroup": "false",
     "ifShow": "true",
+    "ifStats": "true",
     "ifAsCondition": "true"
   },
   {