From dd694b8a3d05e2d785413182e1c28b25a5b3f431 Mon Sep 17 00:00:00 2001
From: Administrator <zhubaomin>
Date: 星期三, 20 十二月 2023 17:24:08 +0800
Subject: [PATCH] Merge branch 'master' of http://8.140.179.55:20000/r/pipIrr-SV

---
 pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/src/main/java/com/dy/aceMw/server/tasks/ToRtuConstantTask.java |   80 +++++++++++++++++++++++++++++++--------
 1 files changed, 63 insertions(+), 17 deletions(-)

diff --git a/pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/src/main/java/com/dy/aceMw/server/tasks/ToRtuConstantTask.java b/pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/src/main/java/com/dy/aceMw/server/tasks/ToRtuConstantTask.java
index 291184a..3de49a2 100644
--- a/pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/src/main/java/com/dy/aceMw/server/tasks/ToRtuConstantTask.java
+++ b/pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/src/main/java/com/dy/aceMw/server/tasks/ToRtuConstantTask.java
@@ -7,7 +7,7 @@
 import com.dy.common.mw.core.CoreTask;
 import com.dy.aceMw.server.forTcp.TcpDownCommandCache;
 import com.dy.aceMw.server.forTcp.TcpDownCommandObj;
-import com.dy.aceMw.server.forTcp.TcpSessionCach;
+import com.dy.aceMw.server.forTcp.TcpSessionCache;
 
 /**
  * 澶勭悊RTU涓嬭鍛戒护鏁版嵁鐨勬亽涔呬换鍔�
@@ -19,26 +19,71 @@
 	 * 鍦ㄥ崟绾跨▼鐜涓繍琛�
 	 */
 	@Override
-	public Integer excute() {
+	public Integer execute() {
 		try{
-			Long now = System.currentTimeMillis() ;
-			dealTcpSession(now) ;
-			return dealDownCommand(now) ;
+			dealTcpSession() ;
+		}catch(Exception e){
+			log.error("鏇存柊RTU浼氳瘽涓婃姤鏁版嵁鏃跺埢鏃跺彂鐢熼泦鍚堟搷浣滃紓甯革紝姝ゅ紓甯稿苟涓嶅奖鍝嶇郴缁熸甯歌繍琛�", e);
+		}
+		try{
+			//log.info("褰撳墠涓嬭鍛戒护闃熷垪涓繕鏈夌粨鐐规暟閲忥細" + TcpDownCommandCache.size());
+			dealDownCom() ;
 		}catch(Exception e){
 			log.error(e);
 		}
-		return null ;
+		return TcpDownCommandCache.size()>0?0:1 ;
 	}
 	/**
 	 * 澶勭悊TCP缂撳瓨涓殑鍚勪釜TCP Session鐨勪笂琛屾暟鎹椂鍒�
 	 */
-	private void dealTcpSession(Long now){
-		TcpSessionCach.updateUpDataTime(now) ;
+	private void dealTcpSession(){
+		TcpSessionCache.updateUpDataTime(System.currentTimeMillis() ) ;
 	}
-	
+
+
 	/**
 	 * 澶勭悊涓嬭鍛戒护
 	 */
+	public void dealDownCom() {
+		Node first = TcpDownCommandCache.getFirstQueueNode() ;
+		if(first != null){
+			Node last = TcpDownCommandCache.getLastQueueNode() ;
+			while (last != null){
+				last = this.doDealDownComm(System.currentTimeMillis(), first, last);
+			}
+		}
+	}
+	/**
+	 * 澶勭悊缂撳瓨鐨勪笅琛屽懡浠よ妭鐐�
+	 * @param now 褰撳墠鏃跺埢
+	 * @param first 绗竴涓妭鐐�
+	 * @param last 鏈�鍚庝竴涓妭鐐�
+	 */
+	private Node doDealDownComm(Long now, Node first, Node last){
+		if(last != null){
+			//鍦╠ealNode鏂规硶涓紝鍙兘瑕佹妸last浠庨槦鍒椾腑绉婚櫎锛岃繖鏃秎ast.pre涓虹┖锛屾墍浠ユ彁鍓嶆妸last.pre鍙栧嚭鏉�
+			Node pre = last.pre ;
+			dealNode(now, last) ;
+			if(first != last){
+				return pre ;
+			}else{
+				//鍋滄
+				return null ;
+			}
+		}else{
+			return null ;
+		}
+	}
+
+
+
+	////////////////////////////////////////////////
+	//
+	//浠ヤ笅瀹炵幇锛岄噰鐢ㄤ簡閫掑綊璋冪敤锛屽綋闃熷垪缂撳瓨缁撶偣寰堝鏃讹紝浼氫骇鐢熸爤婧㈠嚭寮傚父
+	//
+	////////////////////////////////////////////////
+	/**
+	 * 澶勭悊涓嬭鍛戒护
 	public Integer dealDownCommand(Long now) {
 		Node first = TcpDownCommandCache.getFirstQueueNode() ;
 		if(first != null){
@@ -49,12 +94,12 @@
 		}
 		return null ;
 	}
+	 */
 	/**
 	 * 澶勭悊缂撳瓨鐨勪笅琛屽懡浠よ妭鐐�
 	 * @param now 褰撳墠鏃跺埢
 	 * @param first 绗竴涓妭鐐�
 	 * @param last 鏈�鍚庝竴涓妭鐐�
-	 */
 	private void doDealDownCommand1(Long now, Node first, Node last){
 		if(first != null){
 			//鍦╠ealNode鏂规硶涓紝鍙兘瑕佹妸first浠庨槦鍒椾腑绉婚櫎锛岃繖鏃秄irst.next涓虹┖锛屾墍浠ユ彁鍓嶆妸first.next鍙栧嚭鏉�
@@ -70,13 +115,12 @@
 			}
 		}
 	}
-
+	 */
 	/**
 	 * 澶勭悊缂撳瓨鐨勪笅琛屽懡浠よ妭鐐�
 	 * @param now 褰撳墠鏃跺埢
 	 * @param first 绗竴涓妭鐐�
 	 * @param last 鏈�鍚庝竴涓妭鐐�
-	 */
 	private void doDealDownCommand(Long now, Node first, Node last){
 		if(last != null){
 			//鍦╠ealNode鏂规硶涓紝鍙兘瑕佹妸last浠庨槦鍒椾腑绉婚櫎锛岃繖鏃秎ast.pre涓虹┖锛屾墍浠ユ彁鍓嶆妸last.pre鍙栧嚭鏉�
@@ -92,17 +136,19 @@
 			}
 		}
 	}
-
+	 */
 	/**
 	 * 澶勭悊涓�涓妭鐐�
 	 * @param now 鐜板湪鏃跺埢
 	 * @param node 鑺傜偣
 	 */
 	private void dealNode(Long now, Node node){
-		TcpDownCommandObj obj = (TcpDownCommandObj)node.obj ;
-		boolean removeNode = obj.dealSelf(now) ;
-		if(removeNode){
-			TcpDownCommandCache.removeNode(node);
+		if(node != null && node.obj != null){
+			TcpDownCommandObj obj = (TcpDownCommandObj)node.obj ;
+			boolean removeNode = obj.dealSelf(now) ;
+			if(removeNode){
+				TcpDownCommandCache.removeNode(node);
+			}
 		}
 	}
 

--
Gitblit v1.8.0