feat: 三项联动 — 计划过期提醒 + 拜访自动关闭 + 批量制定

1. 计划过期自动提醒:
   - scheduler.py 新增 check_overdue_plans()
   - 每日 9:00 检查过期计划(plan_date < today, status=计划中)
   - 按经理汇总 → 企微推送提醒消息

2. 拜访后自动关闭计划:
   - create_visit 后自动将匹配的计划标记为「已完成」
   - 条件: customer_id 匹配 + status=计划中 + plan_date <= visit_date

3. 亮灯表批量制定:
   - 红灯/黄灯卡片右上角 ☐ 复选框
   - 勾选后出现「批量制定计划」按钮
   - 弹窗统一设置日期+内容 → 批量 POST

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2026-06-27 12:28:36 +08:00
parent 0e25201ede
commit b343970ecc
4 changed files with 165 additions and 4 deletions
+8 -1
View File
@@ -7,7 +7,7 @@ from app.database import engine, Base, async_session
from app.api import router as api_router
from app.api import auth, users, customers, visits, work_plans, mini_business, key_visits
from app.api import dashboard, upload, export, import_data, wecom, daily_notes, ai_summary
from app.services.scheduler import check_daily_reporting
from app.services.scheduler import check_daily_reporting, check_overdue_plans
_scheduler = AsyncIOScheduler()
@@ -18,6 +18,12 @@ async def _scheduled_check():
await check_daily_reporting(db)
async def _scheduled_overdue_check():
"""Check for overdue plans and remind managers (9:00 AM)."""
async with async_session() as db:
await check_overdue_plans(db)
@asynccontextmanager
async def lifespan(app: FastAPI):
# Startup: create tables if not exists (for dev convenience)
@@ -51,6 +57,7 @@ async def lifespan(app: FastAPI):
# Start daily reporting scheduler (17:30 CST = 09:30 UTC)
_scheduler.add_job(_scheduled_check, "cron", hour=17, minute=30, id="daily_check")
_scheduler.add_job(_scheduled_overdue_check, "cron", hour=9, minute=0, id="overdue_check")
_scheduler.start()
yield