fix: 启动时统一 ROI 表 device_id,解决配置推送不到 Edge 的问题
添加 @PostConstruct normalizeDeviceIds(),WVP 启动时自动将所有 ROI 的 device_id 统一为默认边缘设备 ID,确保 writeDeviceAggregatedConfig 能正确查询到关联摄像头,Redis key 和 Stream 事件的 device_id 与 Edge 端 EDGE_DEVICE_ID 一致。 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -32,6 +32,7 @@ import org.springframework.http.MediaType;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpEntity;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import java.util.*;
|
||||
|
||||
@Slf4j
|
||||
@@ -65,6 +66,22 @@ public class AiConfigServiceImpl implements IAiConfigService {
|
||||
|
||||
private final ObjectMapper objectMapper = new ObjectMapper();
|
||||
|
||||
/**
|
||||
* 启动时统一 ROI 表中的 device_id,确保与 Edge 端 EDGE_DEVICE_ID 一致
|
||||
*/
|
||||
@PostConstruct
|
||||
public void normalizeDeviceIds() {
|
||||
try {
|
||||
String defaultDeviceId = getDefaultDeviceId();
|
||||
int updated = roiMapper.updateAllDeviceId(defaultDeviceId);
|
||||
if (updated > 0) {
|
||||
log.info("[AiConfig] 启动时统一 {} 条 ROI 的 device_id → {}", updated, defaultDeviceId);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.warn("[AiConfig] 启动时修复 device_id 失败: {}", e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> exportConfig(String cameraId) {
|
||||
Map<String, Object> config = new LinkedHashMap<>();
|
||||
|
||||
Reference in New Issue
Block a user