fix(aiot): 迁移脚本增加camera_code格式验证
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -24,18 +24,23 @@ FROM (
|
|||||||
HAVING cnt > 1
|
HAVING cnt > 1
|
||||||
) AS duplicates;
|
) AS duplicates;
|
||||||
|
|
||||||
-- 5. 更新 ROI 表中的 camera_id(从 app/stream 格式改为 camera_code)
|
-- 5. 验证 camera_code 格式(应为 cam_xxxxxxxxxxxx,12位十六进制字符)
|
||||||
|
SELECT '检查格式错误的 camera_code' AS check_name, COUNT(*) AS issue_count
|
||||||
|
FROM wvp_stream_proxy
|
||||||
|
WHERE camera_code NOT REGEXP '^cam_[a-f0-9]{12}$';
|
||||||
|
|
||||||
|
-- 6. 更新 ROI 表中的 camera_id(从 app/stream 格式改为 camera_code)
|
||||||
UPDATE wvp_ai_roi r
|
UPDATE wvp_ai_roi r
|
||||||
INNER JOIN wvp_stream_proxy sp ON r.camera_id = CONCAT(sp.app, '/', sp.stream)
|
INNER JOIN wvp_stream_proxy sp ON r.camera_id = CONCAT(sp.app, '/', sp.stream)
|
||||||
SET r.camera_id = sp.camera_code;
|
SET r.camera_id = sp.camera_code;
|
||||||
|
|
||||||
-- 6. 验证 ROI 更新结果
|
-- 7. 验证 ROI 更新结果
|
||||||
SELECT '检查未匹配的 ROI' AS check_name, COUNT(*) AS issue_count
|
SELECT '检查未匹配的 ROI' AS check_name, COUNT(*) AS issue_count
|
||||||
FROM wvp_ai_roi r
|
FROM wvp_ai_roi r
|
||||||
LEFT JOIN wvp_stream_proxy sp ON r.camera_id = sp.camera_code
|
LEFT JOIN wvp_stream_proxy sp ON r.camera_id = sp.camera_code
|
||||||
WHERE sp.camera_code IS NULL;
|
WHERE sp.camera_code IS NULL;
|
||||||
|
|
||||||
-- 7. 显示迁移后的样本数据
|
-- 8. 显示迁移后的样本数据
|
||||||
SELECT id, camera_code, app, stream, name
|
SELECT id, camera_code, app, stream, name
|
||||||
FROM wvp_stream_proxy
|
FROM wvp_stream_proxy
|
||||||
LIMIT 5;
|
LIMIT 5;
|
||||||
|
|||||||
Reference in New Issue
Block a user