IFNULL((SELECT sum(s.alarm_times) from asf_fire_alarm_day_statistics s where s.collect_date = CURRENT_DATE and s.station_code = i.`code`),0) as todayAlarmTimes,
IFNULL((SELECT count(1) from asf_fire_latent_danger d where d.deal_state = 1 and d.station_code = i.`code`),0) as existDangerNumber
i.*,
IFNULL((SELECT sum(s.report_times) from asf_fire_signal_day_statistics s where s.collect_date = CURRENT_DATE and
s.station_code = i.`code`),0) as todayAlarmTimes,
IFNULL((SELECT count(1) from asf_fire_latent_danger d where d.deal_state = 1 and d.station_code = i.`code`),0)
(select count(1) from ast_fire_equipment e where e.station_code = si.code and e.is_iot = true) as iotEquipmentNumber,
(select count(DISTINCT(1)) from asf_fire_equipment_signal_log l where l.station_code = si.code and l.alarm_date =CURRENT_DATE and l.is_alarm = true) as todayAlarmEquipmentNumber
si.id,
si.code,
si.`name`,
(select count(1) from ast_fire_equipment e where e.station_code = si.code and e.is_iot = true) as
iotEquipmentNumber,
(select count(DISTINCT(1)) from asf_fire_equipment_signal_log l where l.station_code = si.code and
l.signal_report_date =CURRENT_DATE and l.is_alarm = true) as todayAlarmEquipmentNumber
FROM `asf_fire_station_info` si
<where>
<iftest="stationCode != null and stationCode != ''">
si.code = #{stationCode}
</if>
<iftest="stationName != null and stationName != ''">