IFNULL( rp.output_flow_rate, 0 ) AS outputFlowRate,
IFNULL((select
avg(IFNULL(ei.`value`, 0))
from
wl_equipment_specific_index ei
where
(ei.equipment_index_key = 'FHS_FirePoolDevice_WaterLevel' or ei.equipment_index_key = 'FHS_WirelessliquidDetector_WaterLevel')
AND FIND_IN_SET( ei.equipment_specific_id, rp.level_device_id) > 0), '--') AS nowLevel,
IFNULL(CASE WHEN (ei.equipment_index_key = 'FHS_FirePoolDevice_WaterLevel' or ei.equipment_index_key = 'FHS_WirelessliquidDetector_WaterLevel') THEN ei.`unit` END,'--') AS 'unit',
IFNULL( rp.volume, 0 ) AS volume,
ec.image,
r.resource_type,
r.sequence_nbr,
wes.code,
ifnull(rp.pump_device_id, '') as pumpDeviceId,
r.biz_org_name AS bizOrgName
FROM
cb_water_resource r
LEFT JOIN cb_water_resource_pool rp ON rp.resource_id = r.sequence_nbr
LEFT JOIN wl_equipment_specific_index ei ON ei.equipment_specific_id = rp.level_device_id
LEFT JOIN wl_equipment_category ec ON ec.id = r.equip_category_id
LEFT JOIN f_fire_fighting_system fs ON fs.id = r.belong_fighting_system_id
LEFT JOIN wl_equipment_specific wes ON wes.id = rp.level_device_id
WHERE
r.resource_type = 'industryPool'
AND r.is_delete = 1
AND r.`biz_org_code` IS NOT NULL
<iftest="bizOrgCode!=null and bizOrgCode!=''">
AND r.biz_org_code like concat(#{bizOrgCode}, '%')
</if>
GROUP BY
r.sequence_nbr) union all
(
SELECT
a.id,
a.`name`,
a.equipmentSpecificId,
a.minLevel,
a.maxLevel,
a.outputFlowRate,
IFNULL( a.nowLevel, '--' ) nowLevel,
a.`unit`,
a.volume,
a.image,
a.resource_type,
a.sequence_nbr,
a.code,
a.pumpDeviceId,
a.bizOrgName
FROM
(
SELECT
r.sequence_nbr AS id,
r.`name`,
wes.id as equipmentSpecificId,
IFNULL( rp.min_water_level, 0 ) AS minLevel,
IFNULL( rp.max_water_level, 0 ) AS maxLevel,
IFNULL( rp.output_flow_rate, 0 ) AS outputFlowRate,
(select
avg(IFNULL(ei.`value`,0))
from
wl_equipment_specific_index ei
where
(ei.equipment_index_key = 'FHS_FirePoolDevice_WaterLevel' or ei.equipment_index_key = 'FHS_WirelessliquidDetector_WaterLevel')
and FIND_IN_SET( ei.equipment_specific_id, rp.level_device_id) > 0) AS nowLevel,
(select
ei.unit
from
wl_equipment_specific_index ei
where
-- or ei.equipment_index_key = 'FHS_WirelessliquidDetector_WaterLevel' 此处由于单位会出现多个,所以无法确定选择哪一个,所以此处默认用一个指标的单位进行单位换算
(ei.equipment_index_key = 'FHS_FirePoolDevice_WaterLevel' or ei.equipment_index_key = 'FHS_WirelessliquidDetector_WaterLevel')
and FIND_IN_SET( ei.equipment_specific_id, rp.level_device_id) > 0 limit 1) AS 'unit',
IFNULL( rp.volume, 0 ) AS volume,
ec.image,
r.resource_type,
r.sequence_nbr,
rp.level_device_id,
wes.code,
ifnull(rp.pump_device_id, '') as pumpDeviceId,
r.biz_org_name AS bizOrgName
FROM
cb_water_resource r
LEFT JOIN cb_water_resource_pool rp ON rp.resource_id = r.sequence_nbr
LEFT JOIN wl_equipment_category ec ON ec.id = r.equip_category_id
LEFT JOIN f_fire_fighting_system fs ON fs.id = r.belong_fighting_system_id
LEFT JOIN wl_equipment_specific wes ON wes.id = rp.level_device_id
WHERE
r.resource_type = 'pool'
AND r.is_delete = 1
AND r.`biz_org_code` IS NOT NULL
<iftest="bizOrgCode!=null and bizOrgCode!=''">
AND r.biz_org_code like concat(#{bizOrgCode}, '%')
</if>
GROUP BY
r.sequence_nbr
) a
)) b
<iftest="stationOrder!=null and stationOrder!=''">
ORDER BY CONVERT(bizOrgName USING gbk) ASC
</if>
<iftest="stationOrder = null OR stationOrder =''">
IFNULL( rp.output_flow_rate, 0 ) AS outputFlowRate,
IFNULL((select
avg(IFNULL(ei.`value`, 0))
from
wl_equipment_specific_index ei
where
(ei.equipment_index_key = 'FHS_FirePoolDevice_WaterLevel' or ei.equipment_index_key = 'FHS_WirelessliquidDetector_WaterLevel')
AND FIND_IN_SET( ei.equipment_specific_id, rp.level_device_id) > 0), '--') AS nowLevel,
IFNULL(CASE WHEN (ei.equipment_index_key = 'FHS_FirePoolDevice_WaterLevel' or ei.equipment_index_key = 'FHS_WirelessliquidDetector_WaterLevel') THEN ei.`unit` END,'--') AS 'unit',
IFNULL( rp.volume, 0 ) AS volume,
ec.image,
r.resource_type,
r.sequence_nbr,
wes.code,
ifnull(rp.pump_device_id, '') as pumpDeviceId,
r.biz_org_name AS bizOrgName
FROM
cb_water_resource r
LEFT JOIN cb_water_resource_pool rp ON rp.resource_id = r.sequence_nbr
LEFT JOIN wl_equipment_specific_index ei ON ei.equipment_specific_id = rp.level_device_id
LEFT JOIN wl_equipment_category ec ON ec.id = r.equip_category_id
LEFT JOIN f_fire_fighting_system fs ON fs.id = r.belong_fighting_system_id
LEFT JOIN wl_equipment_specific wes ON wes.id = rp.level_device_id
WHERE
r.resource_type = 'industryPool'
AND r.is_delete = 1
AND r.`biz_org_code` IS NOT NULL
<iftest="bizOrgCode!=null and bizOrgCode!=''">
AND r.biz_org_code like concat(#{bizOrgCode}, '%')
</if>
GROUP BY
r.sequence_nbr) union all
(
SELECT
a.`name`,
a.equipmentSpecificId,
a.minLevel,
a.maxLevel,
a.outputFlowRate,
IFNULL( a.nowLevel, '--' ) nowLevel,
a.`unit`,
a.volume,
a.image,
a.resource_type,
a.sequence_nbr,
a.code,
a.pumpDeviceId,
a.bizOrgName
FROM
(
SELECT
r.`name`,
wes.id as equipmentSpecificId,
IFNULL( rp.min_water_level, 0 ) AS minLevel,
IFNULL( rp.max_water_level, 0 ) AS maxLevel,
IFNULL( rp.output_flow_rate, 0 ) AS outputFlowRate,
(select
avg(IFNULL(ei.`value`,0))
from
wl_equipment_specific_index ei
where
(ei.equipment_index_key = 'FHS_FirePoolDevice_WaterLevel' or ei.equipment_index_key = 'FHS_WirelessliquidDetector_WaterLevel')
and FIND_IN_SET( ei.equipment_specific_id, rp.level_device_id) > 0) AS nowLevel,
(select
ei.unit
from
wl_equipment_specific_index ei
where
-- or ei.equipment_index_key = 'FHS_WirelessliquidDetector_WaterLevel' 此处由于单位会出现多个,所以无法确定选择哪一个,所以此处默认用一个指标的单位进行单位换算
(ei.equipment_index_key = 'FHS_FirePoolDevice_WaterLevel' or ei.equipment_index_key = 'FHS_WirelessliquidDetector_WaterLevel')
and FIND_IN_SET( ei.equipment_specific_id, rp.level_device_id) > 0 limit 1) AS 'unit',
IFNULL( rp.volume, 0 ) AS volume,
ec.image,
r.resource_type,
r.sequence_nbr,
rp.level_device_id,
wes.code,
ifnull(rp.pump_device_id, '') as pumpDeviceId,
r.biz_org_name AS bizOrgName
FROM
cb_water_resource r
LEFT JOIN cb_water_resource_pool rp ON rp.resource_id = r.sequence_nbr
LEFT JOIN wl_equipment_category ec ON ec.id = r.equip_category_id
LEFT JOIN f_fire_fighting_system fs ON fs.id = r.belong_fighting_system_id
LEFT JOIN wl_equipment_specific wes ON wes.id = rp.level_device_id
WHERE
r.resource_type = 'pool'
AND r.is_delete = 1
AND r.`biz_org_code` IS NOT NULL
<iftest="bizOrgCode!=null and bizOrgCode!=''">
AND r.biz_org_code like concat(#{bizOrgCode}, '%')
( SELECT count( 1 ) FROM `wl_equipment_specific_alarm_log` WHERE 0 <![CDATA[<>]]> find_in_set( `fs`.`id`, `wl_equipment_specific_alarm_log`.`system_ids` ) ) AS `value`
FROM
`f_fire_fighting_system` `fs`
WHERE
fs.system_type_code IS NOT NULL
AND LENGTH(
trim( fs.system_type_code )) != 0
<iftest="bizOrgCode!=null and bizOrgCode!=''">
AND fs.biz_org_code LIKE CONCAT(#{bizOrgCode},'%')
</if>
) d
WHERE d.value != 0
GROUP BY d.system_type_code
</select>
<selectid="getSystemInfoPage"resultType="Map">
SELECT
d.id,
d.`name`,
IF( d.VALUE > 0, '异常', '正常') AS sysState,
d.bizOrgName,
d.value AS `value`,
d.equips
FROM
(
SELECT
`fs`.`id` AS `id`,
`fs`.`name` AS `name`,
fs.system_type_code,
fs.biz_org_name AS bizOrgName,
( SELECT count( 1 ) FROM `wl_equipment_specific_alarm_log` WHERE 0 <![CDATA[<>]]> find_in_set( `fs`.`id`, `wl_equipment_specific_alarm_log`.`system_ids` ) ) AS `value`,
(SELECT COUNT(DISTINCT wesal.equipment_specific_id) FROM wl_equipment_specific_alarm_log wesal WHERE 0 <![CDATA[<>]]> find_in_set(`fs`.`id`, wesal.`system_ids`)) AS equips
FROM
`f_fire_fighting_system` `fs`
WHERE
fs.system_type_code IS NOT NULL
AND LENGTH(
trim( fs.system_type_code )) != 0
<iftest="bizOrgCode!=null and bizOrgCode!=''">
AND fs.biz_org_code LIKE CONCAT(#{bizOrgCode},'%')
</if>
<iftest="systemType!=null and systemType!=''">
AND fs.system_type_code LIKE CONCAT(#{systemType},'%')
</if>
) d
<where>
<iftest="systemState!=null and systemState!='' and systemState ='1'">
d.value <![CDATA[>]]> 0
</if>
<iftest="systemState!=null and systemState!='' and systemState ='1'">
d.value <![CDATA[<]]> 0
</if>
</where>
<iftest="stateOrder!=null and stateOrder!='' and stateOrder=1">
ORDER BY d.value DESC,
</if>
<iftest="stateOrder!=null and stateOrder!='' and stateOrder=0">
ORDER BY d.value ASC,
</if>
<iftest="alarmEquips!=null and alarmEquips!='' and alarmEquips=1">
d.equips DESC
</if>
<iftest="alarmEquips!=null and alarmEquips!='' and alarmEquips=0">
d.equips ASC
</if>
</select>
<selectid="getIotInfo"resultType="Map">
SELECT
*
FROM
(
(SELECT count( DISTINCT wei.name_key ) FROM wl_equipment_index wei WHERE wei.is_iot = 1) AS indexNum,
(SELECT count( 1 ) FROM wl_equipment_specific es LEFT JOIN wl_equipment e ON e.`code` = es.equipment_code WHERE e.is_iot = 1
<iftest="bizOrgCode!=null and bizOrgCode!=''">
AND es.biz_org_code LIKE CONCAT(#{bizOrgCode},'%')
</if>
) AS equipNum,
(SELECT count(1) AS indexMonitorNum FROM wl_equipment_specific_index wesi LEFT JOIN wl_equipment_specific wes on wesi.equipment_specific_id = wes.id WHERE DATE_FORMAT(wesi.update_date, '%Y-%m-%d') = DATE_FORMAT(NOW(), '%Y-%m-%d')
<iftest="bizOrgCode!=null and bizOrgCode!=''">
AND wes.biz_org_code LIKE CONCAT(#{bizOrgCode},'%')