Commit 0af2db3d authored by suhuiguang's avatar suhuiguang

1.检验检测大屏接口接口开发

parent cd8fd7d1
...@@ -109,14 +109,13 @@ public class DPStatisticsServiceImpl { ...@@ -109,14 +109,13 @@ public class DPStatisticsServiceImpl {
private TzsUserInfoMapper userInfoMapper; private TzsUserInfoMapper userInfoMapper;
private RedisUtils redisUtils;
private static Map<String, String> regionCodeOrgCodeMap = new ConcurrentHashMap<>(); private static Map<String, String> regionCodeOrgCodeMap = new ConcurrentHashMap<>();
private static List<RegionModel> regionModels = new ArrayList<>(); private static List<RegionModel> regionModels = new ArrayList<>();
public DPStatisticsServiceImpl(EquipmentCategoryMapper equipmentCategoryMapper, JgUseRegistrationMapper useRegistrationMapper, EquipTechParamPipelineMapper techParamsPipelineMapper, JgEnableDisableMapper enableDisableMapper, JgScrapCancelMapper scrapCancelMapper, RestHighLevelClient restHighLevelClient, TzBaseEnterpriseInfoMapper enterpriseInfoMapper, CommonMapper commonMapper, TzsUserInfoMapper userInfoMapper, RedisUtils redisUtils, RedisUtils redisUtils1) { public DPStatisticsServiceImpl(EquipmentCategoryMapper equipmentCategoryMapper, JgUseRegistrationMapper useRegistrationMapper, EquipTechParamPipelineMapper techParamsPipelineMapper, JgEnableDisableMapper enableDisableMapper, JgScrapCancelMapper scrapCancelMapper, RestHighLevelClient restHighLevelClient, TzBaseEnterpriseInfoMapper enterpriseInfoMapper, CommonMapper commonMapper, TzsUserInfoMapper userInfoMapper) {
this.equipmentCategoryMapper = equipmentCategoryMapper; this.equipmentCategoryMapper = equipmentCategoryMapper;
this.useRegistrationMapper = useRegistrationMapper; this.useRegistrationMapper = useRegistrationMapper;
this.techParamsPipelineMapper = techParamsPipelineMapper; this.techParamsPipelineMapper = techParamsPipelineMapper;
...@@ -126,7 +125,6 @@ public class DPStatisticsServiceImpl { ...@@ -126,7 +125,6 @@ public class DPStatisticsServiceImpl {
this.enterpriseInfoMapper = enterpriseInfoMapper; this.enterpriseInfoMapper = enterpriseInfoMapper;
this.commonMapper = commonMapper; this.commonMapper = commonMapper;
this.userInfoMapper = userInfoMapper; this.userInfoMapper = userInfoMapper;
this.redisUtils = redisUtils1;
} }
public void init() { public void init() {
......
...@@ -73,4 +73,14 @@ public interface JyjcInspectionApplicationMapper extends BaseMapper<JyjcInspecti ...@@ -73,4 +73,14 @@ public interface JyjcInspectionApplicationMapper extends BaseMapper<JyjcInspecti
* @return List<CountDto> * @return List<CountDto>
*/ */
List<CountDto> queryAppByEquListForDP(@Param("orgCode") String orgCode, @Param("dto") DPFilterParamDto dpFilterParamDto); List<CountDto> queryAppByEquListForDP(@Param("orgCode") String orgCode, @Param("dto") DPFilterParamDto dpFilterParamDto);
/**
* 按照8大类,统计
* @param orgCode 指定区域对应的公司
* @param dpFilterParamDto 时间过滤条件
* @return CountDto
*/
CountDto queryAppByEquListForReporting(@Param("orgCode") String orgCode, @Param("dto") DPFilterParamDto dpFilterParamDto);
} }
...@@ -275,4 +275,16 @@ ...@@ -275,4 +275,16 @@
and date_ge(CAST(a.application_date as date),#{dto.beginDate}) and date_le(CAST(a.application_date as date),#{dto.endDate}) and date_ge(CAST(a.application_date as date),#{dto.beginDate}) and date_le(CAST(a.application_date as date),#{dto.endDate})
GROUP BY a.equip_classify GROUP BY a.equip_classify
</select> </select>
<select id="queryAppByEquListForReporting" resultType="com.yeejoin.amos.boot.biz.common.dto.CountDto">
SELECT
count(1) as longValue
FROM
tz_jyjc_inspection_application a,
tz_base_enterprise_info b
where
a.inspection_unit_code= b.use_unit_code
and a.status != '6610' and a.status != '6615'
and b.supervise_org_code like CONCAT(#{orgCode}, '%')
and date_ge(CAST(a.application_date as date),#{dto.beginDate}) and date_le(CAST(a.application_date as date),#{dto.endDate})
</select>
</mapper> </mapper>
...@@ -124,4 +124,38 @@ public class DPStatisticsController { ...@@ -124,4 +124,38 @@ public class DPStatisticsController {
} }
return ResponseHelper.buildResponse(statisticsService.queryInspectionEquipByEquList(dpFilterParamDto)); return ResponseHelper.buildResponse(statisticsService.queryInspectionEquipByEquList(dpFilterParamDto));
} }
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "POST", value = "大屏-检验检测-中间地图左侧全局统计", notes = "大屏-检验检测-中间地图左侧全局统计")
@PostMapping(value = "/jy/center-map/legend")
public ResponseModel<Map<String, Object>> centerMapCountForGlobal(@Validated @RequestBody DPFilterParamDto dpFilterParamDto, BindingResult result) {
List<FieldError> fieldErrors = result.getFieldErrors();
if (!fieldErrors.isEmpty()) {
throw new BadRequest(fieldErrors.get(0).getDefaultMessage());
}
return ResponseHelper.buildResponse(statisticsService.getCenterMapCountDataForGlobal(dpFilterParamDto));
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "POST", value = "大屏-检验检测-中间地图地市统计", notes = "大屏-检验检测-中间-地图地市统计")
@PostMapping(value = "/jy/center-map/overview")
public ResponseModel<List<Map<String, Object>>> centerMapCountForOverview(@Validated @RequestBody DPFilterParamDto dpFilterParamDto, BindingResult result) {
List<FieldError> fieldErrors = result.getFieldErrors();
if (!fieldErrors.isEmpty()) {
throw new BadRequest(fieldErrors.get(0).getDefaultMessage());
}
return ResponseHelper.buildResponse(statisticsService.getCenterMapCountDataForOverview(dpFilterParamDto));
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "POST", value = "大屏-检验检测-八大类设备检验临期、超期统计", notes = "大屏-检验检测-八大类设备检验临期、超期统计")
@PostMapping(value = "/jy/equipInspectTime/countByEquList")
public ResponseModel<Map<String, Object>> equipInspectTimeCountByEquList(@Validated @RequestBody DPFilterParamDto dpFilterParamDto, BindingResult result) {
List<FieldError> fieldErrors = result.getFieldErrors();
if (!fieldErrors.isEmpty()) {
throw new BadRequest(fieldErrors.get(0).getDefaultMessage());
}
return ResponseHelper.buildResponse(statisticsService.equipInspectTimeCountByEquList(dpFilterParamDto));
}
} }
...@@ -10,6 +10,7 @@ import com.yeejoin.amos.boot.module.jyjc.api.enums.BizTypeEnum; ...@@ -10,6 +10,7 @@ import com.yeejoin.amos.boot.module.jyjc.api.enums.BizTypeEnum;
import com.yeejoin.amos.boot.module.jyjc.api.enums.JYJCTypeEnum; import com.yeejoin.amos.boot.module.jyjc.api.enums.JYJCTypeEnum;
import com.yeejoin.amos.boot.module.jyjc.api.mapper.*; import com.yeejoin.amos.boot.module.jyjc.api.mapper.*;
import com.yeejoin.amos.boot.module.ymt.api.dto.EquipmentCategoryDto; import com.yeejoin.amos.boot.module.ymt.api.dto.EquipmentCategoryDto;
import com.yeejoin.amos.boot.module.ymt.api.enums.EquimentEnum;
import com.yeejoin.amos.boot.module.ymt.api.mapper.EquipmentCategoryMapper; import com.yeejoin.amos.boot.module.ymt.api.mapper.EquipmentCategoryMapper;
import com.yeejoin.amos.boot.module.ymt.api.mapper.TzsUserInfoMapper; import com.yeejoin.amos.boot.module.ymt.api.mapper.TzsUserInfoMapper;
import com.yeejoin.amos.component.feign.model.FeignClientResult; import com.yeejoin.amos.component.feign.model.FeignClientResult;
...@@ -17,8 +18,21 @@ import com.yeejoin.amos.feign.systemctl.Systemctl; ...@@ -17,8 +18,21 @@ import com.yeejoin.amos.feign.systemctl.Systemctl;
import com.yeejoin.amos.feign.systemctl.model.RegionModel; import com.yeejoin.amos.feign.systemctl.model.RegionModel;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.elasticsearch.action.search.SearchRequest;
import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.client.RequestOptions;
import org.elasticsearch.client.RestHighLevelClient;
import org.elasticsearch.client.core.CountRequest;
import org.elasticsearch.client.core.CountResponse;
import org.elasticsearch.index.query.BoolQueryBuilder;
import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.search.aggregations.AggregationBuilders;
import org.elasticsearch.search.aggregations.bucket.terms.Terms;
import org.elasticsearch.search.aggregations.bucket.terms.TermsAggregationBuilder;
import org.elasticsearch.search.builder.SearchSourceBuilder;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.io.IOException;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
...@@ -63,7 +77,11 @@ public class DPStatisticsServiceImpl { ...@@ -63,7 +77,11 @@ public class DPStatisticsServiceImpl {
private static Map<String, String> regionCodeOrgCodeMap = new ConcurrentHashMap<>(); private static Map<String, String> regionCodeOrgCodeMap = new ConcurrentHashMap<>();
public DPStatisticsServiceImpl(EquipmentCategoryMapper equipmentCategoryMapper, JyjcInspectionApplicationEquipMapper inspectionApplicationEquipMapper, JyjcInspectionApplicationMapper inspectionApplicationMapper, TzsUserInfoMapper tzsUserInfoMapper, JyjcBaseMapper jyjcBaseMapper, JyjcInspectionResultMapper inspectionResultMapper, JyjcOpeningApplicationMapper openingApplicationMapper) { private static Map<String, List<RegionModel>> regionChildRegionMap = new ConcurrentHashMap<>();
private RestHighLevelClient restHighLevelClient;
public DPStatisticsServiceImpl(EquipmentCategoryMapper equipmentCategoryMapper, JyjcInspectionApplicationEquipMapper inspectionApplicationEquipMapper, JyjcInspectionApplicationMapper inspectionApplicationMapper, TzsUserInfoMapper tzsUserInfoMapper, JyjcBaseMapper jyjcBaseMapper, JyjcInspectionResultMapper inspectionResultMapper, JyjcOpeningApplicationMapper openingApplicationMapper, RestHighLevelClient restHighLevelClient) {
this.equipmentCategoryMapper = equipmentCategoryMapper; this.equipmentCategoryMapper = equipmentCategoryMapper;
this.inspectionApplicationEquipMapper = inspectionApplicationEquipMapper; this.inspectionApplicationEquipMapper = inspectionApplicationEquipMapper;
this.inspectionApplicationMapper = inspectionApplicationMapper; this.inspectionApplicationMapper = inspectionApplicationMapper;
...@@ -71,6 +89,7 @@ public class DPStatisticsServiceImpl { ...@@ -71,6 +89,7 @@ public class DPStatisticsServiceImpl {
this.jyjcBaseMapper = jyjcBaseMapper; this.jyjcBaseMapper = jyjcBaseMapper;
this.inspectionResultMapper = inspectionResultMapper; this.inspectionResultMapper = inspectionResultMapper;
this.openingApplicationMapper = openingApplicationMapper; this.openingApplicationMapper = openingApplicationMapper;
this.restHighLevelClient = restHighLevelClient;
} }
...@@ -215,8 +234,14 @@ public class DPStatisticsServiceImpl { ...@@ -215,8 +234,14 @@ public class DPStatisticsServiceImpl {
private List<RegionModel> getRegionList(DPFilterParamDto dpFilterParamDto) { private List<RegionModel> getRegionList(DPFilterParamDto dpFilterParamDto) {
try { try {
if (regionChildRegionMap.get(dpFilterParamDto.getCityCode()) == null) {
FeignClientResult<List<RegionModel>> feignClientResult = Systemctl.regionClient.queryByParentRegionCode(Integer.parseInt(dpFilterParamDto.getCityCode())); FeignClientResult<List<RegionModel>> feignClientResult = Systemctl.regionClient.queryByParentRegionCode(Integer.parseInt(dpFilterParamDto.getCityCode()));
return feignClientResult.getResult(); List<RegionModel> regionModels = feignClientResult.getResult();
regionChildRegionMap.put(dpFilterParamDto.getCityCode(), regionModels);
return regionModels;
} else {
return regionChildRegionMap.get(dpFilterParamDto.getCityCode());
}
} catch (Exception e) { } catch (Exception e) {
log.error("查询行政区域失败:{}", e.getMessage()); log.error("查询行政区域失败:{}", e.getMessage());
} }
...@@ -325,4 +350,208 @@ public class DPStatisticsServiceImpl { ...@@ -325,4 +350,208 @@ public class DPStatisticsServiceImpl {
List<String> names = equipmentCategoryDtos.stream().map(EquipmentCategoryDto::getName).collect(Collectors.toList()); List<String> names = equipmentCategoryDtos.stream().map(EquipmentCategoryDto::getName).collect(Collectors.toList());
result.put("xdata", names); result.put("xdata", names);
} }
private List<String> getEquListXDataCommon(List<EquipmentCategoryDto> equipmentCategoryDtos) {
// 8大类
return equipmentCategoryDtos.stream().map(EquipmentCategoryDto::getName).collect(Collectors.toList());
}
public Map<String, Object> getCenterMapCountDataForGlobal(DPFilterParamDto dpFilterParamDto) {
Map<String, Object> result = new HashMap<>();
// 0.查询条件构造未上送时间时,默认查询数据为近一个月数据
this.setDefaultFilter(dpFilterParamDto);
// 1.报检数量统计
this.staticsCenterMapCountDataReporting(result, dpFilterParamDto);
// 2.检验检测临期设备数数量统计
this.staticsCenterMapCountDataTemporary(result, dpFilterParamDto);
// 3.检验检测超期设备数数量统计
this.staticsCenterMapCountDataOverdue(result, dpFilterParamDto);
return result;
}
private void staticsCenterMapCountDataTemporary(Map<String, Object> result, DPFilterParamDto dpFilterParamDto) {
long num = 0;
CountRequest request = new CountRequest();
request.indices("idx_biz_view_jg_all");
BoolQueryBuilder boolMust = QueryBuilders.boolQuery();
// 且区域信息模糊查询
boolMust.must(QueryBuilders.wildcardQuery("USE_PLACE_CODE", "*" + dpFilterParamDto.getCityCode() + "*"));
// 且纳管状态为已纳管
boolMust.must(QueryBuilders.termsQuery("IS_INTO_MANAGEMENT", true));
// 且在用状态设备
boolMust.must(QueryBuilders.termsQuery("EQU_STATE", EquimentEnum.ZAIYONG.getCode()));
// 且下次检验日期大于等于当天
long currentDayTime = DateUtil.parse(DateUtil.today(), "yyy-MM-dd").getTime();
boolMust.must(QueryBuilders.rangeQuery("NEXT_INSPECT_DATE").gte(currentDayTime));
// 且查询 下次检验日期 <= 当前天+30天 极为临期
long currentDayAfter30DayTime = DateUtil.offsetDay(DateUtil.parse(DateUtil.today(), "yyy-MM-dd"), 30).getTime();
boolMust.must(QueryBuilders.rangeQuery("NEXT_INSPECT_DATE").lte(currentDayAfter30DayTime));
request.query(boolMust);
try {
CountResponse response = restHighLevelClient.count(request, RequestOptions.DEFAULT);
num = response.getCount();
} catch (IOException e) {
throw new RuntimeException(e);
}
result.put("jyjclqsbCount", num);
}
private void staticsCenterMapCountDataOverdue(Map<String, Object> result, DPFilterParamDto dpFilterParamDto) {
long num = 0;
CountRequest request = new CountRequest();
request.indices("idx_biz_view_jg_all");
BoolQueryBuilder boolMust = QueryBuilders.boolQuery();
// 区域信息模糊查询
boolMust.must(QueryBuilders.wildcardQuery("USE_PLACE_CODE", "*" + dpFilterParamDto.getCityCode() + "*"));
// 纳管状态为已纳管
boolMust.must(QueryBuilders.termsQuery("IS_INTO_MANAGEMENT", true));
// 在用状态设备
boolMust.must(QueryBuilders.termsQuery("EQU_STATE", EquimentEnum.ZAIYONG.getCode()));
// 查询下次检验日期小于当前天的设备,即为超期检验超期设备
long currentDayTime = DateUtil.parse(DateUtil.now(), "yyy-MM-dd").getTime();
boolMust.must(QueryBuilders.rangeQuery("NEXT_INSPECT_DATE").lt(currentDayTime));
request.query(boolMust);
try {
CountResponse response = restHighLevelClient.count(request, RequestOptions.DEFAULT);
num = response.getCount();
} catch (IOException e) {
throw new RuntimeException(e);
}
result.put("jyjccqsbCount", num);
}
private void staticsCenterMapCountDataReporting(Map<String, Object> result, DPFilterParamDto dpFilterParamDto) {
String orgCode = this.getAndSetOrgCode(dpFilterParamDto.getCityCode());
CountDto countDto = inspectionApplicationMapper.queryAppByEquListForReporting(orgCode, dpFilterParamDto);
result.put("bjCount", countDto.getLongValue());
}
public List<Map<String, Object>> getCenterMapCountDataForOverview(DPFilterParamDto dpFilterParamDto) {
return getRegionList(dpFilterParamDto).parallelStream().filter(e -> e.getParentRegionCode() != null && (e.getParentRegionCode().toString()).equals(dpFilterParamDto.getCityCode())).map(r -> {
DPFilterParamDto filterParamDto = new DPFilterParamDto();
filterParamDto.setCityCode(r.getRegionCode().toString());
Map<String, Object> itemResult = getCenterMapOverviewData(filterParamDto);
itemResult.put("regionCode", r.getRegionCode());
itemResult.put("regionName", r.getRegionName());
return itemResult;
}).collect(Collectors.toList());
}
private Map<String, Object> getCenterMapOverviewData(DPFilterParamDto filterParamDto) {
Map<String, Object> result = new HashMap<>();
// 1.报检数量统计
this.staticsCenterMapCountDataReporting(result, filterParamDto);
// 2.检验检测临期设备数数量统计
this.staticsCenterMapCountDataTemporary(result, filterParamDto);
// 3.检验检测超期设备数数量统计
this.staticsCenterMapCountDataOverdue(result, filterParamDto);
return result;
}
public Map<String, Object> equipInspectTimeCountByEquList(DPFilterParamDto dpFilterParamDto) {
// 1.查询条件构造未上送时间时,默认查询数据为近一个月数据
this.setDefaultFilter(dpFilterParamDto);
// 2.按照前端约定格式返回数据
Map<String, Object> result = new HashMap<>();
//2.1 图列数据构造
result.put("legendData", this.getLegendDataForJyTime());
// 8大类设备种类
List<EquipmentCategoryDto> equipmentCategoryDtos = equipmentCategoryMapper.selectClassify();
//2.2 x轴数据构造
result.put("xdata", this.getEquListXDataCommon(equipmentCategoryDtos));
//2.3 y轴数据构造
this.buildYDataForJyTime(result, dpFilterParamDto, equipmentCategoryDtos);
return result;
}
private void buildYDataForJyTime(Map<String, Object> result, DPFilterParamDto dpFilterParamDto, List<EquipmentCategoryDto> equipmentCategoryDtos) {
// 1.检验检测临期设备数数量统计
staticsCenterMapCountDataForJyTimeTemporary(result, dpFilterParamDto, equipmentCategoryDtos);
// 2.检验检测超期设备数数量统计
staticsCenterMapCountDataForJyTimeOverdue(result, dpFilterParamDto, equipmentCategoryDtos);
}
private void staticsCenterMapCountDataForJyTimeTemporary(Map<String, Object> result, DPFilterParamDto dpFilterParamDto, List<EquipmentCategoryDto> equipmentCategoryDtos) {
SearchRequest request = new SearchRequest();
request.indices("idx_biz_view_jg_all");
BoolQueryBuilder boolMust = QueryBuilders.boolQuery();
// 且区域信息模糊查询
boolMust.must(QueryBuilders.wildcardQuery("USE_PLACE_CODE", "*" + dpFilterParamDto.getCityCode() + "*"));
// 且纳管状态为已纳管
boolMust.must(QueryBuilders.termsQuery("IS_INTO_MANAGEMENT", true));
// 且在用状态设备
boolMust.must(QueryBuilders.termsQuery("EQU_STATE", EquimentEnum.ZAIYONG.getCode()));
// 且下次检验日期大于等于当天
long currentDayTime = DateUtil.parse(DateUtil.today(), "yyy-MM-dd").getTime();
boolMust.must(QueryBuilders.rangeQuery("NEXT_INSPECT_DATE").gte(currentDayTime));
// 且查询 下次检验日期 <= 当前天+30天 极为临期
long currentDayAfter30DayTime = DateUtil.offsetDay(DateUtil.parse(DateUtil.today(), "yyy-MM-dd"), 30).getTime();
boolMust.must(QueryBuilders.rangeQuery("NEXT_INSPECT_DATE").lte(currentDayAfter30DayTime));
SearchSourceBuilder builder = new SearchSourceBuilder();
builder.query(boolMust);
TermsAggregationBuilder aggregationBuilder = AggregationBuilders.terms("count_by_equ_list_code").field("EQU_LIST_CODE");
builder.aggregation(aggregationBuilder);
request.source(builder);
try {
SearchResponse response = restHighLevelClient.search(request, RequestOptions.DEFAULT);
Terms terms = response.getAggregations().get("count_by_equ_list_code");
Map<String, Long> countMap = new HashMap<>();
for (Terms.Bucket bucket : terms.getBuckets()) {
countMap.put(bucket.getKeyAsString(), bucket.getDocCount());
}
// 按照8大类枚举,进行加工。目的:固定八大类防止没统计数据导致缺少分类、将设备种类的code换成前端定义的key
equipmentCategoryDtos.forEach(c -> {
result.put(c.getName(), countMap.getOrDefault(c.getCode(), 0L));
});
} catch (IOException e) {
throw new RuntimeException(e);
}
}
private void staticsCenterMapCountDataForJyTimeOverdue(Map<String, Object> result, DPFilterParamDto dpFilterParamDto, List<EquipmentCategoryDto> equipmentCategoryDtos) {
SearchRequest request = new SearchRequest();
request.indices("idx_biz_view_jg_all");
BoolQueryBuilder boolMust = QueryBuilders.boolQuery();
// 区域信息模糊查询
boolMust.must(QueryBuilders.wildcardQuery("USE_PLACE_CODE", "*" + dpFilterParamDto.getCityCode() + "*"));
// 纳管状态为已纳管
boolMust.must(QueryBuilders.termsQuery("IS_INTO_MANAGEMENT", true));
// 在用状态设备
boolMust.must(QueryBuilders.termsQuery("EQU_STATE", EquimentEnum.ZAIYONG.getCode()));
// 查询下次检验日期小于当前天的设备,即为超期检验超期设备
long currentDayTime = DateUtil.parse(DateUtil.now(), "yyy-MM-dd").getTime();
boolMust.must(QueryBuilders.rangeQuery("NEXT_INSPECT_DATE").lt(currentDayTime));
SearchSourceBuilder builder = new SearchSourceBuilder();
builder.query(boolMust);
TermsAggregationBuilder aggregationBuilder = AggregationBuilders.terms("count_by_equ_list_code").field("EQU_LIST_CODE");
builder.aggregation(aggregationBuilder);
request.source(builder);
try {
SearchResponse response = restHighLevelClient.search(request, RequestOptions.DEFAULT);
Terms terms = response.getAggregations().get("count_by_equ_list_code");
Map<String, Long> countMap = new HashMap<>();
for (Terms.Bucket bucket : terms.getBuckets()) {
countMap.put(bucket.getKeyAsString(), bucket.getDocCount());
}
// 按照8大类枚举,进行加工。目的:固定八大类防止没统计数据导致缺少分类、将设备种类的code换成前端定义的key
equipmentCategoryDtos.forEach(c -> {
result.put(c.getName(), countMap.getOrDefault(c.getCode(), 0L));
});
} catch (IOException e) {
throw new RuntimeException(e);
}
}
private Object getLegendDataForJyTime() {
Map<String, Object> item1 = new LinkedHashMap<>();
item1.put("dataKey", "approach");
item1.put("value", "临期");
Map<String, Object> item2 = new LinkedHashMap<>();
item2.put("dataKey", "overdue");
item2.put("value", "超期");
return Arrays.asList(item1, item2);
}
} }
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