Commit 2fece278 authored by tianyiming's avatar tianyiming

feat: 增加SUPERVISORY_CODE判断和压力管道长度统计查询功能

feat: 大屏总览管道查询修改为查询es
parent 1298b897
...@@ -1299,6 +1299,8 @@ public class ComprehensiveStatisticalAnalysisServiceImpl { ...@@ -1299,6 +1299,8 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
BigDecimal pipeLong; BigDecimal pipeLong;
BoolQueryBuilder pipeLengthQuery = QueryBuilderUtils.copyBoolQuery(boolMust); BoolQueryBuilder pipeLengthQuery = QueryBuilderUtils.copyBoolQuery(boolMust);
pipeLengthQuery.must(QueryBuilders.existsQuery("pipeLength")); pipeLengthQuery.must(QueryBuilders.existsQuery("pipeLength"));
pipeLengthQuery.must(existsQuery("SUPERVISORY_CODE"));
pipeLengthQuery.mustNot(QueryBuilders.termQuery("SUPERVISORY_CODE",""));
SumAggregationBuilder pipeLengthAgg = AggregationBuilders.sum(countField).field("pipeLength").missing(0); SumAggregationBuilder pipeLengthAgg = AggregationBuilders.sum(countField).field("pipeLength").missing(0);
builder.aggregation(pipeLengthAgg).size(0); builder.aggregation(pipeLengthAgg).size(0);
request.source(builder); request.source(builder);
......
...@@ -67,6 +67,8 @@ import org.elasticsearch.search.SearchHit; ...@@ -67,6 +67,8 @@ import org.elasticsearch.search.SearchHit;
import org.elasticsearch.search.aggregations.AggregationBuilders; 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.aggregations.metrics.ParsedSum;
import org.elasticsearch.search.aggregations.metrics.SumAggregationBuilder;
import org.elasticsearch.search.builder.SearchSourceBuilder; import org.elasticsearch.search.builder.SearchSourceBuilder;
import org.elasticsearch.search.sort.SortOrder; import org.elasticsearch.search.sort.SortOrder;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
...@@ -92,6 +94,7 @@ import java.util.function.Function; ...@@ -92,6 +94,7 @@ import java.util.function.Function;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import static com.alibaba.fastjson.JSON.parseArray; import static com.alibaba.fastjson.JSON.parseArray;
import static org.elasticsearch.index.query.QueryBuilders.existsQuery;
/** /**
* 大屏统计实现类 * 大屏统计实现类
...@@ -385,7 +388,9 @@ public class JGDPStatisticsServiceImpl { ...@@ -385,7 +388,9 @@ public class JGDPStatisticsServiceImpl {
long hasSupervisoryCodeEquipCount = stCommonService.queryHasSupervisoryCodeEquipCount(orgCode, false); long hasSupervisoryCodeEquipCount = stCommonService.queryHasSupervisoryCodeEquipCount(orgCode, false);
result.put("total", hasSupervisoryCodeEquipCount); result.put("total", hasSupervisoryCodeEquipCount);
//2.压力管道长度统计 //2.压力管道长度统计
stCommonService.staticsCenterMapCountDataForPipeline(result, orgCode, true, false); // 修改为查询es
// stCommonService.staticsCenterMapCountDataForPipeline(result, orgCode, true, false);
this.staticsCenterMapCountPipLine(result, orgCode);
//3.单位数量统计 //3.单位数量统计
this.staticsCenterMapCountDataForCompany(result, orgCode, dpFilterParamDto.getCityCode()); this.staticsCenterMapCountDataForCompany(result, orgCode, dpFilterParamDto.getCityCode());
//4.人员数量统计 //4.人员数量统计
...@@ -419,7 +424,9 @@ public class JGDPStatisticsServiceImpl { ...@@ -419,7 +424,9 @@ public class JGDPStatisticsServiceImpl {
// 1. 8大类设备数量统计,压力容器里包括气瓶所以需要特殊处理,在统计压力容器时去掉气瓶的数量 // 1. 8大类设备数量统计,压力容器里包括气瓶所以需要特殊处理,在统计压力容器时去掉气瓶的数量
stCommonService.staticsCenterMapCountDataForEquip(result, cylinderNum, orgCode, true, true, false); stCommonService.staticsCenterMapCountDataForEquip(result, cylinderNum, orgCode, true, true, false);
// 2. 压力管道长度统计 // 2. 压力管道长度统计
stCommonService.staticsCenterMapCountDataForPipeline(result, orgCode, true, false); // 修改为查询es
//stCommonService.staticsCenterMapCountDataForPipeline(result, orgCode, true, false);
this.staticsCenterMapCountPipLine(result, orgCode);
// 3. 人员数量统计 // 3. 人员数量统计
this.staticsCenterMapCountDataForPerson(result, dpFilterParamDto, orgCode); this.staticsCenterMapCountDataForPerson(result, dpFilterParamDto, orgCode);
return result; return result;
...@@ -468,6 +475,31 @@ public class JGDPStatisticsServiceImpl { ...@@ -468,6 +475,31 @@ public class JGDPStatisticsServiceImpl {
result.put(DPMapStatisticsItemEnum.PERSON_TOTAL.getCode(), personSum); result.put(DPMapStatisticsItemEnum.PERSON_TOTAL.getCode(), personSum);
} }
private void staticsCenterMapCountPipLine(Map<String, Object> result, String orgCode) {
SearchRequest request = new SearchRequest();
SearchSourceBuilder builder = new SearchSourceBuilder();
request.indices(StatisticalAnalysisEnum.equip.getKey());
BigDecimal pipeLong;
BoolQueryBuilder pipeLengthQuery = new BoolQueryBuilder();
pipeLengthQuery.must(QueryBuilders.prefixQuery("ORG_BRANCH_CODE", orgCode));
pipeLengthQuery.must(QueryBuilders.existsQuery("pipeLength"));
pipeLengthQuery.must(existsQuery("SUPERVISORY_CODE"));
pipeLengthQuery.mustNot(QueryBuilders.termQuery("SUPERVISORY_CODE", ""));
SumAggregationBuilder pipeLengthAgg = AggregationBuilders.sum("pipeLengthSum").field("pipeLength").missing(0);
builder.aggregation(pipeLengthAgg).size(0);
request.source(builder);
try {
SearchResponse response = restHighLevelClient.search(request, RequestOptions.DEFAULT);
ParsedSum sumAgg = response.getAggregations().get("pipeLengthSum");
double value = sumAgg.getValue();
pipeLong = new BigDecimal(value);
} catch (IOException e) {
throw new RuntimeException(e);
}
result.put(DPMapStatisticsItemEnum.PRESSURE_PIPELINES.getCode(), pipeLong.divide(new BigDecimal(1000), 2, BigDecimal.ROUND_HALF_UP));
}
private void staticsCenterMapCountDataForCompany(Map<String, Object> result, String orgCode, String cityCode) { private void staticsCenterMapCountDataForCompany(Map<String, Object> result, String orgCode, String cityCode) {
if (orgCode == null) { if (orgCode == null) {
setDefaultCompanyCountData(result); setDefaultCompanyCountData(result);
......
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