From 24681c81c09022f584a57006f2534b5f74723414 Mon Sep 17 00:00:00 2001
From: 云 <2163098428@qq.com>
Date: 星期二, 30 六月 2026 09:27:31 +0800
Subject: [PATCH] 初始化项目
---
yudao-module-iot/yudao-module-iot-gateway/src/main/java/cn/iocoder/yudao/module/iot/gateway/protocol/modbus/tcpserver/manager/IotModbusTcpServerConfigCacheService.java | 24 ++++++++++++++++++++++++
1 files changed, 24 insertions(+), 0 deletions(-)
diff --git a/yudao-module-iot/yudao-module-iot-gateway/src/main/java/cn/iocoder/yudao/module/iot/gateway/protocol/modbus/tcpserver/manager/IotModbusTcpServerConfigCacheService.java b/yudao-module-iot/yudao-module-iot-gateway/src/main/java/cn/iocoder/yudao/module/iot/gateway/protocol/modbus/tcpserver/manager/IotModbusTcpServerConfigCacheService.java
index 19ba6e9..f7df6b5 100644
--- a/yudao-module-iot/yudao-module-iot-gateway/src/main/java/cn/iocoder/yudao/module/iot/gateway/protocol/modbus/tcpserver/manager/IotModbusTcpServerConfigCacheService.java
+++ b/yudao-module-iot/yudao-module-iot-gateway/src/main/java/cn/iocoder/yudao/module/iot/gateway/protocol/modbus/tcpserver/manager/IotModbusTcpServerConfigCacheService.java
@@ -12,10 +12,13 @@
import lombok.extern.slf4j.Slf4j;
import java.util.Collections;
+import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
+
+import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet;
/**
* IoT Modbus TCP Server 閰嶇疆缂撳瓨锛氳璇佹椂鎸夐渶鍔犺浇锛屾柇杩炴椂娓呯悊锛屽畾鏃跺埛鏂板凡杩炴帴璁惧
@@ -97,6 +100,27 @@
}
/**
+ * 娓呯悊鏈疆鍒锋柊鍚庝笉鍐嶆湁鏁堢殑璁惧閰嶇疆
+ *
+ * @param refreshedDeviceIds 鏈疆鍙備笌鍒锋柊鐨勮澶囩紪鍙�
+ * @param currentConfigs 鏈疆杩滅杩斿洖鐨勬湁鏁堥厤缃�
+ * @return 鏈疆宸蹭笉鍐嶆湁鏁堢殑璁惧缂栧彿
+ */
+ public Set<Long> cleanupMissingConfigs(Set<Long> refreshedDeviceIds,
+ List<IotModbusDeviceConfigRespDTO> currentConfigs) {
+ if (CollUtil.isEmpty(refreshedDeviceIds)) {
+ return Collections.emptySet();
+ }
+ Set<Long> currentDeviceIds = convertSet(currentConfigs, IotModbusDeviceConfigRespDTO::getDeviceId);
+ Set<Long> missingDeviceIds = new HashSet<>(refreshedDeviceIds);
+ missingDeviceIds.removeAll(currentDeviceIds);
+ for (Long deviceId : missingDeviceIds) {
+ configCache.remove(deviceId);
+ }
+ return missingDeviceIds;
+ }
+
+ /**
* 鑾峰彇璁惧閰嶇疆
*/
public IotModbusDeviceConfigRespDTO getConfig(Long deviceId) {
--
Gitblit v1.9.3