2025-04-23 13:40:42 +08:00
|
|
|
|
<?xml version="1.0" encoding="UTF-8"?>
|
|
|
|
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
|
|
|
|
<mapper namespace="com.yfd.platform.modules.patroltask.mapper.AlarmLogMapper">
|
|
|
|
|
|
|
|
|
|
<!--静默监视查询-->
|
|
|
|
|
<select id="getAlarmListByType" resultType="java.util.Map">
|
|
|
|
|
SELECT
|
|
|
|
|
area_id,sp.patroldevice_name,sp.area_name,sp.place,a.*
|
|
|
|
|
FROM
|
|
|
|
|
(
|
|
|
|
|
SELECT
|
|
|
|
|
patroldevice_code,
|
|
|
|
|
monitor_type,
|
|
|
|
|
COUNT(*) count,
|
|
|
|
|
MAX(alarm_date) alarmDate
|
|
|
|
|
FROM
|
|
|
|
|
iis_alarm_log
|
|
|
|
|
WHERE
|
|
|
|
|
task_alarm_type = '2'
|
|
|
|
|
AND station_id = #{stationId}
|
|
|
|
|
<if test="areaId != null and areaId != ''">
|
|
|
|
|
AND area_id = #{areaId}
|
|
|
|
|
</if>
|
|
|
|
|
<if test="patrolDeviceName != null and patrolDeviceName != ''">
|
|
|
|
|
AND patroldevice_name LIKE concat('%',#{patrolDeviceName},'%')
|
|
|
|
|
</if>
|
|
|
|
|
<if test="monitorType != null and monitorType != ''">
|
|
|
|
|
AND monitor_type = #{monitorType}
|
|
|
|
|
</if>
|
|
|
|
|
GROUP BY
|
|
|
|
|
monitor_type,
|
|
|
|
|
patroldevice_code) a
|
|
|
|
|
LEFT JOIN iis_substation_patroldevice sp ON a.patroldevice_code= sp.patroldevice_code
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
<!--根据设备编号查询告警列表-->
|
|
|
|
|
<select id="getAlarmListPage" resultType="java.util.Map">
|
|
|
|
|
SELECT
|
|
|
|
|
patroldevice_code,
|
|
|
|
|
content,
|
|
|
|
|
alarm_date,
|
|
|
|
|
defect_file_path
|
|
|
|
|
FROM
|
|
|
|
|
iis_alarm_log
|
|
|
|
|
WHERE
|
|
|
|
|
task_alarm_type = '2'
|
|
|
|
|
<if test="patrolDeviceCode != null and patrolDeviceCode != ''">
|
|
|
|
|
AND patroldevice_code = #{patrolDeviceCode}
|
|
|
|
|
</if>
|
|
|
|
|
<if test="monitorType != null and monitorType != ''">
|
|
|
|
|
AND monitor_type = #{monitorType}
|
|
|
|
|
</if>
|
|
|
|
|
<if test="startDate != null and startDate != ''">
|
|
|
|
|
and str_to_date(alarm_date, '%Y-%m-%d %H:%i:%s') >= #{startDate}
|
|
|
|
|
</if>
|
|
|
|
|
<if test="endDate != null and endDate != ''">
|
|
|
|
|
and str_to_date(alarm_date, '%Y-%m-%d %H:%i:%s') <= #{endDate}
|
|
|
|
|
</if>
|
|
|
|
|
ORDER By alarm_date DESC
|
|
|
|
|
</select>
|
2025-04-28 08:51:12 +08:00
|
|
|
|
<select id="getConfirmationRate" resultType="java.util.Map">
|
|
|
|
|
SELECT
|
|
|
|
|
COUNT(*) AS total_alarms, -- 总告警数量
|
|
|
|
|
SUM(check_result = 1) AS confirmed_count, -- 属实的数量(check_result=1)
|
|
|
|
|
ROUND(
|
|
|
|
|
SUM(check_result = 1) / COUNT(*) * 100, -- 计算比率(分子/分母*100)
|
|
|
|
|
3
|
|
|
|
|
) AS confirmation_rate,-- 比率保留2位小数
|
|
|
|
|
'%' AS unit
|
|
|
|
|
FROM
|
|
|
|
|
iis_alarm_log
|
|
|
|
|
WHERE 1=1
|
|
|
|
|
<if test="stationId != null and stationId != ''">
|
|
|
|
|
AND station_id = #{stationId}
|
|
|
|
|
</if>
|
|
|
|
|
</select>
|
2025-05-06 09:46:18 +08:00
|
|
|
|
<select id="getAlarmLogList" resultType="java.util.Map">
|
|
|
|
|
SELECT
|
2025-05-08 08:47:27 +08:00
|
|
|
|
*
|
|
|
|
|
FROM
|
|
|
|
|
(
|
|
|
|
|
(
|
|
|
|
|
SELECT
|
|
|
|
|
record_id AS id,
|
|
|
|
|
station_id,
|
|
|
|
|
'01' system_type,
|
|
|
|
|
alarm_message AS content,
|
|
|
|
|
CASE
|
|
|
|
|
WHEN alarm_level = 1 THEN
|
|
|
|
|
2
|
|
|
|
|
WHEN alarm_level = 2 THEN
|
|
|
|
|
3
|
|
|
|
|
WHEN alarm_level = 3 THEN
|
|
|
|
|
4 ELSE alarm_level
|
|
|
|
|
END AS alarm_level,
|
|
|
|
|
alarm_time AS alarm_date
|
|
|
|
|
FROM
|
|
|
|
|
`fk_device_alarm_record`
|
|
|
|
|
) UNION ALL
|
|
|
|
|
( SELECT id, station_id,'02' system_type, content, alarm_level alarm_level, alarm_date FROM iis_alarm_log )
|
|
|
|
|
) AS combined_data
|
|
|
|
|
WHERE
|
|
|
|
|
station_id = #{stationId}
|
|
|
|
|
ORDER BY
|
|
|
|
|
alarm_date DESC;
|
|
|
|
|
</select>
|
|
|
|
|
<select id="getAlarmLogById" resultType="java.util.Map">
|
2025-05-06 09:46:18 +08:00
|
|
|
|
SELECT
|
2025-05-08 08:47:27 +08:00
|
|
|
|
'02' systemType,
|
|
|
|
|
al.*,
|
|
|
|
|
tr.patroldevice_code deviceId,
|
|
|
|
|
tr.patroldevice_channelcode channelId,
|
|
|
|
|
tr.patroldevice_pos patroldevicePos
|
|
|
|
|
FROM
|
|
|
|
|
iis_alarm_log al
|
|
|
|
|
INNER JOIN iis_task_result tr ON al.task_result_id = tr.result_id
|
|
|
|
|
WHERE
|
|
|
|
|
al.id = #{id}
|
2025-05-06 09:46:18 +08:00
|
|
|
|
</select>
|
2025-04-23 13:40:42 +08:00
|
|
|
|
</mapper>
|