Commit 0c2be6c1 authored by 李秀明's avatar 李秀明

系统告警部件数量统计修改

parent ee155f3b
...@@ -31,31 +31,19 @@ ...@@ -31,31 +31,19 @@
<select id="getSystemState" resultType="Map"> <select id="getSystemState" resultType="Map">
SELECT SELECT
`fs`.`id` AS `key`, fs.id AS `key`,
`fs`.`name` AS `name`, fs.name AS name,
`fs`.system_type_code AS systemTypeCode, fs.system_type_code AS systemTypeCode,
`fs`.`code` AS code, fs.code AS code,
CASE CASE
WHEN `fs`.system_run_state = '0' THEN WHEN `fs`.system_run_state = '0' THEN '停止'
'停止' WHEN `fs`.system_run_state = '1' THEN '运行'
WHEN `fs`.system_run_state = '1' THEN END AS systemRunState,
'运行' IF(((
END AS systemRunState, SELECT COUNT(t.equipment_specific_id) FROM wl_equipment_specific_alarm t WHERE(FIND_IN_SET(fs.id, t.system_ids) > 0 AND t.status = 1)) > 0
IF ), '异常', '正常') AS status
(((
SELECT
count( `wesa`.`equipment_specific_id` )
FROM
`wl_equipment_specific_alarm` `wesa`
WHERE
( 0 <![CDATA[<>]]> find_in_set( `fs`.`id`, `wesa`.`system_ids` )
AND `wesa`.`status` = 1)) > 0
),
'异常',
'正常'
) AS `status`
FROM FROM
`f_fire_fighting_system` `fs` f_fire_fighting_system fs
<where> <where>
-- 此接口要求过滤掉其他系统 -- 此接口要求过滤掉其他系统
fs.system_type_code IS NOT NULL AND LENGTH(TRIM(fs.system_type_code)) > 0 AND fs.system_type_code != 'otherSys' fs.system_type_code IS NOT NULL AND LENGTH(TRIM(fs.system_type_code)) > 0 AND fs.system_type_code != 'otherSys'
...@@ -64,9 +52,9 @@ ...@@ -64,9 +52,9 @@
</if> </if>
</where> </where>
GROUP BY GROUP BY
`fs`.`id` fs.id
ORDER BY ORDER BY
`fs`.`sort` fs.sort
</select> </select>
<select id="getSystemAlarmTheCount" resultType="java.util.Map"> <select id="getSystemAlarmTheCount" resultType="java.util.Map">
......
...@@ -7177,93 +7177,80 @@ ...@@ -7177,93 +7177,80 @@
<select id="getCenterEquipState" resultType="Map"> <select id="getCenterEquipState" resultType="Map">
SELECT SELECT
SUM( SUM(IF(d.VALUE > 0, 1, 0)) AS alarmNum,
IF SUM(IF(d.VALUE = 0, 1, 0)) AS normalNum,
( d.`value` > 0, 1, 0 )) AS alarmNum, COUNT(d.id ) AS total
SUM(
IF
( d.`value` = 0, 1, 0 )) AS normalNum,
count( d.id ) AS total
FROM FROM
( (
SELECT SELECT
`fs`.`id` AS `id`, fs.id AS id,
`fs`.`name` AS `name`, fs.name AS name,
IFNULL(sum(sa.`status`), 0) as `value` (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 FROM
`f_fire_fighting_system` `fs` f_fire_fighting_system fs
left join (select * from wl_equipment_specific_alarm where `status` = 1) sa on find_in_set( `fs`.`id`, sa.`system_ids` )
WHERE WHERE
fs.system_type_code IS NOT NULL fs.system_type_code IS NOT NULL
AND LENGTH( AND LENGTH(TRIM( fs.system_type_code )) != 0
trim( fs.system_type_code )) != 0 <if test="bizOrgCode!=null and bizOrgCode!=''">
<if test="bizOrgCode!=null and bizOrgCode!=''"> AND fs.biz_org_code LIKE CONCAT(#{bizOrgCode},'%')
AND fs.biz_org_code LIKE CONCAT(#{bizOrgCode},'%') </if>
</if>
group by fs.id
) d ) d
</select> </select>
<select id="getSystemTypesNumStats" resultType="Map"> <select id="getSystemTypesNumStats" resultType="Map">
SELECT SELECT
t1.id AS id, d.id,
t2.`name` AS `name`, d.system_type_code AS code,
t1.system_type_code as `code`, d.name,
sum( sa.`status` ) AS `num` SUM(IF(d.VALUE > 0, 1, 0)) AS num
FROM (
SELECT
t1.id AS id,
t2.name AS name,
t1.system_type_code,
(SELECT COUNT(DISTINCT t.equipment_specific_id) FROM wl_equipment_specific_alarm t WHERE FIND_IN_SET(t1.id, t.system_ids) > 0 AND t.status = 1) AS value
FROM FROM
f_fire_fighting_system t1 f_fire_fighting_system t1
LEFT JOIN wl_equipment_category t2 ON t1.system_type = t2.id LEFT JOIN wl_equipment_category t2 on t1.system_type = t2.id
LEFT JOIN ( SELECT `status`, system_ids FROM wl_equipment_specific_alarm WHERE `status` = 1 GROUP BY system_ids ) sa ON find_in_set( t1.id, sa.system_ids )
WHERE WHERE
t1.system_type_code IS NOT NULL t1.system_type_code IS NOT NULL AND LENGTH(TRIM(t1.system_type_code)) != 0
AND LENGTH( AND t2.name IS NOT NULL AND LENGTH(TRIM(t2.name)) != 0
TRIM( t1.system_type_code )) != 0 <if test="bizOrgCode != null and bizOrgCode != ''">
AND t2.`name` IS NOT NULL AND t1.biz_org_code LIKE CONCAT(#{bizOrgCode},'%')
AND LENGTH( </if>
TRIM( t2.`name` )) != 0 ) d
<if test="bizOrgCode != null and bizOrgCode != ''"> WHERE
AND t1.biz_org_code LIKE CONCAT(#{bizOrgCode},'%') d.value != 0
</if>
GROUP BY GROUP BY
t1.system_type_code d.system_type_code
HAVING
`num` IS NOT NULL
AND `num` > 0
</select> </select>
<select id="getSystemInfoPage" resultType="Map"> <select id="getSystemInfoPage" resultType="Map">
SELECT SELECT
d.id, d.id,
d.`name`, d.name,
IF( d.VALUE > 0, '异常', '正常') AS sysState, IF(d.VALUE > 0, '异常', '正常') AS sysState,
d.bizOrgName, d.bizOrgName,
d.value AS `value`, d.value AS value
d.equips
FROM FROM
( (
SELECT SELECT
`fs`.`id` AS `id`, fs.id AS id,
`fs`.`name` AS `name`, fs.name AS name,
fs.system_type_code, fs.system_type_code,
fs.biz_org_name AS bizOrgName, fs.biz_org_name AS bizOrgName,
count( t.`status` = 0 OR NULL ) AS `value`, (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
count( DISTINCT t.`equipment_specific_id` ) AS equips
FROM FROM
`f_fire_fighting_system` `fs` f_fire_fighting_system fs
LEFT JOIN ( SELECT equipment_specific_id, system_ids, max( `status` ) AS `status` FROM wl_equipment_specific_alarm GROUP BY equipment_specific_id, system_ids ) t ON find_in_set( `fs`.`id`, t.system_ids )
WHERE WHERE
fs.system_type_code IS NOT NULL fs.system_type_code IS NOT NULL
AND LENGTH( AND LENGTH(TRIM(fs.system_type_code)) != 0
trim( fs.system_type_code )) != 0 <if test="bizOrgCode!=null and bizOrgCode!=''">
<if test="bizOrgCode!=null and bizOrgCode!=''"> AND fs.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 fs.system_type_code LIKE CONCAT(#{systemType},'%')
AND fs.system_type_code LIKE CONCAT(#{systemType},'%') </if>
</if>
GROUP BY
`fs`.`id`
) d ) d
<where> <where>
<if test="systemState == 'normal'"> <if test="systemState == 'normal'">
...@@ -7274,19 +7261,19 @@ ...@@ -7274,19 +7261,19 @@
</if> </if>
</where> </where>
ORDER BY ORDER BY
<if test="sortField != null and sortField != ''"> <if test="sortField != null and sortField != ''">
<choose> <choose>
<when test="sortOrder == 'ascend'"> <when test="sortOrder == 'ascend'">
@SORT_FIELD ASC @SORT_FIELD ASC
</when> </when>
<otherwise> <otherwise>
@SORT_FIELD DESC @SORT_FIELD DESC
</otherwise> </otherwise>
</choose> </choose>
</if> </if>
<if test="sortField == null or sortField == ''"> <if test="sortField == null or sortField == ''">
d.equips DESC d.value DESC
</if> </if>
</select> </select>
<select id="getIotInfo" resultType="Map"> <select id="getIotInfo" resultType="Map">
......
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