Explorar o código

修改联锁总表修改系统后状态乱套的问题

sl hai 2 meses
pai
achega
7670c106f0

+ 71 - 13
jeecg-module-interlock/src/main/java/org/jeecg/modules/interlockAvoidCircular/service/impl/InterlockAvoidCircularServiceImpl.java

@@ -94,9 +94,10 @@ public class InterlockAvoidCircularServiceImpl implements InterlockAvoidCircular
 
         InterlockBase base = baseService.getById(interlockBase);
 
-        baseService.updateInterlockBase(interlockBase);
+        //由于没有采集数据该函数会报错,导致数据更新不了,不能更改含义,不然默认正常的状态值没改变会显示相反的状态
+        updateInterlockSummaryStatus(interlockBase, base);//更新该系统下的所有联锁的联锁状态以及回路健康等级
 
-        updateInterlockSummaryStatus(interlockBase);//更新该系统下的所有联锁的联锁状态以及回路健康等级
+        baseService.updateInterlockBase(interlockBase);
 
         if ("1".equals(interlockBase.getInterlockType())){
             try {
@@ -130,13 +131,33 @@ public class InterlockAvoidCircularServiceImpl implements InterlockAvoidCircular
      *
      * @param base
      */
-    public void updateInterlockSummaryStatus(InterlockBase base){
-        // 获取当前日期时间
-        LocalDateTime currentDateTime = LocalDateTime.now();
-        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
-        String formattedDateTime = currentDateTime.format(formatter);
+    public void updateInterlockSummaryStatus(InterlockBase base, InterlockBase interlockBaseOrg){
+
+        //设置默认值,默认状态未改变,看系统状态是否发生变化
+        boolean isChangeControlSystemStatus = false;
+        boolean isChangeBypass = false;
+        boolean isChangeInstrumentStatus = false;
+        boolean isChangeInterlockStatus = false;
 
-        // 1.系统设置的各状态
+        //1.获取原来的含义表,先查看系统状态含义是否发生了变化
+        if(!base.getControlSystemStatusNormal().equals(interlockBaseOrg.getControlSystemStatusNormal())){
+            isChangeControlSystemStatus = true;
+        }
+        if(!base.getBypassYes().equals(interlockBaseOrg.getBypassYes())){
+            isChangeBypass = true;
+        }
+        if(!base.getInstrumentStatusNormal().equals(interlockBaseOrg.getInstrumentStatusNormal())){
+            isChangeInstrumentStatus = true;
+        }
+        if(!base.getInterlockStatusTy().equals(interlockBaseOrg.getInterlockStatusTy())){
+            isChangeInterlockStatus = true;
+        }
+        //如果全部状态都未改变,不需要进行状态变化
+        if((!isChangeControlSystemStatus)&&(!isChangeBypass)&&(!isChangeInstrumentStatus)&&(!isChangeInterlockStatus)){
+            return;
+        }
+
+        // 系统设置的各状态
         // 控制系统状态(输入卡件状态、输出卡件状态、MP状态)
         String controlSystemStatusNormal = base.getControlSystemStatusNormal(); //正常状态: 如正常
         String controlSystemStatusAbnormal = editStatus(base.getControlSystemStatusNormal()); //故障状态:如非正常
@@ -150,8 +171,12 @@ public class InterlockAvoidCircularServiceImpl implements InterlockAvoidCircular
         String interlockStatusTy = base.getInterlockStatusTy(); //正常状态: 如投用
         String interlockStatusWty = editStatus(base.getInterlockStatusTy()); //故障状态:如未投用
 
+        // 获取当前日期时间
+        LocalDateTime currentDateTime = LocalDateTime.now();
+        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
+        String formattedDateTime = currentDateTime.format(formatter);
 
-        //3.先查找该系统下的联锁总表信息
+        //先查找该系统下的联锁总表信息
         //需要更新的联锁总表信息
         List<InterlockSummary> interlockSummaryNewList = new ArrayList<>();
         //需要更新的联锁详细表信息
@@ -165,7 +190,7 @@ public class InterlockAvoidCircularServiceImpl implements InterlockAvoidCircular
         List<InterlockSummary> interlockSummaryList = interlockAvoidCircularMapper.getInterlockSummaryListBySystemId(base.getId());
 
         for(InterlockSummary interlockSummary:interlockSummaryList){
-            //2.设置各状态默认值
+            //设置各状态默认值
             String interlockStatus = interlockStatusTy;;//	先设置为 联锁状态-投用
             String loopHealthLevel = "A";// 回路健康级别
             String controlSystemStatus = controlSystemStatusNormal;// 总体 先设置为 控制系统状态-正常
@@ -175,9 +200,23 @@ public class InterlockAvoidCircularServiceImpl implements InterlockAvoidCircular
             List<InterlockDetail> interlockDetailList = interlockAvoidCircularMapper.getInterlockDetailListBySummaryId(interlockSummary.getId());
 
             for(InterlockDetail interlockDetail:interlockDetailList){
+                //旁路状态更新:如果是直接读取位号,则值不变;如果默认正常或者现场旁路,需要改变旁路状态的值
+                if(isChangeBypass){
+                    if(InterlockAllStatus.IF_BY_PASS_NO.equals(interlockDetail.getIfBypass())){
+                        interlockDetail.setBypass(bypassYes);//如果是默认正常,将旁路状态设为正常状态
+                    }else if(InterlockAllStatus.IF_BY_PASS_spot.equals(interlockDetail.getIfBypass())){
+                        //先判断现在旁路状态是正常还是故障
+                        if(interlockBaseOrg.getBypassYes().equals(interlockDetail.getBypass())){
+                            interlockDetail.setBypass(bypassYes);//原来是正常状态,现在也设置成正常状态对应的值
+                        }else {
+                            interlockDetail.setBypass(bypassNo);//原来是故障状态,现在也设置成故障状态对应的值
+                        }
+                    }
+                }
                 //联锁状态:旁路状态多个的话,任何一个旁路状态是故障状态,则联锁状态是故障状态,如果旁路状态都是正常状态,则联锁状态是正常状态
                 if(interlockDetail.getBypass()!=null && bypassNo.equals(interlockDetail.getBypass())) interlockStatus = interlockStatusWty;
-                //仪表状态
+
+                //仪表状态  有通过原始量判断出来的值,所以不管变不变,都要判断一下当前仪表状态是正常还是故障
                 if(interlockDetail.getInstrumentStatusJuge()!=null){
                     if(InterlockAllStatus.INSTRUMENT_STATUS_JUDGE0.equals(interlockDetail.getInstrumentStatusJuge())){
                         //0直接读取位号
@@ -209,6 +248,14 @@ public class InterlockAvoidCircularServiceImpl implements InterlockAvoidCircular
 
                             IotedgeCollectData iotedgeData = iotedgeCollectDataService.getOneInfo(interlockDetail.getYsmnlDeviceId(),interlockDetail.getYsmnlModuleName(),interlockDetail.getYsmnlTag(),beginDate);
                             BigDecimal beginValue = new BigDecimal(iotedgeData.getValue());
+                            //如果原来的模拟量是0的话
+                            if(beginValue.equals(BigDecimal.ZERO)){
+                                beginValue=BigDecimal.valueOf(0.001);
+                                if(ysmnlValue.equals(BigDecimal.ZERO)){
+                                    ysmnlValue=BigDecimal.valueOf(0.001);
+                                }
+                            }
+                            System.out.println("beginValue:" + beginValue);
                             BigDecimal num = ysmnlValue.subtract(beginValue);
 
                             // (高限-底限) * 阈值  (数据库中的阈值是去掉百分比的直接乘即可)
@@ -225,8 +272,6 @@ public class InterlockAvoidCircularServiceImpl implements InterlockAvoidCircular
                                 interlockDetail.setInstrumentStatus(instrumentStatusAbnormal); // 故障
                             }else interlockDetail.setInstrumentStatus(instrumentStatusNormal); // 正常
                         }
-
-
                     } else if(InterlockAllStatus.INSTRUMENT_STATUS_JUDGE3.equals(interlockDetail.getInstrumentStatusJuge())){
                         //3默认正常
                         interlockDetail.setInstrumentStatus(instrumentStatusNormal);
@@ -234,6 +279,19 @@ public class InterlockAvoidCircularServiceImpl implements InterlockAvoidCircular
 
                     if(interlockDetail.getInstrumentStatus()!=null && interlockDetail.getInstrumentStatus().equals(instrumentStatusAbnormal)) instrumentStatus = instrumentStatusAbnormal;
                 }
+
+                if(isChangeControlSystemStatus){
+                    //MP状态、输入卡件状态、输出卡件状态如果设置的是默认正常,需要更改默认正常的值
+                    if(interlockDetail.getMpStatusTag() == null){
+                        interlockDetail.setMpStatus(controlSystemStatusNormal);
+                    }
+                    if(interlockDetail.getInputStatusTag() == null){
+                        interlockDetail.setInputStatus(controlSystemStatusNormal);
+                    }
+                    if(interlockDetail.getOutputStatusTag() == null){
+                        interlockDetail.setOutputStatus(controlSystemStatusNormal);
+                    }
+                }
                 //控制系统状态 ——  MP状态、输入卡件状态、输出卡件状态任何一个非正常则控制系统状态非正常。
                 if(controlSystemStatusAbnormal.equals(interlockDetail.getMpStatus()) || controlSystemStatusAbnormal.equals(interlockDetail.getInputStatus()) || controlSystemStatusAbnormal.equals(interlockDetail.getOutputStatus())) {
                     interlockDetail.setControlSystemStatus(controlSystemStatusAbnormal); // 非正常

+ 1 - 0
jeecg-module-interlock/src/main/java/org/jeecg/modules/summary/constants/InterlockAllStatus.java

@@ -49,6 +49,7 @@ public class InterlockAllStatus {
     // 是否旁路 0否1是
     public static final String IF_BY_PASS_NO = "0"; // 是否旁路-否
     public static final String IF_BY_PASS_YES = "1"; // 是否旁路-是
+    public static final String IF_BY_PASS_spot = "2"; // 是否旁路-现场旁路
     public static final String IF_BY_PASS_NO_NAME = "否"; // 是否旁路-否
     public static final String IF_BY_PASS_YES_NAME = "是"; // 是否旁路-是