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;
/**
* 业务类型枚举
......
......@@ -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