From 7f16849cfa9362d32eaaf323c71350351f13b689 Mon Sep 17 00:00:00 2001
From: huang <1532065656@qq.com>
Date: 星期四, 11 九月 2025 08:51:15 +0800
Subject: [PATCH] 添加看板库位库存接口

---
 JiuMuMesParent/common/servicebase/src/main/java/com/mes/service/ModbusTcp.java |   15 +++++++++++----
 1 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/JiuMuMesParent/common/servicebase/src/main/java/com/mes/service/ModbusTcp.java b/JiuMuMesParent/common/servicebase/src/main/java/com/mes/service/ModbusTcp.java
index 6248f29..9ce74b3 100644
--- a/JiuMuMesParent/common/servicebase/src/main/java/com/mes/service/ModbusTcp.java
+++ b/JiuMuMesParent/common/servicebase/src/main/java/com/mes/service/ModbusTcp.java
@@ -38,12 +38,19 @@
         }
     }
     //杩炴帴
-    public void connect(){
+    public boolean connect() {
         try {
-            this.socket=new Socket(Ip,Port);
+            if (this.socket != null && !this.socket.isClosed()) {
+                this.socket.close();
+            }
+            this.socket = new Socket(Ip, Port);
             this.socket.setSoTimeout(300);
-        }catch (Exception e) {
-            log.info("The IP address of the host cannot be determined:{}",e.getMessage());
+            log.info("PLC杩炴帴鎴愬姛");
+            return true;
+        } catch (Exception e) {
+            log.error("PLC杩炴帴澶辫触", e);
+            this.socket = null;
+            return false;
         }
     }
     //鍏抽棴杩炴帴

--
Gitblit v1.8.0