Commit 7557ed3d authored by tianyiming's avatar tianyiming

更新大屏设备统计接口

parent bea3202d
......@@ -8,7 +8,7 @@
code as value,
name as label
from tz_equipment_category
where parent_id = #{parentId}
where is_delete = 0 and parent_id = #{parentId}
</select>
<select id="queryEquCategory" resultType="com.alibaba.fastjson.JSONObject">
......@@ -19,7 +19,8 @@
FROM
tz_equipment_category
WHERE
description = #{description}
is_delete = 0
and description = #{description}
<if test="type != null and type != ''">
AND parent_id = (SELECT id FROM tz_equipment_category where code = #{type})
</if>
......
......@@ -110,6 +110,8 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
private final String DOWNLOAD_TOPIC = "/topic/download/excel/%s";
private final String BUCKET_NAME = "upload";
private final String UPLOAD_PATH = "/tzs/excelTempFile";
// 大屏统计图片路径前缀
private final String dpEquipPhotoPrefix = "/upload/tzs/dpscreen/statistic/equip/";
private final List<String> equipHandleOtherFields = Arrays.asList("techParam", "paramRange", "JDJY", "DQJY", "SCJY", "DTJY", "QZ_OR_TANK");
private final List<String> companyHandleOtherFields = Arrays.asList("itemCode", "subItemCode", "permitStatus", "equipCategory", "regulatoryLabels", "unitType");
......@@ -2687,22 +2689,42 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
}
JSONArray typeData = filter.getJSONArray("typeData");
String groupField = "EQU_LIST_CODE";
String groupField = null;
List<Map<String, Object>> staticCountByGroupMap = new ArrayList<>();
if (!ObjectUtils.isEmpty(typeData)) {
String id = null;
if (typeData.size() == 1) {
groupField = "EQU_LIST_CODE";
} else if (typeData.size() == 2) {
groupField = "EQU_CATEGORY_CODE";
} else if (typeData.size() == 3) {
id = JSONObject.parseObject(JSONObject.toJSONString(typeData.get(0))).getString("key");
} else if (typeData.size() == 2) {
groupField = "EQU_DEFINE_CODE";
id = JSONObject.parseObject(JSONObject.toJSONString(typeData.get(1))).getString("key");
}
staticCountByGroupMap = tzsCustomFilterMapper.selectEquipmentCategoryByParentId(id);
} else {
groupField = "EQU_LIST_CODE";
Map<String, List<Map<String, Object>>> resourceJson = JsonUtils.getResourceJson(equipCategory);
staticCountByGroupMap = resourceJson.get(EquipmentClassifityEnum.ZHTJFX.getCode());
}
List<Map<String, Object>> staticCountByGroup = new ArrayList<>();
getStaticCountByGroup(request, builder, boolMust, groupField, tabTotalMap, staticCountByGroup, StatisticalAnalysisEnum.equip.getCode());
return staticCountByGroup;
List<Map<String, Long>> staticCountByGroup = new ArrayList<>();
getStaticCountByGroup(request, builder, boolMust, groupField, staticCountByGroup);
Long otherCount = staticCountByGroup.stream().map(item -> item.values().stream().reduce(0L, Long::sum)).reduce(0L, Long::sum);
tabTotalMap.put(StatisticalAnalysisEnum.equip.getCode(), otherCount);
for (Map<String, Object> map : staticCountByGroupMap) {
}
return staticCountByGroupMap;
}
private void getStaticCountByGroup(SearchRequest request, SearchSourceBuilder builder, BoolQueryBuilder boolMust, String groupField, Map<String, Object> tabTotalMap, List<Map<String, Object>> staticCountByGroup,String businessType) {
private void getStaticCountByGroup(SearchRequest request, SearchSourceBuilder builder, BoolQueryBuilder boolMust, String groupField, List<Map<String, Long>> staticCountByGroup) {
builder.query(boolMust);
builder.aggregation(AggregationBuilders.terms(groupField).field(groupField).missing("null"));
......@@ -2710,14 +2732,11 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
try {
SearchResponse response = restHighLevelClient.search(request, RequestOptions.DEFAULT);
Terms terms = response.getAggregations().get(groupField);
Long otherCount = 0L;
for (Terms.Bucket bucket : terms.getBuckets()) {
Map<String, Object> groupMap = new HashMap<>();
Map<String, Long> groupMap = new HashMap<>();
groupMap.put(bucket.getKeyAsString(), bucket.getDocCount());
staticCountByGroup.add(groupMap);
otherCount += bucket.getDocCount();
}
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