feat(shipping-notice): 完善订单模板解析与库存 RPA 调度流程

- 新增行字段补充合并与订单模板匹配能力
- 优化运行时解析策略、签名校验及资料验证
- 完善库存 RPA 归档、收尾与 Worker 启动流程
- 补充前后端测试、多语言文案及功能文档
This commit is contained in:
hugo committed 2026-09-09 14:32:43 +08:00
1 parent 8f2f568f92
commit dabf140e41
45 files changed
+2007 -151

No files matched your search

@@ -5,7 +5,7 @@ Reservation ID 专用证据区域解析器。
并投影到验证证据 / 订单归属契约。
依赖:reservation_id 格式校验、coordinate_region_text 视觉行序。
逻辑:reservation_id_region 仅作启用标记;画布预览、盲测、正式解析共用本模块的
锚点扫描与 apply/project,不再按保存矩形截取正式值。
锚点扫描与 apply/project,不再按保存矩形截取正式值;行号含 line# / L# / LN#。
"""
from __future__ import annotations
@@ -19,7 +19,15 @@ from app.services.shipping_notice.reservation_id import validated_reservation_id
_ID_RE = re.compile(r"(?<!\d)(\d{5}|\d{10})(?!\d)")
_LINE_RE = re.compile(r"\b(?:reservation\s+)?line\s*#?\s*(\d+)\b|\bfor\s+line\s*#?\s*(\d+)\b", re.I)
# 行号写法:Line 1 / line#1 / for line#1 / Hyve 缩写 L#1、LN#1。
_LINE_RE = re.compile(
r"(?:"
r"\b(?:reservation\s+)?line\s*#?\s*(\d+)\b"
r"|\bfor\s+line\s*#?\s*(\d+)\b"
r"|\bl(?:n)?\s*#\s*(\d+)\b"
r")",
re.I,
)
_RESERVATION_LABEL_RE = re.compile(r"\breservation\b\s*(?:id)?\s*(?:#|:|-)?", re.I)
_VENDOR_COMMENTS_HEADING_RE = re.compile(r'^\s*vendor\s+comments?\b', re.I)
_TERMS_AND_CONDITIONS_HEADING_RE = re.compile(
@@ -48,7 +56,11 @@ class ReservationRegionApplication:
def extract_reservation_from_region(text: str) -> list[ReservationRegionCandidate]:
"""从区域原文提取候选;有行号归明细,无行号归订单头。"""
"""从区域原文提取候选;有行号归明细,无行号归订单头。
核心逻辑:同行须含 Reservation 标签;行号支持 ``line#1`` / ``for line#1`` /
``L#1`` / ``LN#1`` 等写法,命中后 scope=line,禁止误写入订单头。
"""
candidates: list[ReservationRegionCandidate] = []
for raw_line in (str(text or '').splitlines() or [str(text or '')]):
line = raw_line.strip()
@@ -63,7 +75,8 @@ def extract_reservation_from_region(text: str) -> list[ReservationRegionCandidat
line_match = _LINE_RE.search(line)
line_no = None
if line_match:
line_no = int(line_match.group(1) or line_match.group(2))
captured = next((group for group in line_match.groups() if group is not None), None)
line_no = int(captured) if captured is not None else None
scope = 'line' if line_no is not None else 'header'
status = 'mapped' if line_no is not None else 'header'
for value in dict.fromkeys(ids):