Explorar o código

水表信息当前读数查询调整

oppadmin %!s(int64=4) %!d(string=hai) anos
pai
achega
fb710332ad

+ 2 - 2
smart-city-platform/src/main/java/com/bz/smart_city/dao/pay/AmountWaterUsedAmountMapper.java

@@ -68,7 +68,7 @@ public interface AmountWaterUsedAmountMapper {
 
     List<PayBaseCustomerandmeterrela> getCustIdAndSiteId();
 
-    List<PayBaseCustomerandmeterrela> getCustIdAndSiteIdByDevice();
+    List<PayBaseCustomerandmeterrela> getCustIdAndSiteIdByAccount();
 
     //换表明细 list:设备ID
     List<ReplaceMeterDto> getRepalceRecordDetail(@Param("stTime")LocalDateTime stTime,@Param("etTime")LocalDateTime etTime,@Param("list")List<BigInteger> list,@Param("siteId")Integer siteId,@Param("customerId")Integer customerId);
@@ -80,7 +80,7 @@ public interface AmountWaterUsedAmountMapper {
     Integer getwaterUserdAmount(@Param("year")Integer year,@Param("month")Integer month,@Param("siteId")Integer siteId,
          @Param("customerId")Integer customerId, @Param("id")BigInteger id);
 
-
+    //获取设备id(未开户用户)
     List<BigInteger> getNoOpenWaterMeterIdByDay(@Param("siteId") Integer siteId, @Param("customerId")Integer customerId);
 
     //生成抄表记录初始数据(未开户用户)

+ 3 - 3
smart-city-platform/src/main/java/com/bz/smart_city/service/impl/pay/AmountSynByDayServiceImpl.java

@@ -98,7 +98,7 @@ public class AmountSynByDayServiceImpl implements AmountSynByDayService, Initial
     }
 
     public void start(){
-        List<PayBaseCustomerandmeterrela> payBaseCustomerandmeterrelas = amountWaterUsedAmountMapper.getCustIdAndSiteIdByDevice();
+        List<PayBaseCustomerandmeterrela> payBaseCustomerandmeterrelas = amountWaterUsedAmountMapper.getCustIdAndSiteIdByAccount();
         for (PayBaseCustomerandmeterrela payBaseCustomerandmeterrela: payBaseCustomerandmeterrelas){
             this.amountUpdateByDay(payBaseCustomerandmeterrela.getSiteId().intValue(),payBaseCustomerandmeterrela.getCustomerId().intValue());
 
@@ -276,7 +276,7 @@ public class AmountSynByDayServiceImpl implements AmountSynByDayService, Initial
 
     //未开户用户抄表数据
     public void noOpenUpdateByDay(Integer siteId, Integer customerId){
-        log.info(String.format("未开户用户数据同步开始:siteId=%s,customerId=%s"),siteId.toString(),customerId.toString());
+        log.info(String.format("未开户用户数据同步开始:siteId=%s,customerId=%s",siteId.toString(),customerId.toString()));
         //产生未开户的day基础计划
         Integer totalNum = amountWaterUsedAmountMapper.getNoOpenAmountCountByDay(siteId, customerId);
 
@@ -318,7 +318,7 @@ public class AmountSynByDayServiceImpl implements AmountSynByDayService, Initial
                 }
             }
         }
-        log.info(String.format("未开户用户数据同步结束:siteId=%s,customerId=%s"));
+        log.info(String.format("未开户用户数据同步结束:siteId=%s,customerId=%s",siteId.toString(),customerId.toString()));
     }
 
 

+ 15 - 10
smart-city-platform/src/main/resources/mapper/pay/AmountWaterUsedAmountMapper.xml

@@ -222,11 +222,13 @@
 	<select id="getNoOpenAmountCountByDay" resultType="java.lang.Integer">
 		select count(1) as num
 		from sc_device scd
+		left join pay_base_account pba on pba.id = scd.account_id
 		left join pay_amount_waterusedamount_day amount on amount.watermeter_id = scd.id
 		and amount.read_date =DATE_FORMAT(DATE_SUB(now(),INTERVAL 1 day) ,'%Y%m%d')
-		where scd.status =1 and amount.id is null
+		left join pay_base_customerandmeterrela rela on rela.id= amount.customerandmeterrela_id
+		where scd.status =1 and amount.id is null and (rela.id is null or rela.businessstate=2)
 		<if test="customerId!= null" >and scd.customer_id = #{customerId} </if>
-		<if test="siteId!= null" > and scd.site_id = #{siteId} </if>
+		<if test="siteId!= null" > and pba.site_id = #{siteId} </if>
 	</select>
 
 	<select id="getAllAmountRecord"  resultType="com.bz.smart_city.dto.pay.AmountWaterUsedAmountDto">
@@ -444,18 +446,20 @@
 		now(),
 		'每天抄表计划',
 		0,
-		NULL,
+		pba.site_id,
 		c.customer_id,
 		DATE_FORMAT( DATE_SUB( now(), INTERVAL 1 DAY ), '%Y%m%d' ),
 		NULL
 		FROM
 		sc_device c
+		left join pay_base_account pba on pba.id = c.account_id
 		LEFT JOIN pay_amount_waterusedamount_day amount ON amount.watermeter_id = c.id
 		AND amount.read_date = DATE_FORMAT( DATE_SUB( now(), INTERVAL 1 DAY ), '%Y%m%d' )
+		left join pay_base_customerandmeterrela rela on rela.id= amount.customerandmeterrela_id
 		WHERE
-		amount.id IS NULL
+		c.status =1 and  amount.id IS NULL and (rela.id is null or rela.businessstate=2)
 		<if test="customerId!= null" >AND c.customer_id = #{customerId}</if>
-		<if test="siteId!= null" > and c.site_id = #{siteId} </if>
+		<if test="siteId!= null" > and pba.site_id = #{siteId} </if>
 		limit 500
 	</insert>
 
@@ -549,7 +553,7 @@
 		from  pay_amount_waterusedamount_day amount
 		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 rela.id is null
+		and (rela.id is null or rela.businessstate=2)
 		<if test="customerId!= null" > and amount.customer_id =#{customerId}</if>
 		<if test="siteId!= null" > and amount.site_id = #{siteId} </if>
 	</select>
@@ -567,12 +571,13 @@
 	<select id="getNoOpenWaterMeterIdByDay" resultType="java.math.BigInteger">
 		select scd.id
 		from sc_device scd
+		left join pay_base_account pbac on pbac.id = scd.account_id
 		left join pay_amount_waterusedamount_day amount on amount.watermeter_id = scd.id
 		and amount.read_date =DATE_FORMAT(DATE_SUB(now(),INTERVAL 1 day) ,'%Y%m%d')
 		left join pay_base_customerandmeterrela pba on pba.watermeter_id = scd.id
 		where scd.status =1 and amount.reading is null and (pba.id  is null or pba.businessstate=2)
 		<if test="customerId!= null" >and scd.customer_id = #{customerId} </if>
-		<if test="siteId!= null" > and scd.site_id = #{siteId} </if>
+		<if test="siteId!= null" > and pbac.site_id = #{siteId} </if>
 	</select>
 
 	<select id="getCustIdAndSiteId" resultType="com.bz.smart_city.entity.pay.archives.PayBaseCustomerandmeterrela">
@@ -585,12 +590,12 @@
 	group by c.customer_id, c.site_id
 	</select>
 
-	<select id="getCustIdAndSiteIdByDevice" resultType="com.bz.smart_city.entity.pay.archives.PayBaseCustomerandmeterrela">
+	<select id="getCustIdAndSiteIdByAccount" resultType="com.bz.smart_city.entity.pay.archives.PayBaseCustomerandmeterrela">
 	select
 	c.customer_id customerId,
 	c.site_id siteId
-	from sc_device c
-	where c.status =1
+	from pay_base_account c
+	where c.del_flag=0
 	and c.customer_id is not null  and c.site_id is not null
 	group by c.customer_id, c.site_id
 	</select>