This commit is contained in:
Marsway 2026-03-30 17:53:15 +08:00
parent 233713db59
commit ce93879fe9
1 changed files with 15 additions and 3 deletions

View File

@ -4,6 +4,7 @@ import json
import logging
import re
import time
from calendar import monthrange
from datetime import date, datetime
from decimal import Decimal, InvalidOperation
from typing import Any
@ -201,6 +202,17 @@ class SyncEhrLeavesToOaMonthJob(BaseJob):
raise ValueError("public_cfg.oa_login_name is required")
oa_template_code = str(params.get("oa_template_code") or oa_form_code).strip()
sync_month = str(params.get("sync_month") or "").strip()
if sync_month:
if not re.match(r"^\d{4}-\d{2}$", sync_month):
raise ValueError("public_cfg.sync_month must be in format YYYY-MM, e.g. 2022-02")
year = int(sync_month[:4])
month = int(sync_month[5:7])
if month < 1 or month > 12:
raise ValueError("public_cfg.sync_month month must be in range 01-12")
month_start = date(year, month, 1)
month_end = date(year, month, monthrange(year, month)[1])
else:
run_date = _to_date(params.get("run_date"))
month_start = run_date.replace(day=1)
month_end = run_date