fix(aiot): 配置推送改用camera_code查询StreamProxy

问题:昨天更新AiRedisConfigServiceImpl使用camera_code后,
忘记同步更新AiConfigServiceImpl,导致推送时仍用旧的app/stream
分割逻辑,无法识别cam_xxx格式的camera_code,推送空配置

修复:
- 使用 streamProxyMapper.selectByCameraCode 替代 selectOneByAppAndStream
- 移除 camera_id 按 "/" 分割的逻辑
- 支持新的 camera_code 格式(cam_xxx)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-02-14 12:13:12 +08:00
parent be35710c01
commit 835c16a365

View File

@@ -219,26 +219,23 @@ public class AiConfigServiceImpl implements IAiConfigService {
payload.put("binds", bindList);
// 构建 cameras 列表(含 rtsp_urlEdge 需要这些信息启动视频流
// 只保留在 wvp_stream_proxy 中存在且有有效 srcUrl 的摄像头
// 使用 camera_code 查询 StreamProxy,获取源 URL
List<Map<String, Object>> cameraList = new ArrayList<>();
Set<String> 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<String, Object> 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<String, Object> 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);