PayBaseCustomerandmeterrelaMapper.xml 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673
  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.archives.PayBaseCustomerandmeterrelaMapper">
  4. <sql id="sqlColumns">
  5. </sql>
  6. <resultMap id="BaseResultMap" type="com.bz.smart_city.entity.pay.archives.PayBaseCustomerandmeterrela">
  7. <!--@mbg.generated-->
  8. <id column="id" property="id" />
  9. <id column="metercode" property="metercode"/>
  10. <result column="remarks" property="remarks" />
  11. <result column="create_by" property="createBy" />
  12. <result column="update_by" property="updateBy" />
  13. <result column="customer_id" property="customerId" />
  14. </resultMap>
  15. <sql id="sqlJoins">
  16. </sql>
  17. <select id="queryDevice" resultMap="BaseResultMap" resultType="com.bz.smart_city.entity.pay.archives.PayBaseCustomerandmeterrela">
  18. select id as "id",water_meter_no as "metercode" from sc_device LIMIT 1
  19. </select>
  20. <select id="findList" resultType="com.bz.smart_city.entity.pay.archives.PayBaseCustomerandmeterrela">
  21. select
  22. customer.id as "id",
  23. customer.watermeter_id as "watermeterId",
  24. account.id as "accountId",
  25. account.accountnumber as "accountnumber",
  26. customer.office_id as "officeId",
  27. account.name as "name",
  28. account.telephone as "telephone",
  29. customer.metercode as "metercode",
  30. pro.name as "propertyName",
  31. account.address as "address",
  32. customer.opendate as "opendate",
  33. customer.businessstate as "businessstate",
  34. customer.calculateway as "calculateway",
  35. pro.id as "waterPropertyId"
  36. from pay_base_customerandmeterrela customer
  37. left join pay_base_account account on customer.account_id = account.id
  38. left join pay_base_waterproperty pro on pro.id = customer.waterproperty_id
  39. <where>
  40. <if test="id != null">
  41. and customer.id =#{id}
  42. </if>
  43. <if test="metercode != null">
  44. and customer.metercode =#{metercode}
  45. </if>
  46. <if test="siteId != null">
  47. and customer.site_id = #{siteId}
  48. </if>
  49. <if test="customerId != null">
  50. and customer.customer_id = #{customerId}
  51. </if>
  52. order by customer.create_date desc
  53. </where>
  54. </select>
  55. <select id="getAccountId" resultType="com.bz.smart_city.entity.pay.PayBaseAccount">
  56. select
  57. id as "id"
  58. from pay_base_account
  59. <where>
  60. <if test="siteId != null">
  61. and site_id = #{siteId}
  62. </if>
  63. <if test="customerId != null">
  64. and customer_id = #{customerId}
  65. </if>
  66. <if test="accountnumber">
  67. and accountnumber =#{accountnumber}
  68. </if>
  69. order by create_date desc
  70. </where>
  71. </select>
  72. <select id="getDeviceId" resultType="com.bz.smart_city.entity.pay.archives.PayBaseCustomerandmeterrela" >
  73. select
  74. id as "id"
  75. from sc_device
  76. <where>
  77. <!--<if test="siteId != null">
  78. and site_id = #{siteId}
  79. </if>-->
  80. <if test="customerId != null">
  81. and customer_id = #{customerId}
  82. </if>
  83. <if test="metercode != null">
  84. and metercode =#{metercode}
  85. </if>
  86. </where>
  87. limit 1
  88. </select>
  89. <select id="getWaterPropertyId" resultType="com.bz.smart_city.entity.pay.archives.PayBaseCustomerandmeterrela">
  90. select id as "waterPropertyId"
  91. from pay_base_waterproperty
  92. <where>
  93. <if test="siteId != null">
  94. and site_id = #{siteId}
  95. </if>
  96. <if test="customerId != null">
  97. and customer_id = #{customerId}
  98. </if>
  99. <if test="name != null">
  100. and name =#{name}
  101. </if>
  102. order by create_date desc
  103. </where>
  104. </select>
  105. <insert id="insertList">
  106. INSERT INTO pay_base_customerandmeterrela
  107. (
  108. id,
  109. account_id,
  110. watermeter_id,
  111. accountname,
  112. accountnumber,
  113. metercode,
  114. businessstate,
  115. office_id,
  116. housetype,
  117. calculateway,
  118. customercategory,
  119. customergroup,
  120. fixedamount,
  121. vatno,
  122. bankaccount,
  123. invoicetitle,
  124. address,
  125. opendate,
  126. waterproperty_id,
  127. watertype,
  128. canceldate,
  129. create_by,
  130. create_date,
  131. update_by,
  132. update_date,
  133. remarks,
  134. del_flag,
  135. site_id,
  136. customer_id
  137. )
  138. values
  139. <foreach collection="customers" item="customer" index="index" separator=",">
  140. (
  141. #{customer.id,jdbcType=BIGINT},
  142. #{customer.accountId,jdbcType=BIGINT},
  143. #{customer.watermeterId,jdbcType=BIGINT},
  144. #{customer.accountname,jdbcType=VARCHAR},
  145. #{customer.accountnumber,jdbcType=VARCHAR},
  146. #{customer.metercode,jdbcType=VARCHAR},
  147. #{customer.businessstate,jdbcType=INTEGER},
  148. #{customer.officeId,jdbcType=BIGINT},
  149. #{customer.housetype,jdbcType=INTEGER},
  150. #{customer.calculateway,jdbcType=INTEGER},
  151. #{customer.customercategory,jdbcType=INTEGER},
  152. #{customer.customergroup,jdbcType=INTEGER},
  153. #{customer.fixedamount,jdbcType=VARCHAR},
  154. #{customer.vatno,jdbcType=VARCHAR},
  155. #{customer.bankaccount,jdbcType=VARCHAR},
  156. #{customer.invoicetitle,jdbcType=VARCHAR},
  157. #{customer.address,jdbcType=VARCHAR},
  158. #{customer.opendate,jdbcType=TIMESTAMP},
  159. #{customer.waterPropertyId,jdbcType=BIGINT},
  160. #{customer.watertype,jdbcType=INTEGER},
  161. #{customer.canceldate,jdbcType=TIMESTAMP},
  162. #{customer.createBy,jdbcType=VARCHAR},
  163. #{customer.createDate,jdbcType=TIMESTAMP},
  164. #{customer.updateBy,jdbcType=VARCHAR},
  165. #{customer.updateDate,jdbcType=TIMESTAMP},
  166. #{customer.remarks,jdbcType=VARCHAR},
  167. #{customer.delFlag,jdbcType=VARCHAR},
  168. #{customer.siteId,jdbcType=BIGINT},
  169. #{customer.customerId,jdbcType=BIGINT}
  170. )
  171. </foreach>
  172. </insert>
  173. <update id="update">
  174. update pay_base_customerandmeterrela
  175. <set>
  176. <if test="accountId != null">account_id =#{accountId},</if>
  177. <if test="watermeterId != null">watermeter_id =#{watermeterId},</if>
  178. <if test="accountname != null">accountname =#{accountname},</if>
  179. <if test="accountnumber != null">accountnumber =#{accountnumber},</if>
  180. <if test="metercode != null">metercode =#{metercode},</if>
  181. <if test="businessstate != null">businessstate =#{businessstate},</if>
  182. <if test="officeId != null">office_id =#{officeId},</if>
  183. <if test="housetype != null">housetype =#{housetype},</if>
  184. <if test="calculateway != null">calculateway =#{calculateway},</if>
  185. <if test="customercategory != null">customercategory =#{customercategory},</if>
  186. <if test="customergroup != null">customergroup =#{customergroup},</if>
  187. <if test="fixedamount != null">fixedamount =#{fixedamount},</if>
  188. <if test="vatno != null">vatno =#{vatno},</if>
  189. <if test="bankaccount != null">bankaccount =#{bankaccount},</if>
  190. <if test="address != null">address =#{address},</if>
  191. <if test="opendate != null">opendate =#{opendate},</if>
  192. <if test="waterPropertyId != null">waterproperty_id =#{waterPropertyId},</if>
  193. <if test="watertype != null">watertype =#{watertype},</if>
  194. <if test="canceldate != null">canceldate =#{canceldate},</if>
  195. <if test="updateBy != null">update_by =#{updateBy},</if>
  196. <if test="updateDate != null">update_date =#{updateDate},</if>
  197. </set>
  198. <where>
  199. <if test="id != null">id =#{id}</if>
  200. </where>
  201. </update>
  202. <select id="meterAllDebt" resultType="java.lang.Double">
  203. select ifnull(sum(debt),0) debt from pay_pay_receivable r where r.meter_id=#{meterid}
  204. </select>
  205. <select id="findByAccount" resultType="com.bz.smart_city.entity.pay.PayPayRechargeaccount">
  206. select
  207. rech.*
  208. from pay_pay_rechargeaccount rech
  209. <where>
  210. <if test="accountId != null">
  211. and rech.account_id =#{accountId}
  212. </if>
  213. order by rech.create_date desc
  214. </where>
  215. </select>
  216. <update id="updateCustomerState">
  217. update pay_base_customerandmeterrela set businessstate =#{state},update_by=#{updateBy},update_date =#{date},canceldate =#{date}
  218. where site_id =#{siteId} and customer_id =#{customerId} and id =#{id}
  219. </update>
  220. <update id="updateDeviceState">
  221. update sc_device set status =#{state},update_by=#{updateBy},date_update =#{date}
  222. where site_id =#{siteId} and customer_id =#{customerId} and metercode =#{metercode}
  223. </update>
  224. <select id="getAll" resultType="com.bz.smart_city.dto.pay.PayCustomerDto">
  225. select
  226. customer.fixedamount as "fixedamount",
  227. customer.id as "id",
  228. account.accountnumber as "accountnumber",
  229. account.name as "accountname",
  230. account.telephone as "telephone",
  231. customer.metercode as "metercode",
  232. device.water_meter_no as "metereleno",
  233. property.id as "waterPropertyId",
  234. property.name as "waterPropertyName",
  235. account.address as "address",
  236. customer.opendate as "opendate",
  237. customer.office_id as "officeId",
  238. account.email,
  239. customer.vatno,
  240. customer.businessstate as "businessstate",
  241. (select label from pay_sys_dict where type = '开户状态' and value = customer.businessstate and site_id = #{siteId} and customer_id =#{customerId}) as "businessName",
  242. customer.calculateway as "calculateway",
  243. (select label from pay_sys_dict where type = '结算方式' and value = customer.calculateway and site_id = #{siteId} and customer_id =#{customerId}) as "calculatewayName",
  244. account.idtype as "idtype",
  245. (select label from pay_sys_dict where type = '证件类型' and value = account.idtype and site_id = #{siteId} and customer_id =#{customerId}) as "idtypeName",
  246. account.idcardno as "idcardno",
  247. customer.housetype as "housetype",
  248. (select label from pay_sys_dict where type = '住房类型' and value = customer.housetype and site_id = #{siteId} and customer_id =#{customerId}) as "housetypeName",
  249. customer.customergroup as "customergroup",
  250. (select label from pay_sys_dict where type = '开户分组' and value = customer.customergroup and site_id = #{siteId} and customer_id =#{customerId}) as "customergroupName"
  251. from pay_base_customerandmeterrela customer
  252. left join sc_device device on customer.watermeter_id = device.id
  253. left join pay_base_account account on account.id = customer.account_id
  254. left join pay_base_waterproperty property on property.id = customer.waterproperty_id
  255. <where>
  256. <if test="siteId != null">
  257. and customer.site_id = #{siteId}
  258. </if>
  259. <if test="customerId != null">
  260. and customer.customer_id = #{customerId}
  261. </if>
  262. <if test="condition != null">
  263. and
  264. (
  265. account.accountnumber like concat('%',#{condition},'%')
  266. or account.name like concat('%',#{condition},'%')
  267. or customer.metercode like concat('%',#{condition},'%')
  268. or account.address like concat('%',#{condition},'%')
  269. or account.telephone like concat('%',#{condition},'%')
  270. or device.water_meter_no like concat('%',#{condition},'%')
  271. )
  272. </if>
  273. <if test="waterPropertyId != null">
  274. and property.id =#{waterPropertyId}
  275. </if>
  276. <if test="businessstate != null">
  277. and customer.businessstate =#{businessstate}
  278. </if>
  279. <if test="calculateway != null">
  280. and customer.calculateway =#{calculateway}
  281. </if>
  282. <if test="programItems != null and programItems.size() != 0">
  283. and <foreach collection="programItems" item="item" open="(" separator=" or " close=")">
  284. <if test="item.dimensionId == 10">
  285. customer.office_id = #{item.dimensionValue}
  286. </if>
  287. </foreach>
  288. </if>
  289. order by customer.create_date desc
  290. </where>
  291. </select>
  292. <select id="getList" resultType="com.bz.smart_city.entity.pay.archives.PayBaseCustomerandmeterrela">
  293. select
  294. account.accountnumber as "accountnumber",
  295. account.name as "accountname",
  296. account.telephone as "telephone",
  297. customer.metercode as "metercode",
  298. property.name as "propertyName",
  299. device.loc_desc as "address",
  300. customer.opendate as "opendate",
  301. customer.businessstate as "businessstate",
  302. customer.calculateway as "calculateway",
  303. device.water_meter_no as "metereleno"
  304. from pay_base_customerandmeterrela customer
  305. left join pay_base_account account on account.id = customer.account_id
  306. left join pay_base_waterproperty property on property.id = customer.waterproperty_id
  307. inner join sc_device device on device.metercode = customer.metercode
  308. <where>
  309. <if test="siteId != null">
  310. and customer.site_id = #{siteId}
  311. </if>
  312. <if test="customerId != null">
  313. and customer.customer_id = #{customerId}
  314. </if>
  315. <if test="condition != null">
  316. and
  317. (
  318. account.accountnumber like concat('%',#{condition},'%')
  319. or account.name like concat('%',#{condition},'%')
  320. or customer.metercode like concat('%',#{condition},'%')
  321. or account.address like concat('%',#{condition},'%')
  322. or account.telephone like concat('%',#{condition},'%')
  323. or device.water_meter_no like concat('%',#{condition},'%')
  324. )
  325. </if>
  326. <if test="waterPropertyId != null">
  327. and property.id =#{waterPropertyId}
  328. </if>
  329. <if test="businessstate != null">
  330. and customer.businessstate =#{businessstate}
  331. </if>
  332. <if test="calculateway != null">
  333. and customer.calculateway =#{calculateway}
  334. </if>
  335. order by customer.create_date desc
  336. </where>
  337. </select>
  338. <select id="queryNoOpenAccount" resultType="com.bz.smart_city.entity.pay.archives.DeviceListInfo">
  339. select
  340. account.accountnumber as "accountnumber"
  341. from pay_base_account account
  342. <where>
  343. <if test="siteId != null">
  344. and account.site_id = #{siteId}
  345. </if>
  346. <if test="customerId != null">
  347. and account.customer_id = #{customerId}
  348. </if>
  349. order by account.create_date desc
  350. </where>
  351. </select>
  352. <select id="selectAccountInfo" resultType="com.bz.smart_city.entity.pay.archives.MeterListInfo">
  353. select
  354. device.metercode as "metercode",
  355. sil.user_name as accountname,
  356. sil.user_phone as telephone,
  357. sil.id_card as idcardno
  358. from pay_base_account account
  359. inner join sc_device device on account.id = device.account_id
  360. inner join sc_install_list sil on sil.device_id = device.id
  361. <where>
  362. device.metercode not in(select metercode from pay_base_customerandmeterrela where businessstate = '1')
  363. <if test="accountnumber != null">
  364. and account.accountnumber =#{accountnumber}
  365. </if>
  366. <!-- <if test="siteId != null">
  367. and account.site_id = #{siteId}
  368. </if>-->
  369. <if test="customerId != null">
  370. and account.customer_id = #{customerId}
  371. </if>
  372. order by account.create_date desc
  373. </where>
  374. </select>
  375. <select id="selectAccountMeterInfo" resultType="com.bz.smart_city.entity.pay.archives.PayAccountInfo">
  376. select
  377. account.accountnumber as "accountnumber",
  378. account.calculateway as "calculateway",
  379. account.waterproperty_id as "waterPropertyId",
  380. device.metercode as "metercode",
  381. sil.user_name as accountname,
  382. sil.user_phone as telephone,
  383. sil.id_card as idcardno,
  384. device.water_meter_no as "metereleno"
  385. from pay_base_account account
  386. inner join sc_device device on account.id = device.account_id
  387. inner join sc_install_list sil on sil.device_id = device.id
  388. <where>
  389. device.metercode not in(select metercode from pay_base_customerandmeterrela where businessstate = '1')
  390. <if test="metercode != null">
  391. and device.metercode like concat('%',#{metercode},'%')
  392. </if>
  393. <!--<if test="siteId != null">
  394. and account.site_id = #{siteId}
  395. </if>-->
  396. <if test="customerId != null">
  397. and account.customer_id = #{customerId}
  398. </if>
  399. order by account.create_date desc
  400. </where>
  401. </select>
  402. <select id="selectMeterElenoMeterInfo" resultType="com.bz.smart_city.entity.pay.archives.PayAccountInfo">
  403. select
  404. account.accountnumber as "accountnumber",
  405. account.calculateway as "calculateway",
  406. account.waterproperty_id as "waterPropertyId",
  407. device.metercode as "metercode",
  408. sil.user_name as accountname,
  409. sil.user_phone as telephone,
  410. sil.id_card as idcardno,
  411. device.water_meter_no as "metereleno"
  412. from pay_base_account account
  413. inner join sc_device device on account.id = device.account_id
  414. inner join sc_install_list sil on sil.device_id = device.id
  415. <where>
  416. device.id not in(select watermeter_id from pay_base_customerandmeterrela where businessstate = '1')
  417. <if test="metereleno != null">
  418. and device.water_meter_no like concat('%',#{metereleno},'%')
  419. </if>
  420. <!--<if test="siteId != null">
  421. and account.site_id = #{siteId}
  422. </if>-->
  423. <if test="customerId != null">
  424. and account.customer_id = #{customerId}
  425. </if>
  426. order by account.create_date desc
  427. </where>
  428. </select>
  429. <select id="selectAccountWater" resultType="com.bz.smart_city.entity.pay.archives.CustomerListInfo">
  430. select
  431. accountnumber as "accountnumber",
  432. calculateway as "calculateway" ,
  433. waterproperty_id as "waterPropertyId",
  434. device.water_meter_no as "metereleno"
  435. from pay_base_account account
  436. inner join sc_device device on account.id = device.account_id
  437. <where>
  438. and (account.accountnumber not in (select accountnumber from pay_base_customerandmeterrela where businessstate ='1' ))
  439. <if test="accountnumber != null">
  440. and account.accountnumber like concat('%',#{accountnumber},'%')
  441. </if>
  442. <if test="siteId != null">
  443. and account.site_id = #{siteId}
  444. </if>
  445. <if test="customerId != null">
  446. and account.customer_id = #{customerId}
  447. </if>
  448. order by account.create_date desc
  449. </where>
  450. </select>
  451. <select id="queryMetercode" resultType="com.bz.smart_city.entity.pay.archives.MeterListInfo">
  452. select
  453. metercode from sc_device deivce
  454. <where>
  455. deivce.metercode not in (select metercode from pay_base_customerandmeterrela) and deivce.metercode is not null
  456. <!--<if test="siteId != null">
  457. and site_id = #{siteId}
  458. </if>-->
  459. <if test="customerId != null">
  460. and customer_id = #{customerId}
  461. </if>
  462. order by date_create desc
  463. </where>
  464. </select>
  465. <update id="updateAccountInfo">
  466. update pay_base_account set name=#{accountname},idtype =#{idtype},idcardno=#{idcardno},telephone=#{telephone},update_by=#{updateBy},update_date =#{date}
  467. where site_id =#{siteId} and customer_id =#{customerId} and accountnumber =#{accountnumber}
  468. </update>
  469. <update id="updateCustomerInfo">
  470. update pay_base_customerandmeterrela set accountname=#{accountname},housetype =#{housetype} ,office_id =#{officeId},customergroup =#{customergroup},update_by=#{updateBy},update_date =#{date}
  471. where site_id =#{siteId} and customer_id =#{customerId} and accountnumber =#{accountnumber} and metercode =#{metercode}
  472. </update>
  473. <update id="updateBaseAccountInfo">
  474. update pay_base_account set address =#{address} ,telephone =#{telephone},idtype =#{idtype},idcardno=#{idcardno}
  475. where site_id =#{siteId} and customer_id =#{customerId} and accountnumber =#{accountnumber};
  476. </update>
  477. <select id="queryWaterUserdStateCount" resultType="java.lang.Integer">
  478. select count(1) from pay_amount_waterusedamount t
  479. inner join pay_base_closingaccountinfo c on t.year = c.year and t.month = c.month
  480. where t.state = 1 and c.state = 0 and t.watermeter_id = #{id}
  481. </select>
  482. <select id="get" resultType="com.bz.smart_city.entity.pay.archives.PayBaseCustomerandmeterrela">
  483. select
  484. a.id,
  485. a.account_id AS "accountId",
  486. a.watermeter_id AS "watermeterId",
  487. a.accountname,
  488. a.accountnumber,
  489. a.metercode,
  490. a.businessstate,
  491. a.office_id AS "officeId",
  492. a.housetype,
  493. a.calculateway,
  494. a.customercategory,
  495. a.customergroup,
  496. a.fixedamount,
  497. a.vatno,
  498. a.bankaccount,
  499. a.invoicetitle,
  500. a.address,
  501. a.opendate,
  502. a.waterproperty_id AS "waterpropertyId",
  503. a.watertype,
  504. a.canceldate,
  505. a.create_by AS "createBy",
  506. a.create_date AS "createDate",
  507. a.update_by AS "updateBy",
  508. a.update_date AS "updateDate",
  509. a.remarks AS "remarks",
  510. a.del_flag AS "delFlag",
  511. a.site_id as "siteId",
  512. a.customer_id as "customerId"
  513. from pay_base_customerandmeterrela a
  514. <where>
  515. a.id =#{id}
  516. </where>
  517. </select>
  518. <update id="updateMeterInstallOpen">
  519. update sc_install_list set is_accepted =#{isAccepted},date_update=#{date},update_by =#{updateBy} where device_id =#{id}
  520. </update>
  521. <select id="getOfficeId" resultType="com.bz.smart_city.entity.Organization">
  522. select id from sc_organization where site_id =#{siteId} and name =#{name}
  523. </select>
  524. <update id="updateRechargeAccountState">
  525. update pay_pay_rechargeaccount set businessstate ='2',update_by=#{updateBy},update_date =#{date}
  526. where site_id =#{siteId} and customer_id =#{customerId} and account_id =#{id}
  527. </update>
  528. <update id="updateAccountState">
  529. update pay_base_account set state =#{state},update_by=#{updateBy},update_date =#{date}
  530. where site_id =#{siteId} and customer_id =#{customerId} and id =#{id}
  531. </update>
  532. <select id="getResetLadderList" resultType="com.bz.smart_city.dto.pay.PayBaseCustomerandmeterrelaDto">
  533. SELECT
  534. a.waterproperty_id as waterpropertyId,
  535. a.account_id as accountId,
  536. pro.laddertype as laddertype
  537. FROM pay_base_customerandmeterrela a
  538. inner join pay_base_account ac on ac.id = a.account_id
  539. left join pay_base_waterproperty pro on pro.id = a.waterproperty_id
  540. WHERE (pro.laddertype=1 or pro.laddertype=2)
  541. and ac.resetaccumulatedtondate &lt;= now()
  542. and a.businessstate=1
  543. and a.site_id = #{siteId}
  544. and a.customer_id = #{customerId}
  545. </select>
  546. <select id="queryCustomerInfo" resultType="java.lang.Integer">
  547. select
  548. count(1)
  549. from pay_base_customerandmeterrela
  550. where site_id =#{siteId} and customer_id =#{customerId} and accountnumber =#{accountnumber} and metercode =#{metercode}
  551. </select>
  552. <select id="queryCancelInfo" resultType="com.bz.smart_city.entity.pay.archives.PayBaseCustomerandmeterrela">
  553. select
  554. a.id,
  555. a.account_id AS "accountId",
  556. a.watermeter_id AS "watermeterId",
  557. a.accountname,
  558. a.accountnumber,
  559. a.metercode,
  560. a.businessstate,
  561. a.office_id AS "officeId",
  562. a.housetype,
  563. a.calculateway,
  564. a.customercategory,
  565. a.customergroup,
  566. a.fixedamount,
  567. a.vatno,
  568. a.bankaccount,
  569. a.invoicetitle,
  570. a.address,
  571. a.opendate,
  572. a.waterproperty_id AS "waterpropertyId",
  573. a.watertype,
  574. a.canceldate,
  575. a.create_by AS "createBy",
  576. a.create_date AS "createDate",
  577. a.update_by AS "updateBy",
  578. a.update_date AS "updateDate",
  579. a.remarks AS "remarks",
  580. a.del_flag AS "delFlag",
  581. a.site_id as "siteId",
  582. a.customer_id as "customerId"
  583. from pay_base_customerandmeterrela a
  584. <where>
  585. <if test="siteId != null">
  586. and a.site_id =#{siteId}
  587. </if>
  588. <if test="customerId != null">
  589. and a.customer_id =#{customerId}
  590. </if>
  591. <if test="accountnumber != null">
  592. and a.accountnumber =#{accountnumber}
  593. </if>
  594. <if test="metercode != null">
  595. and a.metercode =#{metercode}
  596. </if>
  597. </where>
  598. </select>
  599. <select id="queryMeterState" resultType="java.lang.Integer">
  600. select is_accepted as "isAccepted" from sc_install_list where account_id =#{accountId} and customer_id =#{customerId}
  601. </select>
  602. <select id="getParentOfficeId" resultType="com.bz.smart_city.entity.Organization">
  603. select id from sc_organization where site_id =#{siteId} and parent_id =#{id} and name =#{name}
  604. </select>
  605. <select id="findAccountByAccountNumber" resultType="com.bz.smart_city.entity.pay.archives.PayBaseCustomerandmeterrela">
  606. select
  607. account.id as "accountId",
  608. account.accountnumber as "accountnumber",
  609. account.name as "accountname",
  610. customer.invoicetitle as "invoicetitle",
  611. account.telephone as "telephone",
  612. account.address as "address",
  613. customer.vatno as "vatno",
  614. customer.bankaccount as "bankaccount",
  615. account.email as "email"
  616. from pay_base_customerandmeterrela customer
  617. left join pay_base_account account on customer.account_id = account.id
  618. <where>
  619. <if test="siteId != null">
  620. and customer.site_id = #{siteId}
  621. </if>
  622. <if test="customerId != null">
  623. and customer.customer_id = #{customerId}
  624. </if>
  625. <if test="accountnumber != null and accountnumber != ''">
  626. and customer.accountnumber = #{accountnumber}
  627. </if>
  628. </where>
  629. limit 1
  630. </select>
  631. </mapper>