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

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

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