From 6d1e1d0bc3ea6010c2dbee67f3f15db0ead16653 Mon Sep 17 00:00:00 2001 From: 16337 <1633794139@qq.com> Date: Fri, 13 Feb 2026 11:07:13 +0800 Subject: [PATCH] =?UTF-8?q?feat(aiot):=20snap=E6=8E=A5=E5=8F=A3=E6=94=B9?= =?UTF-8?q?=E7=94=A8cameraCode=E5=8F=82=E6=95=B0=E6=9F=A5=E8=AF=A2StreamPr?= =?UTF-8?q?oxy?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 修改 AiRoiController.getSnap 方法参数从 app/stream 改为 cameraCode - 注入 IStreamProxyService 服务 - 通过 streamProxyService.getStreamProxyByCameraCode() 查询 StreamProxy - 从 StreamProxy 对象获取 app 和 stream 字段 - 增加参数校验,未找到对应代理时返回 404 - 更新日志输出包含 cameraCode 信息 Co-Authored-By: Claude Opus 4.6 --- .../vmp/aiot/controller/AiRoiController.java | 23 ++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/genersoft/iot/vmp/aiot/controller/AiRoiController.java b/src/main/java/com/genersoft/iot/vmp/aiot/controller/AiRoiController.java index 6cb023357..c41a528f2 100644 --- a/src/main/java/com/genersoft/iot/vmp/aiot/controller/AiRoiController.java +++ b/src/main/java/com/genersoft/iot/vmp/aiot/controller/AiRoiController.java @@ -6,6 +6,8 @@ import com.genersoft.iot.vmp.aiot.bean.AiRoiDetail; import com.genersoft.iot.vmp.aiot.service.IAiRoiService; import com.genersoft.iot.vmp.media.bean.MediaServer; import com.genersoft.iot.vmp.media.service.IMediaServerService; +import com.genersoft.iot.vmp.streamProxy.bean.StreamProxy; +import com.genersoft.iot.vmp.streamProxy.service.IStreamProxyService; import com.github.pagehelper.PageInfo; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; @@ -35,6 +37,9 @@ public class AiRoiController { @Autowired private IMediaServerService mediaServerService; + @Autowired + private IStreamProxyService streamProxyService; + @Operation(summary = "分页查询ROI列表") @GetMapping("/list") public PageInfo queryList( @@ -91,8 +96,20 @@ public class AiRoiController { @Operation(summary = "获取摄像头截图") @GetMapping("/snap") public void getSnap(HttpServletResponse resp, - @RequestParam String app, - @RequestParam String stream) { + @RequestParam String cameraCode) { + // 通过 camera_code 查询 StreamProxy + StreamProxy proxy = streamProxyService.getStreamProxyByCameraCode(cameraCode); + + if (proxy == null) { + log.warn("[AI截图] 未找到camera_code对应的StreamProxy: {}", cameraCode); + resp.setStatus(HttpServletResponse.SC_NOT_FOUND); + return; + } + + // 使用 proxy 的 app 和 stream + String app = proxy.getApp(); + String stream = proxy.getStream(); + MediaServer mediaServer = mediaServerService.getDefaultMediaServer(); if (mediaServer == null) { log.warn("[AI截图] 无可用媒体服务器"); @@ -106,7 +123,7 @@ public class AiRoiController { } else { internalUrl = String.format("http://127.0.0.1:%s/%s/%s.live.mp4", mediaServer.getHttpPort(), app, stream); } - log.info("[AI截图] app={}, stream={}, 内部地址={}", app, stream, internalUrl); + log.info("[AI截图] cameraCode={}, app={}, stream={}, 内部地址={}", cameraCode, app, stream, internalUrl); String zlmApi = String.format("http://%s:%s/index/api/getSnap", mediaServer.getIp(), mediaServer.getHttpPort());