(ei.equipment_index_key = 'FHS_FirePoolDevice_WaterLevel' 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), '--') 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(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,
...
...
@@ -5361,6 +5365,7 @@
r.sequence_nbr) union all
(
SELECT
a.id,
a.`name`,
a.equipmentSpecificId,
a.minLevel,
...
...
@@ -5378,6 +5383,7 @@
FROM
(
SELECT
r.sequence_nbr AS id,
r.`name`,
wes.id as equipmentSpecificId,
IFNULL( rp.min_water_level, 0 ) AS minLevel,
...
...
@@ -5388,16 +5394,14 @@
from
wl_equipment_specific_index ei
where
(ei.equipment_index_key = 'FHS_FirePoolDevice_WaterLevel' 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) AS nowLevel,
(select
ei.unit
from
wl_equipment_specific_index ei
where
(ei.equipment_index_key = 'FHS_FirePoolDevice_WaterLevel' 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,
...
...
@@ -5424,8 +5428,133 @@
r.sequence_nbr
) a
)) b
GROUP BY bizOrgName
) c
LEFT JOIN (SELECT SUM(c1.csl) AS totalCsl, (CASE WHEN SUM(c1.csl) <![CDATA[<]]> 4000 THEN '1' ELSE '0' END) AS eligibility, c1.bizOrgName AS bizOrgName1 FROM (
select
*,
(
CASE
WHEN nowLevel IS NOT NULL
AND maxLevel IS NOT NULL
AND nowLevel - maxLevel > 0 THEN
'1'
WHEN nowLevel IS NOT NULL
AND minLevel IS NOT NULL
AND nowLevel != '--'
AND nowLevel - minLevel >= 0 THEN
'0'
WHEN nowLevel IS NOT NULL
AND minLevel IS NOT NULL AND nowLevel != '--'
AND minLevel - nowLevel > 0 THEN
'1' ELSE '0'
END
) AS `status`,
IFNULL(nowLevel/maxlevel, 0) * volume AS csl
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,
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
a1.id,
a1.`name`,
a1.equipmentSpecificId,
a1.minLevel,
a1.maxLevel,
a1.outputFlowRate,
IFNULL( a1.nowLevel, '--' ) nowLevel,
a1.`unit`,
a1.volume,
a1.image,
a1.resource_type,
a1.sequence_nbr,
a1.code,
a1.pumpDeviceId,
a1.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
(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
) a1
)) b1
) c1 GROUP BY bizOrgName1) d ON d.bizOrgName1 = c.bizOrgName GROUP BY d.bizOrgName1