feat(aiot): snap接口改用cameraCode参数查询StreamProxy

- 修改 AiRoiController.getSnap 方法参数从 app/stream 改为 cameraCode
- 注入 IStreamProxyService 服务
- 通过 streamProxyService.getStreamProxyByCameraCode() 查询 StreamProxy
- 从 StreamProxy 对象获取 app 和 stream 字段
- 增加参数校验,未找到对应代理时返回 404
- 更新日志输出包含 cameraCode 信息

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-02-13 11:07:13 +08:00
parent 3792a30616
commit 6d1e1d0bc3

View File

@@ -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<AiRoi> 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());