Commit 8a7545d7 authored by tianyiming's avatar tianyiming

更新代码

parent c855e24d
......@@ -2641,9 +2641,6 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
String companyIndex = StatisticalAnalysisEnum.company.getKey();
String personIndex = StatisticalAnalysisEnum.person.getKey();
List<Long> collect = data.stream().map(e -> Long.valueOf(e.get("value").toString())).collect(Collectors.toList());
Long otherCount = collect.stream().reduce(0L, Long::sum);
if (businessType.equals(StatisticalAnalysisEnum.equip.getCode())) {
// 获取企业总数
Long companyCount = getStaticCount(companyBoolMust, companyIndex);
......@@ -2651,7 +2648,6 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
Long personCount = getStaticCount(personBoolMust, personIndex);
tabTotalMap.put(StatisticalAnalysisEnum.company.getCode(), companyCount);
tabTotalMap.put(StatisticalAnalysisEnum.person.getCode(), personCount);
tabTotalMap.put(StatisticalAnalysisEnum.equip.getCode(), otherCount);
} else if (businessType.equals(StatisticalAnalysisEnum.company.getCode())) {
// 获取设备总数
Long equipCount = getStaticCount(equipBoolMust, equipIndex);
......@@ -2659,7 +2655,6 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
Long personCount = getStaticCount(personBoolMust, personIndex);
tabTotalMap.put(StatisticalAnalysisEnum.equip.getCode(), equipCount);
tabTotalMap.put(StatisticalAnalysisEnum.person.getCode(), personCount);
tabTotalMap.put(StatisticalAnalysisEnum.company.getCode(), otherCount);
} else {
// 获取设备总数
Long equipCount = getStaticCount(equipBoolMust, equipIndex);
......@@ -2667,7 +2662,6 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
Long companyCount = getStaticCount(companyBoolMust, companyIndex);
tabTotalMap.put(StatisticalAnalysisEnum.equip.getCode(), equipCount);
tabTotalMap.put(StatisticalAnalysisEnum.company.getCode(), companyCount);
tabTotalMap.put(StatisticalAnalysisEnum.person.getCode(), otherCount);
}
}
......@@ -2703,26 +2697,27 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
groupField = "EQU_DEFINE_CODE";
}
}
List<Map<String, Object>> staticCountByGroup = getStaticCountByGroup(request, builder, boolMust, groupField);
List<Map<String, Object>> staticCountByGroup = new ArrayList<>();
getStaticCountByGroup(request, builder, boolMust, groupField, tabTotalMap, staticCountByGroup, StatisticalAnalysisEnum.equip.getCode());
return staticCountByGroup;
}
private List<Map<String, Object>> getStaticCountByGroup(SearchRequest request, SearchSourceBuilder builder, BoolQueryBuilder boolMust, String groupField) {
private void getStaticCountByGroup(SearchRequest request, SearchSourceBuilder builder, BoolQueryBuilder boolMust, String groupField, Map<String, Object> tabTotalMap, List<Map<String, Object>> staticCountByGroup,String businessType) {
builder.query(boolMust);
builder.aggregation(AggregationBuilders.terms(groupField).field(groupField).missing("null"));
request.source(builder);
List<Map<String, Object>> data = new ArrayList<>();
try {
SearchResponse response = restHighLevelClient.search(request, RequestOptions.DEFAULT);
Terms terms = response.getAggregations().get(groupField);
Map<String, Object> groupMap = new HashMap<>();
Long otherCount = 0L;
for (Terms.Bucket bucket : terms.getBuckets()) {
Map<String, Object> groupMap = new HashMap<>();
groupMap.put(bucket.getKeyAsString(), bucket.getDocCount());
data.add(groupMap);
staticCountByGroup.add(groupMap);
otherCount += bucket.getDocCount();
}
return data;
tabTotalMap.put(businessType, otherCount);
} catch (IOException e) {
throw new RuntimeException(e);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment