feat: 历史统计时对照显示官方本月学时
This commit is contained in:
@@ -892,16 +892,22 @@ class HoursWatcher:
|
||||
from admin.settings import hours_source_of
|
||||
|
||||
source = hours_source_of()
|
||||
official = ""
|
||||
if source == "history":
|
||||
current = int(await self.session.month_history_minutes())
|
||||
text = str(current)
|
||||
try:
|
||||
official = await self.session.month_hours_text()
|
||||
except Exception:
|
||||
official = ""
|
||||
else:
|
||||
text = await self.session.month_hours_text()
|
||||
current = _parse_minutes(text)
|
||||
official = text
|
||||
if not text:
|
||||
raise RuntimeError("学时没有解析到")
|
||||
self._misses = 0
|
||||
await asyncio.to_thread(_update_month_hours, self.employee_id, text)
|
||||
await asyncio.to_thread(_update_month_hours, self.employee_id, text, official)
|
||||
target = self.current_target()
|
||||
if target > 0 and current >= target:
|
||||
self.reached = True
|
||||
@@ -2389,12 +2395,14 @@ class AutoStudyWorker:
|
||||
|
||||
# ── 数据库更新 ──
|
||||
|
||||
def _update_month_hours(employee_id: str, hours: str) -> None:
|
||||
def _update_month_hours(employee_id: str, hours: str, official: str = "") -> None:
|
||||
from euniv.db import SessionLocal
|
||||
with SessionLocal() as db:
|
||||
account = db.get(Account, employee_id)
|
||||
if account:
|
||||
stamp_hours(account, hours)
|
||||
if official.strip():
|
||||
account.official_month_hours = official.strip()[:32]
|
||||
db.commit()
|
||||
_set_user_status(employee_id, month_hours=hours)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user