fix: 添加 pymysql 依赖 + Edge 兼容路由

- requirements.txt 添加 pymysql、cos-python-sdk-v5
- 新增 /api/ai/alert/edge/report 和 /edge/resolve 路由(无认证)
- 使 Edge 设备可直接上报到 FastAPI 服务

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-02 13:18:35 +08:00
parent f81cc81ce6
commit 9cee0a2cac
4 changed files with 81 additions and 7 deletions

View File

@@ -27,7 +27,7 @@ from app.services.ai_analyzer import trigger_async_analysis
from app.services.notification_service import get_notification_service
from app.services.device_service import get_device_service
from app.utils.logger import logger
from app.routers import yudao_alert_router, yudao_auth_router, yudao_aiot_alarm_router, yudao_aiot_edge_router, yudao_aiot_storage_router
from app.routers import yudao_alert_router, yudao_auth_router, yudao_aiot_alarm_router, yudao_aiot_edge_router, yudao_aiot_storage_router, edge_compat_router
from app.yudao_compat import yudao_exception_handler
import json
@@ -83,19 +83,18 @@ app.include_router(yudao_aiot_alarm_router)
app.include_router(yudao_aiot_edge_router)
app.include_router(yudao_aiot_storage_router)
# ==================== Edge 兼容路由 ====================
# Edge 设备使用 /api/ai/alert/edge/* 路径上报(与 WVP 一致),无需认证
app.include_router(edge_compat_router)
# 注册芋道格式异常处理器
app.add_exception_handler(HTTPException, yudao_exception_handler)
# ==================== 静态文件(本地截图) ====================
# ==================== 静态文件 ====================
_uploads_dir = Path("uploads")
_uploads_dir.mkdir(parents=True, exist_ok=True)
app.mount("/uploads", StaticFiles(directory=str(_uploads_dir)), name="uploads")
# Edge 本地截图目录COS 未配置时的回退访问路径)
_edge_captures_dir = Path(r"C:\Users\16337\PycharmProjects\ai_edge\data\captures")
if _edge_captures_dir.exists():
app.mount("/captures", StaticFiles(directory=str(_edge_captures_dir)), name="captures")
def get_alert_svc():
return alert_service