From 7a0381baabd865d8339b02af822f1c4ffe6bf1bc Mon Sep 17 00:00:00 2001
From: lsh <lsh@163.com>
Date: 星期四, 29 五月 2025 16:42:49 +0800
Subject: [PATCH] *

---
 src/main/java/com/zy/core/thread/JarThread.java |   77 ++++++++++++++++++++++++++++++++++++--
 1 files changed, 73 insertions(+), 4 deletions(-)

diff --git a/src/main/java/com/zy/core/thread/JarThread.java b/src/main/java/com/zy/core/thread/JarThread.java
index 51c1832..fd92bdd 100644
--- a/src/main/java/com/zy/core/thread/JarThread.java
+++ b/src/main/java/com/zy/core/thread/JarThread.java
@@ -40,6 +40,8 @@
     private JarSlave slave;
     private JarProtocol jarProtocol;
     private short heartBeatVal = 1;
+    private boolean connectJar = false;
+
 
     public JarThread(JarSlave slave) {
         this.slave = slave;
@@ -48,7 +50,33 @@
     @Override
     @SuppressWarnings("InfiniteLoopStatement")
     public void run() {
-        this.connect();
+
+        connectJar = this.connect();
+        while(!connectJar){
+            try {
+                connectJar = this.connect();
+                Thread.sleep(100);
+            } catch (Exception e){
+
+            }
+        }
+
+        // 鍚姩绾跨▼鑷姩閲嶈繛
+        new Thread(this::jarConnect).start();
+
+        // 鍚姩璇绘暟鎹嚎绋�
+        new Thread(this::readStatusJar).start();
+
+        // 鍚姩浠诲姟涓嬪彂绾跨▼
+        new Thread(this::taskIssued).start();
+
+
+    }
+
+    /**
+     * 浠诲姟涓嬪彂
+     */
+    private void taskIssued() {
         while (true) {
             try {
                 int step = 1;
@@ -59,7 +87,7 @@
                 switch (step) {
                     // 璇绘暟鎹�
                     case 1:
-                        readStatus();
+//                        readStatus();
                         break;
                     // 鍐欐暟鎹� ID+鐩爣绔�
                     case 2:
@@ -70,14 +98,55 @@
                 }
                 // 蹇冭烦
 //                heartbeat();
-                Thread.sleep(500);
+                Thread.sleep(200);
             } catch (Exception e) {
-                e.printStackTrace();
+                log.error("JAR鍐欑嚎绋嬪紓甯�"+e.getMessage());
+
+//                e.printStackTrace();
             }
 
         }
     }
 
+    private void jarConnect() {
+        while (true) {
+            try {
+                Thread.sleep(1000);
+                if(!connectJar){
+                    try {
+                        connectJar = this.connect();
+                        Thread.sleep(100);
+                    } catch (Exception e){
+
+                    }
+                }
+            } catch (Exception e) {
+                log.error("rgv杩炴帴澶辫触锛侊紒锛� ===>> [id:{}] [ip:{}] [port:{}]", slave.getId(), slave.getIp(), slave.getPort());
+                initSte();
+//                e.printStackTrace();
+            }
+        }
+    }
+
+    private void readStatusJar() {
+        while (true) {
+            try {
+                Thread.sleep(50);
+//                System.out.println("璇荤嚎绋�"+ slave.getId());
+
+                readStatus();
+
+            } catch (Exception e) {
+                log.error("RGV鏁版嵁璇诲彇绾跨▼寮傚父锛侊紒锛� ===>> [id:{}] [ip:{}] [port:{}]", slave.getId(), slave.getIp(), slave.getPort());
+
+                initSte();
+//                e.printStackTrace();
+            }
+
+        }
+
+    }
+
     /**
      * 鍒濆鍖栧爢鍨涙満鐘舵��
      */

--
Gitblit v1.9.1