Преглед на файлове

1.修改概览页
2.修改预计费
3.开户新增阀控

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

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

@@ -11,6 +11,7 @@ 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.EstimatedDayService;
 import com.bz.smart_city.service.impl.ImportServiceImpl;
 import com.bz.smart_city.service.pay.archives.PayBaseCustomerandmeterrelaService;
 import io.swagger.annotations.Api;
@@ -46,6 +47,9 @@ public class PayBaseCustomerandmeterrelaController {
     @Autowired
     private RedisUtil redisUtil;
 
+    @Autowired
+    private EstimatedDayService estimatedDayService;
+
     @ResponseBody
     @GetMapping("/pageOpenList")
     @ApiOperation(value = "计费系统-获取开户分页")
@@ -226,4 +230,10 @@ public class PayBaseCustomerandmeterrelaController {
 
         payBaseCustomerandmeterrelaService.getCustomerListExcel(condition,waterPropertyId,businessstate,calculateway,httpServletResponse);
     }
+
+    @GetMapping("/estimatedTest")
+    @ApiOperation(value = "计费系统-预计费测试")
+    public void estimatedTest(Integer siteId,Integer customerId){
+        estimatedDayService.start(siteId,customerId);
+    }
 }

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

@@ -84,4 +84,6 @@ public interface PayPayReceivableMapper {
 
     BigDecimal querySumTransamount(@Param("siteId")Integer siteId,@Param("customerId")Integer customerId,
                                    @Param("year")Integer year,@Param("month")Integer month,@Param("accountnumber") String accountnumber);
+
+    BigDecimal getHistoryDebt(@Param("siteId")Integer siteId,@Param("customerId")Integer customerId,@Param("accountid")BigInteger accountid);
 }

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

@@ -5,6 +5,7 @@ import com.bz.smart_city.dto.pay.PayCustomerDto;
 import com.bz.smart_city.entity.Organization;
 import com.bz.smart_city.entity.pay.PayBaseAccount;
 import com.bz.smart_city.entity.pay.PayControlRule;
+import com.bz.smart_city.entity.pay.PayControlValve;
 import com.bz.smart_city.entity.pay.PayPayRechargeaccount;
 import com.bz.smart_city.entity.pay.archives.*;
 import org.apache.ibatis.annotations.Mapper;
@@ -31,6 +32,8 @@ public interface PayBaseCustomerandmeterrelaMapper {
     public PayBaseCustomerandmeterrela getWaterPropertyId(@Param("siteId")Integer siteId, @Param("customerId")Integer customerId,@Param("name")String name);
     public int insertList(@Param("customers") List<PayBaseCustomerandmeterrela> customers);
 
+    public int insertValveList(@Param("valve") List<PayControlValve> valve);
+
     public Organization getOfficeId(@Param("siteId")Integer siteId, @Param("name")String name);
 
     public List<PayBaseCustomerandmeterrela> findList(PayBaseCustomerandmeterrela customer);
@@ -101,4 +104,6 @@ public interface PayBaseCustomerandmeterrelaMapper {
     void updateMeterInstallOpen(@Param("isAccepted")Integer isAccepted, @Param("updateBy")String updateBy,@Param("date") LocalDateTime date, @Param("id") BigInteger id);
 
     public List<PayControlRule> getRuleNames(@Param("siteId")Integer siteId,@Param("customerId")Integer customerId,@Param("list")List<String> list);
+
+    void insertValve(@Param("deviceId")BigInteger deviceId,@Param("date")LocalDateTime date,@Param("controlState")int controlState);
 }

+ 26 - 0
smart-city-platform/src/main/java/com/bz/smart_city/entity/pay/PayControlValve.java

@@ -0,0 +1,26 @@
+package com.bz.smart_city.entity.pay;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.math.BigInteger;
+import java.time.LocalDateTime;
+
+/**
+ * @author xjh
+ * @version 计费
+ * @date 2021/1/30 10:07
+ */
+@Data
+@ApiModel("阀控记录表")
+public class PayControlValve {
+    @ApiModelProperty(value = "设备ID")
+    private BigInteger deviceId;//设备id
+    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern="yyyy-MM-dd HH:mm:ss")
+    @ApiModelProperty(value = "下发时间")
+    private LocalDateTime controlTime;//下发时间
+    @ApiModelProperty(value = "操作类型")
+    private Integer controlState;//操作类型 0关 1开
+}

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

@@ -77,8 +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 20 11 * * ?";
+                //String cron = "0 "+Integer.valueOf(minute)+" "+Integer.valueOf(time)+" * * ?";
+                String cron = "0 2 15 * * ?";
                 log.info("预计费每天推送:" + cron);
                 log.info("预计费每天推送:" + "站点ID:"+siteId+"水司ID:"+customerId);
                 entity.setCronExpression(cron);

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

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

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

@@ -794,6 +794,10 @@ 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();
@@ -806,6 +810,14 @@ public class AmountWaterUsedAmountServiceImpl implements AmountWaterUsedAmountSe
                     if(dayReading != null && mReading != null){
                         BigDecimal amount = dayReading.subtract(mReading);
 
+                        // 0水量 不计费但计量
+                        if(amount.intValue()<=0|| calculateway == 3){
+                            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){
@@ -835,6 +847,18 @@ public class AmountWaterUsedAmountServiceImpl implements AmountWaterUsedAmountSe
                                 if (objAmount != null) {
                                     availableAmount = new BigDecimal(objAmount.toString());
                                 }
+                                if(availableAmount.compareTo(BigDecimal.ZERO) == 0){
+                                    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);
+                                        availableAmount = new BigDecimal(objlableL.toString());
+                                    }
+                                }
                                 //阶梯结算水量
                                 BigDecimal calAmount = BigDecimal.ZERO;
                                 if (availableAmount.intValue() > 0) {
@@ -863,6 +887,11 @@ public class AmountWaterUsedAmountServiceImpl implements AmountWaterUsedAmountSe
                             balance = remaining.subtract(fee);
                         }
                     }
+                    //查询该户是否有历史欠费
+                    BigDecimal historyDebt = payPayReceivableMapper.getHistoryDebt(siteId,customerId,accountId);
+                    historyDebt = historyDebt != null ? historyDebt : BigDecimal.ZERO;
+                    //如果有欠费必须加上之前欠费
+                    balance = balance.add(historyDebt.negate());
                     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()));

+ 13 - 0
smart-city-platform/src/main/java/com/bz/smart_city/service/importfile/AsyncTaskImportService.java

@@ -15,6 +15,7 @@ import com.bz.smart_city.entity.Message;
 import com.bz.smart_city.entity.Organization;
 import com.bz.smart_city.entity.pay.PayBaseAccount;
 import com.bz.smart_city.entity.pay.PayControlRule;
+import com.bz.smart_city.entity.pay.PayControlValve;
 import com.bz.smart_city.entity.pay.archives.PayBaseCustomerandmeterrela;
 import com.bz.smart_city.excel.resolver.InstallPlanResolverExcelTemplate;
 import com.bz.smart_city.service.ImportService;
@@ -111,6 +112,7 @@ public class AsyncTaskImportService {
 
                 FormulaEvaluator evaluator = hssfWorkbook.getCreationHelper().createFormulaEvaluator();
                 List<PayBaseCustomerandmeterrela> customerList = newArrayList();
+                List<PayControlValve> valveList = newArrayList();//阀控记录
                 // 循环工作表Sheet
                 for (int numSheet = 0; numSheet < hssfWorkbook.getNumberOfSheets(); numSheet++) {
 
@@ -240,6 +242,7 @@ public class AsyncTaskImportService {
                                }
 
                                PayBaseCustomerandmeterrela customer =  new PayBaseCustomerandmeterrela();//实例化开户实体
+                               PayControlValve valve = new PayControlValve();//实例化阀控实体
                                //根据客户编码寻找客户id
                                PayBaseAccount accounts = payBaseCustomerandmeterrelaMapper.getAccountId(loginUser.getSiteId(),loginUser.getCustomerId(),accountnumber);
                                //根据水表电子号寻找水表id
@@ -393,6 +396,12 @@ public class AsyncTaskImportService {
                                    customerList.add(customer);
                                }
 
+                               //插入阀控记录
+                               valve.setDeviceId(device.getId());
+                               valve.setControlState(1);
+                               valve.setControlTime(LocalDateTime.now());
+                               valveList.add(valve);
+
                                //计算可用水量
                                if(property.getWaterPropertyId() != null){
                                    Boolean  flag = payBaseCustomerandmeterrelaService.UpdateAccountInfo(property.getWaterPropertyId(),accounts.getId(),null,loginUser.getSiteId(),loginUser.getCustomerId());
@@ -445,6 +454,10 @@ public class AsyncTaskImportService {
                     int reslut = payBaseCustomerandmeterrelaMapper.insertList(customerList);
                     log.info("insert reslut:" + reslut);
                 }
+                if(valveList.size() >0){
+                    int reslut = payBaseCustomerandmeterrelaMapper.insertValveList(valveList);
+                    log.info("insert valveResult:" + reslut);
+                }
                 log.info("结束循环为空的行上移");
                 messageContent.append("导入完成,");
                 messageContent.append("导入成功");

+ 2 - 0
smart-city-platform/src/main/java/com/bz/smart_city/service/pay/archives/impl/PayBaseCustomerandmeterrelaServiceImpl.java

@@ -489,6 +489,8 @@ public class PayBaseCustomerandmeterrelaServiceImpl implements PayBaseCustomeran
         //修改水表安装信息为已开户
         payBaseCustomerandmeterrelaMapper.updateMeterInstallOpen(2,loginUser.getUpdateBy(),LocalDateTime.now(),device.getId());
 
+        //往阀控表插入开阀记录
+        payBaseCustomerandmeterrelaMapper.insertValve(device.getId(),LocalDateTime.now(),1);
         if (customerList.size() > 0) {
             int reslut = payBaseCustomerandmeterrelaMapper.insertList(customerList);
 

+ 32 - 0
smart-city-platform/src/main/resources/mapper/PayBaseCustomerandmeterrelaMapper.xml

@@ -112,6 +112,23 @@
         </where>
     </select>
 
+    <insert id="insertValveList">
+        INSERT INTO pay_control_valve
+        (
+            device_id,
+            control_time,
+            control_state
+        )
+        values
+        <foreach collection="valve" item="valve" index="index" separator=",">
+            (
+                #{valve.deviceId,jdbcType=BIGINT},
+                #{valve.controlTime,jdbcType=TIMESTAMP},
+                #{valve.controlState,jdbcType=INTEGER}
+            )
+        </foreach>
+    </insert>
+
     <insert id="insertList">
         INSERT INTO pay_base_customerandmeterrela
         (
@@ -697,4 +714,19 @@
             </if>
         </where>
     </select>
+
+    <insert id="insertValve">
+        insert into pay_control_valve
+        (
+            device_id,
+            control_time,
+            control_state
+        )
+        values
+        (
+            #{deviceId},
+            #{date},
+            #{controlState}
+        )
+    </insert>
 </mapper>

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

@@ -72,7 +72,7 @@
         AS c WHERE a.watermeter_id=c.watermeter_id AND a.read_date = c.read_date)  rd on rd.watermeter_id = scd.id
         <where>
             scd.customer_id =#{customerId} and scd.account_id is not null
-            and scd.water_meter_no is not null
+            and (scd.curr_status =1 or scd.curr_status =2)
             <if test="startDate != null">
                 and scd.date_create &gt;=#{startDate}
             </if>

+ 17 - 0
smart-city-platform/src/main/resources/mapper/pay/PayPayReceivableMapper.xml

@@ -506,4 +506,21 @@
         and cancelperson is null
         ) and site_id =#{siteId} and customer_id =#{customerId}
     </delete>
+
+    <select id="getHistoryDebt" resultType="java.math.BigDecimal">
+        select
+            sum(r.debt) as "debt"
+        from pay_pay_receivable r
+        <where>
+            <if test="siteId != null">
+                and  r.site_id =#{siteId}
+            </if>
+            <if test="customerId != null">
+                and r.customer_id =#{customerId}
+            </if>
+            <if test="accountid != null">
+                and r.account_id =#{accountid}
+            </if>
+        </where>
+    </select>
 </mapper>