Commit 205c60a0 authored by litengwei's avatar litengwei

告警列表优化

parent 52f1b74a
...@@ -7172,25 +7172,17 @@ ...@@ -7172,25 +7172,17 @@
</select> </select>
<select id="getCenterEquipState" resultType="Map"> <select id="getCenterEquipState" resultType="Map">
SELECT WITH t1 as (
SUM(IF(d.VALUE > 0, 1, 0)) AS alarmNum, SELECT ff.id,ff.name,system_type_code as code from f_fire_fighting_system ff
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
WHERE WHERE
fs.system_type_code IS NOT NULL ff.system_type_code IS NOT NULL AND LENGTH(TRIM(ff.system_type_code)) != 0
AND LENGTH(TRIM( fs.system_type_code )) != 0 <if test="bizOrgCode!=null and bizOrgCode!=''">
<if test="bizOrgCode!=null and bizOrgCode!=''"> AND ff.biz_org_code LIKE CONCAT(#{bizOrgCode},'%')
AND fs.biz_org_code LIKE CONCAT(#{bizOrgCode},'%') </if>
</if> ), t2 as (
) d 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>
<select id="getSystemTypesNumStats" resultType="Map"> <select id="getSystemTypesNumStats" resultType="Map">
...@@ -7200,7 +7192,7 @@ ...@@ -7200,7 +7192,7 @@
ff.system_type_code IS NOT NULL AND LENGTH(TRIM(ff.system_type_code)) != 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 AND wec.name IS NOT NULL AND LENGTH(TRIM(wec.name)) != 0
<if test="bizOrgCode != null and bizOrgCode != ''"> <if test="bizOrgCode != null and bizOrgCode != ''">
AND t1.biz_org_code LIKE CONCAT(#{bizOrgCode},'%') AND ff.biz_org_code LIKE CONCAT(#{bizOrgCode},'%')
</if> </if>
), t2 as ( ), 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 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 @@ ...@@ -7209,38 +7201,26 @@
</select> </select>
<select id="getSystemInfoPage" resultType="Map"> <select id="getSystemInfoPage" resultType="Map">
SELECT WITH t1 as (
d.id, SELECT ff.id,ff.name,system_type_code as code, ff.biz_org_name bizOrgName from f_fire_fighting_system ff
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
WHERE WHERE
fs.system_type_code IS NOT NULL ff.system_type_code IS NOT NULL AND LENGTH(TRIM(ff.system_type_code)) != 0
AND LENGTH(TRIM(fs.system_type_code)) != 0 <if test="bizOrgCode!=null and bizOrgCode!=''">
<if test="bizOrgCode!=null and bizOrgCode!=''"> AND ff.biz_org_code LIKE CONCAT(#{bizOrgCode},'%')
AND fs.biz_org_code LIKE CONCAT(#{bizOrgCode},'%') </if>
</if> <if test="systemType!=null and systemType!=''">
<if test="systemType!=null and systemType!=''"> AND ff.system_type_code LIKE CONCAT(#{systemType},'%')
AND fs.system_type_code LIKE CONCAT(#{systemType},'%') </if>
</if> ), t2 as (
) d 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> <where>
<if test="systemState == 'normal'"> <if test="systemState == 'normal'">
AND d.value = 0 AND t2.value is null
</if> </if>
<if test="systemState == 'abnormal'"> <if test="systemState == 'abnormal'">
AND d.value <![CDATA[>]]> 0 AND t2.value <![CDATA[>]]> 0
</if> </if>
</where> </where>
ORDER BY ORDER BY
...@@ -7255,7 +7235,7 @@ ...@@ -7255,7 +7235,7 @@
</choose> </choose>
</if> </if>
<if test="sortField == null or sortField == ''"> <if test="sortField == null or sortField == ''">
d.value DESC t2.value DESC
</if> </if>
</select> </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