Commit 1dac0fa8 authored by suhuiguang's avatar suhuiguang

1.气瓶中评调整 增加统计项

parent bb653fe7
......@@ -20,4 +20,11 @@ public interface CylinderStatisticsMapper {
* @return 办理率*100
*/
String queryUserRegisterCertAppPercent(@Param("orgCode") String orgCode);
/**
* 统计气瓶的办证数量
* @param orgCode 区域对应的公司的orgCode
* @return 办证数量
*/
Long countForCylinderCertNum(String orgCode);
}
......@@ -31,4 +31,16 @@
and supervise_org_code like concat(#{orgCode},'%')
) s2
</select>
<select id="countForCylinderCertNum" resultType="java.lang.Long">
SELECT
count(DISTINCT(a.use_unit_credit_code)) as num
FROM
"tzs_jg_use_registration_manage" a,
privilege_company c
where
a.receive_company_code = c.company_code
and a.certificate_status='已登记'
and a.equ_list_code='2000'
and c.org_code like concat(#{orgCode},'%')
</select>
</mapper>
package com.yeejoin.amos.boot.module.statistcs.biz.service.impl;
import cn.hutool.core.date.DateUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.yeejoin.amos.boot.biz.common.dto.CountDto;
import com.yeejoin.amos.boot.module.common.api.dto.CylinderFillingRecordStatisticsDto;
......@@ -228,38 +229,134 @@ public class CylinderDPStatisticsServiceImpl {
return num;
}
private Long countForCylinderNumForVehicleUsed(String orgCode) {
long num = 0;
CountRequest request = new CountRequest();
request.indices("idx_biz_view_jg_all");
BoolQueryBuilder boolMust = QueryBuilders.boolQuery();
// 按照管辖机构区域信息模糊查询
boolMust.must(QueryBuilders.termQuery("WHETHER_VEHICLE_CYLINDER.keyword", "1"));
boolMust.must(QueryBuilders.wildcardQuery("ORG_BRANCH_CODE.keyword", QueryParser.escape(orgCode) + "*"));
// 且在用状态设备
boolMust.must(QueryBuilders.termQuery("EQU_STATE", EquimentEnum.ZAIYONG.getCode()));
request.query(boolMust);
try {
CountResponse response = restHighLevelClient.count(request, RequestOptions.DEFAULT);
num = response.getCount();
} catch (IOException e) {
throw new RuntimeException(e);
}
return num;
}
private List<String> buildXData(List<RegionModel> regionList) {
return regionList.stream().map(RegionModel::getRegionName).collect(Collectors.toList());
}
public Map<String, Object> getCylinderStatisticsDataByCityForTotal(DPFilterParamDto dpFilterParamDto) {
String regionCode = dpFilterParamDto.getCityCode();
String orgCode = stCommonService.getAndSetOrgCode(regionCode);
Map<String, Object> result = new HashMap<>();
String orgCode = stCommonService.getAndSetOrgCode(dpFilterParamDto.getCityCode());
getCylinderMapCount(orgCode, result);
return result;
}
private Map<String, Object> getCylinderMapCount(String orgCode, Map<String, Object> result) {
if (StringUtils.isNotEmpty(orgCode)) {
result.put("cylindersCount", this.countForCylinderNum(orgCode));
result.put("stationCount", cylinderStatisticsMapper.countEnterpriseNumForCylinder(orgCode));
result.put("operatorCount", cylinderAreaDataMapper.getOpertorStatisticsDataByCity(Collections.singletonList(orgCode)));
// 液化气瓶 (个)
result.put("liquefiedGasCount", 0L);
// 车用气瓶 (个)
result.put("automotiveGasCount", this.countForCylinderNumForVehicleUsed(orgCode));
// 工业气瓶 (个)
result.put("industrialGasCount", 0L);
// 使用登记数量
result.put("useRegistrationQuantityCount", this.countForCylinderCertNum(orgCode));
// 检验临期气瓶数
result.put("jylqsbCount", this.countForCylinderTemporaryInspect(orgCode));
// 检验超期气瓶数
result.put("jycqsbCount", this.countForCylinderOverdueInspect(orgCode));
} else {
this.setDefaultValueIfNoData(result, "stationCount", "cylindersCount", "operatorCount");
this.setDefaultValueIfNoData(result, "cylindersCount", "stationCount", "operatorCount", "liquefiedGasCount", "automotiveGasCount", "industrialGasCount", "useRegistrationQuantityCount", "jylqsbCount", "jycqsbCount");
}
return result;
}
/**
* 临期检验设备数统计
*
* @param orgCode 过滤条件
* @return 临期设备的数量
*/
private Long countForCylinderTemporaryInspect(String orgCode) {
long num = 0;
CountRequest request = new CountRequest();
request.indices("idx_biz_view_jg_all");
BoolQueryBuilder boolMust = QueryBuilders.boolQuery();
// 按照管辖机构区域信息模糊查询
boolMust.must(QueryBuilders.wildcardQuery("ORG_BRANCH_CODE.keyword", QueryParser.escape(orgCode) + "*"));
// 且在用状态设备
boolMust.must(QueryBuilders.termQuery("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);
}
return num;
}
/**
* 超期检验设备数统计
*
* @param orgCode 过滤条件
* @return 超期设备的数量
*/
private Long countForCylinderOverdueInspect(String orgCode) {
long num = 0;
CountRequest request = new CountRequest();
request.indices("idx_biz_view_jg_all");
BoolQueryBuilder boolMust = QueryBuilders.boolQuery();
// 设备类别2300气瓶
boolMust.must(QueryBuilders.termQuery("EQU_CATEGORY_CODE", "2300"));
// 按照管辖机构区域信息模糊查询
boolMust.must(QueryBuilders.wildcardQuery("ORG_BRANCH_CODE.keyword", QueryParser.escape(orgCode) + "*"));
// 在用状态设备
boolMust.must(QueryBuilders.termQuery("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);
}
return num;
}
private Long countForCylinderCertNum(String orgCode) {
return cylinderStatisticsMapper.countForCylinderCertNum(orgCode);
}
public List<Map<String, Object>> getCylinderStatisticsDataByCityForMap(DPFilterParamDto dpFilterParamDto) throws Exception {
List<RegionModel> regionList = stCommonService.setRegionIfRootParent(dpFilterParamDto.getCityCode());
return regionList.parallelStream().map(r -> {
String orgCode = stCommonService.getAndSetOrgCode(r.getRegionCode() + "");
String orgCode = stCommonService.getAndSetOrgCode(r.getRegionCode().toString());
Map<String, Object> item = new HashMap<>();
item.put("regionCode", r.getRegionCode());
item.put("regionName", r.getRegionName());
if (StringUtils.isNotEmpty(orgCode)) {
item.put("stationCount", cylinderStatisticsMapper.countEnterpriseNumForCylinder(orgCode));
item.put("cylindersCount", this.countForCylinderNum(orgCode));
item.put("operatorCount", cylinderAreaDataMapper.getOpertorStatisticsDataByCity(Collections.singletonList(orgCode)));
} else {
this.setDefaultValueIfNoData(item, "stationCount", "cylindersCount", "operatorCount");
}
getCylinderMapCount(orgCode, item);
return item;
}).collect(Collectors.toList());
}
......
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