ChargeMapper.xml 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306
  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.ChargeDao">
  4. <select id="getDevListByChargeDTO" resultType="ChargeDTO">
  5. select c.id,c.num,c.online,c.status,c.updateTime,c.starttime as startTime,c.endtime as endTime,
  6. c.equipmentElectricity,c.free,c.connectorNum,c.hourEnergy,c.alarmStatus,c.alarmInfo,
  7. c.install_date installDate,c.expiration_date expirationDate,s.timezone,lp.name as lampPoleName
  8. from charge c left join lamp_pole lp on lp.id = c.lamp_pole_id
  9. left join section s on lp.sectionid = s.id
  10. where c.lamp_pole_id != 0
  11. <if test="sectionList != null and !sectionList.isEmpty()">
  12. and lp.sectionid in
  13. <foreach collection="sectionList" item="dto" open="(" separator="," close=")">
  14. #{dto}
  15. </foreach>
  16. </if>
  17. <if test="keyword != null and keyword != ''">
  18. and c.num like '%${keyword}%'
  19. </if>
  20. order by convert(lp.number using gbk) asc,c.id desc
  21. <if test="page >= 0 and count > 0">
  22. limit #{page},#{count}
  23. </if>
  24. </select>
  25. <select id="getTotalBySectionList" resultType="Integer">
  26. select count(c.id) as total
  27. from charge c left join lamp_pole lp on lp.id = c.lamp_pole_id
  28. where 1=1 <if test="sectionList != null and !sectionList.isEmpty()">
  29. and lp.sectionid in
  30. <foreach collection="sectionList" item="dto" open="(" separator="," close=")">
  31. #{dto}
  32. </foreach>
  33. </if>
  34. <if test="keyword != null and keyword != ''">
  35. and c.num like '%${keyword}%'
  36. </if>
  37. </select>
  38. <!-- 在线数 -->
  39. <select id="getOnlineTotalBySectionList" resultType="Integer">
  40. select count(c.id) as total
  41. from charge c left join lamp_pole lp on lp.id = c.lamp_pole_id
  42. where c.online = 1
  43. <if test="sectionList != null and !sectionList.isEmpty()">
  44. and lp.sectionid in
  45. <foreach collection="sectionList" item="dto" open="(" separator="," close=")">
  46. #{dto}
  47. </foreach>
  48. </if>
  49. <if test="keyword != null and keyword != ''">
  50. and c.num like '%${keyword}%'
  51. </if>
  52. </select>
  53. <!-- 告警数 -->
  54. <select id="getAlarmTotalBySectionList" resultType="Integer">
  55. select count(c.id) as total
  56. from charge c left join lamp_pole lp on lp.id = c.lamp_pole_id
  57. where c.online = 1 and c.alarmStatus = 1
  58. <if test="sectionList != null and !sectionList.isEmpty()">
  59. and lp.sectionid in
  60. <foreach collection="sectionList" item="dto" open="(" separator="," close=")">
  61. #{dto}
  62. </foreach>
  63. </if>
  64. <if test="keyword != null and keyword != ''">
  65. and c.num like '%${keyword}%'
  66. </if>
  67. </select>
  68. <!-- 充电中的数量 -->
  69. <select id="getChargeTotalBySectionList" resultType="Integer">
  70. select count(c.id) as total
  71. from charge c left join lamp_pole lp on lp.id = c.lamp_pole_id
  72. where c.online = 1 and c.status = 1
  73. <if test="sectionList != null and !sectionList.isEmpty()">
  74. and lp.sectionid in
  75. <foreach collection="sectionList" item="dto" open="(" separator="," close=")">
  76. #{dto}
  77. </foreach>
  78. </if>
  79. <if test="keyword != null and keyword != ''">
  80. and c.num like '%${keyword}%'
  81. </if>
  82. </select>
  83. <!-- 充电时长 -->
  84. <select id="getChargeTimeBySectionList" resultType="ChargeDTO">
  85. select c.id,c.duration
  86. from charge c left join lamp_pole lp on lp.id = c.lamp_pole_id
  87. where 1=1
  88. <if test="sectionList != null and !sectionList.isEmpty()">
  89. and lp.sectionid in
  90. <foreach collection="sectionList" item="dto" open="(" separator="," close=")">
  91. #{dto}
  92. </foreach>
  93. </if>
  94. <if test="keyword != null and keyword != ''">
  95. and c.num like '%${keyword}%'
  96. </if>
  97. </select>
  98. <!-- 充电金额 -->
  99. <select id="getChargeMoneyBySectionList" resultType="ChargeDTO">
  100. select c.id,c.free
  101. from charge c left join lamp_pole lp on lp.id = c.lamp_pole_id
  102. where 1=1
  103. <if test="sectionList != null and !sectionList.isEmpty()">
  104. and lp.sectionid in
  105. <foreach collection="sectionList" item="dto" open="(" separator="," close=")">
  106. #{dto}
  107. </foreach>
  108. </if>
  109. <if test="keyword != null and keyword != ''">
  110. and c.num like '%${keyword}%'
  111. </if>
  112. </select>
  113. <!-- 充电能耗 -->
  114. <select id="getChargeEnergyBySectionList" resultType="ChargeDTO">
  115. select c.id,c.equipmentElectricity
  116. from charge c left join lamp_pole lp on lp.id = c.lamp_pole_id
  117. where 1=1
  118. <if test="sectionList != null and !sectionList.isEmpty()">
  119. and lp.sectionid in
  120. <foreach collection="sectionList" item="dto" open="(" separator="," close=")">
  121. #{dto}
  122. </foreach>
  123. </if>
  124. <if test="keyword != null and keyword != ''">
  125. and c.num like '%${keyword}%'
  126. </if>
  127. </select>
  128. <select id="getChargeInfoByLampPoleId" resultType="ChargeDTO">
  129. select c.type,c.macVoltage,c.power,c.macCurrent,c.voltage,c.current,c.model,c.num,c.chargeModel,
  130. c.electricityFee,c.serviceFee,c.connectorCode,c.stationCode,c.createtime as createTime,
  131. c.status,c.bill_amt as billAmt,c.energy,c.starttime as startTime,c.endtime as endTime,
  132. c.duration,c.free,c.connectorNum,c.equipmentElectricity,c.macVoltage,c.serviceFee,c.connectorNum
  133. from charge c
  134. where c.lamp_pole_id = #{lampPoleId}
  135. limit 1
  136. </select>
  137. <delete id="deleteChargeById">
  138. delete
  139. from charge
  140. where id = #{id};
  141. </delete>
  142. <select id="getLampPoleIdByChargeId" resultType="Integer">
  143. select c.lamp_pole_id
  144. from charge c
  145. where c.id = #{id}
  146. </select>
  147. <select id="getChargeCountByLampPoleId" resultType="Integer">
  148. select count(*)
  149. from charge c
  150. where c.lamp_pole_id = #{lampPoleId}
  151. </select>
  152. <update id="updateLampPoleChargeData" parameterType="ChargeDTO">
  153. update charge c
  154. set
  155. c.num = #{num},
  156. c.model = #{model},
  157. <if test="installDate != null and installDate != ''">c.install_date = #{installDate},</if>
  158. <if test="expirationDate != null and expirationDate != ''">c.expiration_date = #{expirationDate},</if>
  159. c.power = #{power},
  160. c.chargeModel = #{chargeModel}
  161. where 1=1
  162. <if test="lampPoleId != null and lampPoleId != 0">
  163. and c.lamp_pole_id = #{lampPoleId}
  164. </if>
  165. <if test="id != null and id != 0">
  166. and c.id = #{id}
  167. </if>
  168. </update>
  169. <select id="checkChargeData" resultType="Integer">
  170. select count(*)
  171. from charge c
  172. where 1=1
  173. <if test="lampPoleId != null and lampPoleId != 0">
  174. and c.lamp_pole_id != #{lampPoleId}
  175. </if>
  176. <if test="num != null and num != ''">
  177. and c.num = #{num}
  178. </if>
  179. <if test="id != null and id != 0">
  180. and c.id != #{id}
  181. </if>
  182. </select>
  183. <!-- 智诺云信息概览充电量和充电金额 -->
  184. <select id="getTotalChargeEleAndFree" resultType="ChargeDTO">
  185. select
  186. sum(c.equipmentElectricity) as equipmentElectricity,
  187. sum(c.free) as free
  188. from charge c
  189. left join lamp_pole lp on lp.id = c.lamp_pole_id
  190. where 1=1
  191. <if test="sectionList != null and !sectionList.isEmpty()">
  192. and lp.sectionid in
  193. <foreach collection="sectionList" item="item" open="(" separator="," close=")">
  194. #{item}
  195. </foreach>
  196. </if>
  197. <if test="sectionId != null and sectionId != 0">
  198. and lp.sectionid = #{sectionId}
  199. </if>
  200. <if test="areaId != null and areaId != 0">
  201. and lp.areaid = #{areaId}
  202. </if>
  203. </select>
  204. <select id="getChargeListByDTO" resultType="ChargeDTO">
  205. select
  206. c.id,
  207. c.current,
  208. c.voltage,
  209. c.free,
  210. c.equipmentElectricity,
  211. c.duration,
  212. c.status
  213. <choose>
  214. <when test="version == 0">
  215. ,g1.chinese_name as area,g2.chinese_name as city,g3.chinese_name as province
  216. </when>
  217. <when test="version == 1">
  218. ,g1.english_name as area,g2.english_name as city,g3.english_name as province
  219. </when>
  220. <otherwise>
  221. ,g1.ru_name as area,g2.ru_name as city,g3.ru_name as province
  222. </otherwise>
  223. </choose>
  224. from charge c
  225. left join lamp_pole lp on lp.id = c.lamp_pole_id
  226. left join section s on lp.sectionid = s.id
  227. left join global_location g1 on s.pid = g1.id
  228. left join global_location g2 on g1.pid = g2.id
  229. left join global_location g3 on g2.pid = g3.id
  230. where c.lamp_pole_id != 0
  231. <if test="sectionList != null and !sectionList.isEmpty()">
  232. and lp.sectionid in
  233. <foreach collection="sectionList" item="item" open="(" separator="," close=")">
  234. #{item}
  235. </foreach>
  236. </if>
  237. <if test="sectionId != null and sectionId != 0">
  238. and lp.sectionid = #{sectionId}
  239. </if>
  240. <if test="areaId != null and areaId != 0">
  241. and lp.areaid = #{areaId}
  242. </if>
  243. <if test="page >= 0 and count > 0">
  244. limit #{page},#{count}
  245. </if>
  246. </select>
  247. <select id="getChargeTotalByDTO" resultType="Integer">
  248. select count(*)
  249. from charge c
  250. left join lamp_pole lp on lp.id = c.lamp_pole_id
  251. where c.lamp_pole_id != 0
  252. <if test="sectionList != null and !sectionList.isEmpty()">
  253. and lp.sectionid in
  254. <foreach collection="sectionList" item="item" open="(" separator="," close=")">
  255. #{item}
  256. </foreach>
  257. </if>
  258. <if test="sectionId != null and sectionId != 0">
  259. and lp.sectionid = #{sectionId}
  260. </if>
  261. <if test="areaId != null and areaId != 0">
  262. and lp.areaid = #{areaId}
  263. </if>
  264. </select>
  265. <select id="getOneCharge" parameterType="HashMap" resultType="ChargeDTO">
  266. select C.id
  267. from charge C
  268. left join lamp_pole P on P.id = C.lamp_pole_id
  269. where P.areaid = #{areaId} and P.sectionid = #{sectionid}
  270. <choose>
  271. <when test="number != null and model == null">
  272. and C.num = #{number}
  273. </when>
  274. <when test="number == null and model != null">
  275. and C.model = #{model}
  276. </when>
  277. <otherwise>
  278. and C.num = #{number} and C.model = #{model}
  279. </otherwise>
  280. </choose>
  281. </select>
  282. <select id="getOneChargeByLampPoleId" resultType="ChargeDTO" parameterType="Integer">
  283. select status,online,equipmentElectricity,bill_amt as billAmt
  284. from charge
  285. where lamp_pole_id = #{lampPoleId} order by id desc
  286. </select>
  287. </mapper>