|
@@ -160,20 +160,20 @@ public class EsCountService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if (countVOS.size() == 1) {
|
|
|
- EsCountVO countVO = countVOS.get(0);
|
|
|
- String field = countVO.getField();
|
|
|
- String valueOne = countVO.getValueOne();
|
|
|
- String valueTwo = countVO.getValueTwo();
|
|
|
- if (StringUtils.isNotEmpty(valueOne) && StringUtils.isEmpty(valueTwo)) {
|
|
|
- String filterCondition = field + " = " + valueOne;
|
|
|
- if (searchCondition != null && !"".equals(searchCondition.trim())) {
|
|
|
- searchCondition = filterCondition + " AND " + searchCondition;
|
|
|
- } else {
|
|
|
- searchCondition = filterCondition;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+// if (countVOS.size() == 1) {
|
|
|
+// EsCountVO countVO = countVOS.get(0);
|
|
|
+// String field = countVO.getField();
|
|
|
+// String valueOne = countVO.getValueOne();
|
|
|
+// String valueTwo = countVO.getValueTwo();
|
|
|
+// if (StringUtils.isNotEmpty(valueOne) && StringUtils.isEmpty(valueTwo)) {
|
|
|
+// String filterCondition = field + " = " + valueOne;
|
|
|
+// if (searchCondition != null && !"".equals(searchCondition.trim())) {
|
|
|
+// searchCondition = filterCondition + " AND " + searchCondition;
|
|
|
+// } else {
|
|
|
+// searchCondition = filterCondition;
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }
|
|
|
|
|
|
if (!CollectionUtils.isEmpty(customFields)) {
|
|
|
searchCondition = esService.parseCustomField(customFields,projectId,taskId);
|
|
@@ -310,7 +310,7 @@ public class EsCountService {
|
|
|
} else {
|
|
|
filtersBuckets.forEach(filtersBucket -> {
|
|
|
Aggregate filtersAgg = filtersBucket.aggregations().get("filters_agg");
|
|
|
- this.getTermCountDTOS(filtersAgg, field, topN, detailDTOS, esCountDTO, firstName, map, values);
|
|
|
+ this.getTermCountDTOS(filtersAgg, field, topN, detailDTOS, esCountDTO, firstName, map, values,valueOne);
|
|
|
});
|
|
|
}
|
|
|
} else {
|
|
@@ -347,7 +347,7 @@ public class EsCountService {
|
|
|
} 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);
|
|
|
+ this.getTermCountDTOS(agg, field, topN, detailDTOS, esCountDTO, firstName, map, values,valueOne);
|
|
|
}
|
|
|
}
|
|
|
esCountDTO.setCondition(searchCondition);
|
|
@@ -541,45 +541,81 @@ public class EsCountService {
|
|
|
*/
|
|
|
public void getTermCountDTOS(Aggregate agg, String field, Integer topN, List<EsCountDetailDTO> detailDTOS,
|
|
|
EsCountDTO esCountDTO, String firstName,
|
|
|
- Map<String, List<EsCountDetailDTO>> map,List<String> values) {
|
|
|
+ Map<String, List<EsCountDetailDTO>> map,List<String> values,String valueOne) {
|
|
|
List<EsCountDetailDTO> countDetailDTOS = new ArrayList<>();
|
|
|
long otherNum = 0l;
|
|
|
- List<StringTermsBucket> list = agg.sterms().buckets().array();
|
|
|
- for (StringTermsBucket bucket : list) {
|
|
|
- EsCountDetailDTO dto = new EsCountDetailDTO();
|
|
|
- dto.setField(field);
|
|
|
- Aggregate aggregate = bucket.aggregations().get("filter_agg");
|
|
|
- String value = bucket.key().stringValue();
|
|
|
- if (StringUtils.isNotEmpty(value)) {
|
|
|
- dto.setName(value);
|
|
|
- dto.setNumber(bucket.docCount());
|
|
|
- dto.setTopN(topN);
|
|
|
- dto.setFirstName(firstName);
|
|
|
- if (aggregate != null) {
|
|
|
- dto.setNumber(aggregate.filter().docCount());
|
|
|
+ if (StringUtils.isNotEmpty(valueOne)) {
|
|
|
+ Aggregate filterAgg = agg.filter().aggregations().get("filter_agg");
|
|
|
+ List<StringTermsBucket> list = filterAgg.sterms().buckets().array();
|
|
|
+ for (StringTermsBucket bucket : list) {
|
|
|
+ EsCountDetailDTO dto = new EsCountDetailDTO();
|
|
|
+ dto.setField(field);
|
|
|
+ String value = bucket.key().stringValue();
|
|
|
+ if (StringUtils.isNotEmpty(value)) {
|
|
|
+ dto.setName(value);
|
|
|
+ dto.setNumber(bucket.docCount());
|
|
|
+ dto.setTopN(topN);
|
|
|
+ dto.setFirstName(firstName);
|
|
|
+ if (dto.getNumber() > 0) {
|
|
|
+ countDetailDTOS.add(dto);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ otherNum += 1;
|
|
|
}
|
|
|
- if (dto.getNumber() > 0) {
|
|
|
- countDetailDTOS.add(dto);
|
|
|
+ }
|
|
|
+ if (countDetailDTOS.size() > topN) {
|
|
|
+ countDetailDTOS.remove(countDetailDTOS.size() - 1);
|
|
|
+ }
|
|
|
+
|
|
|
+ EsCountDetailDTO countDTO = new EsCountDetailDTO();
|
|
|
+ countDTO.setField(field);
|
|
|
+ countDTO.setName("其他");
|
|
|
+ countDTO.setTopN(topN);
|
|
|
+ Long count = filterAgg.sterms().sumOtherDocCount();
|
|
|
+ if (count > 0) {
|
|
|
+ countDTO.setNumber(count + otherNum);
|
|
|
+ countDetailDTOS.add(countDTO);
|
|
|
+ }
|
|
|
+ esCountDTO.setRemainingNum(count);
|
|
|
+ } else {
|
|
|
+ List<StringTermsBucket> list = agg.sterms().buckets().array();
|
|
|
+ for (StringTermsBucket bucket : list) {
|
|
|
+ EsCountDetailDTO dto = new EsCountDetailDTO();
|
|
|
+ dto.setField(field);
|
|
|
+ Aggregate aggregate = bucket.aggregations().get("filter_agg");
|
|
|
+ String value = bucket.key().stringValue();
|
|
|
+ if (StringUtils.isNotEmpty(value)) {
|
|
|
+ dto.setName(value);
|
|
|
+ dto.setNumber(bucket.docCount());
|
|
|
+ dto.setTopN(topN);
|
|
|
+ dto.setFirstName(firstName);
|
|
|
+ if (aggregate != null) {
|
|
|
+ dto.setNumber(aggregate.filter().docCount());
|
|
|
+ }
|
|
|
+ if (dto.getNumber() > 0) {
|
|
|
+ countDetailDTOS.add(dto);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ otherNum += 1;
|
|
|
}
|
|
|
- } else {
|
|
|
- otherNum += 1;
|
|
|
}
|
|
|
- }
|
|
|
|
|
|
- if (countDetailDTOS.size() > topN) {
|
|
|
- countDetailDTOS.remove(countDetailDTOS.size() - 1);
|
|
|
- }
|
|
|
+ if (countDetailDTOS.size() > topN) {
|
|
|
+ countDetailDTOS.remove(countDetailDTOS.size() - 1);
|
|
|
+ }
|
|
|
|
|
|
- EsCountDetailDTO countDTO = new EsCountDetailDTO();
|
|
|
- countDTO.setField(field);
|
|
|
- countDTO.setName("其他");
|
|
|
- countDTO.setTopN(topN);
|
|
|
- Long count = agg.sterms().sumOtherDocCount();
|
|
|
- if (count > 0) {
|
|
|
- countDTO.setNumber(count + otherNum);
|
|
|
- detailDTOS.add(countDTO);
|
|
|
+ EsCountDetailDTO countDTO = new EsCountDetailDTO();
|
|
|
+ countDTO.setField(field);
|
|
|
+ countDTO.setName("其他");
|
|
|
+ countDTO.setTopN(topN);
|
|
|
+ Long count = agg.sterms().sumOtherDocCount();
|
|
|
+ if (count > 0) {
|
|
|
+ countDTO.setNumber(count + otherNum);
|
|
|
+ detailDTOS.add(countDTO);
|
|
|
+ }
|
|
|
+ esCountDTO.setRemainingNum(count);
|
|
|
}
|
|
|
- esCountDTO.setRemainingNum(count);
|
|
|
+
|
|
|
|
|
|
List<String> strs = new ArrayList<>();
|
|
|
if (!CollectionUtils.isEmpty(values)) {
|