Parcourir la source

修复阀控问题

oppadmin il y a 4 ans
Parent
commit
4811653efe

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

@@ -39,11 +39,11 @@ public class PayControlRuleController {
                     throw new Exception("阀控规则名称不能为空");
                 if(StringUtils.isBlank(payControlRule.getCondition()))
                     throw new Exception("阀控规则判断条件不能为空");
-                if(StringUtils.isBlank(payControlRule.getOperator()))
+                if(payControlRule.getOperator() == null)
                     throw new Exception("阀控规则运算符不能为空");
                 if(StringUtils.isBlank(payControlRule.getValue()))
                     throw new Exception("阀控规则条件值不能为空");
-                if(StringUtils.isBlank(payControlRule.getAction()))
+                if(payControlRule.getAction() == null)
                     throw new Exception("阀控规则执行操作不能为空");
             }
 

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

@@ -23,23 +23,23 @@ public class PayControlRule {
     @ApiModelProperty(example="欠费天数",notes = "判断条件",position = 10)
     private String condition;
 
-    @ApiModelProperty(example="1",notes = "判断条件ID",position = 10)
+    @ApiModelProperty(example="1",notes = "判断条件ID",position = 11)
     private Integer conditionId;
 
-    @ApiModelProperty(example=">",notes = "运算符",position = 15)
-    private String operator;
+    @ApiModelProperty(example="0",notes = "运算符,[=,≠,>,<,≥,≤]对应1,2,3,4,5,6",position = 15)
+    private Integer operator;
 
     @ApiModelProperty(example="1",notes = "条件值",position = 20)
     private String value;
 
     @ApiModelProperty(example="0",notes = "执行动作,0关阀 1开阀",position = 30)
-    private String action;
+    private Integer action;
 
     @ApiModelProperty(example="元", notes="单位",position = 35)
     private String unit;
 
     @ApiModelProperty(example="0", notes="停用标志 0启用 1停用",position = 40)
-    private String disable;
+    private Integer disable;
 
     @ApiModelProperty(example = "正常",notes = "备注",position = 45)
     private String remarks;

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

@@ -41,5 +41,7 @@ public class PayMeter {
     public BigInteger accountId;
     @ApiModelProperty(example = "1",value = "水表ID")
     public BigInteger deviceId;
+    @ApiModelProperty(example = "1",value = "阀门状态: 0关阀 1开阀  2 无阀,3异常")
+    public int controlStatus;
 
 }

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

@@ -52,7 +52,7 @@ public class PayControlRuleServiceImpl implements PayControlRuleService {
         payControlRule.setUpdateBy(new BigInteger(String.valueOf(loginUser.getId())));
         payControlRule.setUpdateDate(LocalDateTime.now());
         payControlRule.setDelFlag("0");
-        payControlRule.setDisable("0");
+        payControlRule.setDisable(0);
 
         Integer result = payControlRuleMapper.add(payControlRule);
         return  result;
@@ -94,7 +94,7 @@ public class PayControlRuleServiceImpl implements PayControlRuleService {
         if(IsUsed(payControlRule.getId().intValue(),new BigInteger(loginUser.getCustomerId().toString()))){
             throw new ServiceException(-99,"该阀控规则已有客户使用,如编辑会对应用客户有影响,是否继续?");
         }
-
+        payControlRule.setCustomerId(new BigInteger(loginUser.getCustomerId().toString()));
         Integer result = payControlRuleMapper.edit(payControlRule);
         return  result;
     }
@@ -120,7 +120,7 @@ public class PayControlRuleServiceImpl implements PayControlRuleService {
 
         PayControlRule payControlRule = new PayControlRule();
         payControlRule.setId(new BigInteger(id));
-        payControlRule.setDisable(disable);
+        payControlRule.setDisable(Integer.parseInt(disable));
 
         Integer result = payControlRuleMapper.edit(payControlRule);
         return  result;
@@ -134,14 +134,17 @@ public class PayControlRuleServiceImpl implements PayControlRuleService {
      */
     public boolean IsUsed(Integer id,BigInteger custoemrId){
         String result = payControlRuleMapper.isUsed(id,custoemrId);
-        String[] sp = result.split(",");
-        if(sp != null && sp.length > 0){
-            for (int i=0;i<sp.length;i++)
-            {
-                if(sp[i].equals(id.toString()))
-                    return true;
+        if(result != null){
+            String[] sp = result.split(",");
+            if(sp != null && sp.length > 0){
+                for (int i=0;i<sp.length;i++)
+                {
+                    if(sp[i].equals(id.toString()))
+                        return true;
+                }
             }
         }
+
         return false;
     }
 
@@ -469,7 +472,7 @@ public class PayControlRuleServiceImpl implements PayControlRuleService {
         //["=", "≠", ">", "<", "≥", "≤"]
         List<PayControlRule> payControlRules = payControlRuleMapper.findList(id,null,null);
         if(payControlRules.size() ==1){
-            String condition= payControlRules.get(0).getOperator();
+            String condition= payControlRules.get(0).getOperator().toString();
             int conditionValue= Integer.valueOf(condition);
             switch (conditionValue){
                 case 1:{

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

@@ -538,6 +538,7 @@
         select
             scd.water_meter_no as waterMeterNo,
             scd.metercode,
+            scd.control_status,
             pba.address as address,
             scd.new_meter_start as initialData,
             scd.date_create as installDate,

+ 13 - 12
smart-city-platform/src/main/resources/mapper/pay/PayControlRuleMapper.xml

@@ -111,19 +111,20 @@
 
     <update id="edit">
         update pay_control_rule pcr
-        set
-            <if test="payControlRule.name != null and  payControlRule.name != ''"> name = #{payControlRule.name},</if>
+        <set>
+            <if test="payControlRule.name != null and  payControlRule.name != ''"> pcr.name = #{payControlRule.name},</if>
             <if test="payControlRule.condition != null and payControlRule.condition != ''"> pcr.condition = #{payControlRule.condition},</if>
-            <if test="payControlRule.value != null and payControlRule.value != ''"> value = #{payControlRule.value},</if>
-            <if test="payControlRule.operator != null and payControlRule.operator != ''"> operator = #{payControlRule.operator},</if>
-            <if test="payControlRule.action != null and payControlRule.action != ''"> action = #{payControlRule.action},</if>
-            <if test="payControlRule.unit != null"> unit = #{payControlRule.unit},</if>
-            <if test="payControlRule.disable != null"> disable = {payControlRule.disable},</if>
-            <if test="payControlRule.updateBy != null"> update_by = #{payControlRule.updateBy},</if>
-            <if test="payControlRule.updateDate != null"> update_date = #{payControlRule.updateDate},</if>
-            <if test="payControlRule.remarks != null"> remarks = #{payControlRule.remarks},</if>
-            <if test="payControlRule.delFlag != null"> del_flag = #{payControlRule.delFlag}</if>
-
+            <if test="payControlRule.conditionId "> pcr.condition_id = #{payControlRule.conditionId},</if>
+            <if test="payControlRule.value != null and payControlRule.value != ''"> pcr.value = #{payControlRule.value},</if>
+            <if test="payControlRule.operator != null "> pcr.operator = #{payControlRule.operator},</if>
+            <if test="payControlRule.action != null "> pcr.action = #{payControlRule.action},</if>
+            <if test="payControlRule.unit != null"> pcr.unit = #{payControlRule.unit},</if>
+            <if test="payControlRule.disable != null"> pcr.disable = #{payControlRule.disable},</if>
+            <if test="payControlRule.updateBy != null"> pcr.update_by = #{payControlRule.updateBy},</if>
+            <if test="payControlRule.updateDate != null"> pcr.update_date = #{payControlRule.updateDate},</if>
+            <if test="payControlRule.remarks != null and payControlRule.remarks != ''"> pcr.remarks = #{payControlRule.remarks},</if>
+            <if test="payControlRule.delFlag != null"> pcr.del_flag = #{payControlRule.delFlag}</if>
+        </set>
         where id = #{payControlRule.id}
     </update>