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}
and #{endDate}
and #{endDate}
and alert_id in (SELECT sequence_nbr from tz_alert_called where alarm_type_code = '960' and call_time between #{startDate} and #{endDate})
and alert_id in (SELECT sequence_nbr from tz_alert_called where alarm_type_code = '960' and call_time between #{startDate} and #{endDate} and father_alert is null)
(select count(1) from tz_alert_called where alarm_type_code = '961' and call_time between #{startDate} and #{endDate}) as faultNum,
(select count(1) from tz_alert_called where alarm_type_code = '961' and call_time between #{startDate} and #{endDate} and father_alert is null) as faultNum,
(select count(1) from tz_alert_called where alarm_type_code = '960' and call_time between #{startDate} and #{endDate} ) as trappedNum
(select count(1) from tz_alert_called where alarm_type_code = '960' and call_time between #{startDate} and #{endDate} and father_alert is null ) as trappedNum
LEFT JOIN idx_biz_jg_use_info t2 ON t1.equipment_id = t2.RECORD WHERE t2.USE_PLACE = #{placeCode} and t1.alarm_type_code = '960' and t1.call_time between #{startDate} and #{endDate}) as trappedNum,
LEFT JOIN idx_biz_jg_use_info t2 ON t1.equipment_id = t2.RECORD WHERE t2.USE_PLACE = #{placeCode} and t1.alarm_type_code = '960' and t1.call_time between #{startDate} and #{endDate} and father_alert is null) as trappedNum,
(SELECT count(1) FROM
(SELECT count(1) FROM
tz_alert_called t1
tz_alert_called t1
LEFT JOIN idx_biz_jg_use_info t2 ON t1.equipment_id = t2.RECORD WHERE t2.USE_PLACE = #{placeCode} and t1.alarm_type_code = '961' and t1.call_time between #{startDate} and #{endDate}) as faultNum
LEFT JOIN idx_biz_jg_use_info t2 ON t1.equipment_id = t2.RECORD WHERE t2.USE_PLACE = #{placeCode} and t1.alarm_type_code = '961' and t1.call_time between #{startDate} and #{endDate} and father_alert is null) as faultNum
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 father_alert is null)
and org_type_code = 'levelOneUnit') as levelOne,
and org_type_code = 'levelOneUnit') as levelOne,
(select count(1)
(select count(1)
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 father_alert is null)
and org_type_code = 'levelTwoUnit') as levelTwo,
and org_type_code = 'levelTwoUnit') as levelTwo,
(select count(1)
(select count(1)
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 father_alert is null)
and org_type_code = '953') as levelThree,
and org_type_code = '953') as levelThree,
(select count(DISTINCT (response_org_id))
(select count(DISTINCT (response_org_id))
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 father_alert is null)
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} and father_alert is null
) 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} 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.biz_org_code like concat('50', '%') and t1.alarm_type_code = '960' and t1.call_time BETWEEN #{startDate} and #{endDate} and t1.father_alert is null
( SELECT * FROM tz_cylinder_filling_record WHERE is_not_es IS NULL AND filling_before_id IS NOT NULL
( SELECT * FROM tz_cylinder_filling_record WHERE is_not_es IS NULL AND filling_before_id IS NOT NULL
AND filling_check_id IS NOT NULL and LENGTH(filling_startTime) >= 10 LIMIT 5000 ) r
AND filling_check_id IS NOT NULL and LENGTH(filling_startTime) >= 10
and app_id in (SELECT app_id from tz_cylinder_unit) LIMIT 5000 ) r
LEFT JOIN tz_cylinder_filling b ON b.filling_before_id = r.filling_before_id
LEFT JOIN tz_cylinder_filling b ON b.filling_before_id = r.filling_before_id
AND r.filling_before_id IS NOT NULL and b.inspection_date NOT LIKE'16%'
AND r.filling_before_id IS NOT NULL and b.inspection_date NOT LIKE'16%'
AND date_format ( b.inspection_date, '%Y-%m-%d' ) = date_format ( r.filling_startTime, '%Y-%m-%d' ) and b.sequence_code is not null AND b.app_id is not null
AND date_format ( b.inspection_date, '%Y-%m-%d' ) = date_format ( r.filling_startTime, '%Y-%m-%d' ) and b.sequence_code is not null AND b.app_id is not null