功能:每日告警日报定时推送到企微群聊

- 新增 DailyReportConfig 配置(DAILY_REPORT_ENABLED/HOUR/MINUTE)
- 新增 daily_report_service:asyncio 定时调度,每日生成前一天告警汇总
- 日报内容:告警总数、环比变化、处理状态分布、类型分布、设备 Top5、平均响应时长
- lifespan 中启动/停止定时任务
This commit is contained in:
2026-03-24 17:43:52 +08:00
parent 5972d97ff9
commit 2a36bd4ffc
3 changed files with 228 additions and 0 deletions

View File

@@ -72,11 +72,23 @@ async def lifespan(app: FastAPI):
wo_client = get_work_order_client()
wo_client.init(settings.work_order)
# 启动日报定时任务
report_task = None
if settings.daily_report.enabled and settings.wechat.group_chat_id:
from app.services.daily_report_service import start_daily_report_scheduler
report_task = asyncio.create_task(start_daily_report_scheduler())
logger.info("AI 告警平台启动完成")
yield
# 关闭
if report_task:
report_task.cancel()
try:
await report_task
except asyncio.CancelledError:
pass
logger.info("AI 告警平台已关闭")