Browse Source

Merge branch '20200918' of http://114.135.61.188:53000/ZONIOT/water-iot into 20200918

oppadmin 4 years ago
parent
commit
d8215b2903
34 changed files with 836 additions and 33 deletions
  1. 26 0
      smart-city-platform/src/main/java/com/bz/smart_city/commom/util/jsonSerializer/BigDecimalJsonSerializer.java
  2. 24 0
      smart-city-platform/src/main/java/com/bz/smart_city/commom/util/jsonSerializer/DoubleJsonSerializer.java
  3. 33 0
      smart-city-platform/src/main/java/com/bz/smart_city/commom/util/jsonSerializer/ValveStateJsonSerializer.java
  4. 2 2
      smart-city-platform/src/main/java/com/bz/smart_city/controller/pay/PayControlRecordController.java
  5. 3 0
      smart-city-platform/src/main/java/com/bz/smart_city/dao/pay/AmountWaterUsedAmountMapper.java
  6. 2 0
      smart-city-platform/src/main/java/com/bz/smart_city/dao/pay/BaseClosingAccountInfoMapper.java
  7. 9 0
      smart-city-platform/src/main/java/com/bz/smart_city/dao/pay/PayControlRecordMapper.java
  8. 5 0
      smart-city-platform/src/main/java/com/bz/smart_city/dao/pay/PayRechargeaccountMapper.java
  9. 18 0
      smart-city-platform/src/main/java/com/bz/smart_city/dto/pay/EstimatedDayDto.java
  10. 5 0
      smart-city-platform/src/main/java/com/bz/smart_city/dto/pay/PayCustomerDto.java
  11. 3 0
      smart-city-platform/src/main/java/com/bz/smart_city/dto/pay/PayMessageTemplateDto.java
  12. 6 0
      smart-city-platform/src/main/java/com/bz/smart_city/dto/pay/PayRechargeaccountDto.java
  13. 4 1
      smart-city-platform/src/main/java/com/bz/smart_city/dto/pay/payfee/PayfeeAccountInfoDto.java
  14. 1 1
      smart-city-platform/src/main/java/com/bz/smart_city/entity/pay/PayControlRecord.java
  15. 2 3
      smart-city-platform/src/main/java/com/bz/smart_city/entity/pay/archives/PayBaseCustomerandmeterrela.java
  16. 64 0
      smart-city-platform/src/main/java/com/bz/smart_city/kafka/ValveStateConsumer.java
  17. 37 0
      smart-city-platform/src/main/java/com/bz/smart_city/quartz/job/EstimateMsgSendJob.java
  18. 11 6
      smart-city-platform/src/main/java/com/bz/smart_city/quartz/job/EstimatedDayJob.java
  19. 18 0
      smart-city-platform/src/main/java/com/bz/smart_city/quartz/service/EstimateMsgSendService.java
  20. 10 1
      smart-city-platform/src/main/java/com/bz/smart_city/quartz/service/EstimatedDayService.java
  21. 113 0
      smart-city-platform/src/main/java/com/bz/smart_city/quartz/service/impl/EstimateMsgSendServiceImpl.java
  22. 35 7
      smart-city-platform/src/main/java/com/bz/smart_city/quartz/service/impl/EstimatedDayServiceImpl.java
  23. 186 0
      smart-city-platform/src/main/java/com/bz/smart_city/service/impl/pay/AmountWaterUsedAmountServiceImpl.java
  24. 53 0
      smart-city-platform/src/main/java/com/bz/smart_city/service/impl/pay/PayMessagesendrecordServiceImp.java
  25. 4 0
      smart-city-platform/src/main/java/com/bz/smart_city/service/pay/AmountWaterUsedAmountService.java
  26. 28 1
      smart-city-platform/src/main/resources/application-dev.properties
  27. 23 8
      smart-city-platform/src/main/resources/application-prd.properties
  28. 25 1
      smart-city-platform/src/main/resources/application-sit.properties
  29. 33 0
      smart-city-platform/src/main/resources/mapper/pay/AmountWaterUsedAmountMapper.xml
  30. 21 0
      smart-city-platform/src/main/resources/mapper/pay/PayControlRecordMapper.xml
  31. 1 0
      smart-city-platform/src/main/resources/mapper/pay/PayMessagetemplateMapper.xml
  32. 22 1
      smart-city-platform/src/main/resources/mapper/pay/PayRechargeaccountMapper.xml
  33. 8 0
      smart-city-platform/src/main/resources/mapper/pay/baseClosingAccountInfoMapper.xml
  34. 1 1
      smart-city-platform/src/main/resources/mapper/pay/payFeeMapper.xml

+ 26 - 0
smart-city-platform/src/main/java/com/bz/smart_city/commom/util/jsonSerializer/BigDecimalJsonSerializer.java

@@ -0,0 +1,26 @@
+package com.bz.smart_city.commom.util.jsonSerializer;
+
+import com.fasterxml.jackson.core.JsonGenerator;
+import com.fasterxml.jackson.databind.JsonSerializer;
+import com.fasterxml.jackson.databind.SerializerProvider;
+
+import java.io.IOException;
+import java.math.BigDecimal;
+import java.text.DecimalFormat;
+
+/**
+ * @description BigDecimal保留三位小数
+ * @auto wangli
+ * @data 2020/12/31 14:17
+ */
+public class BigDecimalJsonSerializer extends JsonSerializer<BigDecimal> {
+
+    private DecimalFormat df = new DecimalFormat("0.000");
+
+    @Override
+    public void serialize(BigDecimal bigDecimal, JsonGenerator jsonGenerator, SerializerProvider serializerProvider) throws IOException {
+        if(bigDecimal != null){
+            jsonGenerator.writeString(df.format(bigDecimal));
+        }
+    }
+}

+ 24 - 0
smart-city-platform/src/main/java/com/bz/smart_city/commom/util/jsonSerializer/DoubleJsonSerializer.java

@@ -0,0 +1,24 @@
+package com.bz.smart_city.commom.util.jsonSerializer;
+
+import com.fasterxml.jackson.core.JsonGenerator;
+import com.fasterxml.jackson.databind.JsonSerializer;
+import com.fasterxml.jackson.databind.SerializerProvider;
+
+import java.io.IOException;
+import java.text.DecimalFormat;
+
+/**
+ * @description Double保留三位小数
+ * @auto wangli
+ * @data 2020/12/31 14:17
+ */
+public class DoubleJsonSerializer extends JsonSerializer<Double> {
+
+    private DecimalFormat df = new DecimalFormat("0.000");
+    @Override
+    public void serialize(Double aDouble, JsonGenerator jsonGenerator, SerializerProvider serializerProvider) throws IOException {
+        if(aDouble != null) {
+            jsonGenerator.writeString(df.format(aDouble));
+        }
+    }
+}

+ 33 - 0
smart-city-platform/src/main/java/com/bz/smart_city/commom/util/jsonSerializer/ValveStateJsonSerializer.java

@@ -0,0 +1,33 @@
+package com.bz.smart_city.commom.util.jsonSerializer;
+
+import com.fasterxml.jackson.core.JsonGenerator;
+import com.fasterxml.jackson.databind.JsonSerializer;
+import com.fasterxml.jackson.databind.SerializerProvider;
+
+import java.io.IOException;
+import java.math.BigDecimal;
+import java.text.DecimalFormat;
+
+/**
+ * @description
+ * @auto wangli
+ * @data 2021/01/20 11:23
+ */
+public class ValveStateJsonSerializer extends JsonSerializer<String> {
+   // 阀门状态: 0关阀 1开阀  2 无阀,3异常
+    @Override
+    public void serialize(String value, JsonGenerator gen, SerializerProvider serializers) throws IOException {
+        if(value != null && value .equals("0")){
+            gen.writeString("关阀");
+        }else
+        if(value != null && value .equals("1")){
+            gen.writeString("1开阀");
+        }else
+        if(value != null && value .equals("2")){
+            gen.writeString("无阀");
+        }else
+        if(value != null && value .equals("3")){
+            gen.writeString("异常");
+        }
+    }
+}

+ 2 - 2
smart-city-platform/src/main/java/com/bz/smart_city/controller/pay/PayControlRecordController.java

@@ -39,7 +39,7 @@ public class PayControlRecordController {
             @ApiParam(value = "阀控规则", required = false) @RequestParam(required = false) String controlRuleId,
             @ApiParam(value = "操作类型 0关阀 1开阀", required = false) @RequestParam(required = false) String type,
             @ApiParam(value = "操作结果 0执行中 1成功 2失败", required = false) @RequestParam(required = false) String result,
-            @ApiParam(value = "阀门状态  0关阀 1开阀 2异常", required = false) @RequestParam(required = false) String state,
+            @ApiParam(value = "阀门状态: 0关阀 1开阀  2无阀,3异常", required = false) @RequestParam(required = false) String state,
             @ApiParam(value = "开始时间yyyyMMdd", required = false) @RequestParam(required = false) String beginTime,
             @ApiParam(value = "结束时间yyyyMMdd", required = false) @RequestParam(required = false) String endTime
     ){
@@ -91,7 +91,7 @@ public class PayControlRecordController {
             @ApiParam(value = "阀控规则", required = false) @RequestParam(required = false) String controlRuleId,
             @ApiParam(value = "操作类型 0关阀 1开阀", required = false) @RequestParam(required = false) String type,
             @ApiParam(value = "操作结果 0执行中 1成功 2失败", required = false) @RequestParam(required = false) String result,
-            @ApiParam(value = "阀门状态  0关阀 1开阀 2异常", required = false) @RequestParam(required = false) String state,
+            @ApiParam(value = "阀门状态: 0关阀 1开阀  2 无阀,3异常", required = false) @RequestParam(required = false) String state,
             @ApiParam(value = "开始时间yyyyMMdd", required = false) @RequestParam(required = false) String beginTime,
             @ApiParam(value = "结束时间yyyyMMdd", required = false) @RequestParam(required = false) String endTime,
             @ApiParam(value = "页数,非必传,默认第一页", required = false, defaultValue = "1") @RequestParam(required = false, defaultValue = "1") int pageNum,

+ 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();
 }

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

@@ -5,6 +5,7 @@ import com.bz.smart_city.entity.pay.PayControlRecord;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
 
+import java.math.BigInteger;
 import java.util.List;
 
 /**
@@ -17,5 +18,13 @@ public interface PayControlRecordMapper {
     Integer add(@Param("payControlRecord")PayControlRecord payControlRecord);
 
     //查询
+
     List<PayControlRecordDto> findList(@Param("payControlRecordDto") PayControlRecordDto payControlRecordDto);
+
+    PayControlRecord findControlRecordByMetercode(@Param("meterCode") String meterCode);
+
+    Integer updateDeviceValveState(@Param("valveStatus") String valveStatus,@Param("meterCode") String meterCode);
+
+    Integer updateControlRecordResult(@Param("result") Integer result,@Param("valveStatus") Integer valveStatus,@Param("id") BigInteger id);
+
 }

+ 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;
 
 }

+ 4 - 1
smart-city-platform/src/main/java/com/bz/smart_city/dto/pay/payfee/PayfeeAccountInfoDto.java

@@ -1,6 +1,8 @@
 package com.bz.smart_city.dto.pay.payfee;
 
+import com.bz.smart_city.commom.util.jsonSerializer.ValveStateJsonSerializer;
 import com.fasterxml.jackson.annotation.JsonFormat;
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
@@ -55,6 +57,7 @@ public class PayfeeAccountInfoDto {
     @ApiModelProperty(value = "水表电子号" )
     private String metereleno;
     @ApiModelProperty(value = "阀门状态: 0关阀 1开阀  2 无阀,3异常" )
-    private String controlStatus;
+    @JsonSerialize(using = ValveStateJsonSerializer.class)
+    private String valveStatus;
 
 }

+ 1 - 1
smart-city-platform/src/main/java/com/bz/smart_city/entity/pay/PayControlRecord.java

@@ -30,7 +30,7 @@ public class PayControlRecord {
     @ApiModelProperty(example="1",notes = "操作结果 0执行中 1成功 2失败",position = 20)
     private Integer result;
 
-    @ApiModelProperty(example="1",notes = "阀门状态  0关阀 1开阀 2异常",position = 25)
+    @ApiModelProperty(example="1",notes = "阀门状态: 0关阀 1开阀  2 无阀,3异常",position = 25)
     private Integer state;
 
     @ApiModelProperty(example="1",notes = "阀控规则id",position = 30)

+ 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;
 }

+ 64 - 0
smart-city-platform/src/main/java/com/bz/smart_city/kafka/ValveStateConsumer.java

@@ -0,0 +1,64 @@
+package com.bz.smart_city.kafka;
+
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
+import com.bz.smart_city.dao.pay.PayControlRecordMapper;
+import com.bz.smart_city.entity.pay.PayControlRecord;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.kafka.clients.consumer.ConsumerRecord;
+import org.springframework.kafka.annotation.KafkaListener;
+import org.springframework.stereotype.Component;
+
+import javax.annotation.Resource;
+import java.util.List;
+import java.util.Optional;
+
+/**
+ * @description
+ * @auto wangli
+ * @data 2021/1/20 8:55
+ */
+@Component
+@Slf4j
+public class ValveStateConsumer {
+    @Resource
+    private PayControlRecordMapper payControlRecordMapper;
+
+    @KafkaListener(topics = {"billing_valveStatus_receiving"})
+    public void listener(ConsumerRecord<String, String> record){
+
+        Optional<String> msg = Optional.ofNullable(record.value());
+        if(msg.isPresent()){
+            log.info("kafka阀门接口数据,{}",msg.get());
+
+            JSONObject jsonObject = JSON.parseObject(msg.get());
+            String valueState = jsonObject.getString("meterStatus"); //阀门状态: 0关阀 1开阀  2 无阀,3异常
+            String meterNo = jsonObject.getString("meterNo");
+
+            //更新设备信息的阀门阀门状态
+            payControlRecordMapper.updateDeviceValveState(valueState,meterNo);
+            //更新阀控记录(最后一条)
+            PayControlRecord payControlRecord = payControlRecordMapper.findControlRecordByMetercode(meterNo);
+
+            Integer state =Integer.valueOf(valueState);
+
+            if(payControlRecord != null && payControlRecord .getResult() == 0){ //执行中的才更新
+                if (payControlRecord.getType() == 0) { //0关阀操作
+                    if(state == 0){   // 阀门为关阀则执行成功
+                        payControlRecordMapper.updateControlRecordResult(1,state,payControlRecord.getId());
+                    }else
+                    if(state == 3){   // 阀门为异常则执行失败
+                        payControlRecordMapper.updateControlRecordResult(2,state,payControlRecord.getId());
+                    }
+                }else if (payControlRecord.getType() == 1) { //1开阀操作
+                    if(state == 1){   // 阀门为开阀则执行成功
+                        payControlRecordMapper.updateControlRecordResult(1,state,payControlRecord.getId());
+                    }else
+                    if(state == 3){   // 阀门为异常则执行失败
+                        payControlRecordMapper.updateControlRecordResult(2,state,payControlRecord.getId());
+                    }
+                }
+            }
+        }
+    }
+}

+ 37 - 0
smart-city-platform/src/main/java/com/bz/smart_city/quartz/job/EstimateMsgSendJob.java

@@ -0,0 +1,37 @@
+package com.bz.smart_city.quartz.job;
+
+import com.bz.smart_city.quartz.service.EstimateMsgSendService;
+import lombok.extern.slf4j.Slf4j;
+import org.quartz.*;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import javax.annotation.Resource;
+import java.io.Serializable;
+
+/**
+ * @description
+ * @auto xjh
+ * @data 2021-01-12 15:32
+ */
+@Slf4j
+@Component
+public class EstimateMsgSendJob implements Job, Serializable {
+
+    @Autowired
+    private EstimateMsgSendService estimateMsgSendService;
+    @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 EstimateMsgSendJob , customerId = {}",customerId);
+        estimateMsgSendService.send(siteId,customerId);
+        log.info("invoked EstimateMsgSendJob , customerId = {}",customerId);
+    }
+}

+ 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);
     }
 }

+ 18 - 0
smart-city-platform/src/main/java/com/bz/smart_city/quartz/service/EstimateMsgSendService.java

@@ -0,0 +1,18 @@
+package com.bz.smart_city.quartz.service;
+
+import java.math.BigInteger;
+
+/**
+ * @description
+ * @auto xjh
+ * @data 2021-01-12 15:32
+ */
+public interface EstimateMsgSendService {
+    void afterPropertiesSet();
+
+    void saveQrtzTask(BigInteger siteId, BigInteger customerId, String sendTime);
+
+    void deleteQrtzTask();
+
+    void send(Integer siteId, Integer 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);
 }

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

@@ -0,0 +1,113 @@
+package com.bz.smart_city.quartz.service.impl;
+
+import com.bz.smart_city.commom.exception.ServiceException;
+import com.bz.smart_city.commom.model.ResultStatus;
+import com.bz.smart_city.dao.pay.BaseClosingAccountInfoMapper;
+import com.bz.smart_city.dao.pay.PayMessagetemplateMapper;
+import com.bz.smart_city.dto.pay.BaseClosingAccountInfoDto;
+import com.bz.smart_city.dto.pay.PayMessageTemplateDto;
+import com.bz.smart_city.quartz.entity.QuartzEntity;
+import com.bz.smart_city.quartz.job.EstimateMsgSendJob;
+import com.bz.smart_city.quartz.job.EstimatedDayJob;
+import com.bz.smart_city.quartz.service.EstimateMsgSendService;
+import com.bz.smart_city.quartz.service.JobAndTriggerService;
+import com.bz.smart_city.service.pay.AmountWaterUsedAmountService;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.InitializingBean;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import javax.annotation.Resource;
+import java.math.BigInteger;
+import java.util.HashMap;
+import java.util.List;
+
+/**
+ * @author xjh
+ * @version 计费
+ * @date 2021/1/13 20:34
+ */
+@Slf4j
+@Component
+public class EstimateMsgSendServiceImpl implements EstimateMsgSendService, InitializingBean {
+
+    //void afterPropertiesSet();
+
+    @Resource
+    private JobAndTriggerService jobAndTriggerService;
+
+    @Autowired
+    private AmountWaterUsedAmountService amountWaterUsedAmountService;
+
+    @Resource
+    private BaseClosingAccountInfoMapper baseClosingAccountInfoMapper;
+
+    @Resource
+    private PayMessagetemplateMapper payMessagetemplateMapper;
+
+    @Override
+    public void afterPropertiesSet() {
+        List<BaseClosingAccountInfoDto> closingList = baseClosingAccountInfoMapper.getClosingSC();
+        if(closingList != null && closingList.size() >0){
+            for(BaseClosingAccountInfoDto list:closingList ){
+                PayMessageTemplateDto dto = payMessagetemplateMapper.get(list.getSiteId(),list.getCustomerId(),null,null);
+                saveQrtzTask(list.getSiteId(),list.getCustomerId(),dto != null && StringUtils.isNotBlank(dto.getSendTime()) ? dto.getSendTime() : "");
+            }
+        }
+    }
+
+    public void saveQrtzTask(BigInteger siteId, BigInteger customerId,String sendTime) {
+        // 1,查询需要批量推送的配置项目并构建定时任务
+        // 2,若对应定时任务不存在则创建
+        QuartzEntity entity = new QuartzEntity();
+        entity.setJobGroup("预计费每天推送");
+        entity.setJobName("EstimateMsgSendJob"+siteId );
+        entity.setDescription("EstimateMsgSendJob"+customerId );
+        // modify by pengdi ,判断定时任务是否存在,不存在才进行新增
+
+        boolean exists = jobAndTriggerService.isExists(entity);
+        if(!exists) {
+            String time = "";
+            String minute = "";
+            String second = "";
+            if(StringUtils.isNotBlank(sendTime)){
+                String[] sp = sendTime.split(":");
+                time = sp[0];
+                minute = sp[1];
+                //String cron = "0 */3 * * * ?";
+                //String cron ="0 40 14 * * ?";
+                //String cron = "0 "+Integer.valueOf(minute)+" "+Integer.valueOf(time)+" * * ? ";
+                String cron = "0 0 19 * * ? ";
+                log.info("预计费每天推送:" + cron);
+                log.info("预计费每天推送:" + "站点ID:"+siteId+"水司ID:"+customerId);
+                entity.setCronExpression(cron);
+                entity.setJobClassName(EstimateMsgSendJob.class.getName());
+                HashMap<String, Object> jobData = new HashMap<String, Object>();
+                jobData.put("siteId", siteId);
+                jobData.put("customerId", customerId);
+                entity.setJobData(jobData);
+                jobAndTriggerService.save(entity);
+            }else{
+                log.info("预计费每天推送失败,失败:" + "站点ID:"+siteId+"水司ID:"+customerId+",失败原因:没有推送时间");
+                //throw new ServiceException(-999,"预计费每天推送失败,失败:"+"站点ID:"+siteId+"水司ID:"+customerId+",失败原因:没有推送时间");
+            }
+        }
+    }
+
+    public void deleteQrtzTask() {
+        // 1,查询需要批量推送的配置项目并构建定时任务
+        QuartzEntity entity = new QuartzEntity();
+        entity.setJobGroup("预计费每天推送");
+        entity.setJobName("EstimateMsgSendJob");
+        if (jobAndTriggerService.isExists(entity)) {
+            jobAndTriggerService.deleteJob(entity);
+        }
+    }
+
+    public void send(Integer siteId,Integer customerId){
+        log.info("================================================>预计费每天统推送始<=====================================");
+        amountWaterUsedAmountService.estimateMsgSend(siteId,customerId);
+        log.info("================================================>预计费每天推送完成<=====================================");
+    }
+}

+ 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);
 }

+ 28 - 1
smart-city-platform/src/main/resources/application-dev.properties

@@ -50,7 +50,34 @@ spring.redis.jedis.pool.max-active=8
 spring.redis.jedis.pool.max-idle=8
 spring.redis.jedis.pool.max-wait=-1ms
 spring.redis.jedis.pool.min-idle=2
- 
+
+
+#kafka
+#============== kafka ===================
+# 指定kafka 代理地址,可以多个
+#spring.kafka.bootstrap-servers=192.168.0.157:9092
+spring.kafka.bootstrap-servers=114.135.61.188:36377
+
+#=============== provider  =======================
+#spring.kafka.producer.retries=0
+## 每次批量发送消息的数量
+#spring.kafka.producer.batch-size=16384
+#spring.kafka.producer.buffer-memory=33554432
+#
+# 指定消息key和消息体的编解码方式
+#spring.kafka.producer.key-serializer=org.apache.kafka.common.serialization.StringSerializer
+#spring.kafka.producer.value-serializer=org.apache.kafka.common.serialization.StringSerializer
+#=============== consumer  =======================
+# 指定消费者group id
+spring.kafka.consumer.group-id = water_api_jf_valveStatus_received
+spring.kafka.consumer.auto-offset-reset=latest
+spring.kafka.consumer.enable-auto-commit=true
+#spring.kafka.consumer.auto-commit-interval=100
+
+# 指定消息key和消息体的编解码方式
+spring.kafka.consumer.key-deserializer=org.apache.kafka.common.serialization.StringDeserializer
+spring.kafka.consumer.value-deserializer=org.apache.kafka.common.serialization.StringDeserializer
+
 
 
 jwt.secret=smartCity123

+ 23 - 8
smart-city-platform/src/main/resources/application-prd.properties

@@ -122,16 +122,31 @@ websocket.so.keepalive=true
 websocket.so.backlog=100
 system.water.meter.lora.code=LORAWM
 
-#kafka配置
-spring.kafka.bootstrap-servers=172.18.110.178:9092
-#kafka消费者配置
-spring.kafka.consumer.group-id=api-group
+#kafka
+#============== kafka ===================
+# 指定kafka 代理地址,可以多个
+#spring.kafka.bootstrap-servers=192.168.0.157:9092
+spring.kafka.bootstrap-servers=114.135.61.188:36377
+
+#=============== provider  =======================
+#spring.kafka.producer.retries=0
+## 每次批量发送消息的数量
+#spring.kafka.producer.batch-size=16384
+#spring.kafka.producer.buffer-memory=33554432
+#
+# 指定消息key和消息体的编解码方式
+#spring.kafka.producer.key-serializer=org.apache.kafka.common.serialization.StringSerializer
+#spring.kafka.producer.value-serializer=org.apache.kafka.common.serialization.StringSerializer
+#=============== consumer  =======================
+# 指定消费者group id
+spring.kafka.consumer.group-id = water_api_jf_valveStatus_received
 spring.kafka.consumer.auto-offset-reset=latest
 spring.kafka.consumer.enable-auto-commit=true
-#kafka生产者配置
-spring.kafka.producer.retries=0
-spring.kafka.producer.batch-size=4096
-spring.kafka.producer.buffer-memory=40960
+#spring.kafka.consumer.auto-commit-interval=100
+
+# 指定消息key和消息体的编解码方式
+spring.kafka.consumer.key-deserializer=org.apache.kafka.common.serialization.StringDeserializer
+spring.kafka.consumer.value-deserializer=org.apache.kafka.common.serialization.StringDeserializer
 
 #\u9AD8\u5FB7\u5730\u56FE
 geomap.apikey=bb218fd3700b37dd1e02872365cab4d5

+ 25 - 1
smart-city-platform/src/main/resources/application-sit.properties

@@ -52,7 +52,31 @@ spring.redis.jedis.pool.max-idle=8
 spring.redis.jedis.pool.max-wait=-1ms
 spring.redis.jedis.pool.min-idle=2
 
-
+#kafka
+#============== kafka ===================
+# 指定kafka 代理地址,可以多个
+#spring.kafka.bootstrap-servers=192.168.0.157:9092
+spring.kafka.bootstrap-servers=114.135.61.188:36377
+
+#=============== provider  =======================
+#spring.kafka.producer.retries=0
+## 每次批量发送消息的数量
+#spring.kafka.producer.batch-size=16384
+#spring.kafka.producer.buffer-memory=33554432
+#
+# 指定消息key和消息体的编解码方式
+#spring.kafka.producer.key-serializer=org.apache.kafka.common.serialization.StringSerializer
+#spring.kafka.producer.value-serializer=org.apache.kafka.common.serialization.StringSerializer
+#=============== consumer  =======================
+# 指定消费者group id
+spring.kafka.consumer.group-id = water_api_jf_valveStatus_received
+spring.kafka.consumer.auto-offset-reset=latest
+spring.kafka.consumer.enable-auto-commit=true
+#spring.kafka.consumer.auto-commit-interval=100
+
+# 指定消息key和消息体的编解码方式
+spring.kafka.consumer.key-deserializer=org.apache.kafka.common.serialization.StringDeserializer
+spring.kafka.consumer.value-deserializer=org.apache.kafka.common.serialization.StringDeserializer
 
 jwt.secret=smartCity123
 jwt.expiration=36000

+ 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>

+ 21 - 0
smart-city-platform/src/main/resources/mapper/pay/PayControlRecordMapper.xml

@@ -76,4 +76,25 @@
         )
 
     </insert>
+
+    <select id="findControlRecordByMetercode" resultType="com.bz.smart_city.entity.pay.PayControlRecord">
+        select
+            pcr.id,
+            pcr.type,
+            pcr.result,
+            pcr.state
+        from pay_control_record pcr
+        left join sc_device d on pcr.meter_id =d.id
+        where d.metercode = #{meterCode}
+        order by pcr.create_date desc
+        limit 1
+    </select>
+    <update id="updateDeviceValveState">
+        udpate sc_device  set control_status = #{valveStatus}  where metercode = #{meterCode}
+    </update>
+    <update id="updateControlRecordResult">
+        update pay_control_record set result =#{result} ,state =#{valveStatus} where id = #{id}
+    </update>
+
+
 </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>

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

@@ -114,7 +114,7 @@
             p.id as "waterPropertyId",
             p.name as "waterPropertyName",
             device.water_meter_no as "metereleno",
-            device.control_status as "controlStatus"
+            device.control_status as "valveStatus"
         from pay_base_customerandmeterrela c
         left join pay_base_account a on c.account_id=a.id
         left join pay_base_waterproperty p on c.waterProperty_id=p.id