wangli преди 4 години
родител
ревизия
e9bbc7d7b4

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

@@ -3,6 +3,8 @@ package com.bz.smart_city.controller.pay;
 import com.bz.smart_city.commom.model.AjaxMessage;
 import com.bz.smart_city.commom.model.Pagination;
 import com.bz.smart_city.commom.model.ResultStatus;
+import com.bz.smart_city.commom.util.UserUtil;
+import com.bz.smart_city.dto.LoginUser;
 import com.bz.smart_city.dto.pay.PayDebtMessageDto;
 import com.bz.smart_city.dto.pay.PayDebtPushMessageDto;
 import com.bz.smart_city.dto.pay.PayMessageTemplateDto;
@@ -191,7 +193,8 @@ public class PayMessagesendrecordController {
     @PostMapping("/sendValveCommond")
     @ApiOperation("测试阀门任务")
     public AjaxMessage<String> sendValveCommond(){
-                payMessagesendrecordService.sendValveCommond( 25,33);
+        LoginUser loginUser = UserUtil.getCurrentUser();
+                payMessagesendrecordService.sendValveCommond( loginUser.getSiteId(),loginUser.getCustomerId());
         return new AjaxMessage<>(ResultStatus.OK,"OK");
     }
 

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

@@ -459,6 +459,7 @@ public class PayMessagesendrecordServiceImp implements PayMessagesendrecordServi
         }else{
             //删除定时任务
             this.deleteQrtzTask(payMessageTemplate.getId());
+            payMessageTemplate.setDays(null);
             entity2.setCronExpression(payMessageTemplate.Corn());
         }
         entity2.setJobGroup("自动关阀命令推送");
@@ -466,7 +467,7 @@ public class PayMessagesendrecordServiceImp implements PayMessagesendrecordServi
         entity2.setDescription("valveCommondSendJob"+payMessageTemplate.getId());
         entity2.setJobClassName(ControlByDayJob.class.getName());
         boolean exists = jobAndTriggerService.isExists(entity2);
-        if(!exists) {
+        if(exists) {
             jobAndTriggerService.deleteJob(entity2);
         }
         jobAndTriggerService.save(entity2);

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

@@ -631,9 +631,9 @@
         select
             c.account_id as "accountId"
             ,c.valve_rule_id as "valveRuleIds"
-            ,r.debt
-            ,rh.remaining
-            ,rh.balance
+            ,ifnull(r.debt,0) as "debt"
+            ,ifnull(rh.remaining,0) as "remaining"
+            ,ifnull(rh.balance,0) as "balance"
             ,TIMESTAMPDIFF(day,ifnull(r.create_date,NOW()),NOW()) as "days"
             ,d.id as "meterId"
             ,d.control_status as "valveState"
@@ -654,20 +654,26 @@
         where c.businessstate =1   and  d.control_status = 1  and c.site_id= #{siteId} and c.customer_id = #{customerId}
         <if test="payControlRules != null and payControlRules.size() != 0">
             <foreach collection="payControlRules" item="rule" open="  and ( " separator=" or " close=" )  ">
-                 ( concat(',',c.valve_rule_id,',') like concat('%,',${rule.id},',%')
                 <if test="rule.conditionId != null and rule.conditionId == 1">
-                   and  TIMESTAMPDIFF(day,ifnull(r.create_date,NOW()),NOW()) ${rule.operatorString} #{rule.value}
+                 ( concat(',',c.valve_rule_id,',') like concat('%,',${rule.id},',%')
+                   and  TIMESTAMPDIFF(day,ifnull(r.create_date,NOW()),NOW()) ${rule.operatorString} #{rule.value})
                 </if>
                 <if test="rule.conditionId != null and rule.conditionId == 2">
-                   and  r.debt ${rule.operatorString} #{rule.value}
+                 ( concat(',',c.valve_rule_id,',') like concat('%,',${rule.id},',%')
+                   and  r.debt ${rule.operatorString} #{rule.value})
                 </if>
                 <if test="rule.conditionId != null and rule.conditionId == 3">
-                    and  rh.remaining ${rule.operatorString} #{rule.value}
+                 ( concat(',',c.valve_rule_id,',') like concat('%,',${rule.id},',%')
+                    and  rh.remaining ${rule.operatorString} #{rule.value})
                 </if>
                 <if test="rule.conditionId != null and rule.conditionId == 4">
-                   and   rh.balance ${rule.operatorString} #{rule.value}
+                 ( concat(',',c.valve_rule_id,',') like concat('%,',${rule.id},',%')
+                   and   rh.balance ${rule.operatorString} #{rule.value})
+                </if>
+                <if test="rule.conditionId != null and rule.conditionId == 7">
+                 ( concat(',',c.valve_rule_id,',') like concat('%,',${rule.id},',%')
+                   and   ifnull(rh.remaining,0) -ifnull(r.debt,0) ${rule.operatorString} #{rule.value})
                 </if>
-                )
             </foreach>
         </if>