feat(shipping-notice,receipt-report): 新增收料报表功能并优化发货通知流程

清理废弃的shipping xfa ocr automark相关代码和job配置
新增收料报表管理的前端页面、路由和侧边栏入口
新增后端收料报表配置接口、数据库模型和RPA脚本
优化发货通知流程的重试策略,将shipping相关job默认不自动重试
移除废弃的库存源确认相关逻辑,更新流程门禁规则
重构订单模板的值适配器模块,新增坐标OCR值适配器
清理前端shipping菜单和action的废弃选项
更新相关文档和测试用例,调整.gitignore忽略规则
This commit is contained in:
hugo committed 2026-08-20 20:23:10 +08:00
1 parent 260465b72d
commit 1b6483a4ea
466 files changed
+32115 -33796

No files matched your search

@@ -20,6 +20,7 @@ from __future__ import annotations
from types import SimpleNamespace
from typing import Any
@@ -195,9 +196,9 @@ def test_ensure_execution_for_task_ignores_superseded_execution(app):
def test_auto_progress_does_not_queue_manual_inventory_retry(gate_execution, monkeypatch):
def test_auto_progress_queues_initial_inventory_rpa_once(gate_execution, monkeypatch):
"""自动推进不得把用户恢复动作 retry_inventory_preparation 重新触发为 RPA。"""
"""首次进入库存准备没有任何 RPA Attempt 时,自动推进必须投递一次 trigger。"""
from app.services.shipping_notice import process_gate_service
@@ -223,7 +224,11 @@ def test_auto_progress_does_not_queue_manual_inventory_retry(gate_execution, mon
monkeypatch.setattr(
process_gate_service,
'queue_gate_attempt',
lambda **kwargs: queued.append(kwargs),
lambda **kwargs: (queued.append(kwargs), SimpleNamespace(id=1))[1],
)
monkeypatch.setattr(
'app.services.shipping_notice.process_gate_job_service.enqueue_gate_attempt_job',
lambda **_kwargs: None,
)
process_gate_service._enqueue_auto_progress_after_gate_pass(
@@ -231,6 +236,37 @@ def test_auto_progress_does_not_queue_manual_inventory_retry(gate_execution, mon
gate=gate,
)
assert len(queued) == 1
assert queued[0]['gate_code'] == 'inventory_preparation'
def test_auto_progress_does_not_requeue_failed_inventory_rpa(gate_execution, monkeypatch):
"""已有终态 Attempt 后,库存 RPA 只允许人工重试,不能被自动无限重放。"""
from app.services.shipping_notice import process_gate_service
from app.models import ShippingNotice, ShippingTaskInventoryRpaAttempt
for prior_gate in ShippingProcessGate.query.filter(
ShippingProcessGate.execution_id == int(gate_execution.id),
ShippingProcessGate.sequence_no < 13,
).all():
prior_gate.status = 'passed'
gate = ShippingProcessGate.query.filter_by(
execution_id=int(gate_execution.id), gate_code='inventory_preparation',
).one()
gate.status = 'blocked_retryable'
gate.next_action_code = 'retry_inventory_preparation'
task = db.session.get(ShippingNotice, int(gate_execution.task_id))
db.session.add(ShippingTaskInventoryRpaAttempt(
task_no=task.task_no, source_code='TEST', attempt_no=1, source_run_no='PSR-FAILED',
status='failed', trigger_file_path='C:/trigger.json', execution_phase='trigger_written',
))
process_gate_service._refresh_execution_pointers(gate_execution)
db.session.flush()
queued: list[dict[str, object]] = []
monkeypatch.setattr(process_gate_service, 'queue_gate_attempt', lambda **kwargs: queued.append(kwargs))
process_gate_service._enqueue_auto_progress_after_gate_pass(execution=gate_execution, gate=gate)
assert queued == []
@@ -386,6 +422,41 @@ def test_upstream_invalidation_only_targets_dependents(gate_execution):
assert doc.status == 'passed'
def test_invalidation_uses_target_gate_retry_action_not_inventory_reroute_fallback(gate_execution):
"""下游 Excel Gate 失效后只能保留自身的重检动作,不能落入库存源重路由兜底。"""
excel = ShippingProcessGate.query.filter_by(
execution_id=int(gate_execution.id), gate_code='excel_readiness',
).one()
excel.status = 'passed'
db.session.flush()
invalidate_downstream_gates(
execution=gate_execution,
change_type='inventory_file_changed',
)
assert excel.status == 'invalidated'
assert excel.next_action_code == 'recheck_excel_readiness'
def test_queue_gate_attempt_rejects_action_owned_by_another_gate(gate_execution):
"""任何调用方都不能把库存源路由动作创建到 Excel Gate Attempt。"""
from app.core.errors import ValidationError
with pytest.raises(ValidationError) as exc:
queue_gate_attempt(
execution_no=gate_execution.execution_no,
gate_code='excel_readiness',
trigger_type='auto',
actor_type='system',
actor_id='test',
idempotency_key='wrong-action-excel-gate',
input_snapshot={'action_code': 'retry_layout_parsing'},
)
assert getattr(exc.value, 'code', None) == 'SHIPPING.PROCESS_GATE_ACTION_NOT_ALLOWED'
@@ -587,7 +658,7 @@ def test_idempotent_queue_replays_same_attempt(gate_execution):
idempotency_key='same-key-ten-times',
input_snapshot={'action_code': 'retry_with_latest_rules'},
input_snapshot={'action_code': 'retry_layout_parsing'},
)
@@ -607,7 +678,7 @@ def test_idempotent_queue_replays_same_attempt(gate_execution):
idempotency_key='same-key-ten-times',
input_snapshot={'action_code': 'retry_with_latest_rules'},
input_snapshot={'action_code': 'retry_layout_parsing'},
)
@@ -643,7 +714,7 @@ def test_idempotent_key_conflicts_across_gate_and_action(gate_execution, app):
idempotency_key='cross-context-key',
input_snapshot={'action_code': 'retry_with_latest_rules'},
input_snapshot={'action_code': 'retry_layout_parsing'},
)
@@ -663,7 +734,7 @@ def test_idempotent_key_conflicts_across_gate_and_action(gate_execution, app):
idempotency_key='cross-context-key',
input_snapshot={'action_code': 'retry_with_latest_rules'},
input_snapshot={'action_code': 'retry_layout_parsing'},
)
@@ -759,7 +830,7 @@ def test_idempotent_key_conflicts_across_execution(app):
idempotency_key='cross-execution-key',
input_snapshot={'action_code': 'retry_with_latest_rules'},
input_snapshot={'action_code': 'retry_layout_parsing'},
)
@@ -779,7 +850,7 @@ def test_idempotent_key_conflicts_across_execution(app):
idempotency_key='cross-execution-key',
input_snapshot={'action_code': 'retry_with_latest_rules'},
input_snapshot={'action_code': 'retry_layout_parsing'},
)