Commit 5450ef00 authored by lisong's avatar lisong

96333统计分析修改

parent c1e83b30
...@@ -5,7 +5,9 @@ ...@@ -5,7 +5,9 @@
<select id="getMessage" resultType="java.util.Map"> <select id="getMessage" resultType="java.util.Map">
SELECT * SELECT *
from ( from (
SELECT concat(ROUND(date_part('second', arrive_time - dispatch_time) / 60, 2), '分钟') as arriveTime, select
arrive_time as ddTime,
dispatch_time as pqTime,
( (
SELECT ME_UNIT_NAME SELECT ME_UNIT_NAME
from idx_biz_jg_maintenance_record_info from idx_biz_jg_maintenance_record_info
...@@ -15,7 +17,8 @@ ...@@ -15,7 +17,8 @@
(SELECT ORG_BRANCH_CODE (SELECT ORG_BRANCH_CODE
from idx_biz_jg_supervision_info from idx_biz_jg_supervision_info
where RECORD = (SELECT equipment_id from tz_alert_called where sequence_nbr = alert_id)) as orgCode, where RECORD = (SELECT equipment_id from tz_alert_called where sequence_nbr = alert_id)) as orgCode,
(SELECT address from tz_alert_called where sequence_nbr = alert_id) as address from tz_dispatch_task (SELECT address from tz_alert_called where sequence_nbr = alert_id) as address
from tz_dispatch_task
where org_type_code = 'levelOneUnit' where org_type_code = 'levelOneUnit'
and arrive_time is not null and arrive_time is not null
and dispatch_time between #{startDate} and dispatch_time between #{startDate}
......
...@@ -20,11 +20,31 @@ ...@@ -20,11 +20,31 @@
from tz_dispatch_task from tz_dispatch_task
where alert_id in (SELECT sequence_nbr from tz_alert_called where biz_org_code like concat(#{orgCode}, '%') and call_time BETWEEN #{startDate} and #{endDate} and alarm_type_code = '960') where alert_id in (SELECT sequence_nbr from tz_alert_called where biz_org_code like concat(#{orgCode}, '%') and call_time BETWEEN #{startDate} and #{endDate} and alarm_type_code = '960')
and org_type_code = 'levelOneUnit') as maintenanceUnit, and org_type_code = 'levelOneUnit') as maintenanceUnit,
(select count(1) ( SELECT count(1) from (
from tz_dispatch_task
where alert_id in (SELECT sequence_nbr from tz_alert_called where biz_org_code like concat(#{orgCode}, '%') and call_time BETWEEN #{startDate} and #{endDate} and alarm_type_code = '960') SELECT
and org_type_code = 'levelOneUnit' t1.sequence_nbr,
and date_part('minute', arrive_time - rec_date) &lt; 30) as lessNum, (SELECT min(arrive_time) from tz_dispatch_task where alert_id = t1.sequence_nbr and arrive_time is not null) as arr,
(SELECT sum(times) from (SELECT date_part('second', arrive_time - rec_date)as times from tz_dispatch_task where alert_id in (SELECT sequence_nbr from tz_alert_called where biz_org_code like concat(#{orgCode}, '%') and call_time BETWEEN #{startDate} and #{endDate} and alarm_type_code = '960') and org_type_code = 'levelOneUnit')) as avgNum
(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.biz_org_code like concat(#{orgCode}, '%') and t1.alarm_type_code = '960' and call_time BETWEEN #{startDate} and #{endDate}
) where extract(epoch from arr - dis ) &lt; 1800
) as lessNum,
(SELECT count(1) from tz_alert_called where biz_org_code like concat(#{orgCode}, '%') and alarm_type_code = '960' and call_time BETWEEN #{startDate} and #{endDate}) 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.biz_org_code like concat('50', '%') and t1.alarm_type_code = '960' and call_time BETWEEN #{startDate} and #{endDate}
) ) as avgNum
</select> </select>
</mapper> </mapper>
...@@ -14,7 +14,9 @@ import org.springframework.stereotype.Service; ...@@ -14,7 +14,9 @@ import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils; import org.springframework.util.ObjectUtils;
import org.typroject.tyboot.core.rdbms.service.BaseService; import org.typroject.tyboot.core.rdbms.service.BaseService;
import java.math.BigDecimal;
import java.text.DecimalFormat; import java.text.DecimalFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
...@@ -41,6 +43,7 @@ public class AlertDispatchStatisticsServiceImpl extends BaseService<AlertDispatc ...@@ -41,6 +43,7 @@ public class AlertDispatchStatisticsServiceImpl extends BaseService<AlertDispatc
@Override @Override
public void statisticalGeneration(String type) { public void statisticalGeneration(String type) {
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
SimpleDateFormat formatTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Calendar cal = Calendar.getInstance(); Calendar cal = Calendar.getInstance();
cal.setTime(new Date()); cal.setTime(new Date());
if (ObjectUtils.isEmpty(type)) { if (ObjectUtils.isEmpty(type)) {
...@@ -66,6 +69,18 @@ public class AlertDispatchStatisticsServiceImpl extends BaseService<AlertDispatc ...@@ -66,6 +69,18 @@ public class AlertDispatchStatisticsServiceImpl extends BaseService<AlertDispatc
alertDispatchStatistics.setStartDate(format.format(firstDayOfMonth)); alertDispatchStatistics.setStartDate(format.format(firstDayOfMonth));
alertDispatchStatistics.setEndDate(format.format(lastDayOfMonth)); alertDispatchStatistics.setEndDate(format.format(lastDayOfMonth));
alertDispatchStatistics.setStatisticsDate(format.format(lastDayOfMonth).substring(0, 7)); alertDispatchStatistics.setStatisticsDate(format.format(lastDayOfMonth).substring(0, 7));
if (data.containsKey("ddTime") && data.containsKey("pqTime")){
try {
Date ddTime = formatTime.parse(String.valueOf(data.get("ddTime")));
Date pqTime = formatTime.parse(String.valueOf(data.get("pqTime")));
BigDecimal bigDecimal = new BigDecimal(String.valueOf(ddTime.getTime() - pqTime.getTime()));
BigDecimal divide = bigDecimal.divide(new BigDecimal(60000), 2, BigDecimal.ROUND_HALF_UP);
alertDispatchStatistics.setArriveTime(divide+"分钟");
} catch (ParseException e) {
e.printStackTrace();
}
}
list.add(alertDispatchStatistics); list.add(alertDispatchStatistics);
}); });
} }
......
...@@ -51,14 +51,14 @@ public class AlertRescueStatisticsServiceImpl extends BaseService<AlertRescueSta ...@@ -51,14 +51,14 @@ public class AlertRescueStatisticsServiceImpl extends BaseService<AlertRescueSta
Date lastDayOfMonth = cal.getTime(); Date lastDayOfMonth = cal.getTime();
ArrayList<AlertRescueStatistics> list = new ArrayList<>(); ArrayList<AlertRescueStatistics> list = new ArrayList<>();
List<LinkedHashMap> supervisionList = alertStatisticsService.getSupervisionList(); List<LinkedHashMap> supervisionList = alertStatisticsService.getSupervisionList();
DecimalFormat decimalFormat = new DecimalFormat("0.000"); DecimalFormat decimalFormat = new DecimalFormat("0.00");
if (!ObjectUtils.isEmpty(supervisionList)) { if (!ObjectUtils.isEmpty(supervisionList)) {
supervisionList.forEach(item -> { supervisionList.forEach(item -> {
AlertRescueStatistics statisticsMessage = this.baseMapper.getStatisticsMessage(String.valueOf(item.get("orgCode")), format.format(firstDayOfMonth) + " 00:00:00", format.format(lastDayOfMonth) + " 23:59:59"); AlertRescueStatistics statisticsMessage = this.baseMapper.getStatisticsMessage(String.valueOf(item.get("orgCode")), format.format(firstDayOfMonth) + " 00:00:00", format.format(lastDayOfMonth) + " 23:59:59");
statisticsMessage.setSupervisoryUnitName(String.valueOf(item.get("companyName"))); statisticsMessage.setSupervisoryUnitName(String.valueOf(item.get("companyName")));
statisticsMessage.setSupervisoryUnitOrgCode(String.valueOf(item.get("orgCode"))); statisticsMessage.setSupervisoryUnitOrgCode(String.valueOf(item.get("orgCode")));
statisticsMessage.setSupervisoryUnitId(String.valueOf(item.get("sequenceNbr"))); statisticsMessage.setSupervisoryUnitId(String.valueOf(item.get("sequenceNbr")));
statisticsMessage.setGreaterNum(statisticsMessage.getMaintenanceUnit() - statisticsMessage.getLessNum()); statisticsMessage.setGreaterNum(statisticsMessage.getGreaterNum() - statisticsMessage.getLessNum());
if (ObjectUtils.isEmpty(statisticsMessage.getAvgNum()) || ObjectUtils.isEmpty(statisticsMessage.getMaintenanceUnit()) || statisticsMessage.getAvgNum().equals("0") || statisticsMessage.getMaintenanceUnit() == 0) { if (ObjectUtils.isEmpty(statisticsMessage.getAvgNum()) || ObjectUtils.isEmpty(statisticsMessage.getMaintenanceUnit()) || statisticsMessage.getAvgNum().equals("0") || statisticsMessage.getMaintenanceUnit() == 0) {
statisticsMessage.setAvgNum("0"); statisticsMessage.setAvgNum("0");
} else { } else {
......
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