Commit 52cdf642 authored by suhuiguang's avatar suhuiguang

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

parent 3035bd99
package com.yeejoin.amos.boot.module.elevator.api.mapper; package com.yeejoin.amos.boot.module.elevator.api.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; 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 com.yeejoin.amos.boot.module.elevator.api.entity.AlertStatistics;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
...@@ -15,4 +16,8 @@ public interface AlertStatisticsMapper extends BaseMapper<AlertStatistics> { ...@@ -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 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); 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 @@ ...@@ -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 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 ) as s ) as avgNum)t
</select> </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> </mapper>
...@@ -27,6 +27,7 @@ import java.text.SimpleDateFormat; ...@@ -27,6 +27,7 @@ import java.text.SimpleDateFormat;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.util.*; import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
@Service @Service
...@@ -37,6 +38,8 @@ public class AlertStatisticsServiceImpl extends BaseService<AlertStatisticsDto, ...@@ -37,6 +38,8 @@ public class AlertStatisticsServiceImpl extends BaseService<AlertStatisticsDto,
@Autowired @Autowired
RedisUtils redisUtils; RedisUtils redisUtils;
private static Map<String, String> regionCodeOrgCodeMap = new ConcurrentHashMap<>();
@Scheduled(cron = "0 0 0 1 * ?") @Scheduled(cron = "0 0 0 1 * ?")
@SchedulerLock(name = "AlertStatisticsServiceImpl", lockAtMostFor = "PT10M", lockAtLeastFor = "PT10M") @SchedulerLock(name = "AlertStatisticsServiceImpl", lockAtMostFor = "PT10M", lockAtLeastFor = "PT10M")
public void statisticalGenerationTask(){ public void statisticalGenerationTask(){
...@@ -178,13 +181,15 @@ public class AlertStatisticsServiceImpl extends BaseService<AlertStatisticsDto, ...@@ -178,13 +181,15 @@ public class AlertStatisticsServiceImpl extends BaseService<AlertStatisticsDto,
startDate = LocalDate.parse(params.getBeginDate()); startDate = LocalDate.parse(params.getBeginDate());
endDate = LocalDate.parse(params.getEndDate()); 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"))); AlertStatistics statistics = this.baseMapper.statisticsInfoByRegionAndDate(regionCode, startDate.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")), endDate.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")));
JSONArray jsonArray = new JSONArray(); JSONArray jsonArray = new JSONArray();
if (!ObjectUtils.isEmpty(statistics)) { if (!ObjectUtils.isEmpty(statistics)) {
JSONObject jsonObject = new JSONObject(); JSONObject jsonObject0 = new JSONObject();
jsonObject.put("key", "dtkr"); jsonObject0.put("key", "dtkr");
jsonObject.put("value", ValidationUtil.isEmpty(statistics.getTrappedPeople()) ? 0 : statistics.getTrappedPeople()); jsonObject0.put("value", ValidationUtil.isEmpty(statistics.getTrappedPeople()) ? 0 : statistics.getTrappedPeople());
jsonObject.put("name", "电梯困人"); jsonObject0.put("name", "电梯困人");
JSONObject jsonObject1 = new JSONObject(); JSONObject jsonObject1 = new JSONObject();
jsonObject1.put("key", "slts"); jsonObject1.put("key", "slts");
...@@ -211,13 +216,52 @@ public class AlertStatisticsServiceImpl extends BaseService<AlertStatisticsDto, ...@@ -211,13 +216,52 @@ public class AlertStatisticsServiceImpl extends BaseService<AlertStatisticsDto,
jsonObject5.put("value", ValidationUtil.isEmpty(statistics.getAvgTime()) ? 0 : statistics.getAvgTime()); jsonObject5.put("value", ValidationUtil.isEmpty(statistics.getAvgTime()) ? 0 : statistics.getAvgTime());
jsonObject5.put("name", "平均救援时间"); 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(jsonObject1);
jsonArray.add(jsonObject2); jsonArray.add(jsonObject2);
jsonArray.add(jsonObject3); jsonArray.add(jsonObject3);
jsonArray.add(jsonObject4); jsonArray.add(jsonObject4);
jsonArray.add(jsonObject5); jsonArray.add(jsonObject5);
jsonArray.add(jsonObject6);
jsonArray.add(jsonObject7);
jsonArray.add(jsonObject8);
jsonArray.add(jsonObject9);
} }
return jsonArray; 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; ...@@ -13,8 +13,6 @@ import java.util.List;
public class FourColorCountDataDto { public class FourColorCountDataDto {
private String label; private String label;
private String img;
private String key; private String key;
private Long value; private Long value;
......
package com.yeejoin.amos.boot.module.jg.api.enums; package com.yeejoin.amos.boot.module.jg.api.enums;
import com.yeejoin.amos.boot.module.ymt.api.enums.EquimentEnum;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Getter; 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; package com.yeejoin.amos.boot.module.jg.api.enums;
import io.swagger.models.auth.In;
/** /**
* 维保备案使用单位枚举 * 维保备案使用单位枚举
*/ */
......
package com.yeejoin.amos.boot.module.jg.api.enums; package com.yeejoin.amos.boot.module.jg.api.enums;
import com.yeejoin.amos.boot.module.jg.api.event.handler.SafetyProblemEventHandler;
import lombok.Getter; import lombok.Getter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.config.AutowireCapableBeanFactory;
/** /**
* 业务类型枚举 * 业务类型枚举
......
...@@ -953,45 +953,45 @@ ...@@ -953,45 +953,45 @@
WHERE ui."DATA_SOURCE" like 'jg%' WHERE ui."DATA_SOURCE" like 'jg%'
</select> </select>
<select id="countBizFinishedNumForDP" resultType="java.lang.Long"> <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 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 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 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 union all
select sum(num) from ( 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 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 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 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 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>
<select id="countAllBizDataInFlowingForDP" resultType="java.lang.Long"> <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 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 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 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 union all
select sum(num) from ( 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 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 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 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 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> </select>
</mapper> </mapper>
package com.yeejoin.amos.boot.module.jg.biz.service.impl; package com.yeejoin.amos.boot.module.jg.biz.service.impl;
import cn.hutool.core.date.DateUtil; 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.dto.CountDto;
import com.yeejoin.amos.boot.biz.common.utils.RedisUtils; 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.DPFilterParamDto;
...@@ -9,11 +8,14 @@ import com.yeejoin.amos.boot.module.common.api.dto.LegendDataDto; ...@@ -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.EquipBizCountDto;
import com.yeejoin.amos.boot.module.jg.api.dto.FourColorCountDataDto; 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.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.CommonMapper;
import com.yeejoin.amos.boot.module.jg.api.mapper.JgEnableDisableMapper; 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.JgScrapCancelMapper;
import com.yeejoin.amos.boot.module.jg.api.mapper.JgUseRegistrationMapper; 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.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.EquipTechParamPipelineMapper;
import com.yeejoin.amos.boot.module.ymt.api.mapper.EquipmentCategoryMapper; import com.yeejoin.amos.boot.module.ymt.api.mapper.EquipmentCategoryMapper;
import com.yeejoin.amos.boot.module.ymt.api.mapper.TzBaseEnterpriseInfoMapper; import com.yeejoin.amos.boot.module.ymt.api.mapper.TzBaseEnterpriseInfoMapper;
...@@ -35,7 +37,6 @@ import org.elasticsearch.search.aggregations.bucket.terms.Terms; ...@@ -35,7 +37,6 @@ import org.elasticsearch.search.aggregations.bucket.terms.Terms;
import org.elasticsearch.search.aggregations.bucket.terms.TermsAggregationBuilder; import org.elasticsearch.search.aggregations.bucket.terms.TermsAggregationBuilder;
import org.elasticsearch.search.builder.SearchSourceBuilder; import org.elasticsearch.search.builder.SearchSourceBuilder;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.StopWatch;
import java.io.IOException; import java.io.IOException;
import java.math.BigDecimal; import java.math.BigDecimal;
...@@ -448,92 +449,177 @@ public class DPStatisticsServiceImpl { ...@@ -448,92 +449,177 @@ public class DPStatisticsServiceImpl {
public Map<String, Object> querySafetyIndex(DPFilterParamDto dpFilterParamDto) { public Map<String, Object> querySafetyIndex(DPFilterParamDto dpFilterParamDto) {
Map<String, Object> result = new HashMap<>(); Map<String, Object> result = new HashMap<>();
result.put("riskScore", 89.2); result.put("riskScore", 12);
return result; return result;
} }
public List<FourColorCountDataDto> queryFourColorManagerSafetyData(DPFilterParamDto dpFilterParamDto) { public List<FourColorCountDataDto> queryFourColorManagerSafetyData(DPFilterParamDto dpFilterParamDto) {
String mockData = "[{\n" + this.setDefaultFilter(dpFilterParamDto);
"\t\t\"label\": \"设备\",\n" + Map<String, Map<String, CountDto>> dataMap = this.getAllDataMap(dpFilterParamDto);
"\t\t\"img\": \"/upload/tzs/dqscreen/images/设备.png\",\n" + return Arrays.stream(FourColorCountItemEnum.values()).map(e -> {
"\t\t\"children\": [{\n" + FourColorCountDataDto dataDto = new FourColorCountDataDto();
"\t\t\t\t\"label\": \"正常在用\",\n" + dataDto.setKey(e.getKey());
"\t\t\t\t\"value\": 112372,\n" + dataDto.setLabel(e.getLabel());
"\t\t\t\t\"img\": \"/upload/tzs/dqscreen/images/qrcodeFour.png\"\n" + dataDto.setChildren(this.buildFourColorItemData(dataMap.get(e.getKey())));
"\t\t\t},\n" + return dataDto;
"\t\t\t{\n" + }).collect(Collectors.toList());
"\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" + private List<FourColorCountDataDto> buildFourColorItemData(Map<String, CountDto> colorCountDataMap) {
"\t\t\t},\n" + return Arrays.stream(FourColorEnum.values()).filter(e -> colorCountDataMap.get(e.getCode()) != null).map(c -> {
"\t\t\t{\n" + FourColorCountDataDto dataDto = new FourColorCountDataDto();
"\t\t\t\t\"label\": \"临期告警\",\n" + dataDto.setKey(c.getCode());
"\t\t\t\t\"value\": 72,\n" + dataDto.setValue(colorCountDataMap.get(c.getCode()).getLongValue());
"\t\t\t\t\"img\": \"/upload/tzs/dqscreen/images/qrcodeTwo.png\"\n" + dataDto.setLabel(colorCountDataMap.get(c.getCode()).getLabel());
"\t\t\t},\n" + return dataDto;
"\t\t\t{\n" + }).collect(Collectors.toList());
"\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" + private Map<String, Map<String, CountDto>> getAllDataMap(DPFilterParamDto dpFilterParamDto) {
"\t\t\t}\n" + Map<String, Map<String, CountDto>> countMap = new HashMap<>();
"\t\t]\n" + countMap.put(FourColorCountItemEnum.EQUIP.getKey(), this.countEquipNum(dpFilterParamDto));
"\t},\n" + countMap.put(FourColorCountItemEnum.COMPANY.getKey(), this.countCompanyNum(dpFilterParamDto));
"\t{\n" + countMap.put(FourColorCountItemEnum.USER.getKey(), this.countUserNum(dpFilterParamDto));
"\t\t\"label\": \"企业\",\n" + return countMap;
"\t\t\"img\": \"/upload/tzs/dqscreen/images/企业.png\",\n" + }
"\t\t\"children\": [{\n" +
"\t\t\t\t\"label\": \"正常在业\",\n" + private Map<String, CountDto> countEquipNum(DPFilterParamDto dpFilterParamDto) {
"\t\t\t\t\"value\": 72,\n" + Map<String, CountDto> countMap = new HashMap<>();
"\t\t\t\t\"img\": \"/upload/tzs/dqscreen/images/qrcodeFour.png\"\n" + countMap.put(FourColorEnum.GREEN.getCode(), this.getGreenStatusEquip(dpFilterParamDto));
"\t\t\t},\n" + countMap.put(FourColorEnum.RED.getCode(), this.getRedStatusEquip(dpFilterParamDto));
"\t\t\t{\n" + countMap.put(FourColorEnum.YELLOW.getCode(), this.getYellowStatusEquip(dpFilterParamDto));
"\t\t\t\t\"label\": \"超期未检\",\n" + countMap.put(FourColorEnum.GREY.getCode(), this.getGreyStatusEquip(dpFilterParamDto));
"\t\t\t\t\"value\": 72,\n" + return countMap;
"\t\t\t\t\"img\": \"/upload/tzs/dqscreen/images/qrcodeThree.png\"\n" + }
"\t\t\t},\n" +
"\t\t\t{\n" + private CountDto getGreenStatusEquip(DPFilterParamDto dpFilterParamDto) {
"\t\t\t\t\"label\": \"临期告警\",\n" + CountDto countDto = new CountDto();
"\t\t\t\t\"value\": 72,\n" + countDto.setLongValue(this.countEquipNumFromES(dpFilterParamDto, EquimentEnum.ZAIYONG.getCode()));
"\t\t\t\t\"img\": \"/upload/tzs/dqscreen/images/qrcodeTwo.png\"\n" + countDto.setLabel("正常在用");
"\t\t\t},\n" + return countDto;
"\t\t\t{\n" + }
"\t\t\t\t\"label\": \"停业\",\n" +
"\t\t\t\t\"value\": 72,\n" + private long countEquipNumFromES(DPFilterParamDto dpFilterParamDto, Integer... states) {
"\t\t\t\t\"img\": \"/upload/tzs/dqscreen/images/qrcodeOne.png\"\n" + long num;
"\t\t\t}\n" + CountRequest request = new CountRequest();
"\t\t]\n" + request.indices("idx_biz_view_jg_all");
"\t},\n" + BoolQueryBuilder boolMust = QueryBuilders.boolQuery();
"\t{\n" + // 区域信息模糊查询
"\t\t\"label\": \"人员\",\n" + boolMust.must(QueryBuilders.wildcardQuery("USE_PLACE_CODE", "*" + dpFilterParamDto.getCityCode() + "*"));
"\t\t\"img\": \"/upload/tzs/dqscreen/images/人员.png\",\n" + // 设备状态过滤
"\t\t\"children\": [{\n" + boolMust.must(QueryBuilders.termsQuery("EQU_STATE", states));
"\t\t\t\t\"label\": \"许可正常\",\n" + request.query(boolMust);
"\t\t\t\t\"value\": 72,\n" + try {
"\t\t\t\t\"img\": \"/upload/tzs/dqscreen/images/qrcodeFour.png\"\n" + CountResponse response = restHighLevelClient.count(request, RequestOptions.DEFAULT);
"\t\t\t},\n" + num = response.getCount();
"\t\t\t{\n" + } catch (IOException e) {
"\t\t\t\t\"label\": \"许可超期\",\n" + throw new RuntimeException(e);
"\t\t\t\t\"value\": 72,\n" + }
"\t\t\t\t\"img\": \"/upload/tzs/dqscreen/images/qrcodeThree.png\"\n" + return num;
"\t\t\t},\n" + }
"\t\t\t{\n" +
"\t\t\t\t\"label\": \"许可临期\",\n" + private CountDto getRedStatusEquip(DPFilterParamDto dpFilterParamDto) {
"\t\t\t\t\"value\": 72,\n" + // TODO 需求不明确
"\t\t\t\t\"img\": \"/upload/tzs/dqscreen/images/qrcodeTwo.png\"\n" + CountDto countDto = new CountDto();
"\t\t\t}\n" + countDto.setLongValue(0L);
"\t\t]\n" + countDto.setLabel("超期未检");
"\t}\n" + return countDto;
"]"; }
return JSONArray.parseArray(mockData, FourColorCountDataDto.class);
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) { public Map<String, Object> queryBizCycleData(DPFilterParamDto dpFilterParamDto) {
Map<String, Object> result = new HashMap<>(); 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); this.setDefaultFilter(dpFilterParamDto);
result.put("xdata", Arrays.asList("安装告知", "监督检验", "使用登记", "定期检验", "变更登记", "注销报废")); result.put("xdata", Arrays.asList("安装告知", "监督检验", "使用登记", "定期检验", "变更登记", "注销报废"));
List<Long> ydata = this.countBizFinishedNum(dpFilterParamDto); List<Long> ydata = this.countBizFinishedNum(dpFilterParamDto);
...@@ -541,15 +627,9 @@ public class DPStatisticsServiceImpl { ...@@ -541,15 +627,9 @@ public class DPStatisticsServiceImpl {
result.put("ydata", ydata); result.put("ydata", ydata);
result.put("allCount", allFinishedCount); result.put("allCount", allFinishedCount);
result.put("completionRate", this.calPercentForBizCycleData(dpFilterParamDto, allFinishedCount)); result.put("completionRate", this.calPercentForBizCycleData(dpFilterParamDto, allFinishedCount));
redisUtils.set(redisKey, result, 20 * 60);
}
return result; return result;
} }
private String buildRedisKey(String prefix, String cityCode) {
return String.format("%s:%s", prefix, cityCode);
}
private String calPercentForBizCycleData(DPFilterParamDto dpFilterParamDto, Long allFinishedCount) { private String calPercentForBizCycleData(DPFilterParamDto dpFilterParamDto, Long allFinishedCount) {
Long allBizDataInFlowingCount = this.countAllBizDataInFlowing(dpFilterParamDto); Long allBizDataInFlowingCount = this.countAllBizDataInFlowing(dpFilterParamDto);
BigDecimal finish = new BigDecimal(String.valueOf(allFinishedCount)); BigDecimal finish = new BigDecimal(String.valueOf(allFinishedCount));
...@@ -561,11 +641,7 @@ public class DPStatisticsServiceImpl { ...@@ -561,11 +641,7 @@ public class DPStatisticsServiceImpl {
private Long countAllBizDataInFlowing(DPFilterParamDto dpFilterParamDto) { private Long countAllBizDataInFlowing(DPFilterParamDto dpFilterParamDto) {
String orgCode = getAndSetOrgCode(dpFilterParamDto.getCityCode()); String orgCode = getAndSetOrgCode(dpFilterParamDto.getCityCode());
StopWatch watch1 = new StopWatch();
watch1.start();
List<Long> inFlowingForDP = commonMapper.countAllBizDataInFlowingForDP(orgCode, dpFilterParamDto); List<Long> inFlowingForDP = commonMapper.countAllBizDataInFlowingForDP(orgCode, dpFilterParamDto);
watch1.stop();
log.info("cx2---->{}", watch1.getTotalTimeSeconds());
return inFlowingForDP.stream().mapToLong(e -> e).sum(); return inFlowingForDP.stream().mapToLong(e -> e).sum();
} }
......
...@@ -70,5 +70,12 @@ public interface TzBaseEnterpriseInfoMapper extends BaseMapper<TzBaseEnterpriseI ...@@ -70,5 +70,12 @@ public interface TzBaseEnterpriseInfoMapper extends BaseMapper<TzBaseEnterpriseI
List<CountDto> countByUnitTypeAndOrgCodeNoParam(); List<CountDto> countByUnitTypeAndOrgCodeNoParam();
/**
* 按照状态统计
*
* @param orgCode 公司的orgCode
* @param operatingStatus 营业状态
* @return Long 统计数量
*/
Long countByOperatingStatusAndOrgCode(@Param("orgCode") String orgCode, @Param("operatingStatus") String operatingStatus);
} }
...@@ -215,4 +215,13 @@ ...@@ -215,4 +215,13 @@
"tz_base_enterprise_info" a "tz_base_enterprise_info" a
group by a.unit_type,a.supervise_org_code group by a.unit_type,a.supervise_org_code
</select> </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> </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