CableMapper.xml 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  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.CableDao">
  4. <select id="getDevListByCableDTO" resultType="CableDTO">
  5. select c.id,c.name,c.online,c.type,c.manhole1_X manhole1X,c.manhole1_Y manhole1Y,c.manhole1_Z manhole1Z,
  6. c.manhole1_V manhole1V,c.manhole1_A manhole1A,c.manhole2_X manhole2X,c.manhole2_Y manhole2Y,c.manhole2_Z manhole2Z,
  7. c.manhole2_V manhole2V,c.manhole2_A manhole2A,c.manhole3_X manhole3X,c.manhole3_Y manhole3Y,c.manhole3_Z manhole3Z,
  8. c.manhole3_V manhole3V,c.manhole3_A manhole3A,c.manhole4_X manhole4X,c.manhole4_Y manhole4Y,c.manhole4_Z manhole4Z,
  9. c.manhole4_V manhole4V,c.manhole4_A manhole4A,c.manhole5_X manhole5X,c.manhole5_Y manhole5Y,c.manhole5_Z manhole5Z,
  10. c.manhole5_V manhole5V,c.manhole5_A manhole5A,c.temperature1_T temperature1T,c.temperature1_V temperature1V,
  11. c.temperature1_A temperature1A,c.temperature2_T temperature2T,c.temperature2_V temperature2V,c.temperature2_A temperature2A,
  12. c.temperature3_T temperature3T,c.temperature3_V temperature3V,c.temperature3_A temperature3A,c.water_W waterW,c.water_V waterV,
  13. c.water_A waterA,c.ch4,c.co,c.h2s,c.o2,c.gas_V gasV,c.gas_A gasA,c.updatetime as updateTime,s.timezone
  14. from cable c left join lamp_pole lp on lp.id = c.lamp_pole_id
  15. left join section s on lp.sectionid = s.id
  16. where 1=1
  17. <if test="keyword != null and keyword != ''">
  18. and (c.name like '%${keyword}%' or c.address like '%${keyword}%')
  19. </if>
  20. <if test="sectionList != null and !sectionList.isEmpty()">
  21. and lp.sectionid in
  22. <foreach collection="sectionList" item="dto" open="(" separator="," close=")">
  23. #{dto}
  24. </foreach>
  25. </if>
  26. order by convert(c.name using gbk) asc,c.id desc
  27. <if test="page >= 0 and count > 0">
  28. limit #{page},#{count}
  29. </if>
  30. </select>
  31. <!-- 设备总数 -->
  32. <select id="getTotalByCableDTO" resultType="Integer">
  33. select count(c.id) as total
  34. from cable c left join lamp_pole lp on c.lamp_pole_id = lp.id
  35. where 1=1
  36. <if test="sectionList != null and !sectionList.isEmpty()">
  37. and lp.sectionid in
  38. <foreach collection="sectionList" item="dto" open="(" separator="," close=")">
  39. #{dto}
  40. </foreach>
  41. </if>
  42. <if test="keyword != null and keyword != ''">
  43. and (c.address like '%${keyword}%' or c.name like '%${keyword}%')
  44. </if>
  45. </select>
  46. <!-- 在线数 -->
  47. <select id="getOnlineTotalByCableDTO" resultType="Integer">
  48. select count(c.id) as total
  49. from cable c left join lamp_pole lp on c.lamp_pole_id = lp.id
  50. where c.online = 1
  51. <if test="sectionList != null and !sectionList.isEmpty()">
  52. and lp.sectionid in
  53. <foreach collection="sectionList" item="dto" open="(" separator="," close=")">
  54. #{dto}
  55. </foreach>
  56. </if>
  57. <if test="keyword != null and keyword != ''">
  58. and (c.address like '%${keyword}%' or c.name like '%${keyword}%')
  59. </if>
  60. </select>
  61. <!-- 高温告警数 -->
  62. <select id="getTempAlarmTotalByCableDTO" resultType="Integer">
  63. select count(c.id) as total
  64. from cable c left join lamp_pole lp on c.lamp_pole_id = lp.id
  65. where c.online = 1 and (c.temperature1_A != 0 or c.temperature2_A != 0 or c.temperature3_A != 0)
  66. <if test="sectionList != null and !sectionList.isEmpty()">
  67. and lp.sectionid in
  68. <foreach collection="sectionList" item="dto" open="(" separator="," close=")">
  69. #{dto}
  70. </foreach>
  71. </if>
  72. <if test="keyword != null and keyword != ''">
  73. and (c.address like '%${keyword}%' or c.name like '%${keyword}%')
  74. </if>
  75. </select>
  76. <!-- 水浸告警数 -->
  77. <select id="getWaterAlarmTotalByCableDTO" resultType="Integer">
  78. select count(c.id) as total
  79. from cable c left join lamp_pole lp on c.lamp_pole_id = lp.id
  80. where c.online = 1 and c.water_A != 0
  81. <if test="sectionList != null and !sectionList.isEmpty()">
  82. and lp.sectionid in
  83. <foreach collection="sectionList" item="dto" open="(" separator="," close=")">
  84. #{dto}
  85. </foreach>
  86. </if>
  87. <if test="keyword != null and keyword != ''">
  88. and (c.address like '%${keyword}%' or c.name like '%${keyword}%')
  89. </if>
  90. </select>
  91. <!-- 井盖位移告警数 -->
  92. <select id="getManholeAlarmTotalByCableDTO" resultType="Integer">
  93. select count(c.id) as total
  94. from cable c left join lamp_pole lp on c.lamp_pole_id = lp.id
  95. where c.online = 1 and (c.manhole1_A != 0 or c.manhole2_A != 0 or c.manhole3_A != 0 or c.manhole4_A != 0 or c.manhole5_A != 0)
  96. <if test="sectionList != null and !sectionList.isEmpty()">
  97. and lp.sectionid in
  98. <foreach collection="sectionList" item="dto" open="(" separator="," close=")">
  99. #{dto}
  100. </foreach>
  101. </if>
  102. <if test="keyword != null and keyword != ''">
  103. and (c.address like '%${keyword}%' or c.name like '%${keyword}%')
  104. </if>
  105. </select>
  106. <!-- ch4告警数 -->
  107. <select id="getCh4AlarmTotalByCableDTO" resultType="Integer">
  108. select count(c.id) as total
  109. from cable c left join lamp_pole lp on c.lamp_pole_id = lp.id
  110. where c.online = 1 and c.gas_A = 1
  111. <if test="sectionList != null and !sectionList.isEmpty()">
  112. and lp.sectionid in
  113. <foreach collection="sectionList" item="dto" open="(" separator="," close=")">
  114. #{dto}
  115. </foreach>
  116. </if>
  117. <if test="keyword != null and keyword != ''">
  118. and (c.address like '%${keyword}%' or c.name like '%${keyword}%')
  119. </if>
  120. </select>
  121. <!-- co2告警数 -->
  122. <select id="getCo2AlarmTotalByCableDTO" resultType="Integer">
  123. select count(c.id) as total
  124. from cable c left join lamp_pole lp on c.lamp_pole_id = lp.id
  125. where c.online = 1 and c.gas_A = 2
  126. <if test="sectionList != null and !sectionList.isEmpty()">
  127. and lp.sectionid in
  128. <foreach collection="sectionList" item="dto" open="(" separator="," close=")">
  129. #{dto}
  130. </foreach>
  131. </if>
  132. <if test="keyword != null and keyword != ''">
  133. and (c.address like '%${keyword}%' or c.name like '%${keyword}%')
  134. </if>
  135. </select>
  136. <!-- h2s告警数 -->
  137. <select id="getH2sAlarmTotalByCableDTO" resultType="Integer">
  138. select count(c.id) as total
  139. from cable c left join lamp_pole lp on c.lamp_pole_id = lp.id
  140. where c.online = 1 and c.gas_A = 4
  141. <if test="sectionList != null and !sectionList.isEmpty()">
  142. and lp.sectionid in
  143. <foreach collection="sectionList" item="dto" open="(" separator="," close=")">
  144. #{dto}
  145. </foreach>
  146. </if>
  147. <if test="keyword != null and keyword != ''">
  148. and (c.address like '%${keyword}%' or c.name like '%${keyword}%')
  149. </if>
  150. </select>
  151. <!-- o2告警数 -->
  152. <select id="getO2AlarmTotalByCableDTO" resultType="Integer">
  153. select count(c.id) as total
  154. from cable c left join lamp_pole lp on c.lamp_pole_id = lp.id
  155. where c.online = 1 and c.gas_A = 8
  156. <if test="sectionList != null and !sectionList.isEmpty()">
  157. and lp.sectionid in
  158. <foreach collection="sectionList" item="dto" open="(" separator="," close=")">
  159. #{dto}
  160. </foreach>
  161. </if>
  162. <if test="keyword != null and keyword != ''">
  163. and (c.address like '%${keyword}%' or c.name like '%${keyword}%')
  164. </if>
  165. </select>
  166. <delete id="deleteCableById">
  167. delete
  168. from cable
  169. where id = #{id};
  170. </delete>
  171. <select id="getCableById" resultType="CableDTO">
  172. select b.lamp_pole_id,lp.sectionid as sectionId
  173. from cable b
  174. left join lamp_pole lp on lp.id = b.lamp_pole_id
  175. left join section s on lp.sectionid = s.id
  176. where b.id = #{id}
  177. </select>
  178. <select id="getCableCountByLampPoleId" resultType="Integer">
  179. select count(*)
  180. from cable b
  181. where b.lamp_pole_id = #{lampPoleId}
  182. </select>
  183. <select id="getCableByLampPoleId" resultType="CableDTO">
  184. select b.lamp_pole_id,lp.sectionid as sectionId
  185. from cable b
  186. left join lamp_pole lp on lp.id = b.lamp_pole_id
  187. left join section s on lp.sectionid = s.id
  188. where b.lamp_pole_id = #{lampPoleId}
  189. </select>
  190. <select id="checkCableData" resultType="Integer">
  191. select count(*)
  192. from cable b
  193. where 1=1
  194. <if test="address != null and address != ''">
  195. and b.address = #{address}
  196. </if>
  197. <if test="lampPoleId != null and lampPoleId != 0">
  198. and b.lamp_pole_id != #{lampPoleId}
  199. </if>
  200. <if test="name != null and name != ''">
  201. and b.name = #{name}
  202. </if>
  203. <if test="id != null and id != 0">
  204. and b.id != #{id}
  205. </if>
  206. </select>
  207. <update id="updateLampPoleCableData" parameterType="CableDTO">
  208. update
  209. cable e
  210. set
  211. <if test="installDate != null and installDate != ''">e.install_date = #{installDate},</if>
  212. <if test="expirationDate != null and installDate != ''">e.expiration_date = #{expirationDate},</if>
  213. <if test="address != null and address != ''">e.address = #{address},</if>
  214. e.type = #{type},
  215. e.name = #{name}
  216. where 1=1
  217. <if test="lampPoleId != null and lampPoleId != 0">
  218. and e.lamp_pole_id = #{lampPoleId}
  219. </if>
  220. <if test="id != null and id != 0">
  221. and e.id = #{id}
  222. </if>
  223. </update>
  224. </mapper>