feat(shipping, admin, workspace, docs): 迭代货代模块、补充文档并处理合并冲突问题
This commit is contained in:
1 parent
4587b56900
commit
3c0e08377c
94 files changed
+29222
-1218
No files matched your search
@@ -5,22 +5,22 @@ backend/app/jobs/handlers/__init__.py
|
||||
逻辑:Wave 2 起在 worker 启动前 import 本包。
|
||||
"""
|
||||
|
||||
from app.jobs.handlers import (
|
||||
from app.jobs.handlers import ( # noqa: F401
|
||||
file_check_run,
|
||||
kb_clean,
|
||||
kb_dify_sync,
|
||||
procurement_contract_review,
|
||||
schedule_run,
|
||||
shipping_auto_progress,
|
||||
shipping_document_layout,
|
||||
shipping_line_auto_fulfill,
|
||||
shipping_notice_parse,
|
||||
shipping_notice_run,
|
||||
shipping_order_extraction,
|
||||
shipping_post_ot_wave_progress,
|
||||
shipping_process_gate,
|
||||
shipping_review_revalidate_progress,
|
||||
shipping_auto_progress,
|
||||
shipping_stp_auto_create,
|
||||
shipping_line_auto_fulfill,
|
||||
shipping_post_ot_wave_progress,
|
||||
shipping_review_revalidate_progress,
|
||||
shipping_xfa_ocr_automark,
|
||||
wecom_directory_sync,
|
||||
) # noqa: F401
|
||||
)
|
||||
@@ -17,7 +17,10 @@ backend/app/jobs/handlers/shipping_stp_auto_create.py
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
import logging
|
||||
from pathlib import Path
|
||||
import urllib.request
|
||||
from typing import Any
|
||||
|
||||
from app.extensions import db
|
||||
@@ -72,9 +75,12 @@ def _classify_stp_job_result(
|
||||
"""
|
||||
tech = is_tech_retryable_error(error_code, category_hint=category_hint)
|
||||
if tech:
|
||||
public_message = message
|
||||
if str(error_code or '').strip() == 'SHIPPING.STP_AUTO_CREATE_UNEXPECTED':
|
||||
public_message = '自动建单失败,系统将自动重试'
|
||||
transient: dict[str, Any] = build_stp_job_failed_transient_result(
|
||||
error_code=error_code,
|
||||
message=message,
|
||||
message=public_message,
|
||||
category_hint=category_hint,
|
||||
)
|
||||
if details:
|
||||
@@ -257,6 +263,19 @@ def handle_shipping_stp_auto_create(ctx: JobContext, payload: dict) -> None:
|
||||
return
|
||||
except Exception as exc: # noqa: BLE001
|
||||
raw_message = str(exc)[:1500]
|
||||
# #region debug-point D:failed-session-state
|
||||
try:
|
||||
debug_env = Path(__file__).resolve().parents[4] / '.dbg' / 'integer-routing-version.env'
|
||||
debug_values = {
|
||||
line.split('=', 1)[0]: line.split('=', 1)[1].strip()
|
||||
for line in debug_env.read_text(encoding='utf-8').splitlines()
|
||||
if '=' in line
|
||||
}
|
||||
urllib.request.urlopen(urllib.request.Request(debug_values.get('DEBUG_SERVER_URL', 'http://127.0.0.1:7777/event'), data=json.dumps({'sessionId': debug_values.get('DEBUG_SESSION_ID', 'integer-routing-version'), 'runId': 'post-fix', 'hypothesisId': 'D', 'location': 'shipping_stp_auto_create.py:259', 'msg': '[DEBUG] handler exception before fail_job', 'data': {'exception_type': type(exc).__name__, 'session_in_transaction': db.session.in_transaction(), 'session_is_active': db.session.is_active, 'message_prefix': raw_message[:240]}}).encode(), headers={'Content-Type': 'application/json'}), timeout=1).read()
|
||||
except Exception:
|
||||
pass
|
||||
db.session.rollback()
|
||||
# #endregion
|
||||
raw_code = 'SHIPPING.STP_AUTO_CREATE_UNEXPECTED'
|
||||
details = {
|
||||
'exception_type': type(exc).__name__,
|
||||
@@ -267,9 +286,10 @@ def handle_shipping_stp_auto_create(ctx: JobContext, payload: dict) -> None:
|
||||
# 倾向可重试;若是业务阻断性异常(如 IntegrityError 唯一冲突),
|
||||
# 真实错误码已在业务层捕获并走 ok=False 路径,不会流入此兜底。
|
||||
category_hint = 'temporary_storage_error'
|
||||
# 对外消息必须稳定且可读;原始异常只进入日志/诊断 details,禁止把 SQL/驱动文本写入用户态 Job。
|
||||
retryable, normalized, next_action = _classify_stp_job_result(
|
||||
error_code=raw_code,
|
||||
message=raw_message,
|
||||
message='自动建单失败,系统将自动重试',
|
||||
details=details,
|
||||
category_hint=category_hint,
|
||||
)
|
||||
@@ -283,7 +303,7 @@ def handle_shipping_stp_auto_create(ctx: JobContext, payload: dict) -> None:
|
||||
)
|
||||
fail_job(
|
||||
job_id,
|
||||
error=str(normalized.get('message') or raw_message)[:2000],
|
||||
error=str(normalized.get('message') or '自动建单失败,系统将自动重试')[:2000],
|
||||
result=normalized,
|
||||
retryable=retryable,
|
||||
owned_attempt=owned_attempt,
|
||||
|
||||
@@ -2,7 +2,8 @@
|
||||
backend/app/jobs/types.py
|
||||
|
||||
用途:Job 类型与状态枚举;KbJob.job_type 与 handler JobType 的双向映射。
|
||||
逻辑:handlers 与 queue 通过 JobType 注册;store 持久化仍走 KbJob 表(Wave 2 双轨)。
|
||||
逻辑:handlers 与 queue 通过 JobType 注册;store 持久化仍走 KbJob 表(Wave 2 双轨);
|
||||
shipping_process_gate 由 shipping worker 与发货通知任务同队列领取。
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
@@ -19,12 +20,18 @@ class JobType(StrEnum):
|
||||
SHIPPING_ORDER_EXTRACTION = 'shipping_order_extraction'
|
||||
SHIPPING_DOCUMENT_LAYOUT = 'shipping_document_layout'
|
||||
SHIPPING_PROCESS_GATE = 'shipping_process_gate'
|
||||
# 历史 APX 兼容:Worker 仅终态化,不再执行 Gate。
|
||||
SHIPPING_AUTO_PROGRESS = 'shipping_auto_progress'
|
||||
SHIPPING_LINE_AUTO_FULFILL = 'shipping_line_auto_fulfill'
|
||||
SHIPPING_POST_OT_WAVE_PROGRESS = 'shipping_post_ot_wave_progress'
|
||||
SHIPPING_REVIEW_REVALIDATE_PROGRESS = 'shipping_review_revalidate_progress'
|
||||
SHIPPING_STP_AUTO_CREATE = 'shipping_stp_auto_create'
|
||||
# XFA 合成预览就绪后的 OCR 自动标记(Job.job_type 为字符串列,无需 DB enum 迁移)
|
||||
SHIPPING_XFA_OCR_AUTOMARK = 'shipping_xfa_ocr_automark'
|
||||
# 资格达标后的 STP 自动建单入队(先 queued,再由 worker 执行 confirm)
|
||||
SHIPPING_STP_AUTO_CREATE = 'shipping_stp_auto_create'
|
||||
# OT 后行级自动履约协调(flag 关闭时不入队)
|
||||
SHIPPING_LINE_AUTO_FULFILL = 'shipping_line_auto_fulfill'
|
||||
# post-OT wave 专用 Excel/RPA 推进(禁止复用 confirm 后整单推进)
|
||||
SHIPPING_POST_OT_WAVE_PROGRESS = 'shipping_post_ot_wave_progress'
|
||||
# Case 字段变更后异步协调:刷新校验、重跑 STP 资格判定、推进自动入队
|
||||
SHIPPING_REVIEW_REVALIDATE_PROGRESS = 'shipping_review_revalidate_progress'
|
||||
SCHEDULE_RUN = 'schedule_run'
|
||||
FILE_CHECK_RUN = 'file_check_run'
|
||||
WECOM_DIRECTORY_SYNC = 'wecom_directory_sync'
|
||||
@@ -61,10 +68,10 @@ QUEUE_KB_JOB_TYPES: dict[str, frozenset[str]] = {
|
||||
'kb': frozenset({'clean', 'path_upload', 'sync_dify'}),
|
||||
'shipping': frozenset({
|
||||
'shipping_notice_run', 'shipping_notice_parse', 'shipping_order_extraction',
|
||||
'shipping_document_layout', 'shipping_process_gate', 'shipping_auto_progress',
|
||||
'shipping_line_auto_fulfill', 'shipping_post_ot_wave_progress',
|
||||
'shipping_review_revalidate_progress', 'shipping_stp_auto_create',
|
||||
'shipping_xfa_ocr_automark',
|
||||
'shipping_document_layout', 'shipping_process_gate', 'shipping_xfa_ocr_automark',
|
||||
'shipping_auto_progress',
|
||||
'shipping_stp_auto_create', 'shipping_line_auto_fulfill',
|
||||
'shipping_post_ot_wave_progress', 'shipping_review_revalidate_progress',
|
||||
}),
|
||||
'contract': frozenset({'procurement_contract_review'}),
|
||||
'schedule': frozenset({'schedule_run'}),
|
||||
|
||||
Reference in new issue
Block a user