推送频率各个类型的警告各自限制频率

This commit is contained in:
zqc
2026-03-11 10:53:54 +08:00
parent e7ec268b24
commit 2fd67fc656
3 changed files with 31 additions and 7 deletions

View File

@@ -376,7 +376,7 @@ class BaseFrameProcessorWorker(threading.Thread):
def _filter_duplicate_alerts(self, cam_id: int, alerts: list, current_time: float) -> list:
"""
过滤5秒内重复告警
过滤重复告警,支持不同 action 使用不同频率
Args:
cam_id: 摄像头ID
@@ -392,11 +392,16 @@ class BaseFrameProcessorWorker(threading.Thread):
push_actions = []
for alert in alerts:
action = alert['action']
# 获取该 action 的推送间隔
# 优先从配置中查找,没有则使用默认的 ALERT_PUSH_INTERVAL
push_interval = constants.ALERT_PUSH_INTERVALS.get(action, ALERT_PUSH_INTERVAL)
last_push = self.last_alert_push_time[cam_id].get(action, 0)
# 检查是否超过推送间隔
if current_time - last_push >= ALERT_PUSH_INTERVAL:
# 使用各自的推送间隔进行检查
if current_time - last_push >= push_interval:
push_actions.append(action)
# push_actions.append(get_alert_label(action))
# 更新该action的最后推送时间
self.last_alert_push_time[cam_id][action] = current_time