Commit 52cdf642 authored by suhuiguang's avatar suhuiguang

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

parent 3035bd99
package com.yeejoin.amos.boot.module.elevator.api.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yeejoin.amos.boot.module.common.api.dto.DPFilterParamDto;
import com.yeejoin.amos.boot.module.elevator.api.entity.AlertStatistics;
import org.apache.ibatis.annotations.Param;
......@@ -15,4 +16,8 @@ public interface AlertStatisticsMapper extends BaseMapper<AlertStatistics> {
AlertStatistics getStatisticsMessage(@Param("orgCode")String orgCode, @Param("startDate")String startDate , @Param("endDate")String endDate);
AlertStatistics statisticsInfoByRegionAndDate(@Param("regionCode")String regionCode, @Param("startDate")String startDate , @Param("endDate")String endDate);
Long countProblemByTypeDateAndOrgCode(@Param("problemType") String problemType,@Param("dto") DPFilterParamDto params, @Param("orgCode") String orgCode);
String getOrgCodeByCompanyCode(String cityCode);
}
......@@ -99,4 +99,17 @@
from tz_alert_called t1 where t1.region_code like concat('%', #{regionCode}, '%') and t1.alarm_type_code = '960' and t1.call_time BETWEEN #{startDate} and #{endDate} and t1.father_alert is null
) as s ) as avgNum)t
</select>
<select id="countProblemByTypeDateAndOrgCode" resultType="java.lang.Long">
SELECT
count(1)
FROM
"tzs_safety_problem_tracing"
WHERE
problem_type = #{problemType}
and governing_body_org_code like concat(#{orgCode}, '%')
and cast(problem_time AS DATE) between #{dto.beginDate} and #{dto.endDate}
</select>
<select id="getOrgCodeByCompanyCode" resultType="java.lang.String">
select org_code from privilege_company where company_code = #{companyCode} limit 1
</select>
</mapper>
......@@ -27,6 +27,7 @@ import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
@Service
......@@ -37,6 +38,8 @@ public class AlertStatisticsServiceImpl extends BaseService<AlertStatisticsDto,
@Autowired
RedisUtils redisUtils;
private static Map<String, String> regionCodeOrgCodeMap = new ConcurrentHashMap<>();
@Scheduled(cron = "0 0 0 1 * ?")
@SchedulerLock(name = "AlertStatisticsServiceImpl", lockAtMostFor = "PT10M", lockAtLeastFor = "PT10M")
public void statisticalGenerationTask(){
......@@ -178,13 +181,15 @@ public class AlertStatisticsServiceImpl extends BaseService<AlertStatisticsDto,
startDate = LocalDate.parse(params.getBeginDate());
endDate = LocalDate.parse(params.getEndDate());
}
params.setBeginDate(startDate.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")));
params.setEndDate(endDate.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")));
AlertStatistics statistics = this.baseMapper.statisticsInfoByRegionAndDate(regionCode, startDate.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")), endDate.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")));
JSONArray jsonArray = new JSONArray();
if (!ObjectUtils.isEmpty(statistics)) {
JSONObject jsonObject = new JSONObject();
jsonObject.put("key", "dtkr");
jsonObject.put("value", ValidationUtil.isEmpty(statistics.getTrappedPeople()) ? 0 : statistics.getTrappedPeople());
jsonObject.put("name", "电梯困人");
JSONObject jsonObject0 = new JSONObject();
jsonObject0.put("key", "dtkr");
jsonObject0.put("value", ValidationUtil.isEmpty(statistics.getTrappedPeople()) ? 0 : statistics.getTrappedPeople());
jsonObject0.put("name", "电梯困人");
JSONObject jsonObject1 = new JSONObject();
jsonObject1.put("key", "slts");
......@@ -211,13 +216,52 @@ public class AlertStatisticsServiceImpl extends BaseService<AlertStatisticsDto,
jsonObject5.put("value", ValidationUtil.isEmpty(statistics.getAvgTime()) ? 0 : statistics.getAvgTime());
jsonObject5.put("name", "平均救援时间");
jsonArray.add(jsonObject);
String orgCode = this.getAndSetOrgCode(regionCode);
JSONObject jsonObject6 = new JSONObject();
jsonObject5.put("key", "jycq");
jsonObject5.put("value", this.getQuestionNumber("检验超期",params, orgCode));
jsonObject5.put("name", "检验超期");
JSONObject jsonObject7 = new JSONObject();
jsonObject5.put("key", "jybhg");
jsonObject5.put("value", this.getQuestionNumber("检验不合格",params, orgCode));
jsonObject5.put("name", "检验不合格");
JSONObject jsonObject8 = new JSONObject();
jsonObject5.put("key", "wbcq");
jsonObject5.put("value", this.getQuestionNumber("维保超期",params, orgCode));
jsonObject5.put("name", "c");
JSONObject jsonObject9 = new JSONObject();
jsonObject5.put("key", "csjsynx");
jsonObject5.put("value", this.getQuestionNumber("超设计使用年限",params, orgCode));
jsonObject5.put("name", "超设计使用年限");
jsonArray.add(jsonObject0);
jsonArray.add(jsonObject1);
jsonArray.add(jsonObject2);
jsonArray.add(jsonObject3);
jsonArray.add(jsonObject4);
jsonArray.add(jsonObject5);
jsonArray.add(jsonObject6);
jsonArray.add(jsonObject7);
jsonArray.add(jsonObject8);
jsonArray.add(jsonObject9);
}
return jsonArray;
}
private Long getQuestionNumber(String problemType, DPFilterParamDto params, String orgCode) {
return this.getBaseMapper().countProblemByTypeDateAndOrgCode(problemType, params, orgCode);
}
private String getAndSetOrgCode(String region) {
String orgCode = regionCodeOrgCodeMap.get(region);
if (orgCode == null) {
orgCode = this.getBaseMapper().getOrgCodeByCompanyCode(region);
if (orgCode != null) {
regionCodeOrgCodeMap.put(region, orgCode);
}
}
return orgCode;
}
}
\ No newline at end of file
......@@ -13,8 +13,6 @@ import java.util.List;
public class FourColorCountDataDto {
private String label;
private String img;
private String key;
private Long value;
......
package com.yeejoin.amos.boot.module.jg.api.enums;
import com.yeejoin.amos.boot.module.ymt.api.enums.EquimentEnum;
import lombok.AllArgsConstructor;
import lombok.Getter;
......
package com.yeejoin.amos.boot.module.jg.api.enums;
import lombok.Getter;
@Getter
public enum FourColorCountItemEnum {
/**
* 四色统计项
*/
EQUIP("设备", "equip"),
COMPANY("企业", "company"),
USER("人员", "user");
private String label;
private String key;
FourColorCountItemEnum(String label, String key) {
this.label = label;
this.key = key;
}
}
package com.yeejoin.amos.boot.module.jg.api.enums;
import lombok.Getter;
/**
* @author Administrator
*/
@Getter
public enum FourColorEnum {
/**
* 四色统计项
*/
GREEN("绿色", "green"),
RED("红色", "red"),
YELLOW("黄色", "yellow"),
GREY("灰色", "grey");
private String name;
private String code;
FourColorEnum(String name, String code) {
this.name = name;
this.code = code;
}
}
package com.yeejoin.amos.boot.module.jg.api.enums;
import io.swagger.models.auth.In;
/**
* 维保备案使用单位枚举
*/
......
package com.yeejoin.amos.boot.module.jg.api.enums;
import com.yeejoin.amos.boot.module.jg.api.event.handler.SafetyProblemEventHandler;
import lombok.Getter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.config.AutowireCapableBeanFactory;
/**
* 业务类型枚举
......
......@@ -953,45 +953,45 @@
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}
SELECT count(1) FROM "tzs_jg_installation_notice" where receive_company_org_code like CONCAT(#{orgCode}, '%') and notice_status = '6616' and date_ge(CAST(handle_date as date),#{dto.beginDate}) and date_le(CAST(handle_date as date),#{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}
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 date_ge(CAST(a.accept_date as date),#{dto.beginDate}) and date_le(CAST(a.accept_date as date),#{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}
SELECT count(1) FROM "tzs_jg_use_registration" where receive_company_org_code like CONCAT(#{orgCode}, '%') and status = '已完成' and date_ge(CAST(audit_pass_date as date),#{dto.beginDate}) and date_le(CAST(audit_pass_date as date),#{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}
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 date_ge(CAST(a.accept_date as date),#{dto.beginDate}) and date_le(CAST(a.accept_date as date),#{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}
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 date_ge(CAST(a.audit_pass_date as date),#{dto.beginDate}) and date_le(CAST(a.audit_pass_date as date),#{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}
SELECT count(1) as num FROM "tzs_jg_change_registration_reform" where receive_company_org_code like CONCAT(#{orgCode}, '%') and audit_status = '已完成' and date_ge(CAST(audit_pass_date as date),#{dto.beginDate}) and date_le(CAST(audit_pass_date as date),#{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}
SELECT count(1) as num FROM "tzs_jg_change_registration_transfer" where receive_company_org_code like CONCAT(#{orgCode}, '%') and audit_status = '已完成' and date_ge(CAST(audit_pass_date as date),#{dto.beginDate}) and date_le(CAST(audit_pass_date as date),#{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}
SELECT count(1) as num FROM "tzs_jg_change_registration_unit" where receive_company_org_code like CONCAT(#{orgCode}, '%') and status = '已完成' and date_ge(CAST(audit_pass_date as date),#{dto.beginDate}) and date_le(CAST(audit_pass_date as date),#{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 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 date_ge(CAST(a.audit_pass_date as date),#{dto.beginDate}) and date_le(CAST(a.audit_pass_date as date),#{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}
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 date_ge(CAST(handle_date as date),#{dto.beginDate}) and date_le(CAST(handle_date as date),#{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}
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 date_ge(CAST(a.accept_date as date),#{dto.beginDate}) and date_le(CAST(a.accept_date as date),#{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}
SELECT count(1) FROM "tzs_jg_use_registration" where receive_company_org_code like CONCAT(#{orgCode}, '%') and status != '使用单位待提交' and status != '使用单位已撤回' and status != '已作废' and date_ge(CAST(audit_pass_date as date),#{dto.beginDate}) and date_le(CAST(audit_pass_date as date),#{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}
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 date_ge(CAST(a.accept_date as date),#{dto.beginDate}) and date_le(CAST(a.accept_date as date),#{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}
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 date_ge(CAST(a.audit_pass_date as date),#{dto.beginDate}) and date_le(CAST(a.audit_pass_date as date),#{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}
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 date_ge(CAST(audit_pass_date as date),#{dto.beginDate}) and date_le(CAST(audit_pass_date as date),#{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}
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 date_ge(CAST(audit_pass_date as date),#{dto.beginDate}) and date_le(CAST(audit_pass_date as date),#{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}
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 date_ge(CAST(audit_pass_date as date),#{dto.beginDate}) and date_le(CAST(audit_pass_date as date),#{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 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 date_ge(CAST(a.audit_pass_date as date),#{dto.beginDate}) and date_le(CAST(a.audit_pass_date as date),#{dto.endDate})
</select>
</mapper>
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;
......@@ -9,11 +8,14 @@ import com.yeejoin.amos.boot.module.common.api.dto.LegendDataDto;
import com.yeejoin.amos.boot.module.jg.api.dto.EquipBizCountDto;
import com.yeejoin.amos.boot.module.jg.api.dto.FourColorCountDataDto;
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.FourColorEnum;
import com.yeejoin.amos.boot.module.jg.api.mapper.CommonMapper;
import com.yeejoin.amos.boot.module.jg.api.mapper.JgEnableDisableMapper;
import com.yeejoin.amos.boot.module.jg.api.mapper.JgScrapCancelMapper;
import com.yeejoin.amos.boot.module.jg.api.mapper.JgUseRegistrationMapper;
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.EquipTechParamPipelineMapper;
import com.yeejoin.amos.boot.module.ymt.api.mapper.EquipmentCategoryMapper;
import com.yeejoin.amos.boot.module.ymt.api.mapper.TzBaseEnterpriseInfoMapper;
......@@ -35,7 +37,6 @@ 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;
......@@ -448,108 +449,187 @@ public class DPStatisticsServiceImpl {
public Map<String, Object> querySafetyIndex(DPFilterParamDto dpFilterParamDto) {
Map<String, Object> result = new HashMap<>();
result.put("riskScore", 89.2);
result.put("riskScore", 12);
return result;
}
public List<FourColorCountDataDto> queryFourColorManagerSafetyData(DPFilterParamDto dpFilterParamDto) {
String mockData = "[{\n" +
"\t\t\"label\": \"设备\",\n" +
"\t\t\"img\": \"/upload/tzs/dqscreen/images/设备.png\",\n" +
"\t\t\"children\": [{\n" +
"\t\t\t\t\"label\": \"正常在用\",\n" +
"\t\t\t\t\"value\": 112372,\n" +
"\t\t\t\t\"img\": \"/upload/tzs/dqscreen/images/qrcodeFour.png\"\n" +
"\t\t\t},\n" +
"\t\t\t{\n" +
"\t\t\t\t\"label\": \"超期末检\",\n" +
"\t\t\t\t\"value\": 72,\n" +
"\t\t\t\t\"img\": \"/upload/tzs/dqscreen/images/qrcodeThree.png\"\n" +
"\t\t\t},\n" +
"\t\t\t{\n" +
"\t\t\t\t\"label\": \"临期告警\",\n" +
"\t\t\t\t\"value\": 72,\n" +
"\t\t\t\t\"img\": \"/upload/tzs/dqscreen/images/qrcodeTwo.png\"\n" +
"\t\t\t},\n" +
"\t\t\t{\n" +
"\t\t\t\t\"label\": \"未注册、停用或注销\",\n" +
"\t\t\t\t\"value\": 72,\n" +
"\t\t\t\t\"img\": \"/upload/tzs/dqscreen/images/qrcodeOne.png\"\n" +
"\t\t\t}\n" +
"\t\t]\n" +
"\t},\n" +
"\t{\n" +
"\t\t\"label\": \"企业\",\n" +
"\t\t\"img\": \"/upload/tzs/dqscreen/images/企业.png\",\n" +
"\t\t\"children\": [{\n" +
"\t\t\t\t\"label\": \"正常在业\",\n" +
"\t\t\t\t\"value\": 72,\n" +
"\t\t\t\t\"img\": \"/upload/tzs/dqscreen/images/qrcodeFour.png\"\n" +
"\t\t\t},\n" +
"\t\t\t{\n" +
"\t\t\t\t\"label\": \"超期未检\",\n" +
"\t\t\t\t\"value\": 72,\n" +
"\t\t\t\t\"img\": \"/upload/tzs/dqscreen/images/qrcodeThree.png\"\n" +
"\t\t\t},\n" +
"\t\t\t{\n" +
"\t\t\t\t\"label\": \"临期告警\",\n" +
"\t\t\t\t\"value\": 72,\n" +
"\t\t\t\t\"img\": \"/upload/tzs/dqscreen/images/qrcodeTwo.png\"\n" +
"\t\t\t},\n" +
"\t\t\t{\n" +
"\t\t\t\t\"label\": \"停业\",\n" +
"\t\t\t\t\"value\": 72,\n" +
"\t\t\t\t\"img\": \"/upload/tzs/dqscreen/images/qrcodeOne.png\"\n" +
"\t\t\t}\n" +
"\t\t]\n" +
"\t},\n" +
"\t{\n" +
"\t\t\"label\": \"人员\",\n" +
"\t\t\"img\": \"/upload/tzs/dqscreen/images/人员.png\",\n" +
"\t\t\"children\": [{\n" +
"\t\t\t\t\"label\": \"许可正常\",\n" +
"\t\t\t\t\"value\": 72,\n" +
"\t\t\t\t\"img\": \"/upload/tzs/dqscreen/images/qrcodeFour.png\"\n" +
"\t\t\t},\n" +
"\t\t\t{\n" +
"\t\t\t\t\"label\": \"许可超期\",\n" +
"\t\t\t\t\"value\": 72,\n" +
"\t\t\t\t\"img\": \"/upload/tzs/dqscreen/images/qrcodeThree.png\"\n" +
"\t\t\t},\n" +
"\t\t\t{\n" +
"\t\t\t\t\"label\": \"许可临期\",\n" +
"\t\t\t\t\"value\": 72,\n" +
"\t\t\t\t\"img\": \"/upload/tzs/dqscreen/images/qrcodeTwo.png\"\n" +
"\t\t\t}\n" +
"\t\t]\n" +
"\t}\n" +
"]";
return JSONArray.parseArray(mockData, FourColorCountDataDto.class);
this.setDefaultFilter(dpFilterParamDto);
Map<String, Map<String, CountDto>> dataMap = this.getAllDataMap(dpFilterParamDto);
return Arrays.stream(FourColorCountItemEnum.values()).map(e -> {
FourColorCountDataDto dataDto = new FourColorCountDataDto();
dataDto.setKey(e.getKey());
dataDto.setLabel(e.getLabel());
dataDto.setChildren(this.buildFourColorItemData(dataMap.get(e.getKey())));
return dataDto;
}).collect(Collectors.toList());
}
public Map<String, Object> queryBizCycleData(DPFilterParamDto dpFilterParamDto) {
Map<String, Object> result = new HashMap<>();
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);
private List<FourColorCountDataDto> buildFourColorItemData(Map<String, CountDto> colorCountDataMap) {
return Arrays.stream(FourColorEnum.values()).filter(e -> colorCountDataMap.get(e.getCode()) != null).map(c -> {
FourColorCountDataDto dataDto = new FourColorCountDataDto();
dataDto.setKey(c.getCode());
dataDto.setValue(colorCountDataMap.get(c.getCode()).getLongValue());
dataDto.setLabel(colorCountDataMap.get(c.getCode()).getLabel());
return dataDto;
}).collect(Collectors.toList());
}
private Map<String, Map<String, CountDto>> getAllDataMap(DPFilterParamDto dpFilterParamDto) {
Map<String, Map<String, CountDto>> countMap = new HashMap<>();
countMap.put(FourColorCountItemEnum.EQUIP.getKey(), this.countEquipNum(dpFilterParamDto));
countMap.put(FourColorCountItemEnum.COMPANY.getKey(), this.countCompanyNum(dpFilterParamDto));
countMap.put(FourColorCountItemEnum.USER.getKey(), this.countUserNum(dpFilterParamDto));
return countMap;
}
private Map<String, CountDto> countEquipNum(DPFilterParamDto dpFilterParamDto) {
Map<String, CountDto> countMap = new HashMap<>();
countMap.put(FourColorEnum.GREEN.getCode(), this.getGreenStatusEquip(dpFilterParamDto));
countMap.put(FourColorEnum.RED.getCode(), this.getRedStatusEquip(dpFilterParamDto));
countMap.put(FourColorEnum.YELLOW.getCode(), this.getYellowStatusEquip(dpFilterParamDto));
countMap.put(FourColorEnum.GREY.getCode(), this.getGreyStatusEquip(dpFilterParamDto));
return countMap;
}
private CountDto getGreenStatusEquip(DPFilterParamDto dpFilterParamDto) {
CountDto countDto = new CountDto();
countDto.setLongValue(this.countEquipNumFromES(dpFilterParamDto, EquimentEnum.ZAIYONG.getCode()));
countDto.setLabel("正常在用");
return countDto;
}
private long countEquipNumFromES(DPFilterParamDto dpFilterParamDto, Integer... states) {
long num;
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("EQU_STATE", states));
request.query(boolMust);
try {
CountResponse response = restHighLevelClient.count(request, RequestOptions.DEFAULT);
num = response.getCount();
} catch (IOException e) {
throw new RuntimeException(e);
}
return result;
return num;
}
private CountDto getRedStatusEquip(DPFilterParamDto dpFilterParamDto) {
// TODO 需求不明确
CountDto countDto = new CountDto();
countDto.setLongValue(0L);
countDto.setLabel("超期未检");
return countDto;
}
private String buildRedisKey(String prefix, String cityCode) {
return String.format("%s:%s", prefix, cityCode);
private CountDto getYellowStatusEquip(DPFilterParamDto dpFilterParamDto) {
// TODO 需求不明确
CountDto countDto = new CountDto();
countDto.setLongValue(0L);
countDto.setLabel("临期告警");
return countDto;
}
private CountDto getGreyStatusEquip(DPFilterParamDto dpFilterParamDto) {
CountDto countDto = new CountDto();
countDto.setLongValue(this.countEquipNumFromES(dpFilterParamDto, EquimentEnum.BAOFEI.getCode(), EquimentEnum.ZHUXIAO.getCode()));
countDto.setLabel("未注册、停用或注销");
return countDto;
}
private Map<String, CountDto> countCompanyNum(DPFilterParamDto dpFilterParamDto) {
Map<String, CountDto> countMap = new HashMap<>();
countMap.put(FourColorEnum.GREEN.getCode(), this.getGreenStatusCompany(dpFilterParamDto));
countMap.put(FourColorEnum.RED.getCode(), this.getRedStatusCompany(dpFilterParamDto));
countMap.put(FourColorEnum.YELLOW.getCode(), this.getYellowStatusCompany(dpFilterParamDto));
countMap.put(FourColorEnum.GREY.getCode(), this.getGreyStatusCompany(dpFilterParamDto));
return countMap;
}
private CountDto getGreyStatusCompany(DPFilterParamDto dpFilterParamDto) {
CountDto countDto = new CountDto();
countDto.setLongValue(0L);
countDto.setLongValue(this.countCompanyByOperatingStatus(dpFilterParamDto, "停业"));
countDto.setLabel("停业");
return countDto;
}
private CountDto getYellowStatusCompany(DPFilterParamDto dpFilterParamDto) {
// TODO 需求不明确
CountDto countDto = new CountDto();
countDto.setLongValue(0L);
countDto.setLabel("临期告警");
return countDto;
}
private CountDto getRedStatusCompany(DPFilterParamDto dpFilterParamDto) {
// TODO 需求不明确
CountDto countDto = new CountDto();
countDto.setLongValue(0L);
countDto.setLabel("超期未检");
return countDto;
}
private CountDto getGreenStatusCompany(DPFilterParamDto dpFilterParamDto) {
CountDto countDto = new CountDto();
countDto.setLongValue(this.countCompanyByOperatingStatus(dpFilterParamDto, "在业"));
countDto.setLabel("正常在业");
return countDto;
}
private long countCompanyByOperatingStatus(DPFilterParamDto dpFilterParamDto, String operatingStatus) {
String orgCode = getAndSetOrgCode(dpFilterParamDto.getCityCode());
return enterpriseInfoMapper.countByOperatingStatusAndOrgCode(orgCode, operatingStatus);
}
private Map<String, CountDto> countUserNum(DPFilterParamDto dpFilterParamDto) {
Map<String, CountDto> countMap = new HashMap<>();
countMap.put(FourColorEnum.GREEN.getCode(), this.getGreenStatusUser(dpFilterParamDto));
countMap.put(FourColorEnum.RED.getCode(), this.getRedStatusUser(dpFilterParamDto));
countMap.put(FourColorEnum.YELLOW.getCode(), this.getYellowStatusUser(dpFilterParamDto));
return countMap;
}
private CountDto getYellowStatusUser(DPFilterParamDto dpFilterParamDto) {
// TODO 需求不明确
CountDto countDto = new CountDto();
countDto.setLongValue(0L);
countDto.setLabel("许可临期");
return countDto;
}
private CountDto getRedStatusUser(DPFilterParamDto dpFilterParamDto) {
// TODO 需求不明确
CountDto countDto = new CountDto();
countDto.setLongValue(0L);
countDto.setLabel("许可超期");
return countDto;
}
private CountDto getGreenStatusUser(DPFilterParamDto dpFilterParamDto) {
// TODO 需求不明确
CountDto countDto = new CountDto();
countDto.setLongValue(0L);
countDto.setLabel("许可正常");
return countDto;
}
public Map<String, Object> queryBizCycleData(DPFilterParamDto dpFilterParamDto) {
Map<String, Object> result = new HashMap<>();
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));
return result;
}
private String calPercentForBizCycleData(DPFilterParamDto dpFilterParamDto, Long allFinishedCount) {
Long allBizDataInFlowingCount = this.countAllBizDataInFlowing(dpFilterParamDto);
BigDecimal finish = new BigDecimal(String.valueOf(allFinishedCount));
......@@ -561,11 +641,7 @@ public class DPStatisticsServiceImpl {
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();
}
......
......@@ -70,5 +70,12 @@ public interface TzBaseEnterpriseInfoMapper extends BaseMapper<TzBaseEnterpriseI
List<CountDto> countByUnitTypeAndOrgCodeNoParam();
/**
* 按照状态统计
*
* @param orgCode 公司的orgCode
* @param operatingStatus 营业状态
* @return Long 统计数量
*/
Long countByOperatingStatusAndOrgCode(@Param("orgCode") String orgCode, @Param("operatingStatus") String operatingStatus);
}
......@@ -215,4 +215,13 @@
"tz_base_enterprise_info" a
group by a.unit_type,a.supervise_org_code
</select>
<select id="countByOperatingStatusAndOrgCode" resultType="java.lang.Long">
SELECT
count(1)
FROM
"tz_base_enterprise_info"
where
supervise_org_code like concat(#{orgCode},'%')
and operating_status = #{operatingStatus}
</select>
</mapper>
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