(SELECT COUNT(1) FROM wl_equipment_specific_alarm t WHERE FIND_IN_SET(fs.id, t.system_ids) AND t.status = 1) AS value
FROM
f_fire_fighting_system fs
WITH t1 as (
SELECT ff.id,ff.name,system_type_code as code from f_fire_fighting_system ff
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
ff.system_type_code IS NOT NULL AND LENGTH(TRIM(ff.system_type_code)) != 0
<iftest="bizOrgCode!=null and bizOrgCode!=''">
AND ff.biz_org_code LIKE CONCAT(#{bizOrgCode},'%')
</if>
), t2 as (
SELECT COUNT(DISTINCT t.equipment_specific_id)as value, t.system_ids FROM wl_equipment_specific_alarm t WHERE t.status = 1 GROUP BY t.system_ids
)
SELECT SUM(IF(t2.VALUE > 0, 1, 0)) AS alarmNum,(COUNT(t1.id ) - SUM(IF(t2.VALUE > 0, 1, 0))) AS normalNum,COUNT(t1.id ) AS total from t1 left join t2 on FIND_IN_SET(t1.id, t2.system_ids) > 0
ff.system_type_code IS NOT NULL AND LENGTH(TRIM(ff.system_type_code)) != 0
AND wec.name IS NOT NULL AND LENGTH(TRIM(wec.name)) != 0
<iftest="bizOrgCode != null and bizOrgCode != ''">
AND t1.biz_org_code LIKE CONCAT(#{bizOrgCode},'%')
AND ff.biz_org_code LIKE CONCAT(#{bizOrgCode},'%')
</if>
), t2 as (
SELECT COUNT(DISTINCT t.equipment_specific_id)as value, t.system_ids FROM wl_equipment_specific_alarm t WHERE t.status = 1 GROUP BY t.system_ids
...
...
@@ -7209,38 +7201,26 @@
</select>
<selectid="getSystemInfoPage"resultType="Map">
SELECT
d.id,
d.name,
IF(d.VALUE > 0, '异常', '正常') AS sysState,
d.bizOrgName,
d.value AS value
FROM
(
SELECT
fs.id AS id,
fs.name AS name,
fs.system_type_code,
fs.biz_org_name AS bizOrgName,
(SELECT COUNT(DISTINCT t.equipment_specific_id) FROM wl_equipment_specific_alarm t WHERE FIND_IN_SET(fs.id, t.system_ids) > 0 AND t.status = 1) AS value
FROM
f_fire_fighting_system fs
WITH t1 as (
SELECT ff.id,ff.name,system_type_code as code, ff.biz_org_name bizOrgName from f_fire_fighting_system ff
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
ff.system_type_code IS NOT NULL AND LENGTH(TRIM(ff.system_type_code)) != 0
<iftest="bizOrgCode!=null and bizOrgCode!=''">
AND ff.biz_org_code LIKE CONCAT(#{bizOrgCode},'%')
</if>
<iftest="systemType!=null and systemType!=''">
AND ff.system_type_code LIKE CONCAT(#{systemType},'%')
</if>
), t2 as (
SELECT COUNT(DISTINCT t.equipment_specific_id)as value, t.system_ids FROM wl_equipment_specific_alarm t WHERE t.status = 1 GROUP BY t.system_ids
)
SELECT t1.*,IF(t2.VALUE > 0, '异常', '正常') AS sysState,IF(t2.value IS NULL, 0, t2.value ) value from t1 left join t2 on FIND_IN_SET(t1.id, t2.system_ids) > 0