feat(in-transit-transfer): 落地证据流重解析并纳入货代与排程配套改动

外部单号进入异动档自然键,圈档按 T-2 成熟封顶,当前归档可单独重解析。同批带上 Crane 禁整页刷新、ODM 白名单降级、排程抽屉与执行记录日期窗,以及 YAML 库存源下线。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
hugoandCursor committed 2026-10-22 00:48:37 +08:00
1 parent 911afa0f73
commit 4c2a7e2a23
145 files changed
+11695 -4214

No files matched your search

+13 -10
View File
@@ -676,9 +676,9 @@ def _adjudicate_notice_odm(
"""
整单(Notice)级 ODM 收敛裁决;模板不消费 odm 字段时直接跳过。
逻辑:客户 ODM ID 范围非空先过滤;用户选择(OT.chosen_odm_id)次之;
无范围且无选择时,各导出行命中 odm 交集唯一则自动收敛(唯一可行解,无需人工)。
多值并存时不过滤,由逐行折叠按现有契约阻断,并由工作台下发候选供用户选择。
逻辑:各行命中 odm 交集恰一个值(唯一可行解)时直接收敛并跳过客户 odm_ids
白名单(2026-10-20 白名单降级);多值时客户 ODM ID 范围非空先过滤,用户选择
(OT.chosen_odm_id)次之;范围排除全部命中或选择已失效时抛 ValueError。
Returns:
{'inventory_lines': 收敛后的库存行, 'feasible_odm_ids': 排序候选,
@@ -711,8 +711,13 @@ def _adjudicate_notice_odm(
result['chosen_odm_id'] = odm_display.get(chosen_odm, str(chosen_odm_raw).strip()) if chosen_odm else None
normalized_keys = _normalize_match_keys(match_keys)
pre_odm_sets = _per_line_odm_sets(line_values, inventory_lines, normalized_keys, odm_key)
# [STEP] 唯一命中优先(2026-10-20 白名单降级):各行命中的 ODM 交集恰一个值时
# 直接取用,不再套客户 odm_ids 白名单——客户主数据与库存文件的口径漂移不应
# 拦下「Excel 里只有一个 ODM」的确定事实(回归 OT-20261017-184D440D)。
unique_feasible = _intersect_odm_sets(pre_odm_sets)
unique_hit = len(unique_feasible) == 1
if customer_odm_ids:
if customer_odm_ids and not unique_hit:
result['whitelist_applied'] = True
scope = set(customer_odm_ids)
inventory_lines = [row for row in inventory_lines if _match_text(row.get(odm_key)) in scope]
@@ -720,20 +725,18 @@ def _adjudicate_notice_odm(
# 避免回落成误导性的「没有匹配的库存记录」。
if any(pre_odm_sets) and not any(_per_line_odm_sets(line_values, inventory_lines, normalized_keys, odm_key)):
raise ValueError('订单行命中的库存记录 ODM ID 不在客户数据维护的 ODM ID 范围内,请检查客户数据或库存文件')
elif unique_hit:
# 唯一命中即唯一可行解:绕过白名单直接收敛,多值时白名单才参与收敛。
inventory_lines = [row for row in inventory_lines if _match_text(row.get(odm_key)) in unique_feasible]
# 逐行候选取「客户范围过滤后、选择收敛前」的集合:用户在任何一行改选,候选都来自同一口径。
scoped_sets = (
_per_line_odm_sets(line_values, inventory_lines, normalized_keys, odm_key)
if customer_odm_ids else pre_odm_sets
if (customer_odm_ids and not unique_hit) else pre_odm_sets
)
if chosen_odm:
inventory_lines = [row for row in inventory_lines if _match_text(row.get(odm_key)) == chosen_odm]
if any(pre_odm_sets) and not any(_per_line_odm_sets(line_values, inventory_lines, normalized_keys, odm_key)):
raise ValueError('发货通知已选择的 ODM ID 在当前库存中不存在,请重新选择')
elif not customer_odm_ids:
# 无范围、无选择:交集唯一即唯一可行解,自动收敛;多值留给折叠阻断 + 人工选择。
feasible = _intersect_odm_sets(pre_odm_sets)
if len(feasible) == 1:
inventory_lines = [row for row in inventory_lines if _match_text(row.get(odm_key)) in feasible]
result['inventory_lines'] = inventory_lines
result['per_line_odm_ids'] = [
sorted(odm_display.get(value, value) for value in line_set)