feat(shipping-notice): 添加订单文档 Profile 盲测集和样本管理功能,支持创建、执行和批准盲测,增强订单冻结和库存核验功能

This commit is contained in:
hugo committed 2026-07-23 00:15:34 +08:00
1 parent c35223d49d
commit abd8fc1e16
98 files changed
+4629 -528

No files matched your search

+31 -3
View File
@@ -703,8 +703,8 @@ def test_unique_manifest_accepted_layout_fields_cannot_be_overridden(app):
assert caught.value.code == 'SHIPPING_NOTICE.ORDER_EXTRACTION_PROVIDER_INVALID_RESPONSE'
def test_accepted_complete_layout_builds_order_without_provider(app):
"""唯一 accepted 表格覆盖全部必填字段时必须直接生成订单,保持零 Provider 调用。"""
def test_accepted_layout_without_approved_profile_uses_provider(app):
"""仅 L4 accepted 表格不是模板盲测凭证,未批准 Profile 仍必须走受控兜底。"""
with app.app_context():
user, agent, session, intake, _document = _seed_run_input(suffix='LAYOUT-ZERO-PROVIDER')
run, _ = create_order_extraction_run(
@@ -724,8 +724,36 @@ def test_accepted_complete_layout_builds_order_without_provider(app):
orders = build_deterministic_unit_orders(run, unit=unit)
assert orders is None
def test_approved_profile_builds_order_from_its_own_parsed_rows(app):
"""关键断言:零 Provider 订单只能取已批准 Profile 的实际解析行,不能借用 L4 候选。"""
with app.app_context():
user, agent, session, intake, _document = _seed_run_input(suffix='APPROVED-PROFILE')
run, _ = create_order_extraction_run(
user=user, agent_id=agent.id, conversation_id=session.session_id,
intake_nos=[intake.intake_no],
)
unit = run.extraction_plan.units[0]
with patch(
'app.services.shipping_notice.order_extraction_workflow._profile_table_candidates',
return_value={
'matched': True, 'blocking': False, 'issues': [],
'tables': [{
'table_id': 'profile-table', 'auto_create_approved': True,
'rows': [{
'row_index': 1, 'status': 'parsed', 'issues': [],
'fields': [{'field_id': 'qty-id', 'field_code': 'qty', 'value': 30, 'quote': 'Qty 30'}],
}],
}],
},
):
from app.services.shipping_notice.order_extraction_workflow import build_deterministic_unit_orders
orders = build_deterministic_unit_orders(run, unit=unit)
assert orders is not None
assert orders[0]['lines'][0]['fields'][0]['field_id'] == 'qty-id'
assert orders[0]['lines'][0]['fields'][0]['observations'][0]['value'] == 30