feat(shipping-notice): 收敛复核阶段同源投影与 OT 后履约推进
统一 Case/Progress 阶段 label_key、修复 Job 成功未推进 OT 的可重试失败投影与写路径,并落地 OT 后行级匹配/波次履约与版面诊断开关。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
74270adc22
commit
fd6a23f870
100 files changed
+12138
-1017
No files matched your search
@@ -231,12 +231,20 @@ def claim_next_shipping_notice_job() -> Job | None:
|
||||
JobType.SHIPPING_PROCESS_GATE,
|
||||
JobType.SHIPPING_XFA_OCR_AUTOMARK,
|
||||
JobType.SHIPPING_STP_AUTO_CREATE,
|
||||
JobType.SHIPPING_LINE_AUTO_FULFILL,
|
||||
JobType.SHIPPING_POST_OT_WAVE_PROGRESS,
|
||||
],
|
||||
)
|
||||
|
||||
|
||||
def run_shipping_notice_job(payload: dict[str, Any], logger: logging.Logger | None = None) -> tuple[bool, str]:
|
||||
"""执行单票发货任务;既可被通用 Job handler 调用,也可被 sync enqueue 直调。"""
|
||||
"""
|
||||
执行单票发货任务;既可被通用 Job handler 调用,也可被 sync enqueue 直调。
|
||||
|
||||
核心逻辑:委托 batch_orchestrator._run_single_task;若 Job 软成功但
|
||||
OT 仍停在 created(已挂 Extraction),则 fail_job 并带
|
||||
auto_progress_job_succeeded_but_task_not_advanced,供幂等重试直至 max_attempts。
|
||||
"""
|
||||
from app.services.shipping_notice.batch_orchestrator import _run_single_task
|
||||
|
||||
raw_job_id = payload.get('job_id')
|
||||
@@ -265,6 +273,26 @@ def run_shipping_notice_job(payload: dict[str, Any], logger: logging.Logger | No
|
||||
status = str(result.get('status') or '').strip().lower()
|
||||
success = status in {'ok', 'running', 'needs_human', 'skipped'}
|
||||
|
||||
# [STEP] 正式 OT 已挂 Extraction 却仍停在 created:软成功不得 finish Job,须 fail/重试。
|
||||
# 根因:orchestrator 对 created+extraction 调 auto_progress 后若未推进,旧逻辑仍会 finish_job。
|
||||
refreshed = get_task_by_ref(task_no)
|
||||
hang_created = bool(
|
||||
refreshed is not None
|
||||
and getattr(refreshed, 'current_order_extraction_id', None)
|
||||
and str(getattr(refreshed, 'process_status', None) or '').strip().lower() in {'', 'created'}
|
||||
and status in {'ok', 'needs_human', 'skipped'}
|
||||
)
|
||||
if hang_created:
|
||||
success = False
|
||||
status = 'failed'
|
||||
result = {
|
||||
**dict(result or {}),
|
||||
'status': 'failed',
|
||||
'error_code': 'auto_progress_job_succeeded_but_task_not_advanced',
|
||||
'message': str(result.get('message') or '')
|
||||
or '自动推进 Job 结束但正式 OT 仍停在 created,将按幂等重试',
|
||||
}
|
||||
|
||||
if job_id is not None:
|
||||
job = db.session.get(Job, job_id)
|
||||
if job is not None:
|
||||
|
||||
Reference in new issue
Block a user