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 logging
import re import re
import time import time
from calendar import monthrange
from datetime import date, datetime from datetime import date, datetime
from decimal import Decimal, InvalidOperation from decimal import Decimal, InvalidOperation
from typing import Any from typing import Any
@ -201,9 +202,20 @@ class SyncEhrLeavesToOaMonthJob(BaseJob):
raise ValueError("public_cfg.oa_login_name is required") raise ValueError("public_cfg.oa_login_name is required")
oa_template_code = str(params.get("oa_template_code") or oa_form_code).strip() oa_template_code = str(params.get("oa_template_code") or oa_form_code).strip()
run_date = _to_date(params.get("run_date")) sync_month = str(params.get("sync_month") or "").strip()
month_start = run_date.replace(day=1) if sync_month:
month_end = run_date 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
display_job_no = str(params.get("oa_display_job_no") or "工号").strip() display_job_no = str(params.get("oa_display_job_no") or "工号").strip()
display_leave_date = str(params.get("oa_display_leave_date") or "请假日期").strip() display_leave_date = str(params.get("oa_display_leave_date") or "请假日期").strip()