Commit 3fce06af authored by tianbo's avatar tianbo

bugfix(tcm,elevator):大屏-应急统计

parent 2dca6124
......@@ -8,7 +8,6 @@ import com.yeejoin.amos.boot.biz.common.entity.BaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import java.util.Date;
/**
*
......@@ -91,6 +90,16 @@ public class AlertStatistics extends BaseEntity {
private String failureRate;
/**
* 平均救援时长(分钟)
*/
private String avgTime;
/**
* 30分钟内到达次数
*/
private Integer withinThirtyRescue;
/**
* 统计日期
*/
@TableField("statistics_date")
......
......@@ -12,5 +12,7 @@ import org.apache.ibatis.annotations.Param;
*/
public interface AlertStatisticsMapper extends BaseMapper<AlertStatistics> {
AlertStatistics getStatissticsMessage(@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);
}
<?xml version="1.0" encoding="UTF-8"?>
<!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.elevator.api.mapper.AlertStatisticsMapper">
<select id="getStatissticsMessage"
<select id="getStatisticsMessage"
resultType="com.yeejoin.amos.boot.module.elevator.api.entity.AlertStatistics">
SELECT temp.*,
CASE
......@@ -57,4 +57,46 @@
) temp
</select>
<select id="statisticsInfoByRegionAndDate" resultType="com.yeejoin.amos.boot.module.elevator.api.entity.AlertStatistics">
select t.*, ROUND((avgNum/greaterNum)/60.0,2) avgTime from (SELECT
( SELECT count(1) from (
SELECT
t1.sequence_nbr
from tz_alert_called t1 where t1.region_code like concat('%',#{regionCode}, '%') and t1.alarm_type_code = '960' and call_time BETWEEN #{startDate} and #{endDate} and father_alert is null
) as t1sn
) as trappedPeople,
( SELECT count(1) from (
SELECT
t1.sequence_nbr
from tz_alert_called t1 where t1.region_code like concat('%',#{regionCode}, '%') and t1.alarm_type_code = '961' and call_time BETWEEN #{startDate} and #{endDate} and father_alert is null
) as n
) as breakdownRescue,
( SELECT count(1) from (
SELECT
t1.sequence_nbr
from tz_alert_called t1 where t1.region_code like concat('%',#{regionCode}, '%') and t1.alarm_type_code = '962' and call_time BETWEEN #{startDate} and #{endDate} and father_alert is null
) as t1sn2
) as complaint,
(SELECT sum( field_value ) FROM tz_alert_form_value WHERE alert_called_id IN (SELECT sequence_nbr FROM tz_alert_called WHERE region_code LIKE concat ('%', #{regionCode}, '%' ) AND call_time BETWEEN #{startDate} and #{endDate} AND alarm_type_code = '960' AND father_alert IS NULL) AND field_code = 'trapped_num') as rescuedCount,
( SELECT count(1) from (
SELECT
t1.sequence_nbr,
(SELECT min(arrive_time) from tz_dispatch_task where alert_id = t1.sequence_nbr and arrive_time is not null) as arr,
(SELECT min(dispatch_time) from tz_dispatch_task where alert_id = t1.sequence_nbr and dispatch_time is not null ) as dis
from tz_alert_called t1 where t1.region_code like concat('%', #{regionCode}, '%') and t1.alarm_type_code = '960' and call_time BETWEEN #{startDate} and #{endDate} and father_alert is null
) as snad where extract(epoch from arr - dis ) > 1800
) as withinThirtyRescue,
(SELECT count(1) from tz_alert_called where region_code like concat('%', #{regionCode}, '%') and alarm_type_code = '960' and call_time BETWEEN #{startDate} and #{endDate} and father_alert is null) as greaterNum,
(
SELECT sum(extract(epoch from arr - dis )) from
( SELECT
t1.sequence_nbr,
(SELECT min(arrive_time) from tz_dispatch_task where alert_id = t1.sequence_nbr and arrive_time is not null) as arr,
(SELECT min(dispatch_time) from tz_dispatch_task where alert_id = t1.sequence_nbr and dispatch_time is not null ) as dis
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>
</mapper>
......@@ -2,6 +2,8 @@ package com.yeejoin.amos.boot.module.elevator.biz.service.impl;
import cn.hutool.core.date.DateUtil;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.yeejoin.amos.boot.biz.common.utils.RedisUtils;
......@@ -14,12 +16,15 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
import org.typroject.tyboot.core.rdbms.service.BaseService;
import java.math.BigDecimal;
import java.text.DecimalFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.*;
......@@ -54,7 +59,7 @@ public class AlertStatisticsServiceImpl extends BaseService<AlertStatisticsDto,
if (!ObjectUtils.isEmpty(supervisionList)) {
supervisionList.forEach(item -> {
if (!ObjectUtils.isEmpty(item.get("orgCode"))) {
AlertStatistics statissticsMessage = this.getBaseMapper().getStatissticsMessage(String.valueOf(item.get("orgCode")), format.format(firstDayOfMonth) + " 00:00:00", format.format(lastDayOfMonth) + " 23:59:59");
AlertStatistics statissticsMessage = this.getBaseMapper().getStatisticsMessage(String.valueOf(item.get("orgCode")), format.format(firstDayOfMonth) + " 00:00:00", format.format(lastDayOfMonth) + " 23:59:59");
statissticsMessage.setSupervisoryUnitName(String.valueOf(item.get("companyName")));
statissticsMessage.setSupervisoryUnitOrgCode(String.valueOf(item.get("orgCode")));
statissticsMessage.setSupervisoryUnitId(String.valueOf(item.get("sequenceNbr")));
......@@ -158,4 +163,54 @@ public class AlertStatisticsServiceImpl extends BaseService<AlertStatisticsDto,
alertStatistics.add(avg);
return alertStatistics;
}
@Override
public JSONArray statisticInfoByRegionAndDate(String regionCode, LocalDate startDate, LocalDate endDate) {
LocalDate today = LocalDate.now();
if (ObjectUtils.isEmpty(startDate) || ObjectUtils.isEmpty(endDate)) {
startDate = today.minusDays(6);
endDate = today;
}
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 jsonObject1 = new JSONObject();
jsonObject1.put("key", "slts");
jsonObject1.put("value", ValidationUtil.isEmpty(statistics.getComplaint()) ? 0 : statistics.getComplaint());
jsonObject1.put("name", "受理投诉");
JSONObject jsonObject2 = new JSONObject();
jsonObject2.put("key", "gzbx");
jsonObject2.put("value", ValidationUtil.isEmpty(statistics.getBreakdownRescue()) ? 0 : statistics.getBreakdownRescue());
jsonObject2.put("name", "故障维修");
JSONObject jsonObject3 = new JSONObject();
jsonObject3.put("key", "jjbkck");
jsonObject3.put("value", ValidationUtil.isEmpty(statistics.getRescuePersonnel()) ? 0 : statistics.getRescuePersonnel());
jsonObject3.put("name", "解救被困乘客");
JSONObject jsonObject4 = new JSONObject();
jsonObject4.put("key", "30fzdd");
jsonObject4.put("value", ValidationUtil.isEmpty(statistics.getWithinThirtyRescue()) ? 0 : statistics.getWithinThirtyRescue());
jsonObject4.put("name", "30分钟内到达");
JSONObject jsonObject5 = new JSONObject();
jsonObject5.put("key", "pjjysj");
jsonObject5.put("value", ValidationUtil.isEmpty(statistics.getAvgTime()) ? 0 : statistics.getAvgTime());
jsonObject5.put("name", "平均救援时间");
jsonArray.add(jsonObject);
jsonArray.add(jsonObject1);
jsonArray.add(jsonObject2);
jsonArray.add(jsonObject3);
jsonArray.add(jsonObject4);
jsonArray.add(jsonObject5);
}
return jsonArray;
}
}
\ No newline at end of file
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