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 3c6461273..15b68dc49 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 @@ -219,26 +219,23 @@ public class AiConfigServiceImpl implements IAiConfigService { payload.put("binds", bindList); // 构建 cameras 列表(含 rtsp_url),Edge 需要这些信息启动视频流 - // 只保留在 wvp_stream_proxy 中存在且有有效 srcUrl 的摄像头 + // 使用 camera_code 查询 StreamProxy,获取源 URL List> cameraList = new ArrayList<>(); Set validCameraIds = new LinkedHashSet<>(); for (String cameraId : cameraIds) { - String[] parts = cameraId.split("/", 2); - if (parts.length == 2) { - StreamProxy proxy = streamProxyMapper.selectOneByAppAndStream(parts[0], parts[1]); - if (proxy != null && proxy.getSrcUrl() != null && !proxy.getSrcUrl().isEmpty()) { - Map camOut = new LinkedHashMap<>(); - camOut.put("camera_id", cameraId); - camOut.put("enabled", true); - camOut.put("rtsp_url", proxy.getSrcUrl()); - camOut.put("camera_name", parts[0] + "/" + parts[1]); - cameraList.add(camOut); - validCameraIds.add(cameraId); - } else { - log.warn("[AiConfig] 跳过无效摄像头(无stream_proxy记录): {}", cameraId); - } + // cameraId 现在是 camera_code 格式(从 ROI 表的 camera_id 字段) + StreamProxy proxy = streamProxyMapper.selectByCameraCode(cameraId); + if (proxy != null && proxy.getSrcUrl() != null && !proxy.getSrcUrl().isEmpty()) { + Map camOut = new LinkedHashMap<>(); + camOut.put("camera_id", cameraId); + camOut.put("enabled", true); + camOut.put("rtsp_url", proxy.getSrcUrl()); + camOut.put("camera_name", proxy.getName() != null ? proxy.getName() : cameraId); + cameraList.add(camOut); + validCameraIds.add(cameraId); + log.debug("[AiConfig] 添加摄像头: cameraCode={}, srcUrl={}", cameraId, proxy.getSrcUrl()); } else { - log.warn("[AiConfig] 跳过无效摄像头(camera_id格式错误): {}", cameraId); + log.warn("[AiConfig] 跳过无效摄像头(无stream_proxy记录或无srcUrl): cameraCode={}", cameraId); } } payload.put("cameras", cameraList);