Commit cb2ac403 authored by 韩桐桐's avatar 韩桐桐

大屏应急统计调整

parent 8043834c
...@@ -41,7 +41,6 @@ import org.elasticsearch.search.aggregations.AggregationBuilders; ...@@ -41,7 +41,6 @@ import org.elasticsearch.search.aggregations.AggregationBuilders;
import org.elasticsearch.search.aggregations.bucket.terms.Terms; import org.elasticsearch.search.aggregations.bucket.terms.Terms;
import org.elasticsearch.search.aggregations.bucket.terms.TermsAggregationBuilder; import org.elasticsearch.search.aggregations.bucket.terms.TermsAggregationBuilder;
import org.elasticsearch.search.builder.SearchSourceBuilder; import org.elasticsearch.search.builder.SearchSourceBuilder;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import org.typroject.tyboot.core.foundation.utils.Bean; import org.typroject.tyboot.core.foundation.utils.Bean;
...@@ -97,6 +96,10 @@ public class YJDPStatisticsServiceImpl { ...@@ -97,6 +96,10 @@ public class YJDPStatisticsServiceImpl {
* 电梯设备品种 * 电梯设备品种
*/ */
private final static String ELEVATOR_EQU_DEFINE_CODES = "3410,3420,3430,3310,3320,3210,3220,3120,3130,3110"; private final static String ELEVATOR_EQU_DEFINE_CODES = "3410,3420,3430,3310,3320,3210,3220,3120,3130,3110";
/**
* 电梯种类
*/
private final static String ELEVATOR_EQU_LIST_CODE = "3000";
public YJDPStatisticsServiceImpl(AlertCalledMapper alertCalledMapper, AlertRescueStatisticsMapper alertRescueStatisticsMapper, AlertUseUnitStatisticsMapper alertUseUnitStatisticsMapper, AlertStatisticsMapper alertStatisticsMapper, DispatchTaskMapper dispatchTaskMapper, RestHighLevelClient restHighLevelClient, StCommonServiceImpl stCommonService, DataDictionaryServiceImpl dataDictionaryService) { public YJDPStatisticsServiceImpl(AlertCalledMapper alertCalledMapper, AlertRescueStatisticsMapper alertRescueStatisticsMapper, AlertUseUnitStatisticsMapper alertUseUnitStatisticsMapper, AlertStatisticsMapper alertStatisticsMapper, DispatchTaskMapper dispatchTaskMapper, RestHighLevelClient restHighLevelClient, StCommonServiceImpl stCommonService, DataDictionaryServiceImpl dataDictionaryService) {
...@@ -463,7 +466,17 @@ public class YJDPStatisticsServiceImpl { ...@@ -463,7 +466,17 @@ public class YJDPStatisticsServiceImpl {
Map<String, Long> alertTypeNumMap = countDtos.stream().collect(Collectors.toMap(CountDto::getKeyStr, CountDto::getLongValue)); Map<String, Long> alertTypeNumMap = countDtos.stream().collect(Collectors.toMap(CountDto::getKeyStr, CountDto::getLongValue));
Map<String, Long> equDefineNumMap = staticsElevatorByEquDefine(filterParamDto.getCityCode()); Map<String, Long> equDefineNumMap = staticsElevatorByEquDefine(filterParamDto.getCityCode());
// 电梯总量(台) // 电梯总量(台)
result.put("dtCount", equDefineNumMap.values().stream().mapToLong(e -> e).sum()); Long dtCount = equDefineNumMap.getOrDefault(ELEVATOR_EQU_LIST_CODE, 0L);
result.put("dtCount", dtCount);
// 无设备品种的电梯数量(台)
long dtEquDefineCount = equDefineNumMap.entrySet()
.stream()
.filter(entry -> !ELEVATOR_EQU_LIST_CODE.equals(entry.getKey()))
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue))
.values()
.stream()
.mapToLong(e -> e).sum();
result.put("dtCountNotEquDefine", dtCount - dtEquDefineCount);
// 曳引驱动乘客电梯(台) // 曳引驱动乘客电梯(台)
result.put("zyqdcjdtCount", equDefineNumMap.getOrDefault("3110", 0L)); result.put("zyqdcjdtCount", equDefineNumMap.getOrDefault("3110", 0L));
// 曳引驱动载货电梯(台) // 曳引驱动载货电梯(台)
...@@ -560,16 +573,24 @@ public class YJDPStatisticsServiceImpl { ...@@ -560,16 +573,24 @@ public class YJDPStatisticsServiceImpl {
// 且设备品种3级,按照真实的过滤,防止有脏数据 // 且设备品种3级,按照真实的过滤,防止有脏数据
boolMust.must(QueryBuilders.termsQuery("EQU_DEFINE_CODE.keyword", ELEVATOR_EQU_DEFINE_CODES.split(","))); boolMust.must(QueryBuilders.termsQuery("EQU_DEFINE_CODE.keyword", ELEVATOR_EQU_DEFINE_CODES.split(",")));
boolMust.must(QueryBuilders.termsQuery("EQU_LIST_CODE",ELEVATOR_EQU_LIST_CODE));
SearchSourceBuilder builder = new SearchSourceBuilder(); SearchSourceBuilder builder = new SearchSourceBuilder();
builder.query(boolMust); builder.query(boolMust);
builder.size(0);
// 原因默认10个,由于业务最多有10个,担心有脏数据,故多查询 // 原因默认10个,由于业务最多有10个,担心有脏数据,故多查询
TermsAggregationBuilder aggregationBuilder = AggregationBuilders.terms("count_by_equ_define_code").field("EQU_DEFINE_CODE.keyword").size(20); TermsAggregationBuilder aggregationBuilder = AggregationBuilders.terms("count_by_equ_define_code").field("EQU_DEFINE_CODE.keyword").size(20);
builder.aggregation(aggregationBuilder); builder.aggregation(aggregationBuilder);
TermsAggregationBuilder aggregationBuilder1 = AggregationBuilders.terms("count_by_equ_list_code").field("EQU_LIST_CODE").size(20);
builder.aggregation(aggregationBuilder1);
request.source(builder); request.source(builder);
try { try {
SearchResponse response = restHighLevelClient.search(request, RequestOptions.DEFAULT); SearchResponse response = restHighLevelClient.search(request, RequestOptions.DEFAULT);
Terms terms = response.getAggregations().get("count_by_equ_define_code"); Terms equDefineTerms = response.getAggregations().get("count_by_equ_define_code");
for (Terms.Bucket bucket : terms.getBuckets()) { for (Terms.Bucket bucket : equDefineTerms.getBuckets()) {
countMap.put(bucket.getKeyAsString(), bucket.getDocCount());
}
Terms equListTerms = response.getAggregations().get("count_by_equ_list_code");
for (Terms.Bucket bucket : equListTerms.getBuckets()) {
countMap.put(bucket.getKeyAsString(), bucket.getDocCount()); countMap.put(bucket.getKeyAsString(), bucket.getDocCount());
} }
} catch (IOException e) { } catch (IOException 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