123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710 |
- <?xml version="1.0" encoding="UTF-8"?>
- <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
- <mapper namespace="com.bz.smart_city.dao.pay.AmountWaterUsedAmountMapper">
- <sql id="amountWaterusedamountColumns">
- a.id AS "id",
- a.approver_id AS "approverId",
- a.approvetime AS "approvetime",
- a.customerandmeterrela_id AS "customerandmeterrelaId",
- a.office_id AS "officeId",
- a.lastreading AS "lastreading",
- a.lastrecorddate AS "lastrecorddate",
- a.metercode AS "metercode",
- a.watermeter_id AS "watermeterId",
- a.month AS "month",
- a.payamount AS "payamount",
- a.reading AS "reading",
- a.recorddate AS "recorddate",
- a.amount AS "amount",
- a.state AS "state",
- a.waterproperty_id AS "waterpropertyId",
- a.year AS "year",
- a.account_id AS "accountId",
- a.accountname AS "accountname",
- a.accountnumber AS "accountnumber",
- a.address AS "address",
- a.watertype AS "watertype",
- a.isprint AS "isprint",
- a.ele_no AS "eleNo",
- a.iswxsend AS "iswxsend",
- a.sendwxdate AS "sendwxdate",
- a.create_by AS "createBy",
- a.create_date AS "createDate",
- a.update_by AS "updateBy",
- a.update_date AS "updateDate",
- a.remarks AS "remarks",
- a.del_flag AS "delFlag",
- a.site_id as "siteId",
- a.customer_id as "customerId",
- c.label as stateName,
- CONCAT(a.`year`,'年',LPAD(a.month, 2, 0),'月') as closingName,
- d.water_meter_no as "metereleno"
- </sql>
- <sql id="amountWaterusedamountJoins">
- inner join sc_device d on a.watermeter_id = d.id
- left join pay_sys_dict c on c.`value` = a.state and c.type ='水量状态'
- <if test="customerId!= null" >AND c.customer_id = #{customerId}</if>
- <if test="siteId!= null" > and c.site_id = #{siteId} </if>
- </sql>
- <select id="get" resultType="com.bz.smart_city.entity.pay.AmountWaterUsedAmount">
- SELECT
- <include refid="amountWaterusedamountColumns"/>
- FROM pay_amount_waterusedamount a
- <include refid="amountWaterusedamountJoins"/>
- WHERE a.id = #{id}
- </select>
- <select id="getList" resultType="com.bz.smart_city.dto.pay.AmountWaterUsedAmountDto">
- SELECT
- <include refid="amountWaterusedamountColumns"/>
- FROM pay_amount_waterusedamount a
- <include refid="amountWaterusedamountJoins"/>
- <where>
- a.customer_id = #{customerId}
- <if test="siteId!= null" > and a.site_id = #{siteId} </if>
- <choose>
- <when test="condition != null and condition !=''">
- and
- (
- a.accountnumber like concat('%',#{condition} ,'%')
- or a.metercode like concat('%',#{condition} ,'%')
- or d.water_meter_no like concat('%',#{condition} ,'%')
- )
- </when>
- <otherwise>
- <if test="accountnumber!= null and accountnumber !=''" > and a.accountnumber = #{accountnumber} </if>
- <if test="metercode!= null and metercode !=''" > and a.metercode = #{metercode} </if>
- </otherwise>
- </choose>
- <if test ="year != null and month != null">
- and a.year = #{year} and a.month = #{month}
- </if>
- <if test="state!= null" > and a.state = #{state} </if>
- <if test="amountMin != null"> and a.payamount >= #{amountMin} </if>
- <if test="amountMax != null"> and a.payamount <![CDATA[ <= ]]> #{amountMax} </if>
- <if test="programItems != null and programItems.size() != 0">
- and
- <foreach collection="programItems" item="item" open="(" separator=" or " close=")">
- <if test="item.dimensionId == 10">
- a.${item.dimensionCode} = #{item.dimensionValue}
- </if>
- </foreach>
- </if>
- </where>
- order by a.recorddate desc
- </select>
- <update id="update">
- UPDATE pay_amount_waterusedamount SET
- amount = #{amountWaterUsedAmount.amount},
- approver_id = #{amountWaterUsedAmount.approverId},
- approvetime = #{amountWaterUsedAmount.approvetime},
- customerandmeterrela_id = #{amountWaterUsedAmount.customerandmeterrelaId},
- office_id = #{amountWaterUsedAmount.officeId},
- lastreading = #{amountWaterUsedAmount.lastreading},
- lastrecorddate = #{amountWaterUsedAmount.lastrecorddate},
- metercode = #{amountWaterUsedAmount.metercode},
- watermeter_id = #{amountWaterUsedAmount.watermeterId},
- month = #{amountWaterUsedAmount.month},
- payamount = #{amountWaterUsedAmount.payamount},
- reading = #{amountWaterUsedAmount.reading},
- recorddate = #{amountWaterUsedAmount.recorddate},
- state = #{amountWaterUsedAmount.state},
- waterproperty_id = #{amountWaterUsedAmount.waterpropertyId},
- year = #{amountWaterUsedAmount.year},
- account_id = #{amountWaterUsedAmount.accountId},
- accountname = #{amountWaterUsedAmount.accountname},
- accountnumber = #{amountWaterUsedAmount.accountnumber},
- address = #{amountWaterUsedAmount.address},
- watertype = #{amountWaterUsedAmount.watertype},
- update_by = #{amountWaterUsedAmount.updateBy},
- update_date = #{amountWaterUsedAmount.updateDate},
- remarks = #{amountWaterUsedAmount.remarks},
- ele_no = #{amountWaterUsedAmount.eleNo},
- isprint = #{amountWaterUsedAmount.isprint},
- iswxsend = #{amountWaterUsedAmount.iswxsend},
- sendwxdate =#{amountWaterUsedAmount.sendwxdate}
- WHERE id = #{amountWaterUsedAmount.id}
- </update>
- <select id="getWaterUsedAmountByMeterId" resultType="com.bz.smart_city.dto.pay.AmountWaterUsedAmountDto">
- select a.create_date,w.date_create installdate,a.year,a.month
- from sc_device w
- left join pay_amount_waterusedamount a on a.watermeter_id = w.id
- where w.id = #{waterMeterId}
- order by a.year desc,a.month desc
- </select>
- <select id ="getIds" resultType="java.math.BigInteger">
- SELECT
- a.id AS "id"
- FROM pay_amount_waterusedamount a
- <include refid="amountWaterusedamountJoins"/>
- <where>
- a.reading is not null
- and a.reading >= a.lastreading
- and a.payamount is not null
- <if test="customerId!= null" >and a.customer_id = #{customerId} </if>
- <if test="siteId!= null" > and a.site_id = #{siteId} </if>
- <choose>
- <when test="condition != null and condition !=''">
- and (a.accountname like concat('%',#{condition} ,'%') or a.accountnumber like concat('%',#{condition} ,'%') or a.metercode like concat('%',#{condition} ,'%') or a.address like concat('%',#{condition} ,'%'))
- </when>
- <otherwise>
- <if test="accountname!= null and accountname !=''" > and a.accountname = #{accountname} </if>
- <if test="accountnumber!= null and accountnumber !=''" > and a.accountnumber = #{accountnumber} </if>
- <if test="metercode!= null and metercode !=''" > and a.metercode = #{metercode} </if>
- <if test="address!= null and address !=''" > and a.address = #{address} </if>
- </otherwise>
- </choose>
- <if test ="year != null and month != null">
- and a.year = #{year} and a.month = #{month}
- </if>
- <if test="state!= null" > and a.state = #{state} </if>
- <if test="amountMin != null"> and a.payamount >= #{amountMin} </if>
- <if test="amountMax != null"> and a.payamount <![CDATA[ <= ]]> #{amountMax} </if>
- <if test="programItems != null and programItems.size() != 0">
- and
- <foreach collection="programItems" item="item" open="(" separator=" or " close=")">
- <if test="item.dimensionId == 10">
- a.${item.dimensionCode} = #{item.dimensionValue}
- </if>
- </foreach>
- </if>
- </where>
- </select>
- <select id = "getCustId" resultType="java.lang.Integer">
- select customerId from pay_base_customerandmeterrela a group by a.customer_id
- </select>
- <select id="getAllAmountCount" resultType="java.lang.Integer">
- select count(1) as num
- from pay_base_customerandmeterrela rela
- left join pay_amount_waterusedamount amount on amount.watermeter_id = rela.watermeter_id
- and amount.year=#{year} and amount.month=#{month}
- where rela.businessstate=1 and amount.id is null
- <if test="customerId!= null" >and rela.customer_id = #{customerId} </if>
- <if test="siteId!= null" > and rela.site_id = #{siteId} </if>
- </select>
- <select id="getAllAmountCountByDay" resultType="java.lang.Integer">
- select count(1) as num
- from pay_base_customerandmeterrela rela
- left join pay_amount_waterusedamount_day amount on amount.watermeter_id = rela.watermeter_id
- and amount.read_date =DATE_FORMAT(DATE_SUB(now(),INTERVAL 1 day) ,'%Y%m%d')
- where rela.businessstate=1 and amount.id is null
- <if test="customerId!= null" >and rela.customer_id = #{customerId} </if>
- <if test="siteId!= null" > and rela.site_id = #{siteId} </if>
- </select>
- <select id="getAllAmountRecord" resultType="com.bz.smart_city.dto.pay.AmountWaterUsedAmountDto">
- select amount.id,
- amount.lastreading,
- amount.ele_no eleNo,
- amount.metercode metercode,
- rela.calculateway,
- rela.fixedamount,
- amount.watermeter_id watermeterId,
- amount.recorddate,
- rela.id customerandmeterrelaId,
- amount.waterproperty_id waterpropertyId,
- rela.account_id as accountId,
- amount.lastrecorddate
- from pay_amount_waterusedamount amount
- inner join pay_base_customerandmeterrela rela on rela.id= amount.customerandmeterrela_id
- where amount.year=#{year} and amount.month=#{month}
- and amount.reading is null and amount.payamount is null
- <if test="customerId!= null" > and rela.customer_id =#{customerId}</if>
- <if test="siteId!= null" > and rela.site_id = #{siteId} </if>
- </select>
- <insert id ="createdAmount" useGeneratedKeys="false">
- INSERT INTO pay_amount_waterusedamount
- (customerandmeterrela_id, office_id, lastreading, lastrecorddate, metercode,
- watermeter_id, month, payamount, reading, recorddate, amount, state,
- waterproperty_id, year, account_id, accountname, accountnumber, address,
- watertype, isprint, ele_no, iswxsend, sendwxdate, create_by, create_date,
- update_by, update_date, remarks, del_flag, site_id, customer_id)
- SELECT
- c.id,c.office_id,
- ifnull(lastwua.reading, IFNULL(d.new_meter_start,0)),
- ifnull(lastwua.recorddate,d.date_create),c.metercode,
- c.watermeter_id,#{month},null,null,null,NULL,1,
- c.waterproperty_id,#{year},c.account_id,c.accountname,c.accountnumber,c.address,
- c.watertype,null,d.water_meter_no,null,null,1,NOW(),
- 1,now(),'批量生成抄表计划',0,c.site_id,c.customer_id
- FROM
- pay_base_customerandmeterrela c
- left join sc_device d on d.id =c.watermeter_id
- LEFT JOIN pay_amount_waterusedamount amount ON amount.watermeter_id = c.watermeter_id
- AND amount.YEAR = #{year}
- AND amount.MONTH = #{month}
- LEFT JOIN (
- SELECT
- oldwua.watermeter_id,
- oldwua.reading,
- oldwua.recorddate
- FROM
- (
- SELECT
- max(
- waterusedamount.create_date
- ) AS create_date,
- waterusedamount.watermeter_id
- FROM
- pay_amount_waterusedamount waterusedamount
- WHERE
- waterusedamount.state = 2
- GROUP BY
- waterusedamount.watermeter_id
- ) lastid
- LEFT JOIN pay_amount_waterusedamount oldwua ON lastid.create_date = oldwua.create_date
- AND oldwua.watermeter_id = lastid.watermeter_id
- ) lastwua ON c.watermeter_id = lastwua.watermeter_id
- WHERE
- c.businessstate = 1
- AND amount.id IS NULL
- <if test="customerId!= null" >AND c.customer_id = #{customerId}</if>
- <if test="siteId!= null" > and c.site_id = #{siteId} </if>
- limit 500
- </insert>
- <update id="batchUpdate">
- UPDATE pay_amount_waterusedamount SET
- amount = #{amountWaterUsedAmount.amount},
- payamount = #{amountWaterUsedAmount.payamount},
- reading = #{amountWaterUsedAmount.reading},
- recorddate = #{amountWaterUsedAmount.recorddate},
- update_date = #{amountWaterUsedAmount.updateDate}
- WHERE id = #{amountWaterUsedAmount.id}
- </update>
- <insert id ="createdAmountByDay" useGeneratedKeys="false">
- INSERT INTO pay_amount_waterusedamount_day (
- customerandmeterrela_id,
- office_id,
- lastreading,
- lastrecorddate,
- metercode,
- watermeter_id,
- payamount,
- reading,
- recorddate,
- amount,
- waterproperty_id,
- account_id,
- create_by,
- create_date,
- update_by,
- update_date,
- remarks,
- del_flag,
- site_id,
- customer_id,
- read_date,
- debt
- ) SELECT
- c.id,
- c.office_id,
- ifnull( lastwua.reading, ifnull(device.new_meter_start,0) ),
- ifnull( lastwua.recorddate, c.create_date ),
- c.metercode,
- c.watermeter_id,
- NULL,
- NULL,
- NULL,
- NULL,
- c.waterproperty_id,
- c.account_id,
- 1,
- NOW(),
- 1,
- now(),
- '每天抄表计划',
- 0,
- c.site_id,
- c.customer_id,
- DATE_FORMAT( DATE_SUB( now(), INTERVAL 1 DAY ), '%Y%m%d' ),
- NULL
- FROM
- pay_base_customerandmeterrela c
- LEFT JOIN sc_device device ON device.id = c.watermeter_id
- LEFT JOIN pay_amount_waterusedamount_day amount ON amount.watermeter_id = c.watermeter_id
- AND amount.read_date = DATE_FORMAT( DATE_SUB( now(), INTERVAL 1 DAY ), '%Y%m%d' )
- LEFT JOIN (
- SELECT
- oldwua.watermeter_id,
- oldwua.reading,
- oldwua.recorddate
- FROM
- (
- SELECT
- max( waterusedamount.create_date ) AS create_date,
- waterusedamount.watermeter_id
- FROM
- pay_amount_waterusedamount waterusedamount
- WHERE
- waterusedamount.state = 2
- GROUP BY
- waterusedamount.watermeter_id
- ) lastid
- LEFT JOIN pay_amount_waterusedamount oldwua ON lastid.create_date = oldwua.create_date
- AND oldwua.watermeter_id = lastid.watermeter_id
- ) lastwua ON c.watermeter_id = lastwua.watermeter_id
- WHERE
- c.businessstate = 1
- AND amount.id IS NULL
- <if test="customerId!= null" >AND c.customer_id = #{customerId}</if>
- <if test="siteId!= null" > and c.site_id = #{siteId} </if>
- </insert>
- <update id="updateByDate">
- UPDATE pay_amount_waterusedamount_day SET
- amount = #{amountWaterUsedAmount.amount},
- payamount = #{amountWaterUsedAmount.payamount},
- reading = #{amountWaterUsedAmount.reading},
- recorddate = #{amountWaterUsedAmount.recorddate},
- update_date = #{amountWaterUsedAmount.updateDate}
- WHERE id = #{amountWaterUsedAmount.id}
- </update>
- <resultMap id="AmountWaterUsedAmountByDayResultMap" type="com.bz.smart_city.entity.pay.AmountWaterUsedAmountByDay">
- <result column="device_id" property="watermeterId" />
- <result column="watermeter_id" property="id" />
- </resultMap>
- <select id ="getAmountWaterUsedAmountByDay" resultMap="AmountWaterUsedAmountByDayResultMap">
- select
- a.id,
- a.watermeter_id
- from pay_amount_waterusedamount_day a
- <where>
- a.read_date=DATE_FORMAT(DATE_SUB(now(),INTERVAL 1 day) ,'%Y%m%d')
- <if test="customerId!= null" >and a.customer_id = #{customerId} </if>
- <if test="siteId!= null" > and a.site_id = #{siteId} </if>
- </where>
- </select>
- <select id="getAllAmountRecordByDay" resultType="com.bz.smart_city.entity.pay.AmountWaterUsedAmountByDay">
- select amount.id,
- amount.lastreading,
- amount.lastrecorddate,
- rela.calculateway,
- rela.fixedamount,
- amount.watermeter_id watermeterId,
- amount.metercode,
- amount.recorddate,
- rela.id customerandmeterrelaId,
- amount.waterproperty_id waterpropertyId,
- rela.account_id as accountId
- from pay_amount_waterusedamount_day amount
- inner join pay_base_customerandmeterrela rela on rela.id= amount.customerandmeterrela_id
- where amount.read_date =DATE_FORMAT(DATE_SUB(now(),INTERVAL 1 day) ,'%Y%m%d')
- and amount.reading is null
- <if test="customerId!= null" > and rela.customer_id =#{customerId}</if>
- <if test="siteId!= null" > and rela.site_id = #{siteId} </if>
- </select>
- <select id="getWaterMeterIdByDay" resultType="java.math.BigInteger">
- select
- amount.watermeter_id
- from pay_amount_waterusedamount_day amount
- where amount.read_date =DATE_FORMAT(DATE_SUB(now(),INTERVAL 1 day) ,'%Y%m%d')
- and amount.reading is null
- <if test="customerId!= null" > and amount.customer_id =#{customerId}</if>
- <if test="siteId!= null" > and amount.site_id = #{siteId} </if>
- </select>
- <select id="getCustIdAndSiteId" resultType="com.bz.smart_city.entity.pay.archives.PayBaseCustomerandmeterrela">
- select
- c.customer_id customerId,
- c.site_id siteId
- from pay_base_customerandmeterrela c
- where c.businessstate =1
- and c.customer_id is not null and c.site_id is not null
- group by c.customer_id, c.site_id
- </select>
- <select id="getLastReadrecord" resultType="com.bz.smart_city.dto.pay.AmountWaterUsedAmountDto">
- SELECT
- <include refid="amountWaterusedamountColumns"/>
- FROM pay_amount_waterusedamount a
- <include refid="amountWaterusedamountJoins"/>
- where a.site_id = #{siteId} and a.customer_id = #{customerId}
- and a.metercode = #{metercode} and a.state=2
- order by a.approvetime desc
- limit 1
- </select>
- <select id="getWatermeterInfoByMetercode" resultType="com.bz.smart_city.dto.pay.BaseWatermeterDto">
- select
- id
- ,metercode
- ,water_meter_no as "eleno"
- ,new_meter_start as "stratcount"
- from sc_device
- where site_id=#{siteId}
- and customer_id=#{customerId}
- and metercode=#{metercode}
- </select>
- <update id="updateWatermeterInfo">
- update sc_device set
- <set>
- <if test="metercode != null and metercode != ''">
- metercode=#{metercode},
- </if>
- <if test="eleno != null and eleno != ''">
- water_meter_no = #{eleno},
- </if>
- <if test="stratcount != null ">
- new_meter_start = #{stratcount},
- </if>
- <if test="updateBy != null ">
- update_by = #{updateBy},
- </if>
- <if test="updateDate != null ">
- date_update = #{updateDate},
- </if>
- </set>
- where id=#{id}
- </update>
- <insert id="insertReplaceRecord">
- insert into pay_device_replace_record
- (
- watermeter_id,
- metercode,
- old_eleno,
- new_eleno,
- old_lastreading,
- old_reading,
- old_amount,
- new_startcount,
- create_date,
- remarks,
- site_id,
- customer_id,
- year,
- month)
- value(
- #{watermeterId},
- #{metercode},
- #{oldEleno},
- #{newEleno},
- #{oldLastreading},
- #{oldReading},
- #{oldAmount},
- #{new_startcount},
- #{createDate},
- #{remarks},
- #{siteId},
- #{customerId},
- #{year},
- #{month})
- </insert>
- <insert id="insertSelectAmountBaseInfo">
- insert into pay_amount_waterusedamount (
- customerandmeterrela_id
- ,office_id
- ,lastreading
- ,lastrecorddate
- ,metercode
- ,watermeter_id
- ,month
- ,state
- ,waterproperty_id
- ,year
- ,account_id
- ,accountname
- ,accountnumber
- ,watertype
- ,isprint
- ,ele_no
- ,create_by
- ,create_date
- ,update_by
- ,update_date
- ,remarks
- ,del_flag
- ,site_id
- ,customer_id
- )
- select
- c.id as customerandmeterrela_id
- ,c.office_id
- ,ifnull(ifnull(amount.reading,d.new_meter_start),null) as lastreading
- ,ifnull(ifnull(amount.recorddate,d.date_create),null) as lastrecorddate
- ,c.metercode
- ,c.watermeter_id
- ,#{month}
- ,1
- ,p.id as waterproperty_id
- ,#{year}
- ,c.account_id
- ,c.accountname
- ,c.accountnumber
- ,c.watertype
- ,0
- ,d.water_meter_no as ele_no
- ,'1'
- ,now()
- ,'1'
- ,now()
- ,'抄表计划'
- ,'0'
- ,#{siteId}
- ,#{customerId}
- from pay_base_customerandmeterrela c
- left join pay_base_waterproperty p on c.waterproperty_id=p.id
- LEFT JOIN pay_amount_waterusedamount amounts ON amounts.watermeter_id = c.watermeter_id
- AND amounts.YEAR = #{year}
- AND amounts.MONTH = #{month}
- left join sc_device d on c.watermeter_id=d.id
- left join (
- select
- a.watermeter_id,
- a.reading,
- a.recorddate
- from (
- select
- ele_no
- ,max(create_date) create_date
- from pay_amount_waterusedamount
- where state =2
- group by ele_no
- ) aLast
- left join pay_amount_waterusedamount a on a.ele_no=aLast.ele_no and a.create_date=aLast.create_date
- ) amount on amount.watermeter_id=c.watermeter_id
- where c.businessstate= 1 and amounts.id is null and c.site_id=#{siteId} and c.customer_id=#{customerId}
- </insert>
- <select id="getSynAmountMetercode" resultType="java.lang.String">
- select metercode from pay_amount_waterusedamount
- where year = #{year} and month = #{month} and site_id = #{siteId} and customer_id=#{customerId}
- </select>
- <resultMap id="AmountSynParam" type="com.bz.smart_city.dto.pay.AmountSynParamDto">
- <result column="yyyymm" property="yyyymm" jdbcType="VARCHAR"/>
- <result column="customerNo" property="customerNo" jdbcType="VARCHAR" />
- <collection property="fileNo" resultMap="metercodes" />
- </resultMap>
- <resultMap id="metercodes" type="java.lang.String">
- <result column="metercode"/>
- </resultMap>
- <select id="GetAmountSynMeterInfo" resultMap="AmountSynParam">
- select
- concat(year,month) as "yyyymm"
- ,c.customer_no as "customerNo"
- ,a.metercode as "metercode"
- from pay_amount_waterusedamount a
- left join sc_customer c on a.customer_id=c.id
- where a.customer_id=#{customerId} and a.site_id=#{siteId}
- and a.`year`=#{year} and a.`month`=#{month}
- </select>
- <select id="GetAmountSynInfo" resultType="java.lang.String">
- select
- a.metercode as "metercode"
- from pay_amount_waterusedamount a
- left join sc_customer c on a.customer_id=c.id
- where a.customer_id=#{customerId} and a.site_id=#{siteId}
- and a.`year`=#{year} and a.`month`=#{month}
- </select>
- <resultMap id="ReplaceMeterCountMap" type="com.bz.smart_city.entity.pay.DeviceReplaceRecord">
- </resultMap>
- <select id="getRepalceRecordCount" resultMap="ReplaceMeterCountMap">
- select
- id
- ,watermeter_id as "watermeterId"
- ,metercode
- ,create_date as "createDate"
- ,old_lastreading as "oldLastreading"
- ,old_reading as "oldReading"
- ,old_amount as "oldAmount"
- from pay_device_replace_record
- where site_id=#{siteId} and customer_id=#{customerId} and year=#{year} and month =#{month}
- </select>
- <select id="getwaterUserdAmount" resultType="java.lang.Integer">
- select
- amount.state from pay_amount_waterusedamount amount
- where amount.account_id =#{id} and amount.year =#{year} and amount.month =#{month}
- </select>
- <select id="getEstimatedDay" resultType="com.bz.smart_city.dto.pay.EstimatedDayDto">
- select
- c.id as "id",
- c.metercode metercode,
- w.reading as "dayReading",
- w.read_date as "readdate",
- u.reading as "MReading",
- c.waterproperty_id as "waterpropertyId",
- u.watermeter_id as "watermeterId",
- u.account_id as "accountId"
- from pay_base_customerandmeterrela c
- left join pay_amount_waterusedamount_day w on c.watermeter_id = w.watermeter_id
- left join pay_amount_waterusedamount u on c.watermeter_id = u.watermeter_id
- <where>
- c.businessstate = '1'
- <if test="readdate != null and readdate != ''">
- and w.read_date =#{readdate}
- </if>
- <if test="year != null and year != ''">
- and u.year =#{year}
- </if>
- <if test="month != null and month != ''">
- and u.month =#{month}
- </if>
- <if test="siteId != null and siteId != ''">
- and w.site_id =#{siteId}
- </if>
- <if test="customerId != null and customerId != ''">
- and w.customer_id =#{customerId}
- </if>
- </where>
- </select>
- </mapper>
|