DataAlarmManageMapper.xml 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  3. <mapper namespace="com.huaxu.dao.alarm.DataAlarmManageMapper">
  4. <sql id="alarmManage_result_list" >
  5. a.ID,
  6. a.alarm_name,
  7. a.be_scene_id,
  8. a.be_device_id,
  9. a.be_attribute_id,
  10. a.be_address,
  11. a.be_type,
  12. a.compute_rules,
  13. a.to_scene_id,
  14. a.to_device_id,
  15. a.to_attribute_id,
  16. a.to_address,
  17. a.to_type,
  18. a.alar_rules,
  19. a.alar_value
  20. </sql>
  21. <insert id="saveDataAlarmManage" useGeneratedKeys="true" keyProperty="id" parameterType="com.huaxu.entity.alarm.DataAlarmManageEntity">
  22. 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,
  23. to_scene_id,to_device_id,to_attribute_id,to_type,alar_rules,alar_value,date_create,status)
  24. values
  25. (#{alarmName}, #{companyOrgId}, #{deptOrgId}, #{tenantId}, #{beSceneId},#{beDeviceId},
  26. #{beAttributeId}, #{beType}, #{computeRules}, #{toSceneId},
  27. #{toDeviceId}, #{toAttributeId}, #{toType}, #{alarRules},
  28. #{alarValue}, #{dateCreate},#{status})
  29. </insert>
  30. <select id="findPage" resultType="com.huaxu.vo.DataAlarmManageVo">
  31. select
  32. <include refid="alarmManage_result_list"></include>
  33. from sms_data_alarm_manage a
  34. inner join sms_device t1 on m
  35. inner join sms_device_attribute t2 on t1.device_type_id = t2.device_type_id and t2.status = 1
  36. inner join sms_device_parm t3 on t3.device_id = t1.id and t3.attribute_id=t2.id and t3.status=1
  37. <where>
  38. <if test="dto.userType != null and dto.userType != -999 and dto.userType!=-9999 and dto.programItems != null and dto.programItems.size() > 0">
  39. <if test="dto.permissonType == 5 or dto.permissonType == 2">
  40. and ( a.DEPT_ORG_ID in
  41. <foreach collection="dto.programItems" item="item" open="(" close=")" separator=",">
  42. #{item.orgId}
  43. </foreach>
  44. or
  45. a.COMPANY_ORG_ID in
  46. <foreach collection="dto.programItems" item="item" open="(" close=")" separator=",">
  47. #{item.orgId}
  48. </foreach>
  49. )
  50. </if>
  51. <if test="dto.permissonType == 4 or dto.permissonType == 3">
  52. and a.DEPT_ORG_ID in
  53. <foreach collection="dto.programItems" item="item" open="(" close=")" separator=",">
  54. #{item.orgId}
  55. </foreach>
  56. </if>
  57. <if test="dto.permissonType == 1">
  58. and a.COMPANY_ORG_ID in
  59. <foreach collection="dto.programItems" item="item" open="(" close=")" separator=",">
  60. #{item.orgId}
  61. </foreach>
  62. and (a.DEPT_ORG_ID is null or a.DEPT_ORG_ID =0)
  63. </if>
  64. </if>
  65. <if test="dto.alarmName != null and dto.alarmName != ''">
  66. and a.alarm_name like CONCAT('%',#{dto.alarmName,jdbcType=VARCHAR},'%')
  67. </if>
  68. a.status = 1
  69. </where>
  70. order by id desc
  71. </select>
  72. <select id="findAlarmManage" resultType="com.huaxu.vo.DataAlarmManageVo">
  73. select
  74. <include refid="alarmManage_result_list"></include>
  75. from sms_data_alarm_manage a
  76. where
  77. a.id = #{alarId} and a.status = 1
  78. </select>
  79. <update id="updateDataAlarmManage">
  80. update sms_data_alarm_manage
  81. set
  82. alarm_name = #{alarmName},
  83. be_scene_id =#{beSceneId},
  84. be_device_id = #{beDeviceId},
  85. be_attribute_id = #{beAttributeId},
  86. be_address = #{beAddress},
  87. be_type = #{beType},
  88. compute_rules = #{beAddress},
  89. to_scene_id = #{toSceneId},
  90. to_device_id= #{toDeviceId},
  91. to_attribute_id = #{toAttributeId},
  92. to_address = #{toAddress},
  93. to_type = #{toType},
  94. alar_rules = #{alarRules},
  95. alar_value = #{alarValue},
  96. date_update = #{dateUpdate}
  97. where
  98. id =#{alarmId}
  99. </update>
  100. <update id="delDataAlarmManage">
  101. update sms_data_alarm_manage
  102. set
  103. status = 0
  104. where
  105. id in
  106. <foreach collection="alarmIds" item="alarmId" open="(" close=")" separator=",">
  107. #{alarmId}
  108. </foreach>
  109. </update>
  110. <select id="selectDeviceAttributes">
  111. select t2.id attribute_id,
  112. t2.name attribute_name,
  113. t1.ADDRESS,
  114. t1.POINT_X,
  115. t1.POINT_Y,
  116. t1.DEVICE_NAME,
  117. a.SCENE_NAME
  118. from sms_data_alarm_manage m
  119. inner join sms_device t1
  120. inner join sms_device_attribute t2 on t1.device_type_id = t2.device_type_id and t2.status = 1
  121. inner join sms_device_parm t3 on t3.device_id = t1.id and t3.attribute_id=t2.id and t3.status=1
  122. where
  123. t3.device_id=#{deviceId}
  124. and t3.scene_id=#{sceneId}
  125. and t3.scene_id=#{sceneId}
  126. and t2.id = #{attrId}
  127. and t1.status = 1
  128. and t3.is_alarm= 1
  129. </select>
  130. </mapper>