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
@@ -93,6 +93,75 @@ def test_layout_snapshot_checksum_and_idempotent_current_version(app):
|
||||
assert current_layout_snapshot(document)['marker'] == 'v1'
|
||||
|
||||
|
||||
def test_inline_derived_xfa_layout_localizes_structure_analysis_identity(app):
|
||||
"""坐标补证派生 Layout 必须克隆 XFA Analysis,样本可安全冻结到新版本。"""
|
||||
with app.app_context():
|
||||
document = _document()
|
||||
analysis = ShippingXfaStructureAnalysis(
|
||||
document_id=document.id,
|
||||
layout_version_id=None,
|
||||
source_content_hash=document.content_hash,
|
||||
document_kind='xfa_hybrid',
|
||||
analysis_status='ready',
|
||||
template_packet_checksum='sha256:template',
|
||||
datasets_packet_checksum='sha256:datasets',
|
||||
dataset_structure_fingerprint='sha256:structure',
|
||||
packet_checksums_json={'datasets': 'sha256:datasets'},
|
||||
stats_json={}, security_summary_json={}, tree_summary_json={},
|
||||
parser_identity='xfa-parser.v1', contract_version='xfa-contract.v1',
|
||||
)
|
||||
db.session.add(analysis)
|
||||
db.session.flush()
|
||||
first = record_inline_layout_snapshot(document, {
|
||||
**_snapshot(marker='xfa-base'),
|
||||
'xfa_capability': {'structure_analysis_id': analysis.id},
|
||||
'capability': {'structure_analysis_id': analysis.id},
|
||||
})
|
||||
assert analysis.layout_version_id == first.id
|
||||
|
||||
derived = record_inline_layout_snapshot(document, {
|
||||
**dict(first.payload_json),
|
||||
'marker': 'xfa-coordinate-evidence',
|
||||
}, parser_key='shipping_order_profile_freeze:page_coordinate_evidence.v1')
|
||||
db.session.commit()
|
||||
|
||||
derived_analysis_id = derived.payload_json['xfa_capability']['structure_analysis_id']
|
||||
derived_analysis = db.session.get(ShippingXfaStructureAnalysis, derived_analysis_id)
|
||||
# 关键断言:新 Layout 与新 Analysis 一一绑定,旧分析仍保留原 Layout 审计身份。
|
||||
assert derived.id != first.id
|
||||
assert derived_analysis_id != analysis.id
|
||||
assert derived_analysis.layout_version_id == derived.id
|
||||
assert analysis.layout_version_id == first.id
|
||||
assert derived.payload_json['capability']['structure_analysis_id'] == derived_analysis.id
|
||||
|
||||
# 修复部署前已落库的派生快照按原 checksum 重放时,同样必须补齐新 identity。
|
||||
stale = record_inline_layout_snapshot(document, {
|
||||
**_snapshot(marker='xfa-pre-fix-stale'),
|
||||
'xfa_capability': {'structure_analysis_id': analysis.id},
|
||||
'capability': {'structure_analysis_id': analysis.id},
|
||||
}, parser_key='shipping_order_profile_freeze:page_coordinate_evidence.v1')
|
||||
stale_payload = {
|
||||
**_snapshot(marker='xfa-pre-fix-stale'),
|
||||
'xfa_capability': {'structure_analysis_id': analysis.id},
|
||||
'capability': {'structure_analysis_id': analysis.id},
|
||||
}
|
||||
stale.payload_json = stale_payload
|
||||
stale.payload_checksum, stale.payload_size_bytes = canonical_layout_payload(stale_payload)
|
||||
db.session.flush()
|
||||
repaired = record_inline_layout_snapshot(document, {
|
||||
**_snapshot(marker='xfa-pre-fix-stale'),
|
||||
'xfa_capability': {'structure_analysis_id': analysis.id},
|
||||
'capability': {'structure_analysis_id': analysis.id},
|
||||
}, parser_key='shipping_order_profile_freeze:page_coordinate_evidence.v1')
|
||||
repaired_analysis = db.session.get(
|
||||
ShippingXfaStructureAnalysis,
|
||||
repaired.payload_json['xfa_capability']['structure_analysis_id'],
|
||||
)
|
||||
assert repaired.id == stale.id
|
||||
assert repaired_analysis.id != analysis.id
|
||||
assert repaired_analysis.layout_version_id == repaired.id
|
||||
|
||||
|
||||
def test_failed_or_oversized_layout_does_not_replace_last_good_version(app):
|
||||
"""失败/超限版本必须可审计,但绝不能覆盖 Document 上一次成功布局。"""
|
||||
app.config['SHIPPING_NOTICE_LAYOUT_MAX_SNAPSHOT_BYTES'] = 500
|
||||
@@ -198,8 +267,8 @@ def test_recoverable_ready_layout_is_reused_for_duplicate_document(app):
|
||||
assert scheduled.id != incomplete.id
|
||||
|
||||
|
||||
def test_xfa_layout_reuse_localizes_structure_analysis_for_duplicate_document(app, monkeypatch):
|
||||
"""相同 XFA 文件复用时,目标 Document 必须获得独立 Analysis 并重写快照身份。"""
|
||||
def test_shared_visual_layout_reuse_localizes_xfa_structure_analysis(app, monkeypatch):
|
||||
"""共享视觉 Layout 带 datasets capability 时,复用必须本地化其结构分析身份。"""
|
||||
app.config['SHIPPING_NOTICE_LAYOUT_MINERU_ENABLED'] = True
|
||||
audit_events: list[str] = []
|
||||
|
||||
@@ -232,11 +301,13 @@ def test_xfa_layout_reuse_localizes_structure_analysis_for_duplicate_document(ap
|
||||
db.session.flush()
|
||||
source_layout = record_inline_layout_snapshot(original, {
|
||||
'status': 'ready',
|
||||
'provider': 'xfa',
|
||||
'provider_version': 'xfa-parser.v1',
|
||||
'backend': 'pypdf',
|
||||
'provider': 'mineru',
|
||||
'provider_version': 'mineru-v1',
|
||||
'backend': 'pipeline',
|
||||
'snapshot_version': 'shipping_document_layout.v1',
|
||||
'tables': [],
|
||||
# 新统一 Layout 仍要满足普通 PDF 的坐标证据复用门禁;datasets 仅为末端值源。
|
||||
'coordinate_evidence': {'pages': {'1': {}}, 'page_glyphs': {'1': []}},
|
||||
'xfa_capability': {
|
||||
'structure_analysis_ready': True,
|
||||
'structure_analysis_id': source_analysis.id,
|
||||
@@ -281,8 +352,8 @@ def test_xfa_layout_reuse_localizes_structure_analysis_for_duplicate_document(ap
|
||||
assert 'xfa_structure_analysis_reused' in audit_events
|
||||
|
||||
|
||||
def test_xfa_layout_without_source_analysis_is_not_reused(app, monkeypatch):
|
||||
"""XFA 快照声明 ready 但源 Analysis 缺失时必须重新排队,禁止复制伪 ready 状态。"""
|
||||
def test_legacy_xfa_only_layout_without_shared_visual_evidence_is_reparsed(app, monkeypatch):
|
||||
"""旧 XFA-only 快照缺共同视觉证据时一律重解析,不能保留格式专用复用分支。"""
|
||||
app.config['SHIPPING_NOTICE_LAYOUT_MINERU_ENABLED'] = True
|
||||
audit_events: list[str] = []
|
||||
|
||||
@@ -332,8 +403,7 @@ def test_xfa_layout_without_source_analysis_is_not_reused(app, monkeypatch):
|
||||
assert scheduled.status == 'queued'
|
||||
assert duplicate.current_layout_version_id is None
|
||||
assert ShippingXfaStructureAnalysis.query.filter_by(document_id=duplicate.id).count() == 0
|
||||
assert 'xfa_structure_analysis_reuse_rejected' in audit_events
|
||||
assert 'xfa_structure_analysis_reparse_queued' in audit_events
|
||||
assert not audit_events
|
||||
|
||||
|
||||
def test_layout_parser_fingerprint_change_creates_new_version_without_force(app, monkeypatch):
|
||||
|
||||
Reference in new issue
Block a user