|
@@ -302,6 +302,106 @@ public class EsCountService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ public void getReturnData1(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;
|
|
|
+ } else {
|
|
|
+ searchCondition = condition;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ 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);
|
|
|
+ builder.query(query);
|
|
|
+ }
|
|
|
+
|
|
|
+ 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);
|
|
|
+ builder.aggregations("Agg", aggregation);
|
|
|
+ //解除最大条数限制
|
|
|
+ builder.trackTotalHits(i -> i.enabled(true));
|
|
|
+ SearchResponse<Patent> response = client.search(builder.build(), Patent.class);
|
|
|
+ Aggregate agg = response.aggregations().get("Agg");
|
|
|
+
|
|
|
+ if (StringUtils.isNotEmpty(field)) {
|
|
|
+ if (dateList.contains(field)) {
|
|
|
+ if (CollectionUtils.isEmpty(values)) {
|
|
|
+ this.getDateCountDTOS(agg, field, topN, format, detailDTOS, esCountDTO,valueOne,valueTwo);
|
|
|
+ } else {
|
|
|
+ this.getDateAnalysisDTOS(agg, field, topN, detailDTOS, esCountDTO, firstName, map, values);
|
|
|
+ }
|
|
|
+ } else if (nestedList.contains(field)) {
|
|
|
+ this.getNestedCountDTOS(agg, field, topN, detailDTOS, esCountDTO, firstName, map, values,valueOne);
|
|
|
+ if (!CollectionUtils.isEmpty(values)) {
|
|
|
+ esCountDTO.setAllNumber(agg.nested().docCount());
|
|
|
+ }
|
|
|
+ } else if (nestDateList.contains(field)) {
|
|
|
+ if (CollectionUtils.isEmpty(values)) {
|
|
|
+ Aggregate termsAgg = agg.nested().aggregations().get("terms_agg");
|
|
|
+ this.getDateCountDTOS(termsAgg, field, topN, format, detailDTOS, esCountDTO,valueOne,valueTwo);
|
|
|
+ } else {
|
|
|
+ Aggregate termsAgg = agg.nested().aggregations().get("terms_agg");
|
|
|
+ this.getDateAnalysisDTOS(termsAgg, field, topN, detailDTOS, esCountDTO, firstName, map, values);
|
|
|
+ }
|
|
|
+ } else if (nestChildList.contains(field)) {
|
|
|
+ Aggregate childAgg = agg.children().aggregations().get("childAgg");
|
|
|
+ this.getNestedCountDTOS(childAgg, field, topN, detailDTOS, esCountDTO, firstName, map, values,valueOne);
|
|
|
+ if (!CollectionUtils.isEmpty(values)) {
|
|
|
+ esCountDTO.setAllNumber(childAgg.nested().docCount());
|
|
|
+ }
|
|
|
+ } else if (childList.contains(field)) {
|
|
|
+ if (CollectionUtils.isEmpty(values)) {
|
|
|
+ this.getChildCountDTOS(agg, field, fieldType, topN, detailDTOS, esCountDTO,projectId,taskId);
|
|
|
+ } else {
|
|
|
+ this.getChildAnalysisDTOS(agg, field, fieldType, topN,
|
|
|
+ detailDTOS, esCountDTO, firstName, map, values);
|
|
|
+ }
|
|
|
+ } else if (numberList.contains(field)) {
|
|
|
+ if (CollectionUtils.isEmpty(values)) {
|
|
|
+
|
|
|
+ } else {
|
|
|
+ this.getNumberAnalysisDTOS(agg, field, topN, detailDTOS, esCountDTO, firstName, map, values);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ this.getTermCountDTOS(agg, field, topN, detailDTOS, esCountDTO, firstName, map, values,valueOne);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ this.getFilterCountDTO(agg, searchCondition, detailDTOS);
|
|
|
+ }
|
|
|
+ esCountDTO.setCondition(searchCondition);
|
|
|
+ esCountDTO.setAnalyseMap(map);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
public EsDateRangeDTO getFieldRange(EsDateRangeVO rangeVO) throws Exception {
|
|
|
String searchCondition = rangeVO.getCondition();
|
|
|
String field = rangeVO.getField();
|