From 8c4a723ff13e34152934b84c52267615c4e0fb8b Mon Sep 17 00:00:00 2001
From: liurunyu <lry9898@163.com>
Date: 星期五, 06 十二月 2024 10:22:34 +0800
Subject: [PATCH] 升级模拟器增加上报81数据,为上报阀门状态,用81数据代替心跳

---
 pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/server/upgrade/UpgradeTask.java |   33 ++++++++++++++++++++++++++++++++-
 1 files changed, 32 insertions(+), 1 deletions(-)

diff --git a/pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/server/upgrade/UpgradeTask.java b/pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/server/upgrade/UpgradeTask.java
index 81fa856..c5d795e 100644
--- a/pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/server/upgrade/UpgradeTask.java
+++ b/pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/server/upgrade/UpgradeTask.java
@@ -1,12 +1,14 @@
 package com.dy.rtuMw.server.upgrade;
 
 import com.alibaba.fastjson2.annotation.JSONField;
+import com.dy.common.mw.protocol.rtuState.RtuStatus;
 import com.dy.common.softUpgrade.parse.HexFileParse;
 import com.dy.common.softUpgrade.state.UpgradeRtu;
 import com.dy.common.softUpgrade.state.UpgradeState;
 import com.dy.common.softUpgrade.state.UpgradeTaskVo;
 import com.dy.common.util.Callback;
 import com.dy.common.util.DateTime;
+import com.dy.rtuMw.server.forTcp.RtuStatusDealer;
 import lombok.Data;
 import org.apache.logging.log4j.LogManager;
 import org.apache.logging.log4j.Logger;
@@ -32,6 +34,8 @@
     protected Integer failTryTimes ;//鍗囩骇澶辫触鍚庯紝閲嶆柊鍋胯瘯鍗囩骇娆℃暟锛�0琛ㄧず涓嶉噸鏂板伩璇曞崌绾�
     @JSONField(serialize = false)
     protected Integer ugMaxRtuSameTime ;//鍚屾椂鍗囩骇RTU鏈�澶т釜鏁�
+    @JSONField(serialize = false)
+    private Integer lastOpenMaxGoOn ;//闃�寮�锛堟车寮�锛夌姸鎬佽缃互鏉ユ寔缁渶闀挎椂闂达紙绉掗挓锛夛紝瓒呰繃杩欎釜鏃堕棿璁や负鐘舵�佹棤鏁堬紙杩欎釜鏃堕暱鍙栧喅浜庡伐浣滄姤闂撮殧锛�
 
     public String setupDt ;//璁剧疆鏃堕棿(yyyy-mm-dd HH:MM:SS)
     @JSONField(serialize = false)
@@ -60,7 +64,8 @@
     /**
      *  鍒濆鍖栭厤缃俊鎭�
      */
-    public void initOption(Integer failTryTimes, Integer ugMaxRtuSameTime) {
+    public void initOption(Integer lastOpenMaxGoOn, Integer failTryTimes, Integer ugMaxRtuSameTime) {
+        this.lastOpenMaxGoOn = lastOpenMaxGoOn;
         this.failTryTimes = failTryTimes;
         this.ugMaxRtuSameTime = ugMaxRtuSameTime;
     }
@@ -222,6 +227,9 @@
                     }else if(info.state == UpgradeRtu.STATE_FAILOFFLINE) {
                         state.failTotal++;
                         state.failOffTotal++;
+                    }else if(info.state == UpgradeRtu.STATE_FAILOPEN) {
+                        state.failTotal++;
+                        state.failOpenTotal++;
                     }
                     if(info.isOver){
                         state.overTotal++;
@@ -282,6 +290,29 @@
     ///////////////////////////////////////////////////////////
 
     /**
+     * 闃�寮�锛堟车寮�锛変笉鍗囩骇澶勭悊
+     */
+    protected void openNoUpgrade(){
+        if(this.upgradeRtus != null && this.upgradeRtus.size() > 0){
+            Map<String, RtuStatus> rsAllMap = RtuStatusDealer.allStatus() ;
+            Long now = System.currentTimeMillis() ;
+            this.upgradeRtus.values().stream().forEach(a -> {
+                RtuStatus rs = rsAllMap.get(a.rtuAddr) ;
+                if(rs != null
+                        && rs.valveOpenTrueCloseFalse != null && rs.valveOpenTrueCloseFalse.booleanValue() == true
+                        && rs.valveStatusLastTimeStamp != null){
+                    //鏈夌姸鎬侊紝骞朵笖鏄榾寮�锛堟车寮�锛�
+                    Long gap = now - rs.valveStatusLastTimeStamp ;
+                    if(gap < this.lastOpenMaxGoOn){
+                        //杩欐椂閲囩撼闃�闂ㄦ墦寮�鐘舵�佷笉鑳藉崌绾�
+                        a.isOver = true ;
+                        a.state = UpgradeRtu.STATE_FAILOPEN ;
+                    }
+                }
+            });
+        }
+    }
+    /**
      * 鍒ゆ柇鏄惁娌$敤浠讳綍涓�涓猂TU杩涜杩囧崌绾э紝鑰屼笖瓒呰繃浜嗘椂闄�
      * @return -1:鏃犱竴RTU鍗囩骇涓旇秴鏃讹紝0锛氭棤RTU鍗囩骇浣嗘湭瓒呮椂绛夊緟锛�1鏈塕TU鍗囩骇姝e父鎵ц
      */

--
Gitblit v1.8.0