feat(shipping_notice): 支持客户 ODM 白名单与整单 ODM 选择收敛导出
- 客户主数据新增 odm_ids 白名单字段(含 Alembic 迁移),表单与管理端支持维护 - 导出库存命中行按客户白名单与整单 ODM 裁决收敛,新增 notice_odm_choice_service - 工作台新增 odm-options / odm-choice 接口,投影行级候选并持久化用户选择 - 修复复核工作台跨 Run 切换时接收解析上下文残留 - 同步四语言 i18n、测试用例、funclist 与 shipping-notice 技术文档
This commit is contained in:
1 parent
a032354cb9
commit
d396371020
51 files changed
+2717
-109
No files matched your search
@@ -210,6 +210,17 @@ def project_reservation_onto_validation_evidence(
|
||||
header_field_id=str((reservation_scope.get('header') or {}).get('field_id') or '') or None,
|
||||
line_field_id=str((reservation_scope.get('line') or {}).get('field_id') or '') or None,
|
||||
line_count=len(projected['lines']),
|
||||
line_numbers=resolve_candidate_line_numbers([
|
||||
next(
|
||||
(
|
||||
field.get('normalized_value') or field.get('raw_value')
|
||||
for field in line.get('fields') or []
|
||||
if isinstance(field, dict) and str(field.get('field_code') or '') == 'customer_po_line_no'
|
||||
),
|
||||
None,
|
||||
)
|
||||
for line in projected['lines']
|
||||
]),
|
||||
)
|
||||
header_target = reservation_scope.get('header')
|
||||
if applied.header_value and header_target:
|
||||
@@ -247,20 +258,51 @@ def project_reservation_onto_validation_evidence(
|
||||
return projected
|
||||
|
||||
|
||||
def resolve_candidate_line_numbers(values: list[object]) -> list[int | None] | None:
|
||||
"""把按逻辑行顺序给出的 Customer PO 行号(LN 列)取值整理为候选定位表。
|
||||
|
||||
核心逻辑:Reservation 注释里的 ``L#n`` 引用的是单据上印刷的行号,必须按 LN 值
|
||||
定位逻辑行;LN 非连续(如部分行已拆单)时按位置写入会错配并误报越界。
|
||||
任一行解析出有效行号才返回定位表;完全没有行号取值时返回 None,
|
||||
由调用方保持历史位置序行为以兼容无 LN 字段的旧 Schema。
|
||||
"""
|
||||
numbers: list[int | None] = []
|
||||
has_number = False
|
||||
for value in values:
|
||||
try:
|
||||
number = int(str(value).strip())
|
||||
except (TypeError, ValueError):
|
||||
number = None
|
||||
else:
|
||||
has_number = True
|
||||
numbers.append(number)
|
||||
return numbers if has_number else None
|
||||
|
||||
|
||||
def apply_reservation_region_candidates(
|
||||
*, candidates: list[dict[str, object]], header_field_id: str | None,
|
||||
line_field_id: str | None, line_count: int,
|
||||
line_numbers: list[int | None] | None = None,
|
||||
) -> ReservationRegionApplication:
|
||||
"""按固定契约将专用区域候选归属到订单头和逻辑明细行。
|
||||
|
||||
无行号 Reservation 是整单事实,最多接受一个不同值;带行号的值仅在
|
||||
Schema 启用明细 Reservation 字段时写入对应逻辑行。冲突、越界行号或
|
||||
多个不同整单值必须转人工复核,不能静默猜测。
|
||||
|
||||
``line_numbers`` 为各逻辑行的 Customer PO 行号(LN 列,1 起始);提供时候选
|
||||
``line_no`` 按 LN 值定位逻辑行,被引用行号不存在则记 ``line_out_of_range``。
|
||||
未提供时保持历史位置序写入,仅兼容无 LN 字段的旧 Schema。
|
||||
"""
|
||||
_ = header_field_id
|
||||
header_values: list[str] = []
|
||||
line_values_by_no: dict[int, list[str]] = {}
|
||||
reasons: list[str] = []
|
||||
line_target_by_number: dict[int, int] = {}
|
||||
if line_numbers is not None:
|
||||
for index, number in enumerate(line_numbers):
|
||||
if isinstance(number, int) and number > 0:
|
||||
line_target_by_number.setdefault(number, index + 1)
|
||||
for item in candidates:
|
||||
if not isinstance(item, dict):
|
||||
continue
|
||||
@@ -277,6 +319,8 @@ def apply_reservation_region_candidates(
|
||||
except (TypeError, ValueError):
|
||||
reasons.append('line_out_of_range')
|
||||
continue
|
||||
if line_numbers is not None:
|
||||
line_no = line_target_by_number.get(line_no, 0)
|
||||
if line_no < 1 or line_no > line_count:
|
||||
reasons.append('line_out_of_range')
|
||||
continue
|
||||
|
||||
Reference in new issue
Block a user