From b7eef391ce3d396887149c7e1ca4aa9e39d6b538 Mon Sep 17 00:00:00 2001
From: ‘liusuyi’ <1951119284@qq.com>
Date: 星期四, 10 八月 2023 10:45:51 +0800
Subject: [PATCH] 优化日志

---
 src/main/java/com/ard/utils/tcp/ClientInitialize.java |   18 +++++++++++-------
 1 files changed, 11 insertions(+), 7 deletions(-)

diff --git a/src/main/java/com/ard/utils/tcp/ClientInitialize.java b/src/main/java/com/ard/utils/tcp/ClientInitialize.java
index 0fa3d9e..15023cf 100644
--- a/src/main/java/com/ard/utils/tcp/ClientInitialize.java
+++ b/src/main/java/com/ard/utils/tcp/ClientInitialize.java
@@ -17,6 +17,9 @@
 import io.netty.channel.socket.nio.NioSocketChannel;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Value;
+import org.springframework.boot.ApplicationArguments;
+import org.springframework.boot.ApplicationRunner;
+import org.springframework.core.annotation.Order;
 import org.springframework.stereotype.Component;
 
 import javax.annotation.PostConstruct;
@@ -34,7 +37,8 @@
  */
 @Component
 @Slf4j(topic = "netty")
-public class ClientInitialize {
+@Order(2)
+public class ClientInitialize implements ApplicationRunner {
 
     @Resource
     IArdEquipRadarService ardEquipRadarService;
@@ -78,7 +82,7 @@
                                 }
                             });
                         }
-                        Thread.sleep(3000);
+                        Thread.sleep(10000);
                     } catch (Exception e) {
                         log.error("Netty鍒濆鍖栭厤缃洃鍚湴鍧�鍑虹幇寮傚父");
                         e.printStackTrace();
@@ -100,14 +104,14 @@
         // 寮傛杩炴帴tcp鏈嶅姟绔�
         bootstrap.remoteAddress(host, port).connect().addListener((ChannelFuture futureListener) -> {
             if (!futureListener.isSuccess()) {
-                log.error(host + ":" + port + "闆疯揪TCP鏈嶅姟绔繛鎺ュけ璐�");
+                log.debug("闆疯揪銆�" + host + ":" + port + "銆戣繛鎺ュけ璐�");
                 futureListener.channel().close();
                 // 杩炴帴澶辫触淇℃伅鎻掑叆Set
                 falseConnectSet.add(ardEquipRadar);
                 // 杩炴帴澶辫触淇℃伅浠巑ap绉婚櫎
                 tureConnectMap.remove(futureListener.channel().id());
             } else {
-                log.info(host + ":" + port + "闆疯揪TCP鏈嶅姟绔繛鎺ユ垚鍔�");
+                log.debug("闆疯揪銆�" + host + ":" + port + "銆戣繛鎺ユ垚鍔�");
                 // 杩炴帴鎴愬姛淇℃伅浠嶴et鎷旈櫎
                 falseConnectSet.remove(ardEquipRadar);
                 // 杩炴帴鎴愬姛淇℃伅鍐欏叆map
@@ -119,8 +123,8 @@
     /**
      * 鍒濆鍖栨柟娉�
      */
-    @PostConstruct
-    public void initialize() {
+    @Override
+    public void run(ApplicationArguments args) throws Exception {
         if (!tcpClientEnable) {
             return;
         }
@@ -129,7 +133,7 @@
         for (ArdEquipRadar ardEquipRadar : ardEquipRadars) {
             String host = ardEquipRadar.getIp();
             Integer port = Integer.valueOf(ardEquipRadar.getPort());
-            log.info("TCP瀹㈡埛绔皾璇曡繛鎺ワ細" + host + ":" + port);
+            log.debug("TCP瀹㈡埛绔皾璇曡繛鎺ワ細" + host + ":" + port);
             connectServer(ardEquipRadar);//杩炴帴姣忎竴涓浄杈炬湇鍔�
         }
     }

--
Gitblit v1.9.3