feat(shipping-notice): 增强订单抽取与审计功能,支持取消与保留策略

- 在环境配置中新增进度细化、订单提取取消与审计导出相关的开关
- 实现订单抽取运行的取消功能,允许管理员在运行中进行操作
- 引入审计事件的保留策略,支持三年保留期的自动清理
- 更新相关模型与服务,确保新功能的完整性与可追溯性
- 增强文档与代码注释,反映新的业务逻辑与审计要求
This commit is contained in:
hugo committed 2026-07-30 14:52:21 +08:00
1 parent c85997884b
commit 95cdfe66b0
158 files changed
+19005 -1201

No files matched your search

@@ -194,6 +194,11 @@ def test_independent_sample_review_reuses_existing_truth_and_excludes_training_i
available = quality.list_independent_samples(suite_id=suite['id'], actor_id=user.id)['samples']
assert {item['document_id'] for item in available} == {documents[1].id, documents[2].id}
# 候选下拉必须能区分同页多表,且不回传 HTML、坐标或内部布局内容。
assert available[0]['table_index'] == 1
assert available[0]['row_count'] > 0 and available[0]['column_count'] > 0
assert available[0]['header_preview']
assert 'html' not in available[0] and 'bbox' not in available[0]
candidate = quality.preview_independent_sample(
suite_id=suite['id'], document_id=documents[1].id, table_id='table-1', actor_id=user.id,
)
@@ -472,6 +477,21 @@ def test_draft_publish_requires_current_approved_blind_test(app):
assert getattr(caught.value, 'code', None) == 'SHIPPING.ORDER_DOCUMENT_PROFILE_PUBLISH_GATE_BLIND_TEST'
def test_draft_publish_requires_static_document_anchor(app):
"""关键断言:零必填锚点的模板不能发布,避免成为匹配所有 PDF 的通配模板。"""
from app.services.shipping_notice import document_profile_quality_service as quality
with app.app_context():
profile, _user, _documents = _published_profile_with_samples()
profile.status = 'draft'
profile.definition_json = {'document_match': {'required_anchors': []}}
with pytest.raises(Exception) as caught:
quality.assert_profile_publishable(profile)
assert getattr(caught.value, 'code', None) == 'SHIPPING.ORDER_DOCUMENT_PROFILE_PUBLISH_GATE_REQUIRED_ANCHOR'
def test_coordinate_v2_publish_promotes_approved_independent_suite(app):
"""关键断言:v2 草稿在训练、独立多明细盲测通过后可发布,并冻结正式 checksum 凭证。"""
from app.services.shipping_notice import order_document_profile_service as profiles