|
@@ -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();
|