LampPoleMapper.xml 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  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. </mapper>