Selaa lähdekoodia

1开阀阀控修改

Xiaojh 4 vuotta sitten
vanhempi
commit
5762e84867

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

@@ -105,7 +105,7 @@ public interface PayBaseCustomerandmeterrelaMapper {
 
     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);
+    void insertValve(@Param("deviceId")BigInteger deviceId,@Param("date")LocalDateTime date,@Param("controlState")int controlState,@Param("controlRuleId")int controlRuleId);
 
     PayBaseCustomerandmeterrela getAccountCustomer(@Param("id") BigInteger id);
 }

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

@@ -23,4 +23,6 @@ public class PayControlValve {
     private LocalDateTime controlTime;//下发时间
     @ApiModelProperty(value = "操作类型")
     private Integer controlState;//操作类型 0关 1开
+    @ApiModelProperty(value = "阀控规则ID")
+    private int controlRuleId;//阀控规则ID
 }

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

@@ -249,8 +249,22 @@ public class AsyncTaskImportService {
                                PayBaseCustomerandmeterrela device = payBaseCustomerandmeterrelaMapper.getDeviceId(loginUser.getSiteId(),loginUser.getCustomerId(),metercode);
                                //根据用水性质名称寻找用水性质id
                                PayBaseCustomerandmeterrela property = payBaseCustomerandmeterrelaMapper.getWaterPropertyId(loginUser.getSiteId(),loginUser.getCustomerId(),propertyName);
+                               List<PayControlRule> contollList = newArrayList();
+                               if(StringUtils.isNotBlank(contollName)){
+                                   //根据阀控规则查找ID
+                                   contollList =payControlRuleMapper.findList(null,contollName,customerId);
+                                   if(contollList != null && contollList.size() > 0){
+                                       if(contollList.get(0).getConditionId() == 5){
+                                           //插入阀控记录
+                                           valve.setDeviceId(device.getId());
+                                           valve.setControlState(1);
+                                           valve.setControlTime(LocalDateTime.now());
+                                           valve.setControlRuleId(contollList.get(0).getId().intValue());
+                                           valveList.add(valve);
+                                       }
+                                   }
+                               }
                                //根据阀控规则名称寻找阀控ID
-                               List<PayControlRule> contollList = payControlRuleMapper.findList(null,contollName,customerId);
                                //根据机构名称寻找机构id
                                Organization office =  null;
                                if(StringUtils.isNotBlank(officeName)){
@@ -396,11 +410,7 @@ public class AsyncTaskImportService {
                                    customerList.add(customer);
                                }
 
-                               //插入阀控记录
-                               valve.setDeviceId(device.getId());
-                               valve.setControlState(1);
-                               valve.setControlTime(LocalDateTime.now());
-                               valveList.add(valve);
+
 
                                //计算可用水量
                                if(property.getWaterPropertyId() != null){

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

@@ -444,6 +444,11 @@ public class PayBaseCustomerandmeterrelaServiceImpl implements PayBaseCustomeran
                 List<PayControlRule> RList = payBaseCustomerandmeterrelaMapper.getRuleNames(loginUser.getSiteId(),loginUser.getCustomerId(),list);
                 if (RList != null && RList.size() >0){
                     for(PayControlRule dao:RList){
+                        if(dao.getConditionId() == 5){
+                            //有开户开阀规则
+                            //往阀控表插入开阀记录
+                            payBaseCustomerandmeterrelaMapper.insertValve(device.getId(),LocalDateTime.now(),1,dao.getId().intValue());
+                        }
                         String name = dao.getName();
                         RName = RName + name +",";
                     }
@@ -489,8 +494,6 @@ 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);
 

+ 13 - 5
smart-city-platform/src/main/resources/mapper/PayBaseCustomerandmeterrelaMapper.xml

@@ -117,14 +117,16 @@
         (
             device_id,
             control_time,
-            control_state
+            control_state,
+            control_rule_id
         )
         values
         <foreach collection="valve" item="valve" index="index" separator=",">
             (
                 #{valve.deviceId,jdbcType=BIGINT},
                 #{valve.controlTime,jdbcType=TIMESTAMP},
-                #{valve.controlState,jdbcType=INTEGER}
+                #{valve.controlState,jdbcType=INTEGER},
+                #{valve.controlRuleId,jdbcType=INTEGER}
             )
         </foreach>
     </insert>
@@ -698,7 +700,11 @@
     </select>
 
     <select id="getRuleNames" resultType="com.bz.smart_city.entity.pay.PayControlRule">
-        select c.name from pay_control_rule c
+        select
+            c.id,
+            c.name,
+            c.condition_id as "conditionId"
+        from pay_control_rule c
         <where>
             <if test="siteId != null">
                 and c.site_id =#{siteId}
@@ -720,13 +726,15 @@
         (
             device_id,
             control_time,
-            control_state
+            control_state,
+            control_rule_id
         )
         values
         (
             #{deviceId},
             #{date},
-            #{controlState}
+            #{controlState},
+            #{controlRuleId}
         )
     </insert>