AmountWaterUsedAmountMapper.xml 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583
  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.bz.smart_city.dao.pay.AmountWaterUsedAmountMapper">
  4. <sql id="amountWaterusedamountColumns">
  5. a.id AS "id",
  6. a.approver_id AS "approverId",
  7. a.approvetime AS "approvetime",
  8. a.customerandmeterrela_id AS "customerandmeterrelaId",
  9. a.office_id AS "officeId",
  10. a.lastreading AS "lastreading",
  11. a.lastrecorddate AS "lastrecorddate",
  12. a.metercode AS "metercode",
  13. a.watermeter_id AS "watermeterId",
  14. a.month AS "month",
  15. a.payamount AS "payamount",
  16. a.reading AS "reading",
  17. a.recorddate AS "recorddate",
  18. a.amount AS "amount",
  19. a.state AS "state",
  20. a.waterproperty_id AS "waterpropertyId",
  21. a.year AS "year",
  22. a.account_id AS "accountId",
  23. a.accountname AS "accountname",
  24. a.accountnumber AS "accountnumber",
  25. a.address AS "address",
  26. a.watertype AS "watertype",
  27. a.isprint AS "isprint",
  28. a.ele_no AS "eleNo",
  29. a.iswxsend AS "iswxsend",
  30. a.sendwxdate AS "sendwxdate",
  31. a.create_by AS "createBy",
  32. a.create_date AS "createDate",
  33. a.update_by AS "updateBy",
  34. a.update_date AS "updateDate",
  35. a.remarks AS "remarks",
  36. a.del_flag AS "delFlag",
  37. a.site_id as "siteId",
  38. a.customer_id as "customerId",
  39. c.label as stateName,
  40. CONCAT(a.`year`,'年',LPAD(a.month, 2, 0),'月') as closingName,
  41. d.water_meter_no as "metereleno"
  42. </sql>
  43. <sql id="amountWaterusedamountJoins">
  44. inner join sc_device d on a.watermeter_id = d.id
  45. left join pay_sys_dict c on c.`value` = a.state and c.type ='水量状态'
  46. <if test="customerId!= null" >AND c.customer_id = #{customerId}</if>
  47. <if test="siteId!= null" > and c.site_id = #{siteId} </if>
  48. </sql>
  49. <select id="get" resultType="com.bz.smart_city.entity.pay.AmountWaterUsedAmount">
  50. SELECT
  51. <include refid="amountWaterusedamountColumns"/>
  52. FROM pay_amount_waterusedamount a
  53. <include refid="amountWaterusedamountJoins"/>
  54. WHERE a.id = #{id}
  55. </select>
  56. <select id="getList" resultType="com.bz.smart_city.dto.pay.AmountWaterUsedAmountDto">
  57. SELECT
  58. <include refid="amountWaterusedamountColumns"/>
  59. FROM pay_amount_waterusedamount a
  60. <include refid="amountWaterusedamountJoins"/>
  61. <where>
  62. a.customer_id = #{customerId}
  63. <if test="siteId!= null" > and a.site_id = #{siteId} </if>
  64. <choose>
  65. <when test="condition != null and condition !=''">
  66. and
  67. (
  68. a.accountnumber like concat('%',#{condition} ,'%')
  69. or a.metercode like concat('%',#{condition} ,'%')
  70. or d.water_meter_no like concat('%',#{condition} ,'%')
  71. )
  72. </when>
  73. <otherwise>
  74. <if test="accountnumber!= null and accountnumber !=''" > and a.accountnumber = #{accountnumber} </if>
  75. <if test="metercode!= null and metercode !=''" > and a.metercode = #{metercode} </if>
  76. </otherwise>
  77. </choose>
  78. <if test ="year != null and month != null">
  79. and a.year = #{year} and a.month = #{month}
  80. </if>
  81. <if test="state!= null" > and a.state = #{state} </if>
  82. <if test="amountMin != null"> and a.payamount >= #{amountMin} </if>
  83. <if test="amountMax != null"> and a.payamount <![CDATA[ <= ]]> #{amountMax} </if>
  84. <if test="programItems != null and programItems.size() != 0">
  85. and
  86. <foreach collection="programItems" item="item" open="(" separator=" or " close=")">
  87. <if test="item.dimensionId == 10">
  88. a.${item.dimensionCode} = #{item.dimensionValue}
  89. </if>
  90. </foreach>
  91. </if>
  92. </where>
  93. order by a.recorddate desc
  94. </select>
  95. <update id="update">
  96. UPDATE pay_amount_waterusedamount SET
  97. amount = #{amountWaterUsedAmount.amount},
  98. approver_id = #{amountWaterUsedAmount.approverId},
  99. approvetime = #{amountWaterUsedAmount.approvetime},
  100. customerandmeterrela_id = #{amountWaterUsedAmount.customerandmeterrelaId},
  101. office_id = #{amountWaterUsedAmount.officeId},
  102. lastreading = #{amountWaterUsedAmount.lastreading},
  103. lastrecorddate = #{amountWaterUsedAmount.lastrecorddate},
  104. metercode = #{amountWaterUsedAmount.metercode},
  105. watermeter_id = #{amountWaterUsedAmount.watermeterId},
  106. month = #{amountWaterUsedAmount.month},
  107. payamount = #{amountWaterUsedAmount.payamount},
  108. reading = #{amountWaterUsedAmount.reading},
  109. recorddate = #{amountWaterUsedAmount.recorddate},
  110. state = #{amountWaterUsedAmount.state},
  111. waterproperty_id = #{amountWaterUsedAmount.waterpropertyId},
  112. year = #{amountWaterUsedAmount.year},
  113. account_id = #{amountWaterUsedAmount.accountId},
  114. accountname = #{amountWaterUsedAmount.accountname},
  115. accountnumber = #{amountWaterUsedAmount.accountnumber},
  116. address = #{amountWaterUsedAmount.address},
  117. watertype = #{amountWaterUsedAmount.watertype},
  118. update_by = #{amountWaterUsedAmount.updateBy},
  119. update_date = #{amountWaterUsedAmount.updateDate},
  120. remarks = #{amountWaterUsedAmount.remarks},
  121. ele_no = #{amountWaterUsedAmount.eleNo},
  122. isprint = #{amountWaterUsedAmount.isprint},
  123. iswxsend = #{amountWaterUsedAmount.iswxsend},
  124. sendwxdate =#{amountWaterUsedAmount.sendwxdate}
  125. WHERE id = #{amountWaterUsedAmount.id}
  126. </update>
  127. <select id="getWaterUsedAmountByMeterId" resultType="com.bz.smart_city.dto.pay.AmountWaterUsedAmountDto">
  128. select a.create_date,w.install_time installdate,a.year,a.month
  129. from sc_install_list w
  130. left join pay_amount_waterusedamount a on a.watermeter_id = w.device_id
  131. where w.device_id = #{waterMeterId}
  132. order by a.year desc,a.month desc
  133. </select>
  134. <select id ="getIds" resultType="java.lang.String">
  135. SELECT
  136. a.id AS "id"
  137. FROM pay_amount_waterusedamount a
  138. <include refid="amountWaterusedamountJoins"/>
  139. <where>
  140. a.reading is not null
  141. and a.reading >= a.lastreading
  142. <if test="customerId!= null" >and a.customer_id = #{customerId} </if>
  143. <if test="siteId!= null" > and a.site_id = #{siteId} </if>
  144. <choose>
  145. <when test="condition != null and condition !=''">
  146. and (a.accountname like concat('%',#{condition} ,'%') or a.accountnumber like concat('%',#{condition} ,'%') or a.metercode like concat('%',#{condition} ,'%') or a.address like concat('%',#{condition} ,'%'))
  147. </when>
  148. <otherwise>
  149. <if test="accountname!= null and accountname !=''" > and a.accountname = #{accountname} </if>
  150. <if test="accountnumber!= null and accountnumber !=''" > and a.accountnumber = #{accountnumber} </if>
  151. <if test="metercode!= null and metercode !=''" > and a.metercode = #{metercode} </if>
  152. <if test="address!= null and address !=''" > and a.address = #{address} </if>
  153. </otherwise>
  154. </choose>
  155. <if test ="year != null and month != null">
  156. and a.year = #{year} and a.month = #{month}
  157. </if>
  158. <if test="state!= null" > and a.state = #{state} </if>
  159. <if test="amountMin != null"> and a.payamount >= #{amountMin} </if>
  160. <if test="amountMax != null"> and a.payamount <![CDATA[ <= ]]> #{amountMax} </if>
  161. <if test="programItems != null and programItems.size() != 0">
  162. and
  163. <foreach collection="programItems" item="item" open="(" separator=" or " close=")">
  164. <if test="item.dimensionId == 10">
  165. a.${item.dimensionCode} = #{item.dimensionValue}
  166. </if>
  167. </foreach>
  168. </if>
  169. </where>
  170. </select>
  171. <select id = "getCustId" resultType="java.lang.Integer">
  172. select customerId from pay_base_customerandmeterrela a group by a.customer_id
  173. </select>
  174. <select id="getAllAmountCount" resultType="java.lang.Integer">
  175. select count(1) as num
  176. from pay_base_customerandmeterrela rela
  177. left join pay_amount_waterusedamount amount on amount.watermeter_id = rela.watermeter_id
  178. and amount.year=#{year} and amount.month=#{month}
  179. where rela.businessstate=1 and amount.id is null
  180. <if test="customerId!= null" >and rela.customer_id = #{customerId} </if>
  181. <if test="siteId!= null" > and rela.site_id = #{siteId} </if>
  182. </select>
  183. <select id="getAllAmountCountByDay" resultType="java.lang.Integer">
  184. select count(1) as num
  185. from pay_base_customerandmeterrela rela
  186. left join pay_amount_waterusedamount_day amount on amount.watermeter_id = rela.watermeter_id
  187. and amount.read_date =DATE_FORMAT(DATE_SUB(now(),INTERVAL 1 day) ,'%Y%m%d')
  188. where rela.businessstate=1 and amount.id is null
  189. <if test="customerId!= null" >and rela.customer_id = #{customerId} </if>
  190. <if test="siteId!= null" > and rela.site_id = #{siteId} </if>
  191. </select>
  192. <select id="getAllAmountRecord" resultType="com.bz.smart_city.dto.pay.AmountWaterUsedAmountDto">
  193. select amount.id,
  194. amount.lastreading,
  195. amount.ele_no eleNo,
  196. rela.calculateway,
  197. rela.fixedamount,
  198. amount.watermeter_id watermeterId,
  199. amount.recorddate,
  200. rela.id customerandmeterrelaId,
  201. amount.waterproperty_id waterpropertyId,
  202. rela.account_id as accountId,
  203. amount.lastrecorddate
  204. from pay_amount_waterusedamount amount
  205. inner join pay_base_customerandmeterrela rela on rela.id= amount.customerandmeterrela_id
  206. where amount.year=#{year} and amount.month=#{month}
  207. and amount.reading is null and amount.payamount is null
  208. <if test="customerId!= null" > and rela.customer_id =#{customerId}</if>
  209. <if test="siteId!= null" > and rela.site_id = #{siteId} </if>
  210. </select>
  211. <insert id ="createdAmount" useGeneratedKeys="false">
  212. INSERT INTO pay_amount_waterusedamount
  213. (customerandmeterrela_id, office_id, lastreading, lastrecorddate, metercode,
  214. watermeter_id, month, payamount, reading, recorddate, amount, state,
  215. waterproperty_id, year, account_id, accountname, accountnumber, address,
  216. watertype, isprint, ele_no, iswxsend, sendwxdate, create_by, create_date,
  217. update_by, update_date, remarks, del_flag, site_id, customer_id)
  218. SELECT
  219. c.id,c.office_id,
  220. ROUND(ifnull(lastwua.reading, IFNULL(d.new_meter_start,0)),2),
  221. ifnull(lastwua.recorddate,ifnull(d.install_time,d.date_create)),c.metercode,
  222. c.watermeter_id,#{month},null,null,null,NULL,1,
  223. c.waterproperty_id,#{year},c.account_id,c.accountname,c.accountnumber,c.address,
  224. c.watertype,null,d.electronic_no,null,null,1,NOW(),
  225. 1,now(),'批量生成抄表计划',0,c.site_id,c.customer_id
  226. FROM
  227. pay_base_customerandmeterrela c
  228. left join sc_install_list d on d.device_id =c.watermeter_id
  229. LEFT JOIN pay_amount_waterusedamount amount ON amount.watermeter_id = c.watermeter_id
  230. AND amount.YEAR = #{year}
  231. AND amount.MONTH = #{month}
  232. LEFT JOIN (
  233. SELECT
  234. oldwua.watermeter_id,
  235. oldwua.reading,
  236. oldwua.recorddate
  237. FROM
  238. (
  239. SELECT
  240. max(
  241. waterusedamount.create_date
  242. ) AS create_date,
  243. waterusedamount.watermeter_id
  244. FROM
  245. pay_amount_waterusedamount waterusedamount
  246. WHERE
  247. waterusedamount.state = 2
  248. GROUP BY
  249. waterusedamount.watermeter_id
  250. ) lastid
  251. LEFT JOIN pay_amount_waterusedamount oldwua ON lastid.create_date = oldwua.create_date
  252. AND oldwua.watermeter_id = lastid.watermeter_id
  253. ) lastwua ON c.watermeter_id = lastwua.watermeter_id
  254. WHERE
  255. c.businessstate = 1
  256. AND amount.id IS NULL
  257. <if test="customerId!= null" >AND c.customer_id = #{customerId}</if>
  258. <if test="siteId!= null" > and c.site_id = #{siteId} </if>
  259. limit 500
  260. </insert>
  261. <update id="batchUpdate">
  262. UPDATE pay_amount_waterusedamount SET
  263. amount = #{amountWaterUsedAmount.amount},
  264. payamount = #{amountWaterUsedAmount.payamount},
  265. reading = #{amountWaterUsedAmount.reading},
  266. recorddate = #{amountWaterUsedAmount.recorddate},
  267. update_date = #{amountWaterUsedAmount.updateDate}
  268. WHERE id = #{amountWaterUsedAmount.id}
  269. </update>
  270. <insert id ="createdAmountByDay" useGeneratedKeys="false">
  271. INSERT INTO pay_amount_waterusedamount_day (
  272. customerandmeterrela_id,
  273. office_id,
  274. lastreading,
  275. lastrecorddate,
  276. metercode,
  277. watermeter_id,
  278. payamount,
  279. reading,
  280. recorddate,
  281. amount,
  282. waterproperty_id,
  283. account_id,
  284. create_by,
  285. create_date,
  286. update_by,
  287. update_date,
  288. remarks,
  289. del_flag,
  290. site_id,
  291. customer_id,
  292. read_date,
  293. debt
  294. ) SELECT
  295. c.id,
  296. c.office_id,
  297. ROUND(ifnull( lastwua.reading, ifnull(sil.new_meter_start,0) ),2),
  298. ifnull( lastwua.recorddate, c.create_date ),
  299. c.metercode,
  300. c.watermeter_id,
  301. NULL,
  302. NULL,
  303. NULL,
  304. NULL,
  305. c.waterproperty_id,
  306. c.account_id,
  307. 1,
  308. NOW(),
  309. 1,
  310. now(),
  311. '每天抄表计划',
  312. 0,
  313. c.site_id,
  314. c.customer_id,
  315. DATE_FORMAT( DATE_SUB( now(), INTERVAL 1 DAY ), '%Y%m%d' ),
  316. NULL
  317. FROM
  318. pay_base_customerandmeterrela c
  319. LEFT JOIN sc_install_list sil ON sil.device_id = c.watermeter_id
  320. LEFT JOIN pay_amount_waterusedamount_day amount ON amount.watermeter_id = c.watermeter_id
  321. AND amount.read_date = DATE_FORMAT( DATE_SUB( now(), INTERVAL 1 DAY ), '%Y%m%d' )
  322. LEFT JOIN (
  323. SELECT
  324. oldwua.watermeter_id,
  325. oldwua.reading,
  326. oldwua.recorddate
  327. FROM
  328. (
  329. SELECT
  330. max( waterusedamount.create_date ) AS create_date,
  331. waterusedamount.watermeter_id
  332. FROM
  333. pay_amount_waterusedamount waterusedamount
  334. WHERE
  335. waterusedamount.state = 2
  336. GROUP BY
  337. waterusedamount.watermeter_id
  338. ) lastid
  339. LEFT JOIN pay_amount_waterusedamount oldwua ON lastid.create_date = oldwua.create_date
  340. AND oldwua.watermeter_id = lastid.watermeter_id
  341. ) lastwua ON c.watermeter_id = lastwua.watermeter_id
  342. WHERE
  343. c.businessstate = 1
  344. AND amount.id IS NULL
  345. <if test="customerId!= null" >AND c.customer_id = #{customerId}</if>
  346. <if test="siteId!= null" > and c.site_id = #{siteId} </if>
  347. limit 500
  348. </insert>
  349. <resultMap id="MeterReadRecordResultMap" type="com.bz.smart_city.dto.pay.MeterReadRecordDto">
  350. <result column="device_id" property="deviceId" />
  351. <result column="read_time" property="readTime" />
  352. <result column="read_data" property="readData" />
  353. </resultMap>
  354. <select id ="getMeterReadRecord" resultMap="MeterReadRecordResultMap">
  355. select
  356. a.device_id,
  357. a.read_data,
  358. a.read_time
  359. from sc_meter_read_record a
  360. <where>
  361. a.read_date=DATE_FORMAT(DATE_SUB(now(),INTERVAL 1 day) ,'%Y%m%d')
  362. and a.device_id in
  363. <foreach collection="list" item="listItem" open="(" close=")" separator=",">
  364. <if test="listItem != null and listItem != ''">
  365. #{listItem}
  366. </if>
  367. </foreach>
  368. </where>
  369. </select>
  370. <update id="updateByDate">
  371. UPDATE pay_amount_waterusedamount_day SET
  372. amount = #{amountWaterUsedAmount.amount},
  373. payamount = #{amountWaterUsedAmount.payamount},
  374. reading = #{amountWaterUsedAmount.reading},
  375. recorddate = #{amountWaterUsedAmount.recorddate},
  376. update_date = #{amountWaterUsedAmount.updateDate}
  377. WHERE id = #{amountWaterUsedAmount.id}
  378. </update>
  379. <resultMap id="AmountWaterUsedAmountByDayResultMap" type="com.bz.smart_city.entity.pay.AmountWaterUsedAmountByDay">
  380. <result column="device_id" property="watermeterId" />
  381. <result column="watermeter_id" property="id" />
  382. </resultMap>
  383. <select id ="getAmountWaterUsedAmountByDay" resultMap="AmountWaterUsedAmountByDayResultMap">
  384. select
  385. a.id,
  386. a.watermeter_id
  387. from pay_amount_waterusedamount_day a
  388. <where>
  389. a.read_date=DATE_FORMAT(DATE_SUB(now(),INTERVAL 1 day) ,'%Y%m%d')
  390. <if test="customerId!= null" >and a.customer_id = #{customerId} </if>
  391. <if test="siteId!= null" > and a.site_id = #{siteId} </if>
  392. </where>
  393. </select>
  394. <select id="getAllAmountRecordByDay" resultType="com.bz.smart_city.entity.pay.AmountWaterUsedAmountByDay">
  395. select amount.id,
  396. amount.lastreading,
  397. amount.lastrecorddate,
  398. rela.calculateway,
  399. rela.fixedamount,
  400. amount.watermeter_id watermeterId,
  401. amount.recorddate,
  402. rela.id customerandmeterrelaId,
  403. amount.waterproperty_id waterpropertyId,
  404. rela.account_id as accountId
  405. from pay_amount_waterusedamount_day amount
  406. inner join pay_base_customerandmeterrela rela on rela.id= amount.customerandmeterrela_id
  407. where amount.read_date =DATE_FORMAT(DATE_SUB(now(),INTERVAL 1 day) ,'%Y%m%d')
  408. and amount.reading is null
  409. <if test="customerId!= null" > and rela.customer_id =#{customerId}</if>
  410. <if test="siteId!= null" > and rela.site_id = #{siteId} </if>
  411. </select>
  412. <select id="getWaterMeterIdByDay" resultType="java.math.BigInteger">
  413. select
  414. amount.watermeter_id
  415. from pay_amount_waterusedamount_day amount
  416. where amount.read_date =DATE_FORMAT(DATE_SUB(now(),INTERVAL 1 day) ,'%Y%m%d')
  417. and amount.reading is null
  418. <if test="customerId!= null" > and amount.customer_id =#{customerId}</if>
  419. <if test="siteId!= null" > and amount.site_id = #{siteId} </if>
  420. </select>
  421. <select id="getCustIdAndSiteId" resultType="com.bz.smart_city.entity.pay.archives.PayBaseCustomerandmeterrela">
  422. select
  423. c.customer_id customerId,
  424. c.site_id siteId
  425. from pay_base_customerandmeterrela c
  426. where c.businessstate =1
  427. and c.customer_id is not null and c.site_id is not null
  428. group by c.customer_id, c.site_id
  429. </select>
  430. <resultMap id="ReplaceMeterMap" type="com.bz.smart_city.dto.pay.ReplaceMeterDto">
  431. </resultMap>
  432. <select id ="getRepalceRecord" resultMap="ReplaceMeterMap">
  433. SELECT
  434. pc.device_id AS deviceId,
  435. pc.date_create AS replaceTime,
  436. pc.new_begin_wsv AS newBegin,
  437. pc.old_end_wsv AS oldEnd
  438. FROM
  439. (
  440. SELECT
  441. pc2.id,
  442. MAX( pc2.date_create ) AS dateCreate
  443. FROM
  444. sc_water_meter_replace_log pc2
  445. <where>
  446. <if test="list != null and list.size() != 0">
  447. pc2.device_id IN
  448. <foreach collection="list" item="listItem" open="(" close=")" separator=",">
  449. <if test="listItem != null and listItem != ''">
  450. #{listItem}
  451. </if>
  452. </foreach>
  453. </if>
  454. </where>
  455. GROUP BY
  456. pc2.id
  457. ) a
  458. LEFT JOIN sc_water_meter_replace_log pc ON a.id = pc.id
  459. </select>
  460. <resultMap id="ReplaceMeterCountMap" type="com.bz.smart_city.dto.pay.ReplaceMeterCountDto">
  461. </resultMap>
  462. <select id="getRepalceRecordCount" resultMap="ReplaceMeterCountMap">
  463. SELECT
  464. COUNT(*) as number,
  465. pc.device_id AS deviceId
  466. FROM sc_water_meter_replace_log pc LEFT JOIN sc_device scd on pc.device_id = scd.id
  467. <where>
  468. <if test="stTime != null"> and pc.date_create >= #{stTime,jdbcType=TIMESTAMP}</if>
  469. <if test="etTime != null"> and pc.date_create &lt;= #{etTime,jdbcType=TIMESTAMP}</if>
  470. <if test="siteId != null"> and scd.site_id = #{siteId}</if>
  471. <if test="customerId != null"> and scd.customer_id = #{customerId}</if>
  472. <if test="list != null and list.size() != 0">
  473. and pc.device_id IN
  474. <foreach collection="list" item="listItem" open="(" close=")" separator=",">
  475. <if test="listItem != null and listItem != ''">
  476. #{listItem}
  477. </if>
  478. </foreach>
  479. </if>
  480. </where>
  481. GROUP BY pc.device_id
  482. </select>
  483. <select id ="getRepalceRecordDetail" resultType="com.bz.smart_city.dto.pay.ReplaceMeterDto">
  484. SELECT
  485. pc.device_id AS deviceId,
  486. pc.date_create AS replaceTime,
  487. pc.new_begin_wsv AS newBegin,
  488. pc.old_end_wsv AS oldEnd
  489. FROM
  490. sc_water_meter_replace_log pc LEFT JOIN sc_device scd on pc.device_id = scd.id
  491. <where>
  492. <if test="stTime != null"> and pc.date_create >= #{stTime,jdbcType=TIMESTAMP}</if>
  493. <if test="etTime != null"> and pc.date_create &lt;= #{etTime,jdbcType=TIMESTAMP}</if>
  494. <if test="siteId != null"> and scd.site_id = #{siteId}</if>
  495. <if test="customerId != null"> and scd.customer_id = #{customerId}</if>
  496. <if test="list != null and list.size() != 0">
  497. and pc.device_id IN
  498. <foreach collection="list" item="listItem" open="(" close=")" separator=",">
  499. <if test="listItem != null and listItem != ''">
  500. #{listItem}
  501. </if>
  502. </foreach>
  503. </if>
  504. </where>
  505. </select>
  506. <select id="getwaterUserdAmount" resultType="java.lang.Integer">
  507. select
  508. amount.state from pay_amount_waterusedamount amount
  509. where amount.account_id =#{id} and amount.year =#{year} and amount.month =#{month}
  510. </select>
  511. </mapper>