feat(shipping-notice): 完成货代发货通知全门禁恢复MVP收口
完成全门禁恢复MVP版本交付:调整自动上传与重试配置,重构正式执行链路;修复多处代码bug,新增测试与审计工具;更新全流程文档与契约规范。
This commit is contained in:
1 parent
8e0bbf7a81
commit
c94d173f92
181 files changed
+12947
-1724
No files matched your search
@@ -399,7 +399,75 @@ def test_each_gate_supports_passed_manual_blocked_and_technical_failed(app, gate
|
||||
assert terminal.status == 'failed_terminal'
|
||||
|
||||
|
||||
def test_business_sync_reuses_same_gate_active_attempt(app):
|
||||
"""Gate 执行器同步同门业务事实时不得递归创建第二个 Attempt。"""
|
||||
with app.app_context():
|
||||
_user, review_case_id, task_id = _seed_workflow_version(suffix='activefactsync')
|
||||
execution = ensure_execution_for_workflow_version(
|
||||
review_case_id=review_case_id,
|
||||
task_id=task_id,
|
||||
)
|
||||
attempt = queue_gate_attempt(
|
||||
execution_no=execution.execution_no,
|
||||
gate_code='inventory_preparation',
|
||||
trigger_type='user_retry',
|
||||
actor_type='user',
|
||||
actor_id=1,
|
||||
idempotency_key='active-fact-sync',
|
||||
input_snapshot={
|
||||
'action_code': 'retry_inventory_preparation',
|
||||
'payload': {'actor_user_id': 1},
|
||||
},
|
||||
)
|
||||
from app.services.shipping_notice.process_gate_service import mark_attempt_running
|
||||
|
||||
mark_attempt_running(attempt_id=int(attempt.id), worker_id='active-fact-sync')
|
||||
gate = sync_gate_from_business_result(
|
||||
execution_no=execution.execution_no,
|
||||
gate_code='inventory_preparation',
|
||||
passed=False,
|
||||
blocking_reason_code='inventory_file_missing',
|
||||
effective_result_json={'findings': [], 'has_inventory_lines': False},
|
||||
idempotency_key='nested-fact-sync-must-not-queue',
|
||||
)
|
||||
|
||||
assert gate.status == 'running'
|
||||
assert ShippingProcessGateAttempt.query.filter_by(gate_id=int(gate.id)).count() == 1
|
||||
|
||||
|
||||
def test_force_business_sync_uses_current_gate_version(app):
|
||||
"""强制重评不得回放失效前的固定幂等 Attempt。"""
|
||||
with app.app_context():
|
||||
_user, review_case_id, task_id = _seed_workflow_version(suffix='forceversion')
|
||||
execution = ensure_execution_for_workflow_version(
|
||||
review_case_id=review_case_id,
|
||||
task_id=task_id,
|
||||
)
|
||||
first = apply_gate_outcome(
|
||||
execution=execution,
|
||||
gate_code='task_creation',
|
||||
passed=True,
|
||||
effective_result={'findings': [], 'task_no': 'T-1'},
|
||||
idempotency_key='fixed-task-sync',
|
||||
force=True,
|
||||
)
|
||||
assert first is not None and first.status == 'passed'
|
||||
first.status = 'invalidated'
|
||||
first.blocking_reason_code = 'gate_invalidated'
|
||||
first.evaluation_version = int(first.evaluation_version) + 1
|
||||
db.session.flush()
|
||||
|
||||
second = apply_gate_outcome(
|
||||
execution=execution,
|
||||
gate_code='task_creation',
|
||||
passed=True,
|
||||
effective_result={'findings': [], 'task_no': 'T-1'},
|
||||
idempotency_key='fixed-task-sync',
|
||||
force=True,
|
||||
)
|
||||
|
||||
assert second is not None and second.status == 'passed'
|
||||
assert ShippingProcessGateAttempt.query.filter_by(gate_id=int(second.id)).count() == 2
|
||||
|
||||
|
||||
def test_idempotent_queue_replays_same_attempt(gate_execution):
|
||||
|
||||
Reference in new issue
Block a user