Commit a15bd290 authored by tianyiming's avatar tianyiming

refactor: 优化组织代码查询逻辑

parent 7c5e2b8a
......@@ -2631,7 +2631,15 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
List<Map<String, Object>> data = new ArrayList<>();
if (StatisticalAnalysisEnum.equip.getCode().equals(businessType)) {
if (orgCode.equals("50")) {
DynamicQueryBuilder dynamicQueryBuilder = new DynamicQueryBuilder();
dynamicQueryBuilder.or(QueryBuilders.prefixQuery("ORG_BRANCH_CODE", orgCode));
dynamicQueryBuilder.or(QueryBuilders.boolQuery().must(QueryBuilders.termQuery("ORG_BRANCH_CODE","")));
dynamicQueryBuilder.or(QueryBuilders.boolQuery().mustNot(QueryBuilders.existsQuery("ORG_BRANCH_CODE")));
boolMust.must(dynamicQueryBuilder.build());
} else {
boolMust.must(QueryBuilders.prefixQuery("ORG_BRANCH_CODE", orgCode));
}
data = queryDpEquipStatistics(filter, request, builder, boolMust, tabTotalMap);
} else if (StatisticalAnalysisEnum.company.getCode().equals(businessType)) {
boolMust.must(QueryBuilders.prefixQuery("superviseOrgCode", orgCode));
......@@ -2650,8 +2658,16 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
private void getTypeCount(String businessType, Map<String, Object> tabTotalMap, String orgCode, List<Map<String, Object>> data) {
BoolQueryBuilder equipBoolMust = QueryBuilders.boolQuery();
if (orgCode.equals("50")) {
DynamicQueryBuilder dynamicQueryBuilder = new DynamicQueryBuilder();
dynamicQueryBuilder.or(QueryBuilders.prefixQuery("ORG_BRANCH_CODE", orgCode));
dynamicQueryBuilder.or(QueryBuilders.boolQuery().must(QueryBuilders.termQuery("ORG_BRANCH_CODE","")));
dynamicQueryBuilder.or(QueryBuilders.boolQuery().mustNot(QueryBuilders.existsQuery("ORG_BRANCH_CODE")));
equipBoolMust.must(dynamicQueryBuilder.build());
} else {
equipBoolMust.must(QueryBuilders.prefixQuery("ORG_BRANCH_CODE", orgCode));
equipBoolMust.mustNot(QueryBuilders.termsQuery("STATUS",Arrays.asList("草稿","已拒领","待认领")));
}
equipBoolMust.mustNot(QueryBuilders.termsQuery("STATUS", Arrays.asList("草稿", "已拒领", "待认领")));
BoolQueryBuilder companyBoolMust = QueryBuilders.boolQuery();
companyBoolMust.must(QueryBuilders.prefixQuery("superviseOrgCode", orgCode));
BoolQueryBuilder personBoolMust = QueryBuilders.boolQuery();
......@@ -2822,13 +2838,13 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
Map<String, List<Map<String, Object>>> resourceJson = JsonUtils.getResourceJson(equipCategory);
staticCountByGroupMap = resourceJson.get(EquipmentClassifityEnum.ZHTJFX.getCode());
}
boolMust.mustNot(QueryBuilders.termsQuery("STATUS",Arrays.asList("草稿","已拒领","待认领")));
boolMust.mustNot(QueryBuilders.termsQuery("STATUS", Arrays.asList("草稿", "已拒领", "待认领")));
Map<String, Long> staticCountByGroup = new HashMap<>();
getStatisticCountByGroup(request, builder, boolMust, groupField, staticCountByGroup);
Long otherCount = staticCountByGroup.values().stream().reduce(0L, Long::sum);
tabTotalMap.put(StatisticalAnalysisEnum.equip.getCode(), otherCount);
Long equipCount = staticCountByGroup.values().stream().reduce(0L, Long::sum);
tabTotalMap.put(StatisticalAnalysisEnum.equip.getCode(), equipCount);
// 组装数据
List<Map<String, Object>> dataMapList = new ArrayList<>();
......@@ -2857,7 +2873,7 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
map.put("NEXT_INSPECT_DATE", nextInspectCountByGroup);
dataMapList.add(map);
}
if(!ObjectUtils.isEmpty(equipCode)){
if (!ObjectUtils.isEmpty(equipCode)) {
tabTotalMap.put(equipCode, dataMapList.stream().mapToLong(map -> (Long) map.get("value")).sum());
}
return dataMapList;
......
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