From d65c665b483f9c7b57358d4ad2c4bf3c6e1f9608 Mon Sep 17 00:00:00 2001
From: 云 <2163098428@qq.com>
Date: 星期五, 07 八月 2026 17:28:11 +0800
Subject: [PATCH] chore(author): 将作者信息从芋道源码更新为超级管理员

---
 yudao-module-iot/yudao-module-iot-gateway/src/main/java/cn/iocoder/yudao/module/iot/gateway/protocol/modbus/tcpserver/IotModbusTcpServerProtocol.java |   20 +++++++++++++++++++-
 1 files changed, 19 insertions(+), 1 deletions(-)

diff --git a/yudao-module-iot/yudao-module-iot-gateway/src/main/java/cn/iocoder/yudao/module/iot/gateway/protocol/modbus/tcpserver/IotModbusTcpServerProtocol.java b/yudao-module-iot/yudao-module-iot-gateway/src/main/java/cn/iocoder/yudao/module/iot/gateway/protocol/modbus/tcpserver/IotModbusTcpServerProtocol.java
index 80ce9ee..24b1929 100644
--- a/yudao-module-iot/yudao-module-iot-gateway/src/main/java/cn/iocoder/yudao/module/iot/gateway/protocol/modbus/tcpserver/IotModbusTcpServerProtocol.java
+++ b/yudao-module-iot/yudao-module-iot-gateway/src/main/java/cn/iocoder/yudao/module/iot/gateway/protocol/modbus/tcpserver/IotModbusTcpServerProtocol.java
@@ -43,7 +43,7 @@
  * 1. 璁惧閫氳繃鑷畾涔夊姛鑳界爜锛團C 65锛夊彂閫佽璇佽姹�
  * 2. 璁よ瘉鎴愬姛鍚庯紝缃戝叧涓诲姩鍙戦�� Modbus 璇昏姹傦紝璁惧鍝嶅簲锛堜簯绔疆璇㈡ā寮忥級
  *
- * @author 鑺嬮亾婧愮爜
+ * @author 瓒呯骇绠$悊鍛�
  */
 @Slf4j
 public class IotModbusTcpServerProtocol implements IotProtocol {
@@ -326,9 +326,27 @@
                     log.error("[refreshConfig][澶勭悊璁惧閰嶇疆澶辫触, deviceId={}]", config.getDeviceId(), e);
                 }
             }
+
+            // 3. 娓呯悊鏈疆涓嶅啀杩斿洖閰嶇疆鐨勫凡杩炴帴璁惧锛岄伩鍏嶇户缁疆璇㈠凡鍒犻櫎璁惧鐨勬棫鐐逛綅
+            Set<Long> missingDeviceIds = configCacheService.cleanupMissingConfigs(connectedDeviceIds, configs);
+            for (Long deviceId : missingDeviceIds) {
+                cleanupMissingDevice(deviceId);
+            }
         } catch (Exception e) {
             log.error("[refreshConfig][鍒锋柊閰嶇疆澶辫触]", e);
         }
     }
 
+    private void cleanupMissingDevice(Long deviceId) {
+        try {
+            pollScheduler.stopPolling(deviceId);
+            pendingRequestManager.removeDevice(deviceId);
+            configCacheService.removeConfig(deviceId);
+            connectionManager.closeConnection(deviceId);
+            log.info("[cleanupMissingDevice][璁惧 {} 閰嶇疆宸插け鏁堬紝宸插仠姝㈣疆璇㈠苟娓呯悊杩炴帴]", deviceId);
+        } catch (Exception e) {
+            log.error("[cleanupMissingDevice][娓呯悊璁惧澶辫触, deviceId={}]", deviceId, e);
+        }
+    }
+
 }

--
Gitblit v1.9.3