This commit is contained in:
Marsway 2026-03-30 17:26:35 +08:00
parent d6c1ad9931
commit 9d620da015
1 changed files with 31 additions and 5 deletions

View File

@ -2,6 +2,7 @@ from __future__ import annotations
import json
import logging
import re
from datetime import date, datetime
from decimal import Decimal, InvalidOperation
from typing import Any
@ -49,9 +50,33 @@ def _date_only(v: Any) -> str:
s = str(v or "").strip()
if not s:
return ""
s = s.replace("T", " ")
if " " in s:
s = s.split(" ", 1)[0]
s2 = s.replace("T", " ")
if re.match(r"^\d{4}-\d{2}-\d{2}$", s2):
return s2
if re.match(r"^\d{4}-\d{2}-\d{2}\s", s2):
return s2.split(" ", 1)[0]
m = re.match(r"^[A-Za-z]{3}\s+([A-Za-z]{3})\s+(\d{1,2})\s+\d{2}:\d{2}:\d{2}\s+[A-Za-z]{3,5}\s+(\d{4})$", s)
if m:
month_map = {
"Jan": "01",
"Feb": "02",
"Mar": "03",
"Apr": "04",
"May": "05",
"Jun": "06",
"Jul": "07",
"Aug": "08",
"Sep": "09",
"Oct": "10",
"Nov": "11",
"Dec": "12",
}
mon = month_map.get(m.group(1).title())
day = int(m.group(2))
year = m.group(3)
if mon:
return f"{year}-{mon}-{day:02d}"
return s
@ -499,7 +524,7 @@ class SyncEhrLeavesToOaMonthJob(BaseJob):
chunk_failed,
str(rj.get("message") or ""),
)
if debug_trace and isinstance(fd, dict) and fd:
if isinstance(fd, dict) and fd:
logger.warning(
"OA batch-update failedData sample: chunk=%s sample=%s",
i // batch_size + 1,
@ -531,7 +556,8 @@ class SyncEhrLeavesToOaMonthJob(BaseJob):
matched_after_write = len(aggregated_keys & verify_key_set)
missing_after_write = sorted(list(aggregated_keys - verify_key_set))[:50]
logger.info(
"OA 写入后复核aggregated_keys=%s matched_after_write=%s missing_after_write=%s",
"OA 写入后复核verify_indexed=%s aggregated_keys=%s matched_after_write=%s missing_after_write=%s",
len(verify_key_set),
len(aggregated_keys),
matched_after_write,
len(aggregated_keys - verify_key_set),