feat: 历史统计时对照显示官方本月学时

This commit is contained in:
Nixevol
2026-11-19 02:54:32 +08:00
parent ba787a513b
commit a0ceb51348
12 changed files with 156 additions and 13 deletions
+8
View File
@@ -416,6 +416,7 @@ def _apply_hours_source(client, summary: dict, items: list | None = None) -> dic
data = dict(summary)
source = hours_source_of()
data["hours_source"] = source
data["official_month_hours"] = data.get("month_hours")
if source != "history":
return data
walker = getattr(client, "month_history_minutes", None)
@@ -440,6 +441,7 @@ def _api_hour_fields(client) -> dict:
return {
"year_hours": summary.get("year_hours"),
"month_hours": summary.get("month_hours"),
"official_month_hours": summary.get("official_month_hours") or summary.get("month_hours"),
"today_hours": summary.get("today_hours"),
"total_hours": summary.get("total_hours"),
}
@@ -461,6 +463,11 @@ def _remember_month_hours(db: Session, employee_id: str, payload: dict) -> None:
from euniv.study_control import stamp_hours
stamp_hours(account, text)
official = payload.get("official_month_hours")
if official is not None and not isinstance(official, bool):
official_text = str(official).strip()
if official_text:
account.official_month_hours = official_text[:32]
db.commit()
@@ -497,6 +504,7 @@ def _hour_fields(data: dict) -> dict:
"hours_source": data.get("hours_source") or "api",
"year_hours": data.get("year_hours"),
"month_hours": data.get("month_hours"),
"official_month_hours": data.get("official_month_hours"),
"today_hours": data.get("today_hours"),
"total_hours": data.get("total_hours"),
}