Browse Source

审核查询欠费关阀
轮训开阀记录

wangli 4 years ago
parent
commit
075abc1dee

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

@@ -32,7 +32,7 @@ public interface AmountWaterUsedAmountMapper {
     List<AmountWaterUsedAmountDto> getWaterUsedAmountByMeterId(@Param("waterMeterId") BigInteger waterMeterId);
     List<AmountWaterUsedAmountDto> getWaterUsedAmountByMeterId(@Param("waterMeterId") BigInteger waterMeterId);
 
 
 
 
-    List<String> getIds(@Param("condition") String condition, @Param("customerId")Integer customerId, @Param("accountnumber") String accountNumber,
+    List<BigInteger> getIds(@Param("condition") String condition, @Param("customerId")Integer customerId, @Param("accountnumber") String accountNumber,
                         @Param("accountname")String accountName, @Param("metercode")String meterCode, @Param("address")String address,
                         @Param("accountname")String accountName, @Param("metercode")String meterCode, @Param("address")String address,
                         @Param("state") Integer state, @Param("amountMin") Integer amountMin, @Param("amountMax") Integer amountMax,
                         @Param("state") Integer state, @Param("amountMin") Integer amountMin, @Param("amountMax") Integer amountMax,
                         @Param("year") Integer year, @Param("month") Integer month,@Param("programItems") List<ProgramItem> programItems,
                         @Param("year") Integer year, @Param("month") Integer month,@Param("programItems") List<ProgramItem> programItems,

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

@@ -6,6 +6,7 @@ import com.bz.smart_city.dto.pay.PayInvoiceDto;
 import com.bz.smart_city.dto.pay.payfee.*;
 import com.bz.smart_city.dto.pay.payfee.*;
 import com.bz.smart_city.entity.ProgramItem;
 import com.bz.smart_city.entity.ProgramItem;
 import com.bz.smart_city.entity.pay.BaseClosingAccountInfo;
 import com.bz.smart_city.entity.pay.BaseClosingAccountInfo;
+import com.bz.smart_city.entity.pay.PayControlRule;
 import com.bz.smart_city.entity.pay.PayPayAgentbranch;
 import com.bz.smart_city.entity.pay.PayPayAgentbranch;
 import com.bz.smart_city.entity.pay.PayReceivable;
 import com.bz.smart_city.entity.pay.PayReceivable;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Mapper;
@@ -65,4 +66,13 @@ public interface PayFeeMapper {
 
 
     List<PayValveStateInfo> getDeviceValveState(@Param("accountId")BigInteger accountId);
     List<PayValveStateInfo> getDeviceValveState(@Param("accountId")BigInteger accountId);
 
 
+    List<PayValveStateInfo> getDeviceValveStateByAccountId(@Param("accountId")BigInteger accountId);
+
+    List<PayValveStateInfo> getDeviceValveStateByAmount(@Param("list")List<BigInteger> list);
+
+    List<PayValveStateInfo> getDeviceValveStateByRecord();
+
+    List<PayValveStateInfo> deleteControlValveInfoByDevice(@Param("list")List<BigInteger> list);
+
+    List<PayControlRule> getValveRulesByType(@Param("type")Integer type);
 }
 }

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

@@ -20,5 +20,6 @@ public class PayValveStateInfo {
     private BigInteger accountId;
     private BigInteger accountId;
     private BigInteger meterId;
     private BigInteger meterId;
     private BigInteger customerNo;
     private BigInteger customerNo;
+    private Integer operation;  //0关阀1开阀
 
 
 }
 }

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

@@ -4,7 +4,9 @@ import com.fasterxml.jackson.annotation.JsonFormat;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 import lombok.Data;
+import org.apache.commons.lang3.StringUtils;
 
 
+import java.math.BigDecimal;
 import java.math.BigInteger;
 import java.math.BigInteger;
 import java.time.LocalDateTime;
 import java.time.LocalDateTime;
 
 
@@ -62,4 +64,37 @@ public class PayControlRule {
     private BigInteger siteId;
     private BigInteger siteId;
     @ApiModelProperty(example = "1",notes = "水司ID",hidden = true)
     @ApiModelProperty(example = "1",notes = "水司ID",hidden = true)
     private BigInteger customerId;
     private BigInteger customerId;
+
+
+    public Boolean checkCondition(BigDecimal data){
+        if(this.operator != null && StringUtils.isNotBlank(this.value)){
+            switch (this.operator) {
+                case 1: {
+                    condition = "=";
+                    return new BigDecimal(value).compareTo(data) == 0;
+                }
+                case 2: {
+                    condition = "<>";
+                    return new BigDecimal(value).compareTo(data) != 0;
+                }
+                case 3: {
+                    condition = ">";
+                    return new BigDecimal(value).compareTo(data) == 1;
+                }
+                case 4: {
+                    condition = "<";
+                    return new BigDecimal(value).compareTo(data) == -1;
+                }
+                case 5: {
+                    condition = ">=";
+                    return new BigDecimal(value).compareTo(data) != -1;
+                }
+                case 6: {
+                    condition = "<=";
+                    return new BigDecimal(value).compareTo(data) != 1;
+                }
+            }
+        }
+        return false;
+    }
 }
 }

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

@@ -0,0 +1,53 @@
+package com.bz.smart_city.quartz.job;
+
+import com.bz.smart_city.dao.pay.PayFeeMapper;
+import com.bz.smart_city.dto.pay.payfee.PayValveStateInfo;
+import com.bz.smart_city.service.pay.PayFeeService;
+import lombok.extern.slf4j.Slf4j;
+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.List;
+import java.util.stream.Collectors;
+
+/**
+ * @description
+ * @auto wangli
+ * @data 2021/1/30 14:29
+ */
+@Slf4j
+@Component
+public class DeviceValveCommondSync implements InitializingBean {
+
+    @Resource
+    private PayFeeMapper payFeeMapper;
+
+    @Autowired
+    private PayFeeService payFeeService;
+    @Override
+    public void afterPropertiesSet() {
+        new Thread(() -> {
+            while (true) {
+                try {
+                    List<PayValveStateInfo> payValveStateInfos = payFeeMapper.getDeviceValveStateByRecord();
+                    List<BigInteger> devices = payValveStateInfos.stream().map( d ->{
+                                payFeeService.sendValveCommond(d);
+                                return d.getMeterId();
+                            }
+                    ).collect(Collectors.toList());
+                    payFeeMapper.deleteControlValveInfoByDevice(devices);
+                } catch (Exception e){
+                    e.printStackTrace();
+                }
+                try {
+                    Thread.sleep(60000);
+                } catch (InterruptedException e) {
+                    e.printStackTrace();
+                }
+            }
+        }).start();
+    }
+}

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

@@ -198,7 +198,7 @@ public class CustomerServiceImpl implements CustomerService {
 
 
     @Override
     @Override
     public List<CustomerDto> findSiteCustomer() {
     public List<CustomerDto> findSiteCustomer() {
-        return customerMapper.getCustomerList(1,null);
+        return customerMapper.getCustomerList(UserUtil.getCurrentUser().getSiteId(),null);
     }
     }
 
 
     @Override
     @Override

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

@@ -5,18 +5,18 @@ import com.bz.smart_city.commom.model.AjaxMessage;
 import com.bz.smart_city.commom.model.Pagination;
 import com.bz.smart_city.commom.model.Pagination;
 import com.bz.smart_city.commom.model.ResultStatus;
 import com.bz.smart_city.commom.model.ResultStatus;
 import com.bz.smart_city.commom.util.*;
 import com.bz.smart_city.commom.util.*;
-import com.bz.smart_city.dao.CustomerMapper;
 import com.bz.smart_city.dao.SiteMapper;
 import com.bz.smart_city.dao.SiteMapper;
 import com.bz.smart_city.dao.pay.*;
 import com.bz.smart_city.dao.pay.*;
 import com.bz.smart_city.dao.pay.archives.PayBaseCustomerandmeterrelaMapper;
 import com.bz.smart_city.dao.pay.archives.PayBaseCustomerandmeterrelaMapper;
-import com.bz.smart_city.dto.CustomerDto;
 import com.bz.smart_city.dto.LoginUser;
 import com.bz.smart_city.dto.LoginUser;
 import com.bz.smart_city.dto.pay.*;
 import com.bz.smart_city.dto.pay.*;
 import com.bz.smart_city.dto.pay.DeviceReplaceRecordDto;
 import com.bz.smart_city.dto.pay.DeviceReplaceRecordDto;
+import com.bz.smart_city.dto.pay.payfee.PayValveStateInfo;
 import com.bz.smart_city.entity.ProgramItem;
 import com.bz.smart_city.entity.ProgramItem;
 import com.bz.smart_city.entity.pay.*;
 import com.bz.smart_city.entity.pay.*;
 import com.bz.smart_city.entity.pay.archives.PayBaseCustomerandmeterrela;
 import com.bz.smart_city.entity.pay.archives.PayBaseCustomerandmeterrela;
 import com.bz.smart_city.service.pay.AmountWaterUsedAmountService;
 import com.bz.smart_city.service.pay.AmountWaterUsedAmountService;
+import com.bz.smart_city.service.pay.PayFeeService;
 import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageHelper;
 import lombok.extern.slf4j.Slf4j;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.commons.lang3.StringUtils;
@@ -66,7 +66,7 @@ public class AmountWaterUsedAmountServiceImpl implements AmountWaterUsedAmountSe
     @Resource
     @Resource
     private PayTransactiondetailsMapper payTransactiondetailsMapper;
     private PayTransactiondetailsMapper payTransactiondetailsMapper;
     @Autowired
     @Autowired
-    private PayFeeServiceImp payFeeServiceImp;
+    private PayFeeService payFeeService;
     @Resource
     @Resource
     private PaySysDictMapper paySysDictMapper;
     private PaySysDictMapper paySysDictMapper;
     @Resource
     @Resource
@@ -162,7 +162,7 @@ public class AmountWaterUsedAmountServiceImpl implements AmountWaterUsedAmountSe
             ajaxMessage.setMsg(-725,"水量审核条数为0");
             ajaxMessage.setMsg(-725,"水量审核条数为0");
             return ajaxMessage;
             return ajaxMessage;
         }
         }
-        List<String> idList =new ArrayList<>();
+        List<BigInteger> idList =new ArrayList<>();
         if(review ==1){
         if(review ==1){
             year = baseClosingAccountInfoDto.getYear();
             year = baseClosingAccountInfoDto.getYear();
             month = baseClosingAccountInfoDto.getMonth();
             month = baseClosingAccountInfoDto.getMonth();
@@ -171,8 +171,12 @@ public class AmountWaterUsedAmountServiceImpl implements AmountWaterUsedAmountSe
             idList = amountWaterUsedAmountMapper.getIds(condition,loginUser.getCustomerId(),null,null,null,null,
             idList = amountWaterUsedAmountMapper.getIds(condition,loginUser.getCustomerId(),null,null,null,null,
                     1,amountMin,amountMax,year,month,programItems,loginUser.getSiteId());
                     1,amountMin,amountMax,year,month,programItems,loginUser.getSiteId());
         }else{
         }else{
-            if(ids!=null)
-                idList  = Arrays.asList(ids.split(","));
+            if(ids!=null) {
+                String[] idArr = ids.split(",");
+                for(String id : idArr){
+                    idList.add(new BigInteger(id));
+                }
+            }
         }
         }
 
 
         if(idList.size()>0) {
         if(idList.size()>0) {
@@ -211,7 +215,32 @@ public class AmountWaterUsedAmountServiceImpl implements AmountWaterUsedAmountSe
                         (defultNum>0?(",审核失败数:"+defultNum):""));
                         (defultNum>0?(",审核失败数:"+defultNum):""));
             }
             }
         }
         }
-
+        if(idList.size()>0){
+            List<PayControlRule> payControlRules = payFeeMapper.getValveRulesByType(2);
+            for(int i=0;2000*i<idList.size();i++){
+                if(2000*i+2000<idList.size()){
+                    List<PayValveStateInfo> PayValveStateInfos = payFeeMapper.getDeviceValveStateByAmount(idList.subList(2000*i,2000*i+2000));
+                    for(PayValveStateInfo payValveStateInfo :PayValveStateInfos){
+                        for(PayControlRule payControlRule :payControlRules){
+                            if(payValveStateInfo.getDebt() != null && payControlRule.checkCondition(payValveStateInfo.getDebt())){
+                                payValveStateInfo.setOperation(payControlRule.getAction());
+                                payFeeService.sendValveCommond(payValveStateInfo);
+                            }
+                        }
+                    }
+                }else{
+                    List<PayValveStateInfo> PayValveStateInfos = payFeeMapper.getDeviceValveStateByAmount(idList.subList(2000*i,idList.size()));
+                    for(PayValveStateInfo payValveStateInfo :PayValveStateInfos){
+                        for(PayControlRule payControlRule :payControlRules){
+                            if(payValveStateInfo.getDebt() != null && payControlRule.checkCondition(payValveStateInfo.getDebt())){
+                                payValveStateInfo.setOperation(payControlRule.getAction());
+                                payFeeService.sendValveCommond(payValveStateInfo);
+                            }
+                        }
+                    }
+                }
+            }
+        }
         return ajaxMessage;
         return ajaxMessage;
     }
     }
 
 
@@ -229,7 +258,7 @@ public class AmountWaterUsedAmountServiceImpl implements AmountWaterUsedAmountSe
             month = baseClosingAccountInfoDto.getMonth();
             month = baseClosingAccountInfoDto.getMonth();
             //List<ProgramItem> programItems = UserUtil.getAllSiteProgramItems(loginUser);
             //List<ProgramItem> programItems = UserUtil.getAllSiteProgramItems(loginUser);
             List<ProgramItem> programItems= UserUtil.getCurrentSiteProgramItems(loginUser);
             List<ProgramItem> programItems= UserUtil.getCurrentSiteProgramItems(loginUser);
-            List<String> idList = amountWaterUsedAmountMapper.getIds(condition, loginUser.getCustomerId(), null, null, null, null,
+            List<BigInteger> idList = amountWaterUsedAmountMapper.getIds(condition, loginUser.getCustomerId(), null, null, null, null,
                     1, amountMin, amountMax, year, month, programItems, loginUser.getSiteId());
                     1, amountMin, amountMax, year, month, programItems, loginUser.getSiteId());
             result = idList.size();
             result = idList.size();
         }
         }
@@ -246,11 +275,11 @@ public class AmountWaterUsedAmountServiceImpl implements AmountWaterUsedAmountSe
      * @param id 主键
      * @param id 主键
      */
      */
     @Transactional
     @Transactional
-    public AjaxMessage reviewWaterUsedAmount(String id,Integer year,Integer month,LoginUser loginUser ){
+    public AjaxMessage reviewWaterUsedAmount(BigInteger id,Integer year,Integer month,LoginUser loginUser ){
 
 
         try {
         try {
             AjaxMessage ajaxMessage = new AjaxMessage(ResultStatus.OK);
             AjaxMessage ajaxMessage = new AjaxMessage(ResultStatus.OK);
-            AmountWaterUsedAmount amountWaterUsedAmount = amountWaterUsedAmountMapper.get(new BigInteger(id),loginUser.getCustomerId(),loginUser.getSiteId());
+            AmountWaterUsedAmount amountWaterUsedAmount = amountWaterUsedAmountMapper.get(id,loginUser.getCustomerId(),loginUser.getSiteId());
             if (amountWaterUsedAmount != null && amountWaterUsedAmount.getState() == 1) {
             if (amountWaterUsedAmount != null && amountWaterUsedAmount.getState() == 1) {
                 BigDecimal amount = amountWaterUsedAmount.getPayamount();
                 BigDecimal amount = amountWaterUsedAmount.getPayamount();
                 Integer yearAmount = amountWaterUsedAmount.getYear();
                 Integer yearAmount = amountWaterUsedAmount.getYear();
@@ -549,7 +578,7 @@ public class AmountWaterUsedAmountServiceImpl implements AmountWaterUsedAmountSe
                             payReceivable.setUpdateBy(BigInteger.valueOf(userId));
                             payReceivable.setUpdateBy(BigInteger.valueOf(userId));
                             payFeeMapper.updatePayReceivable(payReceivable);
                             payFeeMapper.updatePayReceivable(payReceivable);
                             //生成并保存实收
                             //生成并保存实收
-                            PayPayReceived payPayReceived = payFeeServiceImp.getReceived(payReceivable, year, month, localDateTime, payway, payseriesno, receivedamount, feetypeMap, siteId, customerId, userId);
+                            PayPayReceived payPayReceived = payFeeService.getReceived(payReceivable, year, month, localDateTime, payway, payseriesno, receivedamount, feetypeMap, siteId, customerId, userId);
                             //生成交易明细
                             //生成交易明细
                             PayTransactiondetails payTransactiondetails = this.getPayTransactiondetails(5, localDateTime, amountWaterUsedAmount, payseriesno, month, year, receivedamount, siteId, customerId, userId);
                             PayTransactiondetails payTransactiondetails = this.getPayTransactiondetails(5, localDateTime, amountWaterUsedAmount, payseriesno, month, year, receivedamount, siteId, customerId, userId);
                             payTransactiondetails.setReceivedId(payPayReceived.getId());
                             payTransactiondetails.setReceivedId(payPayReceived.getId());
@@ -635,12 +664,12 @@ public class AmountWaterUsedAmountServiceImpl implements AmountWaterUsedAmountSe
     //水量审核
     //水量审核
     class reviewAllById implements Callable<Integer> {
     class reviewAllById implements Callable<Integer> {
 
 
-        private String id;
+        private BigInteger id;
 
 
         private Integer year;
         private Integer year;
         private Integer month;
         private Integer month;
         private LoginUser loginuser;
         private LoginUser loginuser;
-        public reviewAllById(String id,Integer year,Integer month,LoginUser loginuser){
+        public reviewAllById(BigInteger id,Integer year,Integer month,LoginUser loginuser){
             this.id=id;
             this.id=id;
             this.year =year;
             this.year =year;
             this.month = month;
             this.month = month;

+ 17 - 7
smart-city-platform/src/main/java/com/bz/smart_city/service/impl/pay/PayFeeServiceImp.java

@@ -7,6 +7,7 @@ import com.alibaba.fastjson.JSONObject;
 import com.bz.smart_city.commom.exception.ServiceException;
 import com.bz.smart_city.commom.exception.ServiceException;
 import com.bz.smart_city.commom.model.ResultStatus;
 import com.bz.smart_city.commom.model.ResultStatus;
 import com.bz.smart_city.commom.util.HttpClientUtils;
 import com.bz.smart_city.commom.util.HttpClientUtils;
+import com.bz.smart_city.commom.util.HttpRequest;
 import com.bz.smart_city.commom.util.UserUtil;
 import com.bz.smart_city.commom.util.UserUtil;
 import com.bz.smart_city.commom.util.Util;
 import com.bz.smart_city.commom.util.Util;
 import com.bz.smart_city.dao.pay.*;
 import com.bz.smart_city.dao.pay.*;
@@ -316,6 +317,7 @@ public class PayFeeServiceImp implements PayFeeService {
             if(payValveStateInfo != null
             if(payValveStateInfo != null
                     && payValveStateInfo.getDebt()!= null && payValveStateInfo.getDebt().compareTo(BigDecimal.ZERO) ==1
                     && payValveStateInfo.getDebt()!= null && payValveStateInfo.getDebt().compareTo(BigDecimal.ZERO) ==1
                     && payValveStateInfo.getValveState()!= null && payValveStateInfo.getValveState().equals("0")){
                     && payValveStateInfo.getValveState()!= null && payValveStateInfo.getValveState().equals("0")){
+                payValveStateInfo.setOperation(1);
                 Boolean sendValveCommondResult = this.sendValveCommond(payValveStateInfo);
                 Boolean sendValveCommondResult = this.sendValveCommond(payValveStateInfo);
                 if(!sendValveCommondResult){
                 if(!sendValveCommondResult){
 //                    result+="; 开阀异常:"+String.format("%.2f", transAmount)+"元";
 //                    result+="; 开阀异常:"+String.format("%.2f", transAmount)+"元";
@@ -579,6 +581,7 @@ public class PayFeeServiceImp implements PayFeeService {
            if(payValveStateInfo != null
            if(payValveStateInfo != null
                    && payValveStateInfo.getDebt()!= null && payValveStateInfo.getDebt().compareTo(BigDecimal.ZERO) ==1
                    && payValveStateInfo.getDebt()!= null && payValveStateInfo.getDebt().compareTo(BigDecimal.ZERO) ==1
                    && payValveStateInfo.getValveState()!= null && payValveStateInfo.getValveState().equals("0")){
                    && payValveStateInfo.getValveState()!= null && payValveStateInfo.getValveState().equals("0")){
+               payValveStateInfo.setOperation(1);
                Boolean sendValveCommondResult = this.sendValveCommond(payValveStateInfo);
                Boolean sendValveCommondResult = this.sendValveCommond(payValveStateInfo);
                if(!sendValveCommondResult){
                if(!sendValveCommondResult){
 //                    result+="; 开阀异常:"+String.format("%.2f", transAmount)+"元";
 //                    result+="; 开阀异常:"+String.format("%.2f", transAmount)+"元";
@@ -1247,6 +1250,7 @@ public class PayFeeServiceImp implements PayFeeService {
             if(payValveStateInfo != null
             if(payValveStateInfo != null
                     && payValveStateInfo.getDebt()!= null && payValveStateInfo.getDebt().compareTo(BigDecimal.ZERO) ==1
                     && payValveStateInfo.getDebt()!= null && payValveStateInfo.getDebt().compareTo(BigDecimal.ZERO) ==1
                     && payValveStateInfo.getValveState()!= null && payValveStateInfo.getValveState().equals("0")){
                     && payValveStateInfo.getValveState()!= null && payValveStateInfo.getValveState().equals("0")){
+                payValveStateInfo.setOperation(1);
                 Boolean sendValveCommondResult = this.sendValveCommond(payValveStateInfo);
                 Boolean sendValveCommondResult = this.sendValveCommond(payValveStateInfo);
                 if(!sendValveCommondResult){    //关阀失败
                 if(!sendValveCommondResult){    //关阀失败
 //                    result+="; 开阀异常:"+String.format("%.2f", transAmount)+"元";
 //                    result+="; 开阀异常:"+String.format("%.2f", transAmount)+"元";
@@ -1346,17 +1350,23 @@ public class PayFeeServiceImp implements PayFeeService {
     //缴费开阀
     //缴费开阀
     public Boolean sendValveCommond(PayValveStateInfo payValveStateInfo){
     public Boolean sendValveCommond(PayValveStateInfo payValveStateInfo){
         LoginUser loginUser =UserUtil.getCurrentUser();
         LoginUser loginUser =UserUtil.getCurrentUser();
-        JSONObject parmJson= new JSONObject();
-        parmJson.put("meterNo",payValveStateInfo.getMeterCode());
-        parmJson.put("type",1);    //1开0关
-        parmJson.put("customerNo",payValveStateInfo.getCustomerNo());
-        String context=parmJson.toString();
+//        JSONObject parmJson= new JSONObject();
+//        parmJson.put("meterNo",payValveStateInfo.getMeterCode());
+//        parmJson.put("type",payValveStateInfo.getOperation());    //1开0关
+//        parmJson.put("customerNo",payValveStateInfo.getCustomerNo());
+//        String context=parmJson.toString();
         try {
         try {
-            String result= HttpClientUtils.doPostWithJson(payValveCommondUrl+"/platform/sendCommond",context);
+
+            //调用阀门接口
+            String url=payValveCommondUrl + "/api/platform/sendCommond";
+            String params = String.format("?customerNo=%s&meterNo=%s&type=%s",payValveStateInfo.getCustomerNo(),payValveStateInfo.getMeterCode(),payValveStateInfo.getOperation());
+            String result = HttpRequest.doPost(url + params ,"");
+
+//            String result= HttpClientUtils.doPostWithJson(payValveCommondUrl+"/api/platform/sendCommond",context);
             log.info("开关阀请求结果"+result);
             log.info("开关阀请求结果"+result);
             JSONObject jsonObject= JSON.parseObject(result);
             JSONObject jsonObject= JSON.parseObject(result);
             Integer status= jsonObject.getInteger("status");
             Integer status= jsonObject.getInteger("status");
-            if(status .equals("000000")){   //返回正常
+            if(status .equals("0")){   //返回正常
                 //添加阀控记录
                 //添加阀控记录
                 PayControlRecord payControlRecord = new PayControlRecord();
                 PayControlRecord payControlRecord = new PayControlRecord();
                 payControlRecord.setAccountId(payValveStateInfo.getAccountId());
                 payControlRecord.setAccountId(payValveStateInfo.getAccountId());

+ 13 - 6
smart-city-platform/src/main/java/com/bz/smart_city/service/pay/PayFeeService.java

@@ -1,13 +1,17 @@
 package com.bz.smart_city.service.pay;
 package com.bz.smart_city.service.pay;
 
 
 import com.bz.smart_city.dto.pay.PayInvoiceDto;
 import com.bz.smart_city.dto.pay.PayInvoiceDto;
+import com.bz.smart_city.dto.pay.PaySysDictSelectDto;
 import com.bz.smart_city.dto.pay.payfee.*;
 import com.bz.smart_city.dto.pay.payfee.*;
 import com.bz.smart_city.entity.pay.PayPayAgentbranch;
 import com.bz.smart_city.entity.pay.PayPayAgentbranch;
+import com.bz.smart_city.entity.pay.PayPayReceived;
+import com.bz.smart_city.entity.pay.PayReceivable;
 
 
 import java.math.BigDecimal;
 import java.math.BigDecimal;
 import java.math.BigInteger;
 import java.math.BigInteger;
 import java.time.LocalDateTime;
 import java.time.LocalDateTime;
 import java.util.List;
 import java.util.List;
+import java.util.Map;
 
 
 /**
 /**
  * @Author wangli
  * @Author wangli
@@ -44,12 +48,15 @@ public interface PayFeeService {
      */
      */
     PayfeeResult payFeeCounter( String id,Integer payway,BigDecimal transAmount, Integer balancetype,BigDecimal debt,
     PayfeeResult payFeeCounter( String id,Integer payway,BigDecimal transAmount, Integer balancetype,BigDecimal debt,
                                 BigDecimal remaining,Integer amount,BigDecimal price);
                                 BigDecimal remaining,Integer amount,BigDecimal price);
-    /**
-     * 查询客户信息
-     * @param id 开户id
-     * @param condition 查询参数
-     * @return
-     */
+
+    PayPayReceived getReceived(PayReceivable payReceivable, Integer year , Integer month , LocalDateTime localDateTime, int payway, String payseriesno, BigDecimal receivedamount, Map<String, PaySysDictSelectDto> feetypeMap , Integer siteId, Integer customerId, Integer userId);
+
+        /**
+         * 查询客户信息
+         * @param id 开户id
+         * @param condition 查询参数
+         * @return
+         */
     List<PayfeeAccountInfoDto> findPayfeeAccountInfo(BigInteger id , String condition );
     List<PayfeeAccountInfoDto> findPayfeeAccountInfo(BigInteger id , String condition );
 
 
     /**
     /**

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

@@ -146,7 +146,7 @@
 	</select>
 	</select>
 
 
 
 
-	<select id ="getIds" resultType="java.lang.String">
+	<select id ="getIds" resultType="java.math.BigInteger">
 		SELECT
 		SELECT
 		a.id AS "id"
 		a.id AS "id"
 		FROM pay_amount_waterusedamount a
 		FROM pay_amount_waterusedamount a
@@ -154,6 +154,7 @@
 		<where>
 		<where>
 			a.reading is not null
 			a.reading is not null
 			and a.reading >= a.lastreading
 			and a.reading >= a.lastreading
+			and a.payamount is not null
 			<if test="customerId!= null" >and a.customer_id = #{customerId} </if>
 			<if test="customerId!= null" >and a.customer_id = #{customerId} </if>
 
 
 
 

+ 3 - 3
smart-city-platform/src/main/resources/mapper/pay/PayPayCheckbalanceMapper.xml

@@ -11,7 +11,7 @@
         left join pay_pay_agentbranch ppa on ppac.agentbranch_id = ppa.id and ppa.site_id=#{siteId} and ppa.customer_id=#{customerId}
         left join pay_pay_agentbranch ppa on ppac.agentbranch_id = ppa.id and ppa.site_id=#{siteId} and ppa.customer_id=#{customerId}
         left join pay_sys_dict psd on ppa.type = psd.`value` and psd.type = '机构类型' and psd.site_id=#{siteId} and psd.customer_id=#{customerId}
         left join pay_sys_dict psd on ppa.type = psd.`value` and psd.type = '机构类型' and psd.site_id=#{siteId} and psd.customer_id=#{customerId}
         where ppac.transtime>= #{stTime} and ppac.transtime <![CDATA[<=]]> #{endTime} and ppac.state not in(0,4)
         where ppac.transtime>= #{stTime} and ppac.transtime <![CDATA[<=]]> #{endTime} and ppac.state not in(0,4)
-        and ppac.site_id=#{siteId} and ppac.customer_id=#{customerId}
+        and ppac.customer_id=#{customerId}
         group by psd.label,psd.`value`
         group by psd.label,psd.`value`
     </select>
     </select>
 
 
@@ -62,7 +62,7 @@
         left join pay_pay_agentbranch ppa on ppac.agentbranch_id = ppa.id and ppa.site_id=#{siteId} and ppa.customer_id=#{customerId}
         left join pay_pay_agentbranch ppa on ppac.agentbranch_id = ppa.id and ppa.site_id=#{siteId} and ppa.customer_id=#{customerId}
         left join pay_sys_dict psd on ppa.type = psd.`value` and psd.type = '机构类型' and psd.site_id=#{siteId} and psd.customer_id=#{customerId}
         left join pay_sys_dict psd on ppa.type = psd.`value` and psd.type = '机构类型' and psd.site_id=#{siteId} and psd.customer_id=#{customerId}
         where ppac.state not in(0,4) and  ppac.transtime >= #{stTime} and ppac.transtime <![CDATA[<=]]> #{endTime}
         where ppac.state not in(0,4) and  ppac.transtime >= #{stTime} and ppac.transtime <![CDATA[<=]]> #{endTime}
-        and ppac.site_id=#{siteId} and ppac.customer_id=#{customerId}
+        and ppac.customer_id=#{customerId}
         group by psd.label,psd.`value`,ymd ORDER BY ymd asc
         group by psd.label,psd.`value`,ymd ORDER BY ymd asc
     </select>
     </select>
 
 
@@ -107,7 +107,7 @@
         from pay_pay_transactiondetails ptrans
         from pay_pay_transactiondetails ptrans
         LEFT JOIN pay_sys_dict psd1 on psd1.`value` = ptrans.transtype and psd1.type='交易类型' and psd1.site_id=#{siteId} and psd1.customer_id=#{customerId}
         LEFT JOIN pay_sys_dict psd1 on psd1.`value` = ptrans.transtype and psd1.type='交易类型' and psd1.site_id=#{siteId} and psd1.customer_id=#{customerId}
         LEFT JOIN pay_sys_dict psd2 on psd2.`value` = ptrans.payway and psd2.type='支付方式' and psd2.site_id=#{siteId} and psd2.customer_id=#{customerId}
         LEFT JOIN pay_sys_dict psd2 on psd2.`value` = ptrans.payway and psd2.type='支付方式' and psd2.site_id=#{siteId} and psd2.customer_id=#{customerId}
-        left join pay_pay_agenttransaction pagent on pagent.payseriesno = ptrans.payseriesno and pagent.site_id=#{siteId} and pagent.customer_id=#{customerId}
+        left join pay_pay_agenttransaction pagent on pagent.payseriesno = ptrans.payseriesno and pagent.customer_id=#{customerId}
         left join sc_user scu on scu.id = ptrans.cancelperson
         left join sc_user scu on scu.id = ptrans.cancelperson
         where ptrans.site_id=#{siteId} and ptrans.customer_id=#{customerId}
         where ptrans.site_id=#{siteId} and ptrans.customer_id=#{customerId}
         and ptrans.create_date >= #{stTime} and ptrans.create_date <![CDATA[<]]> #{endTime}
         and ptrans.create_date >= #{stTime} and ptrans.create_date <![CDATA[<]]> #{endTime}

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

@@ -417,4 +417,79 @@
 
 
     </select>
     </select>
 
 
+    <select id="getDeviceValveStateByAccountId" resultType="com.bz.smart_city.dto.pay.payfee.PayValveStateInfo">
+        select
+            d.account_id as "accountId"
+            ,d.id as "meterId"
+            ,d.water_meter_no as "eleno"
+            ,ifnull(d.water_meter_no,d.metercode )as "metercode"
+            ,d.control_status as "valveState"
+            ,(select sum(debt) from pay_pay_receivable where debt>0 and account_id=#{accountId}) as "debt"
+            ,cs.customer_no as "customerNo"
+        from sc_device d
+        left join pay_base_customerandmeterrela c on c.watermeter_id=d.id
+        left join sc_customer cs on cs.id=d.customer_id
+        where c.account_id=#{accountId}
+
+    </select>
+
+    <select id="getDeviceValveStateByAmount" resultType="com.bz.smart_city.dto.pay.payfee.PayValveStateInfo">
+        select
+        r.account_id as "accountId"
+        ,d.id as "meterId"
+        ,d.water_meter_no as "eleno"
+        ,ifnull(d.water_meter_no,d.metercode )as "metercode"
+        ,d.control_status as "valveState"
+        ,cs.customer_no as "customerNo"
+        ,sum(debt) debt
+        from pay_pay_receivable r
+        left join sc_device d on d.id=r.meter_id
+        left join sc_customer cs on cs.id=d.customer_id
+        where debt > 0
+        and r.account_id in (
+        select account_id
+        from pay_amount_waterusedamount
+        where   id in
+        <foreach collection="list" item="item" open="(" separator=" or " close=")">
+            #{item}
+        </foreach>
+        )
+        group by cs.customer_no, r.account_id	,d.id	,d.water_meter_no	,d.water_meter_no,d.metercode ,d.control_status
+
+    </select>
+
+    <select id="getDeviceValveStateByRecord" resultType="com.bz.smart_city.dto.pay.payfee.PayValveStateInfo">
+        select
+            c.account_id as "accountId"
+            ,d.id as "meterId"
+            ,d.water_meter_no as "eleno"
+            ,ifnull(d.water_meter_no,d.metercode )as "metercode"
+            ,d.control_status as "valveState"
+            ,cs.customer_no as "customerNo"
+            ,v.control_state as "operation"
+        from pay_control_valve v
+        left join sc_device d on d.id=v.device_id
+        left join pay_base_customerandmeterrela c on c.watermeter_id =d.id
+        left join sc_customer cs on cs.id=d.customer_id
+    </select>
+
+    <delete id="deleteControlValveInfoByDevice">
+        delete from pay_control_valve
+        where   device_id in
+        <foreach collection="list" item="item" open="(" separator=" or " close=")">
+            #{item}
+        </foreach>
+    </delete>
+
+    <select id="getValveRulesByType" resultType="com.bz.smart_city.entity.pay.PayControlRule">
+        select
+            id as "id"
+            ,condition_id as "conditionId"
+            ,operator as "operator"
+            ,value as "value"
+            ,action as "action"
+        from pay_control_rule
+        where `disable` = 0 and  condition_id =#{type}
+    </select>
+
 </mapper>
 </mapper>