feat(scheduler): 新增多种报表推送功能并重构调度器代码

- 新增考勤汇总、风险进度、工作日报、工作周报等报表推送功能
- 重构调度器中的报表推送逻辑,提取通用的 deliver_report 函数
- 添加新的定时任务配置项用于各种报表推送
- 实现飞书推送配置检查函数 _feishu_delivery_configured
- 将重复的报表推送代码抽取为可复用的函数模式
```
This commit is contained in:
2026-07-13 09:47:29 +08:00
parent f8020cab56
commit 267b01b9f4
12 changed files with 722 additions and 191 deletions

View File

@@ -19,6 +19,7 @@ from app.modules.business.models import (
WorkTask,
)
from app.modules.reports.constants import (
ReportPushType,
ReportResponseKey,
ReportTitle,
)
@@ -65,6 +66,7 @@ class ReportSummaryMixin:
]
return {
ReportResponseKey.TITLE: ReportTitle.DAILY_BRIEF,
ReportResponseKey.REPORT_TYPE: ReportPushType.DAILY_BRIEF,
ReportResponseKey.LINES: lines,
ReportResponseKey.CONTENT: "\n".join(lines),
}
@@ -93,6 +95,28 @@ class ReportSummaryMixin:
lines.append(f" - 超预算:{item.get('code')} {item.get('name')}")
return {
ReportResponseKey.TITLE: ReportTitle.PROJECT_WEEKLY,
ReportResponseKey.REPORT_TYPE: ReportPushType.PROJECT_WEEKLY,
ReportResponseKey.LINES: lines,
ReportResponseKey.CONTENT: "\n".join(lines),
}
def risk_progress(self) -> dict[str, Any]:
"""Build a standalone project risk progress report."""
summary = self.risks.summary()
lines = [
f"- 综合风险等级:{summary[RiskSummaryKey.RISK_LEVEL]}",
f"- 风险分:{summary[RiskSummaryKey.RISK_SCORE]}",
f"- 逾期任务:{len(summary[RiskSummaryKey.OVERDUE_TASKS])}",
f"- 延期项目:{len(summary[RiskSummaryKey.DELAYED_PROJECTS])}",
f"- 超预算项目:{len(summary[RiskSummaryKey.OVER_BUDGET_PROJECTS])}",
f"- 资金风险账户:{len(summary[RiskSummaryKey.FUND_RISKS])}",
f"- 供应商风险:{len(summary[RiskSummaryKey.SUPPLIER_RISKS])}",
f"- 打开风险事件:{len(summary[RiskSummaryKey.OPEN_EVENTS])}",
]
return {
ReportResponseKey.TITLE: ReportTitle.RISK_PROGRESS,
ReportResponseKey.REPORT_TYPE: ReportPushType.RISK_PROGRESS,
ReportResponseKey.LINES: lines,
ReportResponseKey.CONTENT: "\n".join(lines),
}
@@ -122,6 +146,7 @@ class ReportSummaryMixin:
lines.append(f"- {status}{count}")
return {
ReportResponseKey.TITLE: ReportTitle.ATTENDANCE_SUMMARY,
ReportResponseKey.REPORT_TYPE: ReportPushType.ATTENDANCE_SUMMARY,
ReportResponseKey.WORK_DATE: target_date.isoformat(),
ReportResponseKey.TOTAL: total,
ReportResponseKey.ABNORMAL_TOTAL: abnormal_total,