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
@@ -173,14 +173,16 @@ def run_shipping_document_layout(ctx: JobContext, payload: dict) -> None:
|
||||
xfa_outcome = analyze_xfa_pdf(content, limits=default_xfa_resource_limits())
|
||||
timings['xfa_analysis_ms'] = round((perf_counter() - xfa_started) * 1000)
|
||||
|
||||
xfa_capability: dict | None = None
|
||||
snapshot = None
|
||||
if (
|
||||
xfa_outcome is not None
|
||||
and xfa_outcome.packet_result is not None
|
||||
and xfa_outcome.packet_result.document_kind not in {'plain_pdf', 'acroform'}
|
||||
):
|
||||
snapshot = dict(xfa_outcome.snapshot)
|
||||
capability = snapshot.get('xfa_capability') if isinstance(snapshot.get('xfa_capability'), dict) else {}
|
||||
xfa_snapshot = dict(xfa_outcome.snapshot)
|
||||
capability = xfa_snapshot.get('xfa_capability') if isinstance(xfa_snapshot.get('xfa_capability'), dict) else {}
|
||||
xfa_capability = dict(capability)
|
||||
try:
|
||||
counts['page_count'] = int(capability.get('page_count') or 0)
|
||||
except (TypeError, ValueError):
|
||||
@@ -191,6 +193,11 @@ def run_shipping_document_layout(ctx: JobContext, payload: dict) -> None:
|
||||
source_content_hash=str(document.content_hash or ''),
|
||||
outcome=xfa_outcome,
|
||||
)
|
||||
# persist_xfa_structure_analysis 将冻结 analysis_id 回填到 outcome 快照;
|
||||
# 重新读取,确保随后合并到统一视觉 Layout 的 capability 可被精确复核。
|
||||
persisted_capability = xfa_outcome.snapshot.get('xfa_capability')
|
||||
if isinstance(persisted_capability, dict):
|
||||
xfa_capability = dict(persisted_capability)
|
||||
if xfa_outcome.error_code == 'XFA_UNSAFE_XML':
|
||||
_layout_job_audit(
|
||||
event_type='xfa_parse_rejected_unsafe',
|
||||
@@ -199,15 +206,15 @@ def run_shipping_document_layout(ctx: JobContext, payload: dict) -> None:
|
||||
result='failure',
|
||||
error_code=xfa_outcome.error_code,
|
||||
)
|
||||
elif snapshot.get('status') == 'ready':
|
||||
elif xfa_snapshot.get('status') == 'ready':
|
||||
_layout_job_audit(
|
||||
event_type='xfa_structure_analysis_ready',
|
||||
job=job,
|
||||
version=version,
|
||||
metadata={
|
||||
'document_kind': snapshot.get('document_kind'),
|
||||
'document_kind': xfa_snapshot.get('document_kind'),
|
||||
'structure_analysis_id': (
|
||||
(snapshot.get('xfa_capability') or {}).get('structure_analysis_id')
|
||||
(xfa_snapshot.get('xfa_capability') or {}).get('structure_analysis_id')
|
||||
),
|
||||
},
|
||||
)
|
||||
@@ -221,15 +228,19 @@ def run_shipping_document_layout(ctx: JobContext, payload: dict) -> None:
|
||||
error_code=xfa_outcome.error_code,
|
||||
metadata={'route_reason': xfa_outcome.route_reason},
|
||||
)
|
||||
if snapshot is None:
|
||||
snapshot = build_mineru_table_snapshot(
|
||||
filename=str(document.filename or asset.original_filename or 'document.pdf'),
|
||||
content=content,
|
||||
document_id=document.id,
|
||||
content_hash=document.content_hash,
|
||||
timings=timings,
|
||||
counts=counts,
|
||||
)
|
||||
# XFA datasets 与视觉 Layout 是同一文档的两种证据。即使 XFA 结构分析成功,
|
||||
# 也必须继续构建通用表格/坐标 Layout,供统一 main_table_id、标注与验证使用。
|
||||
# datasets capability 仅在末端 value adapter 选择正式取值来源,不能再短路生命周期。
|
||||
snapshot = build_mineru_table_snapshot(
|
||||
filename=str(document.filename or asset.original_filename or 'document.pdf'),
|
||||
content=content,
|
||||
document_id=document.id,
|
||||
content_hash=document.content_hash,
|
||||
timings=timings,
|
||||
counts=counts,
|
||||
)
|
||||
if snapshot is not None and xfa_capability is not None:
|
||||
snapshot['xfa_capability'] = xfa_capability
|
||||
timings['snapshot_build_ms'] = round((perf_counter() - total_started) * 1000)
|
||||
if snapshot is None:
|
||||
snapshot = {
|
||||
@@ -286,7 +297,7 @@ def run_shipping_document_layout(ctx: JobContext, payload: dict) -> None:
|
||||
error_code=LAYOUT_JOB_ERROR,
|
||||
metadata={'error': str(exc)[:200]},
|
||||
)
|
||||
fail_job(job.id, error=LAYOUT_JOB_ERROR, retryable=True, owned_attempt=owned_attempt)
|
||||
fail_job(job.id, error=LAYOUT_JOB_ERROR, retryable=False, owned_attempt=owned_attempt)
|
||||
sync_layout_after_job_failure(job.id)
|
||||
# 仅当重试已耗尽时版本才会转 failed;此时需要唤醒等待中的 Run,
|
||||
# 让用户看到“附件解析失败”而不是永久停留在“正在解析”。
|
||||
|
||||
Reference in new issue
Block a user