123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141 |
- <?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
- <include refid="alarmManage_result_list"></include>
- from sms_data_alarm_manage a
- inner join sms_device t1 on m
- 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>
- <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>
|