|
@@ -0,0 +1,254 @@
|
|
|
|
|
+<?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.ruoyi.ems.mapper.OpAlarmMapper">
|
|
|
|
|
+
|
|
|
|
|
+ <resultMap type="com.ruoyi.ems.domain.OpAlarm" id="AdmOpAlarmResult">
|
|
|
|
|
+ <result property="id" column="id"/>
|
|
|
|
|
+ <result property="areaCode" column="area_code"/>
|
|
|
|
|
+ <result property="areaName" column="area_name"/>
|
|
|
|
|
+ <result property="areaShortName" column="area_short_name"/>
|
|
|
|
|
+ <result property="objType" column="obj_type"/>
|
|
|
|
|
+ <result property="objCode" column="obj_code"/>
|
|
|
|
|
+ <result property="alarmDate" column="alarm_date"/>
|
|
|
|
|
+ <result property="alarmTime" column="alarm_time"/>
|
|
|
|
|
+ <result property="alarmCode" column="alarm_code"/>
|
|
|
|
|
+ <result property="subSystemName" column="sub_system_name"/>
|
|
|
|
|
+ <result property="systemCode" column="system_code"/>
|
|
|
|
|
+ <result property="objName" column="obj_name"/>
|
|
|
|
|
+ <result property="alarmMsg" column="alarm_msg"/>
|
|
|
|
|
+ <result property="alarmType" column="alarm_type"/>
|
|
|
|
|
+ <result property="alarmState" column="alarm_state"/>
|
|
|
|
|
+ </resultMap>
|
|
|
|
|
+
|
|
|
|
|
+ <sql id="selectOpAlarmVo">
|
|
|
|
|
+ select
|
|
|
|
|
+ id, area_code, obj_type, obj_code, alarm_date, alarm_time, alarm_code, alarm_msg, alarm_type, alarm_state, obj_name, system_code
|
|
|
|
|
+ from
|
|
|
|
|
+ adm_op_alarm alarm
|
|
|
|
|
+ </sql>
|
|
|
|
|
+
|
|
|
|
|
+ <select id="selectAdmOpAlarmList" parameterType="com.ruoyi.ems.domain.OpAlarm" resultMap="AdmOpAlarmResult">
|
|
|
|
|
+ select
|
|
|
|
|
+ alarm.id, alarm.area_code, a.area_name, a.short_name as area_short_name, alarm.obj_type, alarm.obj_code, alarm.alarm_date, alarm.alarm_time, alarm.alarm_code, alarm.alarm_msg, alarm.alarm_type, alarm.alarm_state, alarm.obj_name, sub.system_name sub_system_name, alarm.system_code
|
|
|
|
|
+ from
|
|
|
|
|
+ adm_op_alarm alarm
|
|
|
|
|
+ left join adm_ems_subsystem sub on sub.system_code = alarm.system_code
|
|
|
|
|
+ left join adm_area a on alarm.area_code = a.area_code
|
|
|
|
|
+ <where>
|
|
|
|
|
+ <if test="areaCode != null and areaCode != '' and areaCode != '-1'">and alarm.area_code = #{areaCode}</if>
|
|
|
|
|
+ <if test="objType != null ">and alarm.obj_type = #{objType}</if>
|
|
|
|
|
+ <if test="objCode != null and objCode != ''">and alarm.obj_code = #{objCode}</if>
|
|
|
|
|
+ <if test="alarmCode != null and alarmCode != ''">and alarm.alarm_code = #{alarmCode}</if>
|
|
|
|
|
+ <if test="objName !=null and objName!=''">and alarm.obj_name like concat('%', #{objName}, '%')</if>
|
|
|
|
|
+ <if test="systemCode !=null and systemCode != ''">and alarm.system_code = #{systemCode}</if>
|
|
|
|
|
+ <if test="alarmMsg != null and alarmMsg != ''">and alarm.alarm_msg like concat('%', #{alarmMsg}, '%')</if>
|
|
|
|
|
+ <if test="alarmType != null ">and alarm.alarm_type = #{alarmType}</if>
|
|
|
|
|
+ <if test="alarmState != null ">and alarm.alarm_state = #{alarmState}</if>
|
|
|
|
|
+ <if test="startRecTime != null and startRecTime != '' and endRecTime != null and endRecTime !=''">
|
|
|
|
|
+ and alarm.alarm_time >= #{startRecTime} and alarm.alarm_time <= #{endRecTime}
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <if test="alarmStateList != null and alarmStateList.size() > 0">
|
|
|
|
|
+ and alarm.alarm_state in
|
|
|
|
|
+ <foreach collection="alarmStateList" item="alarmState" open="(" close=")" separator=",">
|
|
|
|
|
+ #{alarmState}
|
|
|
|
|
+ </foreach>
|
|
|
|
|
+ </if>
|
|
|
|
|
+ </where>
|
|
|
|
|
+ order by alarm.alarm_time desc
|
|
|
|
|
+ </select>
|
|
|
|
|
+
|
|
|
|
|
+ <select id="selectAdmOpAlarmById" parameterType="Long" resultMap="AdmOpAlarmResult">
|
|
|
|
|
+ <include refid="selectOpAlarmVo"/>
|
|
|
|
|
+ where alarm.id = #{id}
|
|
|
|
|
+ </select>
|
|
|
|
|
+
|
|
|
|
|
+ <insert id="insertAdmOpAlarm" parameterType="com.ruoyi.ems.domain.OpAlarm" useGeneratedKeys="true"
|
|
|
|
|
+ keyProperty="id">
|
|
|
|
|
+ insert into adm_op_alarm
|
|
|
|
|
+ <trim prefix="(" suffix=")" suffixOverrides=",">
|
|
|
|
|
+ <if test="areaCode != null and areaCode != ''">area_code,</if>
|
|
|
|
|
+ <if test="objType != null">obj_type,</if>
|
|
|
|
|
+ <if test="objCode != null and objCode != ''">obj_code,</if>
|
|
|
|
|
+ <if test="objName != null and objName!=''">obj_name,</if>
|
|
|
|
|
+ <if test="alarmDate != null">alarm_date,</if>
|
|
|
|
|
+ <if test="alarmTime != null">alarm_time,</if>
|
|
|
|
|
+ <if test="systemCode !=null">system_code,</if>
|
|
|
|
|
+ <if test="alarmCode != null">alarm_code,</if>
|
|
|
|
|
+ <if test="alarmMsg != null">alarm_msg,</if>
|
|
|
|
|
+ <if test="alarmType != null">alarm_type,</if>
|
|
|
|
|
+ <if test="alarmState != null">alarm_state,</if>
|
|
|
|
|
+ </trim>
|
|
|
|
|
+ <trim prefix="values (" suffix=")" suffixOverrides=",">
|
|
|
|
|
+ <if test="areaCode != null and areaCode != ''">#{areaCode},</if>
|
|
|
|
|
+ <if test="objType != null">#{objType},</if>
|
|
|
|
|
+ <if test="objCode != null and objCode != ''">#{objCode},</if>
|
|
|
|
|
+ <if test="objName != null and objName!=''">#{objName},</if>
|
|
|
|
|
+ <if test="alarmDate != null">#{alarmDate},</if>
|
|
|
|
|
+ <if test="alarmTime != null">#{alarmTime},</if>
|
|
|
|
|
+ <if test="systemCode !=null">#{systemCode},</if>
|
|
|
|
|
+ <if test="alarmCode != null">#{alarmCode},</if>
|
|
|
|
|
+ <if test="alarmMsg != null">#{alarmMsg},</if>
|
|
|
|
|
+ <if test="alarmType != null">#{alarmType},</if>
|
|
|
|
|
+ <if test="alarmState != null">#{alarmState},</if>
|
|
|
|
|
+ </trim>
|
|
|
|
|
+ </insert>
|
|
|
|
|
+
|
|
|
|
|
+ <update id="updateAdmOpAlarm" parameterType="com.ruoyi.ems.domain.OpAlarm">
|
|
|
|
|
+ update adm_op_alarm
|
|
|
|
|
+ <trim prefix="SET" suffixOverrides=",">
|
|
|
|
|
+ <if test="areaCode != null and areaCode != ''">area_code = #{areaCode},</if>
|
|
|
|
|
+ <if test="objType != null">obj_type = #{objType},</if>
|
|
|
|
|
+ <if test="objCode != null and objCode != ''">obj_code = #{objCode},</if>
|
|
|
|
|
+ <if test="objName != null and objName!=''">obj_name = #{objName},</if>
|
|
|
|
|
+ <if test="alarmDate != null">alarm_date = #{alarmDate},</if>
|
|
|
|
|
+ <if test="alarmTime != null">alarm_time = #{alarmTime},</if>
|
|
|
|
|
+ <if test="alarmCode != null">alarm_code = #{alarmCode},</if>
|
|
|
|
|
+ <if test="systemCode !=null">system_code = #{systemCode},</if>
|
|
|
|
|
+ <if test="alarmMsg != null">alarm_msg = #{alarmMsg},</if>
|
|
|
|
|
+ <if test="alarmType != null">alarm_type = #{alarmType},</if>
|
|
|
|
|
+ <if test="alarmState != null">alarm_state = #{alarmState},</if>
|
|
|
|
|
+ </trim>
|
|
|
|
|
+ where id = #{id}
|
|
|
|
|
+ </update>
|
|
|
|
|
+
|
|
|
|
|
+ <delete id="deleteAdmOpAlarmById" parameterType="Long">
|
|
|
|
|
+ delete
|
|
|
|
|
+ from adm_op_alarm
|
|
|
|
|
+ where id = #{id}
|
|
|
|
|
+ </delete>
|
|
|
|
|
+
|
|
|
|
|
+ <delete id="deleteAdmOpAlarmByIds" parameterType="String">
|
|
|
|
|
+ delete from adm_op_alarm where id in
|
|
|
|
|
+ <foreach item="id" collection="array" open="(" separator="," close=")">
|
|
|
|
|
+ #{id}
|
|
|
|
|
+ </foreach>
|
|
|
|
|
+ </delete>
|
|
|
|
|
+
|
|
|
|
|
+ <select id="qryAlarmTypeIndex" resultType="java.util.Map">
|
|
|
|
|
+ SELECT count(*) cnt,
|
|
|
|
|
+ alarm_type alarmType
|
|
|
|
|
+ FROM adm_op_alarm
|
|
|
|
|
+ <where>
|
|
|
|
|
+ <if test="areaCode != null and areaCode != '' and areaCode !='-1'">and area_code = #{areaCode}</if>
|
|
|
|
|
+ <if test="startTime != null and startTime != '' and endTime != null and endTime !=''">
|
|
|
|
|
+ and alarm_time >= #{startTime} and alarm_time <= #{endTime}
|
|
|
|
|
+ </if>
|
|
|
|
|
+ </where>
|
|
|
|
|
+ GROUP BY alarm_type
|
|
|
|
|
+ </select>
|
|
|
|
|
+
|
|
|
|
|
+ <select id="qryAlarmTypeIndexByDate" parameterType="OpAlarm" resultType="java.util.Map">
|
|
|
|
|
+ SELECT count(*) cnt,
|
|
|
|
|
+ alarm_type alarmType
|
|
|
|
|
+ FROM adm_op_alarm
|
|
|
|
|
+ <where>
|
|
|
|
|
+ <if test="areaCode != null and areaCode != '' and areaCode !='-1'">and area_code = #{areaCode}</if>
|
|
|
|
|
+ <if test="startRecTime != null and startRecTime != ''">
|
|
|
|
|
+ and alarm_date like CONCAT(#{startRecTime},'%')
|
|
|
|
|
+ </if>
|
|
|
|
|
+ </where>
|
|
|
|
|
+ GROUP BY alarm_type
|
|
|
|
|
+ </select>
|
|
|
|
|
+
|
|
|
|
|
+ <select id="qryAlarmTypeIndexDay" resultType="java.util.Map">
|
|
|
|
|
+ SELECT count(*) cnt,
|
|
|
|
|
+ alarm_type alarmType,
|
|
|
|
|
+ DATE_FORMAT(alarm_time, '%H:00') dateIndex
|
|
|
|
|
+ FROM adm_op_alarm
|
|
|
|
|
+ <where>
|
|
|
|
|
+ <if test="areaCode != null and areaCode != '' and areaCode !='-1'">and area_code = #{areaCode}</if>
|
|
|
|
|
+ <if test="alarmDate != null and alarmDate != ''">and alarm_date = #{alarmDate}</if>
|
|
|
|
|
+ </where>
|
|
|
|
|
+ GROUP BY DATE_FORMAT(alarm_time, '%H:00'), alarm_type
|
|
|
|
|
+ ORDER BY alarm_type, dateIndex
|
|
|
|
|
+ </select>
|
|
|
|
|
+
|
|
|
|
|
+ <select id="qryAlarmTypeIndexMonth" resultType="java.util.Map">
|
|
|
|
|
+ SELECT count(*) cnt,
|
|
|
|
|
+ alarm_type alarmType,
|
|
|
|
|
+ DATE_FORMAT(alarm_date, '%Y-%m-%d') AS dateIndex
|
|
|
|
|
+ FROM adm_op_alarm
|
|
|
|
|
+ <where>
|
|
|
|
|
+ <if test="areaCode != null and areaCode != '' and areaCode !='-1'">and area_code = #{areaCode}</if>
|
|
|
|
|
+ <if test="alarmDate != null and alarmDate != ''">and alarm_date >= #{alarmDate}</if>
|
|
|
|
|
+ </where>
|
|
|
|
|
+ GROUP BY alarm_type, alarm_date
|
|
|
|
|
+ ORDER BY alarm_type, dateIndex
|
|
|
|
|
+ </select>
|
|
|
|
|
+
|
|
|
|
|
+ <select id="qryAlarmTypeIndexYear" resultType="java.util.Map">
|
|
|
|
|
+ SELECT count(*) cnt,
|
|
|
|
|
+ alarm_type alarmType,
|
|
|
|
|
+ DATE_FORMAT(alarm_date, '%Y-%m') AS dateIndex
|
|
|
|
|
+ FROM adm_op_alarm
|
|
|
|
|
+ <where>
|
|
|
|
|
+ <if test="areaCode != null and areaCode != '' and areaCode !='-1'">and area_code = #{areaCode}</if>
|
|
|
|
|
+ <if test="alarmDate != null and alarmDate != ''">and alarm_date >= #{alarmDate}</if>
|
|
|
|
|
+ </where>
|
|
|
|
|
+ GROUP BY alarm_type, DATE_FORMAT(alarm_date, '%Y-%m')
|
|
|
|
|
+ ORDER BY alarm_type, dateIndex
|
|
|
|
|
+ </select>
|
|
|
|
|
+
|
|
|
|
|
+ <select id="qrySubSysIndexDay" resultType="java.util.Map">
|
|
|
|
|
+ SELECT count(*) cnt,
|
|
|
|
|
+ alarm.system_code systemCode,
|
|
|
|
|
+ sub.system_name systemName,
|
|
|
|
|
+ DATE_FORMAT(alarm_time, '%H:00') dateIndex
|
|
|
|
|
+ FROM adm_op_alarm alarm
|
|
|
|
|
+ left join adm_ems_subsystem sub
|
|
|
|
|
+ on alarm.system_code = sub.system_code
|
|
|
|
|
+ <where>
|
|
|
|
|
+ <if test="areaCode != null and areaCode != '' and areaCode !='-1'">and area_code = #{areaCode}</if>
|
|
|
|
|
+ <if test="alarmDate != null and alarmDate != ''">and alarm_date = #{alarmDate}</if>
|
|
|
|
|
+ </where>
|
|
|
|
|
+ GROUP BY DATE_FORMAT(alarm_time, '%H:00'), alarm.system_code
|
|
|
|
|
+ ORDER BY alarm.system_code, dateIndex
|
|
|
|
|
+ </select>
|
|
|
|
|
+
|
|
|
|
|
+ <select id="qrySubSysIndexMonth" resultType="java.util.Map">
|
|
|
|
|
+ SELECT count(*) cnt,
|
|
|
|
|
+ alarm.system_code systemCode,
|
|
|
|
|
+ sub.system_name systemName,
|
|
|
|
|
+ DATE_FORMAT(alarm_date, '%Y-%m-%d') AS dateIndex
|
|
|
|
|
+ FROM adm_op_alarm alarm
|
|
|
|
|
+ left join adm_ems_subsystem sub
|
|
|
|
|
+ on alarm.system_code = sub.system_code
|
|
|
|
|
+ <where>
|
|
|
|
|
+ <if test="areaCode != null and areaCode != '' and areaCode !='-1'">and area_code = #{areaCode}</if>
|
|
|
|
|
+ <if test="alarmDate != null and alarmDate != ''">and alarm_date >= #{alarmDate}</if>
|
|
|
|
|
+ </where>
|
|
|
|
|
+ GROUP BY alarm.system_code, alarm_date
|
|
|
|
|
+ ORDER BY alarm.system_code, dateIndex
|
|
|
|
|
+ </select>
|
|
|
|
|
+
|
|
|
|
|
+ <select id="qrySubSysIndexYear" resultType="java.util.Map">
|
|
|
|
|
+ SELECT count(*) cnt,
|
|
|
|
|
+ alarm.system_code systemCode,
|
|
|
|
|
+ sub.system_name systemName,
|
|
|
|
|
+ DATE_FORMAT(alarm_date, '%Y-%m') AS dateIndex
|
|
|
|
|
+ FROM adm_op_alarm alarm
|
|
|
|
|
+ left join adm_ems_subsystem sub
|
|
|
|
|
+ on alarm.system_code = sub.system_code
|
|
|
|
|
+ <where>
|
|
|
|
|
+ <if test="areaCode != null and areaCode != '' and areaCode !='-1'">and area_code = #{areaCode}</if>
|
|
|
|
|
+ <if test="alarmDate != null and alarmDate != ''">and alarm_date >= #{alarmDate}</if>
|
|
|
|
|
+ </where>
|
|
|
|
|
+ GROUP BY alarm.system_code,
|
|
|
|
|
+ DATE_FORMAT(alarm_date, '%Y-%m')
|
|
|
|
|
+ ORDER BY alarm.system_code,
|
|
|
|
|
+ dateIndex
|
|
|
|
|
+ </select>
|
|
|
|
|
+ <select id="cntHandledAlarmByDate" parameterType="OpAlarm" resultType="java.util.Map">
|
|
|
|
|
+ SELECT
|
|
|
|
|
+ count(id) cnt,
|
|
|
|
|
+ sum( CASE WHEN aoa.alarm_state = 1 THEN 1 ELSE 0 END) handledCnt
|
|
|
|
|
+ from
|
|
|
|
|
+ adm_op_alarm aoa
|
|
|
|
|
+ <where>
|
|
|
|
|
+ <if test="areaCode != null and areaCode != '' and areaCode !='-1'">and area_code = #{areaCode}</if>
|
|
|
|
|
+ <if test="startRecTime != null and startRecTime != ''">and aoa.alarm_date like CONCAT(#{startRecTime}, '%')</if>
|
|
|
|
|
+ </where>
|
|
|
|
|
+ </select>
|
|
|
|
|
+</mapper>
|