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) < 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 ) < 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}