feat(aiot): 截图请求携带 rtsp_url,支持无 ROI 摄像头按需截图

截图 XADD 到 Redis Stream 时,通过 StreamProxyMapper 查询摄像头的
rtsp_url 并附带到请求中,供 Edge 对无 ROI(无常驻流)的摄像头
临时连接 RTSP 抓帧,解决"先截图才能画 ROI"的鸡生蛋问题。

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-02 09:38:51 +08:00
parent 2a8e9c7b82
commit d3c400de64

View File

@@ -3,6 +3,8 @@ package com.genersoft.iot.vmp.aiot.service.impl;
import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONObject;
import com.genersoft.iot.vmp.aiot.service.IAiScreenshotService;
import com.genersoft.iot.vmp.streamProxy.bean.StreamProxy;
import com.genersoft.iot.vmp.streamProxy.dao.StreamProxyMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
@@ -42,6 +44,9 @@ public class AiScreenshotServiceImpl implements IAiScreenshotService {
@Autowired
private StringRedisTemplate stringRedisTemplate;
@Autowired
private StreamProxyMapper streamProxyMapper;
@Value("${ai.screenshot.callback-url:}")
private String callbackUrl;
@@ -83,6 +88,15 @@ public class AiScreenshotServiceImpl implements IAiScreenshotService {
fields.put("callback_url", callbackUrl);
}
// 查询 rtsp_url 放入请求,供 Edge 对无 ROI 摄像头临时连接截图
StreamProxy proxy = streamProxyMapper.selectByCameraCode(cameraCode);
if (proxy != null) {
String rtspUrl = proxy.getSrcUrl();
if (rtspUrl != null && !rtspUrl.isEmpty()) {
fields.put("rtsp_url", rtspUrl);
}
}
try {
MapRecord<String, String, String> record = MapRecord.create(SNAP_REQUEST_STREAM, fields);
RecordId recordId = stringRedisTemplate.opsForStream().add(record);