|
@@ -0,0 +1,150 @@
|
|
|
|
+<?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.alarm.DataAlarmManageMapper">
|
|
|
|
+
|
|
|
|
+ <sql id="alarmManage_result_list" >
|
|
|
|
+ a.ID,
|
|
|
|
+ a.alarm_name,
|
|
|
|
+ a.be_scene_id,
|
|
|
|
+ a.be_device_id,
|
|
|
|
+ a.be_attribute_id,
|
|
|
|
+ a.be_address,
|
|
|
|
+ a.be_type,
|
|
|
|
+ a.compute_rules,
|
|
|
|
+ a.to_scene_id,
|
|
|
|
+ a.to_device_id,
|
|
|
|
+ a.to_attribute_id,
|
|
|
|
+ a.to_address,
|
|
|
|
+ a.to_type,
|
|
|
|
+ a.alar_rules,
|
|
|
|
+ a.alar_value
|
|
|
|
+ </sql>
|
|
|
|
+
|
|
|
|
+ <insert id="saveDataAlarmManage" useGeneratedKeys="true" keyProperty="id" parameterType="com.huaxu.entity.alarm.DataAlarmManageEntity">
|
|
|
|
+ insert sms_data_alarm_manage (alarm_name,company_org_id,dept_org_id,tenant_id,be_scene_id,be_device_id,be_attribute_id,be_type,compute_rules,
|
|
|
|
+ to_scene_id,to_device_id,to_attribute_id,to_type,alar_rules,alar_value,date_create,status)
|
|
|
|
+ values
|
|
|
|
+ (#{alarmName}, #{companyOrgId}, #{deptOrgId}, #{tenantId}, #{beSceneId},#{beDeviceId},
|
|
|
|
+ #{beAttributeId}, #{beType}, #{computeRules}, #{toSceneId},
|
|
|
|
+ #{toDeviceId}, #{toAttributeId}, #{toType}, #{alarRules},
|
|
|
|
+ #{alarValue}, #{dateCreate},#{status})
|
|
|
|
+ </insert>
|
|
|
|
+
|
|
|
|
+ <select id="findPage" resultType="com.huaxu.vo.DataAlarmManageVo">
|
|
|
|
+ select
|
|
|
|
+ m.id,m.alarm_name, t2.name as be_attribute_name,s.SCENE_NAME as be_scene_name,
|
|
|
|
+ m.compute_rules,m.alar_rules,m.alar_value,mm.to_attribute_name,mm.to_scene_name
|
|
|
|
+ from
|
|
|
|
+ sms_data_alarm_manage m
|
|
|
|
+ INNER JOIN sms_scene s on s.id = m.be_scene_id and s.status = 1
|
|
|
|
+ INNER JOIN sms_device t1 on m.be_device_id = t1.id and t1.status = 1
|
|
|
|
+ INNER JOIN sms_device_attribute t2 on m.be_attribute_id=t2.id and t2.status =1
|
|
|
|
+ LEFT JOIN (
|
|
|
|
+ select m.id, t2.name as to_attribute_name,s.SCENE_NAME as to_scene_name
|
|
|
|
+ from
|
|
|
|
+ sms_data_alarm_manage m
|
|
|
|
+ INNER JOIN sms_scene s on s.id = m.to_scene_id and s.status = 1
|
|
|
|
+ INNER JOIN sms_device t1 on m.to_device_id = t1.id and t1.status = 1
|
|
|
|
+ INNER JOIN sms_device_attribute t2 on m.to_attribute_id=t2.id and t2.status =1
|
|
|
|
+ ) mm on mm.id = m.id
|
|
|
|
+ <where>
|
|
|
|
+ <if test="dto.userType != null and dto.userType != -999 and dto.userType!=-9999 and dto.programItems != null and dto.programItems.size() > 0">
|
|
|
|
+ <if test="dto.permissonType == 5 or dto.permissonType == 2">
|
|
|
|
+ and ( a.DEPT_ORG_ID in
|
|
|
|
+ <foreach collection="dto.programItems" item="item" open="(" close=")" separator=",">
|
|
|
|
+ #{item.orgId}
|
|
|
|
+ </foreach>
|
|
|
|
+ or
|
|
|
|
+ a.COMPANY_ORG_ID in
|
|
|
|
+ <foreach collection="dto.programItems" item="item" open="(" close=")" separator=",">
|
|
|
|
+ #{item.orgId}
|
|
|
|
+ </foreach>
|
|
|
|
+ )
|
|
|
|
+ </if>
|
|
|
|
+ <if test="dto.permissonType == 4 or dto.permissonType == 3">
|
|
|
|
+ and a.DEPT_ORG_ID in
|
|
|
|
+ <foreach collection="dto.programItems" item="item" open="(" close=")" separator=",">
|
|
|
|
+ #{item.orgId}
|
|
|
|
+ </foreach>
|
|
|
|
+ </if>
|
|
|
|
+ <if test="dto.permissonType == 1">
|
|
|
|
+ and a.COMPANY_ORG_ID in
|
|
|
|
+ <foreach collection="dto.programItems" item="item" open="(" close=")" separator=",">
|
|
|
|
+ #{item.orgId}
|
|
|
|
+ </foreach>
|
|
|
|
+ and (a.DEPT_ORG_ID is null or a.DEPT_ORG_ID =0)
|
|
|
|
+ </if>
|
|
|
|
+ </if>
|
|
|
|
+ <if test="dto.alarmName != null and dto.alarmName != ''">
|
|
|
|
+ and a.alarm_name like CONCAT('%',#{dto.alarmName,jdbcType=VARCHAR},'%')
|
|
|
|
+ </if>
|
|
|
|
+ a.status = 1
|
|
|
|
+ </where>
|
|
|
|
+ order by id desc
|
|
|
|
+ </select>
|
|
|
|
+
|
|
|
|
+ <select id="findAlarmManage" resultType="com.huaxu.vo.DataAlarmManageVo">
|
|
|
|
+ select
|
|
|
|
+ <include refid="alarmManage_result_list"></include>
|
|
|
|
+ from sms_data_alarm_manage a
|
|
|
|
+ where
|
|
|
|
+ a.id = #{alarId} and a.status = 1
|
|
|
|
+ </select>
|
|
|
|
+
|
|
|
|
+ <update id="updateDataAlarmManage">
|
|
|
|
+ update sms_data_alarm_manage
|
|
|
|
+ set
|
|
|
|
+ alarm_name = #{alarmName},
|
|
|
|
+ be_scene_id =#{beSceneId},
|
|
|
|
+ be_device_id = #{beDeviceId},
|
|
|
|
+ be_attribute_id = #{beAttributeId},
|
|
|
|
+ be_address = #{beAddress},
|
|
|
|
+ be_type = #{beType},
|
|
|
|
+ compute_rules = #{beAddress},
|
|
|
|
+ to_scene_id = #{toSceneId},
|
|
|
|
+ to_device_id= #{toDeviceId},
|
|
|
|
+ to_attribute_id = #{toAttributeId},
|
|
|
|
+ to_address = #{toAddress},
|
|
|
|
+ to_type = #{toType},
|
|
|
|
+ alar_rules = #{alarRules},
|
|
|
|
+ alar_value = #{alarValue},
|
|
|
|
+ date_update = #{dateUpdate}
|
|
|
|
+ where
|
|
|
|
+ id =#{alarmId}
|
|
|
|
+ </update>
|
|
|
|
+
|
|
|
|
+ <update id="delDataAlarmManage">
|
|
|
|
+ update sms_data_alarm_manage
|
|
|
|
+ set
|
|
|
|
+ status = 0
|
|
|
|
+ where
|
|
|
|
+ id in
|
|
|
|
+ <foreach collection="alarmIds" item="alarmId" open="(" close=")" separator=",">
|
|
|
|
+ #{alarmId}
|
|
|
|
+ </foreach>
|
|
|
|
+ </update>
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ <select id="selectDeviceAttributes">
|
|
|
|
+ select t2.id attribute_id,
|
|
|
|
+ t2.name attribute_name,
|
|
|
|
+ t1.ADDRESS,
|
|
|
|
+ t1.POINT_X,
|
|
|
|
+ t1.POINT_Y,
|
|
|
|
+ t1.DEVICE_NAME,
|
|
|
|
+ a.SCENE_NAME
|
|
|
|
+ from sms_data_alarm_manage m
|
|
|
|
+ inner join sms_device t1
|
|
|
|
+ inner join sms_device_attribute t2 on t1.device_type_id = t2.device_type_id and t2.status = 1
|
|
|
|
+ inner join sms_device_parm t3 on t3.device_id = t1.id and t3.attribute_id=t2.id and t3.status=1
|
|
|
|
+ where
|
|
|
|
+ t3.device_id=#{deviceId}
|
|
|
|
+ and t3.scene_id=#{sceneId}
|
|
|
|
+ and t3.scene_id=#{sceneId}
|
|
|
|
+ and t2.id = #{attrId}
|
|
|
|
+ and t1.status = 1
|
|
|
|
+ and t3.is_alarm= 1
|
|
|
|
+ </select>
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+</mapper>
|