|
@@ -0,0 +1,183 @@
|
|
|
+<?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.huaxu.dao.AlarmDetailMapper">
|
|
|
+
|
|
|
+ <sql id="Base_Column_List">
|
|
|
+ a.ID as "id"
|
|
|
+ ,a.TENANT_ID as "tenantId"
|
|
|
+ ,a.DEVICE_ID as "deviceId"
|
|
|
+ ,a.COMPANY_ORG_ID as "companyOrgId"
|
|
|
+ ,a.DEPT_ORG_ID as "deptOrgId"
|
|
|
+ ,a.ALARM_TYPE as "alarmType"
|
|
|
+ ,a.ATTRIBUTE_ID as "attributeId"
|
|
|
+ ,a.ALARM_VALUE as "alarmValue"
|
|
|
+ ,a.ALARM_CONTENT as "alarmContent"
|
|
|
+ ,a.ALARM_START_TIME as "alarmStartTime"
|
|
|
+ ,a.ALARM_END_TIME as "alarmEndTime"
|
|
|
+ ,a.STATE as "state"
|
|
|
+ ,a.OP_STATE as "opState"
|
|
|
+ ,a.REMARK as "remark"
|
|
|
+ ,a.STATUS as "status"
|
|
|
+ ,a.DATE_CREATE as "dateCreate"
|
|
|
+ ,a.CREATE_BY as "createBy"
|
|
|
+ ,a.DATE_UPDATE as "dateUpdate"
|
|
|
+ ,a.UPDATE_BY as "updateBy"
|
|
|
+
|
|
|
+ ,s.SCENE_NAME as "sceneName"
|
|
|
+ ,d.DEVICE_NAME as "deviceName"
|
|
|
+ ,t.DEVICE_TYPE as "devcieType"
|
|
|
+ ,d.ADDRESS as "address"
|
|
|
+ ,d.POINT_X as "pointX"
|
|
|
+ ,d.POINT_Y as "pointY"
|
|
|
+ </sql>
|
|
|
+
|
|
|
+ <sql id="alarmDetailJoins">
|
|
|
+ left join sms_device d on a.DEVICE_ID =d.id and d.`STATUS` = 1
|
|
|
+ left join sms_scene s on d.SCENE_ID =s.id and s.`STATUS` =1
|
|
|
+ left join sms_device_type t on d.DEVICE_TYPE_ID =t.ID
|
|
|
+ </sql>
|
|
|
+ <select id="selectById" resultType="com.huaxu.dto.AlarmDetailsDto">
|
|
|
+ select
|
|
|
+ <include refid="Base_Column_List"/>
|
|
|
+ from sms_alarm_details a
|
|
|
+ <include refid="alarmDetailJoins"/>
|
|
|
+ where a.`STATUS` = 1
|
|
|
+ and a.id=#{id}
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <!--通过实体作为筛选条件查询-->
|
|
|
+ <select id="selectList" resultType="com.huaxu.dto.AlarmDetailsDto">
|
|
|
+ select
|
|
|
+ <include refid="Base_Column_List"/>
|
|
|
+ from sms_alarm_details a
|
|
|
+ <include refid="alarmDetailJoins"/>
|
|
|
+ where a.`STATUS` = 1
|
|
|
+ <if test="alarmDetailsDto.condition != null and alarmDetailsDto.condition != ''">
|
|
|
+ and (s.SCENE_NAME like concat('%', #{alarmDetailsDto.condition},'%') or d.DEVICE_NAME like concat('%', #{alarmDetailsDto.condition},'%') )
|
|
|
+ </if>
|
|
|
+ <if test="alarmDetailsDto.alarmType != null">
|
|
|
+ and a.ALARM_TYPE = #{alarmDetailsDto.alarmType}
|
|
|
+ </if>
|
|
|
+ <if test="alarmDetailsDto.opState != null">
|
|
|
+ and a.OP_STATE =#{alarmDetailsDto.opState}
|
|
|
+ </if>
|
|
|
+ <if test="alarmDetailsDto.startTime != null">
|
|
|
+ and a.ALARM_START_TIME >=#{alarmDetailsDto.startTime}
|
|
|
+ </if>
|
|
|
+ <if test="alarmDetailsDto.endTime != null">
|
|
|
+ and a.ALARM_START_TIME <=DATE_ADD(#{operateLogDto.endTime},INTERVAL 1 DAY)
|
|
|
+ </if>
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <!-- 新增所有列 -->
|
|
|
+ <insert id="insert" keyProperty="id" useGeneratedKeys="true">
|
|
|
+ INSERT INTO sms_alarm_details ( TENANT_ID , DEVICE_ID , COMPANY_ORG_ID , DEPT_ORG_ID , ALARM_TYPE , ATTRIBUTE_ID , ALARM_VALUE , ALARM_CONTENT , ALARM_START_TIME , ALARM_END_TIME , STATE , OP_STATE , REMARK , STATUS , DATE_CREATE , CREATE_BY , DATE_UPDATE , UPDATE_BY )
|
|
|
+ VALUES ( #{tenantId} , #{deviceId} , #{companyOrgId} , #{deptOrgId} , #{alarmType} , #{attributeId} , #{alarmValue} , #{alarmContent} , #{alarmStartTime} , #{alarmEndTime} , #{state} , #{opState} , #{remark} , #{status} , #{dateCreate} , #{createBy} , #{dateUpdate} , #{updateBy} )
|
|
|
+ </insert>
|
|
|
+
|
|
|
+ <!-- 批量新增 -->
|
|
|
+ <insert id="batchInsert">
|
|
|
+ INSERT INTO sms_alarm_details ( TENANT_ID , DEVICE_ID , COMPANY_ORG_ID , DEPT_ORG_ID , ALARM_TYPE , ATTRIBUTE_ID , ALARM_VALUE , ALARM_CONTENT , ALARM_START_TIME , ALARM_END_TIME , STATE , OP_STATE , REMARK , STATUS , DATE_CREATE , CREATE_BY , DATE_UPDATE , UPDATE_BY )
|
|
|
+ values
|
|
|
+ <foreach collection="alarmDetails" item="item" index="index" separator=",">
|
|
|
+ ( #{item.tenantId} , #{item.deviceId} , #{item.companyOrgId} , #{item.deptOrgId} , #{item.alarmType} , #{item.attributeId} , #{item.alarmValue} , #{item.alarmContent} , #{item.alarmStartTime} , #{item.alarmEndTime} , #{item.state} , #{item.opState} , #{item.remark} , #{item.status} , #{item.dateCreate} , #{item.createBy} , #{item.dateUpdate} , #{item.updateBy} )
|
|
|
+ </foreach>
|
|
|
+ </insert>
|
|
|
+
|
|
|
+ <!-- 通过主键修改数据 -->
|
|
|
+ <update id="update">
|
|
|
+ UPDATE sms_alarm_details
|
|
|
+ <set>
|
|
|
+ <if test="tenantId != null and tenantId != '' ">
|
|
|
+ TENANT_ID = #{tenantId},
|
|
|
+ </if>
|
|
|
+ <if test="deviceId != null ">
|
|
|
+ DEVICE_ID = #{deviceId},
|
|
|
+ </if>
|
|
|
+ <if test="companyOrgId != null ">
|
|
|
+ COMPANY_ORG_ID = #{companyOrgId},
|
|
|
+ </if>
|
|
|
+ <if test="deptOrgId != null ">
|
|
|
+ DEPT_ORG_ID = #{deptOrgId},
|
|
|
+ </if>
|
|
|
+ <if test="alarmType != null ">
|
|
|
+ ALARM_TYPE = #{alarmType},
|
|
|
+ </if>
|
|
|
+ <if test="attributeId != null ">
|
|
|
+ ATTRIBUTE_ID = #{attributeId},
|
|
|
+ </if>
|
|
|
+ <if test="alarmValue != null ">
|
|
|
+ ALARM_VALUE = #{alarmValue},
|
|
|
+ </if>
|
|
|
+ <if test="alarmContent != null and alarmContent != '' ">
|
|
|
+ ALARM_CONTENT = #{alarmContent},
|
|
|
+ </if>
|
|
|
+ <if test="alarmStartTime != null ">
|
|
|
+ ALARM_START_TIME = #{alarmStartTime},
|
|
|
+ </if>
|
|
|
+ <if test="alarmStartTime != null ">
|
|
|
+ ALARM_START_TIME = #{alarmStartTime},
|
|
|
+ </if>
|
|
|
+ <if test="alarmEndTime != null ">
|
|
|
+ ALARM_END_TIME = #{alarmEndTime},
|
|
|
+ </if>
|
|
|
+ <if test="state != null ">
|
|
|
+ STATE = #{state},
|
|
|
+ </if>
|
|
|
+ <if test="opState != null ">
|
|
|
+ OP_STATE = #{opState},
|
|
|
+ </if>
|
|
|
+
|
|
|
+ <if test="remark != null and remark != '' ">
|
|
|
+ REMARK = #{remark},
|
|
|
+ </if>
|
|
|
+ <if test="status != null ">
|
|
|
+ STATUS = #{status},
|
|
|
+ </if>
|
|
|
+ <if test="dateUpdate != null ">
|
|
|
+ DATE_UPDATE = #{dateUpdate},
|
|
|
+ </if>
|
|
|
+ <if test="updateBy != null and updateBy != ''">
|
|
|
+ UPDATE_BY = #{updateBy}
|
|
|
+ </if>
|
|
|
+ </set>
|
|
|
+ WHERE ID = #{id};
|
|
|
+ </update>
|
|
|
+
|
|
|
+ <!--通过主键删除-->
|
|
|
+ <delete id="deleteById">
|
|
|
+ UPDATE sms_alarm_details set STATUS = 0 where id = #{id}
|
|
|
+ </delete>
|
|
|
+
|
|
|
+ <!-- 报警挂起、恢复 -->
|
|
|
+ <delete id="suspendedById">
|
|
|
+ UPDATE sms_alarm_details set STATE = #{state} where id = #{id}
|
|
|
+ </delete>
|
|
|
+
|
|
|
+ <!-- 分页查询 -->
|
|
|
+ <select id="selectPage" resultType="com.huaxu.dto.AlarmDetailsDto">
|
|
|
+ select
|
|
|
+ <include refid="Base_Column_List"/>
|
|
|
+ from sms_alarm_details a
|
|
|
+ <include refid="alarmDetailJoins"/>
|
|
|
+ where a.`STATUS` = 1
|
|
|
+ <if test="alarmDetailsDto.condition != null and alarmDetailsDto.condition != ''">
|
|
|
+ and (s.SCENE_NAME like concat('%', #{alarmDetailsDto.condition},'%') or d.DEVICE_NAME like concat('%', #{alarmDetailsDto.condition},'%') )
|
|
|
+ </if>
|
|
|
+ <if test="alarmDetailsDto.alarmType != null">
|
|
|
+ and a.ALARM_TYPE = #{alarmDetailsDto.alarmType}
|
|
|
+ </if>
|
|
|
+ <if test="alarmDetailsDto.opState != null">
|
|
|
+ and a.OP_STATE =#{alarmDetailsDto.opState}
|
|
|
+ </if>
|
|
|
+ <if test="alarmDetailsDto.startTime != null">
|
|
|
+ and a.ALARM_START_TIME >=#{alarmDetailsDto.startTime}
|
|
|
+ </if>
|
|
|
+ <if test="alarmDetailsDto.endTime != null">
|
|
|
+ and a.ALARM_START_TIME <=DATE_ADD(#{operateLogDto.endTime},INTERVAL 1 DAY)
|
|
|
+ </if>
|
|
|
+
|
|
|
+ </select>
|
|
|
+
|
|
|
+
|
|
|
+</mapper>
|