feat(shipping-notice): 增强订单抽取与审计功能,支持取消与保留策略
- 在环境配置中新增进度细化、订单提取取消与审计导出相关的开关 - 实现订单抽取运行的取消功能,允许管理员在运行中进行操作 - 引入审计事件的保留策略,支持三年保留期的自动清理 - 更新相关模型与服务,确保新功能的完整性与可追溯性 - 增强文档与代码注释,反映新的业务逻辑与审计要求
This commit is contained in:
1 parent
c85997884b
commit
95cdfe66b0
158 files changed
+19005
-1201
No files matched your search
@@ -1065,6 +1065,52 @@ def test_selected_eml_attachments_use_bounded_parallel_deep_extraction(app, ship
|
||||
]
|
||||
|
||||
|
||||
def test_eml_materialization_rejects_missing_selected_document(app, shipping_user, monkeypatch):
|
||||
"""已选附件未落成 Document 时,必须停止在输入准备阶段而非误报版面服务故障。"""
|
||||
from app.services.shipping_notice.notice_upload import NoticeIntakeResult
|
||||
import app.services.shipping_notice.order_extraction_materialization as materialization
|
||||
|
||||
with app.app_context():
|
||||
asset, intake = _seed_parsed_intake(shipping_user.id, intake_no='SNI-MISSING-SELECTED-DOCUMENT')
|
||||
asset.original_filename = 'orders.eml'
|
||||
asset.mime_type = 'message/rfc822'
|
||||
db.session.commit()
|
||||
|
||||
def _preview_result(_asset, **_kwargs):
|
||||
return NoticeIntakeResult(
|
||||
filename='orders.eml', source_type='email', source_file_type='message/rfc822',
|
||||
text='mail preview', warnings=[], meta={'attachments': [
|
||||
{
|
||||
'attachment_key': 'att-002', 'filename': 'order.pdf',
|
||||
'mime_type': 'application/pdf', '_payload_bytes': b'pdf',
|
||||
},
|
||||
]},
|
||||
content_hash=str(asset.content_hash), file_size=12, status='accepted', saved_path=None,
|
||||
)
|
||||
|
||||
monkeypatch.setattr(materialization, 'extract_notice_from_asset', _preview_result)
|
||||
# 关键断言:即使持久化层异常静默返回,也不能让空输入进入后续版面调度。
|
||||
monkeypatch.setattr(materialization, 'persist_intake_documents', lambda **_kwargs: {'document_count': 0})
|
||||
|
||||
with pytest.raises(ConflictError) as exc_info:
|
||||
materialization.ensure_order_extraction_input_documents(
|
||||
intakes=[intake],
|
||||
attachment_selection={
|
||||
'items': [{
|
||||
'intake_no': intake.intake_no,
|
||||
'attachment_key': 'att-002',
|
||||
'selected': True,
|
||||
'selection_batch': 1,
|
||||
}],
|
||||
},
|
||||
schema_definition={'fields': []},
|
||||
)
|
||||
|
||||
assert exc_info.value.code == 'SHIPPING_NOTICE.INTAKE_ATTACHMENTS_INCOMPLETE'
|
||||
assert exc_info.value.details['reason'] == 'selected_attachment_document_missing'
|
||||
assert exc_info.value.details['missing_attachment_keys'] == ['att-002']
|
||||
|
||||
|
||||
def test_selected_normal_files_use_global_bounded_parallel_extraction(app, shipping_user, monkeypatch):
|
||||
"""不同普通文件共享首轮并发预算,完成顺序不得改变主线程持久化顺序。"""
|
||||
from app.services.shipping_notice.notice_upload import NoticeIntakeResult
|
||||
|
||||
Reference in new issue
Block a user