refactor: 移除企微Webhook机器人代码,修复VLM日志

- 删除 wechat_service.send_webhook_alarm 方法
- 删除 config.py 中 webhook_url 配置
- 简化 notify_dispatch 通知逻辑(仅保留应用消息)
- 修复 vlm_service 使用项目统一 logger
- 添加 VLM 调用 URL 调试日志

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-09 15:35:32 +08:00
parent 0fbc1ca7a0
commit 24c94ccfbe
4 changed files with 8 additions and 72 deletions

View File

@@ -97,26 +97,8 @@ async def process_alarm_notification(alarm_data: Dict):
event_time.strftime("%Y-%m-%d %H:%M:%S")
if isinstance(event_time, datetime) else str(event_time or "")
)
detail_url = f"{service_base_url}/static/alarm_detail.html?alarm_id={alarm_id}"
sent = False
# 优先 Webhook无需IP白名单
if settings.wechat.webhook_url:
sent = await wechat_service.send_webhook_alarm(
webhook_url=settings.wechat.webhook_url,
alarm_id=alarm_id,
alarm_type=alarm_type,
area_name=area_name,
camera_name=camera_name,
description=description,
event_time=event_time_str,
alarm_level=alarm_level,
detail_url=detail_url,
)
# Webhook 未配置或失败时,降级到应用消息
if not sent and wechat_service.enabled:
if wechat_service.enabled:
user_ids = [p["wechat_uid"] for p in persons]
sent = await wechat_service.send_alarm_card(
user_ids=user_ids,
@@ -130,11 +112,12 @@ async def process_alarm_notification(alarm_data: Dict):
alarm_level=alarm_level,
service_base_url=service_base_url,
)
if not sent:
logger.warning(f"告警通知未发送: {alarm_id}, webhook和应用消息均未成功")
if sent:
logger.info(f"告警通知完成: {alarm_id}")
else:
logger.warning(f"告警通知发送失败: {alarm_id}")
else:
logger.info(f"告警通知完成: {alarm_id}")
logger.info(f"企微未启用,跳过通知: {alarm_id}")
except Exception as e:
logger.error(f"告警通知处理失败: {alarm_id}, error={e}", exc_info=True)