浏览代码

生成阀控记录 调用阀控接口

oppadmin 4 年之前
父节点
当前提交
a54528a0ba
共有 22 个文件被更改,包括 376 次插入40 次删除
  1. 1 1
      smart-city-platform/src/main/java/com/bz/smart_city/controller/pay/PaySyncDataController.java
  2. 1 1
      smart-city-platform/src/main/java/com/bz/smart_city/dao/pay/PayControlRuleMapper.java
  3. 4 0
      smart-city-platform/src/main/java/com/bz/smart_city/entity/Import.java
  4. 18 0
      smart-city-platform/src/main/java/com/bz/smart_city/entity/SyncValveResult.java
  5. 21 0
      smart-city-platform/src/main/java/com/bz/smart_city/entity/SyncValveSend.java
  6. 11 8
      smart-city-platform/src/main/java/com/bz/smart_city/entity/pay/PayControlRule.java
  7. 6 0
      smart-city-platform/src/main/java/com/bz/smart_city/entity/pay/archives/PayBaseCustomerandmeterrela.java
  8. 11 2
      smart-city-platform/src/main/java/com/bz/smart_city/excel/resolver/InstallPlanResolverExcelTemplate.java
  9. 32 0
      smart-city-platform/src/main/java/com/bz/smart_city/quartz/job/ControlByDayJob.java
  10. 9 0
      smart-city-platform/src/main/java/com/bz/smart_city/quartz/service/ControlDayService.java
  11. 142 0
      smart-city-platform/src/main/java/com/bz/smart_city/quartz/service/impl/ControlDayServiceImpl.java
  12. 2 1
      smart-city-platform/src/main/java/com/bz/smart_city/service/impl/ImportServiceImpl.java
  13. 4 1
      smart-city-platform/src/main/java/com/bz/smart_city/service/impl/pay/PayBaseAccountServiceImpl.java
  14. 55 2
      smart-city-platform/src/main/java/com/bz/smart_city/service/impl/pay/PayControlRuleServiceImpl.java
  15. 11 2
      smart-city-platform/src/main/java/com/bz/smart_city/service/impl/pay/PaySyncDataServiceImpl.java
  16. 2 1
      smart-city-platform/src/main/java/com/bz/smart_city/service/pay/PayBaseAccountService.java
  17. 19 0
      smart-city-platform/src/main/java/com/bz/smart_city/service/pay/PayControlRuleService.java
  18. 2 1
      smart-city-platform/src/main/java/com/bz/smart_city/service/pay/PaySyncDataService.java
  19. 1 1
      smart-city-platform/src/main/resources/application-dev.properties
  20. 3 1
      smart-city-platform/src/main/resources/mapper/PayBaseCustomerandmeterrelaMapper.xml
  21. 16 16
      smart-city-platform/src/main/resources/mapper/pay/PayControlRecordMapper.xml
  22. 5 2
      smart-city-platform/src/main/resources/mapper/pay/PayControlRuleMapper.xml

+ 1 - 1
smart-city-platform/src/main/java/com/bz/smart_city/controller/pay/PaySyncDataController.java

@@ -40,7 +40,7 @@ public class PaySyncDataController {
     public AjaxMessage add(
             @ApiParam(value = "安装计划", required = true) @RequestBody(required = true) InstallPlanInputDTO installPlanInput
     ) {
-        return paySyncDataService.addJF(installPlanInput);
+        return paySyncDataService.addJF(installPlanInput,null);
         //return new AjaxMessage(ResultStatus.OK);
     }
 

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

@@ -17,7 +17,7 @@ public interface PayControlRuleMapper {
 
     Integer add(@Param("payControlRule")PayControlRule payControlRule);
 
-    List<PayControlRule>findList(@Param("name") String name,@Param("customerId") BigInteger customerId);
+    List<PayControlRule>findList(@Param("id") Integer id,@Param("name") String name,@Param("customerId") BigInteger customerId);
 
     Integer edit(@Param("payControlRule")PayControlRule payControlRule);
 

+ 4 - 0
smart-city-platform/src/main/java/com/bz/smart_city/entity/Import.java

@@ -1,5 +1,6 @@
 package com.bz.smart_city.entity;
 
+import com.bz.smart_city.dto.LoginUser;
 import com.fasterxml.jackson.annotation.JsonFormat;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
@@ -58,4 +59,7 @@ public class Import {
 
     @ApiModelProperty(value="null")
     private String updateBy;
+
+    @ApiModelProperty(value = "登录信息")
+    private LoginUser loginUser;
 }

+ 18 - 0
smart-city-platform/src/main/java/com/bz/smart_city/entity/SyncValveResult.java

@@ -0,0 +1,18 @@
+package com.bz.smart_city.entity;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+/**
+ * Created by ZJY on 2021-01-19 10:00
+ */
+@Data
+@ApiModel(value = "同步结果")
+public class SyncValveResult {
+    @ApiModelProperty("返回状态,成功000000")
+    private String status;
+
+    @ApiModelProperty("提示")
+    private String msg;
+}

+ 21 - 0
smart-city-platform/src/main/java/com/bz/smart_city/entity/SyncValveSend.java

@@ -0,0 +1,21 @@
+package com.bz.smart_city.entity;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+/**
+ * Created by ZJY on 2021-01-19 9:19
+ */
+@Data
+@ApiModel(value = "同步")
+public class SyncValveSend {
+    @ApiModelProperty("客户编码")
+    private String customerNo;
+
+    @ApiModelProperty("水表表号")
+    private String meterNo;
+
+    @ApiModelProperty("开阀1关阀0")
+    private String type;
+}

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

@@ -17,28 +17,31 @@ public class PayControlRule {
     @ApiModelProperty(example="1",notes = "主键ID,自动生成",position = 1)
     private BigInteger id;
 
-    @ApiModelProperty(example="欠费关阀",notes = "规则描述",position = 2)
+    @ApiModelProperty(example="欠费关阀",notes = "规则描述",position = 5)
     private String name;
 
-    @ApiModelProperty(example="欠费天数",notes = "判断条件",position = 3)
+    @ApiModelProperty(example="欠费天数",notes = "判断条件",position = 10)
     private String condition;
 
-    @ApiModelProperty(example=">",notes = "运算符",position = 4)
+    @ApiModelProperty(example="1",notes = "判断条件ID",position = 10)
+    private Integer conditionId;
+
+    @ApiModelProperty(example=">",notes = "运算符",position = 15)
     private String operator;
 
-    @ApiModelProperty(example="1",notes = "条件值",position = 5)
+    @ApiModelProperty(example="1",notes = "条件值",position = 20)
     private String value;
 
-    @ApiModelProperty(example="0",notes = "执行动作,0关阀 1开阀",position = 6)
+    @ApiModelProperty(example="0",notes = "执行动作,0关阀 1开阀",position = 30)
     private String action;
 
-    @ApiModelProperty(example="元", notes="单位",position = 7)
+    @ApiModelProperty(example="元", notes="单位",position = 35)
     private String unit;
 
-    @ApiModelProperty(example="0", notes="停用标志 0启用 1停用",position = 8)
+    @ApiModelProperty(example="0", notes="停用标志 0启用 1停用",position = 40)
     private String disable;
 
-    @ApiModelProperty(example = "正常",notes = "备注",position = 9)
+    @ApiModelProperty(example = "正常",notes = "备注",position = 45)
     private String remarks;
 
 

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

@@ -101,4 +101,10 @@ public class PayBaseCustomerandmeterrela {
     private List<ProgramItem> programItems;
     @ApiModelProperty(value = "水表电子号", position = 33)
     public String metereleno;
+
+    @ApiModelProperty(value = "阀控规则ID,例:1,2,3,4", position = 34)
+    public String valveRuleId;
+
+    @ApiModelProperty(value = "阀控规则名称", position = 35)
+    public String valveRuleName;
 }

+ 11 - 2
smart-city-platform/src/main/java/com/bz/smart_city/excel/resolver/InstallPlanResolverExcelTemplate.java

@@ -221,15 +221,20 @@ public class InstallPlanResolverExcelTemplate extends AbstractResolverExcelTempl
 
                     InstallPlanDataDTO buildDTO = new InstallPlanDataDTO();
                     InstallPlanDataDTO unitDTO = new InstallPlanDataDTO();
+                    unitDTO.setChildren(new ArrayList<>());
                     InstallPlanDataDTO floorDTO = new InstallPlanDataDTO();
                     InstallPlanDataDTO doorNoDTO = new InstallPlanDataDTO();
 
                     //楼栋 单元 楼层 门牌号
                     buildDTO.setName(buildingCell.getStringCellValue().trim());
+                    buildDTO.setChildren(new ArrayList());
+
                     floorDTO.setName(floorCell.getStringCellValue().trim());
+                    floorDTO.setChildren( new ArrayList());
+
                     doorNoDTO.setName(doorNoCell.getStringCellValue().trim());
 
-                    floorDTO.getChildren().add(doorNoDTO);
+                   floorDTO.getChildren().add(doorNoDTO);
                     if(installPlanInput.getEnableUnit() == 1){
                         unitDTO.setName(unitCell.getStringCellValue().trim());
                         unitDTO.getChildren().add(floorDTO);
@@ -238,7 +243,11 @@ public class InstallPlanResolverExcelTemplate extends AbstractResolverExcelTempl
                     else
                         buildDTO.getChildren().add(floorDTO);
 
-                    AjaxMessage ajax = paySyncDataService.addJF(installPlanInput);
+                    if(installPlanInput.getInstallPlanDataList() == null)
+                        installPlanInput.setInstallPlanDataList(new ArrayList<>());
+                    installPlanInput.getInstallPlanDataList().add(buildDTO);
+                    record.getLoginUser().setSiteType(2);
+                    AjaxMessage ajax = paySyncDataService.addJF(installPlanInput,record.getLoginUser());
                     if(ajax != null){
                         if(ajax.getStatus()==0){
                             ;//成功

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

@@ -0,0 +1,32 @@
+package com.bz.smart_city.quartz.job;
+
+import com.bz.smart_city.quartz.service.ControlDayService;
+import lombok.extern.slf4j.Slf4j;
+import org.quartz.Job;
+import org.quartz.JobExecutionContext;
+import org.quartz.JobExecutionException;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import java.io.Serializable;
+
+/**
+ * Created by ZJY on 2021-01-19 8:06
+ */
+@Slf4j
+@Component
+public class ControlByDayJob implements Job, Serializable {
+
+    private static final long serialVersionUID = 4516011696487870906L;
+    @Autowired
+    ControlDayService controlDayService;
+
+    @Override
+    public void execute(JobExecutionContext context) throws JobExecutionException {
+
+        // 2,调用推送方法
+        log.info("invoke ControlByDayJob");
+        controlDayService.start();
+        log.info("invoked ControlByDayJob");
+    }
+}

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

@@ -0,0 +1,9 @@
+package com.bz.smart_city.quartz.service;
+
+/**
+ * Created by ZJY on 2021-01-18 19:11
+ */
+public interface ControlDayService {
+
+    void start();
+}

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

@@ -0,0 +1,142 @@
+package com.bz.smart_city.quartz.service.impl;
+
+import com.bz.smart_city.commom.util.HttpRequest;
+import com.bz.smart_city.commom.util.JacksonUtil;
+import com.bz.smart_city.dao.CustomerMapper;
+import com.bz.smart_city.dao.pay.AmountWaterUsedAmountMapper;
+import com.bz.smart_city.dao.pay.PayControlRecordMapper;
+import com.bz.smart_city.dao.pay.archives.PayBaseCustomerandmeterrelaMapper;
+import com.bz.smart_city.entity.Customer;
+import com.bz.smart_city.entity.SyncValveResult;
+import com.bz.smart_city.entity.SyncValveSend;
+import com.bz.smart_city.entity.pay.PayControlRecord;
+import com.bz.smart_city.entity.pay.archives.PayBaseCustomerandmeterrela;
+import com.bz.smart_city.quartz.entity.QuartzEntity;
+import com.bz.smart_city.quartz.job.ControlByDayJob;
+import com.bz.smart_city.quartz.service.ControlDayService;
+import com.bz.smart_city.quartz.service.JobAndTriggerService;
+import com.bz.smart_city.service.pay.PayControlRuleService;
+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.beans.factory.annotation.Value;
+import org.springframework.http.HttpEntity;
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.MediaType;
+import org.springframework.http.ResponseEntity;
+import org.springframework.stereotype.Component;
+import org.springframework.util.LinkedMultiValueMap;
+import org.springframework.util.MultiValueMap;
+import org.springframework.web.client.RestTemplate;
+
+import javax.annotation.Resource;
+import java.time.LocalDateTime;
+import java.util.List;
+
+/**
+ * Created by ZJY on 2021-01-18 19:10
+ */
+@Slf4j
+@Component
+public class ControlDayServiceImpl implements ControlDayService, InitializingBean {
+    @Resource
+    private AmountWaterUsedAmountMapper amountWaterUsedAmountMapper;
+    @Resource
+    PayBaseCustomerandmeterrelaMapper payBaseCustomerandmeterrelaMapper;
+    @Resource
+    PayControlRecordMapper payControlRecordMapper;
+    @Resource
+    private JobAndTriggerService jobAndTriggerService;
+    @Resource
+    CustomerMapper  customerMapper;
+
+    @Autowired
+    PayControlRuleService payControlRuleService;
+
+    @Value("${Sync.Data.Url}")
+    String SyncUrl;
+
+    @Override
+    public void afterPropertiesSet(){
+        saveQrtzTask();
+    }
+
+    public void saveQrtzTask(){
+        // 1,查询需要批量推送的配置项目并构建定时任务
+        // 2,若对应定时任务不存在则创建
+        QuartzEntity entity = new QuartzEntity();
+        entity.setJobGroup("根据阀控规则定时处理开关阀");
+        entity.setJobName("ControlByDayJob" );
+        entity.setDescription("ControlByDayJob" );
+
+        boolean exists = jobAndTriggerService.isExists(entity);
+        if(!exists) {
+            String cron = "0 */30 * * * ?";
+            log.info("每天处理开关阀:" + cron);
+            entity.setCronExpression(cron);
+            entity.setJobClassName(ControlByDayJob.class.getName());
+            jobAndTriggerService.save(entity);
+        }
+    }
+
+    @Override
+    public void start(){
+        List<PayBaseCustomerandmeterrela> payBaseCustomerandmeterrelas = amountWaterUsedAmountMapper.getCustIdAndSiteId();
+        for (PayBaseCustomerandmeterrela payBaseCustomerandmeterrela: payBaseCustomerandmeterrelas){
+
+            PayBaseCustomerandmeterrela customer = new PayBaseCustomerandmeterrela();
+            customer.setCustomerId(payBaseCustomerandmeterrela.getCustomerId());
+            List<PayBaseCustomerandmeterrela> payBaseCustomerandmeterrelaList = payBaseCustomerandmeterrelaMapper.findList(customer);
+            if(payBaseCustomerandmeterrelaList.size() > 0){
+
+                Customer customerNo = customerMapper.findById(customer.getCustomerId().intValue());
+                for (PayBaseCustomerandmeterrela one: payBaseCustomerandmeterrelaList){
+                    String[] deviceType  = StringUtils.split(one.getValveRuleId(),",");
+                    String[] deviceTypeName  = StringUtils.split(one.getValveRuleName(),",");
+
+                    if(deviceType != null ){
+                        for (int i=0;i<deviceType.length;i++){
+                            //result执行动作,0关阀 1开阀
+                            Integer result = payControlRuleService.GetConditionReusl(new Integer(deviceType[i]),one.getAccountId().toString());
+                            if(result != null){
+                                //插入数据库
+                                PayControlRecord payControlRecord = new PayControlRecord();
+                                payControlRecord.setAccountId(one.getAccountId());
+                                payControlRecord.setMeterId(one.getWatermeterId());
+                                payControlRecord.setType(result);
+                                payControlRecord.setControlRuleId(new Integer(deviceType[i]));
+                                payControlRecord.setControlRuleIdName(deviceTypeName[i]);
+                                payControlRecord.setDelFlag("0");
+                                payControlRecord.setCustomerId(customer.getCustomerId());
+                                payControlRecord.setCreateDate(LocalDateTime.now());
+                                payControlRecordMapper.add(payControlRecord);
+
+                                //调用阀门接口
+                                try {
+                                    String url=SyncUrl + "/api/platform/sendCommond";
+
+                                    String params = String.format("?customerNo=%s&meterNo=%s&type=%s",customerNo.getCustomerNo(),payControlRecord.getMeterId().toString(),payControlRecord.getType().toString());
+                                    url += params;
+                                    SyncValveSend syncValveSend = new SyncValveSend();
+                                    syncValveSend.setMeterNo(payControlRecord.getMeterId().toString());
+                                    syncValveSend.setType(payControlRecord.getType().toString());
+                                    syncValveSend.setCustomerNo(customerNo.getCustomerNo());
+                                    String json = JacksonUtil.obj2String(syncValveSend);
+                                    String postResult = HttpRequest.doPost(url ,"");
+                                    SyncValveResult syncValveResult = JacksonUtil.string2Obj(postResult, SyncValveResult.class);
+                                    Integer getResult = Integer.parseInt(syncValveResult.getStatus());
+                                }
+                                catch (Exception e){
+                                    e.printStackTrace();
+                                }
+                            }
+                        }
+                    }
+
+                }
+            }
+
+        }
+    }
+}

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

@@ -90,6 +90,7 @@ public class ImportServiceImpl implements ImportService{
         record.setImportStatus(0);
         record.setSuccessTime(0);
         record.setFailTime(0);
+        record.setId(loginUser.getId());
 
 
 
@@ -100,7 +101,7 @@ public class ImportServiceImpl implements ImportService{
             asyncTaskImportService.executeAsyncCustomerTask(loginUser,record,file);
         }
         if(importType == 7){
-
+            record.setLoginUser(loginUser);
             asyncTaskImportService.executeAsyncInstallPlanTask(record);
         }
         log.info("返回结果");

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

@@ -280,9 +280,12 @@ public class PayBaseAccountServiceImpl implements PayBaseAccountService {
 
 
     @Override
-    public int batchInsert(List<PayBaseAccountDto> list,String code) {
+    public int batchInsert(List<PayBaseAccountDto> list,String code,LoginUser excelLoginUser) {
         //1、从登陆信息中获取站点Id 水司ID
         LoginUser loginUser = getLoginUser();
+        if(loginUser == null){
+            loginUser =excelLoginUser;
+        }
         //int maxAccountNumber = getMaxAccountNumber(code);
         int codeNumber = Integer.parseInt(code);
         List<PayRechargeaccountDto> rechList = new ArrayList<PayRechargeaccountDto>();

+ 55 - 2
smart-city-platform/src/main/java/com/bz/smart_city/service/impl/pay/PayControlRuleServiceImpl.java

@@ -6,10 +6,12 @@ import com.bz.smart_city.commom.util.UserUtil;
 import com.bz.smart_city.dao.pay.PayControlRecordMapper;
 import com.bz.smart_city.dao.pay.PayControlRuleMapper;
 import com.bz.smart_city.dao.pay.PayRechargeaccountMapper;
+import com.bz.smart_city.dao.pay.archives.PayBaseCustomerandmeterrelaMapper;
 import com.bz.smart_city.dto.LoginUser;
 import com.bz.smart_city.dto.pay.PayRechargeaccountDto;
 import com.bz.smart_city.entity.pay.PayControlRecord;
 import com.bz.smart_city.entity.pay.PayControlRule;
+import com.bz.smart_city.entity.pay.archives.PayBaseCustomerandmeterrela;
 import com.bz.smart_city.service.pay.PayControlRuleService;
 import com.github.pagehelper.PageHelper;
 import org.springframework.stereotype.Service;
@@ -32,6 +34,7 @@ public class PayControlRuleServiceImpl implements PayControlRuleService {
     PayRechargeaccountMapper payRechargeaccountMapper;
 
 
+
     @Override
     public Integer add(PayControlRule payControlRule){
         LoginUser loginUser = UserUtil.getCurrentUser();
@@ -55,7 +58,7 @@ public class PayControlRuleServiceImpl implements PayControlRuleService {
     public List<PayControlRule>findList(String name){
         LoginUser loginUser = UserUtil.getCurrentUser();
         BigInteger customerId = new BigInteger(String.valueOf(loginUser.getCustomerId()));
-        return payControlRuleMapper.findList(name,customerId);
+        return payControlRuleMapper.findList(null,name,customerId);
     }
 
     @Override
@@ -64,7 +67,7 @@ public class PayControlRuleServiceImpl implements PayControlRuleService {
         BigInteger customerId = new BigInteger(String.valueOf(loginUser.getCustomerId()));
 
         PageHelper.startPage(pageNum,pageSize);
-        List<PayControlRule> payControlRules = payControlRuleMapper.findList(name,customerId);
+        List<PayControlRule> payControlRules = payControlRuleMapper.findList(null,name,customerId);
         return new  Pagination<>(payControlRules);
     }
 
@@ -114,6 +117,7 @@ public class PayControlRuleServiceImpl implements PayControlRuleService {
      * @param value 判断值
      * @return 符合条件返回true
      */
+    @Override
     public boolean ConditionDebtDay(String accountId,String condition,String value){
         Integer day = payControlRuleMapper.findDebtDay(accountId);
         int paramDay = Integer.valueOf(value).intValue();
@@ -162,6 +166,7 @@ public class PayControlRuleServiceImpl implements PayControlRuleService {
      * @param value 判断值
      * @return 符合条件返回true
      */
+    @Override
     public boolean ConditionDebtMoney(String accountId,String condition,String value){
         BigDecimal money = payControlRuleMapper.findDebtMoney(accountId);
         if(money != null){
@@ -257,6 +262,7 @@ public class PayControlRuleServiceImpl implements PayControlRuleService {
      * @param value 判断值
      * @return 符合条件返回true
      */
+    @Override
     public  boolean ConditionUsedMoney(String accountId,String condition,String value){
         BigDecimal money = payControlRuleMapper.findUseMoeny(accountId);
         if(money != null){
@@ -303,6 +309,7 @@ public class PayControlRuleServiceImpl implements PayControlRuleService {
      * @param value 判断值
      * @return 符合条件返回true
      */
+    @Override
     public boolean ConditionOpenUsed(String accountId,String condition,String value){
         Integer state = payControlRuleMapper.findDebtDay(accountId);
         int paramValue = Integer.valueOf(value).intValue();
@@ -333,6 +340,7 @@ public class PayControlRuleServiceImpl implements PayControlRuleService {
      * @param value 判断值
      * @return 符合条件返回true
      */
+    @Override
     public boolean ConditionRechargeAndDebt(String accountId,String condition,String value){
         BigDecimal Recharge = payControlRuleMapper.findUseMoeny(accountId);
         if(Recharge == null)
@@ -392,4 +400,49 @@ public class PayControlRuleServiceImpl implements PayControlRuleService {
         return false;
     }
 
+    /**
+     *
+     * @param id    阀控规则ID
+     * @param accountId
+     * @return
+     */
+    @Override
+    public Integer GetConditionReusl(Integer id,String accountId){
+        List<PayControlRule> payControlRules = payControlRuleMapper.findList(id,null,null);
+        if(payControlRules.size() ==1){
+            String condition= payControlRules.get(0).getOperator();
+            String value = payControlRules.get(0).getValue();
+            boolean bl = false;
+            switch (payControlRules.get(0).getConditionId()){
+                case 1:{
+                    bl =   ConditionDebtDay(accountId,condition,value);
+                    break;
+                }
+                case 2:{
+                    bl = ConditionDebtMoney(accountId,condition,value);
+                    break;
+                }
+                case 3:{
+                    bl = ConditionRecharge(accountId,condition,value);
+                    break;
+                }
+                case 4:{
+                    bl = ConditionOpenUsed(accountId,condition,value);
+                    break;
+                }
+                case 5:{
+                    bl= ConditionRechargeAndDebt(accountId,condition,value);
+                    break;
+                }
+
+            }
+
+            if(bl){
+                return new Integer(payControlRules.get(0).getAction());
+            }
+        }
+        return null;
+
+    }
+
 }

+ 11 - 2
smart-city-platform/src/main/java/com/bz/smart_city/service/impl/pay/PaySyncDataServiceImpl.java

@@ -123,9 +123,15 @@ public class PaySyncDataServiceImpl implements PaySyncDataService {
 
     @Override
     @Transactional
-    public AjaxMessage addJF(InstallPlanInputDTO installPlanInput){
+    public AjaxMessage addJF(InstallPlanInputDTO installPlanInput,LoginUser excelLoginUser){
 
         LoginUser loginUser = UserUtil.getCurrentUser();
+        if(loginUser == null){
+            //异步批量导入无法获取loginUser
+            loginUser = excelLoginUser;
+        }
+
+
         Integer siteId = 1;
         if (loginUser.getSiteType() == 1) {
             siteId = loginUser.getSiteId();
@@ -268,7 +274,10 @@ public class PaySyncDataServiceImpl implements PaySyncDataService {
                 if(ajaxMessage != null && ajaxMessage.getStatus() == 0){
 
                     //生成用户信息和预存账户
-                    payBaseAccountService.batchInsert(accountLists, code);
+                    accountLists.get(0).setSiteId(BigInteger.valueOf(loginUser.getSiteId()));
+                    accountLists.get(0).setCustomerId(BigInteger.valueOf(loginUser.getCurrentSiteId()));
+
+                    payBaseAccountService.batchInsert(accountLists, code,loginUser);
 
                     //生成水表信息(sc_device表)
                     deviceMapper.insertList(deviceList);

+ 2 - 1
smart-city-platform/src/main/java/com/bz/smart_city/service/pay/PayBaseAccountService.java

@@ -2,6 +2,7 @@ package com.bz.smart_city.service.pay;
 
 
 import com.bz.smart_city.commom.model.Pagination;
+import com.bz.smart_city.dto.LoginUser;
 import com.bz.smart_city.dto.pay.*;
 import com.bz.smart_city.entity.pay.PayBaseAccount;
 import com.bz.smart_city.entity.pay.PayMeter;
@@ -22,7 +23,7 @@ public interface PayBaseAccountService {
 
     Pagination<PayBaseAccount> getAll(String queryInfo, Integer pageNum, Integer pageSize);
 
-    int batchInsert(List<PayBaseAccountDto> list,String code);
+    int batchInsert(List<PayBaseAccountDto> list, String code, LoginUser excelLoginUser);
 
     Pagination<PayBaseAccountSelectDto> findList(String queryInfo,String state, String sortColumn,String sortOrder, Integer pageNum, Integer pageSize);
     PayBaseAccountSelectAccountnumberDto findAccountnumberList(String accountnumber, Integer Year);

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

@@ -23,4 +23,23 @@ public interface PayControlRuleService {
 
     Integer delete(String id);
 
+    //欠费天数
+    boolean ConditionDebtDay(String accountId,String condition,String value);
+
+    //欠费金额
+    boolean ConditionDebtMoney(String accountId,String condition,String value);
+
+    //预存金额
+    boolean ConditionRecharge(String accountId,String condition,String value);
+
+    //用水余额
+    boolean ConditionUsedMoney(String accountId,String condition,String value);
+
+    //开户状态
+    boolean ConditionOpenUsed(String accountId,String condition,String value);
+
+    //预存与欠费差额
+    boolean ConditionRechargeAndDebt(String accountId,String condition,String value);
+
+    Integer GetConditionReusl(Integer id,String accountId);
 }

+ 2 - 1
smart-city-platform/src/main/java/com/bz/smart_city/service/pay/PaySyncDataService.java

@@ -4,6 +4,7 @@ import com.bz.smart_city.commom.model.AjaxMessage;
 import com.bz.smart_city.dto.AreaDto;
 import com.bz.smart_city.dto.CommunityDto;
 import com.bz.smart_city.dto.DeviceTypeDto;
+import com.bz.smart_city.dto.LoginUser;
 import com.bz.smart_city.dto.pay.InstallPlanInputDTO;
 import com.bz.smart_city.entity.Community;
 import com.bz.smart_city.entity.WaterMeterReplaceLog;
@@ -23,5 +24,5 @@ public interface PaySyncDataService {
 
     int addReplaceRecord(WaterMeterReplaceLog waterMeterReplaceLog);
 
-    AjaxMessage addJF(InstallPlanInputDTO installPlanInput);
+    AjaxMessage addJF(InstallPlanInputDTO installPlanInput, LoginUser excelloginUser);
 }

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

@@ -117,7 +117,7 @@ amount.syn.day.url=http://114.135.61.188:58080/api/syncData/meterReadData
 #水量同步接口
 amount.syn.url=http://114.135.61.188:58080/api/syncData/clearingData
 
-pay.valve.conmond.url = http://ip:port/platform/sendCommond 
+pay.valve.conmond.url = http://114.135.61.188:58080/platform/sendCommond
 
 
 

+ 3 - 1
smart-city-platform/src/main/resources/mapper/PayBaseCustomerandmeterrelaMapper.xml

@@ -36,7 +36,9 @@
         customer.opendate as "opendate",
         customer.businessstate as "businessstate",
         customer.calculateway as "calculateway",
-        pro.id as "waterPropertyId"
+        pro.id as "waterPropertyId",
+        customer.valve_rule_id,
+        customer.valve_rule_name
         from pay_base_customerandmeterrela customer
         left join pay_base_account account on customer.account_id = account.id
         left join pay_base_waterproperty pro on pro.id = customer.waterproperty_id

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

@@ -35,21 +35,21 @@
     </select>
 
     <insert id="add" useGeneratedKeys="true" keyColumn="id">
-        insert into pay_control_record pcr (
-        pcr.account_id,
-        pcr.meter_id,
-        pcr.type,
-        pcr.result,
-        pcr.state,
-        pcr.control_rule_id,
-        pcr.create_by,
-        pcr.create_date,
-        pcr.update_by,
-        pcr.update_date,
-        pcr.del_flag,
-        pcr.remarks,
-        pcr.site_id,
-        pcr.customer_id
+        insert into pay_control_record(
+        account_id,
+        meter_id,
+        type,
+        result,
+        state,
+        control_rule_id,
+        create_by,
+        create_date,
+        update_by,
+        update_date,
+        del_flag,
+        remarks,
+        site_id,
+        customer_id
         )
         values(
         #{payControlRecord.accountId},
@@ -65,7 +65,7 @@
         0,
         #{payControlRecord.remarks},
         #{payControlRecord.siteId},
-        #{payControlRecord.customerId},
+        #{payControlRecord.customerId}
         )
 
     </insert>

+ 5 - 2
smart-city-platform/src/main/resources/mapper/pay/PayControlRuleMapper.xml

@@ -45,6 +45,7 @@
             id,
             name,
             `condition`,
+            condition_id,
             operator,
             value,
             action,
@@ -60,7 +61,9 @@
             customer_id
         from pay_control_rule
         <where>
-            del_flag = 0 and customer_id = #{customerId}
+            del_flag = 0
+            <if test="customerId != null"> and customer_id = #{customerId} </if>
+            <if test="id != null"> and id = #{id}</if>
             <if test="name != null"> and name = #{name}</if>
         </where>
     </select>
@@ -116,7 +119,7 @@
 
     <select id="findDebtMoney" resultType="Decimal">
        select
-            sum( CASE WHEN pprb.debt IS NULL THEN 0 ELSE pprb.debt END ) sumDebt
+            sum( CASE WHEN rece.debt IS NULL THEN 0 ELSE rece.debt END ) sumDebt
         from pay_pay_receivable rece
         where rece.debt > 0  and rece.account_id = #{accountId}
     </select>