feat(shipping-notice,receipt-report): 新增收料报表功能并优化发货通知流程
清理废弃的shipping xfa ocr automark相关代码和job配置 新增收料报表管理的前端页面、路由和侧边栏入口 新增后端收料报表配置接口、数据库模型和RPA脚本 优化发货通知流程的重试策略,将shipping相关job默认不自动重试 移除废弃的库存源确认相关逻辑,更新流程门禁规则 重构订单模板的值适配器模块,新增坐标OCR值适配器 清理前端shipping菜单和action的废弃选项 更新相关文档和测试用例,调整.gitignore忽略规则
This commit is contained in:
1 parent
260465b72d
commit
1b6483a4ea
466 files changed
+32115
-33796
No files matched your search
@@ -16,13 +16,17 @@ from app.services.shipping_notice.order_supplement_merge import merge_email_supp
|
||||
SCHEMA = {'fields': [
|
||||
{'field_id': 'po', 'field_code': 'customer_po_number', 'scope': 'header', 'aliases': ['PO#', 'PO Number']},
|
||||
{'field_id': 'part', 'field_code': 'part_number', 'scope': 'line', 'aliases': ['MPN', 'Part Number']},
|
||||
{'field_id': 'customer-part', 'field_code': 'customer_part_number', 'scope': 'line', 'aliases': ['AMPN']},
|
||||
{'field_id': 'qty', 'field_code': 'qty'},
|
||||
{
|
||||
'field_id': 'reservation', 'field_code': 'reservation_id', 'scope': 'line',
|
||||
'aliases': ['Reservation ID', 'External reservation ID'],
|
||||
'aliases': ['Reservation ID', 'External reservation ID', 'Reservation Number'],
|
||||
},
|
||||
{'field_id': 'allocation', 'field_code': 'allocation_id'},
|
||||
{'field_id': 'source', 'field_code': 'inventory_source_hint', 'scope': 'line', 'aliases': ['Source Type']},
|
||||
{'field_id': 'source-party', 'field_code': 'source_from_party', 'scope': 'line', 'aliases': ['source_from_party']},
|
||||
{'field_id': 'allocated-entity', 'field_code': 'allocated_entity', 'scope': 'line', 'aliases': ['allocated_entity']},
|
||||
{'field_id': 'allocated-qty', 'field_code': 'allocated_qty', 'scope': 'line', 'aliases': ['allocated_qty']},
|
||||
]}
|
||||
|
||||
|
||||
@@ -83,6 +87,125 @@ def test_email_supplement_external_reservation_id_alias_merges_real_mail_header(
|
||||
assert merged[0]['_hxops_email_supplement_relation'] == 'po_mpn'
|
||||
|
||||
|
||||
def test_email_supplement_ampn_alias_matches_customer_part_number():
|
||||
"""邮件 AMPN 应能与订单客户料号交叉关联并补入预约号。"""
|
||||
order = _order()
|
||||
order['lines'][0]['fields'][0]['observations'][0]['value'] = 'D4-A08AR12000002'
|
||||
order['lines'][0]['fields'].append({
|
||||
'field_id': 'customer-part', 'observations': [{'value': 'AMTEMP-S000218922'}],
|
||||
})
|
||||
supplement = parse_email_allocation_tables(
|
||||
content_hash='f' * 64,
|
||||
html_tables=['''<table><tr><th>PO#</th><th>AMPN</th><th>Reservation Number</th></tr><tr><td>4518738152</td><td>AMTEMP-S000218922</td><td>33874</td></tr></table>'''],
|
||||
schema_definition=SCHEMA,
|
||||
)
|
||||
merged = merge_email_supplements(
|
||||
orders=[order], supplements_by_intake={1: {**supplement, 'document_id': 44}}, schema_definition=SCHEMA,
|
||||
)
|
||||
assert _value(merged[0]['lines'][0]['fields'], 'reservation') == '33874'
|
||||
|
||||
|
||||
def test_email_supplement_schema_field_fills_missing_part_number_from_pdf_customer_part_match():
|
||||
"""PDF 缺内部料号时,EML 的 Schema 内部料号应由 PO+客户料号唯一补齐。"""
|
||||
order = _order()
|
||||
order['lines'][0]['fields'] = [
|
||||
{'field_id': 'customer-part', 'observations': [{'value': 'AMTEMP-S000218922'}]},
|
||||
{'field_id': 'qty', 'observations': [{'value': 1}]},
|
||||
]
|
||||
supplement = parse_email_allocation_tables(
|
||||
content_hash='g' * 64,
|
||||
html_tables=['''<table><tr><th>PO#</th><th>MPN</th><th>AMPN</th><th>Reservation Number</th></tr><tr><td>4518738152</td><td>D4-A08AR12000001</td><td>AMTEMP-S000218922</td><td>33874</td></tr></table>'''],
|
||||
schema_definition=SCHEMA,
|
||||
)
|
||||
merged = merge_email_supplements(
|
||||
orders=[order], supplements_by_intake={1: {**supplement, 'document_id': 44}}, schema_definition=SCHEMA,
|
||||
)
|
||||
fields = merged[0]['lines'][0]['fields']
|
||||
assert _value(fields, 'part') == 'D4-A08AR12000001'
|
||||
assert _value(fields, 'reservation') == '33874'
|
||||
|
||||
|
||||
def test_email_supplement_conflicting_schema_field_does_not_overwrite_pdf_or_pick_a_value():
|
||||
"""同一已关联行的 EML 字段多值必须逐字段转复核,禁止顺序覆盖。"""
|
||||
order = _order()
|
||||
supplement = {
|
||||
'document_id': 44,
|
||||
'rows': [
|
||||
{'customer_po_number': '4518738152', 'part_number': 'D4-A08AR12000002', 'reservation_id': '33874', 'evidence': {}},
|
||||
{'customer_po_number': '4518738152', 'part_number': 'D4-A08AR12000002', 'reservation_id': '33875', 'evidence': {}},
|
||||
],
|
||||
}
|
||||
merged = merge_email_supplements(
|
||||
orders=[order], supplements_by_intake={1: supplement}, schema_definition=SCHEMA,
|
||||
)[0]
|
||||
assert not any(item['field_id'] == 'reservation' for item in merged['lines'][0]['fields'])
|
||||
assert {'severity': 'blocking', 'reason': 'supplement_field_conflict', 'field': 'reservation_id'} in merged['conflicts']
|
||||
|
||||
|
||||
def test_email_supplement_pdf_value_conflict_keeps_pdf_and_requires_review():
|
||||
"""PDF 与 EML 对同一 Schema 字段给出不同唯一值时不得静默接受任一方。"""
|
||||
order = _order()
|
||||
order['lines'][0]['fields'].append({
|
||||
'field_id': 'reservation', 'observations': [{'value': 'PDF-33873'}],
|
||||
})
|
||||
supplement = {
|
||||
'document_id': 44,
|
||||
'rows': [{
|
||||
'customer_po_number': '4518738152',
|
||||
'part_number': 'D4-A08AR12000002',
|
||||
'reservation_id': 'EML-33874',
|
||||
'evidence': {},
|
||||
}],
|
||||
}
|
||||
|
||||
merged = merge_email_supplements(
|
||||
orders=[order], supplements_by_intake={1: supplement}, schema_definition=SCHEMA,
|
||||
)[0]
|
||||
|
||||
assert _value(merged['lines'][0]['fields'], 'reservation') == 'PDF-33873'
|
||||
assert {'severity': 'blocking', 'reason': 'supplement_field_conflict', 'field': 'reservation_id'} in merged['conflicts']
|
||||
|
||||
|
||||
def test_email_supplement_cross_adjudicates_pn_and_ampn_against_both_order_part_numbers():
|
||||
"""邮件 PN/AMPN 均可与订单内部/客户料号交叉匹配,不依赖字段名称相同。"""
|
||||
scenarios = [
|
||||
('part_number', 'D4-A08AR12000002', 'part'),
|
||||
('part_number', 'AMTEMP-S000218922', 'customer-part'),
|
||||
('customer_part_number', 'D4-A08AR12000002', 'part'),
|
||||
('customer_part_number', 'AMTEMP-S000218922', 'customer-part'),
|
||||
]
|
||||
for index, (mail_field, value, order_field) in enumerate(scenarios, start=1):
|
||||
order = _order()
|
||||
order['lines'][0]['fields'].append({
|
||||
'field_id': 'customer-part', 'observations': [{'value': 'AMTEMP-S000218922'}],
|
||||
})
|
||||
if order_field == 'part':
|
||||
order['lines'][0]['fields'][0]['observations'][0]['value'] = value
|
||||
supplement = {'document_id': 44, 'rows': [{
|
||||
'po_number': '4518738152', mail_field: value,
|
||||
'reservation_id': f'30000{index}', 'evidence': {},
|
||||
}]}
|
||||
merged = merge_email_supplements(
|
||||
orders=[order], supplements_by_intake={1: supplement}, schema_definition=SCHEMA,
|
||||
)
|
||||
assert _value(merged[0]['lines'][0]['fields'], 'reservation') == f'30000{index}'
|
||||
assert merged[0]['_hxops_email_supplement_relation'] == 'po_mpn'
|
||||
|
||||
|
||||
def test_email_supplement_po_fallback_writes_unique_reservation_without_part_match():
|
||||
"""唯一 PO 兜底不得在写入阶段重新要求邮件料号匹配。"""
|
||||
result = merge_email_supplements(
|
||||
orders=[_order()],
|
||||
supplements_by_intake={1: {'document_id': 44, 'rows': [{
|
||||
'customer_po_number': '4518738152', 'part_number': 'D4-A08AR12000001',
|
||||
'reservation_id': '33874', 'evidence': {},
|
||||
}]}},
|
||||
schema_definition=SCHEMA,
|
||||
)[0]
|
||||
assert _value(result['lines'][0]['fields'], 'reservation') == '33874'
|
||||
assert result['_hxops_email_supplement_relation'] == 'po_fallback'
|
||||
|
||||
|
||||
def test_email_supplement_po_fallback_requires_one_reservation():
|
||||
"""缺 MPN 时只有唯一 Reservation 的 PO 可广播;多 Reservation 必须复核。"""
|
||||
one = {'document_id': 44, 'rows': [{'po_number': '4518738152', 'reservation_id': '2000484577', 'evidence': {}}]}
|
||||
@@ -103,15 +226,15 @@ def test_email_supplement_unique_mpn_fallback_handles_mistyped_email_po():
|
||||
'document_id': 44,
|
||||
'rows': [
|
||||
{
|
||||
'po_number': '4518738152', 'mpn': 'D4-A08AR12000002',
|
||||
'customer_po_number': '4518738152', 'part_number': 'D4-A08AR12000002',
|
||||
'reservation_id': '2000484577', 'evidence': {},
|
||||
},
|
||||
{
|
||||
'po_number': '4518738152', 'mpn': 'D4-A08AR12000002',
|
||||
'customer_po_number': '4518738152', 'part_number': 'D4-A08AR12000002',
|
||||
'reservation_id': '2000484577', 'evidence': {},
|
||||
},
|
||||
{
|
||||
'po_number': '4518838154', 'mpn': 'B3-AR1000270A1',
|
||||
'customer_po_number': '4518838154', 'part_number': 'B3-AR1000270A1',
|
||||
'reservation_id': '4000111701', 'evidence': {},
|
||||
},
|
||||
],
|
||||
@@ -133,9 +256,9 @@ def test_email_supplement_plain_text_vertical_table_is_parsed_without_guessing_b
|
||||
)
|
||||
assert supplement['rows'] == [{
|
||||
'allocation_id': 'A-1', 'reservation_id': '2000484577',
|
||||
'source_from_party': 'Welltrust', 'source_type': 'DSB CMH',
|
||||
'allocated_entity': 'IEC-CJS', 'mpn': 'D4-A08AR12000002',
|
||||
'allocated_qty': '30', 'po_number': '4518838152',
|
||||
'source_from_party': 'Welltrust', 'inventory_source_hint': 'DSB CMH',
|
||||
'allocated_entity': 'IEC-CJS', 'part_number': 'D4-A08AR12000002',
|
||||
'allocated_qty': '30', 'customer_po_number': '4518838152',
|
||||
'evidence': supplement['rows'][0]['evidence'], 'table_index': None, 'row_index': 1,
|
||||
}]
|
||||
|
||||
|
||||
Reference in new issue
Block a user