Merge branch 'dev' into runny827
feat(training): 新增精益培训视频与周任务管理 # Conflicts: # backend/app/models/__init__.py
This commit is contained in:
1 parent
85d27e9ffa
commit
91b7233872
812 files changed
+73763
-18908
No files matched your search
@@ -19,8 +19,10 @@ INTERNAL_UUID_RE = re.compile(
|
||||
r"^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$",
|
||||
re.IGNORECASE,
|
||||
)
|
||||
# Wistron 等 PO:PR Number = ADU_S-ENCWIW260528126265@1000140351
|
||||
RESERVATION_AT_SUFFIX_RE = re.compile(r"@(\d{10}|\d{5})\b")
|
||||
# Reservation 本体后可带一段半角或全角括号备注;普通尾随文本不属于合法值。
|
||||
RESERVATION_VALUE_RE = re.compile(r"^(\d{10}|\d{5})(?!\d)\s*(?:\([^()\r\n]*\)|([^()\r\n]*))?\s*$")
|
||||
# ``@`` 是预约号与前缀说明的显式分隔,后缀复用 Reservation 值的括号备注契约。
|
||||
RESERVATION_AT_SUFFIX_RE = re.compile(r"@\s*(\d{10}|\d{5})(?!\d)(?=\s*(?:\([^()\r\n]*\)|([^()\r\n]*))?\s*$)")
|
||||
PR_NUMBER_LINE_RE = re.compile(
|
||||
r"PR\s*Number\s*[::]?\s*([^\n\r]+)",
|
||||
re.IGNORECASE,
|
||||
@@ -57,29 +59,36 @@ def normalize_reservation_id(value: Any) -> str:
|
||||
|
||||
|
||||
def extract_reservation_id(value: Any) -> str:
|
||||
"""从原值提取 Reservation ID 候选;合法性必须另由 `is_valid_reservation_id` 判断。"""
|
||||
"""标准化 Reservation ID,并识别 ``@`` 后带可选括号备注的预约号。
|
||||
|
||||
Args:
|
||||
value: Reservation ID 字段原始值;仅允许整体纯数字,或明确 ``@`` 分隔后可带括号备注的纯数字。
|
||||
|
||||
Returns:
|
||||
str: 已确认的五位或十位纯数字 Reservation ID;普通尾随文本或金额文本返回空字符串。
|
||||
"""
|
||||
text = str(value or "").strip()
|
||||
if not text:
|
||||
return ""
|
||||
|
||||
direct = normalize_reservation_id(text)
|
||||
if looks_like_reservation_id(direct):
|
||||
return direct
|
||||
direct_match = RESERVATION_VALUE_RE.fullmatch(direct)
|
||||
if direct_match:
|
||||
return direct_match.group(1)
|
||||
|
||||
match = RESERVATION_AT_SUFFIX_RE.search(text)
|
||||
if match:
|
||||
return match.group(1)
|
||||
|
||||
if "@" in text:
|
||||
tail = normalize_reservation_id(text.rsplit("@", 1)[-1])
|
||||
if looks_like_reservation_id(tail):
|
||||
return tail
|
||||
|
||||
return direct
|
||||
return match.group(1) if match else ""
|
||||
|
||||
|
||||
def find_reservation_id_in_document(text: str) -> str:
|
||||
"""扫描全文 PR Number 行或 @1000140351 后缀,提取文档级 Reservation ID。"""
|
||||
"""扫描全文 PR Number 行或 ``@`` 分隔、可带括号备注的 Reservation ID。
|
||||
|
||||
Args:
|
||||
text: 文档原始文本;仅接受 ``@`` 后可带括号备注的完整五位或十位纯数字。
|
||||
|
||||
Returns:
|
||||
str: 已验证的五位或十位纯数字 Reservation ID;无明确分隔证据时返回空字符串。
|
||||
"""
|
||||
body = str(text or "")
|
||||
if not body.strip():
|
||||
return ""
|
||||
|
||||
Reference in new issue
Block a user