EnvmonitorMapper.xml 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726
  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.EnvmonitorDao">
  4. <select id="getWeatherListByDTO" resultType="EnvmonitorDTO">
  5. select e.id,e.model as name,e.lamp_pole_id lampPoleId,e.address,e.netStatus,eil.illumination,e.netType,
  6. eil.updatetime as updateTime,e.install_date installDate,e.expiration_date expirationDate,s.timezone,
  7. lp.name as lampPoleName,eil.humidity,eil.temperature,eil.noise,eil.PM10,eil.PM25,eil.illumination,
  8. eil.windDire,eil.windSpeed,eil.updatetime,eil.rainfall,eil.radiation,eil.co,eil.co2,eil.tsp,eil.atmospressue
  9. from envmonitor e left join lamp_pole lp on e.lamp_pole_id = lp.id
  10. left join section s on e.section = s.id
  11. left join (SELECT t1.* FROM envmonitor_info_log t1
  12. INNER JOIN ( SELECT envmonitorid, MAX( updatetime ) AS maxDateTime FROM envmonitor_info_log GROUP BY envmonitorid ) t2
  13. ON t1.envmonitorid = t2.envmonitorid AND t1.updatetime = t2.maxDateTime) as eil on e.id = eil.envmonitorid
  14. where e.lamp_pole_id != 0
  15. <if test="sectionList != null and !sectionList.isEmpty()">
  16. and e.sectionid in
  17. <foreach collection="sectionList" item="dto" open="(" separator="," close=")">
  18. #{dto}
  19. </foreach>
  20. </if>
  21. <choose>
  22. <when test="online == 0">
  23. and e.netStatus = 0
  24. </when>
  25. <when test="online == 1">
  26. and e.netStatus = 1
  27. </when>
  28. </choose>
  29. order by convert(lp.number using gbk) asc,
  30. convert(e.model using gbk) asc,e.id desc
  31. <if test="page >= 0 and count > 0">
  32. limit #{page},#{count}
  33. </if>
  34. </select>
  35. <select id="getTotalBySectionList" resultType="Integer">
  36. select count(e.id) as total from envmonitor e
  37. left join lamp_pole lp on e.lamp_pole_id = lp.id
  38. <if test="sectionList != null and !sectionList.isEmpty()">
  39. where lp.sectionid in
  40. <foreach collection="sectionList" item="dto" open="(" separator="," close=")">
  41. #{dto}
  42. </foreach>
  43. </if>
  44. </select>
  45. <select id="getOnlineTotalBySectionList" resultType="Integer">
  46. select count(e.id) as total from envmonitor e
  47. left join lamp_pole lp on e.lamp_pole_id = lp.id
  48. where e.netStatus = 1
  49. <if test="sectionList != null and !sectionList.isEmpty()">
  50. and lp.sectionid in
  51. <foreach collection="sectionList" item="dto" open="(" separator="," close=")">
  52. #{dto}
  53. </foreach>
  54. </if>
  55. </select>
  56. <select id="getDetailByDTO" resultType="EnvmonitorDTO">
  57. select eil.illumination
  58. from envmonitor e
  59. left join (SELECT t1.* FROM envmonitor_info_log t1
  60. INNER JOIN ( SELECT envmonitorid, MAX( updatetime ) AS maxDateTime FROM envmonitor_info_log GROUP BY envmonitorid ) t2
  61. ON t1.envmonitorid = t2.envmonitorid AND t1.updatetime = t2.maxDateTime) as eil on e.id = eil.envmonitorid
  62. where e.lamp_pole_id != 0
  63. <if test="sectionList != null and !sectionList.isEmpty()">
  64. and e.sectionid in
  65. <foreach collection="sectionList" item="dto" open="(" separator="," close=")">
  66. #{dto}
  67. </foreach>
  68. </if>
  69. limit 1
  70. </select>
  71. <update id="updateDataByEnvmonitorDTO" parameterType="EnvmonitorDTO">
  72. update
  73. envmonitor e
  74. set
  75. e.model = #{model},
  76. e.netType = #{netType},
  77. e.address = #{address}
  78. where e.id = #{id}
  79. </update>
  80. <select id="findDataByEnvmonitorDTO" resultType="Integer">
  81. select count(*)
  82. from envmonitor e
  83. where 1=1
  84. <if test="sectionId != null and sectionId != 0">
  85. and e.sectionid = #{sectionId}
  86. </if>
  87. <if test="model != null and model != ''">
  88. and e.model = #{model}
  89. </if>
  90. <if test="name != null and name != ''">
  91. and e.name = #{name}
  92. </if>
  93. <if test="address != null and address != ''">
  94. and e.address = #{address}
  95. </if>
  96. <if test="num != null and num != ''">
  97. and e.num = #{num}
  98. </if>
  99. <if test="number != null and number != ''">
  100. and e.number = #{number}
  101. </if>
  102. <if test="id != null and id != 0">
  103. and e.id != #{id}
  104. </if>
  105. <if test="lampPoleId != 0">
  106. and e.lamp_pole_id != 0
  107. </if>
  108. <if test="sectionList != null and !sectionList.isEmpty()">
  109. and e.sectionid in
  110. <foreach collection="sectionList" item="dto" open="(" separator="," close=")">
  111. #{dto}
  112. </foreach>
  113. </if>
  114. </select>
  115. <select id="findSectionIdById" resultType="Integer">
  116. select e.sectionid as sectionId
  117. from envmonitor e
  118. where e.id = #{id}
  119. </select>
  120. <select id="getEnvmonitorListByDTO" resultType="com.welampiot.dto.EnvmonitorDTO">
  121. SELECT e.id,e.number,eil.humidity,eil.temperature,eil.noise,eil.PM10,eil.PM25,
  122. eil.illumination,eil.atmospressue,e.updatetime AS updateTime,s.timezone
  123. FROM envmonitor e
  124. LEFT JOIN section s ON e.section = s.id
  125. LEFT JOIN (SELECT t1.*
  126. FROM envmonitor_info_log t1
  127. INNER JOIN ( SELECT envmonitorid, MAX( updatetime ) AS maxDateTime
  128. FROM envmonitor_info_log
  129. GROUP BY envmonitorid ) t2
  130. ON t1.envmonitorid = t2.envmonitorid
  131. AND t1.updatetime = t2.maxDateTime)
  132. AS eil ON e.id = eil.envmonitorid
  133. WHERE e.lamp_pole_id != 0
  134. <if test="sectionList != null and !sectionList.isEmpty()">
  135. and e.sectionid in
  136. <foreach collection="sectionList" item="dto" open="(" separator="," close=")">
  137. #{dto}
  138. </foreach>
  139. </if>
  140. </select>
  141. <update id="changeEnvmonitorLocationById" parameterType="EnvmonitorDTO">
  142. update
  143. envmonitor e
  144. set
  145. e.longitude = #{longitude},
  146. e.latitude = #{latitude}
  147. where e.id = #{id}
  148. </update>
  149. <select id="getEnvmonitorByLampPoleId" resultType="EnvmonitorDTO">
  150. select
  151. e.id,
  152. e.longitude,
  153. e.latitude,
  154. e.netType,
  155. e.model,
  156. e.num,
  157. e.address,
  158. e.importPra,
  159. e.sectionid as sectionId,
  160. e1.temperature,
  161. e1.humidity,
  162. e1.PM25,
  163. e1.PM10,
  164. e1.noise,
  165. e1.atmospressue,
  166. e1.illumination,
  167. e1.windSpeed,
  168. e1.windDire,
  169. e1.co2,
  170. e1.co,
  171. e1.tsp,
  172. e1.rainfall,
  173. e1.radiation,
  174. e1.updatetime as updateTime,
  175. n.protocoltype as protocolType
  176. from
  177. envmonitor e
  178. left join envmonitor_info_log e1 on e1.envmonitorid = e.id
  179. left join network n on e.networkid = n.id
  180. where
  181. e.lamp_pole_id = #{lampPoleId}
  182. limit 1
  183. </select>
  184. <delete id="deleteEnvmonitorById">
  185. delete
  186. from envmonitor
  187. where id = #{id};
  188. </delete>
  189. <select id="getLampPoleIdByEnvmonitorId" resultType="Integer">
  190. select e.lamp_pole_id
  191. from envmonitor e
  192. where e.id = #{id}
  193. </select>
  194. <update id="updateLampPoleEnvmonitorData" parameterType="EnvmonitorDTO">
  195. update envmonitor e
  196. set
  197. e.model = #{model},
  198. e.devType = #{devType},
  199. <if test="pramType != null">
  200. e.pramType = #{pramType},
  201. </if>
  202. <if test="installDate != null and installDate != ''">
  203. e.install_date = #{installDate},
  204. </if>
  205. <if test="expirationDate != null and expirationDate != ''">
  206. e.expiration_date = #{expirationDate},
  207. </if>
  208. e.rate = #{rate},
  209. e.netType = #{netType},
  210. e.mp = #{mp}
  211. where 1=1
  212. <if test="lampPoleId != null and lampPoleId != 0">
  213. and e.lamp_pole_id = #{lampPoleId}
  214. </if>
  215. <if test="id != null and id != 0">
  216. and e.id = #{id}
  217. </if>
  218. </update>
  219. <select id="checkEnvmonitorData" resultType="Integer">
  220. select count(*)
  221. from envmonitor s
  222. where 1=1
  223. <if test="lampPoleId != null and lampPoleId != 0">
  224. and s.lamp_pole_id != #{lampPoleId}
  225. </if>
  226. <if test="sectionId != null and sectionId != 0">
  227. and s.sectionid = #{sectionId}
  228. </if>
  229. <if test="model != null and model != ''">
  230. and s.model = #{model}
  231. </if>
  232. <if test="id != null and id != 0">
  233. and s.id != #{id}
  234. </if>
  235. </select>
  236. <select id="getEnvmonitorCountByLampPoleId" resultType="Integer">
  237. select count(*)
  238. from envmonitor e
  239. where e.lamp_pole_id = #{lampPoleId}
  240. </select>
  241. <update id="updateEnvmonitorMpData" parameterType="EnvmonitorDTO">
  242. update
  243. envmonitor e
  244. set
  245. e.mp_status = #{mpStatus},
  246. e.mp_start_time = #{mpStartTime},
  247. e.mp_end_time = #{mpEndTime},
  248. e.mp_bright = #{mpBright},
  249. e.mp_illumination = #{mpIllumination}
  250. where
  251. e.id = #{id}
  252. </update>
  253. <select id="getEnvmonitorMpDataById" resultType="EnvmonitorDTO">
  254. select
  255. e.id,
  256. e.mp_status as mpStatus,
  257. e.mp_start_time as mpStartTime,
  258. e.mp_end_time as mpEndTime,
  259. e.mp_bright as mpBright,e.rate,
  260. e.lamp_pole_id as lampPoleId,e.devType,e.serial_port as serialPort,
  261. e.mp_illumination as mpIllumination
  262. from envmonitor e
  263. where
  264. e.id = #{id}
  265. </select>
  266. <select id="getEnvmonitorListByVO" resultType="EnvmonitorDTO">
  267. select
  268. e.id,e.model as `name`,
  269. e.number,
  270. eil.updatetime as updateTime,
  271. eil.humidity,
  272. eil.temperature,
  273. eil.illumination,
  274. eil.windSpeed,
  275. eil.windDire,
  276. eil.noise,
  277. eil.PM10,
  278. eil.PM25,
  279. eil.atmospressue,
  280. e.longitude,
  281. e.latitude,
  282. s.name as section
  283. <choose>
  284. <when test="version == 0">
  285. ,g1.chinese_name as area,g2.chinese_name as city,g3.chinese_name as province
  286. </when>
  287. <when test="version == 1">
  288. ,g1.english_name as area,g2.english_name as city,g3.english_name as province
  289. </when>
  290. <otherwise>
  291. ,g1.ru_name as area,g2.ru_name as city,g3.ru_name as province
  292. </otherwise>
  293. </choose>
  294. from envmonitor e
  295. left join (
  296. SELECT t1.*
  297. FROM envmonitor_info_log t1
  298. INNER JOIN ( SELECT
  299. envmonitorid,
  300. MAX( updatetime ) AS maxDateTime
  301. FROM envmonitor_info_log
  302. GROUP BY envmonitorid ) t2
  303. ON t1.envmonitorid = t2.envmonitorid
  304. AND t1.updatetime = t2.maxDateTime) as eil on e.id = eil.envmonitorid
  305. left join lamp_pole lp on e.lamp_pole_id = lp.id
  306. left join section s on lp.sectionid = s.id
  307. left join global_location g1 on s.pid = g1.id
  308. left join global_location g2 on g1.pid = g2.id
  309. left join global_location g3 on g2.pid = g3.id
  310. where e.lamp_pole_id = 0 and e.type = 0
  311. <if test="sectionList != null and !sectionList.isEmpty()">
  312. and e.sectionid in
  313. <foreach collection="sectionList" item="dto" open="(" separator="," close=")">
  314. #{dto}
  315. </foreach>
  316. </if>
  317. <if test="keyword != null and keyword != ''">
  318. and e.number like '%${keyword}%'
  319. </if>
  320. <if test="areaId != null and areaId != 0">
  321. and e.areaid = #{areaId}
  322. </if>
  323. <if test="sectionId != null and sectionId != 0">
  324. and e.sectionid = #{sectionId}
  325. </if>
  326. order by convert(e.model using gbk) asc,e.id desc
  327. <if test="page >= 0 and count > 0">
  328. limit #{page},#{count}
  329. </if>
  330. </select>
  331. <select id="getEnvmonitorTotalByVO" resultType="Integer">
  332. select count(*)
  333. from envmonitor e
  334. where e.type = 0 and e.lamp_pole_id = 0
  335. <if test="sectionList != null and !sectionList.isEmpty()">
  336. and e.sectionid in
  337. <foreach collection="sectionList" item="dto" open="(" separator="," close=")">
  338. #{dto}
  339. </foreach>
  340. </if>
  341. <if test="areaId != null and areaId != 0">
  342. and e.areaid = #{areaId}
  343. </if>
  344. <if test="sectionId != null and sectionId != 0">
  345. and e.sectionid = #{sectionId}
  346. </if>
  347. </select>
  348. <insert id="addEnvmonitorData" parameterType="EnvmonitorDTO" useGeneratedKeys="true" keyProperty="id">
  349. insert into envmonitor(`number`,
  350. areaid,
  351. sectionid,
  352. networkid,
  353. <if test="longitude != null and longitude != ''">
  354. longitude,
  355. </if>
  356. <if test="latitude != null and latitude != ''">
  357. latitude,
  358. </if>
  359. <if test="monitorType != null and monitorType != ''">
  360. monitortype,
  361. </if>
  362. <if test="batteryAh != null and batteryAh != ''">
  363. batteryah,
  364. </if>
  365. <if test="lampPoleId != null and lampPoleId != 0">
  366. lamp_pole_id,
  367. </if>
  368. num,
  369. createtime,
  370. updatetime)
  371. values (#{number},
  372. #{areaId},
  373. #{sectionId},
  374. #{networkId},
  375. <if test="longitude != null and longitude != ''">
  376. #{longitude},
  377. </if>
  378. <if test="latitude != null and latitude != ''">
  379. #{latitude},
  380. </if>
  381. <if test="monitorType != null and monitorType != ''">
  382. #{monitorType},
  383. </if>
  384. <if test="batteryAh != null and batteryAh != ''">
  385. #{batteryAh},
  386. </if>
  387. <if test="lampPoleId != null and lampPoleId != 0">
  388. #{lampPoleId},
  389. </if>
  390. #{num},
  391. #{createTime},
  392. #{updateTime})
  393. </insert>
  394. <update id="updateEnvmonitorData" parameterType="EnvmonitorDTO">
  395. update envmonitor e
  396. set
  397. e.number = #{number},
  398. e.areaid = #{areaId},
  399. e.sectionid = #{sectionId},
  400. <if test="longitude != null and longitude != ''">
  401. e.longitude = #{longitude},
  402. </if>
  403. <if test="latitude != null and latitude != ''">
  404. e.latitude = #{latitude},
  405. </if>
  406. <if test="monitorType != null and monitorType != ''">
  407. e.monitortype = #{monitorType},
  408. </if>
  409. <if test="batteryAh != null and batteryAh != ''">
  410. e.batteryah = #{batteryAh},
  411. </if>
  412. <if test="lampPoleId != null and lampPoleId != 0">
  413. e.lamp_pole_id = #{lampPoleId},
  414. </if>
  415. e.num = #{num},
  416. e.updatetime = #{updateTime}
  417. where
  418. e.id = #{id}
  419. </update>
  420. <select id="getEnvmonitorDetailByVO" resultType="EnvmonitorDTO">
  421. select
  422. e.id,
  423. e.number,
  424. e.areaid as areaId,
  425. e.sectionid as sectionId,
  426. e.address,
  427. e.longitude,
  428. e.latitude,
  429. e.monitortype as monitorType,
  430. e.batteryah as batteryAh,
  431. eil.PM10,
  432. eil.PM25,
  433. eil.temperature,
  434. eil.humidity,
  435. eil.noise,
  436. eil.atmospressue as atmosPressue,
  437. eil.illumination,
  438. n.protocoltype as protocolType,
  439. s.name as section
  440. <choose>
  441. <when test="version == 0">
  442. ,gl.chinese_name as area
  443. </when>
  444. <when test="version == 1">
  445. ,gl.english_name as area
  446. </when>
  447. <otherwise>
  448. ,gl.ru_name as area
  449. </otherwise>
  450. </choose>
  451. from envmonitor e
  452. left join section s on s.id = e.sectionid
  453. left join global_location gl on s.pid = gl.id
  454. left join network n on e.networkid = n.id
  455. left join (
  456. SELECT t1.*
  457. FROM envmonitor_info_log t1
  458. INNER JOIN ( SELECT
  459. envmonitorid,
  460. MAX( updatetime ) AS maxDateTime
  461. FROM envmonitor_info_log
  462. GROUP BY envmonitorid ) t2
  463. ON t1.envmonitorid = t2.envmonitorid
  464. AND t1.updatetime = t2.maxDateTime) as eil on e.id = eil.envmonitorid
  465. where e.id = #{id} and e.type = 0
  466. </select>
  467. <insert id="addIlluminanceData" parameterType="EnvmonitorDTO" useGeneratedKeys="true" keyProperty="id">
  468. insert into envmonitor(`model`,
  469. areaid,
  470. sectionid,
  471. networkid,
  472. remarks,
  473. manufactor,
  474. `name`,
  475. longitude,
  476. latitude,
  477. address,
  478. createtime,
  479. updatetime)
  480. values (#{model},
  481. #{areaId},
  482. #{sectionId},
  483. #{networkId},
  484. #{remarks},
  485. #{manuFactor},
  486. #{name},
  487. #{longitude},
  488. #{latitude},
  489. #{address},
  490. #{createTime},
  491. #{updateTime})
  492. </insert>
  493. <update id="updateIlluminanceData" parameterType="EnvmonitorDTO">
  494. update envmonitor e
  495. set
  496. e.model = #{model},
  497. e.areaid = #{areaId},
  498. e.sectionid = #{sectionId},
  499. e.longitude = #{longitude},
  500. e.latitude = #{latitude},
  501. e.address = #{address},
  502. e.name = #{name},
  503. e.remarks = #{remarks},
  504. e.manufactor = #{manuFactor},
  505. e.updatetime = #{updateTime}
  506. where
  507. e.id = #{id}
  508. </update>
  509. <select id="getIlluminanceDetailByVO" resultType="EnvmonitorDTO">
  510. select
  511. e.id,
  512. e.name,
  513. e.areaid as areaId,
  514. e.sectionid as sectionId,
  515. e.address,
  516. e.longitude,
  517. e.latitude,
  518. e.model,
  519. e.remarks,
  520. e.manufactor as manuFactor,
  521. n.protocoltype as protocolType,
  522. s.name as section
  523. <choose>
  524. <when test="version == 0">
  525. ,gl.chinese_name as area
  526. </when>
  527. <when test="version == 1">
  528. ,gl.english_name as area
  529. </when>
  530. <otherwise>
  531. ,gl.ru_name as area
  532. </otherwise>
  533. </choose>
  534. from envmonitor e
  535. left join section s on s.id = e.sectionid
  536. left join global_location gl on s.pid = gl.id
  537. left join network n on e.networkid = n.id
  538. where e.id = #{id} and e.type = 1
  539. </select>
  540. <select id="getIlluminanceListByVO" resultType="EnvmonitorDTO">
  541. select
  542. e.id,
  543. e.name,
  544. e.areaid as areaId,
  545. e.sectionid as sectionId,
  546. e.address,
  547. e.longitude,
  548. e.latitude,
  549. e.model,
  550. e.remarks,
  551. e.manufactor as manuFactor,
  552. n.protocoltype as protocolType,
  553. s.name as section,
  554. e.illumination
  555. <choose>
  556. <when test="version == 0">
  557. ,gl.chinese_name as area
  558. </when>
  559. <when test="version == 1">
  560. ,gl.english_name as area
  561. </when>
  562. <otherwise>
  563. ,gl.ru_name as area
  564. </otherwise>
  565. </choose>
  566. from envmonitor e
  567. left join section s on s.id = e.sectionid
  568. left join global_location gl on s.pid = gl.id
  569. left join network n on e.networkid = n.id
  570. where e.type = 1
  571. <if test="sectionList != null and !sectionList.isEmpty()">
  572. and e.sectionid in
  573. <foreach collection="sectionList" item="dto" open="(" separator="," close=")">
  574. #{dto}
  575. </foreach>
  576. </if>
  577. <if test="keyword != null and keyword != ''">
  578. and e.name like '%${keyword}%'
  579. </if>
  580. <if test="areaId != null and areaId != 0">
  581. and e.areaid = #{areaId}
  582. </if>
  583. <if test="sectionId != null and sectionId != 0">
  584. and e.sectionid = #{sectionId}
  585. </if>
  586. order by convert(e.name using gbk) asc,e.id desc
  587. <if test="page >= 0 and count > 0">
  588. limit #{page},#{count}
  589. </if>
  590. </select>
  591. <select id="getNewMapDataByVO" resultType="com.welampiot.dto.EnvmonitorDTO" parameterType="com.welampiot.vo.MapDataVO">
  592. select E.id,E.number,E.longitude,E.latitude,EI.temperature,
  593. EI.humidity,
  594. EI.atmospressue as atmosPressue,
  595. EI.PM25,
  596. EI.PM10,
  597. EI.noise,
  598. EI.updatetime as updateTime,
  599. EI.illumination
  600. from envmonitor E
  601. left join network N on E.networkid = N.id
  602. left join section S on E.sectionid = S.id
  603. left join global_location A on S.pid = A.id
  604. left join (select t1.* from envmonitor_info_log t1, (select envmonitorid, max(updatetime) as maxtime from envmonitor_info_log group by envmonitorid) t2 where t1.envmonitorid = t2.envmonitorid and t1.updatetime = t2.maxtime) EI on EI.envmonitorid = E.id
  605. where E.lamp_pole_id = 0
  606. <if test="sectionList != null and !sectionList.isEmpty()">
  607. and E.sectionid in
  608. <foreach item="vo" collection="sectionList" open="(" separator="," close=")">
  609. #{vo}
  610. </foreach>
  611. </if>
  612. <if test="keyword != null and !keyword.isEmpty()">
  613. and E.number like "%#{keyword}%"
  614. </if>
  615. <choose>
  616. <when test="!lngLow.isEmpty() and !lngHigh.isEmpty() and Double.parseDouble(lngLow) > Double.parseDouble(lngHigh)">
  617. and ((L.longitude >= #{lngLow} and L.longitude &lt;= 180) or (L.longitude &lt;= #{lngLow} and L.longitude >= -180))
  618. </when>
  619. <otherwise>
  620. <if test="!lngLow.isEmpty()">
  621. and L.longitude >= #{lngLow}
  622. </if>
  623. <if test="!lngHigh.isEmpty()">
  624. and L.longitude &lt;= #{lngHigh}
  625. </if>
  626. </otherwise>
  627. </choose>
  628. <if test="!latLow.isEmpty()">
  629. and L.latitude >= #{latLow}
  630. </if>
  631. <if test="!latHigh.isEmpty()">
  632. and L.latitude &lt;= #{latHigh}
  633. </if>
  634. group by L.id
  635. </select>
  636. <select id="getOneEnvmonitor" parameterType="HashMap" resultType="EnvmonitorDTO">
  637. select E.id
  638. from envmonitor E
  639. left join lamp_pole P on P.id = E.lamp_pole_id
  640. where P.areaid = #{areaId} and P.sectionid = #{sectionId}
  641. <choose>
  642. <when test="number != null and model == null">
  643. and E.model = #{number}
  644. </when>
  645. <when test="number == null and model != null">
  646. and E.model = #{model}
  647. </when>
  648. <otherwise>
  649. and (E.model = #{number} or E.model = #{model})
  650. </otherwise>
  651. </choose>
  652. </select>
  653. <select id="getOne" parameterType="integer" resultType="EnvmonitorDTO">
  654. select id,areaid as areaId,weatherUpdatetime,netType,weatherInfo,devType,pramType
  655. from envmonitor
  656. where lamp_pole_id = #{lampPoleId}
  657. </select>
  658. <select id="getList" resultType="EnvmonitorDTO" parameterType="EnvmonitorDTO">
  659. select EI.humidity,EI.temperature,EI.noise,EI.PM25,EI.PM10,EI.illumination,EI.windSpeed,EI.windDire,W.weatherInfo,W.weatherUpdatetime,W.areaid as areaId,W.id,S.name as sectionName,LP.number,W.devType
  660. <choose>
  661. <when test="version == 0">
  662. ,G.chinese_name as area
  663. </when>
  664. <when test="version == 1">
  665. ,G.english_name as area
  666. </when>
  667. <otherwise>
  668. ,G.ru_name as area
  669. </otherwise>
  670. </choose>
  671. from envmonitor W left join (select t1.* from envmonitor_info_log AS t1 join (select max(updatetime) as maxTime,envmonitorid from envmonitor_info_log group by envmonitorid) AS t2 ON t1.updatetime = t2.maxTime AND t1.envmonitorid = t2.envmonitorid) AS EI on EI.envmonitorid = W.id
  672. left join section AS S on S.id = W.sectionid
  673. left join global_location AS G on S.pid = G.id
  674. left join lamp_pole AS LP on LP.id = W.lamp_pole_id
  675. where W.lamp_pole_id != 0
  676. <if test="areaId != null and areaId != 0">
  677. and W.areaid = #{areaId}
  678. </if>
  679. <if test="sectionId != null and sectionId != 0">
  680. and W.sectionid = #{sectionId}
  681. </if>
  682. <if test="sectionList != null and !sectionList.isEmpty()">
  683. and W.sectionid in
  684. <foreach collection="sectionList" item="dto" open="(" separator="," close=")">
  685. #{dto}
  686. </foreach>
  687. </if>
  688. <if test="page >= 0 and count > 0">
  689. limit #{page},#{count}
  690. </if>
  691. </select>
  692. <update id="updateWeatherInfo" parameterType="EnvmonitorDTO">
  693. update envmonitor set weatherInfo = #{weatherInfo},weatherUpdatetime = #{weatherUpdatetime}
  694. where id = #{id}
  695. </update>
  696. </mapper>