|
@@ -213,75 +213,78 @@
|
|
|
</select>
|
|
|
|
|
|
<select id="getAllAmountRecord" resultType="com.bz.smart_city.dto.pay.AmountWaterUsedAmountDto">
|
|
|
-select amount.id,
|
|
|
- amount.lastreading,
|
|
|
- amount.ele_no eleNo,
|
|
|
- rela.calculateway,
|
|
|
- rela.fixedamount,
|
|
|
- amount.watermeter_id watermeterId,
|
|
|
- amount.recorddate,
|
|
|
- rela.id customerandmeterrelaId,
|
|
|
- amount.waterproperty_id waterpropertyId,
|
|
|
- rela.account_id as accountId
|
|
|
-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 amount.id,
|
|
|
+ amount.lastreading,
|
|
|
+ amount.ele_no eleNo,
|
|
|
+ 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, 0),ifnull(lastwua.recorddate,ifnull(d.install_time,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.electronic_no,null,null,1,NOW(),
|
|
|
-1,now(),'批量生成抄表计划',0,c.site_id,c.customer_id
|
|
|
-FROM
|
|
|
- pay_base_customerandmeterrela c
|
|
|
-left join sc_install_list d on d.device_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
|
|
|
- (
|
|
|
+ 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,ifnull(d.install_time,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.electronic_no,null,null,1,NOW(),
|
|
|
+ 1,now(),'批量生成抄表计划',0,c.site_id,c.customer_id
|
|
|
+ FROM
|
|
|
+ pay_base_customerandmeterrela c
|
|
|
+ left join sc_install_list d on d.device_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
|
|
|
- max(
|
|
|
- waterusedamount.create_date
|
|
|
- ) AS create_date,
|
|
|
- waterusedamount.watermeter_id
|
|
|
+ oldwua.watermeter_id,
|
|
|
+ oldwua.reading,
|
|
|
+ oldwua.recorddate
|
|
|
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
|
|
|
+ (
|
|
|
+ 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>
|
|
|
|
|
@@ -495,13 +498,17 @@ limit 500
|
|
|
MAX( pc2.date_create ) AS dateCreate
|
|
|
FROM
|
|
|
sc_water_meter_replace_log pc2
|
|
|
- WHERE
|
|
|
- pc2.device_id IN
|
|
|
- <foreach collection="list" item="listItem" open="(" close=")" separator=",">
|
|
|
- <if test="listItem != null and listItem != ''">
|
|
|
- #{listItem}
|
|
|
+ <where>
|
|
|
+ <if test="list != null and list.size() != 0">
|
|
|
+ pc2.device_id IN
|
|
|
+ <foreach collection="list" item="listItem" open="(" close=")" separator=",">
|
|
|
+ <if test="listItem != null and listItem != ''">
|
|
|
+ #{listItem}
|
|
|
+ </if>
|
|
|
+ </foreach>
|
|
|
</if>
|
|
|
- </foreach>
|
|
|
+ </where>
|
|
|
+
|
|
|
GROUP BY
|
|
|
pc2.id
|
|
|
) a
|
|
@@ -515,22 +522,24 @@ limit 500
|
|
|
<select id="getRepalceRecordCount" resultMap="ReplaceMeterCountMap">
|
|
|
SELECT
|
|
|
COUNT(*) as number,
|
|
|
- device_id AS deviceId
|
|
|
- FROM sc_water_meter_replace_log
|
|
|
+ pc.device_id AS deviceId
|
|
|
+ FROM sc_water_meter_replace_log pc LEFT JOIN sc_device scd on pc.device_id = scd.id
|
|
|
<where>
|
|
|
- <if test="stTime != null"> and date_create >= #{stTime,jdbcType=TIMESTAMP}</if>
|
|
|
- <if test="etTime != null"> and date_create <= #{etTime,jdbcType=TIMESTAMP}</if>
|
|
|
-
|
|
|
- and device_id IN
|
|
|
- <foreach collection="list" item="listItem" open="(" close=")" separator=",">
|
|
|
- <if test="listItem != null and listItem != ''">
|
|
|
- #{listItem}
|
|
|
- </if>
|
|
|
- </foreach>
|
|
|
-
|
|
|
+ <if test="stTime != null"> and pc.date_create >= #{stTime,jdbcType=TIMESTAMP}</if>
|
|
|
+ <if test="etTime != null"> and pc.date_create <= #{etTime,jdbcType=TIMESTAMP}</if>
|
|
|
+ <if test="siteId != null"> and scd.site_id = #{siteId}</if>
|
|
|
+ <if test="customerId != null"> and scd.customer_id = #{customerId}</if>
|
|
|
+ <if test="list != null and list.size() != 0">
|
|
|
+ and pc.device_id IN
|
|
|
+ <foreach collection="list" item="listItem" open="(" close=")" separator=",">
|
|
|
+ <if test="listItem != null and listItem != ''">
|
|
|
+ #{listItem}
|
|
|
+ </if>
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
|
|
|
</where>
|
|
|
- GROUP BY device_id
|
|
|
+ GROUP BY pc.device_id
|
|
|
</select>
|
|
|
|
|
|
<select id ="getRepalceRecordDetail" resultType="com.bz.smart_city.dto.pay.ReplaceMeterDto">
|
|
@@ -540,17 +549,21 @@ limit 500
|
|
|
pc.new_begin_wsv AS newBegin,
|
|
|
pc.old_end_wsv AS oldEnd
|
|
|
FROM
|
|
|
- sc_water_meter_replace_log pc
|
|
|
+ sc_water_meter_replace_log pc LEFT JOIN sc_device scd on pc.device_id = scd.id
|
|
|
<where>
|
|
|
<if test="stTime != null"> and pc.date_create >= #{stTime,jdbcType=TIMESTAMP}</if>
|
|
|
<if test="etTime != null"> and pc.date_create <= #{etTime,jdbcType=TIMESTAMP}</if>
|
|
|
+ <if test="siteId != null"> and scd.site_id = #{siteId}</if>
|
|
|
+ <if test="customerId != null"> and scd.customer_id = #{customerId}</if>
|
|
|
+ <if test="list != null and list.size() != 0">
|
|
|
+ and pc.device_id IN
|
|
|
+ <foreach collection="list" item="listItem" open="(" close=")" separator=",">
|
|
|
+ <if test="listItem != null and listItem != ''">
|
|
|
+ #{listItem}
|
|
|
+ </if>
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
|
|
|
- and pc.device_id IN
|
|
|
- <foreach collection="list" item="listItem" open="(" close=")" separator=",">
|
|
|
- <if test="listItem != null and listItem != ''">
|
|
|
- #{listItem}
|
|
|
- </if>
|
|
|
- </foreach>
|
|
|
|
|
|
</where>
|
|
|
|