Commit f813eeb5 authored by tianyiming's avatar tianyiming

大屏设备统计-增加一类二类三类数据块

parent 2c65fde4
...@@ -3286,6 +3286,7 @@ public class ComprehensiveStatisticalAnalysisServiceImpl { ...@@ -3286,6 +3286,7 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
Map<String, Object> staticCountByGroup = new HashMap<>(); Map<String, Object> staticCountByGroup = new HashMap<>();
// 组装数据 // 组装数据
List<Map<String, Object>> resultList = new ArrayList<>();
List<Map<String, Object>> dataMapList = new ArrayList<>(); List<Map<String, Object>> dataMapList = new ArrayList<>();
// 当设备默认进入时候,提前复制前置查询条件,供气瓶提级使用 // 当设备默认进入时候,提前复制前置查询条件,供气瓶提级使用
BoolQueryBuilder gasBoolQueryBuilder = new BoolQueryBuilder(); BoolQueryBuilder gasBoolQueryBuilder = new BoolQueryBuilder();
...@@ -3307,6 +3308,9 @@ public class ComprehensiveStatisticalAnalysisServiceImpl { ...@@ -3307,6 +3308,9 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
List<String> codes = new ArrayList<>(); List<String> codes = new ArrayList<>();
BoolQueryBuilder pipeBoolMust = QueryBuilderUtils.copyBoolQuery(boolMust); BoolQueryBuilder pipeBoolMust = QueryBuilderUtils.copyBoolQuery(boolMust);
Long oneClassCount = 0L;
Long twoClassCount = 0L;
Long threeClassCount = 0L;
for (Map<String, Object> categoryMap : staticCountByGroupMap) { for (Map<String, Object> categoryMap : staticCountByGroupMap) {
BoolQueryBuilder queryBuilder = QueryBuilderUtils.copyBoolQuery(pipeBoolMust); BoolQueryBuilder queryBuilder = QueryBuilderUtils.copyBoolQuery(pipeBoolMust);
String code = categoryMap.get("value").toString(); String code = categoryMap.get("value").toString();
...@@ -3339,6 +3343,11 @@ public class ComprehensiveStatisticalAnalysisServiceImpl { ...@@ -3339,6 +3343,11 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
SearchSourceBuilder scoreBuilder = new SearchSourceBuilder(); SearchSourceBuilder scoreBuilder = new SearchSourceBuilder();
Map<String, Object> scoreCountByGroup = new HashMap<>(); Map<String, Object> scoreCountByGroup = new HashMap<>();
getStatisticCountByGroup(request, scoreBuilder, scoreQuery, "DATA_QUALITY_SCORE", scoreCountByGroup, "scoreCount"); getStatisticCountByGroup(request, scoreBuilder, scoreQuery, "DATA_QUALITY_SCORE", scoreCountByGroup, "scoreCount");
if(!code.startsWith("8")){
for (String key : scoreCountByGroup.keySet()) {
Long classCount = "1".equals(key) ? oneClassCount += (Long) scoreCountByGroup.get(key) : ("2".equals(key) ? (twoClassCount += (Long) scoreCountByGroup.get(key)) : (threeClassCount += (Long) scoreCountByGroup.get(key)));
}
}
map.put("DATA_QUALITY_SCORE", scoreCountByGroup); map.put("DATA_QUALITY_SCORE", scoreCountByGroup);
// 统计该分类下红黄绿码分别的分组数量 NEXT_INSPECT_DATE // 统计该分类下红黄绿码分别的分组数量 NEXT_INSPECT_DATE
Map<String, Long> nextInspectCountByGroup = new HashMap<>(); Map<String, Long> nextInspectCountByGroup = new HashMap<>();
...@@ -3382,6 +3391,9 @@ public class ComprehensiveStatisticalAnalysisServiceImpl { ...@@ -3382,6 +3391,9 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
Map<String, Object> scoreCountByGroup = new HashMap<>(); Map<String, Object> scoreCountByGroup = new HashMap<>();
getStatisticCountByGroup(request, scoreBuilder, scoreQuery, "DATA_QUALITY_SCORE", scoreCountByGroup, "scoreCount"); getStatisticCountByGroup(request, scoreBuilder, scoreQuery, "DATA_QUALITY_SCORE", scoreCountByGroup, "scoreCount");
map.put("DATA_QUALITY_SCORE", scoreCountByGroup); map.put("DATA_QUALITY_SCORE", scoreCountByGroup);
for (String key : scoreCountByGroup.keySet()) {
Long classCount = "1".equals(key) ? oneClassCount += (Long) scoreCountByGroup.get(key) : ("2".equals(key) ? (twoClassCount += (Long) scoreCountByGroup.get(key)) : (threeClassCount += (Long) scoreCountByGroup.get(key)));
}
// 统计该分类下红黄绿码分别的分组数量 NEXT_INSPECT_DATE // 统计该分类下红黄绿码分别的分组数量 NEXT_INSPECT_DATE
Map<String, Long> nextInspectCountByGroup = new HashMap<>(); Map<String, Long> nextInspectCountByGroup = new HashMap<>();
BoolQueryBuilder nextInspectQuery = QueryBuilderUtils.copyBoolQuery(gasBoolQueryBuilder); BoolQueryBuilder nextInspectQuery = QueryBuilderUtils.copyBoolQuery(gasBoolQueryBuilder);
...@@ -3409,6 +3421,10 @@ public class ComprehensiveStatisticalAnalysisServiceImpl { ...@@ -3409,6 +3421,10 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
// 统计种类/类别/品种数据不对的数据字段 // 统计种类/类别/品种数据不对的数据字段
if (!ObjectUtils.isEmpty(staticCountByGroup)) { if (!ObjectUtils.isEmpty(staticCountByGroup)) {
statisticOtherCount(request, dataMapList, staticCountByGroup, boolMust, groupField, equipCode); statisticOtherCount(request, dataMapList, staticCountByGroup, boolMust, groupField, equipCode);
Map<String, Long> otherMap = (Map<String, Long>) dataMapList.get(dataMapList.size() - 1).get("DATA_QUALITY_SCORE");
oneClassCount += otherMap.containsKey("1") ? otherMap.get("1") : 0L;
twoClassCount += otherMap.containsKey("2") ? otherMap.get("2") : 0L;
threeClassCount += otherMap.containsKey("3") ? otherMap.get("3") : 0L;
} }
if (!ObjectUtils.isEmpty(equipCode)) { if (!ObjectUtils.isEmpty(equipCode)) {
...@@ -3423,7 +3439,20 @@ public class ComprehensiveStatisticalAnalysisServiceImpl { ...@@ -3423,7 +3439,20 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
tabTotalMap.put(equipCode, dataMapList.stream().mapToLong(map -> (Long) map.get("value")).sum()); tabTotalMap.put(equipCode, dataMapList.stream().mapToLong(map -> (Long) map.get("value")).sum());
} }
} }
return dataMapList; for (int i = 1; i < 4; i++) {
Map<String, Object> map = new HashMap<>();
map.put("key", i);
map.put("code", i);
map.put("noChild", Boolean.TRUE);
map.put("noDetails", Boolean.TRUE);
map.put("noBottom", Boolean.TRUE);
map.put("fieldKey", "DATA_QUALITY_SCORE");
map.put("label", i == 1 ? "一类设备" : i == 2 ? "二类设备" : "三类设备");
map.put("value", i == 1 ? oneClassCount : i == 2 ? twoClassCount : threeClassCount);
resultList.add(map);
}
resultList.addAll(dataMapList);
return resultList;
} }
private void statisticOtherCount(SearchRequest request, List<Map<String, Object>> dataMapList, Map<String, Object> staticCountByGroup, BoolQueryBuilder boolMust, String groupField, String equipCode) { private void statisticOtherCount(SearchRequest request, List<Map<String, Object>> dataMapList, Map<String, Object> staticCountByGroup, BoolQueryBuilder boolMust, String groupField, String equipCode) {
......
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