Commit 0a274c95 authored by suhuiguang's avatar suhuiguang

1.4色管安全:企业统计、设备统计之前未明确需求进行开发

parent 968361b4
...@@ -28,4 +28,8 @@ public interface ZLStatisticsMapper { ...@@ -28,4 +28,8 @@ public interface ZLStatisticsMapper {
String getOrgCodeByCompanyCode(@Param("cityCode") String cityCode); String getOrgCodeByCompanyCode(@Param("cityCode") String cityCode);
List<Map<String, String>> userCountNew(@Param("screenDto") DPFilterParamDto screenDto, @Param("unitTypeList") List<String> unitTypeList); List<Map<String, String>> userCountNew(@Param("screenDto") DPFilterParamDto screenDto, @Param("unitTypeList") List<String> unitTypeList);
Long countCompanyForCertDateTimeOut(@Param("dto") DPFilterParamDto dpFilterParamDto, @Param("orgCode") String orgCode, @Param("limitDate") String limitDate);
Long countCompanyForCertDateTemporary(@Param("dto")DPFilterParamDto dpFilterParamDto, @Param("orgCode") String orgCode, @Param("limitDate") String limitDate);
} }
...@@ -69,7 +69,34 @@ ...@@ -69,7 +69,34 @@
</foreach> </foreach>
</if> </if>
</select> </select>
<sql id="countCompanyNumber">
select
count(1)
from
(
SELECT
(select min(l.expiry_date) from tz_base_unit_licence l where l.unit_code = b.use_unit_code) as expiry_date
FROM
"tz_base_enterprise_info" b
where
1=1
and ((b.supervise_org_code != '50' and b.supervise_org_code LIKE CONCAT (#{orgCode}, '%')) or (b.supervise_org_code = '50' and b.office_region LIKE CONCAT ('%', #{dto.cityCode}, '%')))
and operating_status = '在业'
and register_type !='个人主体'
and expiry_date is not null
) a
</sql>
<select id="countCompanyForCertDateTimeOut" resultType="java.lang.Long">
<include refid="countCompanyNumber"/>
where
a.expiry_date <![CDATA[<]]> #{limitDate}
</select>
<select id="countCompanyForCertDateTemporary" resultType="java.lang.Long">
<include refid="countCompanyNumber"/>
where
a.expiry_date >= current_date
and a.expiry_date <![CDATA[<=]]> #{limitDate}
</select>
</mapper> </mapper>
package com.yeejoin.amos.boot.module.statistcs.biz.service.impl; package com.yeejoin.amos.boot.module.statistcs.biz.service.impl;
import cn.hutool.core.date.DateField;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
import com.yeejoin.amos.boot.biz.common.dto.CountDto; import com.yeejoin.amos.boot.biz.common.dto.CountDto;
import com.yeejoin.amos.boot.module.common.api.constant.TZSCommonConstant; import com.yeejoin.amos.boot.module.common.api.constant.TZSCommonConstant;
...@@ -12,6 +13,7 @@ import com.yeejoin.amos.boot.module.jg.api.enums.DPMapStatisticsItemEnum; ...@@ -12,6 +13,7 @@ import com.yeejoin.amos.boot.module.jg.api.enums.DPMapStatisticsItemEnum;
import com.yeejoin.amos.boot.module.jg.api.enums.FourColorCountItemEnum; import com.yeejoin.amos.boot.module.jg.api.enums.FourColorCountItemEnum;
import com.yeejoin.amos.boot.module.jg.api.enums.FourColorEnum; import com.yeejoin.amos.boot.module.jg.api.enums.FourColorEnum;
import com.yeejoin.amos.boot.module.jg.api.mapper.*; import com.yeejoin.amos.boot.module.jg.api.mapper.*;
import com.yeejoin.amos.boot.module.statistics.api.mapper.ZLStatisticsMapper;
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.enums.EquimentEnum;
import com.yeejoin.amos.boot.module.ymt.api.mapper.EquipTechParamPipelineMapper; import com.yeejoin.amos.boot.module.ymt.api.mapper.EquipTechParamPipelineMapper;
...@@ -39,7 +41,6 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -39,7 +41,6 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils; import org.springframework.util.ObjectUtils;
import javax.annotation.Resource;
import java.io.IOException; import java.io.IOException;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode; import java.math.RoundingMode;
...@@ -124,17 +125,17 @@ public class JGDPStatisticsServiceImpl { ...@@ -124,17 +125,17 @@ public class JGDPStatisticsServiceImpl {
private TzsUserInfoMapper userInfoMapper; private TzsUserInfoMapper userInfoMapper;
private ZLStatisticsMapper zlStatisticsMapper;
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<>();
@Resource
private DPStatisticsMapper dpStatisticsMapper; private DPStatisticsMapper dpStatisticsMapper;
@Autowired
private JgUseRegistrationManageMapper jgUseRegistrationManageMapper; private JgUseRegistrationManageMapper jgUseRegistrationManageMapper;
public JGDPStatisticsServiceImpl(EquipmentCategoryMapper equipmentCategoryMapper, JgUseRegistrationMapper useRegistrationMapper, EquipTechParamPipelineMapper techParamsPipelineMapper, JgEnableDisableMapper enableDisableMapper, JgScrapCancelMapper scrapCancelMapper, RestHighLevelClient restHighLevelClient, TzBaseEnterpriseInfoMapper enterpriseInfoMapper, CommonMapper commonMapper, TzsUserInfoMapper userInfoMapper) { public JGDPStatisticsServiceImpl(EquipmentCategoryMapper equipmentCategoryMapper, JgUseRegistrationMapper useRegistrationMapper, EquipTechParamPipelineMapper techParamsPipelineMapper, JgEnableDisableMapper enableDisableMapper, JgScrapCancelMapper scrapCancelMapper, RestHighLevelClient restHighLevelClient, TzBaseEnterpriseInfoMapper enterpriseInfoMapper, CommonMapper commonMapper, TzsUserInfoMapper userInfoMapper, ZLStatisticsMapper zlStatisticsMapper, DPStatisticsMapper dpStatisticsMapper, JgUseRegistrationManageMapper jgUseRegistrationManageMapper) {
this.equipmentCategoryMapper = equipmentCategoryMapper; this.equipmentCategoryMapper = equipmentCategoryMapper;
this.useRegistrationMapper = useRegistrationMapper; this.useRegistrationMapper = useRegistrationMapper;
this.techParamsPipelineMapper = techParamsPipelineMapper; this.techParamsPipelineMapper = techParamsPipelineMapper;
...@@ -144,6 +145,9 @@ public class JGDPStatisticsServiceImpl { ...@@ -144,6 +145,9 @@ public class JGDPStatisticsServiceImpl {
this.enterpriseInfoMapper = enterpriseInfoMapper; this.enterpriseInfoMapper = enterpriseInfoMapper;
this.commonMapper = commonMapper; this.commonMapper = commonMapper;
this.userInfoMapper = userInfoMapper; this.userInfoMapper = userInfoMapper;
this.zlStatisticsMapper = zlStatisticsMapper;
this.dpStatisticsMapper = dpStatisticsMapper;
this.jgUseRegistrationManageMapper = jgUseRegistrationManageMapper;
} }
public void init() { public void init() {
...@@ -261,7 +265,7 @@ public class JGDPStatisticsServiceImpl { ...@@ -261,7 +265,7 @@ public class JGDPStatisticsServiceImpl {
private Map<String, Object> getCenterMapOverviewData(DPFilterParamDto dpFilterParamDto) { private Map<String, Object> getCenterMapOverviewData(DPFilterParamDto dpFilterParamDto) {
Map<String, Object> result = new HashMap<>(); Map<String, Object> result = new HashMap<>();
String orgCode = this.getAndSetOrgCode(dpFilterParamDto.getCityCode()); String orgCode = this.getAndSetOrgCode(dpFilterParamDto.getCityCode());
if(StringUtils.isEmpty(orgCode)){ if (StringUtils.isEmpty(orgCode)) {
return new HashMap<>(); return new HashMap<>();
} }
// 0. 气瓶数量统计 // 0. 气瓶数量统计
...@@ -539,25 +543,83 @@ public class JGDPStatisticsServiceImpl { ...@@ -539,25 +543,83 @@ public class JGDPStatisticsServiceImpl {
} }
private CountDto getRedStatusEquip(DPFilterParamDto dpFilterParamDto) { private CountDto getRedStatusEquip(DPFilterParamDto dpFilterParamDto) {
// TODO 需求不明确
CountDto countDto = new CountDto(); CountDto countDto = new CountDto();
countDto.setLongValue(0L); countDto.setLongValue(this.staticsCenterMapCountDateOverdue(dpFilterParamDto));
countDto.setLabel("超期未检"); countDto.setLabel("超期未检");
return countDto; return countDto;
} }
private CountDto getYellowStatusEquip(DPFilterParamDto dpFilterParamDto) { private CountDto getYellowStatusEquip(DPFilterParamDto dpFilterParamDto) {
// TODO 需求不明确
CountDto countDto = new CountDto(); CountDto countDto = new CountDto();
countDto.setLongValue(0L); countDto.setLongValue(this.staticsCenterMapCountDateTemporary(dpFilterParamDto));
countDto.setLabel("临期告警"); countDto.setLabel("临期告警");
return countDto; return countDto;
} }
/**
* 临期检验设备数统计
* @param dpFilterParamDto 过滤条件
* @return 临期设备的数量
*/
private Long staticsCenterMapCountDateTemporary(DPFilterParamDto dpFilterParamDto) {
long num = 0;
CountRequest request = new CountRequest();
request.indices("idx_biz_view_jg_all");
BoolQueryBuilder boolMust = QueryBuilders.boolQuery();
String orgCode = this.getAndSetOrgCode(dpFilterParamDto.getCityCode());
// 按照管辖机构区域信息模糊查询
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 dpFilterParamDto 过滤条件
* @return 超期设备的数量
*/
private Long staticsCenterMapCountDateOverdue(DPFilterParamDto dpFilterParamDto) {
long num = 0;
CountRequest request = new CountRequest();
request.indices("idx_biz_view_jg_all");
BoolQueryBuilder boolMust = QueryBuilders.boolQuery();
String orgCode = this.getAndSetOrgCode(dpFilterParamDto.getCityCode());
// 按照管辖机构区域信息模糊查询
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 CountDto getGreyStatusEquip(DPFilterParamDto dpFilterParamDto) { private CountDto getGreyStatusEquip(DPFilterParamDto dpFilterParamDto) {
CountDto countDto = new CountDto(); CountDto countDto = new CountDto();
countDto.setLongValue(this.countEquipNumFromES(dpFilterParamDto, EquimentEnum.BAOFEI.getCode(), EquimentEnum.ZHUXIAO.getCode())); countDto.setLongValue(this.countEquipNumFromES(dpFilterParamDto, EquimentEnum.BAOFEI.getCode(), EquimentEnum.ZHUXIAO.getCode(), EquimentEnum.TINGYONG.getCode()));
countDto.setLabel("未注册、停用或注销"); countDto.setLabel("停用、报废及注销");
return countDto; return countDto;
} }
...@@ -572,28 +634,39 @@ public class JGDPStatisticsServiceImpl { ...@@ -572,28 +634,39 @@ public class JGDPStatisticsServiceImpl {
private CountDto getGreyStatusCompany(DPFilterParamDto dpFilterParamDto) { private CountDto getGreyStatusCompany(DPFilterParamDto dpFilterParamDto) {
CountDto countDto = new CountDto(); CountDto countDto = new CountDto();
countDto.setLongValue(0L);
countDto.setLongValue(this.countCompanyByOperatingStatus(dpFilterParamDto, "停业")); countDto.setLongValue(this.countCompanyByOperatingStatus(dpFilterParamDto, "停业"));
countDto.setLabel("停业"); countDto.setLabel("停业");
return countDto; return countDto;
} }
private CountDto getYellowStatusCompany(DPFilterParamDto dpFilterParamDto) { private CountDto getYellowStatusCompany(DPFilterParamDto dpFilterParamDto) {
// TODO 需求不明确
CountDto countDto = new CountDto(); CountDto countDto = new CountDto();
countDto.setLongValue(0L); countDto.setLongValue(this.countCompanyForCertDateTimeOut(dpFilterParamDto));
countDto.setLabel("临期告警"); countDto.setLabel("资质临期");
return countDto; return countDto;
} }
private CountDto getRedStatusCompany(DPFilterParamDto dpFilterParamDto) { private CountDto getRedStatusCompany(DPFilterParamDto dpFilterParamDto) {
// TODO 需求不明确
CountDto countDto = new CountDto(); CountDto countDto = new CountDto();
countDto.setLongValue(0L); countDto.setLongValue(this.countCompanyForCertDateTemporary(dpFilterParamDto));
countDto.setLabel("超期未检"); countDto.setLabel("资质超期");
return countDto; return countDto;
} }
private long countCompanyForCertDateTemporary(DPFilterParamDto dpFilterParamDto) {
String orgCode = getAndSetOrgCode(dpFilterParamDto.getCityCode());
// 临期6个月
String limitDate = DateUtil.offset(DateUtil.date(), DateField.DAY_OF_MONTH,6).toDateStr();
return zlStatisticsMapper.countCompanyForCertDateTemporary(dpFilterParamDto,orgCode, limitDate);
}
private long countCompanyForCertDateTimeOut(DPFilterParamDto dpFilterParamDto) {
String orgCode = getAndSetOrgCode(dpFilterParamDto.getCityCode());
String limitDate = DateUtil.today();
return zlStatisticsMapper.countCompanyForCertDateTimeOut(dpFilterParamDto,orgCode, limitDate);
}
private CountDto getGreenStatusCompany(DPFilterParamDto dpFilterParamDto) { private CountDto getGreenStatusCompany(DPFilterParamDto dpFilterParamDto) {
CountDto countDto = new CountDto(); CountDto countDto = new CountDto();
countDto.setLongValue(this.countCompanyByOperatingStatus(dpFilterParamDto, "在业")); countDto.setLongValue(this.countCompanyByOperatingStatus(dpFilterParamDto, "在业"));
......
...@@ -224,6 +224,7 @@ ...@@ -224,6 +224,7 @@
1=1 1=1
and ((supervise_org_code != '50' and supervise_org_code LIKE CONCAT (#{orgCode}, '%')) or (supervise_org_code = '50' and office_region LIKE CONCAT ('%', #{cityCode}, '%'))) and ((supervise_org_code != '50' and supervise_org_code LIKE CONCAT (#{orgCode}, '%')) or (supervise_org_code = '50' and office_region LIKE CONCAT ('%', #{cityCode}, '%')))
and operating_status = #{operatingStatus} and operating_status = #{operatingStatus}
and register_type !='个人主体'
</select> </select>
<select id="queryByUseCode" resultType="com.yeejoin.amos.boot.module.ymt.api.dto.TzBaseEnterpriseInfoDto"> <select id="queryByUseCode" resultType="com.yeejoin.amos.boot.module.ymt.api.dto.TzBaseEnterpriseInfoDto">
select * from tz_base_enterprise_info where use_code in select * from tz_base_enterprise_info where use_code in
......
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