|
@@ -390,6 +390,64 @@
|
|
|
<if test="siteId!= null" > and c.site_id = #{siteId} </if>
|
|
|
</insert>
|
|
|
|
|
|
+ <insert id ="createdAllAmountByDay" 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,
|
|
|
+ NULL,
|
|
|
+ NULL,
|
|
|
+ device.metercode,
|
|
|
+ device.id,
|
|
|
+ NULL,
|
|
|
+ NULL,
|
|
|
+ NULL,
|
|
|
+ NULL,
|
|
|
+ c.waterproperty_id,
|
|
|
+ pba.id,
|
|
|
+ 1,
|
|
|
+ NOW(),
|
|
|
+ 1,
|
|
|
+ now(),
|
|
|
+ '每天抄表计划',
|
|
|
+ 0,
|
|
|
+ pba.site_id,
|
|
|
+ pba.customer_id,
|
|
|
+ DATE_FORMAT( DATE_SUB( now(), INTERVAL 1 DAY ), '%Y%m%d' ),
|
|
|
+ NULL
|
|
|
+ FROM
|
|
|
+ pay_base_account pba
|
|
|
+ LEFT JOIN sc_device device ON device.account_id = pba.id
|
|
|
+ LEFT JOIN pay_amount_waterusedamount_day amount ON amount.watermeter_id = device.id
|
|
|
+ AND amount.read_date = DATE_FORMAT( DATE_SUB( now(), INTERVAL 1 DAY ), '%Y%m%d' )
|
|
|
+ LEFT JOIN pay_base_customerandmeterrela c ON device.id = c.watermeter_id
|
|
|
+ WHERE
|
|
|
+ device.curr_status > 0 and amount.id IS NULL
|
|
|
+ <if test="customerId!= null" >AND pba.customer_id = #{customerId}</if>
|
|
|
+ <if test="siteId!= null" > and pba.site_id = #{siteId} </if>
|
|
|
+ </insert>
|
|
|
|
|
|
<update id="updateByDate">
|
|
|
|
|
@@ -434,11 +492,11 @@
|
|
|
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
|
|
|
+ left 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>
|
|
|
+ and amount.reading is null and amount.metercode is not null
|
|
|
+ <if test="customerId!= null" > and amount.customer_id =#{customerId}</if>
|
|
|
+ <if test="siteId!= null" > and amount.site_id = #{siteId} </if>
|
|
|
</select>
|
|
|
|
|
|
<select id="getWaterMeterIdByDay" resultType="java.math.BigInteger">
|
|
@@ -461,6 +519,15 @@
|
|
|
group by c.customer_id, c.site_id
|
|
|
</select>
|
|
|
|
|
|
+ <select id="getCustIdAndSiteIdByAccount" resultType="com.bz.smart_city.entity.pay.archives.PayBaseCustomerandmeterrela">
|
|
|
+ select
|
|
|
+ c.customer_id customerId,
|
|
|
+ c.site_id siteId
|
|
|
+ from pay_base_account c
|
|
|
+ where
|
|
|
+ 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
|