Xiaojh преди 4 години
родител
ревизия
ae77fb17dd

+ 28 - 0
smart-city-platform/src/main/java/com/bz/smart_city/controller/pay/archives/PayBaseCustomerandmeterrelaController.java

@@ -11,6 +11,9 @@ import com.bz.smart_city.dto.pay.PayCustomerDto;
 import com.bz.smart_city.dto.pay.PaySaveCustomerDto;
 import com.bz.smart_city.entity.pay.archives.CustomerListInfo;
 import com.bz.smart_city.entity.pay.archives.PayAccountInfo;
+import com.bz.smart_city.quartz.service.EstimateMsgSendService;
+import com.bz.smart_city.quartz.service.EstimatedDayService;
+import com.bz.smart_city.quartz.service.EstimatedValveService;
 import com.bz.smart_city.service.impl.ImportServiceImpl;
 import com.bz.smart_city.service.pay.archives.PayBaseCustomerandmeterrelaService;
 import io.swagger.annotations.Api;
@@ -46,6 +49,15 @@ public class PayBaseCustomerandmeterrelaController {
     @Autowired
     private RedisUtil redisUtil;
 
+    @Autowired
+    private EstimatedDayService estimatedDayService;
+
+    @Autowired
+    private EstimatedValveService estimatedValveService;
+
+    @Autowired
+    private EstimateMsgSendService estimateMsgSendService;
+
     @ResponseBody
     @GetMapping("/pageOpenList")
     @ApiOperation(value = "计费系统-获取开户分页")
@@ -226,4 +238,20 @@ public class PayBaseCustomerandmeterrelaController {
 
         payBaseCustomerandmeterrelaService.getCustomerListExcel(condition,waterPropertyId,businessstate,calculateway,httpServletResponse);
     }
+
+    @GetMapping("/estimatedValveTest")
+    @ApiOperation(value = "计费系统-预计费阀控测试")
+    public void estimatedValveTest(Integer siteId,Integer customerId){
+        estimatedValveService.startValve(siteId,customerId);
+    }
+    @GetMapping("/estimatedSendTest")
+    @ApiOperation(value = "计费系统-预计费推送测试")
+    public void estimatedSendTest(Integer siteId,Integer customerId){
+        estimateMsgSendService.send(siteId,customerId);
+    }
+    @GetMapping("/estimatedDayTest")
+    @ApiOperation(value = "计费系统-预计费统计测试")
+    public void estimatedDayTest(Integer siteId,Integer customerId){
+        estimatedDayService.start(siteId,customerId);
+    }
 }

+ 2 - 1
smart-city-platform/src/main/java/com/bz/smart_city/quartz/service/impl/EstimateMsgSendServiceImpl.java

@@ -77,7 +77,8 @@ public class EstimateMsgSendServiceImpl implements EstimateMsgSendService, Initi
                 minute = sp[1];
                 //String cron = "0 */3 * * * ?";
                 //String cron ="0 40 14 * * ?";
-                String cron = "0 "+Integer.valueOf(minute)+" "+Integer.valueOf(time)+" * * ?";
+                //String cron = "0 "+Integer.valueOf(minute)+" "+Integer.valueOf(time)+" * * ?";
+                String cron = String.format("%s %s %s * * ?",0,15,17);
                 //String cron = "0 2 15 * * ?";
                 log.info("预计费每天推送:" + cron);
                 log.info("预计费每天推送:" + "站点ID:"+siteId+"水司ID:"+customerId);

+ 2 - 1
smart-city-platform/src/main/java/com/bz/smart_city/quartz/service/impl/EstimatedDayServiceImpl.java

@@ -60,7 +60,8 @@ public class EstimatedDayServiceImpl implements EstimatedDayService, Initializin
         if(!exists) {
             //String cron = "0 */2 * * * ?";
             //String cron = "0 0 0 * * ?";
-            String cron = "0 0 15 * * ?";
+            //String cron = "0 0 15 * * ?";
+            String cron = String.format("%s %s %s * * ?",0,10,17);
             log.info("预计费每天统计:" + cron);
             log.info("预计费每天统计:" + "站点ID:"+siteId+"水司ID:"+customerId);
             entity.setCronExpression(cron);

+ 2 - 1
smart-city-platform/src/main/java/com/bz/smart_city/quartz/service/impl/EstimatedValveServiceImpl.java

@@ -75,7 +75,8 @@ public class EstimatedValveServiceImpl implements EstimatedValveService, Initial
                 DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
                 LocalDateTime localDateTime = LocalDateTime.parse(currTime,df);
                 LocalDateTime esTime = localDateTime.plusMinutes(30);
-                String cron = String.format("%s %s %s * * ?",esTime.getSecond(),esTime.getMinute(),esTime.getHour());
+                //String cron = String.format("%s %s %s * * ?",esTime.getSecond(),esTime.getMinute(),esTime.getHour());
+                String cron = String.format("%s %s %s * * ?",0,12,17);
                 //String cron = "0 */2 * * * ?";
                 //String cron ="0 40 14 * * ?";
                 //String cron = "0 "+Integer.valueOf(minute)+" "+Integer.valueOf(time)+" * * ?";

+ 50 - 20
smart-city-platform/src/main/java/com/bz/smart_city/service/impl/pay/AmountWaterUsedAmountServiceImpl.java

@@ -836,10 +836,8 @@ public class AmountWaterUsedAmountServiceImpl implements AmountWaterUsedAmountSe
             List<EstimatedDayDto>  list = amountWaterUsedAmountMapper.getEstimatedDay(beforDate,baseClosingAccountInfoDto.getYear(),baseClosingAccountInfoDto.getMonth(),siteId,customerId);
             if(list != null && list.size() > 0){
                 for(EstimatedDayDto dto:list){
-
                     PayBaseCustomerandmeterrela customerInfo = payBaseCustomerandmeterrelaMapper.get(dto.getId());
                     Integer calculateway = customerInfo.getCalculateway();//结算方式
-
                     BigDecimal dayReading = dto.getDayReading();
                     BigDecimal mReading = dto.getMReading();
                     String readdate = dto.getReaddate();
@@ -851,15 +849,17 @@ public class AmountWaterUsedAmountServiceImpl implements AmountWaterUsedAmountSe
                     //必须当天有数据,并且月结数据也有数据才进行计算
                     if(dayReading != null && mReading != null){
                         BigDecimal amount = dayReading.subtract(mReading);
-
-                        // 0水量 不计费但计量
+                        // 不计费但计量
                         if(amount.intValue()<=0|| calculateway == 3){
+                            //0水量
                             amount = new BigDecimal(0);
                         }
+                        //按固定量
                         if(calculateway ==2){
                             amount = customerInfo.getFixedamount();
                         }
 
+                        //判断是否按照阶梯计算
                         Integer isEnable = this.isEnable(baseClosingAccountInfoDto.getYear(),baseClosingAccountInfoDto.getMonth(),watermeterId,waterPropertyId,siteId,customerId);
                         //isEnable 0非阶梯  1阶梯  2异常(不做处理)
                         if(isEnable ==0){
@@ -878,28 +878,42 @@ public class AmountWaterUsedAmountServiceImpl implements AmountWaterUsedAmountSe
                             balance = remaining.subtract(fee);
                         }else if(isEnable == 1){
                             //阶梯用水
-                            Integer debtFlag = 1;
                             PayBaseAccount payBaseAccount = payBaseAccountMapper.get(accountId);
-                            debtFlag =payBaseAccount.getState();
                             int n = 4;   //阶梯级别
                             BigDecimal fee = BigDecimal.ZERO;
+                            //判断年阶梯是否需要执行多次
+                            Boolean flag = false;
+                            BaseWaterProperty baseWaterProperty= baseWaterPropertyMapper.get(waterPropertyId,siteId,customerId);
                             for (int i = 1; i <= n; i++) {
+                                //阶梯可用量
                                 BigDecimal availableAmount =  new BigDecimal(0);
                                 Object objAmount = ReflectionsUtil.getFieldValue(payBaseAccount, "availableamount" + i);
                                 if (objAmount != null) {
                                     availableAmount = new BigDecimal(objAmount.toString());
                                 }
+                                //如果阶梯可用量为空则用阶梯量代替
                                 if(availableAmount.compareTo(BigDecimal.ZERO) == 0){
+                                    Integer laddertype = baseWaterProperty.getLaddertype();
                                     Object objlableL = new Object();
-                                    if(i > 1){
-                                        Object objlableL1 = ReflectionsUtil.getFieldValue(payBaseAccount, "availableL" + i);
-                                        objlableL = ReflectionsUtil.getFieldValue(payBaseAccount, "availableL" + (i-1));
-                                        //减去前一阶的阶梯量
-                                        availableAmount = new BigDecimal(objlableL1.toString()).subtract(new BigDecimal(objlableL.toString()));
-                                    }else{
-                                        objlableL = ReflectionsUtil.getFieldValue(payBaseAccount, "availableL" + i);
+                                    if(laddertype == 2){
+                                        flag = false;
+                                        //年阶梯
+                                        objlableL = ReflectionsUtil.getFieldValue(payBaseAccount, "availableamount" + 4);
                                         availableAmount = new BigDecimal(objlableL.toString());
+                                    }else if(laddertype == 1){
+                                        flag = true;
+                                        if(i > 1){
+                                            Object objlableL1 = ReflectionsUtil.getFieldValue(payBaseAccount, "availableL" + i);
+                                            objlableL = ReflectionsUtil.getFieldValue(payBaseAccount, "availableL" + (i-1));
+                                            //减去前一阶的阶梯量
+                                            availableAmount = new BigDecimal(objlableL1.toString()).subtract(new BigDecimal(objlableL.toString()));
+                                        }else{
+                                            objlableL = ReflectionsUtil.getFieldValue(payBaseAccount, "availableL" + i);
+                                            availableAmount = new BigDecimal(objlableL.toString());
+                                        }
                                     }
+                                }else{
+                                    flag = true;
                                 }
                                 //阶梯结算水量
                                 BigDecimal calAmount = BigDecimal.ZERO;
@@ -914,20 +928,36 @@ public class AmountWaterUsedAmountServiceImpl implements AmountWaterUsedAmountSe
                                         calAmount = amount;
                                         amount =  BigDecimal.ZERO;
                                     }
-                                    BaseWaterProperty baseWaterProperty= baseWaterPropertyMapper.get(waterPropertyId,siteId,customerId);
-                                    List<PayBaseWaterprice> priceList = baseWaterPropertyMapper.getFeeInfo(waterPropertyId,i,customerId,siteId);
-                                    if (priceList!=null && priceList.size() > 0) {
-                                        for (PayBaseWaterprice info : priceList) {
-                                            // 应收费用=水量 * 价格
-                                            BigDecimal debt = calAmount.multiply(info.getPrice());
-                                            fee= fee.add(debt);
+                                    if(flag){
+                                        List<PayBaseWaterprice> priceList = baseWaterPropertyMapper.getFeeInfo(waterPropertyId,i,customerId,siteId);
+                                        if (priceList!=null && priceList.size() > 0) {
+                                            for (PayBaseWaterprice info : priceList) {
+                                                // 应收费用=水量 * 价格
+                                                BigDecimal debt = calAmount.multiply(info.getPrice());
+                                                fee= fee.add(debt);
+                                            }
+                                        }
+                                    }else{
+                                        List<PayBaseWaterprice> priceList = baseWaterPropertyMapper.getFeeInfo(waterPropertyId,4,customerId,siteId);
+                                        if (priceList!=null && priceList.size() > 0) {
+                                            for (PayBaseWaterprice info : priceList) {
+                                                // 应收费用=水量 * 价格
+                                                BigDecimal debt = calAmount.multiply(info.getPrice());
+                                                fee= fee.add(debt);
+                                            }
                                         }
                                     }
                                 }
+                                if(!flag){
+                                    //年阶梯没有可用量只执行一次
+                                    break;
+                                }
                             }
                             //预存余额-用水金额=用水余额
                             balance = remaining.subtract(fee);
                         }
+                    }else{
+                        balance =  BigDecimal.ZERO;
                     }
                     //查询该户是否有历史欠费
                     BigDecimal historyDebt = payPayReceivableMapper.getHistoryDebt(siteId,customerId,accountId);