Explorar o código

1添加预计费功能

Xiaojh %!s(int64=4) %!d(string=hai) anos
pai
achega
91fbc7c235
Modificáronse 18 ficheiros con 407 adicións e 18 borrados
  1. 3 0
      smart-city-platform/src/main/java/com/bz/smart_city/dao/pay/AmountWaterUsedAmountMapper.java
  2. 2 0
      smart-city-platform/src/main/java/com/bz/smart_city/dao/pay/BaseClosingAccountInfoMapper.java
  3. 5 0
      smart-city-platform/src/main/java/com/bz/smart_city/dao/pay/PayRechargeaccountMapper.java
  4. 18 0
      smart-city-platform/src/main/java/com/bz/smart_city/dto/pay/EstimatedDayDto.java
  5. 5 0
      smart-city-platform/src/main/java/com/bz/smart_city/dto/pay/PayCustomerDto.java
  6. 3 0
      smart-city-platform/src/main/java/com/bz/smart_city/dto/pay/PayMessageTemplateDto.java
  7. 6 0
      smart-city-platform/src/main/java/com/bz/smart_city/dto/pay/PayRechargeaccountDto.java
  8. 2 3
      smart-city-platform/src/main/java/com/bz/smart_city/entity/pay/archives/PayBaseCustomerandmeterrela.java
  9. 11 6
      smart-city-platform/src/main/java/com/bz/smart_city/quartz/job/EstimatedDayJob.java
  10. 10 1
      smart-city-platform/src/main/java/com/bz/smart_city/quartz/service/EstimatedDayService.java
  11. 35 7
      smart-city-platform/src/main/java/com/bz/smart_city/quartz/service/impl/EstimatedDayServiceImpl.java
  12. 186 0
      smart-city-platform/src/main/java/com/bz/smart_city/service/impl/pay/AmountWaterUsedAmountServiceImpl.java
  13. 53 0
      smart-city-platform/src/main/java/com/bz/smart_city/service/impl/pay/PayMessagesendrecordServiceImp.java
  14. 4 0
      smart-city-platform/src/main/java/com/bz/smart_city/service/pay/AmountWaterUsedAmountService.java
  15. 33 0
      smart-city-platform/src/main/resources/mapper/pay/AmountWaterUsedAmountMapper.xml
  16. 1 0
      smart-city-platform/src/main/resources/mapper/pay/PayMessagetemplateMapper.xml
  17. 22 1
      smart-city-platform/src/main/resources/mapper/pay/PayRechargeaccountMapper.xml
  18. 8 0
      smart-city-platform/src/main/resources/mapper/pay/baseClosingAccountInfoMapper.xml

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

@@ -91,4 +91,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);
 
+    List<EstimatedDayDto> getEstimatedDay(@Param("readdate")String readdate,@Param("year")Integer year,@Param("month")Integer month,
+                                          @Param("siteId")Integer siteId,@Param("customerId")Integer customerId);
+
 }

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

@@ -36,4 +36,6 @@ public interface BaseClosingAccountInfoMapper {
     public BaseClosingAccountInfoDto getLastClosingAccount( @Param("siteId")Integer siteId,@Param("customerId") Integer customerId);
 
     BaseClosingAccountInfoDto getCurrentCloseInfo(@Param("siteId")Integer siteId,@Param("customerId") Integer customerId);
+
+    List<BaseClosingAccountInfoDto> getClosingSC();
 }

+ 5 - 0
smart-city-platform/src/main/java/com/bz/smart_city/dao/pay/PayRechargeaccountMapper.java

@@ -4,6 +4,7 @@ import com.bz.smart_city.dto.pay.PayRechargeaccountDto;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
 
+import java.math.BigDecimal;
 import java.math.BigInteger;
 import java.util.List;
 
@@ -30,4 +31,8 @@ public interface PayRechargeaccountMapper {
     void batchDelete( @Param("accountIds") List<BigInteger> accountIds);
 
     int batchInsert(List<PayRechargeaccountDto> list);
+
+    void updateBalance(@Param("balance") BigDecimal balance, @Param("readdate") String readdate, @Param("id")BigInteger id);
+
+    public List<PayRechargeaccountDto> getEstimateBalance(@Param("siteId") Integer siteId,@Param("customerId") Integer customerId);
 }

+ 18 - 0
smart-city-platform/src/main/java/com/bz/smart_city/dto/pay/EstimatedDayDto.java

@@ -0,0 +1,18 @@
+package com.bz.smart_city.dto.pay;
+
+import lombok.Data;
+
+import java.math.BigDecimal;
+import java.math.BigInteger;
+
+@Data
+public class EstimatedDayDto {
+    private BigInteger id;//开户ID
+    private String metercode;//水表档案号
+    private String readdate;//每天抄表日期
+    private BigDecimal dayReading;//每天止度
+    private BigDecimal MReading;//月结止度
+    private BigInteger waterpropertyId;//用水性质ID
+    private BigInteger watermeterId;//水表ID
+    private BigInteger accountId;//客户ID
+}

+ 5 - 0
smart-city-platform/src/main/java/com/bz/smart_city/dto/pay/PayCustomerDto.java

@@ -70,4 +70,9 @@ public class PayCustomerDto {
     public String email;
     @ApiModelProperty(value = "水表电子号",position = 24)
     public String metereleno;
+
+    @ApiModelProperty(value = "阀控规则数组名称",position = 25)
+    public String valveRuleName;
+    @ApiModelProperty(value = "阀控规则数组Id",position = 26)
+    public String valveRuleId;
 }

+ 3 - 0
smart-city-platform/src/main/java/com/bz/smart_city/dto/pay/PayMessageTemplateDto.java

@@ -45,6 +45,9 @@ public class PayMessageTemplateDto extends BaseDto {
     @ApiModelProperty(value = "停水短信模板")
     private String template3;
 
+    @ApiModelProperty(value = "预计费短信模板")
+    private String template4;
+
     @ApiModelProperty(value = "模板说明")
     private String template;
 

+ 6 - 0
smart-city-platform/src/main/java/com/bz/smart_city/dto/pay/PayRechargeaccountDto.java

@@ -1,11 +1,13 @@
 package com.bz.smart_city.dto.pay;
 
+import com.fasterxml.jackson.annotation.JsonFormat;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 
 import java.math.BigDecimal;
 import java.math.BigInteger;
+import java.time.LocalDateTime;
 
 /**
  * @Author wangli
@@ -34,6 +36,10 @@ public class PayRechargeaccountDto extends BaseDto{
 
     @ApiModelProperty(value = "机构id", hidden = true)
     private BigInteger officeId;
+    @ApiModelProperty("用水余额")
+    private BigDecimal balance;
 
+    @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
+    private LocalDateTime estimatedDate;
 
 }

+ 2 - 3
smart-city-platform/src/main/java/com/bz/smart_city/entity/pay/archives/PayBaseCustomerandmeterrela.java

@@ -102,9 +102,8 @@ public class PayBaseCustomerandmeterrela {
     @ApiModelProperty(value = "水表电子号", position = 33)
     public String metereleno;
 
-    @ApiModelProperty(value = "阀控规则ID,例:1,2,3,4", position = 34)
+    @ApiModelProperty(value = "阀控规则数组ID", position = 34)
     public String valveRuleId;
-
-    @ApiModelProperty(value = "阀控规则名称", position = 35)
+    @ApiModelProperty(value = "阀控规则数组名称", position = 35)
     public String valveRuleName;
 }

+ 11 - 6
smart-city-platform/src/main/java/com/bz/smart_city/quartz/job/EstimatedDayJob.java

@@ -2,9 +2,7 @@ package com.bz.smart_city.quartz.job;
 
 import com.bz.smart_city.quartz.service.EstimatedDayService;
 import lombok.extern.slf4j.Slf4j;
-import org.quartz.Job;
-import org.quartz.JobExecutionContext;
-import org.quartz.JobExecutionException;
+import org.quartz.*;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 
@@ -24,9 +22,16 @@ public class EstimatedDayJob implements Job, Serializable {
 
     @Override
     public void execute(JobExecutionContext context) throws JobExecutionException {
+
+        // 1,获取推送配置信息
+        JobDetail jobDetail = context.getJobDetail();
+        JobDataMap jobDataMap = jobDetail.getJobDataMap();
+        Integer siteId = Integer.valueOf(jobDataMap.get("siteId").toString());
+        Integer customerId = Integer.valueOf(jobDataMap.get("customerId").toString());
+
         // 2,调用推送方法
-        log.info("invoke EstimatedDayJob");
-        estimatedDayService.start();
-        log.info("invoked EstimatedDayJob");
+        log.info("invoke EstimatedDayJob , customerId = {}",customerId);
+        estimatedDayService.start(siteId,customerId);
+        log.info("invoked EstimatedDayJob , customerId = {}",customerId);
     }
 }

+ 10 - 1
smart-city-platform/src/main/java/com/bz/smart_city/quartz/service/EstimatedDayService.java

@@ -1,10 +1,19 @@
 package com.bz.smart_city.quartz.service;
 
+import java.math.BigInteger;
+
 /**
  * @description
  * @auto xjh
  * @data 2021-01-12 15:32
  */
 public interface EstimatedDayService {
-    void start();
+
+    void afterPropertiesSet();
+
+    void saveQrtzTask(BigInteger siteId, BigInteger customerId);
+
+    void deleteQrtzTask();
+
+    void start(Integer siteId,Integer customerId);
 }

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

@@ -1,14 +1,21 @@
 package com.bz.smart_city.quartz.service.impl;
 
+import com.alibaba.druid.sql.visitor.functions.Bin;
+import com.bz.smart_city.dao.pay.BaseClosingAccountInfoMapper;
+import com.bz.smart_city.dto.pay.BaseClosingAccountInfoDto;
 import com.bz.smart_city.quartz.entity.QuartzEntity;
 import com.bz.smart_city.quartz.job.EstimatedDayJob;
 import com.bz.smart_city.quartz.service.EstimatedDayService;
 import com.bz.smart_city.quartz.service.JobAndTriggerService;
+import com.bz.smart_city.service.pay.AmountWaterUsedAmountService;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.InitializingBean;
 import org.springframework.stereotype.Component;
 
 import javax.annotation.Resource;
+import java.math.BigInteger;
+import java.util.HashMap;
+import java.util.List;
 
 /**
  * @description
@@ -22,27 +29,45 @@ public class EstimatedDayServiceImpl implements EstimatedDayService, Initializin
     @Resource
     private JobAndTriggerService jobAndTriggerService;
 
+    @Resource
+    private AmountWaterUsedAmountService amountWaterUsedAmountService;
+
+    @Resource
+    private BaseClosingAccountInfoMapper baseClosingAccountInfoMapper;
+
     @Override
     public void afterPropertiesSet() {
-        saveQrtzTask();
+
+        List<BaseClosingAccountInfoDto> closingList = baseClosingAccountInfoMapper.getClosingSC();
+        if(closingList != null && closingList.size() >0){
+            for(BaseClosingAccountInfoDto list:closingList ){
+                saveQrtzTask(list.getSiteId(),list.getCustomerId());
+            }
+        }
     }
 
 
-    public void saveQrtzTask() {
+    public void saveQrtzTask(BigInteger siteId, BigInteger customerId) {
         // 1,查询需要批量推送的配置项目并构建定时任务
         // 2,若对应定时任务不存在则创建
         QuartzEntity entity = new QuartzEntity();
         entity.setJobGroup("预计费每天统计");
-        entity.setJobName("EstimatedDayJob" );
-        entity.setDescription("EstimatedDayJob" );
+        entity.setJobName("EstimatedDayJob"+siteId );
+        entity.setDescription("EstimatedDayJob"+customerId );
         // modify by pengdi ,判断定时任务是否存在,不存在才进行新增
 
         boolean exists = jobAndTriggerService.isExists(entity);
         if(!exists) {
-            String cron = "0 */1 * * * ?";
+            //String cron = "0 */2 * * * ?";
+            String cron = "0 0 19 * * ? ";
             log.info("预计费每天统计:" + cron);
+            log.info("预计费每天统计:" + "站点ID:"+siteId+"水司ID:"+customerId);
             entity.setCronExpression(cron);
             entity.setJobClassName(EstimatedDayJob.class.getName());
+            HashMap<String, Object> jobData = new HashMap<String, Object>();
+            jobData.put("siteId", siteId);
+            jobData.put("customerId", customerId);
+            entity.setJobData(jobData);
             jobAndTriggerService.save(entity);
         }
     }
@@ -58,7 +83,10 @@ public class EstimatedDayServiceImpl implements EstimatedDayService, Initializin
         }
     }
 
-    public void start(){
-        log.info("================================================>预计费每天统计<=====================================");
+    public void start(Integer siteId,Integer customerId){
+        log.info("================================================>预计费每天统计开始<=====================================");
+        amountWaterUsedAmountService.estimatedDay(siteId,customerId);
+        log.info("================================================>预计费每天统计完成<=====================================");
+
     }
 }

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

@@ -28,6 +28,7 @@ import javax.annotation.Resource;
 import javax.servlet.http.HttpServletResponse;
 import java.math.BigDecimal;
 import java.math.BigInteger;
+import java.text.SimpleDateFormat;
 import java.time.LocalDateTime;
 import java.time.format.DateTimeFormatter;
 import java.util.*;
@@ -73,6 +74,12 @@ public class AmountWaterUsedAmountServiceImpl implements AmountWaterUsedAmountSe
     @Resource
     private SiteMapper siteMapper;
 
+    @Resource
+    PayMessagetemplateMapper payMessagetemplateMapper;
+
+    @Resource
+    private PayMessagesendrecordServiceImp payMessagesendrecordServiceImp;
+
     @Override
     public Pagination<AmountWaterUsedAmountDto> getList(String condition, String accountNumber, String accountName, String meterCode, String address, Integer year, Integer month, Integer state,
                                                         Integer amountMin, Integer amountMax, Integer pageNum, Integer pageSize) {
@@ -717,4 +724,183 @@ public class AmountWaterUsedAmountServiceImpl implements AmountWaterUsedAmountSe
 
     }
 
+    public Integer isEnable(Integer year,Integer month,BigInteger watermeterId,BigInteger waterPropertyId,Integer siteId,Integer customerId){
+        Integer isEnable = 1;
+        if(waterPropertyId != null){
+            //根据用水性质ID查找是否是阶梯
+            BaseWaterPropertyDto waterPropertyDto = baseWaterPropertyMapper.get(waterPropertyId,siteId,customerId);
+            Integer laddertype = waterPropertyDto.getLaddertype();
+            if(laddertype != null && laddertype == 0){
+                isEnable = 0;
+            }
+        }
+
+        //月阶梯用户 新安装户相差天数>31天或者跨账期结算则非阶梯结算
+        if(isEnable>=1){
+            List<AmountWaterUsedAmountDto> amountWaterUsedAmounts = amountWaterUsedAmountMapper.getWaterUsedAmountByMeterId(watermeterId);
+            if(amountWaterUsedAmounts!=null && amountWaterUsedAmounts.size()>0){
+                AmountWaterUsedAmountDto theLastOne = null;
+                if(amountWaterUsedAmounts.size()>1){
+                    //取最后一次已审核
+                    theLastOne = amountWaterUsedAmounts.get(1);
+                    if((theLastOne.getYear() - year) ==0){
+                        //同年跨月
+                        if(month-theLastOne.getMonth()>1){
+                            isEnable =0;
+                        }
+                    }else if((year - theLastOne.getYear()) == 1){
+                        if((month!= 1||theLastOne.getMonth()!= 12)){
+                            isEnable =0;
+                        }
+                    }else{
+                        //跨年
+                        isEnable =0;
+                    }
+                }else{
+                    //新安装户,取安装时间比较
+                    theLastOne = amountWaterUsedAmounts.get(0);
+                    Date createDate = theLastOne.getInstalldate();
+                    if(createDate!=null) {
+                        Double sDay = DateTimeUtil.getDistanceOfTwoDate(createDate, new Date());
+                        if (sDay > 31) {
+                            isEnable = 0;
+                        }
+                    }else{
+                        isEnable = 2;//异常
+                       /* ajaxMessage.setMsg(-701,"水表设备"+amountWaterUsedAmount.getMetercode()+"安装时间为空");
+                        return ajaxMessage;*/
+                    }
+                }
+            }
+        }
+        return isEnable;
+    }
+
+    public void estimatedDay(Integer siteId,Integer customerId){
+        //  createReceivable
+        //查询当前账期
+        Calendar calendar = Calendar.getInstance(); //得到日历
+        Date dNow = new Date();   //当前时间
+        calendar.setTime(dNow);//把当前时间赋给日历
+        calendar.add(Calendar.DAY_OF_MONTH, -1);  //设置为前一天
+        String beforDate = new SimpleDateFormat("yyyyMMdd").format(calendar.getTime());//格式化前一天
+        //获取最新账期
+        BaseClosingAccountInfoDto baseClosingAccountInfoDto = baseClosingAccountInfoMapper.getLastClosingAccount(siteId,customerId);
+        //1.如果账期为空则取水表起度
+        //1.1.费用=(每天的止度-月用量)*单价
+        BigDecimal balance = BigDecimal.ZERO;
+        if(baseClosingAccountInfoDto != null){
+            //根据最新账期,水司进行统计每天
+            List<EstimatedDayDto>  list = amountWaterUsedAmountMapper.getEstimatedDay(beforDate,baseClosingAccountInfoDto.getYear(),baseClosingAccountInfoDto.getMonth(),siteId,customerId);
+            if(list != null && list.size() > 0){
+                for(EstimatedDayDto dto:list){
+                    BigDecimal dayReading = dto.getDayReading();
+                    BigDecimal mReading = dto.getMReading();
+                    String readdate = dto.getReaddate();
+                    BigInteger waterPropertyId =  dto.getWaterpropertyId();
+                    BigInteger watermeterId = dto.getWatermeterId();
+                    BigInteger accountId = dto.getAccountId();
+                    PayRechargeaccountDto payRechargeaccountDto = payRechargeaccountMapper.findById(null,accountId);//查询预存账户
+                    BigDecimal remaining = payRechargeaccountDto.getRemaining();//预存金额
+                    //必须当天有数据,并且月结数据也有数据才进行计算
+                    if(dayReading != null && mReading != null){
+                        BigDecimal amount = dayReading.subtract(mReading);
+
+                        Integer isEnable = this.isEnable(baseClosingAccountInfoDto.getYear(),baseClosingAccountInfoDto.getMonth(),watermeterId,waterPropertyId,siteId,customerId);
+                        //isEnable 0非阶梯  1阶梯  2异常(不做处理)
+                        if(isEnable ==0){
+                            //非阶梯用水
+                            BaseWaterProperty baseWaterProperty= baseWaterPropertyMapper.get(waterPropertyId,siteId,customerId);
+                            List<PayBaseWaterprice> priceList = baseWaterPropertyMapper.getFeeInfo(waterPropertyId,1,customerId,siteId);
+                            BigDecimal fee = BigDecimal.ZERO;
+                            if (priceList!=null && priceList.size() > 0) {
+                                for (PayBaseWaterprice info : priceList) {
+                                    // 应收费用=水量 * 价格
+                                    BigDecimal debt = amount.multiply(info.getPrice());
+                                    fee= fee.add(debt);
+                                }
+                            }
+                            //预存余额-用水金额=用水余额
+                            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;
+                            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());
+                                }
+                                //阶梯结算水量
+                                BigDecimal calAmount = BigDecimal.ZERO;
+                                if (availableAmount.intValue() > 0) {
+                                    if (amount.intValue() == 0) {
+                                        break;
+                                    }
+                                    if (amount.intValue() > availableAmount.intValue()) {
+                                        calAmount = availableAmount;
+                                        amount = amount.subtract(availableAmount);
+                                    } else {
+                                        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);
+                                        }
+                                    }
+                                }
+                            }
+                            //预存余额-用水金额=用水余额
+                            balance = remaining.subtract(fee);
+                        }
+                    }
+                    payRechargeaccountMapper.updateBalance(balance,new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()),payRechargeaccountDto.getId());
+                    //修改账户用水余额字段跟预计费日期
+                    log.info("【"+payRechargeaccountDto.getAccountnumber()+"】户:用水余额:"+balance+",预计费日期:"+new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
+                }
+            }
+        }else{
+            //取起度作为量(每天的用量-起度)
+        }
+    }
+
+    public void estimateMsgSend(Integer siteId,Integer customerId){
+
+        PayMessageTemplateDto payMessageTemplateDto = new PayMessageTemplateDto();
+        payMessageTemplateDto.setSiteId(BigInteger.valueOf(siteId));
+        payMessageTemplateDto.setCustomerId(BigInteger.valueOf(customerId));
+        payMessageTemplateDto.setSendType(0);
+
+        //获取短信模板
+        PayMessageTemplateDto templateList= payMessagetemplateMapper.get(BigInteger.valueOf(siteId),BigInteger.valueOf(customerId),null,null);
+        if(templateList == null){
+            //获取短信模板失败,没查询到有效模板
+            throw new ServiceException(ResultStatus.MESSAGE_TEMPLATE_FAILED);
+        }
+        //获取最新账期
+        BaseClosingAccountInfoDto baseClosingAccountInfoDto=baseClosingAccountInfoMapper.getLastClosingAccount(siteId,customerId);
+        if(baseClosingAccountInfoDto == null){
+            throw new ServiceException(ResultStatus.ClOSING_ACCCOUNT_NOT_EXIT);
+        }
+        //根据站点跟客户ID查找出用水余额小于0用户
+        List<PayRechargeaccountDto> rechList = payRechargeaccountMapper.getEstimateBalance(siteId,customerId);
+        if(rechList != null && rechList.size() >0){
+            for(PayRechargeaccountDto dto: rechList){
+                PayBaseAccount account = payBaseAccountMapper.get(dto.getAccountId());
+                payMessagesendrecordServiceImp.sendEstimateMessage(BigInteger.valueOf(siteId),BigInteger.valueOf(customerId),templateList,baseClosingAccountInfoDto.getYear(),baseClosingAccountInfoDto.getMonth(),account);
+            }
+        }
+
+        System.out.println("==============================>预计费短信推送成功<============================");
+    }
+
 }

+ 53 - 0
smart-city-platform/src/main/java/com/bz/smart_city/service/impl/pay/PayMessagesendrecordServiceImp.java

@@ -17,6 +17,7 @@ import com.bz.smart_city.dto.pay.PayDebtMessageDto;
 import com.bz.smart_city.dto.pay.PayMessageTemplateDto;
 import com.bz.smart_city.dto.pay.PayMessagesendrecordDto;
 import com.bz.smart_city.entity.ProgramItem;
+import com.bz.smart_city.entity.pay.PayBaseAccount;
 import com.bz.smart_city.quartz.entity.QuartzEntity;
 import com.bz.smart_city.quartz.job.MessageSendJob;
 import com.bz.smart_city.quartz.service.JobAndTriggerService;
@@ -446,5 +447,57 @@ public class PayMessagesendrecordServiceImp implements PayMessagesendrecordServi
         }
     }
 
+    public Integer sendEstimateMessage(BigInteger siteId, BigInteger customerId, PayMessageTemplateDto templates, Integer year,Integer month, PayBaseAccount payDebtMessageDto) {
+        String template = "";
+        template=templates.getTemplate4();
+        //拼接短信内容
+        StringBuilder address= new StringBuilder(payDebtMessageDto.getAddress());
+        if(address.length()>6){
+            address.replace(0,address.length()-5,"*****");
+        }else{
+            address.replace(0,address.length()/2,"*****");
+        }
+        String message= template.replace("{accountname}",new StringBuilder(payDebtMessageDto.getName()).replace(0,1,"*"))
+                .replace("{accountnumber}",payDebtMessageDto.getAccountnumber())
+                .replace("{address}",address.toString());
+        //生成推送记录
+        PayMessagesendrecordDto payMessagesendrecordDto=new PayMessagesendrecordDto();
+        payMessagesendrecordDto.setAccountId(payDebtMessageDto.getId());
+        payMessagesendrecordDto.setAccountname(payDebtMessageDto.getName());
+        payMessagesendrecordDto.setAccountnumber(payDebtMessageDto.getAccountnumber());
+        payMessagesendrecordDto.setAddress(payDebtMessageDto.getAddress());
+        payMessagesendrecordDto.setYear(year);
+        payMessagesendrecordDto.setMonth(month);
+        payMessagesendrecordDto.setContent(message);
+        payMessagesendrecordDto.setType(1);
+        payMessagesendrecordDto.setMobilephone(payDebtMessageDto.getMobilephone());
+
+        //推送短信参数设置
+        SendReq sendReq = new SendReq();
+        sendReq.setApId(templates.getApId());
+        sendReq.setEcName(templates.getEcName());
+        sendReq.setSecretKey(templates.getSecretKey());
+        sendReq.setContent(message);
+        sendReq.setMobiles(payDebtMessageDto.getMobilephone());
+        sendReq.setSign(templates.getSign());
+        //
+        //短信推送:1成功 0失败
+        int result = SMSClient.sendMsg(sendReq);
+        if(result == 1){
+            payMessagesendrecordDto.setState("成功");
+        }else{
+            payMessagesendrecordDto.setState("失败");
+        }
+
+        payMessagesendrecordDto.setCreateBy(templates.getUpdateBy());
+        payMessagesendrecordDto.setCreateDate(LocalDateTime.now());
+        payMessagesendrecordDto.setUpdateBy(templates.getUpdateBy());
+        payMessagesendrecordDto.setUpdateDate(LocalDateTime.now());
+        payMessagesendrecordDto.setDelFlag("0");
+        payMessagesendrecordDto.setSiteId(siteId);
+        payMessagesendrecordDto.setCustomerId(customerId);
+        payMessagesendrecordMapper.insert(payMessagesendrecordDto);
+        return result;
+    }
 
 }

+ 4 - 0
smart-city-platform/src/main/java/com/bz/smart_city/service/pay/AmountWaterUsedAmountService.java

@@ -32,4 +32,8 @@ public interface AmountWaterUsedAmountService {
      * @param deviceReplaceRecordDto
      */
     void saveDeviceReplaceRecord(DeviceReplaceRecordDto deviceReplaceRecordDto);
+
+    void estimatedDay(Integer siteId,Integer customerId);
+
+    void estimateMsgSend(Integer siteId,Integer customerId);
 }

+ 33 - 0
smart-city-platform/src/main/resources/mapper/pay/AmountWaterUsedAmountMapper.xml

@@ -673,4 +673,37 @@
 		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>

+ 1 - 0
smart-city-platform/src/main/resources/mapper/pay/PayMessagetemplateMapper.xml

@@ -127,6 +127,7 @@
             a.template1 as "template1",
             a.template2 as "template2",
             a.template3 as "template3",
+            a.template4 as "template4",
             a.days as "days",
             a.send_time as "sendTime",
             a.send_type as "sendType",

+ 22 - 1
smart-city-platform/src/main/resources/mapper/pay/PayRechargeaccountMapper.xml

@@ -16,7 +16,9 @@
         a.del_flag as "delFlag",
         a.site_id as "siteId",
         a.customer_id as "customerId",
-        a.office_id as "officeId"
+        a.office_id as "officeId",
+        a.balance as "balance",
+        a.estimatedDate as "estimatedDate"
     </sql>
     <select id="findList" resultType="com.bz.smart_city.dto.pay.PayRechargeaccountDto">
         select
@@ -209,5 +211,24 @@
         </foreach>
     </insert>
 
+    <update id="updateBalance">
+        update pay_pay_rechargeaccount set balance=#{balance},estimatedDate =#{readdate} where id =#{id}
+    </update>
+
+    <select id="getEstimateBalance" resultType="com.bz.smart_city.dto.pay.PayRechargeaccountDto">
+        select
+        <include refid="mainColumnInfo"/>
+        from pay_pay_rechargeaccount a
+        <where>
+            balance &lt; 0
+            <if test="siteId != null">
+                and a.site_id =#{siteId}
+            </if>
+            <if test="customerId != null">
+                and a.customer_id =#{customerId}
+            </if>
+        </where>
+    </select>
+
 </mapper>
 

+ 8 - 0
smart-city-platform/src/main/resources/mapper/pay/baseClosingAccountInfoMapper.xml

@@ -217,5 +217,13 @@
 		limit 1
 	</select>
 
+	<select id="getClosingSC" resultType="com.bz.smart_city.dto.pay.BaseClosingAccountInfoDto">
+		select
+			site_id as "siteId",
+			customer_id as "customerId"
+		from pay_base_closingaccountinfo
+		GROUP BY site_id,customer_id
+	</select>
+
 
 </mapper>