From be6d1c74de730976683a697c0532d629423ae463 Mon Sep 17 00:00:00 2001 From: 16337 <1633794139@qq.com> Date: Sat, 28 Feb 2026 17:05:51 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=90=AF=E5=8A=A8=E6=97=B6=E7=BB=9F?= =?UTF-8?q?=E4=B8=80=20ROI=20=E8=A1=A8=20device=5Fid=EF=BC=8C=E8=A7=A3?= =?UTF-8?q?=E5=86=B3=E9=85=8D=E7=BD=AE=E6=8E=A8=E9=80=81=E4=B8=8D=E5=88=B0?= =?UTF-8?q?=20Edge=20=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 添加 @PostConstruct normalizeDeviceIds(),WVP 启动时自动将所有 ROI 的 device_id 统一为默认边缘设备 ID,确保 writeDeviceAggregatedConfig 能正确查询到关联摄像头,Redis key 和 Stream 事件的 device_id 与 Edge 端 EDGE_DEVICE_ID 一致。 Co-Authored-By: Claude Opus 4.6 --- .../aiot/service/impl/AiConfigServiceImpl.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) 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 9dd588dd1..a0ba4979b 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 @@ -32,6 +32,7 @@ import org.springframework.http.MediaType; import org.springframework.http.HttpHeaders; import org.springframework.http.HttpEntity; +import javax.annotation.PostConstruct; import java.util.*; @Slf4j @@ -65,6 +66,22 @@ public class AiConfigServiceImpl implements IAiConfigService { private final ObjectMapper objectMapper = new ObjectMapper(); + /** + * 启动时统一 ROI 表中的 device_id,确保与 Edge 端 EDGE_DEVICE_ID 一致 + */ + @PostConstruct + public void normalizeDeviceIds() { + try { + String defaultDeviceId = getDefaultDeviceId(); + int updated = roiMapper.updateAllDeviceId(defaultDeviceId); + if (updated > 0) { + log.info("[AiConfig] 启动时统一 {} 条 ROI 的 device_id → {}", updated, defaultDeviceId); + } + } catch (Exception e) { + log.warn("[AiConfig] 启动时修复 device_id 失败: {}", e.getMessage()); + } + } + @Override public Map exportConfig(String cameraId) { Map config = new LinkedHashMap<>();