178 lines
6.4 KiB
XML
178 lines
6.4 KiB
XML
<?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>
|
||
<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>
|
||
<select id="getAlarmLogList" resultType="java.util.Map">
|
||
SELECT
|
||
id,
|
||
station_id,
|
||
alarm_source_type,
|
||
content,
|
||
alarm_level alarm_level,
|
||
alarm_date
|
||
FROM
|
||
iis_alarm_log
|
||
WHERE
|
||
station_id = #{stationId}
|
||
ORDER BY
|
||
alarm_date DESC;
|
||
</select>
|
||
<select id="getAlarmLogById" resultType="java.util.Map">
|
||
SELECT
|
||
al.*,
|
||
tr.patroldevice_code deviceId,
|
||
tr.patroldevice_channelcode channelId,
|
||
tr.patroldevice_pos patroldevicePos
|
||
FROM
|
||
iis_alarm_log al
|
||
LEFT JOIN iis_task_result tr ON al.task_result_id = tr.result_id
|
||
WHERE
|
||
al.id = #{id}
|
||
</select>
|
||
<select id="getNotCheckAlarmCount" resultType="com.yfd.platform.modules.patroltask.domain.AlarmLog">
|
||
SELECT
|
||
record_id AS id,
|
||
ds.main_device_id,
|
||
ds.main_component_id,
|
||
'01' system_type
|
||
FROM
|
||
`fk_device_alarm_record` dar
|
||
INNER JOIN fk_device_signal ds ON dar.signal_id = ds.signal_id
|
||
WHERE
|
||
dar.station_id = #{stationId} UNION ALL
|
||
SELECT
|
||
id,
|
||
main_device_id,
|
||
component_id,
|
||
'02' system_type
|
||
FROM
|
||
iis_alarm_log
|
||
WHERE
|
||
station_id = #{stationId}
|
||
</select>
|
||
|
||
<!-- <select id="getDeviceAlarmRecordPage"-->
|
||
<!-- resultType="com.yfd.platform.modules.auxcontrol.domain.DeviceAlarmRecord">-->
|
||
<!-- SELECT-->
|
||
<!-- dar.*,-->
|
||
<!-- sdi1.dictname AS alarmTypeName,-->
|
||
<!-- sdi2.dictname AS alarmLevelName,-->
|
||
<!-- sdi3.dictname AS alarmStatusName,-->
|
||
<!-- COALESCE (-->
|
||
<!-- (-->
|
||
<!-- SELECT-->
|
||
<!-- GROUP_CONCAT( dictname ORDER BY itemcode SEPARATOR ',' )-->
|
||
<!-- FROM-->
|
||
<!-- sys_dictionary_items-->
|
||
<!-- WHERE-->
|
||
<!-- dictid = 'd3a5c69ef214012abcdb31495ef4e772'-->
|
||
<!-- AND FIND_IN_SET( itemcode, dar.notice_action ) > 0-->
|
||
<!-- ),-->
|
||
<!-- ''-->
|
||
<!-- ) AS noticeTypeName-->
|
||
<!-- FROM-->
|
||
<!-- fk_device_alarm_record dar-->
|
||
<!-- LEFT JOIN sys_dictionary_items sdi1 ON sdi1.dictid = 'aad92e9fd54d05e090b074f3e0666c8c'-->
|
||
<!-- AND sdi1.itemcode = dar.alarm_type-->
|
||
<!-- LEFT JOIN sys_dictionary_items sdi2 ON sdi2.dictid = '138d15a0ce89e5abd516389a1176db6e'-->
|
||
<!-- AND sdi2.itemcode = dar.alarm_level-->
|
||
<!-- LEFT JOIN sys_dictionary_items sdi3 ON sdi3.dictid = '1f0eb135658ed4c825021e2d5189efc0'-->
|
||
<!-- AND sdi3.itemcode = dar.`status`-->
|
||
<!-- where 1=1-->
|
||
<!-- <if test="systemcode != null and systemcode != ''">-->
|
||
<!-- and dar.systemcode= #{systemcode}-->
|
||
<!-- </if>-->
|
||
<!-- <if test="deviceName != null and deviceName != ''">-->
|
||
<!-- and dar.device_name like concat('%',#{deviceName},'%')-->
|
||
<!-- </if>-->
|
||
<!-- <if test="signalName != null and signalName != ''">-->
|
||
<!-- and dar.signal_name like concat('%',#{signalName},'%')-->
|
||
<!-- </if>-->
|
||
<!-- <if test="alarmLevel != null and alarmLevel != ''">-->
|
||
<!-- and dar.alarm_level = #{alarmLevel}-->
|
||
<!-- </if>-->
|
||
<!-- <if test="status != null and status != ''">-->
|
||
<!-- and dar.status = #{status}-->
|
||
<!-- </if>-->
|
||
<!-- <if test="startDate != null and startDate != ''">-->
|
||
<!-- and dar.alarm_time >= #{startDate}-->
|
||
<!-- </if>-->
|
||
|
||
<!-- <if test="endDate != null and endDate != ''">-->
|
||
<!-- and dar.alarm_time <= #{endDate}-->
|
||
<!-- </if>-->
|
||
<!-- </select>-->
|
||
</mapper>
|