重构(alarm_event_service): 默认告警等级改用 constants 统一定义

This commit is contained in:
2026-04-07 12:35:59 +08:00
parent 72fc77a0ed
commit 8446bab921

View File

@@ -8,6 +8,7 @@ from typing import Optional, List, Dict, Any, Tuple
from sqlalchemy import func, cast, Date, Integer, extract, text
from app.constants import ALARM_TYPE_DEFAULT_LEVEL
from app.models import AlarmEvent, AlarmEventExt, AlarmLlmAnalysis, get_session
from app.services.oss_storage import get_oss_storage
from app.utils.logger import logger
@@ -36,14 +37,8 @@ def _determine_alarm_level(
2. 时长升级:持续型告警随时长升级(只升不降)
3. 无配置时使用算法默认等级
"""
# 算法默认等级
default_levels = {
"intrusion": 1, # 重要
"leave_post": 2, # 普通
"illegal_parking": 1, # 重要
"vehicle_congestion": 2, # 普通
}
base_level = initial_level if initial_level is not None else default_levels.get(alarm_type, 2)
# 算法默认等级(来自 constants.py 统一定义)
base_level = initial_level if initial_level is not None else ALARM_TYPE_DEFAULT_LEVEL.get(alarm_type, 2)
# 入侵检测:事件型,不升级
if alarm_type == "intrusion":