feat(shipping, admin, workspace, docs): 迭代货代模块、补充文档并处理合并冲突问题

This commit is contained in:
hugo committed 2026-08-12 09:27:33 +08:00
1 parent 4587b56900
commit 3c0e08377c
94 files changed
+29222 -1218

No files matched your search

+6 -6
View File
@@ -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,