Commit 3035bd99 authored by suhuiguang's avatar suhuiguang

1.大屏概览接口-业务全过程

parent fbfcb996
......@@ -3,6 +3,7 @@ package com.yeejoin.amos.boot.module.jg.api.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yeejoin.amos.boot.biz.common.bo.CompanyBo;
import com.yeejoin.amos.boot.module.common.api.dto.DPFilterParamDto;
import com.yeejoin.amos.boot.module.jg.api.bo.JgBizCountDataBO;
import com.yeejoin.amos.boot.module.jg.api.dto.ReportAnalysisSearchDTO;
import com.yeejoin.amos.boot.module.ymt.api.entity.EquipmentCategory;
......@@ -113,5 +114,23 @@ public interface CommonMapper extends BaseMapper<EquipmentCategory> {
List<Map<String, Object>> queryOutOfMaintenanceRecord();
List<Map<String, Object>> queryOutOfInspectionRecord();
/**
* 大屏业务全过程统计已经完成的单据
*
* @param orgCode 行政区划对应公司的orgCode
* @param dpFilterParamDto 过滤条件
* @return 统计数量数组
*/
List<Long> countBizFinishedNumForDP(@Param("orgCode") String orgCode, @Param("dto") DPFilterParamDto dpFilterParamDto);
/**
* 大屏大屏业务全过程统计流程中(包括已经完成)的单据
*
* @param orgCode 行政区划对应公司的orgCode
* @param dpFilterParamDto 过滤条件
* @return 统计数量数组
*/
List<Long> countAllBizDataInFlowingForDP(@Param("orgCode")String orgCode, @Param("dto") DPFilterParamDto dpFilterParamDto);
}
......@@ -952,4 +952,46 @@
LEFT JOIN idx_biz_jg_supervision_info si on si."RECORD" = tt."RECORD"
WHERE ui."DATA_SOURCE" like 'jg%'
</select>
<select id="countBizFinishedNumForDP" resultType="java.lang.Long">
SELECT count(1) FROM "tzs_jg_installation_notice" where receive_company_org_code like CONCAT(#{orgCode}, '%') and notice_status = '6616' and handle_date between #{dto.beginDate} and #{dto.endDate}
union all
SELECT count(1) FROM "tz_jyjc_inspection_application" a, tz_base_enterprise_info b where a.inspection_unit_code= b.use_unit_code and b.supervise_org_code like '50%' and a.status = '6616' and a.biz_type = 'supervise' and a.accept_date between #{dto.beginDate} and #{dto.endDate}
union all
SELECT count(1) FROM "tzs_jg_use_registration" where receive_company_org_code like CONCAT(#{orgCode}, '%') and status = '已完成' and audit_pass_date between #{dto.beginDate} and #{dto.endDate}
union all
SELECT count(1) FROM "tz_jyjc_inspection_application" a, tz_base_enterprise_info b where a.inspection_unit_code= b.use_unit_code and b.supervise_org_code like '50%' and a.status = '6616' and a.inspection_type = 'DQJY' and a.accept_date between #{dto.beginDate} and #{dto.endDate}
union all
select sum(num) from (
select count(1) as num from tzs_jg_change_registration_name a, privilege_company b where a.receive_org_code= b.company_code and b.org_code like '50%' and a.audit_status = '已完成' and a.audit_pass_date between #{dto.beginDate} and #{dto.endDate}
union all
SELECT count(1) as num FROM "tzs_jg_change_registration_reform" where receive_company_org_code like CONCAT(#{orgCode}, '%') and audit_status = '已完成' and audit_pass_date between #{dto.beginDate} and #{dto.endDate}
union all
SELECT count(1) as num FROM "tzs_jg_change_registration_transfer" where receive_company_org_code like CONCAT(#{orgCode}, '%') and audit_status = '已完成' and audit_pass_date between #{dto.beginDate} and #{dto.endDate}
union all
SELECT count(1) as num FROM "tzs_jg_change_registration_unit" where receive_company_org_code like CONCAT(#{orgCode}, '%') and status = '已完成' and audit_pass_date between #{dto.beginDate} and #{dto.endDate}
)
union all
select count(1) from tzs_jg_scrap_cancel a, privilege_company b where a.receive_org_code= b.company_code and b.org_code like CONCAT(#{orgCode}, '%') and a.audit_status = '已完成' and a.audit_pass_date between #{dto.beginDate} and #{dto.endDate}
</select>
<select id="countAllBizDataInFlowingForDP" resultType="java.lang.Long">
SELECT count(1) FROM "tzs_jg_installation_notice" where receive_company_org_code like CONCAT(#{orgCode}, '%') and notice_status != '6610' and notice_status != '6615' and notice_status != '6617' and handle_date between #{dto.beginDate} and #{dto.endDate}
union all
SELECT count(1) FROM "tz_jyjc_inspection_application" a, tz_base_enterprise_info b where a.inspection_unit_code= b.use_unit_code and b.supervise_org_code like CONCAT(#{orgCode}, '%') and a.status != '6610' and a.status != '6615' and a.status != '6617' and a.biz_type = 'supervise' and a.accept_date between #{dto.beginDate} and #{dto.endDate}
union all
SELECT count(1) FROM "tzs_jg_use_registration" where receive_company_org_code like CONCAT(#{orgCode}, '%') and status != '使用单位待提交' and status != '使用单位已撤回' and status != '已作废' and audit_pass_date between #{dto.beginDate} and #{dto.endDate}
union all
SELECT count(1) FROM "tz_jyjc_inspection_application" a, tz_base_enterprise_info b where a.inspection_unit_code= b.use_unit_code and b.supervise_org_code like CONCAT(#{orgCode}, '%') and a.status != '6610' and a.status != '6615' and a.status != '6617' and a.inspection_type = 'DQJY' and a.accept_date between #{dto.beginDate} and #{dto.endDate}
union all
select sum(num) from (
select count(1) as num from tzs_jg_change_registration_name a, privilege_company b where a.receive_org_code= b.company_code and b.org_code like CONCAT(#{orgCode}, '%') and a.audit_status != '使用单位已撤回' and a.audit_status != '使用单位待提交' and a.audit_status !='已作废' and a.audit_pass_date between #{dto.beginDate} and #{dto.endDate}
union all
SELECT count(1) as num FROM "tzs_jg_change_registration_reform" where receive_company_org_code like CONCAT(#{orgCode}, '%') and audit_status != '使用单位待提交' and audit_status != '使用单位已撤回' and audit_status != '已作废' and audit_pass_date between #{dto.beginDate} and #{dto.endDate}
union all
SELECT count(1) as num FROM "tzs_jg_change_registration_transfer" where receive_company_org_code like CONCAT(#{orgCode}, '%') and audit_status != '使用单位待提交' and audit_status != '使用单位已撤回' and audit_status != '已作废' and audit_pass_date between #{dto.beginDate} and #{dto.endDate}
union all
SELECT count(1) as num FROM "tzs_jg_change_registration_unit" where receive_company_org_code like CONCAT(#{orgCode}, '%') and status != '使用单位待提交' and status != '使用单位已撤回' and status != '已作废' and audit_pass_date between #{dto.beginDate} and #{dto.endDate}
)
union all
select count(1) from tzs_jg_scrap_cancel a, privilege_company b where a.receive_org_code= b.company_code and b.org_code like CONCAT(#{orgCode}, '%') and a.audit_status != '使用单位待提交' and a.audit_status != '使用单位已撤回' and a.audit_status != '已作废' and a.audit_pass_date between #{dto.beginDate} and #{dto.endDate}
</select>
</mapper>
......@@ -3,6 +3,7 @@ package com.yeejoin.amos.boot.module.jg.biz.service.impl;
import cn.hutool.core.date.DateUtil;
import com.alibaba.fastjson.JSONArray;
import com.yeejoin.amos.boot.biz.common.dto.CountDto;
import com.yeejoin.amos.boot.biz.common.utils.RedisUtils;
import com.yeejoin.amos.boot.module.common.api.dto.DPFilterParamDto;
import com.yeejoin.amos.boot.module.common.api.dto.LegendDataDto;
import com.yeejoin.amos.boot.module.jg.api.dto.EquipBizCountDto;
......@@ -34,6 +35,7 @@ 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.util.StopWatch;
import java.io.IOException;
import java.math.BigDecimal;
......@@ -106,12 +108,14 @@ public class DPStatisticsServiceImpl {
private TzsUserInfoMapper userInfoMapper;
private RedisUtils redisUtils;
private static Map<String, String> regionCodeOrgCodeMap = new ConcurrentHashMap<>();
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) {
public DPStatisticsServiceImpl(EquipmentCategoryMapper equipmentCategoryMapper, JgUseRegistrationMapper useRegistrationMapper, EquipTechParamPipelineMapper techParamsPipelineMapper, JgEnableDisableMapper enableDisableMapper, JgScrapCancelMapper scrapCancelMapper, RestHighLevelClient restHighLevelClient, TzBaseEnterpriseInfoMapper enterpriseInfoMapper, CommonMapper commonMapper, TzsUserInfoMapper userInfoMapper, RedisUtils redisUtils, RedisUtils redisUtils1) {
this.equipmentCategoryMapper = equipmentCategoryMapper;
this.useRegistrationMapper = useRegistrationMapper;
this.techParamsPipelineMapper = techParamsPipelineMapper;
......@@ -121,6 +125,7 @@ public class DPStatisticsServiceImpl {
this.enterpriseInfoMapper = enterpriseInfoMapper;
this.commonMapper = commonMapper;
this.userInfoMapper = userInfoMapper;
this.redisUtils = redisUtils1;
}
public void init() {
......@@ -245,7 +250,6 @@ public class DPStatisticsServiceImpl {
}
private void staticsCenterMapCountDataForPerson(Map<String, Object> result, DPFilterParamDto dpFilterParamDto) {
// 效率太慢暂时注释掉
String orgCode = regionCodeOrgCodeMap.get(dpFilterParamDto.getCityCode());
if (orgCode == null) {
orgCode = commonMapper.getOrgCodeByCompanyCode(dpFilterParamDto.getCityCode());
......@@ -525,10 +529,64 @@ public class DPStatisticsServiceImpl {
public Map<String, Object> queryBizCycleData(DPFilterParamDto dpFilterParamDto) {
Map<String, Object> result = new HashMap<>();
result.put("xdata", Arrays.asList("安装告知", "监督检验", "使用登记", "定期检验", "变更登录", "注销报废"));
result.put("ydata", Arrays.asList(35, 13, 19, 18, 87, 71));
result.put("allCount", 1021);
result.put("completionRate", 90.2);
String redisKey = this.buildRedisKey("bizCycleData", dpFilterParamDto.getCityCode());
if (redisUtils.hasKey(redisKey)) {
return (Map<String, Object>) redisUtils.get(redisKey);
} else {
// 查询条件构造未上送时间时,默认查询数据为近一个月数据
this.setDefaultFilter(dpFilterParamDto);
result.put("xdata", Arrays.asList("安装告知", "监督检验", "使用登记", "定期检验", "变更登记", "注销报废"));
List<Long> ydata = this.countBizFinishedNum(dpFilterParamDto);
Long allFinishedCount = ydata.stream().mapToLong(e -> e).sum();
result.put("ydata", ydata);
result.put("allCount", allFinishedCount);
result.put("completionRate", this.calPercentForBizCycleData(dpFilterParamDto, allFinishedCount));
redisUtils.set(redisKey, result, 20 * 60);
}
return result;
}
private String buildRedisKey(String prefix, String cityCode) {
return String.format("%s:%s", prefix, cityCode);
}
private String calPercentForBizCycleData(DPFilterParamDto dpFilterParamDto, Long allFinishedCount) {
Long allBizDataInFlowingCount = this.countAllBizDataInFlowing(dpFilterParamDto);
BigDecimal finish = new BigDecimal(String.valueOf(allFinishedCount));
BigDecimal total = new BigDecimal(String.valueOf(allBizDataInFlowingCount));
BigDecimal result = finish.divide(total, 2, RoundingMode.HALF_UP);
BigDecimal percentage = result.multiply(new BigDecimal("100")).setScale(2, RoundingMode.HALF_UP);
return percentage.toPlainString();
}
private Long countAllBizDataInFlowing(DPFilterParamDto dpFilterParamDto) {
String orgCode = getAndSetOrgCode(dpFilterParamDto.getCityCode());
StopWatch watch1 = new StopWatch();
watch1.start();
List<Long> inFlowingForDP = commonMapper.countAllBizDataInFlowingForDP(orgCode, dpFilterParamDto);
watch1.stop();
log.info("cx2---->{}", watch1.getTotalTimeSeconds());
return inFlowingForDP.stream().mapToLong(e -> e).sum();
}
private List<Long> countBizFinishedNum(DPFilterParamDto dpFilterParamDto) {
// 1.统计各业务办理量注意要和x轴顺序一致
String orgCode = getAndSetOrgCode(dpFilterParamDto.getCityCode());
// 省、市、区县为按照行政区划进行编码的,公司的code为行政区划编码
if (orgCode == null) {
return Arrays.asList(0L, 0L, 0L, 0L, 0L, 0L);
}
return commonMapper.countBizFinishedNumForDP(orgCode, dpFilterParamDto);
}
private String getAndSetOrgCode(String cityCode) {
String orgCode = regionCodeOrgCodeMap.get(cityCode);
if (orgCode == null) {
orgCode = commonMapper.getOrgCodeByCompanyCode(cityCode);
if (orgCode != null) {
regionCodeOrgCodeMap.put(cityCode, orgCode);
}
}
return orgCode;
}
}
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