AllAlarmInfoLogMapper.xml 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460
  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.AllAlarmInfoLogDao">
  4. <select id="getListByVO" resultType="com.welampiot.dto.AllAlarmInfoLogDTO" parameterType="com.welampiot.vo.LampCountVO">
  5. select L.number,
  6. <choose>
  7. <when test="version == 1">
  8. G.english_name as area,
  9. </when>
  10. <when test="version == 2">
  11. G.ru_name as area,
  12. </when>
  13. <otherwise>
  14. G.chinese_name as area,
  15. </otherwise>
  16. </choose>
  17. S.name as section,AI.stralarmtype as strAlarmType,AI.updatetime from all_alarm_info_log AI inner join lampinfo L on L.id = AI.lampid left join section S on L.sectionid = S.id left join global_location G on S.pid = G.id
  18. where L.faultstatus != 0
  19. <if test="sectionList != null and !sectionList.isEmpty()">
  20. and L.sectionid in
  21. <foreach item="vo" collection="sectionList" open="(" separator="," close=")">
  22. #{vo}
  23. </foreach>
  24. </if>
  25. order by AI.updatetime desc
  26. <if test="offset != null and limit != null">
  27. limit #{offset},#{limit}
  28. </if>
  29. </select>
  30. <select id="getListByAllAlarmInfoLogVO" resultType="com.welampiot.dto.AllAlarmInfoLogDTO" parameterType="com.welampiot.vo.AllAlarmInfoLogVO">
  31. select
  32. <choose>
  33. <when test="version == 0">
  34. gl.chinese_name as area,
  35. </when>
  36. <when test="version == 1">
  37. gl.english_name as area,
  38. </when>
  39. <otherwise>
  40. gl.ru_name as area,
  41. </otherwise>
  42. </choose>
  43. a.id,s.name as secton,l.number,l.name,a.devType,a.dType,a.stralarmtype as strAlarmType,
  44. a.updatetime as updateTime,a.status,a.alarmtype as alarmType,s.timezone
  45. from all_alarm_info_log a
  46. left join lampinfo l on a.lampid = l.id
  47. left join section s on l.section_id = s.id
  48. left join global_location gl on s.pid = gl.id
  49. where 1=1
  50. <if test="keyword != null and keyword != ''">
  51. and (l.number like '%${keyword}%' or a.stralarmtype like '%${keyword}%')
  52. </if>
  53. <if test="sectionList != null and !sectionList.isEmpty()">
  54. and l.sectionid in
  55. <foreach collection="sectionList" item="dto" open="(" separator="," close=")">
  56. #{dto}
  57. </foreach>
  58. </if>
  59. <choose>
  60. <when test="status == 0">
  61. and a.status = 0
  62. </when>
  63. <when test="status == 1">
  64. and a.status = 1
  65. </when>
  66. <when test="status == 2">
  67. and a.status = 2
  68. </when>
  69. </choose>
  70. <choose>
  71. <when test="devType == 0">
  72. and a.devType = 0
  73. </when>
  74. <when test="devType == 1">
  75. and a.devType = 1
  76. </when>
  77. <when test="devType == 2">
  78. and a.devType = 2
  79. </when>
  80. <when test="devType == 3">
  81. and a.devType = 3
  82. </when>
  83. <when test="devType == 4">
  84. and a.devType = 4
  85. </when>
  86. <when test="devType == 5">
  87. and a.devType = 5
  88. </when>
  89. </choose>
  90. order by a.updatetime desc
  91. <if test="offset >= 0 and limit > 0">
  92. limit #{offset},#{limit}
  93. </if>
  94. </select>
  95. <select id="getUnTreatedCountByStatus" resultType="Integer">
  96. select count(a.id) as total
  97. from all_alarm_info_log a
  98. left join lampinfo l on a.lampid = l.id
  99. where a.status = 0
  100. <if test="sectionList != null and !sectionList.isEmpty()">
  101. and l.sectionid in
  102. <foreach collection="sectionList" item="dto" open="(" separator="," close=")">
  103. #{dto}
  104. </foreach>
  105. </if>
  106. </select>
  107. <select id="getProcessingCountByStatus" resultType="Integer">
  108. select count(a.id) as total
  109. from all_alarm_info_log a
  110. left join lampinfo l on a.lampid = l.id
  111. where a.status = 1
  112. <if test="sectionList != null and !sectionList.isEmpty()">
  113. and l.sectionid in
  114. <foreach collection="sectionList" item="dto" open="(" separator="," close=")">
  115. #{dto}
  116. </foreach>
  117. </if>
  118. </select>
  119. <select id="getHandleCountByStatus" resultType="Integer">
  120. select count(a.id) as total
  121. from all_alarm_info_log a
  122. left join lampinfo l on a.lampid = l.id
  123. where a.status = 2
  124. <if test="sectionList != null and !sectionList.isEmpty()">
  125. and l.sectionid in
  126. <foreach collection="sectionList" item="dto" open="(" separator="," close=")">
  127. #{dto}
  128. </foreach>
  129. </if>
  130. </select>
  131. <select id="getAlarmTotalByStatus" resultType="Integer">
  132. select count(a.id) as total
  133. from all_alarm_info_log a
  134. left join lampinfo l on a.lampid = l.id
  135. <if test="sectionList != null and !sectionList.isEmpty()">
  136. where l.sectionid in
  137. <foreach collection="sectionList" item="dto" open="(" separator="," close=")">
  138. #{dto}
  139. </foreach>
  140. </if>
  141. </select>
  142. <update id="updateAlarmStatusByAlarmId" parameterType="com.welampiot.dto.AllAlarmInfoLogDTO">
  143. update
  144. all_alarm_info_log a
  145. set
  146. a.status = #{status}
  147. where a.id = #{id}
  148. </update>
  149. <select id="getAlarmListBySectionList" resultType="com.welampiot.dto.AllAlarmInfoLogDTO">
  150. select a.id,l.number,a.stralarmtype as strAlarmType,a.status,a.updatetime as updateTime,
  151. r.repair_userid as repairUserid,r.repair_time as repairTime
  152. from all_alarm_info_log a
  153. left join lampinfo l on a.lampid = l.id
  154. left join repair_info r on r.lampid = l.id
  155. where 1=1
  156. <if test="sectionList != null and !sectionList.isEmpty()">
  157. and l.sectionid in
  158. <foreach collection="sectionList" item="dto" open="(" separator="," close=")">
  159. #{dto}
  160. </foreach>
  161. </if>
  162. </select>
  163. <select id="getLampAlarmListByVO" resultType="AllAlarmInfoLogDTO" parameterType="AllAlarmInfoLogVO">
  164. select
  165. a.id,a.updatetime as updateTime,a.stralarmtype as strAlarmType,
  166. s.name as section,a.devType,l.number,l.longitude,l.latitude,l.name
  167. <choose>
  168. <when test="version == 0">
  169. ,gl.chinese_name as area
  170. </when>
  171. <when test="version == 1">
  172. ,gl.english_name as area
  173. </when>
  174. <otherwise>
  175. ,gl.ru_name as area
  176. </otherwise>
  177. </choose>
  178. <choose>
  179. <when test="version == 0">
  180. ,gl1.chinese_name as city
  181. </when>
  182. <when test="version == 1">
  183. ,gl1.english_name as city
  184. </when>
  185. <otherwise>
  186. ,gl1.ru_name as city
  187. </otherwise>
  188. </choose>
  189. <choose>
  190. <when test="version == 0">
  191. ,gl2.chinese_name as province
  192. </when>
  193. <when test="version == 1">
  194. ,gl2.english_name as province
  195. </when>
  196. <otherwise>
  197. ,gl2.ru_name as province
  198. </otherwise>
  199. </choose>
  200. from all_alarm_info_log a
  201. left join section s on a.sectionId = s.id
  202. left join global_location gl on s.pid = gl.id
  203. left join global_location gl1 on gl.pid = gl1.id
  204. left join global_location gl2 on gl1.pid = gl2.id
  205. left join lampinfo l on a.lampid = l.id
  206. where a.devType = 0
  207. <if test="sectionList != null and !sectionList.isEmpty()">
  208. and a.sectionId in
  209. <foreach collection="sectionList" item="item" open="(" separator="," close=")">
  210. #{item}
  211. </foreach>
  212. </if>
  213. <if test="sectionId != null and sectionId != 0">
  214. and s.id = #{sectionId}
  215. </if>
  216. <if test="areaId != null and areaId != 0">
  217. and gl.id = #{areaId}
  218. </if>
  219. <if test="cityId != null and cityId != 0">
  220. and gl1.id = #{cityId}
  221. </if>
  222. <if test="provinceId != null and provinceId != 0">
  223. and gl2.id = #{provinceId}
  224. </if>
  225. <if test="alarmType != null and alarmType != ''">
  226. and a.stralarmtype like '%${alarmType}%'
  227. </if>
  228. <if test="limit >= 0 and offset > 0">
  229. limit #{limit},#{offset}
  230. </if>
  231. </select>
  232. <select id="getLampPoleAlarmListByVO" resultType="AllAlarmInfoLogDTO" parameterType="AllAlarmInfoLogVO">
  233. select
  234. a.id,a.updatetime as updateTime,a.stralarmtype as strAlarmType,
  235. s.name as section,a.devType,l.number,l.longitude,l.latitude,l.name
  236. <choose>
  237. <when test="version == 0">
  238. ,gl.chinese_name as area
  239. </when>
  240. <when test="version == 1">
  241. ,gl.english_name as area
  242. </when>
  243. <otherwise>
  244. ,gl.ru_name as area
  245. </otherwise>
  246. </choose>
  247. <choose>
  248. <when test="version == 0">
  249. ,gl1.chinese_name as city
  250. </when>
  251. <when test="version == 1">
  252. ,gl1.english_name as city
  253. </when>
  254. <otherwise>
  255. ,gl1.ru_name as city
  256. </otherwise>
  257. </choose>
  258. <choose>
  259. <when test="version == 0">
  260. ,gl2.chinese_name as province
  261. </when>
  262. <when test="version == 1">
  263. ,gl2.english_name as province
  264. </when>
  265. <otherwise>
  266. ,gl2.ru_name as province
  267. </otherwise>
  268. </choose>
  269. from all_alarm_info_log a
  270. left join section s on a.sectionId = s.id
  271. left join global_location gl on s.pid = gl.id
  272. left join global_location gl1 on gl.pid = gl1.id
  273. left join global_location gl2 on gl1.pid = gl2.id
  274. left join lamp_pole l on a.lampid = l.id
  275. where a.devType = 1
  276. <if test="sectionList != null and !sectionList.isEmpty()">
  277. and a.sectionId in
  278. <foreach collection="sectionList" item="item" open="(" separator="," close=")">
  279. #{item}
  280. </foreach>
  281. </if>
  282. <if test="sectionId != null and sectionId != 0">
  283. and s.id = #{sectionId}
  284. </if>
  285. <if test="areaId != null and areaId != 0">
  286. and gl.id = #{areaId}
  287. </if>
  288. <if test="cityId != null and cityId != 0">
  289. and gl1.id = #{cityId}
  290. </if>
  291. <if test="provinceId != null and provinceId != 0">
  292. and gl2.id = #{provinceId}
  293. </if>
  294. <if test="alarmType != null and alarmType != ''">
  295. and a.stralarmtype like '%${alarmType}%'
  296. </if>
  297. <if test="limit >= 0 and offset > 0">
  298. limit #{limit},#{offset}
  299. </if>
  300. </select>
  301. <select id="getWaterImmersionAlarmListByVO" resultType="AllAlarmInfoLogDTO" parameterType="AllAlarmInfoLogVO">
  302. select
  303. a.id,a.updatetime as updateTime,a.stralarmtype as strAlarmType,
  304. s.name as section,a.devType,w.number,lp.longitude,lp.latitude,w.name
  305. <choose>
  306. <when test="version == 0">
  307. ,gl.chinese_name as area
  308. </when>
  309. <when test="version == 1">
  310. ,gl.english_name as area
  311. </when>
  312. <otherwise>
  313. ,gl.ru_name as area
  314. </otherwise>
  315. </choose>
  316. <choose>
  317. <when test="version == 0">
  318. ,gl1.chinese_name as city
  319. </when>
  320. <when test="version == 1">
  321. ,gl1.english_name as city
  322. </when>
  323. <otherwise>
  324. ,gl1.ru_name as city
  325. </otherwise>
  326. </choose>
  327. <choose>
  328. <when test="version == 0">
  329. ,gl2.chinese_name as province
  330. </when>
  331. <when test="version == 1">
  332. ,gl2.english_name as province
  333. </when>
  334. <otherwise>
  335. ,gl2.ru_name as province
  336. </otherwise>
  337. </choose>
  338. from all_alarm_info_log a
  339. left join section s on a.sectionId = s.id
  340. left join global_location gl on s.pid = gl.id
  341. left join global_location gl1 on gl.pid = gl1.id
  342. left join global_location gl2 on gl1.pid = gl2.id
  343. left join lamp_pole lp on a.lampid = lp.id
  344. left join water_immersion_dev_info w on w.lamp_pole_id = lp.id
  345. where a.devType = 3
  346. <if test="sectionList != null and !sectionList.isEmpty()">
  347. and a.sectionId in
  348. <foreach collection="sectionList" item="item" open="(" separator="," close=")">
  349. #{item}
  350. </foreach>
  351. </if>
  352. <if test="sectionId != null and sectionId != 0">
  353. and s.id = #{sectionId}
  354. </if>
  355. <if test="areaId != null and areaId != 0">
  356. and gl.id = #{areaId}
  357. </if>
  358. <if test="cityId != null and cityId != 0">
  359. and gl1.id = #{cityId}
  360. </if>
  361. <if test="provinceId != null and provinceId != 0">
  362. and gl2.id = #{provinceId}
  363. </if>
  364. <if test="alarmType != null and alarmType != ''">
  365. and a.stralarmtype like '%${alarmType}%'
  366. </if>
  367. <if test="limit >= 0 and offset > 0">
  368. limit #{limit},#{offset}
  369. </if>
  370. </select>
  371. <select id="getElectricBoxAlarmListByVO" resultType="AllAlarmInfoLogDTO" parameterType="AllAlarmInfoLogVO">
  372. select
  373. a.id,a.updatetime as updateTime,a.stralarmtype as strAlarmType,
  374. s.name as section,a.devType,e.address as `number`,e.longitude,e.latitude,e.name
  375. <choose>
  376. <when test="version == 0">
  377. ,gl.chinese_name as area
  378. </when>
  379. <when test="version == 1">
  380. ,gl.english_name as area
  381. </when>
  382. <otherwise>
  383. ,gl.ru_name as area
  384. </otherwise>
  385. </choose>
  386. <choose>
  387. <when test="version == 0">
  388. ,gl1.chinese_name as city
  389. </when>
  390. <when test="version == 1">
  391. ,gl1.english_name as city
  392. </when>
  393. <otherwise>
  394. ,gl1.ru_name as city
  395. </otherwise>
  396. </choose>
  397. <choose>
  398. <when test="version == 0">
  399. ,gl2.chinese_name as province
  400. </when>
  401. <when test="version == 1">
  402. ,gl2.english_name as province
  403. </when>
  404. <otherwise>
  405. ,gl2.ru_name as province
  406. </otherwise>
  407. </choose>
  408. from all_alarm_info_log a
  409. left join section s on a.sectionId = s.id
  410. left join global_location gl on s.pid = gl.id
  411. left join global_location gl1 on gl.pid = gl1.id
  412. left join global_location gl2 on gl1.pid = gl2.id
  413. left join electric_box e on a.lampid = e.id
  414. where a.devType = 4
  415. <if test="sectionList != null and !sectionList.isEmpty()">
  416. and a.sectionId in
  417. <foreach collection="sectionList" item="item" open="(" separator="," close=")">
  418. #{item}
  419. </foreach>
  420. </if>
  421. <if test="sectionId != null and sectionId != 0">
  422. and s.id = #{sectionId}
  423. </if>
  424. <if test="areaId != null and areaId != 0">
  425. and gl.id = #{areaId}
  426. </if>
  427. <if test="cityId != null and cityId != 0">
  428. and gl1.id = #{cityId}
  429. </if>
  430. <if test="provinceId != null and provinceId != 0">
  431. and gl2.id = #{provinceId}
  432. </if>
  433. <if test="alarmType != null and alarmType != ''">
  434. and a.stralarmtype like '%${alarmType}%'
  435. </if>
  436. <if test="limit >= 0 and offset > 0">
  437. limit #{limit},#{offset}
  438. </if>
  439. </select>
  440. <!-- 更新故障状态 -->
  441. <update id="updateAlarmStatus" parameterType="Integer">
  442. update all_alarm_info_log a
  443. set
  444. a.status = #{status}
  445. where a.id = #{id}
  446. </update>
  447. </mapper>