From 4aae7ee45980d81e61a1d5912656abba87252f0a Mon Sep 17 00:00:00 2001 From: 16337 <1633794139@qq.com> Date: Sat, 28 Feb 2026 11:31:05 +0800 Subject: [PATCH] =?UTF-8?q?fix(aiot):=20pushAllConfig=E8=A1=A5=E5=85=85Red?= =?UTF-8?q?is=E8=81=9A=E5=90=88=E9=85=8D=E7=BD=AE=E5=86=99=E5=85=A5+?= =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E6=88=AA=E5=9B=BE=E5=9B=9E=E8=B0=83=E5=9C=B0?= =?UTF-8?q?=E5=9D=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit pushAllConfig原来只做HTTP推送,不写Redis,导致Edge在 CONFIG_SYNC_MODE=REDIS模式下无法通过Stream接收全量配置。 现在推送后对每个deviceId调用writeDeviceAggregatedConfig, 写入device:{id}:config并发布device_config_stream事件。 同时修正application-dev.yml中截图回调地址。 Co-Authored-By: Claude Opus 4.6 --- .../aiot/service/impl/AiConfigServiceImpl.java | 18 ++++++++++++++++-- src/main/resources/application-dev.yml | 2 +- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/genersoft/iot/vmp/aiot/service/impl/AiConfigServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/aiot/service/impl/AiConfigServiceImpl.java index 293ef7306..a9112ce48 100644 --- a/src/main/java/com/genersoft/iot/vmp/aiot/service/impl/AiConfigServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/aiot/service/impl/AiConfigServiceImpl.java @@ -163,12 +163,26 @@ public class AiConfigServiceImpl implements IAiConfigService { payload.put("sync_mode", "full"); boolean httpSyncOk = pushPayloadToLocalEdge(payload); + // 写入 Redis 聚合配置 + Stream 事件(供 CONFIG_SYNC_MODE=REDIS 模式的 Edge 使用) + Set deviceIds = new LinkedHashSet<>(); + for (AiRoi roi : rois) { + String deviceId = roi.getDeviceId(); + if (deviceId != null && !deviceId.isEmpty()) { + deviceIds.add(deviceId); + } + } + for (String deviceId : deviceIds) { + redisConfigService.writeDeviceAggregatedConfig(deviceId, "UPDATE"); + } + log.info("[AiConfig] 全量推送 Redis 聚合配置完成, deviceIds={}", deviceIds); + Map result = new LinkedHashMap<>(); result.put("rois", rois.size()); result.put("binds", binds.size()); result.put("http_sync", httpSyncOk); - result.put("message", "已推送全部ROI和算法绑定到Edge"); - log.info("[AiConfig] 全量推送完成 rois={}, binds={}, httpSync={}", rois.size(), binds.size(), httpSyncOk); + result.put("redis_sync_devices", deviceIds.size()); + result.put("message", "已推送全部ROI和算法绑定到Edge(HTTP+Redis双通道)"); + log.info("[AiConfig] 全量推送完成 rois={}, binds={}, httpSync={}, redisDevices={}", rois.size(), binds.size(), httpSyncOk, deviceIds.size()); return result; } diff --git a/src/main/resources/application-dev.yml b/src/main/resources/application-dev.yml index c2e06d1c2..59d170601 100644 --- a/src/main/resources/application-dev.yml +++ b/src/main/resources/application-dev.yml @@ -123,7 +123,7 @@ ai: enabled: true screenshot: # Edge截图回调地址(WVP外部可访问地址,Edge通过此地址回调截图结果) - callback-url: http://124.222.218.198:18080 + callback-url: http://124.221.55.225:18080 mqtt: # MQTT推送开关 enabled: false