DiagnoseThresholdChMapper.xml 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  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.xunmei.iot.mapper.DiagnoseThresholdChMapper">
  4. <select id="selectPageData" resultType="com.xunmei.iot.vo.sensor.DiagnoseThresholdPageVo">
  5. select c.* from
  6. (
  7. select s.id,s.org_id, s.org_name,s.org_path, s.device_name, dvs.device_name as host_name,
  8. (select group_concat(threshold_code) from iot_device_diagnose_threshold_ch ch where ch.iot_token = s.iot_token
  9. and ch.device_product=s.device_product and ch.dvs = s.host_code and ch.channel = s.device_code) threshold_codes
  10. from iot_device_info s
  11. inner join iot_device_info dvs on dvs.iot_token = s.iot_token
  12. and dvs.device_product = s.device_product and dvs.device_code = s.host_code
  13. and dvs.deleted = 0 and s.enable = 0 and dvs.device_type = 1
  14. where s.deleted=0 and s.enable=0 and s.device_type = 2
  15. <if test="request.orgId!= null">
  16. and s.org_id=#{request.orgId}
  17. </if>
  18. <if test="request.orgPath!= null">
  19. and s.org_path like CONCAT(#{request.orgPath}, '%')
  20. </if>
  21. <if test="request.deviceName != null and request.deviceName!= ''">
  22. and s.device_name like CONCAT('%',#{request.deviceName},'%')
  23. </if>
  24. order by s.host_code ,cast(s.device_code as signed)
  25. ) c where 1=1
  26. <choose>
  27. <when test=" request.state == null">
  28. </when>
  29. <when test=" request.state == 0">
  30. and c.threshold_codes is null
  31. </when>
  32. <otherwise>
  33. and c.threshold_codes is not null
  34. </otherwise>
  35. </choose>
  36. <choose>
  37. <when test=" request.thresholdCode != null and request.thresholdCode != '' ">
  38. and c.threshold_codes like CONCAT('%',#{request.thresholdCode}, '%')
  39. </when>
  40. <otherwise>
  41. </otherwise>
  42. </choose>
  43. </select>
  44. <select id="selectCamerasCount" resultType="java.lang.Integer">
  45. select count(1) from
  46. (
  47. select s.iot_token,s.device_product,s.host_code dvs,s.device_code channel,
  48. (select group_concat(threshold_code) from iot_device_diagnose_threshold_ch ch where ch.iot_token = s.iot_token
  49. and ch.device_product=s.device_product and ch.dvs = s.host_code and ch.channel = s.device_code) threshold_codes
  50. from iot_device_info s
  51. inner join iot_device_info dvs on dvs.iot_token = s.iot_token
  52. and dvs.device_product = s.device_product and dvs.device_code = s.host_code
  53. and dvs.deleted = 0 and s.enable = 0 and dvs.device_type = 1
  54. where s.deleted=0 and s.enable=0 and s.device_type = 2
  55. <if test="request.orgId!= null">
  56. and s.org_id=#{request.orgId}
  57. </if>
  58. <if test="request.orgPath!= null">
  59. and s.org_path like CONCAT(#{request.orgPath}, '%')
  60. </if>
  61. <if test="request.deviceName != null and request.deviceName!= ''">
  62. and s.device_name like CONCAT('%',#{request.deviceName},'%')
  63. </if>
  64. order by s.host_code ,cast(s.device_code as signed)
  65. ) c where 1=1
  66. <choose>
  67. <when test=" request.state == null">
  68. </when>
  69. <when test=" request.state == 0">
  70. and c.threshold_codes is null
  71. </when>
  72. <otherwise>
  73. and c.threshold_codes is not null
  74. </otherwise>
  75. </choose>
  76. <choose>
  77. <when test=" request.thresholdCode != null and request.thresholdCode != '' ">
  78. and c.threshold_codes like CONCAT('%',#{request.thresholdCode}, '%')
  79. </when>
  80. <otherwise>
  81. </otherwise>
  82. </choose>
  83. </select>
  84. <select id="selectCamerasBind" resultType="com.xunmei.iot.vo.sensor.DiagnoseThresholdBindVo">
  85. select c.* from
  86. (
  87. select s.iot_token,s.device_product,s.host_code dvs,s.device_code channel,
  88. (select group_concat(concat(threshold_code,'#',id)) from iot_device_diagnose_threshold_ch ch where ch.iot_token = s.iot_token
  89. and ch.device_product=s.device_product and ch.dvs = s.host_code and ch.channel = s.device_code) threshold_codes
  90. from iot_device_info s
  91. inner join iot_device_info dvs on dvs.iot_token = s.iot_token
  92. and dvs.device_product = s.device_product and dvs.device_code = s.host_code
  93. and dvs.deleted = 0 and s.enable = 0 and dvs.device_type = 1
  94. where s.deleted=0 and s.enable=0 and s.device_type = 2
  95. <if test="request.orgId!= null">
  96. and s.org_id=#{request.orgId}
  97. </if>
  98. <if test="request.orgPath!= null">
  99. and s.org_path like CONCAT(#{request.orgPath}, '%')
  100. </if>
  101. <if test="request.deviceName != null and request.deviceName!= ''">
  102. and s.device_name like CONCAT('%',#{request.deviceName},'%')
  103. </if>
  104. order by s.host_code ,cast(s.device_code as signed)
  105. ) c where 1=1
  106. <choose>
  107. <when test=" request.state == null">
  108. </when>
  109. <when test=" request.state == 0">
  110. and c.threshold_codes is null
  111. </when>
  112. <otherwise>
  113. and c.threshold_codes is not null
  114. </otherwise>
  115. </choose>
  116. <choose>
  117. <when test=" request.thresholdCode != null and request.thresholdCode != '' ">
  118. and c.threshold_codes like CONCAT('%',#{request.thresholdCode}, '%')
  119. </when>
  120. <otherwise>
  121. </otherwise>
  122. </choose>
  123. </select>
  124. <insert id="batchInsertThresholdCh" parameterType="java.util.List">
  125. insert into iot_device_diagnose_threshold_ch (id,threshold_code,iot_token,device_product,dvs,channel)
  126. values
  127. <foreach collection="list" item="item" index="index" separator=",">
  128. (#{item.id},#{item.thresholdCode},#{item.iotToken},#{item.deviceProduct},#{item.dvs}, #{item.channel})
  129. </foreach>
  130. </insert>
  131. <delete id="batchDeleteThresholdCh" parameterType="java.lang.Long">
  132. delete from iot_device_diagnose_threshold_ch where id in
  133. <foreach collection="ids" item="item" index="index"
  134. open="(" separator="," close=")">#{item}
  135. </foreach>
  136. </delete>
  137. <select id="updateDiagnoseNumber" resultType="java.lang.Integer">
  138. update iot_device_diagnose_threshold set diagnose_number =
  139. (
  140. select count(1) from iot_device_diagnose_threshold_ch where threshold_code = #{thresholdCode}
  141. )
  142. where threshold_code = #{thresholdCode}
  143. </select>
  144. <delete id="deleteCamerasByThresholdCode">
  145. delete from iot_device_diagnose_threshold_ch where threshold_code = #{thresholdCode}
  146. </delete>
  147. <select id="selectExcelData" resultType="com.xunmei.iot.vo.sensor.DiagnoseThresholdPageVo">
  148. select c.* from
  149. (
  150. select s.id,s.org_id, s.org_name,s.org_path, s.device_name, dvs.device_name as host_name,
  151. (select group_concat(threshold_code) from iot_device_diagnose_threshold_ch ch where ch.iot_token = s.iot_token
  152. and ch.device_product=s.device_product and ch.dvs = s.host_code and ch.channel = s.device_code) threshold_codes
  153. from iot_device_info s
  154. inner join iot_device_info dvs on dvs.iot_token = s.iot_token
  155. and dvs.device_product = s.device_product and dvs.device_code = s.host_code
  156. and dvs.deleted = 0 and s.enable = 0 and dvs.device_type = 1
  157. where s.deleted=0 and s.enable=0 and s.device_type = 2
  158. <if test="request.orgId!= null">
  159. and s.org_id=#{request.orgId}
  160. </if>
  161. <if test="request.orgPath!= null">
  162. and s.org_path like CONCAT(#{request.orgPath}, '%')
  163. </if>
  164. <if test="request.deviceName != null and request.deviceName!= ''">
  165. and s.device_name like CONCAT('%',#{request.deviceName},'%')
  166. </if>
  167. order by s.host_code ,cast(s.device_code as signed)
  168. ) c where 1=1
  169. <choose>
  170. <when test=" request.state == null">
  171. </when>
  172. <when test=" request.state == 0">
  173. and c.threshold_codes is null
  174. </when>
  175. <otherwise>
  176. and c.threshold_codes is not null
  177. </otherwise>
  178. </choose>
  179. <choose>
  180. <when test=" request.thresholdCode != null and request.thresholdCode != '' ">
  181. and c.threshold_codes like CONCAT('%',#{request.thresholdCode}, '%')
  182. </when>
  183. <otherwise>
  184. </otherwise>
  185. </choose>
  186. </select>
  187. <select id="selectAllDiagnoseThreshold" resultType="com.xunmei.common.core.domain.iot.domain.IotDeviceDiagnoseThreshold">
  188. select * from iot_device_diagnose_threshold
  189. </select>
  190. </mapper>