Commit 58e808c7 authored by suhuiguang's avatar suhuiguang

1.气瓶许可有效期统计修改

parent 2a3908dc
package com.yeejoin.amos.boot.module.cylinder.api.dto;
import lombok.Data;
/**
* @author Administrator
*/
@Data
public class KeyValueDto {
private String strKey;
private Integer iValue;
private String strValue;
}
package com.yeejoin.amos.boot.module.cylinder.flc.api.mapper; package com.yeejoin.amos.boot.module.cylinder.flc.api.mapper;
import com.yeejoin.amos.boot.module.cylinder.flc.api.entity.CylinderAreaData;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yeejoin.amos.boot.module.cylinder.api.dto.KeyValueDto;
import com.yeejoin.amos.boot.module.cylinder.flc.api.entity.CylinderAreaData;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Map; import java.util.Map;
/** /**
...@@ -14,9 +16,26 @@ import java.util.Map; ...@@ -14,9 +16,26 @@ import java.util.Map;
*/ */
public interface CylinderAreaDataMapper extends BaseMapper<CylinderAreaData> { public interface CylinderAreaDataMapper extends BaseMapper<CylinderAreaData> {
Map<String, Object> getLicenseEfficiency(@Param(value = "regionCode")String regionCode, @Param(value = "appId")String appId);
Map<String, Object> getInspectionExpiredRate(@Param(value = "regionCode")String regionCode, @Param(value = "appId")String appId); Map<String, Object> getInspectionExpiredRate(@Param(value = "regionCode") String regionCode, @Param(value = "appId") String appId);
Map<String, Object> getInspectionResultRate(@Param(value = "regionCode") String regionCode, @Param(value = "appId") String appId);
/**
* 查询单个单位的有效期信息
*
* @param appId 公司唯一标识
* @return KeyValueDto
*/
KeyValueDto queryLicenseEfficiencyOneCompany(@Param(value = "appId") String appId);
/**
* 单位按照资质状态分组下的统计数量
*
* @param regionCode 区域
* @return List<KeyValueDto>
*/
List<KeyValueDto> queryLicenseEfficiencyOfRegion(@Param(value = "regionCode") String regionCode);
Map<String, Object> getInspectionResultRate(@Param(value = "regionCode")String regionCode, @Param(value = "appId")String appId);
} }
...@@ -2,21 +2,36 @@ ...@@ -2,21 +2,36 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.yeejoin.amos.boot.module.cylinder.flc.api.mapper.CylinderAreaDataMapper"> <mapper namespace="com.yeejoin.amos.boot.module.cylinder.flc.api.mapper.CylinderAreaDataMapper">
<select id="getLicenseEfficiency" resultType="java.util.Map"> <select id="queryLicenseEfficiencyOneCompany" resultType="com.yeejoin.amos.boot.module.cylinder.api.dto.KeyValueDto">
SELECT SELECT
CASE WHEN COUNT ( CASE WHEN ul.expiry_date >= now( ) THEN 1 END ) = 1 THEN '正常' ELSE '已超期' END AS licenseOk, cu.sequence_nbr as strKey,
CASE WHEN COUNT(*) = 0 THEN 0 ELSE ROUND( ( COUNT ( CASE WHEN ul.expiry_date >= now( ) THEN 1 END ) * 100.0 / COUNT ( * ) ), 2 ) END AS licenseRate (select
case
when min(ul.expiry_date) >= now()
THEN '正常'
when min(ul.expiry_date) is null then '--'
ELSE '已超期'
END AS licenseOk from tz_base_unit_licence ul where cu.credit_code = ul.unit_code) as strValue
FROM FROM
tz_cylinder_unit cu tz_cylinder_unit cu
LEFT JOIN tz_base_unit_licence ul ON cu.credit_code = ul.unit_code where
<where> cu.app_id = #{appId}
<if test="regionCode != null and regionCode != ''"> </select>
cu.region_code like concat('%', #{regionCode}, '%') <select id="queryLicenseEfficiencyOfRegion" resultType="com.yeejoin.amos.boot.module.cylinder.api.dto.KeyValueDto">
</if> SELECT
<if test="appId != null and appId != ''"> count(1) as iValue,
cu.app_id = #{appId} (select
</if> case
</where> when min(ul.expiry_date) >= now()
THEN '正常'
when min(ul.expiry_date) is null then '未提供'
ELSE '已超期'
END AS licenseOk from tz_base_unit_licence ul where cu.credit_code = ul.unit_code) as strKey
FROM
tz_cylinder_unit cu
where
cu.region_code like concat('%', #{regionCode}, '%')
GROUP BY strKey
</select> </select>
<select id="getInspectionExpiredRate" resultType="java.util.Map"> <select id="getInspectionExpiredRate" resultType="java.util.Map">
......
package com.yeejoin.amos.boot.module.cylinder.flc.biz.service.impl; package com.yeejoin.amos.boot.module.cylinder.flc.biz.service.impl;
import com.yeejoin.amos.boot.module.cylinder.flc.api.dto.CityCylinderInfoDto; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
import com.yeejoin.amos.boot.module.cylinder.api.entity.ESCylinderFillingRecordDto; import com.yeejoin.amos.boot.module.cylinder.api.dto.KeyValueDto;
import com.yeejoin.amos.boot.module.cylinder.flc.api.dto.CityCylinderInfoDto;
import com.yeejoin.amos.boot.module.cylinder.flc.api.dto.CylinderAreaDataDto;
import com.yeejoin.amos.boot.module.cylinder.flc.api.entity.CylinderAreaData; import com.yeejoin.amos.boot.module.cylinder.flc.api.entity.CylinderAreaData;
import com.yeejoin.amos.boot.module.cylinder.flc.api.mapper.CylinderAreaDataMapper; import com.yeejoin.amos.boot.module.cylinder.flc.api.mapper.CylinderAreaDataMapper;
import com.yeejoin.amos.boot.module.cylinder.flc.api.service.ICylinderAreaDataService; import com.yeejoin.amos.boot.module.cylinder.flc.api.service.ICylinderAreaDataService;
import com.yeejoin.amos.boot.module.cylinder.flc.api.dto.CylinderAreaDataDto;
import org.elasticsearch.client.RequestOptions; import org.elasticsearch.client.RequestOptions;
import org.elasticsearch.client.RestHighLevelClient; import org.elasticsearch.client.RestHighLevelClient;
import org.elasticsearch.client.core.CountRequest; import org.elasticsearch.client.core.CountRequest;
...@@ -15,12 +16,14 @@ import org.elasticsearch.client.core.CountResponse; ...@@ -15,12 +16,14 @@ import org.elasticsearch.client.core.CountResponse;
import org.elasticsearch.index.query.BoolQueryBuilder; import org.elasticsearch.index.query.BoolQueryBuilder;
import org.elasticsearch.index.query.QueryBuilders; import org.elasticsearch.index.query.QueryBuilders;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils; import org.springframework.util.ObjectUtils;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil; import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
import org.typroject.tyboot.core.rdbms.service.BaseService; import org.typroject.tyboot.core.rdbms.service.BaseService;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import java.io.IOException; import java.io.IOException;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;
...@@ -32,10 +35,11 @@ import java.util.stream.Collectors; ...@@ -32,10 +35,11 @@ import java.util.stream.Collectors;
* @date 2022-03-08 * @date 2022-03-08
*/ */
@Service @Service
public class CylinderAreaDataServiceImpl extends BaseService<CylinderAreaDataDto,CylinderAreaData,CylinderAreaDataMapper> implements ICylinderAreaDataService { public class CylinderAreaDataServiceImpl extends BaseService<CylinderAreaDataDto, CylinderAreaData, CylinderAreaDataMapper> implements ICylinderAreaDataService {
@Autowired public final static String LICENSE_IS_OK = "正常";
private CylinderAreaDataMapper mapper;
public final static String NO_DATA_STR = "--";
@Autowired @Autowired
RestHighLevelClient restHighLevelClient; RestHighLevelClient restHighLevelClient;
...@@ -43,15 +47,15 @@ public class CylinderAreaDataServiceImpl extends BaseService<CylinderAreaDataDto ...@@ -43,15 +47,15 @@ public class CylinderAreaDataServiceImpl extends BaseService<CylinderAreaDataDto
/** /**
* 分页查询 * 分页查询
*/ */
public Page<CylinderAreaDataDto> queryForCylinderAreaDataPage(Page<CylinderAreaDataDto> page) { public Page<CylinderAreaDataDto> queryForCylinderAreaDataPage(Page<CylinderAreaDataDto> page) {
return this.queryForPage(page, null, false); return this.queryForPage(page, null, false);
} }
/** /**
* 列表查询 示例 * 列表查询 示例
*/ */
public List<CylinderAreaDataDto> queryForCylinderAreaDataList() { public List<CylinderAreaDataDto> queryForCylinderAreaDataList() {
return this.queryForList("" , false); return this.queryForList("", false);
} }
public List<CityCylinderInfoDto> getCityCylinderData(String level) { public List<CityCylinderInfoDto> getCityCylinderData(String level) {
...@@ -70,16 +74,22 @@ public class CylinderAreaDataServiceImpl extends BaseService<CylinderAreaDataDto ...@@ -70,16 +74,22 @@ public class CylinderAreaDataServiceImpl extends BaseService<CylinderAreaDataDto
public Page<Map<String, Object>> getEarlyWarningStatistics(String regionCode, String appId) { public Page<Map<String, Object>> getEarlyWarningStatistics(String regionCode, String appId) {
Page<Map<String, Object>> page = new Page<>(); Page<Map<String, Object>> page = new Page<>();
// 是否有充装企业在指定区域下
Boolean isHavingUnitInRegion = true;
List<Map<String, Object>> list = Lists.newArrayList(); List<Map<String, Object>> list = Lists.newArrayList();
Map<String, Object> result1 = Maps.newHashMap(); Map<String, Object> result1 = Maps.newHashMap();
Map<String, Object> result2 = Maps.newHashMap(); Map<String, Object> result2 = Maps.newHashMap();
// 1.许可有效率 // 1.许可有效率
if (!ValidationUtil.isEmpty(appId)) { if (!ValidationUtil.isEmpty(appId)) {
result1.put("name", "许可有效期"); result1.put("name", "许可有效期");
result1.put("value", mapper.getLicenseEfficiency(null, appId).get("licenseOk").toString()); result1.put("value", this.getBaseMapper().queryLicenseEfficiencyOneCompany(appId).getStrValue());
} else if (!ValidationUtil.isEmpty(regionCode)){ } else if (!ValidationUtil.isEmpty(regionCode)) {
result1.put("name", "许可有效率(%)"); result1.put("name", "许可有效率(%)");
result1.put("value", mapper.getLicenseEfficiency(regionCode, null).get("licenseRate").toString()); result1.put("value", this.getLicenseEfficiencyByRegion(regionCode));
isHavingUnitInRegion = this.setNoUnitDataStaticInfo(list, result1.get("value").toString());
}
if (!ValidationUtil.isEmpty(regionCode) && !isHavingUnitInRegion) {
return page.setRecords(list);
} }
// 2.使用登记办理率 // 2.使用登记办理率
if (!ValidationUtil.isEmpty(appId)) { if (!ValidationUtil.isEmpty(appId)) {
...@@ -92,11 +102,11 @@ public class CylinderAreaDataServiceImpl extends BaseService<CylinderAreaDataDto ...@@ -92,11 +102,11 @@ public class CylinderAreaDataServiceImpl extends BaseService<CylinderAreaDataDto
// 3.检验超期率 // 3.检验超期率
Map<String, Object> result3 = Maps.newHashMap(); Map<String, Object> result3 = Maps.newHashMap();
result3.put("name", "检验超期率(%)"); result3.put("name", "检验超期率(%)");
result3.put("value", mapper.getInspectionExpiredRate(regionCode, appId).get("expiredRate").toString()); result3.put("value", this.getBaseMapper().getInspectionExpiredRate(regionCode, appId).get("expiredRate").toString());
// 4.检验合格率 // 4.检验合格率
Map<String, Object> result4 = Maps.newHashMap(); Map<String, Object> result4 = Maps.newHashMap();
result4.put("name", "检验合格率(%)"); result4.put("name", "检验合格率(%)");
result4.put("value", mapper.getInspectionResultRate(regionCode, appId).get("resultRate").toString()); result4.put("value", this.getBaseMapper().getInspectionResultRate(regionCode, appId).get("resultRate").toString());
// 5.充装检查率 // 5.充装检查率
Map<String, Object> result5 = Maps.newHashMap(); Map<String, Object> result5 = Maps.newHashMap();
long totalAll = searchEsCount(false, false, regionCode, appId); long totalAll = searchEsCount(false, false, regionCode, appId);
...@@ -128,12 +138,44 @@ public class CylinderAreaDataServiceImpl extends BaseService<CylinderAreaDataDto ...@@ -128,12 +138,44 @@ public class CylinderAreaDataServiceImpl extends BaseService<CylinderAreaDataDto
return page; return page;
} }
private Map<String, Object> getFillingCheckRate(ESCylinderFillingRecordDto esCylinderFillingRecordDto) { private Boolean setNoUnitDataStaticInfo(List<Map<String, Object>> list, String value) {
return null; if (NO_DATA_STR.equals(value)) {
Map<String, Object> result2 = Maps.newHashMap();
result2.put("name", "使用登记办理率(%)");
result2.put("value", NO_DATA_STR);
Map<String, Object> result3 = Maps.newHashMap();
result3.put("name", "检验超期率(%)");
result3.put("value", NO_DATA_STR);
Map<String, Object> result4 = Maps.newHashMap();
result4.put("name", "检验合格率(%)");
result4.put("value", NO_DATA_STR);
Map<String, Object> result5 = Maps.newHashMap();
result5.put("name", "充装检查率(%)");
result5.put("value", NO_DATA_STR);
Map<String, Object> result6 = Maps.newHashMap();
result6.put("name", "充装检查合格率(%)");
result6.put("value", NO_DATA_STR);
list.add(result2);
list.add(result3);
list.add(result5);
list.add(result4);
list.add(result6);
return false;
}
return true;
} }
private Map<String, Object> getValidFillingCheckRate(ESCylinderFillingRecordDto esCylinderFillingRecordDto) { private String getLicenseEfficiencyByRegion(String regionCode) {
return null; List<KeyValueDto> keyValueDtos = this.getBaseMapper().queryLicenseEfficiencyOfRegion(regionCode);
int totalUnitNumber = keyValueDtos.stream().mapToInt(KeyValueDto::getIValue).sum();
int okUnitNumberNumber = keyValueDtos.stream().filter(k -> k.getStrKey().equals(LICENSE_IS_OK)).mapToInt(KeyValueDto::getIValue).sum();
if (totalUnitNumber == 0) {
return NO_DATA_STR;
}
BigDecimal bigTotalUnitNumber = new BigDecimal(String.valueOf(totalUnitNumber));
BigDecimal bigOkUnitNumberNumber = new BigDecimal(String.valueOf(okUnitNumberNumber));
BigDecimal result = bigOkUnitNumberNumber.divide(bigTotalUnitNumber, 4, RoundingMode.HALF_UP).multiply(new BigDecimal("100")).setScale(2);
return result.toPlainString();
} }
private long searchEsCount(Boolean checkOk, Boolean resultOk, String regionCode, String appId) { private long searchEsCount(Boolean checkOk, Boolean resultOk, String regionCode, String appId) {
......
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