feat: 仪表盘+催办在休息日跳过填报检查
- 新增 is_working_day() 工具函数,自动跳过周末 + 可配置法定假日 - 仪表盘填报进度新增 is_rest_day 字段,休息日显示灰「休」印章 - 催办调度改用 is_working_day() 替代原始 weekday 检查 - 系统设置新增「法定节假日」配置卡片,支局长可管理假日日期 Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -7,16 +7,29 @@ from app.models.user import User
|
||||
from app.models.leave import Leave
|
||||
from app.models.work_plan import WorkPlan
|
||||
from app.models.customer import Customer
|
||||
from app.models.system_config import SystemConfig
|
||||
from app.services.wecom import wecom_client
|
||||
from app.utils.timezone import today_cst
|
||||
from app.utils.timezone import today_cst, is_working_day
|
||||
|
||||
|
||||
async def check_daily_reporting(db: AsyncSession) -> dict:
|
||||
"""Check today's reporting progress and send wecom reminders to managers who haven't reported."""
|
||||
today = today_cst()
|
||||
weekday = today.weekday()
|
||||
if weekday >= 5: # Skip weekends
|
||||
return {"status": "weekend", "date": str(today)}
|
||||
|
||||
# Load holiday config
|
||||
holiday_row = await db.get(SystemConfig, "holidays")
|
||||
holidays: set[date] = set()
|
||||
if holiday_row and holiday_row.value:
|
||||
for s in holiday_row.value.split(","):
|
||||
s = s.strip()
|
||||
if s:
|
||||
try:
|
||||
holidays.add(date.fromisoformat(s))
|
||||
except ValueError:
|
||||
pass
|
||||
|
||||
if not is_working_day(today, holidays):
|
||||
return {"status": "rest_day", "date": str(today)}
|
||||
|
||||
# Get all users who need to report
|
||||
result = await db.execute(
|
||||
|
||||
Reference in New Issue
Block a user