fix(aiot): 告警触发时不发送持续时长,等待回岗后再计算

修改算法层告警触发逻辑:
- 移除 duration_minutes 字段(告警触发时不计算持续时长)
- 新增 first_frame_time 字段(记录离开时间)
- 修改消息为固定文本"人员离岗告警"

持续时长改为在人员回岗时由 alarm_resolve 事件计算

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-02-13 09:42:25 +08:00
parent 5b2440c467
commit 690eb66277
2 changed files with 64 additions and 4 deletions

View File

@@ -289,16 +289,14 @@ class LeavePostAlgorithm:
(current_time - self.alert_cooldowns[cooldown_key]).total_seconds() > self.cooldown_sec:
bbox = self._get_latest_bbox(tracks, roi_id)
total_off_duty_sec = (current_time - self._leave_start_time).total_seconds()
elapsed_minutes = int(total_off_duty_sec / 60)
alerts.append({
"track_id": roi_id,
"camera_id": camera_id,
"bbox": bbox,
"duration_minutes": elapsed_minutes,
"alert_type": "leave_post",
"message": f"离岗 {elapsed_minutes} 分钟",
"message": "人员离岗告警",
"first_frame_time": self._leave_start_time.strftime('%Y-%m-%d %H:%M:%S'),
})
self.alert_cooldowns[cooldown_key] = current_time