feat(shipping-notice): 添加 MinerU 订单附件表格结构化功能,更新环境配置和数据模型以支持新布局解析和文档模板管理
This commit is contained in:
1 parent
c4095b08da
commit
c35223d49d
148 files changed
+15709
-1353
No files matched your search
@@ -11,10 +11,8 @@ from __future__ import annotations
|
||||
import re
|
||||
from typing import Any
|
||||
|
||||
# 常见 Reservation ID:纯数字,如 1000140351(通常 8~12 位)
|
||||
RESERVATION_ID_NUMERIC_RE = re.compile(r"^\d{8,12}$")
|
||||
# 部分库存源使用带字母/连字符的业务单号,如 AWS-311、ORD-3002、R-1。
|
||||
RESERVATION_ID_BUSINESS_RE = re.compile(r"^[A-Z0-9][A-Z0-9._/-]{1,63}$", re.IGNORECASE)
|
||||
# Reservation ID 业务契约固定为 5 位或 10 位纯数字。
|
||||
RESERVATION_ID_NUMERIC_RE = re.compile(r"^(?:\d{5}|\d{10})$")
|
||||
# 数据库主键、哈希或 UUID 不属于业务 Reservation ID。
|
||||
INTERNAL_HEX_ID_RE = re.compile(r"^[0-9a-f]{32}$", re.IGNORECASE)
|
||||
INTERNAL_UUID_RE = re.compile(
|
||||
@@ -22,7 +20,7 @@ INTERNAL_UUID_RE = re.compile(
|
||||
re.IGNORECASE,
|
||||
)
|
||||
# Wistron 等 PO:PR Number = ADU_S-ENCWIW260528126265@1000140351
|
||||
RESERVATION_AT_SUFFIX_RE = re.compile(r"@(\d{8,12})\b")
|
||||
RESERVATION_AT_SUFFIX_RE = re.compile(r"@(\d{10}|\d{5})\b")
|
||||
PR_NUMBER_LINE_RE = re.compile(
|
||||
r"PR\s*Number\s*[::]?\s*([^\n\r]+)",
|
||||
re.IGNORECASE,
|
||||
@@ -101,7 +99,7 @@ def find_reservation_id_in_document(text: str) -> str:
|
||||
|
||||
|
||||
def looks_like_reservation_id(value: Any) -> bool:
|
||||
"""判断标准化后的值是否符合 8~12 位纯数字 Reservation ID 格式。"""
|
||||
"""判断标准化后的值是否符合 5 位或 10 位纯数字 Reservation ID 格式。"""
|
||||
text = normalize_reservation_id(value)
|
||||
return bool(text and RESERVATION_ID_NUMERIC_RE.fullmatch(text))
|
||||
|
||||
@@ -110,10 +108,10 @@ def is_valid_reservation_id(value: Any, *, numeric_only: bool = False) -> bool:
|
||||
"""
|
||||
判断候选值是否可作为业务 Reservation ID。
|
||||
|
||||
核心逻辑:默认兼容数字型与现有字母型业务单号,但明确拒绝 32 位 hex、UUID、纯字母等内部或弱语义值。
|
||||
核心逻辑:只接受 5 位或 10 位纯数字;字母型编号、其他长度数字、hex 和 UUID 均拒绝。
|
||||
Args:
|
||||
value: 待校验的原始值。
|
||||
numeric_only: 为 True 时仅接受 8~12 位纯数字,用于明确的 External Reservation 模板。
|
||||
numeric_only: 兼容既有调用签名;当前统一契约始终只接受 5 位或 10 位纯数字。
|
||||
|
||||
Returns:
|
||||
bool: 值是否满足当前 Reservation ID 契约。
|
||||
@@ -121,15 +119,7 @@ def is_valid_reservation_id(value: Any, *, numeric_only: bool = False) -> bool:
|
||||
text = extract_reservation_id(value)
|
||||
if not text or INTERNAL_HEX_ID_RE.fullmatch(text) or INTERNAL_UUID_RE.fullmatch(text):
|
||||
return False
|
||||
if RESERVATION_ID_NUMERIC_RE.fullmatch(text):
|
||||
return True
|
||||
if numeric_only:
|
||||
return False
|
||||
return bool(
|
||||
RESERVATION_ID_BUSINESS_RE.fullmatch(text)
|
||||
and re.search(r"[A-Z]", text, re.IGNORECASE)
|
||||
and re.search(r"\d", text)
|
||||
)
|
||||
return bool(RESERVATION_ID_NUMERIC_RE.fullmatch(text))
|
||||
|
||||
|
||||
def validated_reservation_id(value: Any, *, numeric_only: bool = False) -> str:
|
||||
|
||||
Reference in new issue
Block a user