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

- 优化订单文档解析、补充合并与坐标重建
- 完善订单模板校验、发布及前端管理界面
- 改进库存 RPA 下载回退与工作流处理
- 补充后端、前端及 RPA 自动化测试
- 更新 Shipping Notice 技术文档与四语言文案
This commit is contained in:
hugo committed 2026-09-09 09:10:10 +08:00
1 parent c4a27324c8
commit 8f2f568f92
46 files changed
+1745 -265

No files matched your search

+77 -1
View File
@@ -1,7 +1,8 @@
"""验证 EML 正文补充表的确定性解析、关联和数量保护。
依赖:正文补充解析器与合并服务。
逻辑:正文只补 Reservation/来源字段,PDF 数量始终保持权威,歧义稳定进入复核。
逻辑:正文只补 Reservation/来源字段,PDF 数量始终保持权威;关联优先 PO+料号,
其次 PO+预约号,歧义稳定进入复核。
"""
from __future__ import annotations
@@ -345,6 +346,81 @@ def test_email_supplement_cross_adjudicates_pn_and_ampn_against_both_order_part_
assert merged[0]['_hxops_email_supplement_relation'] == 'po_mpn'
def test_email_supplement_po_reservation_injects_hint_when_parts_do_not_match():
"""同 PO 下 PDF 已有预约号、邮件仅 APN 不对料号时,按 reservation 对齐灌入库存源线索。
回归:AWS allocation 表 Component APN 对不上 Wistron MPN 时,不得因缺 po_mpn
把多行 VMI-* 线索整单丢掉。
"""
order = {
'_hxops_intake_id': 1,
'header_fields': [{'field_id': 'po', 'observations': [{'value': '16776707'}]}],
'lines': [
{'fields': [
{'field_id': 'part', 'observations': [{'value': 'D4-A08AR12000002'}]},
{'field_id': 'reservation', 'observations': [{'value': '2000484577'}]},
{'field_id': 'qty', 'observations': [{'value': 30}]},
]},
{'fields': [
{'field_id': 'part', 'observations': [{'value': 'D4-A08AR12000003'}]},
{'field_id': 'reservation', 'observations': [{'value': '2000484578'}]},
{'field_id': 'qty', 'observations': [{'value': 24}]},
]},
],
'conflicts': [],
}
supplement = {
'document_id': 44,
'rows': [
{
'customer_po_number': '16776707',
'part_number': '504-006055-001',
'reservation_id': '2000484577',
'inventory_source_hint': 'VMI-RTM01',
'evidence': {'inventory_source_hint': {'raw_value': 'VMI-RTM01'}},
},
{
'customer_po_number': '16776707',
'part_number': '504-006056-001',
'reservation_id': '2000484578',
'inventory_source_hint': 'VMI-DUB',
'evidence': {'inventory_source_hint': {'raw_value': 'VMI-DUB'}},
},
],
}
merged = merge_email_supplements(
orders=[order], supplements_by_intake={1: supplement}, schema_definition=SCHEMA,
)[0]
# 关键断言:关联码为 po_reservation;两行分别灌入对应线索,数量不被覆盖。
assert merged['_hxops_email_supplement_relation'] == 'po_reservation'
assert _value(merged['lines'][0]['fields'], 'source') == 'VMI-RTM01'
assert _value(merged['lines'][1]['fields'], 'source') == 'VMI-DUB'
assert _value(merged['lines'][0]['fields'], 'qty') == 30
assert _value(merged['lines'][1]['fields'], 'qty') == 24
assert not any(item.get('reason') == 'supplement_relation_ambiguous' for item in merged['conflicts'])
def test_email_supplement_po_mpn_still_preferred_over_po_reservation():
"""料号能精确命中时仍走 po_mpn,不得因两边都有预约号改走 reservation 档。"""
order = _order()
order['lines'][0]['fields'].append({
'field_id': 'reservation', 'observations': [{'value': '2000484577'}],
})
merged = merge_email_supplements(
orders=[order],
supplements_by_intake={1: {'document_id': 44, 'rows': [{
'customer_po_number': '4518738152',
'part_number': 'D4-A08AR12000002',
'reservation_id': '2000484577',
'inventory_source_hint': 'DSB CMH',
'evidence': {},
}]}},
schema_definition=SCHEMA,
)[0]
assert merged['_hxops_email_supplement_relation'] == 'po_mpn'
assert _value(merged['lines'][0]['fields'], 'source') == 'DSB CMH'
def test_email_supplement_po_fallback_writes_unique_reservation_without_part_match():
"""唯一 PO 兜底不得在写入阶段重新要求邮件料号匹配。"""
result = merge_email_supplements(