feat: 集成 apisbo.com 中国节假日 API 自动获取+缓存
- 新增 holidays.py 服务:按年获取节假日数据,缓存到 system_config - 区分 holiday(工作日假日)和 workday(调休上班日)两种类型 - is_working_day() 支持调休判断:周末在 workdays 集合中视为工作日 - 启动时自动从 API 刷新当年+明年数据,失败则使用缓存 - 系统设置新增「从 API 刷新」按钮,支局长可手动触发 - 支持 2010-2026 年数据,API 免费免鉴权 Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -8,6 +8,7 @@ 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, system_config, leaves
|
||||
from app.models.system_config import SystemConfig
|
||||
from app.services.holidays import refresh_holidays
|
||||
from app.services.scheduler_manager import start_scheduler, shutdown_scheduler
|
||||
|
||||
|
||||
@@ -84,6 +85,11 @@ async def lifespan(app: FastAPI):
|
||||
notification_hour, notification_minute = int(parts[0]), int(parts[1])
|
||||
except (ValueError, IndexError):
|
||||
pass
|
||||
# Auto-refresh Chinese holiday data from API on startup
|
||||
try:
|
||||
await refresh_holidays(db)
|
||||
except Exception:
|
||||
pass # Use cached data if API unavailable
|
||||
|
||||
# Start daily reporting scheduler
|
||||
start_scheduler(notification_hour, notification_minute)
|
||||
|
||||
Reference in New Issue
Block a user