refactor(agent, shipping): 简化代理模型并完善订单抽取业务

- 移除 Agent 的 exposure_mode 与 internal_executor 相关逻辑,清理关联的过滤、序列化代码
- 删除废弃的 AgentRuntimeBinding 模型及其依赖
- 新增订单抽取上传批次、请求快照等数据库迁移与业务逻辑
- 修复附件完整性检测、订单抽取状态映射问题
- 更新多语言错误文案与前端单元测试配置
- 清理平台配置中不再使用的暴露模式配置
This commit is contained in:
hugo committed 2026-07-28 20:25:48 +08:00
1 parent 1f3ecb87b7
commit 61ac6403c4
159 files changed
+12883 -5099

No files matched your search

+25 -1
View File
@@ -6,7 +6,10 @@
from __future__ import annotations
from app.services.shipping_notice.email_allocation_table_parser import parse_email_allocation_tables
from app.services.shipping_notice.email_allocation_table_parser import (
parse_email_allocation_tables,
parse_email_allocation_text,
)
from app.services.shipping_notice.order_supplement_merge import merge_email_supplements
@@ -69,3 +72,24 @@ def test_email_supplement_po_fallback_requires_one_reservation():
]}
result = merge_email_supplements(orders=[_order()], supplements_by_intake={1: ambiguous}, schema_definition=SCHEMA)[0]
assert any(item.get('reason') == 'supplement_relation_ambiguous' for item in result['conflicts'])
def test_email_supplement_plain_text_vertical_table_is_parsed_without_guessing_body_text():
"""Outlook 展平的纵向表头可恢复补充行,尾部邮件正文不会被误当数据。"""
supplement = parse_email_allocation_text(
content_hash='b' * 64,
body_text='''Hello\nallocation_id\nreservation_id\nsource_from_party\nsource_type\nallocated_entity\nmpn\nallocated_qty\nPO#\nA-1\n2000484577\nWelltrust\nDSB CMH\nIEC-CJS\nD4-A08AR12000002\n30\n4518838152\nThank you''',
)
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',
'evidence': supplement['rows'][0]['evidence'], 'table_index': None, 'row_index': 1,
}]
def test_email_supplement_plain_text_deduplicates_quoted_email_rows():
"""转发邮件重复同一正文表时只保留一个事实行,避免制造补充关联冲突。"""
body = '''allocation_id\nreservation_id\nsource_from_party\nsource_type\nallocated_entity\nmpn\nallocated_qty\nPO#\nA-1\n2000484577\nWelltrust\nDSB CMH\nIEC-CJS\nD4-A08AR12000002\n30\n4518838152\nA-1\n2000484577\nWelltrust\nDSB CMH\nIEC-CJS\nD4-A08AR12000002\n30\n4518838152'''
assert len(parse_email_allocation_text(body_text=body, content_hash='c' * 64)['rows']) == 1