WaterImmersionDevInfoMapper.xml 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248
  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.welampiot.dao.WaterImmersionDevInfoDao">
  4. <select id="getWaterImmersionListByDTO" resultType="WaterImmersionDevInfoDTO">
  5. select w.id,w.lamp_pole_id lampPoleId,s.name as section,g.chinese_name chArea,g.english_name enArea,
  6. g.ru_name ruArea,lp.name lampPoleName,w.number,w.name,w.model,w.status,w.probe1,w.probe2,w.delaytime as delayTime,
  7. w.level,w.powerstatus as powerStatus,w.address,w.box_address boxAddress,w.box_sub_address boxSubAddress,w.factory,
  8. w.deviceId,wifi.model as cloudBoxModel,w.createtime as createTime,w.updatetime as updateTime,w.install_date installDate,
  9. w.expiration_date expirationDate,s.timezone
  10. from water_immersion_dev_info w left join lamp_pole lp on lp.id = w.lamp_pole_id
  11. left join wifi on wifi.lamp_pole_id = lp.id
  12. left join section s on lp.sectionid = s.id
  13. left join global_location g on s.pid = g.id
  14. where w.lamp_pole_id != 0
  15. <if test="sectionList != null and !sectionList.isEmpty()">
  16. and lp.sectionid in
  17. <foreach collection="sectionList" open="(" separator="," close=")" item="dto">
  18. #{dto}
  19. </foreach>
  20. </if>
  21. <if test="keyword != null and keyword != ''">
  22. and (w.name like '%${keyword}%' or w.number like '%${keyword}%')
  23. </if>
  24. <choose>
  25. <when test="online == 0">
  26. and w.status = 0
  27. </when>
  28. <when test="online == 1">
  29. and w.status = 1
  30. </when>
  31. </choose>
  32. order by convert(lp.number using gbk) asc,
  33. convert(w.name using gbk) asc,w.id desc
  34. <if test="page >= 0 and count > 0">
  35. limit #{page},#{count}
  36. </if>
  37. </select>
  38. <select id="getDeviceTotalByDTO" resultType="Integer">
  39. select count(w.id) as total
  40. from water_immersion_dev_info w left join lamp_pole lp on w.lamp_pole_id = lp.id
  41. <if test="sectionList != null and !sectionList.isEmpty()">
  42. where lp.sectionid in
  43. <foreach collection="sectionList" open="(" separator="," close=")" item="dto">
  44. #{dto}
  45. </foreach>
  46. </if>
  47. </select>
  48. <select id="getLogListByDTO" resultType="WaterImmersionDevInfoLogDTO">
  49. select w1.id,w1.water_immersion_id waterImmersionId,w1.probe1,w1.probe2,w1.level,w1.powerstatus,w1.updatetime as updateTime,s.timezone
  50. from water_immersion_dev_info_log w1 left join water_immersion_dev_info w2 on w1.water_immersion_id = w2.id
  51. left join lamp_pole lp on lp.id = w2.lamp_pole_id
  52. left join section s on lp.sectionid = s.id
  53. where 1=1
  54. <if test="waterImmersionId != null and waterImmersionId != 0">
  55. and w1.water_immersion_id = #{waterImmersionId}
  56. </if>
  57. <if test="sectionList != null and !sectionList.isEmpty()">
  58. and lp.sectionid in
  59. <foreach collection="sectionList" item="dto" open="(" separator="," close=")">
  60. #{dto}
  61. </foreach>
  62. </if>
  63. <if test="beginTime != null and beginTime != ''">
  64. and date_format(w1.updatetime,'%Y-%m-%d %H:%i:%s') <![CDATA[ >= ]]> date_format(#{beginTime},'%Y-%m-%d %H:%i:%s')
  65. </if>
  66. <if test="endTime != null and endTime != ''">
  67. and date_format(w1.updatetime,'%Y-%m-%d %H:%i:%s') <![CDATA[ <= ]]> date_format(#{endTime},'%Y-%m-%d %H:%i:%s')
  68. </if>
  69. <if test="page >= 0 and count > 0">
  70. limit #{page},#{count}
  71. </if>
  72. </select>
  73. <select id="getTimezoneById" resultType="Integer">
  74. select s.timezone
  75. from water_immersion_dev_info w1 left join lamp_pole lp on lp.id = w1.lamp_pole_id
  76. left join section s on lp.sectionid = s.id
  77. where w1.id = #{waterImmersionId}
  78. </select>
  79. <update id="updateWaterImmersionDataByDTO" parameterType="com.welampiot.dto.WaterImmersionDevInfoDTO">
  80. update water_immersion_dev_info
  81. set
  82. number = #{number},
  83. name = #{name},
  84. factory = #{factory},
  85. model = #{model},
  86. level = #{level},
  87. powerStatus = #{powerStatus},
  88. serial_port = #{serialPort},
  89. address = #{address},
  90. box_address = #{boxAddress}
  91. <if test="installDate != null and installDate != ''">
  92. ,install_date = #{installDate}
  93. </if>
  94. <if test="expirationDate != null and expirationDate != ''">
  95. ,expiration_date = #{expirationDate}
  96. </if>
  97. ,box_sub_address = #{boxSubAddress}
  98. where id = #{id}
  99. </update>
  100. <update id="updateDelayTimeByDto" parameterType="com.welampiot.dto.WaterImmersionDevInfoDTO">
  101. update water_immersion_dev_info
  102. set
  103. delaytime = #{delayTime}
  104. where id = #{id}
  105. </update>
  106. <select id="findByWaterImmersionDTO" resultType="Integer">
  107. select count(*)
  108. from `water_immersion_dev_info` w
  109. left join lamp_pole lp on lp.id = w.lamp_pole_id
  110. where 1=1
  111. <if test="sectionId != null">
  112. and lp.sectionid = #{sectionId}
  113. </if>
  114. <if test="name != null">
  115. and w.name = #{name}
  116. </if>
  117. <if test="number != null">
  118. and w.number = #{number}
  119. </if>
  120. <if test="id != null">
  121. and w.id != #{id}
  122. </if>
  123. </select>
  124. <select id="findSectionIdById" resultType="Integer">
  125. select lp.sectionid
  126. from `water_immersion_dev_info` w
  127. left join lamp_pole lp on w.lamp_pole_id = lp.id
  128. where w.id = #{id}
  129. </select>
  130. <delete id="deleteWaterImmersionDataByDTO">
  131. delete
  132. from water_immersion_dev_info
  133. where id = #{id};
  134. </delete>
  135. <delete id="deleteWaterImmersionLogDataByDTO">
  136. delete
  137. from water_immersion_dev_info_log
  138. where water_immersion_id = #{id};
  139. </delete>
  140. <select id="getWaterDTOById" resultType="WaterImmersionDevInfoDTO">
  141. select w.id,w.number,w.serial_port as serialPort,w.address,w.factory,c.num,c.model
  142. from water_immersion_dev_info w
  143. left join wifi c on c.lamp_pole_id = w.lamp_pole_id
  144. where w.id = #{id}
  145. </select>
  146. <select id="getWaterImmersionTotal" resultType="Integer">
  147. select
  148. count(*)
  149. from water_immersion_dev_info w
  150. left join lamp_pole lp on lp.id = w.lamp_pole_id
  151. where 1=1
  152. <if test="sectionList != null and !sectionList.isEmpty()">
  153. and lp.sectionid in
  154. <foreach collection="sectionList" item="item" open="(" separator="," close=")">
  155. #{item}
  156. </foreach>
  157. </if>
  158. <if test="areaId != null and areaId != 0">
  159. and lp.areaid = #{areaId}
  160. </if>
  161. <if test="sectionId != null and sectionId != 0">
  162. and lp.sectionid = #{sectionId}
  163. </if>
  164. </select>
  165. <select id="getWaterImmersionOnlineCount" resultType="Integer">
  166. select
  167. count(*)
  168. from water_immersion_dev_info w
  169. left join lamp_pole lp on lp.id = w.lamp_pole_id
  170. where w.status = 1
  171. <if test="sectionList != null and !sectionList.isEmpty()">
  172. and lp.sectionid in
  173. <foreach collection="sectionList" item="item" open="(" separator="," close=")">
  174. #{item}
  175. </foreach>
  176. </if>
  177. <if test="areaId != null and areaId != 0">
  178. and lp.areaid = #{areaId}
  179. </if>
  180. <if test="sectionId != null and sectionId != 0">
  181. and lp.sectionid = #{sectionId}
  182. </if>
  183. </select>
  184. <select id="getWaterImmersionAlarmCount" resultType="Integer">
  185. select
  186. count(*)
  187. from water_immersion_dev_info w
  188. left join lamp_pole lp on lp.id = w.lamp_pole_id
  189. where (w.probe1 = 1 or w.probe2 = 1)
  190. <if test="sectionList != null and !sectionList.isEmpty()">
  191. and lp.sectionid in
  192. <foreach collection="sectionList" item="item" open="(" separator="," close=")">
  193. #{item}
  194. </foreach>
  195. </if>
  196. <if test="areaId != null and areaId != 0">
  197. and lp.areaid = #{areaId}
  198. </if>
  199. <if test="sectionId != null and sectionId != 0">
  200. and lp.sectionid = #{sectionId}
  201. </if>
  202. </select>
  203. <select id="getWaterImmersionNewCount" resultType="Integer">
  204. select
  205. count(*)
  206. from water_immersion_dev_info w
  207. left join lamp_pole lp on lp.id = w.lamp_pole_id
  208. where w.createtime >= date_sub(now(),interval 7 day)
  209. <if test="sectionList != null and !sectionList.isEmpty()">
  210. and lp.sectionid in
  211. <foreach collection="sectionList" item="item" open="(" separator="," close=")">
  212. #{item}
  213. </foreach>
  214. </if>
  215. <if test="areaId != null and areaId != 0">
  216. and lp.areaid = #{areaId}
  217. </if>
  218. <if test="sectionId != null and sectionId != 0">
  219. and lp.sectionid = #{sectionId}
  220. </if>
  221. </select>
  222. <select id="getTotalBySectionList" resultType="Integer">
  223. select count(b.id) as total from water_immersion_dev_info b
  224. left join lamp_pole lp on b.lamp_pole_id = lp.id
  225. <if test="sectionList != null and !sectionList.isEmpty()">
  226. where lp.sectionid in
  227. <foreach collection="sectionList" item="dto" open="(" separator="," close=")">
  228. #{dto}
  229. </foreach>
  230. </if>
  231. </select>
  232. </mapper>