feat(aiot): 数据库schema更新 - 添加离岗倒计时参数

问题描述:
- 离岗检测算法param_schema缺少leave_countdown_sec参数
- 部分默认值不符合业务需求

修改内容:
1. 初始化-mysql-aiot.sql (Line 76)
   - leave_post算法新增参数:
     "leave_countdown_sec": {"type":"int","default":300,"min":0}
   - 修正默认值:
     confirm_leave_sec: 10 → 30秒
     cooldown_sec: 300 → 600秒

2. 新增迁移脚本:迁移-添加离岗倒计时参数.sql
   - UPDATE wvp_ai_algorithm表的param_schema
   - 适用于已部署的生产环境数据库升级

参数说明:
- confirm_on_duty_sec: 上岗确认期(默认10秒)
- confirm_leave_sec: 离岗确认期(默认30秒)
- leave_countdown_sec: 离岗倒计时(默认300秒=5分钟)
- cooldown_sec: 告警冷却期(默认600秒=10分钟)

业务流程:
人离开 → 30s确认离岗 → 300s倒计时 → 触发告警

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-02-12 15:06:59 +08:00
parent 197f484482
commit 346e0fc5fe
2 changed files with 20 additions and 1 deletions

View File

@@ -73,5 +73,5 @@ CREATE TABLE IF NOT EXISTS wvp_ai_config_log (
-- 初始数据预置算法2个与边缘端保持一致
-- ============================================================
INSERT INTO wvp_ai_algorithm (algo_code, algo_name, target_class, param_schema, description, is_active, create_time, update_time) VALUES
('leave_post', '离岗检测', 'person', '{"confirm_on_duty_sec":{"type":"int","default":10,"min":1},"confirm_leave_sec":{"type":"int","default":10,"min":1},"cooldown_sec":{"type":"int","default":300,"min":0},"working_hours":{"type":"list","default":[]}}', '检测人员是否在岗,支持工作时间段配置', 1, NOW(), NOW()),
('leave_post', '离岗检测', 'person', '{"confirm_on_duty_sec":{"type":"int","default":10,"min":1},"confirm_leave_sec":{"type":"int","default":30,"min":1},"leave_countdown_sec":{"type":"int","default":300,"min":0},"cooldown_sec":{"type":"int","default":600,"min":0},"working_hours":{"type":"list","default":[]}}', '检测人员是否在岗,支持工作时间段配置', 1, NOW(), NOW()),
('intrusion', '周界入侵检测', 'person', '{"cooldown_seconds":{"type":"int","default":120,"min":0},"confirm_seconds":{"type":"int","default":5,"min":1}}', '检测人员进入指定区域', 1, NOW(), NOW());

View File

@@ -0,0 +1,19 @@
-- ============================================================
-- AIoT 离岗检测算法参数更新迁移脚本
-- 功能:添加 leave_countdown_sec离岗倒计时参数
-- 执行时间2026-02-12
-- ============================================================
-- 更新 leave_post 算法的 param_schema
-- 添加 leave_countdown_sec (默认300秒 = 5分钟)
-- 修正 confirm_leave_sec 默认值从10秒改为30秒
-- 修正 cooldown_sec 默认值从300秒改为600秒
UPDATE wvp_ai_algorithm
SET param_schema = '{"confirm_on_duty_sec":{"type":"int","default":10,"min":1},"confirm_leave_sec":{"type":"int","default":30,"min":1},"leave_countdown_sec":{"type":"int","default":300,"min":0},"cooldown_sec":{"type":"int","default":600,"min":0},"working_hours":{"type":"list","default":[]}}',
update_time = NOW()
WHERE algo_code = 'leave_post';
-- 验证更新结果
SELECT algo_code, algo_name, param_schema, update_time
FROM wvp_ai_algorithm
WHERE algo_code = 'leave_post';