功能:告警级别体系统一为 0紧急/1重要/2普通/3轻微

更新 API 接口、Schema 验证、报告生成、企微通知的级别映射,
与前端和边缘端保持一致。

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-03-18 16:39:16 +08:00
parent 44c5df7302
commit dd86da5bcd
4 changed files with 8 additions and 8 deletions

View File

@@ -23,7 +23,7 @@ ALARM_TYPE_NAMES = {
}
# 告警级别映射
ALARM_LEVEL_NAMES = {1: "提醒", 2: "一般", 3: "严重", 4: "紧急"}
ALARM_LEVEL_NAMES = {0: "紧急", 1: "重要", 2: "普通", 3: "轻微"}
class WeChatService:
@@ -210,7 +210,7 @@ class WeChatService:
access_token = await self._get_access_token()
type_name = ALARM_TYPE_NAMES.get(alarm_type, alarm_type)
level_name = ALARM_LEVEL_NAMES.get(alarm_level, "一般")
level_name = ALARM_LEVEL_NAMES.get(alarm_level, "普通")
msg = {
"touser": "|".join(user_ids),
@@ -221,7 +221,7 @@ class WeChatService:
"task_id": alarm_id,
"source": {
"desc": "AI安防告警",
"desc_color": 3 if alarm_level >= 3 else 0,
"desc_color": 3 if alarm_level <= 1 else 0,
},
"main_title": {
"title": f"{level_name}{type_name}告警",
@@ -595,7 +595,7 @@ class WeChatService:
return False
type_name = ALARM_TYPE_NAMES.get(alarm_type, alarm_type)
level_name = ALARM_LEVEL_NAMES.get(alarm_level, "一般")
level_name = ALARM_LEVEL_NAMES.get(alarm_level, "普通")
success = True
# ---- 1. 发送告警截图image 消息) ----