LampPoleMapper.xml 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440
  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.LampPoleDao">
  4. <select id="getCountByVO" resultType="Integer" parameterType="com.welampiot.vo.LampPoleCountVO">
  5. select count(*) from lamp_pole a
  6. where 1=1
  7. <if test="sectionList != null and !sectionList.isEmpty()">
  8. and a.sectionid in
  9. <foreach item="vo" collection="sectionList" open="(" separator="," close=")">
  10. #{vo}
  11. </foreach>
  12. </if>
  13. <if test="name != null">
  14. AND a.name = #{name}
  15. </if>
  16. <if test="number != null">
  17. AND a.number = #{number}
  18. </if>
  19. <if test="sectionId != null">
  20. AND a.sectionid = #{sectionId}
  21. </if>
  22. <if test="id != null">
  23. AND a.id != #{id}
  24. </if>
  25. </select>
  26. <select id="getNavByVO" resultType="com.welampiot.dto.LampPoleDTO" parameterType="com.welampiot.vo.LampPoleVO">
  27. select LP.id,LP.name,LP.longitude,LP.latitude,W.online from lamp_pole LP
  28. left join wifi as W on W.lamp_pole_id = LP.id
  29. left join envmonitor as E on E.lamp_pole_id = LP.id
  30. <if test="devType == 2">
  31. left join video_monitor as V on V.lamp_pole_id = LP.id
  32. </if>
  33. <if test="devType == 1">
  34. left join lampinfo as L on L.lamp_pole_id = LP.id
  35. </if>
  36. where 1=1
  37. <if test="sectionList != null and !sectionList.isEmpty()">
  38. and LP.sectionid in
  39. <foreach item="vo" collection="sectionList" open="(" separator="," close=")">
  40. #{vo}
  41. </foreach>
  42. </if>
  43. <if test="devType != null">
  44. <choose>
  45. <when test="devType == 1">
  46. <if test="devId == null">
  47. AND (LP.devtype like "%0%")
  48. </if>
  49. <if test="devId != null">
  50. AND (LP.devtype like "%0%" OR L.id = #{devId})
  51. </if>
  52. </when>
  53. <when test="devType == 2">
  54. <if test="devId == null">
  55. AND (LP.devtype like "%1%")
  56. </if>
  57. <if test="devId != null">
  58. AND (LP.devtype like "%1%" OR L.id = #{devId})
  59. </if>
  60. </when>
  61. <otherwise>
  62. <if test="devId == null">
  63. AND (LP.devtype like "%7%")
  64. </if>
  65. <if test="devId != null">
  66. AND (LP.devtype like "%7%" OR L.id = #{devId})
  67. </if>
  68. </otherwise>
  69. </choose>
  70. </if>
  71. </select>
  72. <select id="getListByVO" resultType="com.welampiot.dto.LampPoleDTO" parameterType="com.welampiot.vo.LampPoleVO">
  73. select LP.id,LP.name,LP.devtype as devType,LP.createtime,LP.sn,LP.longitude,LP.latitude from lamp_pole LP
  74. where 1=1
  75. <if test="sectionList != null and !sectionList.isEmpty()">
  76. and LP.sectionid in
  77. <foreach item="vo" collection="sectionList" open="(" separator="," close=")">
  78. #{vo}
  79. </foreach>
  80. </if>
  81. <if test="keyword != null">
  82. AND (LP.name like '%#{keyword}%' OR LP.sn like '%#{keyword}%')
  83. </if>
  84. </select>
  85. <select id="lampPoleList" resultType="com.welampiot.dto.LampPoleDTO" parameterType="com.welampiot.vo.LampPoleVO">
  86. select LP.id,LP.name,LP.devtype as devType,LP.sn,LP.longitude,LP.latitude,LP.createtime as createTime,L.faultstatus,LI.grid_active_power as power,LI.dim_value as lighteness,L.policy_type as policyType,P.name as policyName,LP.devtype as devType,LI.updatetime as updateTime,V.is_inspec as isInspec,S.timezone,S.name as section,C.name as company,L.policyid as policyId,LP.install_date as installDate,LP.expiration_date as expirationDate,
  87. <choose>
  88. <when test="version == 1">
  89. G.english_name as area,G2.english_name as city
  90. </when>
  91. <when test="version == 2">
  92. G.ru_name as area,G2.ru_name as city
  93. </when>
  94. <otherwise>
  95. G.chinese_name as area,G2.chinese_name as city
  96. </otherwise>
  97. </choose> from lamp_pole LP
  98. left join section as S on S.id = LP.sectionid
  99. left join lampinfo as L on L.lamp_pole_id = LP.id
  100. left join lamp_info_log_new as LI on LI.lampid = L.id
  101. left join global_location as G on G.id = S.pid
  102. left join global_location as G2 on G.pid = G2.id
  103. left join policy as P on L.policyid = P.id
  104. left join video_monitor as V on V.lamp_pole_id = LP.id
  105. left join user as U on U.id = LP.create_id
  106. left join company as C on U.company_id = C.id
  107. where 1=1
  108. <if test="sectionList != null and !sectionList.isEmpty()">
  109. and LP.sectionid in
  110. <foreach item="vo" collection="sectionList" open="(" separator="," close=")">
  111. #{vo}
  112. </foreach>
  113. </if>
  114. <if test="keyword != null">
  115. AND (LP.name like '%#{keyword}%' OR LP.sn like '%#{keyword}%')
  116. </if>
  117. <if test="isInspec != null">
  118. and V.is_inspec = #{isInspec}
  119. </if>
  120. order by convert(LP.number using gbk) ASC,convert(LP.name using gbk) ASC,LP.id DESC
  121. <if test="offset != null and limit != null">
  122. limit #{offset},#{limit}
  123. </if>
  124. </select>
  125. <select id="lampPoleCount" resultType="int" parameterType="com.welampiot.vo.LampPoleVO">
  126. select count(LP.id) as total from lamp_pole LP
  127. left join video_monitor as V on V.lamp_pole_id = LP.id
  128. where 1=1
  129. <if test="sectionList != null and !sectionList.isEmpty()">
  130. and LP.sectionid in
  131. <foreach item="vo" collection="sectionList" open="(" separator="," close=")">
  132. #{vo}
  133. </foreach>
  134. </if>
  135. <if test="keyword != null">
  136. AND (LP.name like '%#{keyword}%' OR LP.sn like '%#{keyword}%')
  137. </if>
  138. <if test="isInspec != null">
  139. and V.is_inspec = #{isInspec}
  140. </if>
  141. </select>
  142. <insert id="add" parameterType="com.welampiot.dto.LampPoleDTO" useGeneratedKeys="true" keyProperty="id"
  143. >
  144. insert into lamp_pole(name,number,height,areaid,sectionid,longitude,latitude,createtime,create_id,install_date,expiration_date
  145. <!-- <if test="mode != null">-->
  146. <!-- ,mode-->
  147. <!-- </if>-->
  148. )
  149. values
  150. (#{name},#{number},#{height},#{areaId},#{sectionId},#{longitude},#{latitude},#{createTime},#{createId},#{installDate},#{expirationDate}
  151. <!-- <if test="mode != null">-->
  152. <!-- ,#{mode}-->
  153. <!-- </if>-->
  154. )
  155. </insert>
  156. <insert id="update" parameterType="com.welampiot.dto.LampPoleDTO"
  157. >
  158. update lamp_pole
  159. set
  160. <if test="sn != null">sn = #{sn},</if>
  161. <if test="name != null">name = #{name},</if>
  162. <if test="number != null">number = #{number},</if>
  163. <if test="height != null">height = #{height},</if>
  164. <if test="areaId != null">areaid = #{areaId},</if>
  165. <if test="devType != null">devtype = #{devType},</if>
  166. <if test="sectionId != null">sectionid = #{sectionId},</if>
  167. <if test="longitude != null">longitude = #{longitude},</if>
  168. <if test="latitude != null">latitude = #{latitude},</if>
  169. <if test="installDate != null">install_date = #{installDate},</if>
  170. <if test="expirationDate != null">expiration_date = #{expirationDate},</if>
  171. id=#{id}
  172. where id = #{id}
  173. </insert>
  174. <select id="getDetailById" resultType="com.welampiot.dto.LampPoleDTO" parameterType="int">
  175. select id,name,number,height,areaid as areaId,sectionid as sectionId,longitude,latitude,install_date as installDate,expiration_date as expirationDate,devtype as devType from lamp_pole
  176. where id=#{id}
  177. </select>
  178. <delete id="deleteById" parameterType="int">
  179. delete from lamp_pole
  180. where id=#{id}
  181. </delete>
  182. <select id="getLampPoleListByDTO" resultType="com.welampiot.dto.LampPoleDTO">
  183. select
  184. <choose>
  185. <when test="version == 0">
  186. gl.chinese_name as area,
  187. </when>
  188. <when test="version == 1">
  189. gl.english_name as area,
  190. </when>
  191. <otherwise>
  192. gl.ru_name as area,
  193. </otherwise>
  194. </choose>
  195. lp.id,lp.sn,lp.longitude,lp.latitude,lp.devtype as devType,s.name as section,lp.name,
  196. l.updatetime as updateTime,l1.grid_active_power as power,l1.gridvolt as gridVolt,
  197. l1.gridcurr as gridCurr,n.snr,n.rssi,l.id as lampId,vm.id as videoId,l.faultstatus,
  198. l1.work_time_total as lightTime,l.lighteness,n.status,s.timezone
  199. from lamp_pole lp
  200. left join section s on lp.sectionid = s.id
  201. left join global_location gl on s.pid = gl.id
  202. left join lampinfo l on lp.id = l.lamp_pole_id
  203. left join lamp_info_log_new l1 on l1.lampid = l.id
  204. left join network n on l.networkid = n.id
  205. left join video_monitor vm on lp.id = vm.lamp_pole_id
  206. where 1=1
  207. <if test="sectionList != null and !sectionList.isEmpty()">
  208. and lp.sectionid in
  209. <foreach collection="sectionList" item="item" open="(" separator="," close=")">
  210. #{item}
  211. </foreach>
  212. </if>
  213. <choose>
  214. <when test="alarmType == 16">
  215. and l.faultstatus = 16
  216. </when>
  217. <when test="alarmType == 8">
  218. and l.faultstatus = 8
  219. </when>
  220. <when test="alarmType == 4">
  221. and l.faultstatus = 4
  222. </when>
  223. <when test="alarmType == 2">
  224. and l.faultstatus = 2
  225. </when>
  226. <when test="alarmType == 1">
  227. and l.faultstatus = 1
  228. </when>
  229. <otherwise>
  230. and l.faultstatus = 0
  231. </otherwise>
  232. </choose>
  233. <choose>
  234. <when test="online1 == '1'">
  235. and n.status = 1
  236. </when>
  237. <when test="online1 == '0'">
  238. and n.status = 0
  239. </when>
  240. </choose>
  241. </select>
  242. <!-- 灯杆安装总数 -->
  243. <select id="getLampPoleInstallTotalByDTO" resultType="Integer">
  244. select count(l.id)
  245. from lamp_pole l
  246. where 1=1
  247. <if test="sectionList != null and !sectionList.isEmpty()">
  248. and l.sectionid in
  249. <foreach collection="sectionList" item="item" open="(" separator="," close=")">
  250. #{item}
  251. </foreach>
  252. </if>
  253. <if test="areaId != null and areaId != 0">
  254. and l.areaid = #{areaId}
  255. </if>
  256. </select>
  257. <!-- 摄像头数量 -->
  258. <select id="getVideoCount" resultType="Integer">
  259. SELECT
  260. count(vm.id)
  261. AS total
  262. FROM lamp_pole lp
  263. LEFT JOIN video_monitor vm
  264. ON vm.lamp_pole_id = lp.id
  265. WHERE vm.lamp_pole_id != 0
  266. <if test="sectionList != null and !sectionList.isEmpty()">
  267. AND lp.sectionid IN
  268. <foreach collection="sectionList" item="item" open="(" separator="," close=")">
  269. #{item}
  270. </foreach>
  271. </if>
  272. <if test="areaId != null and areaId != 0">
  273. AND lp.areaid = #{areaId}
  274. </if>
  275. </select>
  276. <!-- 屏幕数量 -->
  277. <select id="getScreenCount" resultType="Integer">
  278. SELECT
  279. count(s.id)
  280. AS total
  281. FROM lamp_pole lp
  282. LEFT JOIN screen s
  283. ON s.lamp_pole_id = lp.id
  284. WHERE s.lamp_pole_id != 0
  285. <if test="sectionList != null and !sectionList.isEmpty()">
  286. AND lp.sectionid IN
  287. <foreach collection="sectionList" item="item" open="(" separator="," close=")">
  288. #{item}
  289. </foreach>
  290. </if>
  291. <if test="areaId != null and areaId != 0">
  292. AND lp.areaid = #{areaId}
  293. </if>
  294. </select>
  295. <!-- WIFI数量 -->
  296. <select id="getWifiCount" resultType="Integer">
  297. SELECT
  298. count(w.id)
  299. AS total
  300. FROM lamp_pole lp
  301. LEFT JOIN wifi w
  302. ON w.lamp_pole_id = lp.id
  303. WHERE w.lamp_pole_id != 0
  304. <if test="sectionList != null and !sectionList.isEmpty()">
  305. AND lp.sectionid IN
  306. <foreach collection="sectionList" item="item" open="(" separator="," close=")">
  307. #{item}
  308. </foreach>
  309. </if>
  310. <if test="areaId != null and areaId != 0">
  311. AND lp.areaid = #{areaId}
  312. </if>
  313. </select>
  314. <!-- 气象站数量 -->
  315. <select id="getWeatherCount" resultType="Integer">
  316. SELECT
  317. count(e.id)
  318. AS total
  319. FROM lamp_pole lp
  320. LEFT JOIN envmonitor e
  321. ON e.lamp_pole_id = lp.id
  322. WHERE e.lamp_pole_id != 0
  323. <if test="sectionList != null and !sectionList.isEmpty()">
  324. AND lp.sectionid IN
  325. <foreach collection="sectionList" item="item" open="(" separator="," close=")">
  326. #{item}
  327. </foreach>
  328. </if>
  329. <if test="areaId != null and areaId != 0">
  330. AND lp.areaid = #{areaId}
  331. </if>
  332. </select>
  333. <!-- 充电桩数量 -->
  334. <select id="getChargeCount" resultType="Integer">
  335. SELECT
  336. count(c.id)
  337. AS total
  338. FROM lamp_pole lp
  339. LEFT JOIN charge c
  340. ON c.lamp_pole_id = lp.id
  341. WHERE c.lamp_pole_id != 0
  342. <if test="sectionList != null and !sectionList.isEmpty()">
  343. AND lp.sectionid IN
  344. <foreach collection="sectionList" item="item" open="(" separator="," close=")">
  345. #{item}
  346. </foreach>
  347. </if>
  348. <if test="areaId != null and areaId != 0">
  349. AND lp.areaid = #{areaId}
  350. </if>
  351. </select>
  352. <!-- 一键报警数量 -->
  353. <select id="getEmergencyCount" resultType="Integer">
  354. SELECT
  355. count(c.id)
  356. AS total
  357. FROM lamp_pole lp
  358. LEFT JOIN emergency c
  359. ON c.lamp_pole_id = lp.id
  360. WHERE c.lamp_pole_id != 0
  361. <if test="sectionList != null and !sectionList.isEmpty()">
  362. AND lp.sectionid IN
  363. <foreach collection="sectionList" item="item" open="(" separator="," close=")">
  364. #{item}
  365. </foreach>
  366. </if>
  367. <if test="areaId != null and areaId != 0">
  368. AND lp.areaid = #{areaId}
  369. </if>
  370. </select>
  371. <!-- RFID数量 -->
  372. <select id="getRfidCount" resultType="Integer">
  373. SELECT
  374. count(r.id)
  375. AS total
  376. FROM lamp_pole lp
  377. LEFT JOIN rfid r
  378. ON r.lamp_pole_id = lp.id
  379. WHERE r.lamp_pole_id != 0
  380. <if test="sectionList != null and !sectionList.isEmpty()">
  381. AND lp.sectionid IN
  382. <foreach collection="sectionList" item="item" open="(" separator="," close=")">
  383. #{item}
  384. </foreach>
  385. </if>
  386. <if test="areaId != null and areaId != 0">
  387. AND lp.areaid = #{areaId}
  388. </if>
  389. </select>
  390. <!-- 广播数量 -->
  391. <select id="getBroadcastCount" resultType="Integer">
  392. SELECT
  393. count(b.id)
  394. AS total
  395. FROM lamp_pole lp
  396. LEFT JOIN broadcast b
  397. ON b.lamp_pole_id = lp.id
  398. WHERE b.lamp_pole_id != 0
  399. <if test="sectionList != null and !sectionList.isEmpty()">
  400. AND lp.sectionid IN
  401. <foreach collection="sectionList" item="item" open="(" separator="," close=")">
  402. #{item}
  403. </foreach>
  404. </if>
  405. <if test="areaId != null and areaId != 0">
  406. AND lp.areaid = #{areaId}
  407. </if>
  408. </select>
  409. <select id="getSectionIdByLampPoleId" resultType="Integer">
  410. select lp.sectionid
  411. from lamp_pole lp
  412. where lp.id = #{id}
  413. </select>
  414. <update id="changeLampPoleLocationById" parameterType="LampPoleDTO">
  415. update
  416. lamp_pole l
  417. set
  418. l.longitude = #{longitude},
  419. l.latitude = #{latitude}
  420. where l.id = #{id}
  421. </update>
  422. </mapper>