Commit 205c60a0 authored by litengwei's avatar litengwei

告警列表优化

parent 52f1b74a
......@@ -7172,25 +7172,17 @@
</select>
<select id="getCenterEquipState" resultType="Map">
SELECT
SUM(IF(d.VALUE > 0, 1, 0)) AS alarmNum,
SUM(IF(d.VALUE = 0, 1, 0)) AS normalNum,
COUNT(d.id ) AS total
FROM
(
SELECT
fs.id AS id,
fs.name AS name,
(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
<if test="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
<if test="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
</select>
<select id="getSystemTypesNumStats" resultType="Map">
......@@ -7200,7 +7192,7 @@
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
<if test="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>
<select id="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
<if test="bizOrgCode!=null and bizOrgCode!=''">
AND fs.biz_org_code LIKE CONCAT(#{bizOrgCode},'%')
</if>
<if test="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
<if test="bizOrgCode!=null and bizOrgCode!=''">
AND ff.biz_org_code LIKE CONCAT(#{bizOrgCode},'%')
</if>
<if test="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
<where>
<if test="systemState == 'normal'">
AND d.value = 0
AND t2.value is null
</if>
<if test="systemState == 'abnormal'">
AND d.value <![CDATA[>]]> 0
AND t2.value <![CDATA[>]]> 0
</if>
</where>
ORDER BY
......@@ -7255,7 +7235,7 @@
</choose>
</if>
<if test="sortField == null or sortField == ''">
d.value DESC
t2.value DESC
</if>
</select>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment