DiagnoseMissionChMapper.xml 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  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.DiagnoseMissionChMapper">
  4. <select id="selectPageData" resultType="com.xunmei.iot.vo.sensor.DiagnoseMissionPageVo">
  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 mission_id from iot_device_diagnose_mission_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 limit 1) mission_id
  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.mission_id is null
  31. </when>
  32. <otherwise>
  33. and c.mission_id is not null
  34. </otherwise>
  35. </choose>
  36. <choose>
  37. <when test=" request.missionCode != null and request.missionCode != '' ">
  38. and c.mission_id = #{request.missionCode}
  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 mission_id from iot_device_diagnose_mission_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 limit 1) mission_id
  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.mission_id is null
  71. </when>
  72. <otherwise>
  73. and c.mission_id is not null
  74. </otherwise>
  75. </choose>
  76. <choose>
  77. <when test=" request.missionCode != null and request.missionCode != '' ">
  78. and c.mission_id = #{request.missionCode}
  79. </when>
  80. <otherwise>
  81. </otherwise>
  82. </choose>
  83. </select>
  84. <select id="selectCamerasBind" resultType="com.xunmei.iot.vo.sensor.DiagnoseMissionBindVo">
  85. select c.* from
  86. (
  87. select s.iot_token,s.device_product,s.host_code dvs,s.device_code channel,ch.mission_id,ch.id,
  88. (select group_concat(threshold_code) 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. left join iot_device_diagnose_mission_ch ch on ch.iot_token = s.iot_token
  95. and ch.device_product=s.device_product and ch.dvs = s.host_code and ch.channel = s.device_code
  96. where s.deleted=0 and s.enable=0 and s.device_type = 2
  97. <if test="request.orgId!= null">
  98. and s.org_id=#{request.orgId}
  99. </if>
  100. <if test="request.orgPath!= null">
  101. and s.org_path like CONCAT(#{request.orgPath}, '%')
  102. </if>
  103. <if test="request.deviceName != null and request.deviceName!= ''">
  104. and s.device_name like CONCAT('%',#{request.deviceName},'%')
  105. </if>
  106. order by s.host_code ,cast(s.device_code as signed)
  107. ) c where 1=1
  108. <choose>
  109. <when test=" request.state == null">
  110. </when>
  111. <when test=" request.state == 0">
  112. and c.mission_id is null
  113. </when>
  114. <otherwise>
  115. and c.mission_id is not null
  116. </otherwise>
  117. </choose>
  118. <choose>
  119. <when test=" request.missionCode != null and request.missionCode != '' ">
  120. and c.mission_id = #{request.missionCode}
  121. </when>
  122. <otherwise>
  123. </otherwise>
  124. </choose>
  125. </select>
  126. <insert id="batchInsertMissionCh" parameterType="java.util.List">
  127. insert into iot_device_diagnose_mission_ch (id,mission_id,iot_token,device_product,dvs,channel)
  128. values
  129. <foreach collection="list" item="item" index="index" separator=",">
  130. (#{item.id},#{item.missionId},#{item.iotToken},#{item.deviceProduct},#{item.dvs}, #{item.channel})
  131. </foreach>
  132. </insert>
  133. <update id="batchUpdateMissionCh" parameterType="java.util.List">
  134. <foreach collection="list" item="item" index="index" open="" close="" separator=";">
  135. update iot_device_diagnose_mission_ch
  136. <set>
  137. <if test="item.missionId != null">
  138. mission_id = #{item.missionId},
  139. </if>
  140. </set>
  141. where iot_token = #{item.iotToken} and device_product = #{item.deviceProduct}
  142. and dvs = #{item.dvs} and channel = #{item.channel}
  143. </foreach>
  144. </update>
  145. <insert id="batchInsertThresholdCh" parameterType="java.util.List">
  146. insert into iot_device_diagnose_threshold_ch (id,threshold_code, iot_token,device_product,dvs,channel)
  147. values
  148. <foreach collection="list" item="item" index="index" separator="," >
  149. (#{item.id},#{item.thresholdCode},#{item.iotToken},#{item.deviceProduct},#{item.dvs}, #{item.channel})
  150. </foreach>
  151. </insert>
  152. <delete id="batchDeleteMissionCh" parameterType="java.lang.Long">
  153. delete from iot_device_diagnose_mission_ch where id in
  154. <foreach collection="ids" item="item" index="index"
  155. open="(" separator="," close=")">#{item}
  156. </foreach>
  157. </delete>
  158. <delete id="deleteCamerasByMissionId" parameterType="java.lang.String">
  159. delete from iot_device_diagnose_mission_ch where mission_id = #{missionId}
  160. </delete>
  161. <select id="selectAllDiagnoseMission" resultType="com.xunmei.common.core.domain.iot.domain.IotDeviceDiagnoseMission">
  162. select * from iot_device_diagnose_mission
  163. </select>
  164. </mapper>