浏览代码

Merge remote-tracking branch 'origin/master'

xiexiang 1 年之前
父节点
当前提交
7832156ed4

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

@@ -7,6 +7,6 @@ import java.util.List;
 @Data
 public class EsCountDTO {
     private String condition;
-
+    private Integer topN;
     private List<EsCountDetailDTO> detailDTOS;
 }

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

@@ -12,14 +12,18 @@ public class EsCountVO {
     private String fieldId;
     //自定义栏位类型
     private Integer fieldType;
-    //统计搜索的栏位值1
+    //过滤条件 ----统计搜索的栏位值1
     private String valueOne;
-    //统计搜索的栏位值2
+    //过滤条件 -----统计搜索的栏位值2
     private String valueTwo;
+    //过滤条件
+    private String filterCondition;
     //top
     private Integer topN = 10;
     //开关
     private Boolean ifHaveChild = false;
-    //分析搜索栏位值
+    //显示条件
     private List<String> values;
+    //日期格式
+    private String format;
 }

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

@@ -91,9 +91,16 @@ public class PatentController {
 
     @Operation(summary = "esAnalysis")
     @PostMapping("/esAnalysis")
-    public Response esAnalysis(@RequestBody EsCountVO countVO) throws Exception {
+    public Response esAnalysis(@RequestBody EsAllCountVO countVO) throws Exception {
         EsCountDTO dto = esCountService.esAnalysis(countVO);
         return Response.success(dto);
     }
 
+    @Operation(summary = "聚合统计")
+    @PostMapping("/esCountAnalysis")
+    public Response esCountAnalysis(@RequestBody EsAllCountVO countVO) throws Exception {
+        EsCountDTO dto = esCountService.esCountAnalysis(countVO);
+        return Response.success(dto);
+    }
+
 }

+ 20 - 0
src/main/java/cn/cslg/pas/factorys/EsCountAnalyseBuilderFactory/EsCountAnalysisBuilderFactory.java

@@ -0,0 +1,20 @@
+package cn.cslg.pas.factorys.EsCountAnalyseBuilderFactory;
+
+import cn.cslg.pas.factorys.EsAnalysisBuilderFactory.IEsAnalysisBuilder;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import java.util.Map;
+
+@Component
+public class EsCountAnalysisBuilderFactory {
+
+    @Autowired
+    private Map<String, IEsCountAnalysisBuilder> iEsCountAnalysisBuilderMap;
+
+
+    public IEsCountAnalysisBuilder getClass(String builderName) {
+        IEsCountAnalysisBuilder bean1 = iEsCountAnalysisBuilderMap.get(builderName);
+        return bean1;
+    }
+}

+ 12 - 0
src/main/java/cn/cslg/pas/factorys/EsCountAnalyseBuilderFactory/IEsCountAnalysisBuilder.java

@@ -0,0 +1,12 @@
+package cn.cslg.pas.factorys.EsCountAnalyseBuilderFactory;
+
+import co.elastic.clients.elasticsearch._types.aggregations.Aggregation;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public interface IEsCountAnalysisBuilder {
+
+    public Aggregation createCountAnalyseAgg() throws Exception;
+
+}

+ 120 - 0
src/main/java/cn/cslg/pas/factorys/EsCountAnalyseBuilderFactory/TermsCountAnalysisBuilder.java

@@ -0,0 +1,120 @@
+package cn.cslg.pas.factorys.EsCountAnalyseBuilderFactory;
+
+import cn.cslg.pas.common.utils.StringUtils;
+import co.elastic.clients.elasticsearch._types.aggregations.Aggregation;
+import co.elastic.clients.elasticsearch._types.aggregations.AggregationBuilders;
+import co.elastic.clients.elasticsearch._types.aggregations.TermsAggregation;
+import co.elastic.clients.elasticsearch._types.query_dsl.Query;
+import co.elastic.clients.elasticsearch._types.query_dsl.QueryBuilders;
+import org.springframework.stereotype.Component;
+import org.springframework.util.CollectionUtils;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+
+@Component
+public class TermsCountAnalysisBuilder implements IEsCountAnalysisBuilder {
+    public String field = "";
+    public String valueOne = "";
+    public String valueTwo = "";
+    public Integer topN = 10;
+    public String path = "";
+    public Boolean ifHaveChild = false;
+    public String fieldType = null;
+    public String fieldId = null;
+    public List<String> values = new ArrayList<>();
+
+    @Override
+    public Aggregation createCountAnalyseAgg() throws Exception {
+        Aggregation aggregation = null;
+        if (StringUtils.isNotEmpty(valueOne)) {
+            String str = "*";
+            String s = str.concat(valueOne).concat("*");
+            Query query = QueryBuilders.wildcard(i -> i.field(field).value(s));
+            Aggregation filter = AggregationBuilders.filter(n -> n.bool(k -> k.must(query)));
+            aggregation = new Aggregation.Builder().terms(new TermsAggregation.Builder()
+                    .field(field).size(topN).build())
+                    .aggregations(new HashMap() {{
+                        put("filter_agg", filter);
+                    }}).build();
+        } else if (CollectionUtils.isEmpty(values)) {
+            aggregation = AggregationBuilders.terms(i -> i.field(field).include(j -> j.terms(values)).size(topN));
+        } else {
+            aggregation = AggregationBuilders.terms(i -> i.field(field).size(topN));
+        }
+        return aggregation;
+    }
+
+    public String getField() {
+        return field;
+    }
+
+    public void setField(String field) {
+        this.field = field;
+    }
+
+    public String getValueOne() {
+        return valueOne;
+    }
+
+    public void setValueOne(String valueOne) {
+        this.valueOne = valueOne;
+    }
+
+    public String getValueTwo() {
+        return valueTwo;
+    }
+
+    public void setValueTwo(String valueTwo) {
+        this.valueTwo = valueTwo;
+    }
+
+    public Integer getTopN() {
+        return topN;
+    }
+
+    public void setTopN(Integer topN) {
+        this.topN = topN;
+    }
+
+    public String getPath() {
+        return path;
+    }
+
+    public void setPath(String path) {
+        this.path = path;
+    }
+
+    public Boolean getIfHaveChild() {
+        return ifHaveChild;
+    }
+
+    public void setIfHaveChild(Boolean ifHaveChild) {
+        this.ifHaveChild = ifHaveChild;
+    }
+
+    public String getFieldType() {
+        return fieldType;
+    }
+
+    public void setFieldType(String fieldType) {
+        this.fieldType = fieldType;
+    }
+
+    public String getFieldId() {
+        return fieldId;
+    }
+
+    public void setFieldId(String fieldId) {
+        this.fieldId = fieldId;
+    }
+
+    public List<String> getValues() {
+        return values;
+    }
+
+    public void setValues(List<String> values) {
+        this.values = values;
+    }
+}

+ 4 - 2
src/main/java/cn/cslg/pas/factorys/EsCountBuilderFactory/ChildCountBuilder.java

@@ -74,8 +74,10 @@ public class ChildCountBuilder implements IEsCountBuilder{
      * @return
      */
     private Aggregation getAggregation(List<Query> queryList) {
-        Query query = QueryBuilders.term(i -> i.field("custom_field.field").value(fieldId));
-        queryList.add(query);
+        Query q1 = QueryBuilders.term(i -> i.field("custom_field.field").value(fieldId));
+        Query q2 = QueryBuilders.term(i -> i.field("custom_field.field_type").value(fieldType));
+        queryList.add(q1);
+        queryList.add(q2);
 
         Aggregation filtersAgg = AggregationBuilders.filter(n -> n.bool(k -> k.must(queryList)));
 

+ 0 - 1
src/main/java/cn/cslg/pas/factorys/EsCountBuilderFactory/TermsCountBuilder.java

@@ -30,7 +30,6 @@ public class TermsCountBuilder implements IEsCountBuilder{
             String s = str.concat(valueOne).concat("*");
             Query query = QueryBuilders.wildcard(i -> i.field(field).value(s));
             Aggregation filter = AggregationBuilders.filter(n -> n.bool(k -> k.must(query)));
-//            Aggregation filter = AggregationBuilders.filter(n -> n.term(m -> m.field(field).value(valueOne)));
             aggregation = new Aggregation.Builder().terms(new TermsAggregation.Builder()
                     .field(field).size(topN).build())
                     .aggregations(new HashMap() {{

+ 237 - 50
src/main/java/cn/cslg/pas/service/business/es/EsCountService.java

@@ -14,6 +14,8 @@ import cn.cslg.pas.common.vo.business.EsCountVO;
 import cn.cslg.pas.domain.es.Patent;
 import cn.cslg.pas.factorys.EsAnalysisBuilderFactory.EsAnalysisBuilderFactory;
 import cn.cslg.pas.factorys.EsAnalysisBuilderFactory.IEsAnalysisBuilder;
+import cn.cslg.pas.factorys.EsCountAnalyseBuilderFactory.EsCountAnalysisBuilderFactory;
+import cn.cslg.pas.factorys.EsCountAnalyseBuilderFactory.IEsCountAnalysisBuilder;
 import cn.cslg.pas.factorys.EsCountBuilderFactory.EsCountBuilderFactory;
 import cn.cslg.pas.factorys.EsCountBuilderFactory.IEsCountBuilder;
 import cn.cslg.pas.service.business.CommonService;
@@ -52,6 +54,8 @@ public class EsCountService {
     @Autowired
     private EsAnalysisBuilderFactory esAnalysisBuilderFactory;
     @Autowired
+    private EsCountAnalysisBuilderFactory esCountAnalysisBuilderFactory;
+    @Autowired
     private FormatQueryService formatQueryService;
     @Autowired
     private EsService esService;
@@ -71,7 +75,7 @@ public class EsCountService {
         }
         Integer taskId = countVO.getTaskId();
         Integer projectId = countVO.getProjectId();
-        if( taskId != null){
+        if (taskId != null) {
             if (searchCondition != null && !"".equals(searchCondition.trim())) {
                 searchCondition = "taskId = " + taskId + " AND " + searchCondition;
             } else {
@@ -89,12 +93,15 @@ public class EsCountService {
 
         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");
+        Query query = null;
+        if (StringUtils.isNotEmpty(searchCondition)) {
+            //1. 解析检索条件
+            treeNode tree = expressManager.getInstance().Parse(searchCondition, false);
+            //格式化检索式
+            //3. 从es中检索数据
+            query = formatQueryService.EsQueryToQuery((operateNode) tree, "patent");
+        }
+
 
         EsCountDTO esCountDTO = new EsCountDTO();
         List<EsCountDetailDTO> detailDTOS = new ArrayList<>();
@@ -106,8 +113,9 @@ public class EsCountService {
             //查询es返回数据
             Aggregation aggregation = this.selectAggregation(builder, vo);
             if (query != null) {
+                Query finalQuery = query;
                 Aggregation filtersAgg = new Aggregation.Builder().filters(new FiltersAggregation.Builder()
-                        .filters(i -> i.array(Arrays.asList(query))).build())
+                        .filters(i -> i.array(Arrays.asList(finalQuery))).build())
                         .aggregations(new HashMap() {{
                             put("filters_agg", aggregation);
                         }}).build();
@@ -173,6 +181,40 @@ public class EsCountService {
      * @throws Exception
      */
     public EsCountDTO esAnalysisSearch(EsAllCountVO countVO) throws Exception {
+        String searchCondition = countVO.getCondition();
+        List<EsCustomFieldValueDTO> customFields = countVO.getCustomFields();
+        if (!CollectionUtils.isEmpty(customFields)) {
+            searchCondition = esService.parseCustomField(customFields);
+        }
+        Integer taskId = countVO.getTaskId();
+        Integer projectId = countVO.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;
+                }
+            }
+        }
+
+        SearchRequest.Builder builder = new SearchRequest.Builder();
+        //设置查询索引
+        Query query = null;
+        if (StringUtils.isNotEmpty(searchCondition)) {
+            //1. 解析检索条件
+            treeNode tree = expressManager.getInstance().Parse(searchCondition, false);
+            //格式化检索式
+            //3. 从es中检索数据
+            query = formatQueryService.EsQueryToQuery((operateNode) tree, "patent");
+        }
+
         EsCountDTO esCountDTO = new EsCountDTO();
         List<EsCountDetailDTO> detailDTOS = new ArrayList<>();
         List<EsCountVO> countVOS = countVO.getCountVOS();
@@ -184,7 +226,6 @@ public class EsCountService {
             List<String> values = vo.getValues();
 
             //查询es返回数据
-            SearchRequest.Builder builder = new SearchRequest.Builder();
             builder.index("patent");
             IEsAnalysisBuilder iEsAnalysisBuilder = null;
             String json = CommonService.readJsonFile("esAnalysis.json");
@@ -204,6 +245,19 @@ public class EsCountService {
                 iEsAnalysisBuilder.setValues(values);
 
                 Aggregation aggregation = iEsAnalysisBuilder.createAnalyseAgg();
+
+                if (query != null) {
+                    Query finalQuery = query;
+                    Aggregation filtersAgg = new Aggregation.Builder().filters(new FiltersAggregation.Builder()
+                            .filters(i -> i.array(Arrays.asList(finalQuery))).build())
+                            .aggregations(new HashMap() {{
+                                put("filters_agg", aggregation);
+                            }}).build();
+                    builder.aggregations("Agg", filtersAgg);
+                } else {
+                    builder.aggregations("Agg", aggregation);
+                }
+
                 builder.aggregations("Agg", aggregation);
                 SearchResponse<Patent> response = client.search(builder.build(), Patent.class);
 
@@ -215,7 +269,7 @@ public class EsCountService {
                 } else if (childList.contains(field)) {
                     this.getChildAnalysisDTOS(agg, field, detailDTOS);
                 } else if (numberList.contains(field)) {
-                    this.getNumberAnalysisDTOS(agg, field,detailDTOS);
+                    this.getNumberAnalysisDTOS(agg, field, detailDTOS);
                 } else {
                     this.getTermCountDTOS(agg, field, detailDTOS);
                 }
@@ -226,50 +280,99 @@ public class EsCountService {
     }
 
     //测试用的
-    public EsCountDTO esAnalysis(EsCountVO vo) throws Exception {
-        EsCountDTO esCountDTO = new EsCountDTO();
-        List<EsCountDetailDTO> detailDTOS = new ArrayList<>();
-        String field = vo.getField();
-        Integer topN = vo.getTopN();
-        Boolean ifHaveChild = vo.getIfHaveChild();
-        String fieldId = vo.getFieldId();
-        List<String> values = vo.getValues();
+    public EsCountDTO esAnalysis(EsAllCountVO countVO) throws Exception {
+        String searchCondition = countVO.getCondition();
+        List<EsCustomFieldValueDTO> customFields = countVO.getCustomFields();
+        if (!CollectionUtils.isEmpty(customFields)) {
+            searchCondition = esService.parseCustomField(customFields);
+        }
+        Integer taskId = countVO.getTaskId();
+        Integer projectId = countVO.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;
+                }
+            }
+        }
 
-        //查询es返回数据
         SearchRequest.Builder builder = new SearchRequest.Builder();
+        //设置查询索引
         builder.index("patent");
-        IEsAnalysisBuilder iEsAnalysisBuilder = null;
-        String json = CommonService.readJsonFile("esAnalysis.json");
-        List<EsConfigVO> esConfigVOS = JSON.parseArray(json, EsConfigVO.class);
-        EsConfigVO esConfigVO = esConfigVOS.stream().filter(item -> item.getField().equals(field))
-                .findFirst().orElse(null);
-        if (esConfigVO != null) {
-            iEsAnalysisBuilder = esAnalysisBuilderFactory.getClass(esConfigVO.getEsClass());
-            iEsAnalysisBuilder.setField(esConfigVO.getEsField());
-            iEsAnalysisBuilder.setTopN(topN);
-            iEsAnalysisBuilder.setIfHaveChild(ifHaveChild);
-            iEsAnalysisBuilder.setFieldValue(fieldId);
-            if (iEsAnalysisBuilder.getField().contains(".")) {
-                String path = iEsAnalysisBuilder.getField().substring(0, iEsAnalysisBuilder.getField().indexOf("."));
-                iEsAnalysisBuilder.setPath(path);
-            }
-            iEsAnalysisBuilder.setValues(values);
+        Query query = null;
+        if (StringUtils.isNotEmpty(searchCondition)) {
+            //1. 解析检索条件
+            treeNode tree = expressManager.getInstance().Parse(searchCondition, false);
+            //格式化检索式
+            //3. 从es中检索数据
+            query = formatQueryService.EsQueryToQuery((operateNode) tree, "patent");
+        }
 
-            Aggregation aggregation = iEsAnalysisBuilder.createAnalyseAgg();
-            builder.aggregations("Agg", aggregation);
-            SearchResponse<Patent> response = client.search(builder.build(), Patent.class);
+        EsCountDTO esCountDTO = new EsCountDTO();
+        List<EsCountDetailDTO> detailDTOS = new ArrayList<>();
+        List<EsCountVO> countVOS = countVO.getCountVOS();
+        for (EsCountVO vo : countVOS) {
+            String field = vo.getField();
+            Integer topN = vo.getTopN();
+            Boolean ifHaveChild = vo.getIfHaveChild();
+            String fieldId = vo.getFieldId();
+            List<String> values = vo.getValues();
 
-            Aggregate agg = response.aggregations().get("Agg");
-            if (dateList.contains(field)) {
-                this.getDateAnalysisDTOS(agg, field, topN, detailDTOS);
-            } else if (nestedList.contains(field)) {
-                this.getNestedCountDTOS(agg, field, detailDTOS);
-            } else if (childList.contains(field)) {
-                this.getChildAnalysisDTOS(agg, field, detailDTOS);
-            } else if (numberList.contains(field)) {
-                this.getNumberAnalysisDTOS(agg, field,detailDTOS);
-            } else {
-                this.getTermCountDTOS(agg, field, detailDTOS);
+            //查询es返回数据
+            builder.index("patent");
+            IEsAnalysisBuilder iEsAnalysisBuilder = null;
+            String json = CommonService.readJsonFile("esAnalysis.json");
+            List<EsConfigVO> esConfigVOS = JSON.parseArray(json, EsConfigVO.class);
+            EsConfigVO esConfigVO = esConfigVOS.stream().filter(item -> item.getField().equals(field))
+                    .findFirst().orElse(null);
+            if (esConfigVO != null) {
+                iEsAnalysisBuilder = esAnalysisBuilderFactory.getClass(esConfigVO.getEsClass());
+                iEsAnalysisBuilder.setField(esConfigVO.getEsField());
+                iEsAnalysisBuilder.setTopN(topN);
+                iEsAnalysisBuilder.setIfHaveChild(ifHaveChild);
+                iEsAnalysisBuilder.setFieldValue(fieldId);
+                if (iEsAnalysisBuilder.getField().contains(".")) {
+                    String path = iEsAnalysisBuilder.getField().substring(0, iEsAnalysisBuilder.getField().indexOf("."));
+                    iEsAnalysisBuilder.setPath(path);
+                }
+                iEsAnalysisBuilder.setValues(values);
+
+                Aggregation aggregation = iEsAnalysisBuilder.createAnalyseAgg();
+
+                if (query != null) {
+                    Query finalQuery = query;
+                    Aggregation filtersAgg = new Aggregation.Builder().filters(new FiltersAggregation.Builder()
+                            .filters(i -> i.array(Arrays.asList(finalQuery))).build())
+                            .aggregations(new HashMap() {{
+                                put("filters_agg", aggregation);
+                            }}).build();
+                    builder.aggregations("Agg", filtersAgg);
+                } else {
+                    builder.aggregations("Agg", aggregation);
+                }
+
+                SearchResponse<Patent> response = client.search(builder.build(), Patent.class);
+
+                Aggregate agg = response.aggregations().get("Agg");
+                if (dateList.contains(field)) {
+                    this.getDateAnalysisDTOS(agg, field, topN, detailDTOS);
+                } else if (nestedList.contains(field)) {
+                    this.getNestedCountDTOS(agg, field, detailDTOS);
+                } else if (childList.contains(field)) {
+                    this.getChildAnalysisDTOS(agg, field, detailDTOS);
+                } else if (numberList.contains(field)) {
+                    this.getNumberAnalysisDTOS(agg, field, detailDTOS);
+                } else {
+                    this.getTermCountDTOS(agg, field, detailDTOS);
+                }
             }
         }
         esCountDTO.setDetailDTOS(detailDTOS);
@@ -447,7 +550,7 @@ public class EsCountService {
      * @param field
      * @param detailDTOS
      */
-    public void getNumberAnalysisDTOS(Aggregate agg, String field,List<EsCountDetailDTO> detailDTOS) {
+    public void getNumberAnalysisDTOS(Aggregate agg, String field, List<EsCountDetailDTO> detailDTOS) {
         List<RangeBucket> list = agg.range().buckets().array();
         for (RangeBucket bucket : list) {
             EsCountDetailDTO dto = new EsCountDetailDTO();
@@ -541,4 +644,88 @@ public class EsCountService {
             }
         });
     }
+
+
+    public EsCountDTO esCountAnalysis(EsAllCountVO vo) throws Exception {
+        String searchCondition = vo.getCondition();
+        List<EsCustomFieldValueDTO> customFields = vo.getCustomFields();
+        if (!CollectionUtils.isEmpty(customFields)) {
+            searchCondition = esService.parseCustomField(customFields);
+        }
+        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;
+                }
+            }
+        }
+
+        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");
+        }
+
+        EsCountDTO esCountDTO = new EsCountDTO();
+        List<EsCountDetailDTO> detailDTOS = new ArrayList<>();
+        List<EsCountVO> countVOS = vo.getCountVOS();
+        for (EsCountVO countVO : countVOS) {
+            String field = countVO.getField();
+            Integer topN = countVO.getTopN();
+            String condition = searchCondition;
+            String filterCondition = countVO.getFilterCondition();
+            String valueOne = countVO.getValueOne();
+            String valueTwo = countVO.getValueTwo();
+            List<String> values = countVO.getValues();
+
+            IEsCountAnalysisBuilder iEsCountAnalysisBuilder = null;
+            String json = CommonService.readJsonFile("esAnalysis.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());
+                if (StringUtils.isNotEmpty(valueOne) || StringUtils.isNotEmpty(valueTwo)) {
+
+                } else if (!CollectionUtils.isEmpty(values)) {
+
+                } else {
+
+                }
+            }
+            if (query != null) {
+                Query finalQuery = query;
+                Aggregation filtersAgg = new Aggregation.Builder().filters(new FiltersAggregation.Builder()
+                        .filters(i -> i.array(Arrays.asList(finalQuery))).build())
+                        .aggregations(new HashMap() {{
+                            put("filters_agg", aggregation);
+                        }}).build();
+                builder.aggregations("Agg", filtersAgg);
+            } else {
+                builder.aggregations("Agg", aggregation);
+            }
+            SearchResponse<Patent> response = client.search(builder.build(), Patent.class);
+        }
+        return null;
+    }
 }

+ 38 - 50
src/main/resources/jsons/patent.json

@@ -96,7 +96,7 @@
     "ifAsCondition": "true"
   },
   {
-    "name": "子文档号",
+    "name": "项目id",
     "type": "String",
     "value": "projectId",
     "field": "projectId",
@@ -135,7 +135,7 @@
   {
     "name": "实审日",
     "type": "String",
-    "value": "examinationDate",
+    "value": "EXD",
     "field": "examinationDate",
     "esField": "examination_date",
     "esClass": "dateQueryBuilder",
@@ -184,7 +184,7 @@
     "name": "公开说明书文本",
     "type": "String",
     "value": "publicFullText",
-    "field": "publicFullText",
+    "field": "PFT",
     "esField": "public_full_text.text_content",
     "esClass": "matchQueryBuilder",
     "ifSearch": "false",
@@ -196,7 +196,7 @@
     "name": "授权说明书文本",
     "type": "String",
     "value": "grantFullText",
-    "field": "grantFullText",
+    "field": "GFT",
     "esField": "grant_full_text.text_content",
     "esClass": "matchQueryBuilder",
     "ifSearch": "false",
@@ -220,7 +220,7 @@
     "name": "代理人名称",
     "type": "Array",
     "value": "agent",
-    "field": "agent",
+    "field": "AG",
     "esField": "agent",
     "esClass": "matchQueryBuilder",
     "ifSearch": "false",
@@ -231,8 +231,8 @@
   {
     "name": "引用专利数量",
     "type": "Integer",
-    "value": "CC",
-    "field": "CC",
+    "value": "quotePatentNoNum",
+    "field": "QPN",
     "esField": "quote_patent_no_num",
     "esClass": "numberQueryBuilder",
     "ifSearch": "false",
@@ -244,7 +244,7 @@
     "name": "被引用专利数量",
     "type": "Integer",
     "value": "quotedPatentNoNum",
-    "field": "quotedPatentNoNum",
+    "field": "QDPN",
     "esField": "quoted_patent_no_num",
     "esClass": "numberQueryBuilder",
     "ifSearch": "false",
@@ -255,9 +255,9 @@
   {
     "name": "申请人地址",
     "type": "String",
-    "value": "DZ",
-    "field": "DZ",
-    "esField": "applicant_addr",
+    "value": "appAddress",
+    "field": "ADD",
+    "esField": "applicant_addr.address",
     "esClass": "matchQueryBuilder",
     "ifSearch": "false",
     "ifGroup": "false",
@@ -268,7 +268,7 @@
     "name": "申请国家",
     "type": "String",
     "value": "appCountry",
-    "field": "appCountry",
+    "field": "CO",
     "esField": "app_country",
     "esClass": "keyWordQueryBuilder",
     "ifSearch": "false",
@@ -279,8 +279,8 @@
   {
     "name": "申请人国家",
     "type": "String",
-    "value": "CO",
-    "field": "CO",
+    "value": "appCountry",
+    "field": "AAC",
     "esField": "applicant_addr.country",
     "esClass": "keyWordQueryBuilder",
     "ifSearch": "false",
@@ -292,7 +292,7 @@
     "name": "申请人省份",
     "type": "String",
     "value": "appProvince",
-    "field": "appProvince",
+    "field": "ADP",
     "esField": "applicant_addr.province",
     "esClass": "prefixQueryBuilder",
     "ifSearch": "false",
@@ -304,7 +304,7 @@
     "name": "申请人市区",
     "type": "String",
     "value": "appCity",
-    "field": "appCity",
+    "field": "ADC",
     "esField": "applicant_addr.city",
     "esClass": "prefixQueryBuilder",
     "ifSearch": "false",
@@ -316,7 +316,7 @@
     "name": "申请人区县",
     "type": "String",
     "value": "appDistrict",
-    "field": "appDistrict",
+    "field": "ADA",
     "esField": "applicant_addr.district",
     "esClass": "prefixQueryBuilder",
     "ifSearch": "false",
@@ -327,9 +327,9 @@
   {
     "name": "权利人地址",
     "type": "String",
-    "value": "rightHolderAddr",
-    "field": "rightHolderAddr",
-    "esField": "right_holder_addr",
+    "value": "rightAddress",
+    "field": "RDD",
+    "esField": "right_holder_addr.address",
     "esClass": "matchQueryBuilder",
     "ifSearch": "false",
     "ifGroup": "false",
@@ -340,7 +340,7 @@
     "name": "权利人国家",
     "type": "String",
     "value": "rightCountry",
-    "field": "rightCountry",
+    "field": "DZ",
     "esField": "right_holder_addr.country",
     "esClass": "keyWordQueryBuilder",
     "ifSearch": "false",
@@ -352,7 +352,7 @@
     "name": "权利人省份",
     "type": "String",
     "value": "rightProvince",
-    "field": "rightProvince",
+    "field": "RDP",
     "esField": "right_holder_addr.province",
     "esClass": "prefixQueryBuilder",
     "ifSearch": "false",
@@ -364,7 +364,7 @@
     "name": "权利人市区",
     "type": "String",
     "value": "rightCity",
-    "field": "rightCity",
+    "field": "RDC",
     "esField": "right_holder_addr.city",
     "esClass": "prefixQueryBuilder",
     "ifSearch": "false",
@@ -376,7 +376,7 @@
     "name": "权利人区县",
     "type": "String",
     "value": "rightDistrict",
-    "field": "rightDistrict",
+    "field": "RDD",
     "esField": "right_holder_addr.district",
     "esClass": "prefixQueryBuilder",
     "ifSearch": "false",
@@ -399,8 +399,8 @@
   {
     "name": "IPC分类号一级",
     "type": "String",
-    "value": "mipcLevel1",
-    "field": "mipcLevel1",
+    "value": "ipcLevel1",
+    "field": "IC",
     "esField": "mipc.level1",
     "esClass": "keyWordQueryBuilder",
     "ifSearch": "false",
@@ -411,8 +411,8 @@
   {
     "name": "IPC分类号二级",
     "type": "String",
-    "value": "mipcLevel2",
-    "field": "mipcLevel2",
+    "value": "ipcLevel2",
+    "field": "IC2",
     "esField": "mipc.level2",
     "esClass": "keyWordQueryBuilder",
     "ifSearch": "false",
@@ -423,8 +423,8 @@
   {
     "name": "IPC分类号三级",
     "type": "String",
-    "value": "mipcLevel3",
-    "field": "mipcLevel3",
+    "value": "ipcLevel3",
+    "field": "IC3",
     "esField": "mipc.level3",
     "esClass": "keyWordQueryBuilder",
     "ifSearch": "false",
@@ -435,8 +435,8 @@
   {
     "name": "IPC分类号四级",
     "type": "String",
-    "value": "mipcLevel4",
-    "field": "mipcLevel4",
+    "value": "ipcLevel4",
+    "field": "IC4",
     "esField": "mipc.level4",
     "esClass": "keyWordQueryBuilder",
     "ifSearch": "false",
@@ -447,8 +447,8 @@
   {
     "name": "IPC分类号五级",
     "type": "String",
-    "value": "mipcLevel5",
-    "field": "mipcLevel5",
+    "value": "ipcLevel5",
+    "field": "IC5",
     "esField": "mipc.level5",
     "esClass": "keyWordQueryBuilder",
     "ifSearch": "false",
@@ -459,19 +459,7 @@
   {
     "name": "权利要求",
     "type": "String",
-    "value": "TX",
-    "field": "TX",
-    "esField": "claim",
-    "esClass": "matchQueryBuilder",
-    "ifSearch": "false",
-    "ifGroup": "false",
-    "ifShow": "false",
-    "ifAsCondition": "true"
-  },
-  {
-    "name": "权利要求内容",
-    "type": "String",
-    "value": "CL",
+    "value": "claim",
     "field": "CL",
     "esField": "claim.text_content",
     "esClass": "matchQueryBuilder",
@@ -483,7 +471,7 @@
   {
     "name": "专利状态",
     "type": "String",
-    "value": "SS",
+    "value": "simpleStatus",
     "field": "SS",
     "esField": "simple_status",
     "esClass": "keyWordQueryBuilder",
@@ -495,7 +483,7 @@
   {
     "name": "专利类型",
     "type": "String",
-    "value": "PT",
+    "value": "patentType",
     "field": "PT",
     "esField": "patent_type",
     "esClass": "keyWordQueryBuilder",
@@ -507,7 +495,7 @@
   {
     "name": "法律状态",
     "type": "String",
-    "value": "LG",
+    "value": "legalStatus",
     "field": "LG",
     "esField": "legal_status",
     "esClass": "keyWordQueryBuilder",