功能:摄像头绑定边缘设备,截图请求按 device_id 隔离

- wvp_stream_proxy 新增 edge_device_id 字段
- StreamProxy 实体 + Mapper INSERT/UPDATE 支持
- 截图请求 XADD 时带上 device_id,边缘端按此过滤
- 存量数据默认绑定到 edge
This commit is contained in:
2026-03-22 00:49:58 +08:00
parent 937eb07b37
commit 0eb2053c6f
4 changed files with 23 additions and 3 deletions

View File

@@ -131,6 +131,11 @@ public class AiScreenshotServiceImpl implements IAiScreenshotService {
if (rtspUrl != null && !rtspUrl.isEmpty()) {
fields.put("rtsp_url", rtspUrl);
}
// 多 Edge 设备隔离:带上绑定的 edge_device_id
String edgeDeviceId = proxy.getEdgeDeviceId();
if (edgeDeviceId != null && !edgeDeviceId.isEmpty()) {
fields.put("device_id", edgeDeviceId);
}
}
try {

View File

@@ -78,6 +78,9 @@ public class StreamProxy extends CommonGBChannel {
@Schema(description = "所属区域ID")
private Long areaId;
@Schema(description = "绑定的边缘设备ID如 edge、edge_002")
private String edgeDeviceId;
public CommonGBChannel buildCommonGBChannel() {
if (ObjectUtils.isEmpty(this.getGbDeviceId())) {
return null;

View File

@@ -13,10 +13,10 @@ public interface StreamProxyMapper {
@Insert("INSERT INTO wvp_stream_proxy (type, app, stream,relates_media_server_id, src_url, " +
"timeout, ffmpeg_cmd_key, rtsp_type, enable_audio, enable_mp4, enable, pulling, " +
"enable_disable_none_reader, server_id, create_time, camera_code, camera_name, area_id) VALUES" +
"enable_disable_none_reader, server_id, create_time, camera_code, camera_name, area_id, edge_device_id) VALUES" +
"(#{type}, #{app}, #{stream}, #{relatesMediaServerId}, #{srcUrl}, " +
"#{timeout}, #{ffmpegCmdKey}, #{rtspType}, #{enableAudio}, #{enableMp4}, #{enable}, #{pulling}, " +
"#{enableDisableNoneReader}, #{serverId}, #{createTime}, #{cameraCode}, #{cameraName}, #{areaId} )")
"#{enableDisableNoneReader}, #{serverId}, #{createTime}, #{cameraCode}, #{cameraName}, #{areaId}, #{edgeDeviceId} )")
@Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id")
int add(StreamProxy streamProxyDto);
@@ -35,7 +35,8 @@ public interface StreamProxyMapper {
"enable_disable_none_reader=#{enableDisableNoneReader}, " +
"enable_mp4=#{enableMp4}, " +
"camera_name=#{cameraName}, " +
"area_id=#{areaId} " +
"area_id=#{areaId}, " +
"edge_device_id=#{edgeDeviceId} " +
"WHERE id=#{id}")
int update(StreamProxy streamProxyDto);

View File

@@ -0,0 +1,11 @@
-- 摄像头绑定边缘设备迁移脚本
-- 新增 edge_device_id 字段,标识摄像头属于哪个边缘端
-- Step 1: 添加 edge_device_id 列
ALTER TABLE wvp_stream_proxy ADD COLUMN edge_device_id VARCHAR(64) NULL AFTER area_id;
-- Step 2: 存量数据默认绑定到 edge第一台边缘设备
UPDATE wvp_stream_proxy SET edge_device_id = 'edge' WHERE edge_device_id IS NULL;
-- 验证
SELECT camera_code, camera_name, edge_device_id FROM wvp_stream_proxy;