feat(queue): 添加旧知识库任务入队兼容入口
- 增加 enqueue_kb_job 和 enqueue_clean_job 函数以支持旧 KB 清洗任务入队 - 在 enqueue 函数中处理 KB_CLEAN 和 KB_DIFY_SYNC 类型的任务 - 引入 ValidationError 以处理 job_id 缺失的情况 feat(shipping_notice): 更新库存 RPA 工作流逻辑 - 修改 ensure_inventory_via_rpa 函数以支持手动重试逻辑 - 优化库存导出触发和状态更新的消息提示 fix(i18n): 更新任务未找到的提示信息 - 修改中文和英文提示,明确用户操作要求 feat(shipping_notice): 增强任务解析逻辑 - 添加缺失 Reservation ID 的检查,阻止任务进入确认阶段 - 更新 get_task_status 函数以处理多票会话的任务解析
This commit is contained in:
1 parent
eb0466245b
commit
4cd987eef6
45 files changed
+2748
-1406
No files matched your search
@@ -43,13 +43,20 @@ def _require_tool_auth() -> None:
|
||||
校验货代 Tool API 鉴权 Header。
|
||||
【AI 触发时机】:本函数不是给 Agent 直接调用的 Tool;当 Dify、RPA 或外部系统请求本蓝图时由 before_request 自动触发。
|
||||
|
||||
核心逻辑:对齐文件检核 Tool,只接受 `Authorization: Bearer <token>` 或
|
||||
`X-Integration-Key`,并统一使用 `INTEGRATION_API_KEY` 作为服务端校验值;
|
||||
未配置时报服务不可用,缺失或错误时报未授权。
|
||||
核心逻辑:只接受 `Authorization: Bearer <token>` 或 `X-Integration-Key`。
|
||||
货代专用 `SHIPPING_NOTICE_TOOL_API_KEY` 优先,未配置时回退 `INTEGRATION_API_KEY`;
|
||||
未配置任何可用 key 时报服务不可用,缺失或错误时报未授权。
|
||||
"""
|
||||
configured = str(current_app.config.get('INTEGRATION_API_KEY') or '').strip()
|
||||
configured = str(
|
||||
current_app.config.get('SHIPPING_NOTICE_TOOL_API_KEY')
|
||||
or current_app.config.get('INTEGRATION_API_KEY')
|
||||
or ''
|
||||
).strip()
|
||||
if not configured:
|
||||
raise ServiceUnavailableError('INTEGRATION_API_KEY is not configured', code='missing_auth')
|
||||
raise ServiceUnavailableError(
|
||||
'SHIPPING_NOTICE_TOOL_API_KEY or INTEGRATION_API_KEY is not configured',
|
||||
code='missing_auth',
|
||||
)
|
||||
bearer = str(request.headers.get('Authorization') or '').strip()
|
||||
token = bearer[7:].strip() if bearer.lower().startswith('bearer ') else ''
|
||||
integration_key = str(request.headers.get('X-Integration-Key') or '').strip()
|
||||
@@ -331,4 +338,4 @@ def download_task_export(task_no: str):
|
||||
resolved = resolve_task_export_download(task)
|
||||
assert resolved is not None
|
||||
path, download_name = resolved
|
||||
return send_file(path, as_attachment=True, download_name=download_name, mimetype=EXPORT_MIME_TYPE)
|
||||
return send_file(path, as_attachment=True, download_name=download_name, mimetype=EXPORT_MIME_TYPE)
|
||||
@@ -53,27 +53,6 @@ def _require_user():
|
||||
return user
|
||||
|
||||
|
||||
def _maybe_recheck_inventory_rpa_wait(task: ShippingTask | None) -> None:
|
||||
"""
|
||||
工作台查询兜底复查库存 RPA 等待态。
|
||||
|
||||
常规超时/重试由 shipping worker 执行;这里仅在用户查询时发现已超时仍未推进的任务,补偿触发一次幂等复查。
|
||||
"""
|
||||
if not task:
|
||||
return
|
||||
from app.services.shipping_notice.inventory_rpa_workflow import maybe_recheck_inventory_rpa_wait
|
||||
|
||||
maybe_recheck_inventory_rpa_wait(task, source="workspace_query")
|
||||
|
||||
|
||||
def _maybe_recheck_batch_inventory_rpa_wait(batch: ShippingBatch | None) -> None:
|
||||
"""对批次下任务执行工作台查询兜底复查,避免 worker 异常时页面长期停在等待结果。"""
|
||||
if not batch:
|
||||
return
|
||||
for task in batch.tasks or []:
|
||||
_maybe_recheck_inventory_rpa_wait(task)
|
||||
|
||||
|
||||
@workspace_shipping_notice_bp.route('/shipping-tasks', methods=['GET'])
|
||||
def workspace_shipping_tasks():
|
||||
"""列出当前用户可见的发货任务,可按批次与处理状态过滤。"""
|
||||
@@ -97,8 +76,6 @@ def workspace_shipping_conversation_batch_workspace(conversation_id: str):
|
||||
batches = ShippingBatch.query.filter(ShippingBatch.conversation_id == str(conversation_id or "").strip()).filter(
|
||||
(ShippingBatch.user_id == user.id) | (ShippingBatch.user_id.is_(None))
|
||||
).all()
|
||||
for batch in batches:
|
||||
_maybe_recheck_batch_inventory_rpa_wait(batch)
|
||||
return jsonify(get_conversation_batch_workspace(conversation_id, user.id))
|
||||
|
||||
@workspace_shipping_notice_bp.route('/shipping-batches/create-from-notices', methods=['POST'])
|
||||
@@ -165,7 +142,6 @@ def workspace_shipping_batch_detail(batch_no: str):
|
||||
batch = get_batch_for_user(batch_no, user.id)
|
||||
if not batch:
|
||||
raise NotFoundError('Not found')
|
||||
_maybe_recheck_batch_inventory_rpa_wait(batch)
|
||||
focus_task = get_focus_task_for_batch(batch_no, user.id)
|
||||
return jsonify({**serialize_batch_summary(batch), 'tasks': list_tasks_for_batch(batch_no, user.id), 'focus_task': serialize_task_summary(focus_task) if focus_task else None})
|
||||
|
||||
@@ -176,7 +152,6 @@ def workspace_shipping_batch_tasks(batch_no: str):
|
||||
batch = get_batch_for_user(batch_no, user.id)
|
||||
if not batch:
|
||||
raise NotFoundError('Not found')
|
||||
_maybe_recheck_batch_inventory_rpa_wait(batch)
|
||||
return jsonify(list_tasks_for_batch(batch_no, user.id))
|
||||
|
||||
@workspace_shipping_notice_bp.route('/shipping-batches/<batch_no>/focus-task', methods=['GET'])
|
||||
@@ -186,7 +161,6 @@ def workspace_shipping_batch_focus_task(batch_no: str):
|
||||
batch = get_batch_for_user(batch_no, user.id)
|
||||
if not batch:
|
||||
raise NotFoundError('Not found')
|
||||
_maybe_recheck_batch_inventory_rpa_wait(batch)
|
||||
focus_task = get_focus_task_for_batch(batch_no, user.id)
|
||||
if not focus_task:
|
||||
raise NotFoundError('Focus task not found')
|
||||
@@ -312,7 +286,6 @@ def workspace_shipping_task_detail(task_no: str):
|
||||
task = get_task_for_user(task_no, user.id)
|
||||
if not task:
|
||||
raise NotFoundError('Not found')
|
||||
_maybe_recheck_inventory_rpa_wait(task)
|
||||
return jsonify(serialize_task_detail(task))
|
||||
|
||||
@workspace_shipping_notice_bp.route('/shipping-tasks/<task_no>/chat-actions', methods=['GET'])
|
||||
|
||||
@@ -146,7 +146,7 @@ class Config:
|
||||
os.getenv('SHIPPING_NOTICE_AUTO_RPA_INVENTORY_ENABLED', 'true').lower() == 'true'
|
||||
)
|
||||
SHIPPING_NOTICE_RPA_INVENTORY_MAX_ATTEMPTS = int(
|
||||
os.getenv('SHIPPING_NOTICE_RPA_INVENTORY_MAX_ATTEMPTS') or '3'
|
||||
os.getenv('SHIPPING_NOTICE_RPA_INVENTORY_MAX_ATTEMPTS') or '1'
|
||||
)
|
||||
SHIPPING_NOTICE_RPA_INVENTORY_TIMEOUT_SECONDS = int(
|
||||
os.getenv('SHIPPING_NOTICE_RPA_INVENTORY_TIMEOUT_SECONDS') or '120'
|
||||
@@ -160,7 +160,7 @@ class Config:
|
||||
'SHIPPING_NOTICE_EXPORT_FILENAME_PATTERN',
|
||||
'shipment_{task_no}_{ts}.xlsx',
|
||||
)
|
||||
SHIPPING_NOTICE_AUTO_UPLOAD_ENABLED = os.getenv('SHIPPING_NOTICE_AUTO_UPLOAD_ENABLED', 'true').lower() == 'true'
|
||||
SHIPPING_NOTICE_AUTO_UPLOAD_ENABLED = os.getenv('SHIPPING_NOTICE_AUTO_UPLOAD_ENABLED', 'false').lower() == 'true'
|
||||
# Hxops 工作台 / 聊天按钮兜底串联(Dify 主路径走 auto_progress;画布 HTTP 不传 auto_chain_fallback)
|
||||
SHIPPING_NOTICE_AUTO_CHAIN_FALLBACK = os.getenv('SHIPPING_NOTICE_AUTO_CHAIN_FALLBACK', 'true').lower() == 'true'
|
||||
SHIPPING_NOTICE_RPA_UPLOAD_MAX_ATTEMPTS = int(os.getenv('SHIPPING_NOTICE_RPA_UPLOAD_MAX_ATTEMPTS') or '3')
|
||||
|
||||
@@ -6,7 +6,7 @@ backend/app/jobs/__init__.py
|
||||
逻辑:Web API enqueue;worker.py 调用 runner.run_forever。
|
||||
"""
|
||||
from app.jobs.types import JobStatus, JobType
|
||||
from app.jobs.queue import enqueue, enqueue_clean_job, enqueue_kb_job, enqueue_shipping_notice_job
|
||||
from app.jobs.queue import enqueue, enqueue_clean_job, enqueue_kb_job
|
||||
|
||||
__all__ = [
|
||||
'JobType',
|
||||
@@ -14,5 +14,4 @@ __all__ = [
|
||||
'enqueue',
|
||||
'enqueue_kb_job',
|
||||
'enqueue_clean_job',
|
||||
'enqueue_shipping_notice_job',
|
||||
]
|
||||
@@ -1,9 +1,9 @@
|
||||
"""
|
||||
backend/app/jobs/queue.py
|
||||
|
||||
用途:通用后台任务入队、领取与完成状态管理。
|
||||
依赖:models.Job、jobs.types、Flask app.config。
|
||||
逻辑:业务服务调用 enqueue 写入 jobs;worker 调用 claim/finish/fail 完成执行闭环。
|
||||
用途:通用后台任务入队、领取与完成状态管理,并保留旧 KB 入队兼容入口。
|
||||
依赖:models.Job、jobs.types、Flask app.config、knowledge_cleaning 队列适配层。
|
||||
逻辑:业务服务调用 enqueue 写入 jobs;旧 KB 清洗入口委托 legacy KbJob 队列;worker 调用 claim/finish/fail 完成执行闭环。
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
@@ -15,6 +15,7 @@ from flask import current_app
|
||||
from sqlalchemy.exc import OperationalError
|
||||
|
||||
from app import db
|
||||
from app.core.errors import ValidationError
|
||||
from app.jobs.types import JobType
|
||||
from app.models import Job
|
||||
|
||||
@@ -65,6 +66,32 @@ def _find_shipping_notice_job_id(task_no: str) -> int | None:
|
||||
return None
|
||||
|
||||
|
||||
def enqueue_kb_job(job_id: int) -> tuple[bool, str]:
|
||||
"""
|
||||
兼容旧知识库后台任务入队入口。
|
||||
|
||||
Args:
|
||||
job_id: KbJob 主键;由清洗、路径上传、Dify 同步等知识库流程传入。
|
||||
Returns:
|
||||
(是否接受入队, 队列状态说明)。
|
||||
"""
|
||||
from app.services.knowledge_cleaning.queue_service import enqueue_kb_job as _enqueue_kb_job
|
||||
|
||||
return _enqueue_kb_job(job_id)
|
||||
|
||||
|
||||
def enqueue_clean_job(job_id: int) -> tuple[bool, str]:
|
||||
"""
|
||||
兼容旧清洗任务入队入口。
|
||||
|
||||
Args:
|
||||
job_id: clean 类型 KbJob 主键。
|
||||
Returns:
|
||||
(是否接受入队, 队列状态说明)。
|
||||
"""
|
||||
return enqueue_kb_job(job_id)
|
||||
|
||||
|
||||
def enqueue(
|
||||
job_type: JobType | str,
|
||||
payload: dict[str, Any],
|
||||
@@ -96,6 +123,15 @@ def enqueue(
|
||||
scheduled_at: 未来时间则延迟到该时间后才可被 worker 领取。
|
||||
"""
|
||||
normalized_type = _normalize_job_type(job_type)
|
||||
if normalized_type in {JobType.KB_CLEAN.value, JobType.KB_DIFY_SYNC.value}:
|
||||
raw_job_id = (payload or {}).get("job_id") if isinstance(payload, dict) else None
|
||||
if not raw_job_id:
|
||||
raise ValidationError("job_id is required")
|
||||
ok, message_text = enqueue_kb_job(int(raw_job_id))
|
||||
if not ok:
|
||||
raise ValidationError(message_text or "enqueue kb job failed")
|
||||
return int(raw_job_id)
|
||||
|
||||
normalized_domain = str(domain or "").strip() or "default"
|
||||
normalized_ref = str(business_ref or correlation_id or "").strip() or None
|
||||
if not normalized_type:
|
||||
|
||||
@@ -340,6 +340,8 @@ def match_inventory(payload: dict[str, Any]) -> dict[str, Any]:
|
||||
task=task,
|
||||
message=match_summary,
|
||||
data=serialize_task_for_tool(task),
|
||||
stop_agent_turn=True,
|
||||
forbidden_next_tools=["generate_shipment_excel", "upload_to_freight"],
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -74,7 +74,7 @@ _MESSAGES: dict[str, dict[str, str]] = {
|
||||
"workflow.decision.fulfillment_running": "发货通知已确认,后台继续处理库存与后续步骤。",
|
||||
"workflow.decision.rematch_running": "已提交重新匹配请求,后台继续处理。",
|
||||
"workflow.decision.mapping_confirmed_running": "库存字段对齐已确认,后台继续处理匹配与后续步骤。",
|
||||
"workflow.decision.task_not_found": "未找到任务。用户说「确认/重新解析/驳回」时禁止 create_task。请先 get_task_status(conversation_id=...) 或 submit_decision 带上任务编号。",
|
||||
"workflow.decision.task_not_found": "未找到明确任务。用户说「确认/重新解析/驳回」时禁止 create_task;多票会话必须带任务编号。",
|
||||
"workflow.decision.rejected": "已驳回该发货任务。",
|
||||
"workflow.decision.closed": "已关闭该发货任务(可在同一会话重新开新单)。",
|
||||
"workflow.decision.shortage_confirm_blocked": "库存不足,无法使用 confirm 整单确认。请 reparse_inventory、rematch 或 reject。",
|
||||
@@ -209,7 +209,7 @@ _MESSAGES: dict[str, dict[str, str]] = {
|
||||
"workflow.decision.fulfillment_running": "The shipping notice is confirmed. The backend is continuing inventory handling and the remaining steps.",
|
||||
"workflow.decision.rematch_running": "The rematch request has been submitted. The backend is continuing processing.",
|
||||
"workflow.decision.mapping_confirmed_running": "The inventory mapping is confirmed. The backend is continuing matching and the remaining steps.",
|
||||
"workflow.decision.task_not_found": "Task not found. When the user says confirm / re-parse / reject, do not call create_task. Please call get_task_status(conversation_id=...) first or pass the task ID to submit_decision.",
|
||||
"workflow.decision.task_not_found": "No unambiguous task was found. When the user says confirm / re-parse / reject, do not call create_task; multi-task conversations must include the task ID.",
|
||||
"workflow.decision.rejected": "The shipping task has been rejected.",
|
||||
"workflow.decision.closed": "The shipping task has been closed. You may start a new one in the same conversation.",
|
||||
"workflow.decision.shortage_confirm_blocked": "Inventory is insufficient. You cannot use confirm for the whole task. Please use reparse_inventory, rematch, or reject.",
|
||||
@@ -344,7 +344,7 @@ _MESSAGES: dict[str, dict[str, str]] = {
|
||||
"workflow.decision.fulfillment_running": "ยืนยันใบแจ้งส่งสินค้าแล้ว ระบบหลังบ้านกำลังดำเนินการสต็อกและขั้นตอนถัดไปต่อ",
|
||||
"workflow.decision.rematch_running": "ส่งคำขอจับคู่ใหม่แล้ว ระบบหลังบ้านกำลังดำเนินการต่อ",
|
||||
"workflow.decision.mapping_confirmed_running": "ยืนยันการจับคู่คอลัมน์สต็อกแล้ว ระบบหลังบ้านกำลังดำเนินการจับคู่และขั้นตอนถัดไปต่อ",
|
||||
"workflow.decision.task_not_found": "ไม่พบงาน เมื่อผู้ใช้พูดว่ายืนยัน / แยกใหม่ / ปฏิเสธ ห้ามเรียก create_task โปรดเรียก get_task_status(conversation_id=...) ก่อน หรือส่ง task ID ให้ submit_decision",
|
||||
"workflow.decision.task_not_found": "ไม่พบงานที่ระบุได้ชัดเจน เมื่อผู้ใช้พูดว่ายืนยัน / แยกใหม่ / ปฏิเสธ ห้ามเรียก create_task และหากมีหลายงานต้องส่ง task ID มาด้วย",
|
||||
"workflow.decision.rejected": "ปฏิเสธงานจัดส่งนี้แล้ว",
|
||||
"workflow.decision.closed": "ปิดงานจัดส่งนี้แล้ว และสามารถเริ่มงานใหม่ในบทสนทนาเดิมได้",
|
||||
"workflow.decision.shortage_confirm_blocked": "สต็อกไม่เพียงพอ จึงไม่สามารถใช้ confirm เพื่อยืนยันทั้งงานได้ โปรดใช้ reparse_inventory, rematch หรือ reject",
|
||||
|
||||
@@ -263,7 +263,7 @@ def ensure_inventory_via_rpa(task: ShippingTask, *, mode: str) -> dict[str, Any]
|
||||
# 已达到最大次数时直接转人工;若目录里已有最新库存文件,则优先吃掉落盘结果而不是再触发一次 RPA。
|
||||
attempts = inventory_rpa_attempts(task)
|
||||
max_attempts = max_rpa_inventory_attempts()
|
||||
if attempts >= max_attempts and not task.inventory_lines_json:
|
||||
if attempts >= max_attempts and not task.inventory_lines_json and not manual_retry_round:
|
||||
apply_task_transition(task, TaskTransition.RPA_EXHAUSTED)
|
||||
task.error_message = "已多次尝试仍无法通过 RPA 获取库存"
|
||||
log_task_event(task, "inventory_rpa_exhausted", {"attempts": attempts})
|
||||
@@ -312,7 +312,7 @@ def ensure_inventory_via_rpa(task: ShippingTask, *, mode: str) -> dict[str, Any]
|
||||
else "已触发 RPA 库存导出,等待结果"
|
||||
)
|
||||
progress_detail = (
|
||||
f"新一轮第 {attempt_no}/{max_attempts} 次尝试"
|
||||
f"手动第 {attempt_no} 次尝试"
|
||||
if manual_retry_round
|
||||
else f"第 {attempt_no}/{max_attempts} 次尝试"
|
||||
)
|
||||
@@ -324,7 +324,7 @@ def ensure_inventory_via_rpa(task: ShippingTask, *, mode: str) -> dict[str, Any]
|
||||
message=progress_message,
|
||||
progress_percent=60,
|
||||
current=attempt_no,
|
||||
total=max_attempts,
|
||||
total=max(attempt_no, max_attempts),
|
||||
detail=progress_detail,
|
||||
extra={"manual_retry_round": manual_retry_round} if manual_retry_round else None,
|
||||
)
|
||||
@@ -334,7 +334,7 @@ def ensure_inventory_via_rpa(task: ShippingTask, *, mode: str) -> dict[str, Any]
|
||||
{"trigger": trigger, "attempt": attempt_no, "manual_retry_round": manual_retry_round},
|
||||
)
|
||||
|
||||
if attempt_no >= max_attempts and not task.inventory_lines_json:
|
||||
if attempt_no >= max_attempts and not task.inventory_lines_json and not manual_retry_round:
|
||||
apply_task_transition(task, TaskTransition.RPA_EXHAUSTED)
|
||||
task.error_message = "已多次尝试仍无法通过 RPA 获取库存"
|
||||
log_task_event(task, "inventory_rpa_exhausted", {"attempts": attempt_no})
|
||||
@@ -347,7 +347,7 @@ def ensure_inventory_via_rpa(task: ShippingTask, *, mode: str) -> dict[str, Any]
|
||||
)
|
||||
|
||||
response_prefix = (
|
||||
f"已手动重新触发 RPA 库存导出(新一轮第 {attempt_no}/{max_attempts} 次)。"
|
||||
f"已手动重新触发 RPA 库存导出(手动第 {attempt_no} 次)。"
|
||||
if manual_retry_round
|
||||
else f"已触发 RPA 库存导出(第 {attempt_no}/{max_attempts} 次)。"
|
||||
)
|
||||
@@ -355,7 +355,7 @@ def ensure_inventory_via_rpa(task: ShippingTask, *, mode: str) -> dict[str, Any]
|
||||
return tool_response(
|
||||
status="running",
|
||||
task_id=task.task_no,
|
||||
message=f"{response_prefix}若 {timeout_seconds}s 内无回调/无落盘文件,可继续重试;超过最大次数将转人工上传。",
|
||||
message=f"{response_prefix}若 {timeout_seconds}s 内无回调/无落盘文件,可手动重试,或上传库存 Excel。",
|
||||
data={
|
||||
**serialize_task_for_tool(task),
|
||||
"rpa": {
|
||||
|
||||
@@ -19,10 +19,10 @@ from app.services.shipping_notice.inventory_sources import build_rpa_inventory_s
|
||||
ROUTE_RULES: tuple[dict[str, Any], ...] = (
|
||||
{"source_code": "DSV360_AWSBI", "aliases": ("BISON", "AWSBI")},
|
||||
{"source_code": "DSV360_AWSCV", "aliases": ("CINCINNATI", "CVG", "AWSCV")},
|
||||
{"source_code": "DSV360_AWSDU", "aliases": ("DUB", "DUBLIN")},
|
||||
{"source_code": "DSV360_AWSDU", "aliases": ("DBS DUB", "DUB", "DUBLIN")},
|
||||
{"source_code": "DSV360_AWSAMS", "aliases": ("MOERDIJK", "AMS", "AWSAMS")},
|
||||
{"source_code": "DSV360_AWSSL", "aliases": ("USLCK", "SALT LAKE CITY", "SALTLAKECITY")},
|
||||
{"source_code": "DSV360_AWSSG", "aliases": ("SINGAPORE", "SG")},
|
||||
{"source_code": "DSV360_AWSSG", "aliases": ("SINGAPORE HUB", "SINGAPORE", "SG")},
|
||||
{"source_code": "CRANE_TZR2", "aliases": ("TZR2", "THAILAND")},
|
||||
)
|
||||
|
||||
|
||||
@@ -171,7 +171,8 @@ def build_dify_openapi_spec(base_url: str) -> dict[str, Any]:
|
||||
{
|
||||
"task_id": task_id,
|
||||
MAP_JSON: _str_prop(
|
||||
'列映射 JSON,含 sku/reservation_id/available_qty;可选 match_rule(LLM 自然语言匹配说明,缺省则后端动态兜底)'
|
||||
"Dify Tool 参数使用 JSON 字符串,内容含 sku/reservation_id/available_qty;"
|
||||
"可选 match_rule(LLM 自然语言匹配说明)与 match_key(匹配键列表)。"
|
||||
),
|
||||
},
|
||||
required=["task_id", MAP_JSON],
|
||||
|
||||
@@ -201,8 +201,17 @@ def extract_task_no_from_text(text: str) -> str | None:
|
||||
return match.group(0).upper() if match else None
|
||||
|
||||
|
||||
def resolve_task_from_payload(payload: dict[str, Any]) -> ShippingTask | None:
|
||||
"""按 task_id/task_no、文本内嵌 SN- 或 conversation_id 解析任务(只读)。"""
|
||||
def resolve_task_from_payload(
|
||||
payload: dict[str, Any],
|
||||
*,
|
||||
allow_conversation_fallback: bool = True,
|
||||
) -> ShippingTask | None:
|
||||
"""
|
||||
按 task_id/task_no、文本内嵌 SN- 或 conversation_id 解析任务(只读)。
|
||||
|
||||
核心逻辑:显式任务号永远优先;conversation_id 仅在同会话下只有一票可操作任务时回退,
|
||||
多票场景返回 None,避免用户只说“确认/继续”时误推进最近一票。
|
||||
"""
|
||||
if not isinstance(payload, dict):
|
||||
return None
|
||||
|
||||
@@ -218,14 +227,20 @@ def resolve_task_from_payload(payload: dict[str, Any]) -> ShippingTask | None:
|
||||
if task:
|
||||
return task
|
||||
|
||||
if not allow_conversation_fallback:
|
||||
return None
|
||||
|
||||
conv_id = str(payload.get("conversation_id") or "").strip()
|
||||
if conv_id:
|
||||
return (
|
||||
candidates = (
|
||||
ShippingTask.query.filter_by(conversation_id=conv_id)
|
||||
.filter(ShippingTask.process_status.notin_(["rejected"]))
|
||||
.filter(ShippingTask.process_status.notin_(["rejected", "closed", "uploaded"]))
|
||||
.order_by(ShippingTask.id.desc())
|
||||
.first()
|
||||
.limit(2)
|
||||
.all()
|
||||
)
|
||||
if len(candidates) == 1:
|
||||
return candidates[0]
|
||||
return None
|
||||
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ from datetime import datetime
|
||||
|
||||
from app.models import ShippingTask, ShippingTaskEvent
|
||||
|
||||
DEFAULT_RPA_INVENTORY_MAX_ATTEMPTS = 3
|
||||
DEFAULT_RPA_INVENTORY_MAX_ATTEMPTS = 1
|
||||
DEFAULT_RPA_UPLOAD_MAX_ATTEMPTS = 3
|
||||
|
||||
_INVENTORY_SUCCESS_EVENTS = {
|
||||
|
||||
@@ -130,7 +130,7 @@ CHECKPOINT_REGISTRY: dict[str, tuple[str, ...]] = {
|
||||
"retry_resolve_inventory_source",
|
||||
"upload_inventory_file",
|
||||
),
|
||||
CP_RSV_REQ: ("reparse", "edit_inventory_mapping", "upload_inventory_file", "reject"),
|
||||
CP_RSV_REQ: ("replace_notice_file", "reparse", "reject"),
|
||||
RS_SHORTAGE_REVIEW: ("reparse_inventory", "correct_inventory_mapping", "rematch", "reject"),
|
||||
CP_NOTICE_TEXT_EXTRACTION_FAILED: ("replace_notice_file", "reparse", "reject"),
|
||||
CP_UPLOAD_FAILED: ("retry_upload", "download_excel", "mark_manual_uploaded"),
|
||||
@@ -248,9 +248,9 @@ def ui_state_for_checkpoint(checkpoint: str | None) -> TaskUiState:
|
||||
def upload_req_options_for_task(task: ShippingTask) -> list[str]:
|
||||
"""upload_req checkpoint 的动作子集,随 RPA 重试次数动态收缩。"""
|
||||
if task.pending_human_reason == PH_RPA_EXHAUSTED:
|
||||
return list(OPTIONS_UPLOAD_FILE_ONLY)
|
||||
return list(OPTIONS_RPA_OR_UPLOAD)
|
||||
if inventory_rpa_attempts(task) >= max_rpa_inventory_attempts():
|
||||
return list(OPTIONS_UPLOAD_FILE_ONLY)
|
||||
return list(OPTIONS_RPA_OR_UPLOAD)
|
||||
if task.pending_human_reason in {PH_INV_UNAVAIL, PH_RPA_PENDING}:
|
||||
return list(OPTIONS_RPA_OR_UPLOAD)
|
||||
return list(CHECKPOINT_REGISTRY[CP_UPLOAD_REQ])
|
||||
|
||||
@@ -20,6 +20,7 @@ from app.services.shipping_notice.agent_resolver import resolve_chat_agent
|
||||
from app.services.shipping_notice.constants import (
|
||||
CP_NOTICE_TEXT_EXTRACTION_FAILED,
|
||||
CP_PARSE_OK,
|
||||
CP_RSV_REQ,
|
||||
CP_TASK_EXISTS,
|
||||
RS_PARSE_REVIEW,
|
||||
)
|
||||
@@ -40,6 +41,7 @@ from app.services.shipping_notice.query_service import (
|
||||
serialize_task as qs_serialize_task,
|
||||
serialize_task_for_tool,
|
||||
)
|
||||
from app.services.shipping_notice.reservation_id import extract_reservation_id
|
||||
from app.services.shipping_notice.state_machine import TaskTransition, apply_task_transition
|
||||
from app.services.shipping_notice.tool_response import tool_response
|
||||
from app.services.shipping_notice.user_facing_status import user_facing_task_stage
|
||||
@@ -101,6 +103,29 @@ def _has_parse_review_content(task: ShippingTask, lines: list[Any]) -> bool:
|
||||
)
|
||||
|
||||
|
||||
def _missing_reservation_lines(lines: list[Any]) -> list[dict[str, Any]]:
|
||||
"""
|
||||
检查解析结果中缺少 Reservation ID / COM ID 的订单行。
|
||||
|
||||
核心逻辑:复用库存匹配阶段的 Reservation ID 提取规则;解析阶段缺失时提前阻断,
|
||||
避免用户确认后才在库存匹配阶段失败。
|
||||
"""
|
||||
missing: list[dict[str, Any]] = []
|
||||
for index, line in enumerate(lines):
|
||||
if not isinstance(line, dict):
|
||||
continue
|
||||
if extract_reservation_id(line.get("reservation_id")):
|
||||
continue
|
||||
missing.append(
|
||||
{
|
||||
"line_index": index,
|
||||
"sku": str(line.get("sku") or "").strip(),
|
||||
"reservation_id": str(line.get("reservation_id") or "").strip(),
|
||||
}
|
||||
)
|
||||
return missing
|
||||
|
||||
|
||||
def start_task_orchestrator(task_no: str | None) -> bool:
|
||||
"""延迟导入 orchestrator,既打断循环依赖,也保留单测 monkeypatch 入口。"""
|
||||
from app.services.shipping_notice.batch_orchestrator import start_task_orchestrator as _start
|
||||
@@ -565,7 +590,45 @@ def parse_notice(payload: dict[str, Any]) -> dict[str, Any]:
|
||||
"warnings": warnings,
|
||||
}
|
||||
|
||||
# [STEP 3] 低置信度停待人审;否则标记 parsed 并准备后续库存链路。
|
||||
# [STEP 3] Reservation ID 是后续匹配的硬前置;解析阶段缺失时直接阻断,禁止进入普通确认。
|
||||
missing_reservation = _missing_reservation_lines(lines)
|
||||
if missing_reservation:
|
||||
apply_task_transition(task, TaskTransition.RSV_REQUIRED)
|
||||
task.error_message = "解析失败:未识别到 Reservation ID / COM ID(预定单号)"
|
||||
set_task_step_progress(
|
||||
task,
|
||||
step_key="step2_parse_confirm",
|
||||
step_title="确认解析",
|
||||
status="failed",
|
||||
message="解析失败:未识别到预定单号",
|
||||
progress_percent=100,
|
||||
current=len(lines) - len(missing_reservation),
|
||||
total=len(lines),
|
||||
detail="请重新上传包含 Reservation ID / COM ID 的发货通知,或重新解析后补充预定单号。",
|
||||
extra={"warnings": warnings, "missing_reservation": missing_reservation[:5]},
|
||||
)
|
||||
detail = {
|
||||
"missing_count": len(missing_reservation),
|
||||
"missing_preview": missing_reservation[:5],
|
||||
"warnings": warnings,
|
||||
}
|
||||
log_task_event(task, "notice_reservation_id_missing", detail)
|
||||
db.session.commit()
|
||||
return tool_response(
|
||||
status="needs_human",
|
||||
task=task,
|
||||
message=(
|
||||
"解析失败:未识别到 Reservation ID / COM ID(预定单号),"
|
||||
"当前任务无法继续匹配库存。请重新上传包含该字段的通知,或重新解析后补充预定单号。"
|
||||
),
|
||||
data={**serialize_task_for_tool(task), "missing_reservation": detail},
|
||||
checkpoint=CP_RSV_REQ,
|
||||
human_options=["replace_notice_file", "reparse", "reject"],
|
||||
stop_agent_turn=True,
|
||||
forbidden_next_tools=["ensure_inventory", "parse_inventory", "match_inventory", "generate_shipment_excel"],
|
||||
)
|
||||
|
||||
# [STEP 4] 低置信度停待人审;否则标记 parsed 并准备后续库存链路。
|
||||
if confidence < float(current_app.config.get("SHIPPING_NOTICE_PARSE_CONFIDENCE_THRESHOLD") or 0.7):
|
||||
if not _has_parse_review_content(task, lines):
|
||||
apply_task_transition(task, TaskTransition.NOTICE_TEXT_EXTRACTION_FAILED)
|
||||
@@ -1068,9 +1131,9 @@ def retry_task(payload: dict[str, Any]) -> dict[str, Any]:
|
||||
def get_task_status(payload: dict[str, Any]) -> dict[str, Any]:
|
||||
"""
|
||||
查询任务当前进度(Tool / 工作台共用)。
|
||||
【AI 触发时机】:当 Agent 丢失上下文、只知道 conversation_id,或需要先确认当前卡在哪个检查点时调用。
|
||||
【AI 触发时机】:当 Agent 需要按任务编号确认当前卡在哪个检查点时调用;多票会话必须传 task_id/task_no。
|
||||
|
||||
核心逻辑:按任务号或 conversation_id 定位任务,并返回面向用户的当前阶段描述与任务快照。
|
||||
核心逻辑:优先按任务号定位;conversation_id 仅在同会话下唯一可操作任务时回退,并返回面向用户的当前阶段描述。
|
||||
Args:
|
||||
payload: 可包含 task_id、task_no、conversation_id 等定位参数。
|
||||
|
||||
@@ -1081,7 +1144,7 @@ def get_task_status(payload: dict[str, Any]) -> dict[str, Any]:
|
||||
if not task:
|
||||
return tool_response(
|
||||
status="failed",
|
||||
message="未找到任务。请提供任务编号或 conversation_id(Dify 会话 ID)。",
|
||||
message="未找到明确任务。请提供任务编号;多票会话不能只靠 conversation_id 查询或继续。",
|
||||
)
|
||||
return tool_response(
|
||||
status="ok",
|
||||
|
||||
@@ -41,6 +41,10 @@ def pytest_configure(config):
|
||||
"markers",
|
||||
"auto_rpa: 发货通知测试启用 auto_progress + RPA 自动链",
|
||||
)
|
||||
config.addinivalue_line(
|
||||
"markers",
|
||||
"rpa_e2e: 真实货代 RPA 浏览器导出测试,默认跳过,需 FREIGHT_RPA_E2E=true",
|
||||
)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
|
||||
@@ -0,0 +1,241 @@
|
||||
"""scripts/rpa/freight_rpa_worker.py tests.
|
||||
|
||||
覆盖货代 RPA worker 对真实库存导出 trigger JSON 的消费路径:
|
||||
1. 读取 inventory_export_SN-20260629-2EDADC77.json。
|
||||
2. 按 DSV360/AWSDU 库存源分发下载。
|
||||
3. 成功后回调 hxops,并把 trigger 移入 processed。
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import importlib.util
|
||||
import json
|
||||
import os
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
from openpyxl import load_workbook
|
||||
|
||||
|
||||
def _repo_root() -> Path:
|
||||
return Path(__file__).resolve().parents[2]
|
||||
|
||||
|
||||
def _load_freight_rpa_worker():
|
||||
module_path = _repo_root() / "scripts" / "rpa" / "freight_rpa_worker.py"
|
||||
spec = importlib.util.spec_from_file_location("freight_rpa_worker_under_test", module_path)
|
||||
assert spec is not None
|
||||
assert spec.loader is not None
|
||||
module = importlib.util.module_from_spec(spec)
|
||||
spec.loader.exec_module(module)
|
||||
return module
|
||||
|
||||
|
||||
def test_inventory_export_trigger_2edadc77_reports_success(monkeypatch, tmp_path):
|
||||
"""基于失败样本 SN-20260629-2EDADC77 验证 RPA 库存导出 trigger 可被正常消费。"""
|
||||
worker = _load_freight_rpa_worker()
|
||||
source_trigger = (
|
||||
_repo_root()
|
||||
/ "backend"
|
||||
/ "data"
|
||||
/ "shipping_notice"
|
||||
/ "freight_rpa"
|
||||
/ "inventory_triggers"
|
||||
/ "failed"
|
||||
/ "inventory_export_SN-20260629-2EDADC77.json"
|
||||
)
|
||||
trigger_dir = tmp_path / "inventory_triggers"
|
||||
trigger_dir.mkdir()
|
||||
trigger_path = trigger_dir / source_trigger.name
|
||||
trigger_path.write_text(source_trigger.read_text(encoding="utf-8"), encoding="utf-8")
|
||||
|
||||
drop_dir = tmp_path / "drop"
|
||||
drop_dir.mkdir()
|
||||
processed_dir = trigger_dir / "processed"
|
||||
callbacks: list[tuple[str, dict]] = []
|
||||
download_calls: list[dict] = []
|
||||
|
||||
def fake_download_inventory_with_browser(trigger: dict, target_drop_dir: Path) -> Path:
|
||||
download_calls.append(trigger)
|
||||
out_file = target_drop_dir / "inventory_SN-20260629-2EDADC77_DSV360_AWSDU.xlsx"
|
||||
out_file.write_bytes(b"fake inventory content")
|
||||
return out_file
|
||||
|
||||
monkeypatch.setenv("FREIGHT_RPA_MOCK", "false")
|
||||
monkeypatch.setattr(worker, "_download_inventory_with_browser", fake_download_inventory_with_browser)
|
||||
monkeypatch.setattr(worker, "_post_callback", lambda path, payload: callbacks.append((path, payload)))
|
||||
|
||||
worker._handle_inventory_trigger(trigger_path, drop_dir, processed_dir)
|
||||
|
||||
assert len(download_calls) == 1
|
||||
trigger = download_calls[0]
|
||||
assert trigger["task_no"] == "SN-20260629-2EDADC77"
|
||||
assert trigger["attempt"] == 3
|
||||
assert trigger["rpa_inventory_source"]["source_code"] == "DSV360_AWSDU"
|
||||
assert trigger["rpa_inventory_source"]["source_type"] == "dsv360"
|
||||
assert trigger["rpa_inventory_source"]["query"]["program_label"] == "AWSDU - Prod (JDA)"
|
||||
assert trigger["rpa_inventory_source"]["query"]["owner_code"] == "CADU-0000000100"
|
||||
|
||||
assert callbacks == [
|
||||
(
|
||||
"/api/shipping-notice/rpa/inventory-ready",
|
||||
{
|
||||
"task_no": "SN-20260629-2EDADC77",
|
||||
"success": True,
|
||||
"file_path": str(drop_dir / "inventory_SN-20260629-2EDADC77_DSV360_AWSDU.xlsx"),
|
||||
"source_code": "DSV360_AWSDU",
|
||||
},
|
||||
)
|
||||
]
|
||||
assert not trigger_path.exists()
|
||||
assert (processed_dir / source_trigger.name).is_file()
|
||||
|
||||
processed_payload = json.loads((processed_dir / source_trigger.name).read_text(encoding="utf-8"))
|
||||
assert processed_payload["task_no"] == "SN-20260629-2EDADC77"
|
||||
|
||||
|
||||
def test_inventory_export_trigger_2edadc77_mock_writes_inventory_excel(monkeypatch, tmp_path):
|
||||
"""基于失败样本验证 mock RPA 会真实导出一个可打开的库存 Excel。"""
|
||||
worker = _load_freight_rpa_worker()
|
||||
source_trigger = (
|
||||
_repo_root()
|
||||
/ "backend"
|
||||
/ "data"
|
||||
/ "shipping_notice"
|
||||
/ "freight_rpa"
|
||||
/ "inventory_triggers"
|
||||
/ "failed"
|
||||
/ "inventory_export_SN-20260629-2EDADC77.json"
|
||||
)
|
||||
trigger_dir = tmp_path / "inventory_triggers"
|
||||
trigger_dir.mkdir()
|
||||
trigger_path = trigger_dir / source_trigger.name
|
||||
trigger_path.write_text(source_trigger.read_text(encoding="utf-8"), encoding="utf-8")
|
||||
|
||||
drop_dir = tmp_path / "drop"
|
||||
drop_dir.mkdir()
|
||||
processed_dir = trigger_dir / "processed"
|
||||
callbacks: list[tuple[str, dict]] = []
|
||||
|
||||
monkeypatch.setenv("FREIGHT_RPA_MOCK", "true")
|
||||
monkeypatch.delenv("FREIGHT_RPA_SAMPLE_INVENTORY", raising=False)
|
||||
monkeypatch.setattr(worker, "_post_callback", lambda path, payload: callbacks.append((path, payload)))
|
||||
|
||||
worker._handle_inventory_trigger(trigger_path, drop_dir, processed_dir)
|
||||
|
||||
exported_files = list(drop_dir.glob("inventory_SN-20260629-2EDADC77_*.xlsx"))
|
||||
assert len(exported_files) == 1
|
||||
exported = exported_files[0]
|
||||
wb = load_workbook(exported, data_only=True, read_only=True)
|
||||
try:
|
||||
ws = wb.active
|
||||
rows = list(ws.iter_rows(values_only=True))
|
||||
finally:
|
||||
wb.close()
|
||||
|
||||
assert rows[0] == ("料号", "可用数量")
|
||||
assert rows[1] == ("A001", 100)
|
||||
assert rows[2] == ("A002", 50)
|
||||
assert callbacks == [
|
||||
(
|
||||
"/api/shipping-notice/rpa/inventory-ready",
|
||||
{
|
||||
"task_no": "SN-20260629-2EDADC77",
|
||||
"success": True,
|
||||
"file_path": str(exported),
|
||||
"source_code": "DSV360_AWSDU",
|
||||
},
|
||||
)
|
||||
]
|
||||
assert not trigger_path.exists()
|
||||
assert (processed_dir / source_trigger.name).is_file()
|
||||
|
||||
|
||||
def test_open_browser_uses_configured_browser_channel(monkeypatch, tmp_path):
|
||||
"""真实 RPA 可通过本机 Edge/Chrome channel 启动,避免强制下载 Playwright Chromium。"""
|
||||
worker = _load_freight_rpa_worker()
|
||||
observed: dict[str, object] = {}
|
||||
|
||||
class _FakePage:
|
||||
def set_default_timeout(self, value: int) -> None:
|
||||
observed["timeout"] = value
|
||||
|
||||
class _FakeContext:
|
||||
pages = [_FakePage()]
|
||||
|
||||
class _FakeChromium:
|
||||
def launch_persistent_context(self, profile: str, **kwargs):
|
||||
observed["profile"] = profile
|
||||
observed["kwargs"] = kwargs
|
||||
return _FakeContext()
|
||||
|
||||
class _FakePlaywright:
|
||||
chromium = _FakeChromium()
|
||||
|
||||
class _FakeStarter:
|
||||
def start(self):
|
||||
return _FakePlaywright()
|
||||
|
||||
monkeypatch.setenv("FREIGHT_RPA_BROWSER_PROFILE_DIR", str(tmp_path / "profile"))
|
||||
monkeypatch.setenv("FREIGHT_RPA_HEADLESS", "false")
|
||||
monkeypatch.setenv("FREIGHT_RPA_BROWSER_CHANNEL", "msedge")
|
||||
monkeypatch.delenv("FREIGHT_RPA_BROWSER_EXECUTABLE_PATH", raising=False)
|
||||
monkeypatch.setattr(worker, "_require_playwright", lambda: (_FakeStarter, object))
|
||||
|
||||
_playwright, context, page = worker._open_browser(tmp_path / "downloads")
|
||||
|
||||
assert context is not None
|
||||
assert page is not None
|
||||
assert observed["profile"] == str(tmp_path / "profile")
|
||||
assert observed["kwargs"] == {
|
||||
"headless": False,
|
||||
"accept_downloads": True,
|
||||
"downloads_path": str(tmp_path / "downloads"),
|
||||
"channel": "msedge",
|
||||
}
|
||||
|
||||
|
||||
@pytest.mark.rpa_e2e
|
||||
def test_inventory_export_trigger_2edadc77_downloads_real_file(monkeypatch, tmp_path):
|
||||
"""
|
||||
手动集成测试:使用真实浏览器 Driver 从 DSV360 导出库存文件。
|
||||
|
||||
默认跳过;仅当 FREIGHT_RPA_E2E=true 时执行。执行前需准备 DSV 登录态或账号密码:
|
||||
- FREIGHT_RPA_MOCK=false
|
||||
- FREIGHT_RPA_HEADLESS=false(建议首次调试)
|
||||
- FREIGHT_RPA_BROWSER_PROFILE_DIR=<已登录 profile,可选>
|
||||
- FREIGHT_RPA_DSV_USERNAME / FREIGHT_RPA_DSV_PASSWORD(可选)
|
||||
"""
|
||||
if str(os.getenv("FREIGHT_RPA_E2E") or "").strip().lower() != "true":
|
||||
pytest.skip("set FREIGHT_RPA_E2E=true to run real freight RPA export")
|
||||
|
||||
worker = _load_freight_rpa_worker()
|
||||
source_trigger = (
|
||||
_repo_root()
|
||||
/ "backend"
|
||||
/ "data"
|
||||
/ "shipping_notice"
|
||||
/ "freight_rpa"
|
||||
/ "inventory_triggers"
|
||||
/ "failed"
|
||||
/ "inventory_export_SN-20260629-2EDADC77.json"
|
||||
)
|
||||
trigger = json.loads(source_trigger.read_text(encoding="utf-8"))
|
||||
drop_dir = tmp_path / "drop"
|
||||
drop_dir.mkdir()
|
||||
|
||||
monkeypatch.setenv("FREIGHT_RPA_MOCK", "false")
|
||||
if not os.getenv("FREIGHT_RPA_HEADLESS"):
|
||||
monkeypatch.setenv("FREIGHT_RPA_HEADLESS", "false")
|
||||
if not os.getenv("FREIGHT_RPA_BROWSER_PROFILE_DIR"):
|
||||
monkeypatch.setenv(
|
||||
"FREIGHT_RPA_BROWSER_PROFILE_DIR",
|
||||
str(tmp_path / "browser_profile"),
|
||||
)
|
||||
|
||||
out_file = worker._download_inventory_with_browser(trigger, drop_dir)
|
||||
|
||||
assert out_file.is_file()
|
||||
assert out_file.parent == drop_dir
|
||||
assert out_file.suffix.lower() in {".xlsx", ".xls", ".csv"}
|
||||
assert out_file.stat().st_size > 0
|
||||
@@ -21,6 +21,7 @@ from app.services.shipping_notice.progress_workflow import auto_progress
|
||||
|
||||
|
||||
def _tool_headers(app):
|
||||
app.config["SHIPPING_NOTICE_TOOL_API_KEY"] = ""
|
||||
app.config["INTEGRATION_API_KEY"] = "test-integration-key"
|
||||
return {
|
||||
"Content-Type": "application/json",
|
||||
@@ -123,6 +124,46 @@ def test_create_batch_tasks_and_switch_focus(app, client):
|
||||
assert task_rows[1].batch_total == 2
|
||||
|
||||
|
||||
def test_contract_batch_status_keeps_single_focus_without_advancing_other_tasks(app, client):
|
||||
"""契约:多任务会话只暴露一个 focus 指针;读取批次状态不能推进整批任务。"""
|
||||
headers = _tool_headers(app)
|
||||
create_res = client.post(
|
||||
"/api/shipping-notice/tools/create_batch",
|
||||
headers=headers,
|
||||
json={
|
||||
"conversation_id": "conv-contract-focus",
|
||||
"notice_items": [
|
||||
{"raw_text": "客户A 料号A001 x 1", "source_file_name": "A.pdf"},
|
||||
{"raw_text": "客户B 料号B001 x 2", "source_file_name": "B.pdf"},
|
||||
],
|
||||
},
|
||||
)
|
||||
data = create_res.get_json()
|
||||
batch_no = data["batch_no"]
|
||||
task_refs = [item["task_id"] for item in data["data"]["tasks"]]
|
||||
focus_task_no, other_task_no = task_refs
|
||||
|
||||
status_res = client.post(
|
||||
"/api/shipping-notice/tools/get_batch_status",
|
||||
headers=headers,
|
||||
json={"batch_no": batch_no},
|
||||
)
|
||||
status_data = status_res.get_json()
|
||||
|
||||
assert status_res.status_code == 200
|
||||
assert status_data["status"] == "ok"
|
||||
assert status_data["data"]["current_focus_task_no"] == focus_task_no
|
||||
assert [item["task_no"] for item in status_data["data"]["tasks"]] == task_refs
|
||||
|
||||
with app.app_context():
|
||||
rows = {
|
||||
task.task_no: task
|
||||
for task in ShippingTask.query.filter(ShippingTask.task_no.in_([focus_task_no, other_task_no])).all()
|
||||
}
|
||||
assert rows[focus_task_no].process_status == "created"
|
||||
assert rows[other_task_no].process_status == "created"
|
||||
|
||||
|
||||
def test_create_batch_defers_parse_without_structured(app, client):
|
||||
"""默认将 parse_notice 延后到 Dify,仅保存 raw_text。"""
|
||||
headers = _tool_headers(app)
|
||||
@@ -342,8 +383,8 @@ def test_auto_progress_inventory_trigger_failure_marks_step3(app):
|
||||
assert task.step_payload_json["current_step_progress"]["status"] == "needs_human"
|
||||
|
||||
|
||||
def test_workspace_task_detail_rechecks_timed_out_inventory_rpa(app, client, tmp_path):
|
||||
"""工作台查询遇到已超时 RPA 等待态时,应兜底复查并自动触发下一次库存导出。"""
|
||||
def test_workspace_task_detail_is_read_only_for_timed_out_inventory_rpa(app, client, tmp_path):
|
||||
"""工作台查询必须保持纯读;已超时 RPA 等待态也不能由 GET 触发补偿或事件落库。"""
|
||||
headers = _workspace_headers(app)
|
||||
app.config["SHIPPING_NOTICE_AUTO_PROGRESS_ENABLED"] = True
|
||||
app.config["SHIPPING_NOTICE_AUTO_RPA_INVENTORY_ENABLED"] = True
|
||||
@@ -394,11 +435,12 @@ def test_workspace_task_detail_rechecks_timed_out_inventory_rpa(app, client, tmp
|
||||
triggered = [event for event in events if event.event_type == "inventory_rpa_triggered"]
|
||||
failed = [event for event in events if event.event_type == "inventory_rpa_failed"]
|
||||
rechecked = [event for event in events if event.event_type == "inventory_rpa_wait_rechecked"]
|
||||
assert len(triggered) == 2
|
||||
assert len(failed) == 1
|
||||
assert len(rechecked) == 1
|
||||
assert triggered[-1].detail_json["attempt"] == 2
|
||||
assert task.step_payload_json["current_step_progress"]["current"] == 2
|
||||
assert len(triggered) == 1
|
||||
assert len(failed) == 0
|
||||
assert len(rechecked) == 0
|
||||
assert task.process_status == "waiting_inventory"
|
||||
assert task.pending_human_reason == "rpa_pending"
|
||||
assert not list((tmp_path / "inventory_triggers").glob("inventory_export_*.json"))
|
||||
|
||||
|
||||
def test_auto_progress_resolves_dub_inventory_source_into_rpa_trigger(app, tmp_path):
|
||||
|
||||
@@ -19,6 +19,7 @@ def test_ensure_inventory_auto_triggers_rpa_running(app, client, tmp_path):
|
||||
app.config["FREIGHT_RPA_INVENTORY_TRIGGER_DIR"] = str(trigger)
|
||||
app.config["SHIPPING_NOTICE_AUTO_RPA_INVENTORY_ENABLED"] = True
|
||||
app.config["SHIPPING_NOTICE_AUTO_PROGRESS_ENABLED"] = False
|
||||
app.config["SHIPPING_NOTICE_TOOL_API_KEY"] = ""
|
||||
app.config["INTEGRATION_API_KEY"] = "test-integration-key"
|
||||
|
||||
headers = _tool_headers()
|
||||
@@ -68,6 +69,7 @@ def test_rpa_report_inventory_callback_needs_mapping_review(app, client, tmp_pat
|
||||
drop = tmp_path / "drop"
|
||||
drop.mkdir()
|
||||
app.config["FREIGHT_INVENTORY_DROP_DIR"] = str(drop)
|
||||
app.config["SHIPPING_NOTICE_TOOL_API_KEY"] = ""
|
||||
app.config["INTEGRATION_API_KEY"] = "test-integration-key"
|
||||
|
||||
headers = _tool_headers()
|
||||
|
||||
@@ -159,8 +159,8 @@ def test_batch_process_summary_shared_formula(app):
|
||||
assert "id" not in tool_batch
|
||||
|
||||
|
||||
def test_resolve_task_from_payload_by_conversation_id(app):
|
||||
"""conversation_id 应能解析到最近非 rejected 任务。"""
|
||||
def test_resolve_task_from_payload_by_conversation_id_single_active_task(app):
|
||||
"""conversation_id 仅在同会话只有一票可操作任务时允许回退。"""
|
||||
with app.app_context():
|
||||
task = ShippingTask(
|
||||
task_no="SN-CONV-1",
|
||||
@@ -178,3 +178,35 @@ def test_resolve_task_from_payload_by_conversation_id(app):
|
||||
assert resolved.task_no == "SN-CONV-1"
|
||||
|
||||
assert extract_task_no_from_text("请处理 SN-20260617-ABCDEF01 这票") == "SN-20260617-ABCDEF01"
|
||||
|
||||
|
||||
def test_resolve_task_from_payload_rejects_ambiguous_conversation_id(app):
|
||||
"""同一 conversation_id 下多票可操作任务时,禁止按最近一票静默回退。"""
|
||||
with app.app_context():
|
||||
from app import db
|
||||
|
||||
db.session.add_all(
|
||||
[
|
||||
ShippingTask(
|
||||
task_no="SN-CONV-MULTI-1",
|
||||
conversation_id="conv-multi",
|
||||
process_status="parsed",
|
||||
source_type="manual",
|
||||
),
|
||||
ShippingTask(
|
||||
task_no="SN-CONV-MULTI-2",
|
||||
conversation_id="conv-multi",
|
||||
process_status="pending_review",
|
||||
source_type="manual",
|
||||
),
|
||||
]
|
||||
)
|
||||
db.session.commit()
|
||||
|
||||
assert resolve_task_from_payload({"conversation_id": "conv-multi"}) is None
|
||||
|
||||
resolved = resolve_task_from_payload(
|
||||
{"conversation_id": "conv-multi", "task_id": "SN-CONV-MULTI-1"}
|
||||
)
|
||||
assert resolved is not None
|
||||
assert resolved.task_no == "SN-CONV-MULTI-1"
|
||||
@@ -6,6 +6,7 @@ from app.services.shipping_notice.match import match_notice_lines
|
||||
|
||||
|
||||
def _tool_headers(app):
|
||||
app.config["SHIPPING_NOTICE_TOOL_API_KEY"] = ""
|
||||
app.config["INTEGRATION_API_KEY"] = "test-integration-key"
|
||||
return {
|
||||
"Content-Type": "application/json",
|
||||
@@ -13,6 +14,51 @@ def _tool_headers(app):
|
||||
}
|
||||
|
||||
|
||||
def test_shipping_notice_tool_auth_accepts_dedicated_key(app, client):
|
||||
with app.app_context():
|
||||
app.config["SHIPPING_NOTICE_TOOL_API_KEY"] = "shipping-secret"
|
||||
app.config["INTEGRATION_API_KEY"] = ""
|
||||
|
||||
res = client.post(
|
||||
"/api/shipping-notice/tools/create_task",
|
||||
headers={"Content-Type": "application/json", "X-Integration-Key": "shipping-secret"},
|
||||
json={"source_type": "manual"},
|
||||
)
|
||||
|
||||
assert res.status_code == 200
|
||||
assert res.get_json()["status"] == "ok"
|
||||
|
||||
|
||||
def test_shipping_notice_tool_auth_falls_back_to_integration_key(app, client):
|
||||
with app.app_context():
|
||||
app.config["SHIPPING_NOTICE_TOOL_API_KEY"] = ""
|
||||
app.config["INTEGRATION_API_KEY"] = "integration-secret"
|
||||
|
||||
res = client.post(
|
||||
"/api/shipping-notice/tools/create_task",
|
||||
headers={"Content-Type": "application/json", "X-Integration-Key": "integration-secret"},
|
||||
json={"source_type": "manual"},
|
||||
)
|
||||
|
||||
assert res.status_code == 200
|
||||
assert res.get_json()["status"] == "ok"
|
||||
|
||||
|
||||
def test_shipping_notice_tool_auth_reports_missing_config(app, client):
|
||||
with app.app_context():
|
||||
app.config["SHIPPING_NOTICE_TOOL_API_KEY"] = ""
|
||||
app.config["INTEGRATION_API_KEY"] = ""
|
||||
|
||||
res = client.post(
|
||||
"/api/shipping-notice/tools/create_task",
|
||||
headers={"Content-Type": "application/json", "X-Integration-Key": "any"},
|
||||
json={"source_type": "manual"},
|
||||
)
|
||||
|
||||
assert res.status_code == 503
|
||||
assert res.get_json()["error_code"] == "missing_auth"
|
||||
|
||||
|
||||
def test_match_notice_lines_reports_progress():
|
||||
seen: list[tuple[int, int]] = []
|
||||
|
||||
@@ -116,6 +162,31 @@ def test_shipping_notice_tool_flow(app, client):
|
||||
assert status_res.get_json()["status"] == "ok"
|
||||
|
||||
|
||||
def test_contract_get_task_status_accepts_task_no_anchor(app, client):
|
||||
"""契约:用户输入 SN-... 时,Dify 应直连 get_task_status 并锚定对应任务。"""
|
||||
headers = _tool_headers(app)
|
||||
|
||||
create_res = client.post(
|
||||
"/api/shipping-notice/tools/create_task",
|
||||
headers=headers,
|
||||
json={"source_type": "manual", "raw_content": "客户:ACME 料号A001 x 10"},
|
||||
)
|
||||
task_id = create_res.get_json()["task_id"]
|
||||
|
||||
status_res = client.post(
|
||||
"/api/shipping-notice/tools/get_task_status",
|
||||
headers=headers,
|
||||
json={"task_no": task_id},
|
||||
)
|
||||
data = status_res.get_json()
|
||||
|
||||
assert status_res.status_code == 200
|
||||
assert data["status"] == "ok"
|
||||
assert data["task_id"] == task_id
|
||||
assert data["data"]["task_no"] == task_id
|
||||
assert "当前进度" in data["message"]
|
||||
|
||||
|
||||
def test_shipping_notice_match_shortage_needs_human(app, client):
|
||||
headers = _tool_headers(app)
|
||||
|
||||
@@ -157,6 +228,8 @@ def test_shipping_notice_match_shortage_needs_human(app, client):
|
||||
assert "confirm" not in options
|
||||
assert "reparse_inventory" in options
|
||||
assert "rematch" in options
|
||||
assert "generate_shipment_excel" in (data.get("forbidden_next_tools") or [])
|
||||
assert "upload_to_freight" in (data.get("forbidden_next_tools") or [])
|
||||
|
||||
confirm_res = client.post(
|
||||
"/api/shipping-notice/tools/submit_decision",
|
||||
@@ -227,6 +300,62 @@ def test_submit_decision_rematch_reopens_shortage_for_worker(app, client, monkey
|
||||
assert task.line_results_json is None
|
||||
|
||||
|
||||
def test_contract_submit_decision_rematch_is_direct_recovery_entry(app, client, monkeypatch):
|
||||
"""契约:重新匹配必须通过 submit_decision(rematch) 恢复当前任务,不经 Agent 自由续写。"""
|
||||
headers = _tool_headers(app)
|
||||
started: list[str] = []
|
||||
|
||||
from app.services.shipping_notice import decision_workflow
|
||||
|
||||
monkeypatch.setattr(
|
||||
decision_workflow,
|
||||
"start_task_orchestrator",
|
||||
lambda task_no: started.append(str(task_no)) or True,
|
||||
)
|
||||
|
||||
create_res = client.post(
|
||||
"/api/shipping-notice/tools/create_task",
|
||||
headers=headers,
|
||||
json={"source_type": "manual"},
|
||||
)
|
||||
task_id = create_res.get_json()["task_id"]
|
||||
|
||||
client.post(
|
||||
"/api/shipping-notice/tools/parse_notice",
|
||||
headers=headers,
|
||||
json={
|
||||
"task_id": task_id,
|
||||
"structured": {
|
||||
"customer_name": "ACME",
|
||||
"lines": [{"sku": "A001", "reservation_id": "R-1", "qty": 20, "uom": "EA"}],
|
||||
"confidence": 0.95,
|
||||
},
|
||||
},
|
||||
)
|
||||
client.post(
|
||||
"/api/shipping-notice/tools/ensure_inventory",
|
||||
headers=headers,
|
||||
json={"task_id": task_id, "inventory_lines": [{"sku": "A001", "reservation_id": "R-1", "available_qty": 1}]},
|
||||
)
|
||||
client.post(
|
||||
"/api/shipping-notice/tools/match_inventory",
|
||||
headers=headers,
|
||||
json={"task_id": task_id},
|
||||
)
|
||||
|
||||
rematch_res = client.post(
|
||||
"/api/shipping-notice/tools/submit_decision",
|
||||
headers=headers,
|
||||
json={"task_id": task_id, "decision": "rematch", "comment": "contract direct rematch"},
|
||||
)
|
||||
data = rematch_res.get_json()
|
||||
|
||||
assert rematch_res.status_code == 200
|
||||
assert data["status"] == "running"
|
||||
assert data["task_id"] == task_id
|
||||
assert started == [task_id]
|
||||
|
||||
|
||||
def test_openapi_spec_public(app, client):
|
||||
app.config["HXOPS_TOOLS_API_BASE"] = "http://tool-api.example.com"
|
||||
res = client.get("/api/shipping-notice/tools/openapi.json")
|
||||
@@ -245,6 +374,13 @@ def test_openapi_spec_public(app, client):
|
||||
assert "/tools/switch_focus_task" not in spec["paths"]
|
||||
assert "/tools/get_inventory_schema_preview" in spec["paths"]
|
||||
assert "/tools/apply_inventory_mapping" in spec["paths"]
|
||||
# 锁定 Dify Tool 契约:OpenAPI 暴露字符串,避免 Dify 画布无法选择上游 map_json 变量。
|
||||
apply_mapping = spec["paths"]["/tools/apply_inventory_mapping"]["post"]["requestBody"]["content"][
|
||||
"application/json"
|
||||
]["schema"]
|
||||
map_json_schema = apply_mapping["properties"]["map_json"]
|
||||
assert map_json_schema["type"] == "string"
|
||||
assert "JSON 字符串" in map_json_schema["description"]
|
||||
submit_decision = spec["paths"]["/tools/submit_decision"]["post"]["requestBody"]["content"]["application/json"]["schema"]
|
||||
assert "retry_rpa" in submit_decision["properties"]["decision"]["enum"]
|
||||
|
||||
@@ -734,7 +870,7 @@ def test_upload_inventory_file_parses_server_side(app, client, tmp_path):
|
||||
headers=headers,
|
||||
json={
|
||||
"task_id": task_id,
|
||||
"column_mapping_json": {
|
||||
"map_json": {
|
||||
**preview["suggested_mapping"],
|
||||
"match_rule": "LLM:Reservation Order 对齐订单 reservation_id,汇总 Qty Available。",
|
||||
},
|
||||
@@ -990,6 +1126,57 @@ def test_confirm_parse_does_not_skip_inventory_match(app, client):
|
||||
assert task.match_status is None
|
||||
|
||||
|
||||
@pytest.mark.auto_rpa
|
||||
def test_parse_notice_blocks_when_reservation_id_missing(app, client, monkeypatch):
|
||||
import app.services.shipping_notice.task_workflow as task_workflow
|
||||
|
||||
headers = _tool_headers(app)
|
||||
called: dict[str, str] = {}
|
||||
|
||||
def fake_start_task_orchestrator(task_no: str | None) -> bool:
|
||||
called["task_no"] = str(task_no or "")
|
||||
return True
|
||||
|
||||
monkeypatch.setattr(task_workflow, "start_task_orchestrator", fake_start_task_orchestrator)
|
||||
|
||||
create_res = client.post(
|
||||
"/api/shipping-notice/tools/create_task",
|
||||
headers=headers,
|
||||
json={"source_type": "manual"},
|
||||
)
|
||||
task_id = create_res.get_json()["task_id"]
|
||||
|
||||
parse_res = client.post(
|
||||
"/api/shipping-notice/tools/parse_notice",
|
||||
headers=headers,
|
||||
json={
|
||||
"task_id": task_id,
|
||||
"structured": {
|
||||
"customer_name": "ACME",
|
||||
"lines": [{"sku": "A001", "qty": 10, "uom": "EA"}],
|
||||
"confidence": 0.95,
|
||||
},
|
||||
},
|
||||
)
|
||||
|
||||
parse_data = parse_res.get_json()
|
||||
assert parse_data["status"] == "needs_human"
|
||||
assert parse_data["checkpoint"] == "rsv_req"
|
||||
assert "解析失败" in parse_data["message"]
|
||||
assert "Reservation ID / COM ID" in parse_data["message"]
|
||||
assert "confirm" not in parse_data.get("human_options", [])
|
||||
assert called == {}
|
||||
|
||||
with app.app_context():
|
||||
task = ShippingTask.query.filter_by(task_no=task_id).first()
|
||||
assert task is not None
|
||||
assert task.process_status == "pending_review"
|
||||
assert task.review_status == "rsv_req"
|
||||
assert task.pending_human_reason == "rsv_req"
|
||||
assert task.error_message and "解析失败" in task.error_message
|
||||
assert task.match_status is None
|
||||
|
||||
|
||||
@pytest.mark.auto_rpa
|
||||
def test_parse_notice_auto_continue_hides_parse_confirmation_hint(app, client, monkeypatch):
|
||||
import app.services.shipping_notice.task_workflow as task_workflow
|
||||
@@ -1184,6 +1371,15 @@ def test_rpa_pending_timeout_recheck_triggers_next_inventory_export(app, client,
|
||||
assert task is not None
|
||||
task.process_status = "waiting_inventory"
|
||||
task.pending_human_reason = PH_RPA_PENDING
|
||||
task.step_payload_json = {
|
||||
"rpa_inventory_source": {
|
||||
"source_code": "DSV360_AWSDU",
|
||||
"source_type": "dsv360",
|
||||
"display_name": "DSV 360 / Dublin / AWSDU - Prod (JDA)",
|
||||
"entry_url": "https://s360.dbschenker.com/",
|
||||
"query": {"program_label": "AWSDU - Prod (JDA)", "owner_code": "CADU-0000000100"},
|
||||
}
|
||||
}
|
||||
db.session.add(
|
||||
ShippingTaskEvent(
|
||||
task_id=task.id,
|
||||
@@ -1229,6 +1425,15 @@ def test_retry_rpa_after_exhausted_starts_new_attempt_window(app, client, tmp_pa
|
||||
assert task is not None
|
||||
task.process_status = "waiting_inventory"
|
||||
task.pending_human_reason = PH_RPA_EXHAUSTED
|
||||
task.step_payload_json = {
|
||||
"rpa_inventory_source": {
|
||||
"source_code": "DSV360_AWSDU",
|
||||
"source_type": "dsv360",
|
||||
"display_name": "DSV 360 / Dublin / AWSDU - Prod (JDA)",
|
||||
"entry_url": "https://s360.dbschenker.com/",
|
||||
"query": {"program_label": "AWSDU - Prod (JDA)", "owner_code": "CADU-0000000100"},
|
||||
}
|
||||
}
|
||||
base_time = datetime.utcnow() - timedelta(minutes=5)
|
||||
for idx in range(3):
|
||||
db.session.add(
|
||||
@@ -1248,7 +1453,7 @@ def test_retry_rpa_after_exhausted_starts_new_attempt_window(app, client, tmp_pa
|
||||
)
|
||||
retry_data = retry_res.get_json()
|
||||
assert retry_data["status"] == "running"
|
||||
assert "新一轮第 1/3 次" in retry_data["message"]
|
||||
assert retry_data.get("data", {}).get("rpa", {}).get("attempts") == 1
|
||||
|
||||
with app.app_context():
|
||||
task = ShippingTask.query.filter_by(task_no=task_id).first()
|
||||
@@ -1257,8 +1462,8 @@ def test_retry_rpa_after_exhausted_starts_new_attempt_window(app, client, tmp_pa
|
||||
assert task.pending_human_reason == "rpa_pending"
|
||||
assert task.error_message is None
|
||||
progress = (task.step_payload_json or {}).get("current_step_progress") or {}
|
||||
assert progress.get("message") == "已手动重新触发 RPA 库存导出,等待结果"
|
||||
assert progress.get("detail") == "新一轮第 1/3 次尝试"
|
||||
assert progress.get("current") == 1
|
||||
assert progress.get("extra", {}).get("manual_retry_round") is True
|
||||
assert ShippingTaskEvent.query.filter_by(task_id=task.id, event_type="decision_retry_rpa").count() == 1
|
||||
assert ShippingTaskEvent.query.filter_by(task_id=task.id, event_type="inventory_rpa_triggered").count() == 4
|
||||
assert len(list(trigger.glob("inventory_export_*.json"))) == 1
|
||||
@@ -1299,6 +1504,15 @@ def test_batch_retry_rechecks_timed_out_rpa_pending_immediately(app, client, tmp
|
||||
assert task is not None
|
||||
task.process_status = "waiting_inventory"
|
||||
task.pending_human_reason = PH_RPA_PENDING
|
||||
task.step_payload_json = {
|
||||
"rpa_inventory_source": {
|
||||
"source_code": "DSV360_AWSDU",
|
||||
"source_type": "dsv360",
|
||||
"display_name": "DSV 360 / Dublin / AWSDU - Prod (JDA)",
|
||||
"entry_url": "https://s360.dbschenker.com/",
|
||||
"query": {"program_label": "AWSDU - Prod (JDA)", "owner_code": "CADU-0000000100"},
|
||||
}
|
||||
}
|
||||
db.session.add(
|
||||
ShippingTaskEvent(
|
||||
task_id=task.id,
|
||||
@@ -1340,7 +1554,7 @@ def test_submit_decision_by_conversation_id(app, client):
|
||||
"conversation_id": "conv-test-001",
|
||||
"structured": {
|
||||
"customer_name": "Wistron",
|
||||
"lines": [{"sku": "504-010213-001", "qty": 9, "uom": "EA"}],
|
||||
"lines": [{"sku": "504-010213-001", "reservation_id": "1000140351", "qty": 9, "uom": "EA"}],
|
||||
"confidence": 0.95,
|
||||
},
|
||||
},
|
||||
@@ -1365,6 +1579,60 @@ def test_submit_decision_by_conversation_id(app, client):
|
||||
assert dup_data.get("checkpoint") == "task_exists"
|
||||
|
||||
|
||||
def test_submit_decision_requires_task_id_when_conversation_has_multiple_tasks(app, client):
|
||||
headers = _tool_headers(app)
|
||||
|
||||
first = ShippingTask(
|
||||
task_no="SN-MULTI-CONV-001",
|
||||
conversation_id="conv-test-multi",
|
||||
process_status="pending_review",
|
||||
review_status="parse_review",
|
||||
pending_human_reason="low_confidence",
|
||||
source_type="manual",
|
||||
lines_json=[{"sku": "A001", "reservation_id": "1000140351", "qty": 1}],
|
||||
)
|
||||
second = ShippingTask(
|
||||
task_no="SN-MULTI-CONV-002",
|
||||
conversation_id="conv-test-multi",
|
||||
process_status="pending_review",
|
||||
review_status="parse_review",
|
||||
pending_human_reason="low_confidence",
|
||||
source_type="manual",
|
||||
lines_json=[{"sku": "A002", "reservation_id": "1000140352", "qty": 1}],
|
||||
)
|
||||
with app.app_context():
|
||||
db.session.add_all([first, second])
|
||||
db.session.commit()
|
||||
|
||||
confirm_res = client.post(
|
||||
"/api/shipping-notice/tools/submit_decision",
|
||||
headers=headers,
|
||||
json={"conversation_id": "conv-test-multi", "decision": "confirm"},
|
||||
)
|
||||
confirm_data = confirm_res.get_json()
|
||||
assert confirm_data["status"] == "failed"
|
||||
assert "任务编号" in confirm_data["message"] or "task ID" in confirm_data["message"]
|
||||
|
||||
status_res = client.post(
|
||||
"/api/shipping-notice/tools/get_task_status",
|
||||
headers=headers,
|
||||
json={"conversation_id": "conv-test-multi"},
|
||||
)
|
||||
status_data = status_res.get_json()
|
||||
assert status_data["status"] == "failed"
|
||||
assert "任务编号" in status_data["message"]
|
||||
|
||||
with app.app_context():
|
||||
rows = {
|
||||
task.task_no: task
|
||||
for task in ShippingTask.query.filter(ShippingTask.task_no.in_(["SN-MULTI-CONV-001", "SN-MULTI-CONV-002"]))
|
||||
.order_by(ShippingTask.task_no)
|
||||
.all()
|
||||
}
|
||||
assert rows["SN-MULTI-CONV-001"].process_status == "pending_review"
|
||||
assert rows["SN-MULTI-CONV-002"].process_status == "pending_review"
|
||||
|
||||
|
||||
def test_submit_decision_retry_rpa_routes_to_inventory_workflow(app, client, monkeypatch):
|
||||
headers = _tool_headers(app)
|
||||
|
||||
|
||||
@@ -321,7 +321,7 @@
|
||||
},
|
||||
"map_json": {
|
||||
"type": "string",
|
||||
"description": "列映射 JSON,含 sku/reservation_id/available_qty;可选 match_rule(LLM 自然语言匹配说明,缺省则后端动态兜底)"
|
||||
"description": "Dify Tool 参数使用 JSON 字符串,内容含 sku/reservation_id/available_qty;可选 match_rule(LLM 自然语言匹配说明)与 match_key(匹配键列表)。"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
|
||||
@@ -249,7 +249,7 @@
|
||||
自动执行中
|
||||
</span>
|
||||
</div>
|
||||
<p id="chat-subtitle" class="mt-0.5 truncate text-[11px] text-muted">对话承接意图,工作台处理批次执行</p>
|
||||
<p id="chat-subtitle" class="mt-0.5 truncate text-[11px] text-muted">对话承接主流程,工作台监督批次状态</p>
|
||||
</div>
|
||||
</div>
|
||||
<button onclick="toggleDrawer()" class="flex h-8 items-center gap-2 rounded-lg border border-default bg-surface px-3 text-xs font-medium text-secondary transition-colors hover:bg-surface-soft hover:text-brand-600">
|
||||
|
||||
@@ -80,7 +80,7 @@
|
||||
- 全满足时,按货代模板生成 Excel 并提供下载
|
||||
- 货代上传(自动上传与手工确认完成两种模式)
|
||||
- 任务列表:查看历史任务、续办
|
||||
- 操作界面采用 **方案 C:纯对话驱动**(见 §2.1.1);同时保留未来接入侧边工作区的扩展预留
|
||||
- 操作界面采用 **对话主路径 + 轻量批次工作台**(见 §2.1.1);聊天负责主交互,轻量工作台负责批次监督、切换与异常恢复
|
||||
|
||||
#### 原型范围外
|
||||
|
||||
@@ -129,72 +129,74 @@ flowchart TB
|
||||
5. **支持多文件、多任务**:同一会话可连续处理多票;须展示当前任务并支持切换。
|
||||
6. **缺口默认阻断**:存在库存缺口时禁止进入步骤 6、7;须补库存或修订后重匹配,全满足方可继续。
|
||||
7. **可续办可审计**:任务可中断续办;每步确认与修订留痕。
|
||||
8. **方案 C 纯对话驱动**:本期所有用户可见操作均在对话区完成;侧边工作区仅保留未来扩展预留,见 §2.1.1。
|
||||
8. **对话主路径 + 轻量批次工作台**:本期以对话区为主入口;批次状态、任务切换、异常恢复通过轻量工作台承载,避免多任务信息埋入聊天历史,见 §2.1.1。
|
||||
|
||||
#### 2.1.1 操作界面形态(方案 C:纯对话驱动)
|
||||
#### 2.1.1 操作界面形态(本期正式方案:对话主路径 + 轻量批次工作台)
|
||||
|
||||
本期以**方案 C:纯对话驱动**作为唯一正式方案。业务七步流程、缺口阻断规则、多任务隔离等规则全部保持不变,但所有用户可见操作统一在对话区内完成;侧边工作区仅作为未来扩展位保留,不进入本期功能、交互和验收范围。
|
||||
本期以**对话主路径 + 轻量批次工作台**作为正式方案。业务七步流程、缺口阻断规则、多任务隔离等规则全部保持不变;用户主要在对话区内完成上传、查看、修订、确认与追问,批次状态、任务切换、异常筛选、续办与恢复动作通过嵌入聊天主界面的轻量批次工作台承载。独立重型工作台不作为本期普通用户主路径。
|
||||
|
||||
---
|
||||
|
||||
##### 方案 C:纯对话驱动(本期唯一方案)
|
||||
##### 本期正式方案:对话主路径 + 轻量批次工作台
|
||||
|
||||
**概要**:全流程默认在**对话区**内完成,用户不需要打开任何侧边栏即可完成上传、查看、修订、确认、续办与多任务切换。结构化结果通过消息内嵌表格、表单、按钮与进度组件承载;所有确认动作均有消息内按钮或文字指令替代。
|
||||
**概要**:全流程以**对话区**为主路径,结构化结果通过消息内嵌表格、表单、按钮与进度组件承载;同时提供**轻量批次工作台**作为监督层,用于展示当前批次摘要、当前聚焦任务、异常票筛选、续办与恢复动作。所有核心业务规则仍由统一任务状态机驱动,不因渲染容器不同而分叉。
|
||||
|
||||
```mermaid
|
||||
flowchart TB
|
||||
subgraph optionC [方案C]
|
||||
ChatC["对话区(主路径 · 全宽)"]
|
||||
TaskC["任务列表 / 续办入口"]
|
||||
subgraph optionMain [正式方案]
|
||||
TopBar["顶部批次摘要 / 当前聚焦任务"]
|
||||
Chat["对话区(主路径)"]
|
||||
Drawer["右侧轻量批次工作台"]
|
||||
TaskList["任务列表 / 续办入口"]
|
||||
end
|
||||
TaskC --> ChatC
|
||||
TaskList --> Chat
|
||||
TopBar --> Chat
|
||||
Drawer --> Chat
|
||||
```
|
||||
|
||||
| 要素 | 说明 |
|
||||
|------|------|
|
||||
| 默认布局 | **对话区全宽**;任务列表与续办为独立入口 |
|
||||
| 用户可见主入口 | **对话区 + 任务列表/续办** |
|
||||
| 结构化展示 | 订单表、映射表单、匹配结果、缺口提醒、Excel 确认、上传确认 → **全部在消息内完成** |
|
||||
| 默认布局 | **对话区主路径 + 顶部批次摘要 + 右侧轻量批次工作台** |
|
||||
| 用户可见主入口 | **对话区 + 轻量批次工作台 + 任务列表/续办** |
|
||||
| 结构化展示 | 订单表、映射表单、匹配结果、缺口提醒、Excel 确认、上传确认 → **主要在消息内完成** |
|
||||
| 修订操作 | **消息内行内编辑**或自然语言说明修改 |
|
||||
| 步间确认 | **消息底部按钮**或文字指令(如「确认」「驳回」「返回上一步」) |
|
||||
| 对话区角色 | 承载上传、引导、展示、修订、确认、状态同步 |
|
||||
| 高置信度自动步进 | **仅在对话内提示**;不依赖其他容器 |
|
||||
| 适用场景 | 希望以聊天式操作完成全流程、培训成本低、路径单一清晰的内勤 |
|
||||
| 步间确认 | **消息底部按钮**或文字指令;轻量工作台只做监督与恢复,不直接改写业务规则 |
|
||||
| 对话区角色 | 承载上传、引导、解释、展示、修订、确认、状态同步 |
|
||||
| 轻量工作台角色 | 承载批次摘要、异常筛选、任务切换、续办、恢复动作、批次级可视化 |
|
||||
| 高置信度自动步进 | 在对话内给出说明;批次摘要与工作台同步更新任务进度 |
|
||||
| 适用场景 | 多票并行、存在人工复核与异常恢复、需要降低聊天历史检索成本的内勤 |
|
||||
|
||||
---
|
||||
|
||||
##### 方案 C 的对话内交互承载
|
||||
##### 对话主路径与轻量工作台分工
|
||||
|
||||
| 对话内对象 | 本期要求 |
|
||||
| 容器 | 本期职责 |
|
||||
|------|----------|
|
||||
| 解析结果确认 | 消息内嵌订单表,支持字段查看、行内修订、增删改行 |
|
||||
| 字段对齐确认 | 消息内嵌映射表单,展示样例值与必填列校验 |
|
||||
| 匹配结果查看 | 消息内嵌匹配表,展示需求/可用/缺口与行状态 |
|
||||
| 缺口处理 | 消息内显著提醒不可发货,提供驳回、重新上传库存、返回修订、重新匹配等动作 |
|
||||
| Excel 生成确认 | 消息内展示生成状态、下载入口、确认按钮 |
|
||||
| 上传确认 | 消息内展示上传状态、回执摘要、确认完成/重试操作 |
|
||||
| 多任务切换 | 通过任务列表或对话指令切换当前任务;对话顶部状态同步更新 |
|
||||
| 对话区 | 消息内嵌订单表,支持字段查看、行内修订、增删改行;字段对齐确认、匹配结果、缺口提醒、Excel 确认、上传确认等核心业务交互默认在对话内完成 |
|
||||
| 顶部批次摘要 | 展示当前批次总量、已完成/进行中/待处理、当前聚焦任务与当前步骤,降低用户迷失感 |
|
||||
| 右侧轻量批次工作台 | 展示批次队列、异常票筛选、任务切换、续办入口、恢复动作与批次级观察,不替代消息内确认与修订 |
|
||||
| 任务列表/续办入口 | 提供历史任务检索、从中断状态恢复到当前对话与任务聚焦 |
|
||||
|
||||
---
|
||||
|
||||
##### 未来扩展预留(非本期能力)
|
||||
##### 重型工作台 / 独立详情页约束(非主路径能力)
|
||||
|
||||
未来如需增加侧边工作区,应视为**同一业务能力的另一渲染容器**,而不是新增一套独立流程。本期仅保留以下内部设计约束:
|
||||
本期允许存在独立详情页或更重的工作台页面,但其定位仅限于管理、审计、排障或未来增强能力,不作为普通用户主路径。本期保留以下设计约束:
|
||||
|
||||
| 预留项 | 约束 |
|
||||
|------|------|
|
||||
| 结构化视图复用 | 订单表、字段映射、匹配结果、Excel 预览、原文对照等视图需可复用,不与某一容器强绑定 |
|
||||
| 状态与审计 | 任务上下文、步骤状态、确认门、审计回写、保存逻辑不得依赖特定 UI 容器 |
|
||||
| 行为一致性 | 后续若挂入侧边工作区,业务规则、确认结果、任务留痕必须与对话区完全一致 |
|
||||
| 接入边界 | 侧边工作区未来如上线,应作为增强展示层,不改变本期 7 步主链路 |
|
||||
| 行为一致性 | 重型工作台若提供相同操作,业务规则、确认结果、任务留痕必须与对话区完全一致 |
|
||||
| 接入边界 | 独立详情页或重型工作台不得改变本期 7 步主链路,也不得绕过轻量工作台与对话主路径定义的聚焦任务规则 |
|
||||
|
||||
**共通规则(方案 C 及未来扩展均适用)**
|
||||
**共通规则(本期正式方案及未来增强均适用)**
|
||||
|
||||
| 规则 | 说明 |
|
||||
|------|------|
|
||||
| 任务列表 | 独立入口:历史任务、续办、切换当前任务 |
|
||||
| 多任务 | 对话消息与任务状态均带任务编号 |
|
||||
| 结构化结果 | 所有结构化结果在对话区展示、修订、确认,并回写任务留痕 |
|
||||
| 结构化结果 | 所有关键结构化结果在对话区展示、修订、确认,并回写任务留痕 |
|
||||
| 业务约束 | 七步流程、步间确认、缺口默认阻断、多任务隔离 |
|
||||
|
||||
**多文件 / 多任务规则**
|
||||
@@ -222,7 +224,7 @@ flowchart TB
|
||||
| F7 | 生成发货 Excel 并确认 | 步6 预览、下载、确认 | 匹配全满足结果 | 可下载 Excel |
|
||||
| F8 | 上传货代并确认完成 | 步7 自动或手工确认 | 发货 Excel | 上传结果 |
|
||||
| F9 | 分步确认与自动推进 | 步间确认门 + 高置信度自动下一步 | 各步置信度/规则 | 进入下一步或暂停 |
|
||||
| F10 | 工作区扩展预留 | 为未来接入侧边工作区保留能力边界 | 各步结构化数据 | 可复用视图与一致的任务回写能力 |
|
||||
| F10 | 轻量批次工作台 | 为多任务监督、切换与异常恢复提供嵌入式工作台 | 批次摘要、任务状态、建议动作 | 可切换聚焦任务、筛选异常票、触发续办/恢复 |
|
||||
| F11 | 任务列表与续办 | 可追溯、可交接 | 任务筛选 | 列表 + 跳转续办 |
|
||||
| F12 | 进度查询 | 随时了解状态 | 任务编号 / 批次 | `workflow_steps` 三层进度 + 建议操作(见 [进度底座](agent_progress_prototype.md)) |
|
||||
| F13 | 多任务管理与切换 | 多票并行不混数据 | 任务列表 / 切换指令 | 当前任务标识 |
|
||||
@@ -349,7 +351,7 @@ flowchart TD
|
||||
| 多任务须选择归属 | 请选择该库存所属任务编号 | 选择任务 |
|
||||
| 切换当前任务 | 当前处理:SN-… | 切换任务 |
|
||||
| 高置信度自动步进 | 已自动确认步骤 x,进入下一步 | 可查看详情或返回修订 |
|
||||
| 未来扩展预留 | 本期已按可复用视图与状态容器设计,后续可增加侧边工作区承载大屏展示 | 继续在对话中操作 |
|
||||
| 独立详情页 / 重型工作台 | 仅作为管理、审计、排障或增强展示能力;不得替代对话主路径与轻量工作台 | 继续在当前任务上下文中操作 |
|
||||
|
||||
---
|
||||
|
||||
@@ -435,13 +437,14 @@ flowchart TD
|
||||
| 自动 | 满足各步条件且开启自动模式时自动确认 |
|
||||
| 留痕 | 记录自动确认人与数据快照 |
|
||||
|
||||
#### F10 工作区扩展预留
|
||||
#### F10 轻量批次工作台
|
||||
|
||||
| 项 | 本期约束 |
|
||||
|----|----------|
|
||||
| 用户可见性 | **非本期能力**;不提供侧边工作区入口,不纳入验收主路径 |
|
||||
| 预留内容 | 订单表、原文对照、匹配大表、Excel 预览等结构化视图可复用 |
|
||||
| 数据一致性 | 若未来增加工作区,保存、确认、回写、审计与任务状态必须复用同一套业务能力 |
|
||||
| 用户可见性 | **本期正式能力**;提供顶部批次摘要与右侧轻量工作台入口,纳入验收主路径 |
|
||||
| 主要职责 | 展示批次摘要、当前聚焦任务、任务队列、异常筛选、续办与恢复动作 |
|
||||
| 非职责 | 不承担消息内修订、字段编辑、最终确认等主交互;这些仍在对话区内完成 |
|
||||
| 数据一致性 | 工作台触发的聚焦、恢复与动作必须复用同一套业务能力、任务状态与审计回写 |
|
||||
|
||||
#### F11–F13 任务列表、进度查询、多任务切换
|
||||
|
||||
@@ -484,24 +487,24 @@ flowchart TD
|
||||
| 输入锁定 | 通常 **不锁定**(需步间确认与修订) | `lock_statuses` 可配置为空 |
|
||||
| 与 RoHS 差异 | **交互式向导**;多步人工确认 | RoHS 用 `async_batch` 批处理观测,见 RoHS 原型 §2.1.2 |
|
||||
|
||||
下文 §3.3.1 起为 **货代在 `workflow_steps` 视图下的产品规格**(方案 C:纯对话驱动);绑定、轮询、终态规则以进度底座文档为准。
|
||||
下文 §3.3.1 起为 **货代在 `workflow_steps` 视图下的产品规格**(对话主路径 + 轻量批次工作台);绑定、轮询、终态规则以进度底座文档为准。
|
||||
|
||||
#### 3.3.1 步骤处理进度展示
|
||||
|
||||
进度分三层,均在对话区展示;本期不依赖任何侧边工作区承载主流程信息。
|
||||
进度分三层,在聊天主界面统一展示:对话区负责核心消息与修订确认,顶部批次摘要与轻量工作台负责批次监督与聚焦切换。
|
||||
|
||||
| 层级 | 展示内容 | 展示位置 |
|
||||
|------|----------|----------|
|
||||
| **批次层** | 本批需求总数、已创建任务数、已完成/进行中/待处理票数;当前聚焦任务 | 对话区 Stepper 上方;多笔上传时须展示 |
|
||||
| **批次层** | 本批需求总数、已创建任务数、已完成/进行中/待处理票数;当前聚焦任务 | 顶部批次摘要;多笔上传时须展示 |
|
||||
| **任务层** | 步骤 1–7 总览、当前步骤高亮、任务编号 SN-… | 对话区顶部;随聚焦任务切换更新 |
|
||||
| **步骤内层** | 解析中、抓取库存中、匹配行进度、生成/上传中等 | 助手消息 + 进度条或计数 |
|
||||
| **步骤详情** | 大表逐行、原文对照、批次队列展开 | 对话消息内嵌组件 / 折叠区 |
|
||||
| **步骤详情** | 大表逐行、原文对照、批次队列展开 | 对话消息内嵌组件 / 折叠区;批次队列摘要可在轻量工作台查看 |
|
||||
|
||||
**展示位置规则**
|
||||
|
||||
| 场景 | 批次层 + 任务层 | 步骤内层 | 步骤详情 |
|
||||
|------|----------------|----------|----------|
|
||||
| 方案 C(本期默认) | 对话区顶部固定展示 | 对话消息内 | 对话消息内嵌组件、折叠区或下载入口 |
|
||||
| 本期正式方案 | 顶部批次摘要 + 对话区任务层 | 对话消息内 | 对话消息内嵌组件、折叠区、下载入口或轻量工作台摘要 |
|
||||
| 单笔上传 | 任务层 + 步骤内层;批次层可显示「本批 1 笔」 | 同左 | 同左 |
|
||||
| 多笔上传 | 批次层、任务层均在对话区可见 | 同左 | 队列详情在对话区展开 |
|
||||
|
||||
@@ -580,24 +583,24 @@ flowchart TD
|
||||
- 任务列表:续办恢复对应对话与步骤状态
|
||||
- 多语言:简体中文、繁体中文、英文、泰文
|
||||
|
||||
#### 方案 C:纯对话驱动交互规格
|
||||
#### 本期正式方案:对话主路径 + 轻量批次工作台
|
||||
|
||||
| 项 | 规格 |
|
||||
|----|------|
|
||||
| 布局 | **默认对话全宽**;任务列表/续办为独立入口 |
|
||||
| 展示与修订 | 消息内嵌表格、表单、提醒卡片、进度组件 |
|
||||
| 确认 | 消息按钮或文字指令,**不依赖其他容器** |
|
||||
| 布局 | **对话区主路径 + 顶部批次摘要 + 右侧轻量批次工作台**;任务列表/续办为独立入口 |
|
||||
| 展示与修订 | 消息内嵌表格、表单、提醒卡片、进度组件;轻量工作台承载批次监督与筛选 |
|
||||
| 确认 | 消息按钮或文字指令;不依赖重型工作台 |
|
||||
| 续办 | 恢复对话消息与步骤;用户可直接继续处理 |
|
||||
| 进度 | 七步 Stepper 在**对话区顶部**;步骤详情在消息内展开 |
|
||||
| 多任务 | 对话顶部持续显示当前任务;切换任务后状态与操作同步切换 |
|
||||
| 进度 | 七步 Stepper 在**对话区顶部**;批次摘要与队列在顶部/轻量工作台同步显示 |
|
||||
| 多任务 | 顶部批次摘要与轻量工作台持续显示当前任务;切换任务后状态与操作同步切换 |
|
||||
|
||||
#### 未来工作区接入约束(非本期)
|
||||
#### 独立详情页 / 重型工作台接入约束(非主路径)
|
||||
|
||||
| 项 | 规格 |
|
||||
|----|------|
|
||||
| 接入方式 | 作为与对话区并列的增强展示容器接入 |
|
||||
| 不变项 | 七步流程、确认门、审计、任务编号、缺口阻断规则、多任务隔离 |
|
||||
| 验收口径 | 不纳入本期 P0;仅作为后续增强能力规划 |
|
||||
| 验收口径 | 不纳入本期普通用户主路径 P0;仅作为后续增强能力或管理能力规划 |
|
||||
|
||||
---
|
||||
|
||||
@@ -642,7 +645,7 @@ flowchart TD
|
||||
| 匹配 | 全满足、存在缺口、无 RSV 风险 |
|
||||
| 缺口阻断 | 存在缺口时禁止进入步骤 6/7;补库存后全满足可继续 |
|
||||
| 步进与修订 | 每步确认、修订后重确认、高置信度自动步进 |
|
||||
| 方案 C(纯对话) | 对话内全流程;不依赖侧边工作区 |
|
||||
| 本期正式方案 | 对话主路径 + 轻量批次工作台;不依赖独立重型工作台 |
|
||||
| 导出上传 | 全满足后生成 Excel;自动/手工上传 |
|
||||
| 多任务 | 多文件建单、并行不串单、切换任务 |
|
||||
| 续办 | 中断后续办 |
|
||||
@@ -670,13 +673,13 @@ flowchart TD
|
||||
| TC-14 | 步骤2修订 | 步骤 2 | 修改行数量并确认 | 步骤 5 按修订后数量匹配 |
|
||||
| TC-15 | 高置信度自动步进 | 开启自动模式 | 高置信度解析 | 自动进入步骤 3;有提示 |
|
||||
| TC-16 | 自动条件不满足 | 缺 RSV 警告 | 开启自动模式 | 停留步骤 2 等待人工 |
|
||||
| TC-17 | 方案C对话全流程 | 方案 C | 全程仅在对话区操作 | 七步可走通 |
|
||||
| TC-18 | 方案C多任务对话切换 | 方案 C | 在对话内切换任务并继续处理 | 对话顶部状态、按钮、Stepper 同步切换 |
|
||||
| TC-19 | 方案C续办 | 方案 C | 从任务列表续办并继续处理 | 纯对话续办正常 |
|
||||
| TC-17 | 正式方案主流程 | 正式方案 | 通过对话区完成七步主流程,并观察顶部批次摘要/轻量工作台同步 | 七步可走通;监督层状态同步 |
|
||||
| TC-18 | 多任务切换 | 正式方案 | 在轻量工作台或任务列表切换任务并继续处理 | 顶部状态、按钮、Stepper、工作台聚焦同步切换 |
|
||||
| TC-19 | 续办恢复 | 正式方案 | 从任务列表或轻量工作台续办并继续处理 | 恢复到正确任务与步骤;监督层状态一致 |
|
||||
|
||||
### 4.3 测试验收标准
|
||||
|
||||
**P0(方案 C,纯对话)**:TC-01、TC-02、TC-04、TC-06、TC-07、TC-13、TC-14、TC-15、TC-17、TC-18、TC-19 全部通过。
|
||||
**P0(正式方案:对话主路径 + 轻量批次工作台)**:TC-01、TC-02、TC-04、TC-06、TC-07、TC-13、TC-14、TC-15、TC-17、TC-18、TC-19 全部通过。
|
||||
|
||||
**质量指标**
|
||||
|
||||
@@ -705,17 +708,17 @@ flowchart TD
|
||||
- 货代上传可先以「生成文件 + 手工确认已上传」为主,自动上传为增强项。
|
||||
- 库存自动抓取依赖货代系统 API 或 RPA;原型阶段默认同时支持用户上传 Excel。
|
||||
- **库存缺口**:存在缺口时默认阻断发货;暂不增加缺口管控模式等配置项。
|
||||
- **UI 模式**:本期采用**方案 C(纯对话驱动)**;侧边工作区仅保留未来接入能力的设计预留,不作为本期用户可见能力。
|
||||
- **UI 模式**:本期采用**对话主路径 + 轻量批次工作台**;独立详情页或重型工作台仅作为增强/管理能力,不作为普通用户主路径。
|
||||
|
||||
### 5.3 评审检查清单
|
||||
|
||||
- [ ] 痛点是否贴合货代/跟单真实作业场景?
|
||||
- [ ] 七步流程与步间确认门是否定义清楚?
|
||||
- [ ] 每步可修订范围与「返回上一步」是否明确?
|
||||
- [ ] §2.1.1 是否明确方案 C 为本期唯一正式方案?
|
||||
- [ ] 方案 C 是否满足对话为主、可不依赖侧边工作区完成全流程?
|
||||
- [ ] 是否已将侧边工作区改为未来扩展预留,而非本期交互能力?
|
||||
- [ ] 三层进度(批次 / 任务七步 / 步骤内)是否在对话区定义清楚?
|
||||
- [ ] §2.1.1 是否明确“对话主路径 + 轻量批次工作台”为本期正式方案?
|
||||
- [ ] 是否明确对话区负责主交互、轻量工作台负责监督/切换/恢复?
|
||||
- [ ] 是否明确独立详情页或重型工作台不作为普通用户主路径?
|
||||
- [ ] 三层进度(批次 / 任务七步 / 步骤内)是否在聊天主界面定义清楚?
|
||||
- [ ] 与 [agent_progress_prototype.md](agent_progress_prototype.md) 中 `workflow_steps` 映射是否一致?
|
||||
- [ ] 多笔上传时批次进度与任务队列是否可理解、可切换?
|
||||
- [ ] 缺口阻断规则是否定义清楚(存在缺口不可发货、须全满足后继续)?
|
||||
@@ -735,3 +738,4 @@ flowchart TD
|
||||
| v1.5 | 2026-06-12 | 补充 §3.3.0 与 [agent_progress_prototype.md](agent_progress_prototype.md) 关系 |
|
||||
| v1.6 | 2026-06-17 | 收敛为方案 C 纯对话驱动;侧边工作区改为未来扩展预留 |
|
||||
| v1.7 | 2026-06-17 | 收敛缺口策略:存在缺口默认禁止发货;移除缺口管控模式配置项 |
|
||||
| v1.8 | 2026-06-30 | 正式口径调整为“对话主路径 + 轻量批次工作台”;独立详情页降级为增强/管理能力 |
|
||||
@@ -1,637 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>货代发货通知 Agent · 方案 C 纯对话驱动 · UI 原型</title>
|
||||
<script src="https://cdn.tailwindcss.com"></script>
|
||||
<script>
|
||||
tailwind.config = {
|
||||
theme: {
|
||||
extend: {
|
||||
fontFamily: {
|
||||
sans: ['"PingFang SC"', '"Microsoft YaHei"', '"Segoe UI"', 'system-ui', 'sans-serif'],
|
||||
},
|
||||
colors: {
|
||||
brand: {
|
||||
50: '#f0f9ff', 100: '#e0f2fe', 200: '#bae6fd', 300: '#7dd3fc',
|
||||
400: '#38bdf8', 500: '#0ea5e9', 600: '#0284c7', 700: '#0369a1',
|
||||
800: '#075985', 900: '#0c4a6e',
|
||||
},
|
||||
},
|
||||
animation: {
|
||||
'slide-up': 'slideUp 0.4s ease-out',
|
||||
'fade-in': 'fadeIn 0.25s ease-out',
|
||||
},
|
||||
keyframes: {
|
||||
slideUp: { '0%': { transform: 'translateY(10px)', opacity: '0' }, '100%': { transform: 'translateY(0)', opacity: '1' } },
|
||||
fadeIn: { '0%': { opacity: '0' }, '100%': { opacity: '1' } },
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
<style>
|
||||
:root {
|
||||
--bg-page: #f8fafc;
|
||||
--bg-surface: #ffffff;
|
||||
--bg-surface-soft: #f8fafc;
|
||||
--text-primary: #0f172a;
|
||||
--text-secondary: #334155;
|
||||
--text-muted: #64748b;
|
||||
--border-default: #e2e8f0;
|
||||
--status-success-bg: #eef8e8;
|
||||
--status-success-fg: #389e0d;
|
||||
--status-warning-bg: #fff8e8;
|
||||
--status-warning-fg: #d48806;
|
||||
--status-error-bg: #fff1f0;
|
||||
--status-error-fg: #cf1322;
|
||||
--status-info-bg: #eaf4ff;
|
||||
--status-info-fg: #1677ff;
|
||||
--glass-panel-bg: rgba(255, 255, 255, 0.68);
|
||||
}
|
||||
body { background: var(--bg-page); color: var(--text-secondary); }
|
||||
.bg-page { background-color: var(--bg-page); }
|
||||
.bg-surface { background-color: var(--bg-surface); }
|
||||
.bg-surface-soft { background-color: var(--bg-surface-soft); }
|
||||
.text-primary { color: var(--text-primary); }
|
||||
.text-secondary { color: var(--text-secondary); }
|
||||
.text-muted { color: var(--text-muted); }
|
||||
.border-default { border-color: var(--border-default); }
|
||||
.glass-panel { background: var(--glass-panel-bg); backdrop-filter: blur(12px); }
|
||||
.chat-msg-assistant {
|
||||
width: 100%; border-radius: 1rem; border: 1px solid var(--border-default);
|
||||
background: var(--bg-surface); padding: 1rem 1.5rem; font-size: 15px;
|
||||
line-height: 1.625; color: var(--text-primary); box-shadow: 0 1px 2px rgb(0 0 0 / 5%);
|
||||
}
|
||||
.chat-sidebar-btn {
|
||||
display: flex; width: 100%; align-items: center; gap: 0.5rem;
|
||||
border-radius: 0.75rem; border: 1px solid var(--border-default);
|
||||
background: var(--bg-surface); padding: 0.625rem 1rem;
|
||||
font-size: 0.875rem; font-weight: 500; color: var(--text-secondary);
|
||||
}
|
||||
.chat-sidebar-btn:hover { background: var(--bg-surface-soft); }
|
||||
.chat-history-link {
|
||||
display: block; width: 100%; border-radius: 0.75rem; padding: 0.625rem 0.75rem;
|
||||
font-size: 0.875rem; text-align: left; transition: background 0.12s;
|
||||
}
|
||||
.chat-history-link:hover { background: var(--bg-surface-soft); }
|
||||
.chat-history-link--active {
|
||||
background: color-mix(in srgb, #0ea5e9 12%, var(--bg-surface-soft));
|
||||
font-weight: 500; color: #0284c7;
|
||||
}
|
||||
.ship-btn-primary { border-radius: 0.75rem; background: #059669; padding: 0.5rem 1rem; font-size: 0.875rem; font-weight: 500; color: #fff; }
|
||||
.ship-btn-primary:hover { background: #047857; }
|
||||
.ship-btn-danger { border-radius: 0.75rem; border: 1px solid #fecdd3; background: #fff1f2; padding: 0.5rem 1rem; font-size: 0.875rem; font-weight: 500; color: #be123c; }
|
||||
.ship-btn-secondary { border-radius: 0.75rem; border: 1px solid var(--border-default); padding: 0.5rem 1rem; font-size: 0.875rem; font-weight: 500; color: var(--text-secondary); }
|
||||
.ship-btn-secondary:hover { background: var(--bg-surface-soft); }
|
||||
.ship-btn-brand { border-radius: 0.75rem; background: #0284c7; padding: 0.5rem 1rem; font-size: 0.875rem; font-weight: 500; color: #fff; }
|
||||
.ship-btn-brand:hover { background: #0369a1; }
|
||||
.scrollbar-thin::-webkit-scrollbar { width: 6px; }
|
||||
.scrollbar-thin::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 999px; }
|
||||
[data-step-content] { display: none; }
|
||||
[data-step-content].visible { display: block; }
|
||||
.step-node { flex: 1; min-width: 52px; text-align: center; position: relative; }
|
||||
.step-node:not(:last-child)::after {
|
||||
content: ""; position: absolute; top: 10px; left: calc(50% + 11px);
|
||||
width: calc(100% - 22px); height: 2px; background: var(--border-default); z-index: 0;
|
||||
}
|
||||
.step-node.done:not(:last-child)::after { background: #0284c7; }
|
||||
.step-node.active:not(:last-child)::after { background: linear-gradient(90deg, #0284c7 50%, var(--border-default) 50%); }
|
||||
.step-dot {
|
||||
width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--border-default);
|
||||
background: var(--bg-surface); margin: 0 auto 0.25rem; position: relative; z-index: 1;
|
||||
display: grid; place-items: center; font-size: 0.55rem; font-weight: 700; color: var(--text-muted);
|
||||
}
|
||||
.step-node.done .step-dot { background: #0284c7; border-color: #0284c7; color: #fff; }
|
||||
.step-node.active .step-dot { border-color: #0284c7; color: #0284c7; box-shadow: 0 0 0 3px rgba(14,165,233,.18); }
|
||||
.step-label { font-size: 0.58rem; color: var(--text-muted); line-height: 1.2; }
|
||||
.step-node.active .step-label { color: #0284c7; font-weight: 600; }
|
||||
.msg-details summary { cursor: pointer; list-style-position: inside; }
|
||||
.msg-details summary::-webkit-details-marker { display: none; }
|
||||
.msg-details summary::before { content: '▸ '; color: var(--text-muted); }
|
||||
.msg-details[open] summary::before { content: '▾ '; }
|
||||
.scheme-c-badge {
|
||||
display: inline-flex; align-items: center; gap: 0.35rem;
|
||||
border-radius: 999px; border: 1px solid color-mix(in srgb, #0ea5e9 35%, var(--border-default));
|
||||
background: color-mix(in srgb, #0ea5e9 8%, var(--bg-surface));
|
||||
padding: 0.2rem 0.65rem; font-size: 0.65rem; font-weight: 600; letter-spacing: 0.04em;
|
||||
color: #0284c7; text-transform: uppercase;
|
||||
}
|
||||
.demo-bar { border-bottom: 1px dashed var(--border-default); background: color-mix(in srgb, #0ea5e9 5%, var(--bg-surface)); }
|
||||
.task-modal-backdrop { background: var(--overlay-soft, rgba(15,23,42,.4)); }
|
||||
</style>
|
||||
</head>
|
||||
<body class="antialiased">
|
||||
|
||||
<!-- 方案 C:纯对话驱动 — 无右侧工作区 / 无浏览器侧栏 -->
|
||||
<div class="relative flex h-screen overflow-hidden bg-page text-secondary">
|
||||
|
||||
<!-- ChatSidebar -->
|
||||
<aside class="glass-panel relative z-10 flex h-full w-80 shrink-0 flex-col border-r border-default bg-surface">
|
||||
<div class="flex items-center justify-between p-4">
|
||||
<div class="flex min-w-0 flex-1 items-center gap-3">
|
||||
<div class="flex h-8 w-8 shrink-0 items-center justify-center rounded-xl bg-gradient-to-br from-brand-500 via-brand-600 to-sky-600 text-sm font-bold text-white shadow-sm shadow-brand-500/25">SN</div>
|
||||
<div class="min-w-0">
|
||||
<div class="truncate font-bold text-primary">货代发货通知</div>
|
||||
<div class="mt-0.5 flex items-center gap-2">
|
||||
<span class="scheme-c-badge">方案 C</span>
|
||||
<span class="truncate text-[11px] text-muted">纯对话驱动</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="px-4 pb-4">
|
||||
<button type="button" class="chat-sidebar-btn">
|
||||
<svg class="h-4 w-4" fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24"><path d="M12 5v14M5 12h14"/></svg>
|
||||
新建对话
|
||||
</button>
|
||||
</div>
|
||||
<div class="flex items-center justify-between px-4 py-2">
|
||||
<span class="text-xs font-semibold text-slate-500">历史记录</span>
|
||||
</div>
|
||||
<div class="scrollbar-thin flex-1 overflow-y-auto px-2">
|
||||
<button type="button" class="chat-history-link chat-history-link--active">
|
||||
<div class="truncate">批量 5 票 · 进行中</div>
|
||||
<div class="mt-0.5 truncate text-[11px] text-muted">今天 09:42</div>
|
||||
</button>
|
||||
<button type="button" class="chat-history-link">
|
||||
<div class="truncate">单票 SN-…E4 · 已完成</div>
|
||||
<div class="mt-0.5 truncate text-[11px] text-muted">昨天 16:20</div>
|
||||
</button>
|
||||
</div>
|
||||
<div class="border-t border-default p-4">
|
||||
<div class="flex h-8 w-8 items-center justify-center rounded-full bg-brand-600 text-sm font-bold text-white">张</div>
|
||||
</div>
|
||||
</aside>
|
||||
|
||||
<!-- 主对话区:全宽,无右侧面板 -->
|
||||
<div class="relative z-10 flex h-full min-w-0 flex-1 flex-col overflow-hidden bg-surface">
|
||||
<div class="demo-bar flex flex-wrap items-center gap-3 px-4 py-2 text-xs">
|
||||
<span class="font-semibold text-brand-700">原型演示 · 方案 C</span>
|
||||
<label class="flex items-center gap-1.5 text-muted">步骤
|
||||
<select id="stepSelect" class="rounded-lg border border-default bg-surface px-2 py-1 text-secondary">
|
||||
<option value="batch">批次解析中</option>
|
||||
<option value="2">2 · 确认解析</option>
|
||||
<option value="3">3 · 获取库存</option>
|
||||
<option value="4">4 · 字段对齐</option>
|
||||
<option value="5-gap">5 · 匹配(缺口)</option>
|
||||
<option value="6">6 · 生成 Excel</option>
|
||||
<option value="7-running">7 · 上传中</option>
|
||||
<option value="7-failed">7 · 上传失败</option>
|
||||
<option value="7-done">7 · 上传成功</option>
|
||||
</select>
|
||||
</label>
|
||||
<span class="text-muted">本期无侧边工作区 · 全部在对话内完成</span>
|
||||
</div>
|
||||
|
||||
<main class="scrollbar-thin flex-1 overflow-y-auto p-3 md:p-8">
|
||||
<div class="flex min-h-full flex-col justify-end">
|
||||
|
||||
<!-- workflow_steps 进度头 — 对话区顶部 sticky 感 -->
|
||||
<section class="mx-auto mb-4 w-full max-w-4xl overflow-hidden rounded-2xl border border-sky-100 bg-gradient-to-br from-sky-50 via-white to-emerald-50 shadow-sm">
|
||||
<div class="border-b border-sky-100/80 px-4 py-3">
|
||||
<div class="flex flex-wrap items-center justify-between gap-2">
|
||||
<div class="text-xs text-slate-500">
|
||||
本批 <strong class="text-slate-800">5</strong> 笔 · 已完成 <strong>1</strong> · 进行中 <strong>1</strong> · 待处理 <strong>3</strong>
|
||||
</div>
|
||||
<div class="flex items-center gap-2">
|
||||
<button type="button" id="openTaskList" class="inline-flex items-center gap-1 rounded-lg border border-default bg-white/80 px-2.5 py-1 text-xs font-medium text-secondary transition hover:border-brand-300 hover:bg-brand-50 hover:text-brand-700">
|
||||
<svg class="h-3.5 w-3.5" fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24"><path d="M8 6h13M8 12h13M8 18h13M3 6h.01M3 12h.01M3 18h.01"/></svg>
|
||||
任务列表 / 续办
|
||||
</button>
|
||||
<button type="button" id="batchToggle" class="text-xs font-medium text-brand-600 hover:text-brand-700">展开列表 ▼</button>
|
||||
</div>
|
||||
</div>
|
||||
<div id="batchQueue" class="mt-2 hidden space-y-1 border-t border-dashed border-sky-100 pt-2">
|
||||
<button type="button" class="queue-switch flex w-full items-center gap-2 rounded-lg px-2 py-1.5 text-left text-xs hover:bg-white/70" data-task="A">
|
||||
<span class="text-muted">①</span><span class="flex-1">订单_A.pdf</span><span class="font-mono text-brand-600">SN-…A1</span><span class="rounded-full bg-amber-50 px-1.5 text-amber-700">步骤2 待确认</span>
|
||||
</button>
|
||||
<button type="button" class="queue-switch flex w-full items-center gap-2 rounded-lg bg-white/80 px-2 py-1.5 text-left text-xs ring-1 ring-brand-200" data-task="B">
|
||||
<span class="text-muted">②</span><span class="flex-1 font-medium">订单_B.pdf</span><span class="font-mono text-brand-600">SN-…B2</span><span class="text-brand-600">步骤 <span id="queueStepNum">2</span>/7</span>
|
||||
</button>
|
||||
<button type="button" class="queue-switch flex w-full items-center gap-2 rounded-lg px-2 py-1.5 text-left text-xs text-muted hover:bg-white/60" data-task="C">
|
||||
<span>③</span><span class="flex-1">订单_C.pdf</span><span class="font-mono">SN-…C3</span><span>排队中</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="space-y-3 px-4 py-4">
|
||||
<div class="flex flex-wrap items-baseline justify-between gap-2">
|
||||
<div>
|
||||
<div class="font-mono text-sm font-semibold text-brand-700" id="taskId">SN-20260529-B2B2B2B2</div>
|
||||
<div class="mt-0.5 text-xs text-muted">当前 · 第 <span id="taskIndex">2</span>/5 笔 · <em class="not-italic text-secondary" id="taskFile">订单_B.pdf</em></div>
|
||||
</div>
|
||||
<div class="text-xs text-muted">步骤 <strong class="text-secondary" id="currentStepNum">2</strong>/7 · <span id="currentStepName">确认解析结果</span></div>
|
||||
</div>
|
||||
<div class="flex overflow-x-auto pb-1" id="stepper"></div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<!-- 批次解析中:多票队列在消息内 -->
|
||||
<div data-step-content="batch">
|
||||
<div class="group mx-auto mb-6 flex w-full max-w-4xl animate-slide-up justify-end">
|
||||
<div class="max-w-[88%] md:max-w-[74%]">
|
||||
<div class="rounded-2xl rounded-tr-sm bg-brand-600 px-5 py-2.5 text-[15px] text-white shadow-sm shadow-brand-500/15">已上传 5 份发货通知</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="group mx-auto mb-6 flex w-full max-w-4xl animate-slide-up justify-start">
|
||||
<div class="w-full chat-msg-assistant">
|
||||
<p class="text-sm text-secondary">正在按文件顺序逐个解析,您可在下方查看批次进度并切换任务。</p>
|
||||
<div class="mt-3 flex items-center gap-3 text-xs text-muted">
|
||||
<span>正在解析第 2/5 个文件:订单_B.pdf</span>
|
||||
<div class="h-1 max-w-[120px] flex-1 rounded-full bg-slate-200"><div class="h-full w-2/5 rounded-full bg-brand-500"></div></div>
|
||||
</div>
|
||||
<div class="mt-4 space-y-2 rounded-xl border border-default bg-surface-soft/90 p-3">
|
||||
<div class="flex items-center gap-2 rounded-lg border border-emerald-200 bg-emerald-50/80 px-3 py-2 text-xs">
|
||||
<span class="font-medium text-emerald-800">① 订单_A.pdf</span>
|
||||
<span class="font-mono text-emerald-700">SN-…A1</span>
|
||||
<span class="ml-auto rounded-full bg-white px-2 py-0.5 text-emerald-700">✓ 步骤2 待您确认</span>
|
||||
<button type="button" class="ship-btn-secondary py-1 text-xs">去确认</button>
|
||||
</div>
|
||||
<div class="flex items-center gap-2 rounded-lg border border-brand-200 bg-brand-50/80 px-3 py-2 text-xs">
|
||||
<span class="font-medium text-brand-800">② 订单_B.pdf</span>
|
||||
<span class="font-mono text-brand-700">SN-…B2</span>
|
||||
<span class="ml-auto text-brand-600">◐ 解析中</span>
|
||||
</div>
|
||||
<div class="flex items-center gap-2 rounded-lg px-3 py-2 text-xs text-muted">
|
||||
<span>③ 订单_C.pdf</span><span class="font-mono">SN-…C3</span><span class="ml-auto">○ 排队中</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Step 2 -->
|
||||
<div data-step-content="2">
|
||||
<div class="group mx-auto mb-6 flex w-full max-w-4xl justify-end">
|
||||
<div class="max-w-[88%] md:max-w-[74%]">
|
||||
<div class="rounded-2xl rounded-tr-sm bg-brand-600 px-5 py-2.5 text-[15px] text-white shadow-sm shadow-brand-500/15">已上传:订单_B.pdf</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="group mx-auto mb-6 flex w-full max-w-4xl justify-start">
|
||||
<div class="w-full chat-msg-assistant">
|
||||
<p class="text-sm font-medium text-secondary">已解析 <strong>订单_B.pdf</strong>,共 <strong>4</strong> 行。请核对后确认;缺失 Reservation ID 的行已标黄。</p>
|
||||
<div class="mt-4 space-y-4 rounded-2xl border border-default bg-surface-soft/90 p-4">
|
||||
<div class="flex flex-wrap items-center justify-between gap-2">
|
||||
<span class="text-xs font-bold uppercase tracking-wider text-muted">解析结果 · 消息内编辑</span>
|
||||
<span class="rounded-full bg-emerald-50 px-2 py-0.5 text-xs font-semibold text-emerald-700">置信度 92%</span>
|
||||
</div>
|
||||
<div class="overflow-x-auto">
|
||||
<table class="w-full border-collapse text-sm">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="border border-slate-200 bg-slate-50 px-3 py-2 text-left text-xs font-semibold text-muted">#</th>
|
||||
<th class="border border-slate-200 bg-slate-50 px-3 py-2 text-left text-xs font-semibold text-muted">SKU</th>
|
||||
<th class="border border-slate-200 bg-slate-50 px-3 py-2 text-left text-xs font-semibold text-muted">Reservation ID</th>
|
||||
<th class="border border-slate-200 bg-slate-50 px-3 py-2 text-left text-xs font-semibold text-muted">数量</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="text-secondary">
|
||||
<tr><td class="border border-slate-200 px-2 py-1.5">1</td><td class="border border-slate-200 px-2 py-1"><input class="w-full rounded border-0 bg-transparent px-1 py-0.5 font-mono text-xs focus:bg-white focus:ring-1 focus:ring-brand-400" value="HX-MCU-8842" /></td><td class="border border-slate-200 px-2 py-1"><input class="w-full rounded border-0 bg-transparent px-1 py-0.5 font-mono text-xs focus:bg-white focus:ring-1 focus:ring-brand-400" value="8842156301" /></td><td class="border border-slate-200 px-2 py-1"><input class="w-16 rounded border-0 bg-transparent px-1 py-0.5 text-xs focus:bg-white focus:ring-1 focus:ring-brand-400" value="500" /></td></tr>
|
||||
<tr class="bg-amber-50"><td class="border border-slate-200 px-2 py-1.5">3</td><td class="border border-slate-200 px-2 py-1 font-mono text-xs">HX-CONN-9910</td><td class="border border-slate-200 px-2 py-1 text-xs text-amber-700">缺失 — 请补充</td><td class="border border-slate-200 px-2 py-1">120</td></tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<!-- 方案 C:原文对照用折叠区,不用侧栏 -->
|
||||
<details class="msg-details rounded-xl border border-default bg-surface px-4 py-3">
|
||||
<summary class="text-xs font-semibold uppercase tracking-wide text-secondary">展开原文对照 · 订单_B.pdf</summary>
|
||||
<div class="mt-3 space-y-2 rounded-lg bg-surface-soft p-3 font-mono text-xs text-muted">
|
||||
<div class="rounded border border-amber-200 bg-amber-50 p-2 text-amber-900">Line 12: RSV 8842156301 · Part HX-MCU-8842 · Qty 500</div>
|
||||
<div class="h-2 rounded bg-slate-200"></div><div class="h-2 w-3/4 rounded bg-slate-200"></div>
|
||||
</div>
|
||||
</details>
|
||||
</div>
|
||||
<div class="mt-4 space-y-2 border-t border-default pt-4">
|
||||
<div class="text-xs font-medium text-muted">请选择操作</div>
|
||||
<div class="flex flex-wrap gap-2">
|
||||
<button type="button" class="ship-btn-primary">确认并下一步</button>
|
||||
<button type="button" class="ship-btn-secondary">重新解析</button>
|
||||
<button type="button" class="ship-btn-danger">驳回任务</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Step 3 -->
|
||||
<div data-step-content="3">
|
||||
<div class="group mx-auto mb-6 flex w-full max-w-4xl justify-start">
|
||||
<div class="w-full chat-msg-assistant">
|
||||
<p class="text-sm text-secondary">请获取库存:可自动抓取或上传 Excel。大表请走附件,勿粘贴进对话框。</p>
|
||||
<div class="mt-3 flex items-center gap-3 text-xs text-muted">
|
||||
<span>抓取库存中…</span>
|
||||
<div class="h-1 max-w-[140px] flex-1 rounded-full bg-slate-200"><div class="h-full w-[60%] rounded-full bg-brand-500"></div></div>
|
||||
<span>60%</span>
|
||||
</div>
|
||||
<div class="mt-4 space-y-2 border-t border-default pt-4">
|
||||
<div class="text-xs font-medium text-muted">请选择操作</div>
|
||||
<div class="flex flex-wrap gap-2">
|
||||
<button type="button" class="ship-btn-secondary">1. 上传库存 Excel</button>
|
||||
<button type="button" class="ship-btn-secondary">2. 重试 RPA 抓取</button>
|
||||
<button type="button" class="ship-btn-primary opacity-50" disabled>确认库存快照</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Step 4 -->
|
||||
<div data-step-content="4">
|
||||
<div class="group mx-auto mb-6 flex w-full max-w-4xl justify-start">
|
||||
<div class="w-full chat-msg-assistant">
|
||||
<p class="whitespace-pre-wrap text-sm font-medium text-secondary">已读取库存表 4,821 行。请确认列映射(与 ShippingInventoryMappingMessage 一致)。</p>
|
||||
<div class="mt-4 space-y-4 rounded-2xl border border-default bg-surface-soft/90 p-4">
|
||||
<div class="text-xs font-bold uppercase tracking-wider text-muted">库存表头</div>
|
||||
<div class="flex flex-wrap gap-2">
|
||||
<span class="rounded-full border border-default bg-surface px-3 py-1 text-xs">Part Number</span>
|
||||
<span class="rounded-full border border-default bg-surface px-3 py-1 text-xs">COM ID</span>
|
||||
<span class="rounded-full border border-default bg-surface px-3 py-1 text-xs">Qty Available</span>
|
||||
</div>
|
||||
<div class="grid gap-4 md:grid-cols-2">
|
||||
<label class="space-y-1.5"><span class="text-xs font-semibold text-muted">SKU 列 *</span><select class="w-full rounded-xl border border-default px-3 py-2 text-sm"><option>Part Number</option></select></label>
|
||||
<label class="space-y-1.5"><span class="text-xs font-semibold text-muted">可用数量 *</span><select class="w-full rounded-xl border border-default px-3 py-2 text-sm"><option>Qty Available</option></select></label>
|
||||
<label class="space-y-1.5 md:col-span-2"><span class="text-xs font-semibold text-muted">Reservation ID</span><select class="w-full rounded-xl border border-default px-3 py-2 text-sm"><option>COM ID</option></select></label>
|
||||
</div>
|
||||
<div class="flex justify-end gap-2">
|
||||
<button type="button" class="ship-btn-secondary">重新上传</button>
|
||||
<button type="button" class="ship-btn-primary">确认并解析</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="mt-4 border-t border-default pt-4">
|
||||
<div class="text-xs font-medium text-muted">请选择操作</div>
|
||||
<div class="mt-2 flex flex-wrap gap-2">
|
||||
<button type="button" class="ship-btn-primary">确认映射并匹配</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Step 5 gap -->
|
||||
<div data-step-content="5-gap">
|
||||
<div class="group mx-auto mb-6 flex w-full max-w-4xl justify-start">
|
||||
<div class="w-full chat-msg-assistant">
|
||||
<p class="text-sm text-secondary">匹配完成:2/4 行满足,2 行缺口。存在缺口时默认禁止发货,须补库存或返回修订后重匹配。</p>
|
||||
<div class="mt-4 overflow-x-auto rounded-2xl border border-default">
|
||||
<table class="w-full border-collapse text-sm">
|
||||
<thead><tr>
|
||||
<th class="border border-slate-200 bg-slate-50 px-3 py-2 text-left text-xs">SKU</th>
|
||||
<th class="border border-slate-200 bg-slate-50 px-3 py-2 text-left text-xs">需求</th>
|
||||
<th class="border border-slate-200 bg-slate-50 px-3 py-2 text-left text-xs">可用</th>
|
||||
<th class="border border-slate-200 bg-slate-50 px-3 py-2 text-left text-xs">缺口</th>
|
||||
<th class="border border-slate-200 bg-slate-50 px-3 py-2 text-left text-xs">状态</th>
|
||||
</tr></thead>
|
||||
<tbody>
|
||||
<tr class="bg-emerald-50/50"><td class="border border-slate-200 px-3 py-2 font-mono text-xs">HX-MCU-8842</td><td class="border border-slate-200 px-3 py-2">500</td><td class="border border-slate-200 px-3 py-2">520</td><td class="border border-slate-200 px-3 py-2">0</td><td class="border border-slate-200 px-3 py-2"><span class="rounded-full bg-emerald-50 px-2 text-xs text-emerald-700">满足</span></td></tr>
|
||||
<tr class="bg-rose-50/70"><td class="border border-slate-200 px-3 py-2 font-mono text-xs">HX-LED-3300</td><td class="border border-slate-200 px-3 py-2">800</td><td class="border border-slate-200 px-3 py-2">0</td><td class="border border-slate-200 px-3 py-2 font-semibold text-rose-700">-800</td><td class="border border-slate-200 px-3 py-2"><span class="rounded-full bg-rose-50 px-2 text-xs text-rose-700">不足</span></td></tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div id="gapBanner" class="mt-4 rounded-xl border px-4 py-3" style="background:var(--status-error-bg);border-color:#ffb3b0">
|
||||
<div class="text-sm font-semibold" style="color:var(--status-error-fg)" id="gapTitle">存在库存缺口</div>
|
||||
<p class="mt-1 text-xs text-secondary" id="gapDesc"></p>
|
||||
<span class="mt-2 inline-block rounded px-2 py-0.5 text-[11px] font-semibold bg-rose-100 text-rose-700" id="gapModeTag">缺口阻断</span>
|
||||
</div>
|
||||
<div class="mt-4 border-t border-default pt-4">
|
||||
<div class="text-xs font-medium text-muted">请选择操作</div>
|
||||
<div class="mt-2 flex flex-wrap gap-2" id="gapActions"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Step 6 -->
|
||||
<div data-step-content="6">
|
||||
<div class="group mx-auto mb-6 flex w-full max-w-4xl justify-start">
|
||||
<div class="w-full chat-msg-assistant">
|
||||
<p class="text-sm text-secondary">发货 Excel 已生成(全部应发行)。</p>
|
||||
<div class="mt-4 rounded-2xl border border-default bg-surface-soft/90 p-5 text-center">
|
||||
<div class="mx-auto mb-2 flex h-12 w-12 items-center justify-center rounded-xl bg-emerald-50 text-sm font-bold text-emerald-700">XLS</div>
|
||||
<div class="font-mono text-sm font-semibold">SN-20260529-B2B2B2B2-20260616.xlsx</div>
|
||||
<div class="mt-1 text-xs text-muted">2 行 · 货代模板 · 可下载</div>
|
||||
<button type="button" class="ship-btn-brand mt-4">下载 Excel</button>
|
||||
</div>
|
||||
<details class="msg-details mt-4 rounded-xl border border-default bg-surface-soft/90 px-4 py-3">
|
||||
<summary class="text-xs font-semibold text-secondary">展开列预览(前 5 列)</summary>
|
||||
<div class="mt-2 overflow-x-auto text-xs"><table class="w-full"><tr class="text-muted"><td class="py-1 pr-3">SKU</td><td class="py-1 pr-3">RSV</td><td class="py-1">Qty</td></tr><tr><td class="font-mono">HX-MCU-8842</td><td class="font-mono">8842156301</td><td>500</td></tr></table></div>
|
||||
</details>
|
||||
<div class="mt-4 border-t border-default pt-4">
|
||||
<div class="text-xs font-medium text-muted">请选择操作</div>
|
||||
<div class="mt-2 flex flex-wrap gap-2">
|
||||
<button type="button" class="ship-btn-primary">确认并上传货代</button>
|
||||
<button type="button" class="ship-btn-secondary">重新生成</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Step 7 running -->
|
||||
<div data-step-content="7-running">
|
||||
<div class="group mx-auto mb-6 flex w-full max-w-4xl justify-start">
|
||||
<div class="w-full chat-msg-assistant">
|
||||
<div class="rounded-xl border px-4 py-3" style="background:var(--status-info-bg);border-color:#9fcbff">
|
||||
<div class="flex items-center gap-2 text-sm font-semibold" style="color:var(--status-info-fg)">
|
||||
<svg class="h-4 w-4 animate-spin" fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24"><path d="M21 12a9 9 0 1 1-6.219-8.56"/></svg>
|
||||
货代上传 · 上传中
|
||||
</div>
|
||||
<p class="mt-2 text-xs text-secondary">任务 <span class="font-mono">SN-20260529-B2B2B2B2</span> · 自动上传模式 · 第 1 次尝试</p>
|
||||
<div class="mt-3 flex items-center gap-3 text-xs text-muted">
|
||||
<span>等待货代回执</span>
|
||||
<div class="h-1 max-w-[160px] flex-1 rounded-full bg-slate-200"><div class="h-full w-[70%] rounded-full bg-brand-500 animate-pulse"></div></div>
|
||||
</div>
|
||||
</div>
|
||||
<p class="mt-3 text-xs text-muted">上传完成前请勿重复发起;状态将自动刷新。</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Step 7 failed -->
|
||||
<div data-step-content="7-failed">
|
||||
<div class="group mx-auto mb-6 flex w-full max-w-4xl justify-start">
|
||||
<div class="w-full chat-msg-assistant">
|
||||
<div class="rounded-xl border px-4 py-3" style="background:var(--status-error-bg);border-color:#ffb3b0">
|
||||
<div class="text-sm font-semibold" style="color:var(--status-error-fg)">货代上传失败</div>
|
||||
<p class="mt-2 text-xs text-secondary">错误码 <code class="rounded bg-white/80 px-1 font-mono">UPLOAD_RPA_TIMEOUT</code> · RPA 超时未回调</p>
|
||||
<p class="mt-1 text-xs text-muted">started: 2026-06-16 10:32:01 · attempt: 1</p>
|
||||
</div>
|
||||
<div class="mt-4 border-t border-default pt-4">
|
||||
<div class="text-xs font-medium text-muted">请选择操作</div>
|
||||
<div class="mt-2 flex flex-wrap gap-2">
|
||||
<button type="button" class="ship-btn-brand">重试自动上传</button>
|
||||
<button type="button" class="ship-btn-secondary">改为手工上传</button>
|
||||
<button type="button" class="ship-btn-primary">确认已手工上传完成</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Step 7 done -->
|
||||
<div data-step-content="7-done">
|
||||
<div class="group mx-auto mb-6 flex w-full max-w-4xl justify-start">
|
||||
<div class="w-full chat-msg-assistant">
|
||||
<div class="rounded-xl border px-4 py-3" style="background:var(--status-success-bg);border-color:#b7e2a7">
|
||||
<div class="text-sm font-semibold" style="color:var(--status-success-fg)">货代上传成功 · 任务已完成</div>
|
||||
<p class="mt-2 text-xs text-secondary">回执摘要:FreightRef #FR-882910 · 2026-06-16 10:35:22</p>
|
||||
</div>
|
||||
<div class="mt-4 border-t border-default pt-4">
|
||||
<div class="text-xs font-medium text-muted">请选择操作</div>
|
||||
<div class="mt-2 flex flex-wrap gap-2">
|
||||
<button type="button" class="ship-btn-secondary">查看审计记录</button>
|
||||
<button type="button" class="ship-btn-brand">新建任务</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</main>
|
||||
|
||||
<!-- ChatInputBar — 方案 C:无「打开浏览器」入口 -->
|
||||
<footer class="sticky bottom-0 z-20 bg-transparent p-3 md:p-6">
|
||||
<div class="relative mx-auto max-w-4xl">
|
||||
<div class="flex flex-col rounded-2xl bg-surface p-2 shadow-[0_0_15px_rgba(0,0,0,0.05)]">
|
||||
<textarea rows="1" placeholder="输入「确认」、粘贴邮件正文,或回复数字菜单…"
|
||||
class="w-full resize-none border-none bg-transparent px-3 py-2 text-[15px] leading-relaxed text-primary placeholder-slate-400 focus:outline-none"
|
||||
style="min-height:44px;max-height:220px"></textarea>
|
||||
<div class="mt-2 flex items-center justify-between px-2 pb-1">
|
||||
<div class="flex items-center gap-3">
|
||||
<button type="button" class="text-muted hover:text-brand-600" title="语音">
|
||||
<svg class="h-5 w-5" fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24"><path d="M12 2a3 3 0 0 0-3 3v6a3 3 0 0 0 6 0V5a3 3 0 0 0-3-3Z"/><path d="M19 10v1a7 7 0 0 1-14 0v-1"/><path d="M12 18v4"/></svg>
|
||||
</button>
|
||||
<button type="button" class="flex h-9 w-9 items-center justify-center rounded-lg text-muted hover:text-brand-600" title="附件">
|
||||
<svg class="h-5 w-5" fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24"><path d="m21.44 11.05-9.19 9.19a6 6 0 0 1-8.49-8.49l9.19-9.19a4 4 0 0 1 5.66 5.66l-9.2 9.19a2 2 0 0 1-2.83-2.83l8.49-8.48"/></svg>
|
||||
</button>
|
||||
<span class="hidden text-[11px] text-muted sm:inline">方案 C · 纯对话 · 无侧栏</span>
|
||||
</div>
|
||||
<button type="button" class="flex h-10 w-10 items-center justify-center rounded-full border border-brand-500 bg-brand-500 text-white shadow-[0_0_0_4px_rgba(59,130,246,0.18)] hover:bg-brand-600">
|
||||
<svg class="h-4 w-4" fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24"><path d="m22 2-7 20-4-9-9-4Z"/><path d="M22 2 11 13"/></svg>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="mt-3 text-center text-[11px] text-muted">AI 生成内容仅供参考,请以业务系统与原件为准。</div>
|
||||
</div>
|
||||
</footer>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 任务列表弹层 — 方案 C 独立入口(TC-18 / 续办) -->
|
||||
<div id="taskModal" class="fixed inset-0 z-[100] hidden items-center justify-center task-modal-backdrop p-4">
|
||||
<div class="max-h-[85vh] w-full max-w-lg overflow-hidden rounded-2xl border border-default bg-surface shadow-xl animate-fade-in">
|
||||
<div class="flex items-center justify-between border-b border-default px-5 py-4">
|
||||
<div>
|
||||
<h2 class="text-base font-bold text-primary">任务列表</h2>
|
||||
<p class="mt-0.5 text-xs text-muted">切换任务后对话顶部 Stepper 与操作同步更新</p>
|
||||
</div>
|
||||
<button type="button" id="closeTaskModal" class="rounded-lg p-2 text-muted hover:bg-surface-soft">✕</button>
|
||||
</div>
|
||||
<div class="scrollbar-thin max-h-[60vh] overflow-y-auto p-3">
|
||||
<button type="button" class="task-pick mb-2 flex w-full flex-col rounded-xl border border-brand-200 bg-brand-50/50 p-4 text-left" data-sn="SN-20260529-B2B2B2B2" data-file="订单_B.pdf" data-step="2">
|
||||
<div class="flex items-center justify-between"><span class="font-mono text-sm font-semibold text-brand-700">SN-20260529-B2B2B2B2</span><span class="rounded-full bg-brand-100 px-2 py-0.5 text-xs text-brand-700">进行中</span></div>
|
||||
<div class="mt-1 text-sm text-secondary">订单_B.pdf · 步骤 2/7 · 待确认解析</div>
|
||||
<div class="mt-2 text-xs text-brand-600">当前聚焦 →</div>
|
||||
</button>
|
||||
<button type="button" class="task-pick mb-2 flex w-full flex-col rounded-xl border border-default p-4 text-left hover:bg-surface-soft" data-sn="SN-20260529-A1A1A1A1" data-file="订单_A.pdf" data-step="2">
|
||||
<div class="flex items-center justify-between"><span class="font-mono text-sm font-semibold">SN-20260529-A1A1A1A1</span><span class="rounded-full bg-amber-50 px-2 py-0.5 text-xs text-amber-700">待确认</span></div>
|
||||
<div class="mt-1 text-sm text-muted">订单_A.pdf · 步骤 2/7</div>
|
||||
</button>
|
||||
<button type="button" class="task-pick flex w-full flex-col rounded-xl border border-default p-4 text-left hover:bg-surface-soft" data-sn="SN-20260528-E4E4E4E4" data-file="订单_E.xlsx" data-step="7">
|
||||
<div class="flex items-center justify-between"><span class="font-mono text-sm font-semibold">SN-20260528-E4E4E4E4</span><span class="rounded-full bg-emerald-50 px-2 py-0.5 text-xs text-emerald-700">已完成</span></div>
|
||||
<div class="mt-1 text-sm text-muted">续办示例 · 步骤 7/7 · 上传成功</div>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
const STEPS = [
|
||||
{ num: 1, name: '提交通知' }, { num: 2, name: '确认解析' }, { num: 3, name: '获取库存' },
|
||||
{ num: 4, name: '字段对齐' }, { num: 5, name: '匹配库存' }, { num: 6, name: '生成Excel' }, { num: 7, name: '上传货代' },
|
||||
];
|
||||
const STEP_META = {
|
||||
batch: { step: 1, name: '批量解析', queue: 1 },
|
||||
'2': { step: 2, name: '确认解析结果', queue: 2 },
|
||||
'3': { step: 3, name: '获取库存数据', queue: 2 },
|
||||
'4': { step: 4, name: '确认字段对齐', queue: 2 },
|
||||
'5-gap': { step: 5, name: '匹配 · 缺口阻断', queue: 2 },
|
||||
'6': { step: 6, name: '生成发货 Excel', queue: 2 },
|
||||
'7-running': { step: 7, name: '上传货代 · 上传中', queue: 2 },
|
||||
'7-failed': { step: 7, name: '上传货代 · 失败', queue: 2 },
|
||||
'7-done': { step: 7, name: '已完成', queue: 2 },
|
||||
};
|
||||
const GAP = {
|
||||
title: '存在库存缺口 — 禁止继续发货',
|
||||
desc: '不可进入步骤 6/7。请补库存、返回字段对齐或重新匹配,直至全部行满足。',
|
||||
btns: ['reupload', 'remap', 'rematch', 'reject'],
|
||||
};
|
||||
const BTN = {
|
||||
reupload: '<button type="button" class="ship-btn-secondary">重新上传库存</button>',
|
||||
remap: '<button type="button" class="ship-btn-secondary">返回字段对齐</button>',
|
||||
rematch: '<button type="button" class="ship-btn-secondary">重新匹配</button>',
|
||||
reject: '<button type="button" class="ship-btn-danger">驳回任务</button>',
|
||||
};
|
||||
|
||||
const stepSelect = document.getElementById('stepSelect');
|
||||
const stepper = document.getElementById('stepper');
|
||||
const taskModal = document.getElementById('taskModal');
|
||||
|
||||
function renderStepper(n) {
|
||||
stepper.innerHTML = STEPS.map(s => {
|
||||
let c = 'step-node';
|
||||
if (s.num < n) c += ' done';
|
||||
else if (s.num === n) c += ' active';
|
||||
return `<div class="${c}"><div class="step-dot">${s.num < n ? '✓' : s.num}</div><div class="step-label">${s.name}</div></div>`;
|
||||
}).join('');
|
||||
}
|
||||
|
||||
function showStep(key) {
|
||||
const m = STEP_META[key] || STEP_META['2'];
|
||||
document.getElementById('currentStepNum').textContent = m.step;
|
||||
document.getElementById('currentStepName').textContent = m.name;
|
||||
document.getElementById('queueStepNum').textContent = m.step;
|
||||
document.getElementById('taskIndex').textContent = m.queue;
|
||||
renderStepper(m.step);
|
||||
document.querySelectorAll('[data-step-content]').forEach(el => {
|
||||
el.classList.toggle('visible', el.dataset.stepContent === key);
|
||||
});
|
||||
if (key === '5-gap') applyGap();
|
||||
}
|
||||
|
||||
function applyGap() {
|
||||
document.getElementById('gapTitle').textContent = GAP.title;
|
||||
document.getElementById('gapDesc').innerHTML = GAP.desc;
|
||||
document.getElementById('gapActions').innerHTML = GAP.btns.map(k => BTN[k]).join('');
|
||||
}
|
||||
|
||||
stepSelect.addEventListener('change', () => showStep(stepSelect.value));
|
||||
document.getElementById('batchToggle').addEventListener('click', function () {
|
||||
const q = document.getElementById('batchQueue');
|
||||
const hidden = q.classList.toggle('hidden');
|
||||
this.textContent = hidden ? '展开列表 ▼' : '收起列表 ▲';
|
||||
});
|
||||
document.getElementById('openTaskList').addEventListener('click', () => {
|
||||
taskModal.classList.remove('hidden');
|
||||
taskModal.classList.add('flex');
|
||||
});
|
||||
document.getElementById('closeTaskModal').addEventListener('click', () => {
|
||||
taskModal.classList.add('hidden');
|
||||
taskModal.classList.remove('flex');
|
||||
});
|
||||
taskModal.addEventListener('click', e => {
|
||||
if (e.target === taskModal) { taskModal.classList.add('hidden'); taskModal.classList.remove('flex'); }
|
||||
});
|
||||
document.querySelectorAll('.task-pick').forEach(btn => {
|
||||
btn.addEventListener('click', () => {
|
||||
document.getElementById('taskId').textContent = btn.dataset.sn;
|
||||
document.getElementById('taskFile').textContent = btn.dataset.file;
|
||||
taskModal.classList.add('hidden');
|
||||
taskModal.classList.remove('flex');
|
||||
});
|
||||
});
|
||||
|
||||
showStep('2');
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
+45
-41
@@ -49,8 +49,10 @@ flask db upgrade
|
||||
# hxops 侧 Tool API 根地址(OpenAPI 导出、RPA 回调等;Dify OpenAPI Credential 的 Server URL 应与此一致)
|
||||
HXOPS_TOOLS_API_BASE=http://192.168.100.192:8890
|
||||
|
||||
# 统一 Tool API Key(Dify OpenAPI 工具 Credential、RPA 回调共用;不再注入 Dify Start 变量)
|
||||
INTEGRATION_API_KEY=your-tool-key
|
||||
# 货代 Tool API Key(Dify OpenAPI 工具 Credential、RPA 回调共用;不再注入 Dify Start 变量)
|
||||
# 未配置时后端回退 INTEGRATION_API_KEY,建议新环境优先配置专用 key。
|
||||
SHIPPING_NOTICE_TOOL_API_KEY=your-tool-key
|
||||
# INTEGRATION_API_KEY=your-tool-key
|
||||
|
||||
# 文件存储
|
||||
SHIPPING_NOTICE_STORAGE_ROOT=data/shipping_notice
|
||||
@@ -73,11 +75,12 @@ FREIGHT_SHIPMENT_TEMPLATE_PATH=templates/freight_shipment_upload.xlsx
|
||||
# 自动推进 / 自动上传
|
||||
# SHIPPING_NOTICE_AUTO_PROGRESS_ENABLED=true
|
||||
# SHIPPING_NOTICE_AUTO_RPA_INVENTORY_ENABLED=true
|
||||
# SHIPPING_NOTICE_RPA_INVENTORY_MAX_ATTEMPTS=3
|
||||
# SHIPPING_NOTICE_RPA_INVENTORY_MAX_ATTEMPTS=1
|
||||
# SHIPPING_NOTICE_AUTO_MAPPING_ALLOW_LLM=true
|
||||
# SHIPPING_NOTICE_AUTO_MATCH_ENABLED=true
|
||||
# SHIPPING_NOTICE_AUTO_GENERATE_EXCEL_ENABLED=true
|
||||
# SHIPPING_NOTICE_AUTO_UPLOAD_ENABLED=true
|
||||
# 真实货代上传 RPA 尚未完成,默认 false;仅 mock 或已接入正式上传 Driver 后再开启。
|
||||
# SHIPPING_NOTICE_AUTO_UPLOAD_ENABLED=false
|
||||
# SHIPPING_NOTICE_AUTO_CHAIN_FALLBACK=true
|
||||
# SHIPPING_NOTICE_EXPORT_FILENAME_PATTERN={task_no}-{date}.xlsx
|
||||
|
||||
@@ -118,7 +121,7 @@ python seed_shipping_notice_agents.py
|
||||
|
||||
```powershell
|
||||
$env:HXOPS_API_BASE = "http://127.0.0.1:5052"
|
||||
$env:INTEGRATION_API_KEY = "your-tool-key"
|
||||
$env:SHIPPING_NOTICE_TOOL_API_KEY = "your-tool-key"
|
||||
$env:FREIGHT_RPA_MOCK = "true"
|
||||
python scripts/rpa/freight_rpa_worker.py
|
||||
```
|
||||
@@ -157,7 +160,7 @@ pytest tests/test_shipping_notice_tools.py tests/test_shipping_notice_query_serv
|
||||
| 应用模式 | `advanced-chat` |
|
||||
| DSL version | `0.6.0` |
|
||||
| OpenAPI 地址 | `http://<host>/api/shipping-notice/tools/openapi.json` |
|
||||
| 认证 | `Authorization: Bearer <token>` 或 `X-Integration-Key: <INTEGRATION_API_KEY>` |
|
||||
| 认证 | `Authorization: Bearer <token>` 或 `X-Integration-Key: <SHIPPING_NOTICE_TOOL_API_KEY>`;未配置专用 key 时回退 `INTEGRATION_API_KEY` |
|
||||
|
||||
### 2.2 导入后应看到的 Tool
|
||||
|
||||
@@ -373,7 +376,7 @@ http://<host>/api/shipping-notice/tools/openapi.json
|
||||
|
||||
1. 鉴权:
|
||||
- `Authorization: Bearer <token>`,或
|
||||
- `X-Integration-Key: <INTEGRATION_API_KEY>`
|
||||
- `X-Integration-Key: <SHIPPING_NOTICE_TOOL_API_KEY>`(未配置专用 key 时可使用 `<INTEGRATION_API_KEY>`)
|
||||
2. 手动创建画布后,在每个 Tool 节点中重新选择:
|
||||
- `Hxops Shipping Notice`
|
||||
|
||||
@@ -1105,6 +1108,7 @@ def main(text: str = ""):
|
||||
|
||||
- 本节点只校验并规范化 LLM 返回的 `map_json`,不生成业务结论。
|
||||
- 字段缺失、JSON 非法等失败都应在这里收口成统一错误文本,供后续 Answer 节点直接展示。
|
||||
- Dify OpenAPI Tool 参数使用 `string` 才能稳定选择上游变量,因此本节点输出 JSON 字符串;后端仍兼容对象入参,仅供 Hxops 前端内部调用。
|
||||
|
||||
##### 节点:库存列映射是否成功
|
||||
|
||||
@@ -1989,25 +1993,17 @@ Agent 禁用 Tool:
|
||||
|
||||
```text
|
||||
#### 角色
|
||||
|
||||
你是 **货代发货通知助手**,通过发货通知 Tool API 处理客户发货指令。需要人工复核时暂停,等待用户明确选择后再继续。
|
||||
|
||||
发货通知已由 **当前对话上传并保存 raw_text**;随后由画布 LLM 节点解析订单需求,并调用 `parse_notice(structured=...)` 落库。你收到 `parse_msg`(或 `get_task_status.message`)后**原文展示**并引导确认。库存 Excel 由用户在当前对话上传后,由画布 **Tool 节点**完成列映射;Agent **禁止**自行推断 `map_json`,也不要脱离既定解析节点重复执行 `parse_notice`。
|
||||
若用户用自然语言要求“改采购单号 / 改预订单号 / 改料号 / 改数量 / 新增一行 / 删除一行”,应优先调用 `update_notice_fields`、`update_notice_line`、`add_notice_line`、`remove_notice_line` 持久化修改,禁止只在回复里口头改写解析结果。
|
||||
|
||||
当 **当前对话** 已上传通知并自动发起首轮续办时,你**不得**再询问用户“是否开始解析”“是否现在开始解析”“请确认是否开始解析”。首轮续办的正确行为是:立即读取 `raw_text` → 由画布 LLM 节点抽取 structured → 调用 `parse_notice(structured=...)` → 再根据返回结果决定是否进入人工确认。只有当 `parse_notice` 或后端状态机明确返回 `needs_human` / `stop_agent_turn=true` 时,才允许进入确认语义。
|
||||
|
||||
首层附件分流由 Chatflow 的 Code 节点完成(通知/库存附件 → 引导回 **当前对话** 上传)。你负责第二层业务理解与 Tool 调用,**不要接管首层分流职责**。
|
||||
|
||||
#### 重新解析与重新上传边界
|
||||
|
||||
- `reparse` 只表示:基于当前任务已保存的 `raw_text` 重新执行 Dify 结构化抽取与 `parse_notice`,**不会重新读取原 PDF,也不会重跑 `loader_pdf`**。
|
||||
- 当后端返回 `notice_text_extraction_failed`,说明当前任务没有可审核内容;用户应在宿主系统上传清晰版 PDF/文本,宿主系统调用 `/api/workspace/shipping-tasks/<task_no>/replace-notice` 覆盖当前任务通知文件。
|
||||
- `replace-notice` 保留原 `task_no / batch_no / batch_index`,重新执行 `save_task_notice_upload → extract_notice_text(loader_pdf/OCR) → 覆盖 raw_content → 重置旧解析/匹配/导出状态 → 重新编排当前票`。
|
||||
- 用户主动上传多份新通知时才新建批次;当前任务失败上下文里的单文件重新上传必须修复当前票,禁止误建新批次。
|
||||
|
||||
#### 主流程
|
||||
|
||||
【宿主系统已完成】建 task + raw_text 落库
|
||||
→ Dify LLM 解析订单需求 + parse_notice(structured=...)
|
||||
→ submit_decision(confirm)
|
||||
@@ -2015,11 +2011,8 @@ Agent 禁用 Tool:
|
||||
→ 【暂停】align_msg
|
||||
→ submit_decision(confirm_inventory_mapping)
|
||||
→ hxops worker 统一续跑匹配、Excel 生成与上传
|
||||
|
||||
#### Tool 响应字段
|
||||
|
||||
每轮 Tool 调用后必须读取:
|
||||
|
||||
| 字段 | 含义 |
|
||||
|------|------|
|
||||
| `status` | `ok` / `running` / `needs_human` / `failed` |
|
||||
@@ -2031,9 +2024,21 @@ Agent 禁用 Tool:
|
||||
| `message` | 固定格式人类可读文案(须原文展示) |
|
||||
| `data.schema_preview` | 表头 + 样例行 |
|
||||
| `data.field_alignment` | 字段对齐详情 |
|
||||
|
||||
#### 回复格式契约
|
||||
当 `action_buttons` 或 `human_options` 非空时,最终回复正文只能包含:
|
||||
1. 一句当前状态。
|
||||
2. 一句业务影响或原因。
|
||||
3. 如确实需要用户操作,只写:`请使用下方按钮继续。`
|
||||
禁止输出任何 Markdown / 文本操作清单,包括但不限于:
|
||||
- `请选择以下方式`
|
||||
- `请选择操作`
|
||||
- `推荐下一步`
|
||||
- `1. 选择库存文件`
|
||||
- `2. 重试 RPA`
|
||||
- `3. 粘贴库存`
|
||||
- 任意把按钮文字重复写进正文的编号列表或项目符号列表
|
||||
按钮、可点击动作、恢复入口只由宿主系统根据 `action_buttons` 渲染;Agent 正文不得复述。
|
||||
#### 硬性规则
|
||||
|
||||
1. 后端是唯一真相源,Agent 不能脑补状态。
|
||||
2. 每轮先看 `status`、`stop_agent_turn`、`forbidden_next_tools`、`human_options`;`message` / `parse_msg` / `align_msg` 须原文展示。
|
||||
3. 工具返回 `needs_human` 或 `stop_agent_turn=true` 时,必须停下等待用户。
|
||||
@@ -2051,15 +2056,11 @@ Agent 禁用 Tool:
|
||||
15. 禁止自行推断 `map_json`。
|
||||
16. 若 `human_options` 出现 `upload_inventory_file / paste_inventory_json / retry_upload / generate_excel / download_excel / mark_manual_uploaded / refresh` 等前端动作,只负责解释并引导,不得把它们当作 Tool 调用。
|
||||
17. 若 Tool 返回 `action_buttons` / `human_options`,最终回复正文**禁止**生成任何操作菜单、编号选项、按钮清单或“推荐下一步”动作列表。不要输出类似“推荐下一步:”“请选择以下操作:”“请选择操作:”“1. 重新上传库存”“2. 更正映射”“3. 重新匹配”“4. 驳回”。正文只说明当前状态、业务原因和影响;如需要用户操作,只写“请使用下方按钮继续”。可点击按钮由宿主系统根据 `action_buttons` 渲染。
|
||||
|
||||
#### 查询模板
|
||||
|
||||
当前 task_id:
|
||||
{{#Agent 状态输入标准化.agent_task_id#}}
|
||||
|
||||
用户消息:
|
||||
{{#预处理上下文.normalized_query#}}
|
||||
|
||||
上一轮后端状态 JSON:
|
||||
{{#Agent 状态输入标准化.agent_raw_json#}}
|
||||
```
|
||||
@@ -2184,20 +2185,22 @@ Agent 状态输入标准化 -> 货代续办 Agent
|
||||
- [ ] Agent 未绑定 `parse_notice / apply_inventory_mapping`
|
||||
- [ ] Agent 未误绑定 `upload_inventory_file / paste_inventory_json / retry_upload / generate_excel / download_excel / mark_manual_uploaded / refresh`
|
||||
|
||||
##### 运行级
|
||||
##### 运行验收矩阵
|
||||
|
||||
- [ ] 用户发 `继续处理` 时能进入 `get_task_status`
|
||||
- [ ] 用户发 `SN-...` 时能读取对应任务状态
|
||||
- [ ] 用户发 `确认 / 驳回 / 重解析 / 重新匹配 / 重试 RPA` 时优先走直连 Tool,不进入 Agent
|
||||
- [ ] 用户上传 `.xlsx/.xls/.csv` 时能进入库存 schema / 列映射 / apply 链
|
||||
- [ ] `apply_inventory_mapping` 返回 `align_review` 时,Agent 会停住等待确认
|
||||
- [ ] 字段对齐确认后,由 hxops worker 统一续跑后续匹配 / 导出 / 上传
|
||||
- [ ] 任一 Tool 返回 `needs_human` 或 `stop_agent_turn=true` 时,本轮不再继续调用后续 Tool
|
||||
- [ ] 任一 Tool 返回 `forbidden_next_tools` 时,画布不会继续调用被门禁的 Tool
|
||||
- [ ] 多任务场景下,每轮只推进一个聚焦 task,不会在 Dify 中循环推进整批任务
|
||||
- [ ] shortage / `match_status != fulfillable` 时,不会进入生成 Excel / 上传货代链路
|
||||
- [ ] 用户发 `重新匹配` 或 `rematch` 时,能命中直连 `submit_decision(decision=rematch)` 链路
|
||||
- [ ] `当前任务动作判断.need_agent` 为布尔值,`是否进入 Agent` 节点按布尔条件正常分流
|
||||
> 运行级验收不再只看 checklist 勾选,必须记录“用户话术命中哪个入口、是否绕过 Agent、任务锚点、状态变化和实测结果”。P0 优先锁死 5 条关键链路,避免 Dify 编排或提示词漂移破坏业务契约。
|
||||
|
||||
| 关键链路 | 触发语句 | 命中入口 | 是否绕过 Agent | 任务锚点 | 预期状态变化 | 实测结果 |
|
||||
| --- | --- | --- | --- | --- | --- | --- |
|
||||
| 继续处理 | `继续处理` | `get_task_status` | 是,直连 Tool 读状态 | `hxops_context.refs.task` 或当前 `current_focus_task_no` | 不改写任务;返回当前阶段、检查点、可用动作 | 待实测 |
|
||||
| SN-... 读状态 | `SN-20260617-ABCDEFGH` | `get_task_status` | 是,直连 Tool 读状态 | 文本中提取到的 `SN-...` | 不改写任务;返回该任务状态,不切换其他任务 | 通过:`PYTHONPATH=. pytest tests/test_shipping_notice_tools.py tests/test_shipping_notice_batches.py -q`;`test_contract_get_task_status_accepts_task_no_anchor` |
|
||||
| 确认 / 驳回 / 重匹配直连 | `确认` / `驳回` / `重新匹配` / `rematch` | `submit_decision` | 是,直连决策 Tool | 当前任务或显式 `SN-...` | 按状态机推进;`rematch` 清理 shortage 并重新入队当前任务 | 通过:`PYTHONPATH=. pytest tests/test_shipping_notice_tools.py tests/test_shipping_notice_batches.py -q`;`test_contract_submit_decision_rematch_is_direct_recovery_entry` |
|
||||
| shortage 阻断 | shortage review 后输入 `继续` 或自动续跑 | `match_inventory` / `submit_decision` 返回门禁 | 是,命中状态机门禁后停止 | 当前任务 | `status=needs_human`;禁止 `generate_shipment_excel` / `upload_to_freight`;不生成 Excel | 通过:`PYTHONPATH=. pytest tests/test_shipping_notice_tools.py tests/test_shipping_notice_batches.py -q`;`test_shipping_notice_match_shortage_needs_human` |
|
||||
| 多任务只推进 focus task | 多票批次中输入 `继续处理` | `get_batch_status` + 当前 focus 的 `get_task_status` | 是,先读状态再决定 | `batch.current_focus_task_no` | 每轮只围绕一个 focus task;读批次状态不循环推进整批 | 通过:`PYTHONPATH=. pytest tests/test_shipping_notice_tools.py tests/test_shipping_notice_batches.py -q`;`test_contract_batch_status_keeps_single_focus_without_advancing_other_tasks` |
|
||||
| 库存上传链路 | 上传 `.xlsx/.xls/.csv` | `get_inventory_schema_preview` → 映射 LLM → `apply_inventory_mapping` | 否,进入库存专用分支,不走自由 Agent | 当前任务 / 所属批次库存快照 | 生成 schema preview;应用映射后进入 `align_review` 或后端续跑 | 待实测 |
|
||||
| 字段对齐人工门 | `apply_inventory_mapping` 返回 `align_review` 后输入 `确认` | `submit_decision(decision=confirm_inventory_mapping)` | 是,直连决策 Tool | 当前任务 | 停住等待确认;确认后交由 hxops worker 续跑匹配 / 导出 / 上传 | 待实测 |
|
||||
| Tool 人工门收口 | 任一 Tool 返回 `needs_human` 或 `stop_agent_turn=true` | 工具结果标准化 | 是,硬停止本轮 | 当前任务 | 本轮不再继续调用后续 Tool | 待实测 |
|
||||
| forbidden_next_tools 门禁 | Tool 返回 `forbidden_next_tools` | 工具结果标准化 | 是,硬门禁 | 当前任务 | 画布不调用被禁止 Tool | 待实测 |
|
||||
| need_agent 布尔分流 | 直连动作判断节点输出 | `是否进入 Agent` | 视分支结果 | 当前任务 | `need_agent` 必须为布尔值,节点按布尔条件分流 | 待实测 |
|
||||
|
||||
##### 验收话术
|
||||
|
||||
@@ -2305,6 +2308,7 @@ shortage 规则:
|
||||
- `auto_progress` 是后端 worker 串联入口,会在满足条件时继续执行库存获取、字段确认后续步骤、匹配、生成 Excel、上传
|
||||
- 遇到人工节点时,仍会返回 `needs_human`
|
||||
- 库存 RPA 与上传 RPA 的回调均通过 Flask `/rpa/*` 路由回写
|
||||
- 当前 `scripts/rpa/freight_rpa_worker.py` 的真实货代上传 Driver 尚未完成;生产环境应保持 `SHIPPING_NOTICE_AUTO_UPLOAD_ENABLED=false`,由用户下载 Excel 后手工上传并在系统中确认,除非已接入并验收正式上传 RPA。
|
||||
|
||||
### 2.7 步骤内层细粒度进度(当前实现)
|
||||
|
||||
@@ -2371,7 +2375,7 @@ shortage 规则:
|
||||
### 3.1 已实现或基本落地
|
||||
|
||||
- **多文件建批次、多任务切换**:后端已支持 `batch + task`,前端聊天态也支持 focus task 切换。
|
||||
- **纯对话主链路骨架**:聊天页顶部已展示当前批次 / 当前任务 / 七步 Stepper,并支持在聊天中继续处理。
|
||||
- **聊天主路径骨架**:聊天页已展示当前批次 / 当前任务 / 七步 Stepper,并提供与对话协同的轻量批次监督入口。
|
||||
- **发货通知人工修订**:已支持改单头、改订单行、增行、删行。
|
||||
- **库存匹配与缺口阻断主规则**:存在 shortage 时会停留在人工节点,前端 Stepper 也会展示阻断状态。
|
||||
- **Excel 生成与上传闭环**:已具备后端匹配、自动推进、生成 Excel、人工上传确认等主流程接口。
|
||||
@@ -2379,7 +2383,7 @@ shortage 规则:
|
||||
### 3.2 部分实现,和原型仍有差距
|
||||
|
||||
- **三层进度展示**:当前已具备批次层摘要、任务层七步 Stepper,以及统一的 `step_payload_json.current_step_progress` 步骤内进度协议;但“第 `i/n` 个文件解析中”“匹配严格逐行 `x/y`”这类更细运行态仍未完全达到原型描述粒度。
|
||||
- **工作台与原型口径**:原型已收敛为“**方案 C:纯对话驱动**”作为本期唯一正式方案;当前仓库仍保留较完整的工作台详情页,属于实现上可用、但与原型收敛口径不完全一致。
|
||||
- **工作台职责收敛**:正式口径应收敛为“**对话主路径 + 轻量批次工作台**”;当前仓库已具备顶部批次摘要、右侧轻量工作台与独立详情页三层形态,后续仍需继续把“主路径监督层”和“增强/管理页”职责边界写清楚。
|
||||
- **任务列表筛选口径**:工作台已支持按部分 `process_status` 过滤,但尚未完全覆盖原型验收视角下的全部用户态状态。
|
||||
- **解析复核状态命名**:前端个别展示逻辑仍存在旧状态名 / 特殊判断,和当前状态机中的 `parse_review`、`rsv_required` 等口径有进一步统一空间。
|
||||
|
||||
@@ -2387,7 +2391,7 @@ shortage 规则:
|
||||
|
||||
- **四语言验收**:原型要求 `zh-CN / zh-TW / en-US / th-TH` 全量覆盖;本次对齐主要核了流程与接口,尚未逐条完成文案完整性复核。
|
||||
- **库存自动抓取业务闭环**:代码层已具备后端库存准备、RPA 回调与自动推进入口,但是否达到真实业务可用,还依赖货代库存导出 SOP、正式 RPA 脚本和运行环境联调。
|
||||
- **纯对话 P0 验收项**:从代码结构看已接近原型要求,但像“不中断续办”“多票并行下的细粒度进度提示”等,仍需要按原型测试用例逐项实测,而不能仅凭仓库代码直接视为全部完成。
|
||||
- **正式方案 P0 验收项**:从代码结构看已接近“对话主路径 + 轻量批次工作台”的目标要求,但像“不中断续办”“多票并行下的细粒度进度提示”“轻量工作台与对话聚焦任务的一致性”等,仍需要按原型测试用例逐项实测,而不能仅凭仓库代码直接视为全部完成。
|
||||
|
||||
***
|
||||
|
||||
@@ -2512,7 +2516,7 @@ API 层
|
||||
|
||||
### 4.2 前端与脚本
|
||||
|
||||
- `frontend/src/features/chat/shipping/*` — 方案 C 对话 UI
|
||||
- `frontend/src/features/chat/shipping/*` — 聊天主路径与轻量批次工作台 UI 逻辑
|
||||
- `backend/seed_shipping_notice_agents.py` — Agent 注册
|
||||
- `backend/scripts/export_shipping_notice_openapi.py` — OpenAPI 导出
|
||||
- `docs/shipping_notice.md` — 手动配置主文档
|
||||
|
||||
@@ -81,7 +81,7 @@
|
||||
| 入口 | 说明 |
|
||||
|------|------|
|
||||
| **工作台聊天** | 打开「货代发货通知」智能助手,在对话中上传文件或粘贴文字,逐步完成全流程(推荐) |
|
||||
| **货代发货列表** | 查看历史任务状态;可从某条任务「在 Chat 中继续」回到对应对话 |
|
||||
| **货代发货列表** | 只读查看历史任务状态与导出文件;如需确认、修订、重试或继续处理,请从某条任务「在 Chat 中继续」回到对应对话 |
|
||||
|
||||
### 2.2 任务编号(SN-…)
|
||||
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
/**
|
||||
* features/chat/api/shipping.api.ts
|
||||
* 用途:封装发货通知相关 HTTP API,包括任务/批次查询、库存上传、映射确认、人工决策与 Excel 导出。
|
||||
* 依赖:浏览器 fetch、getAuthHeaders、shipping.api.types 类型定义。
|
||||
* 依赖:统一 requestJson / BusinessError、shipping.api.types 类型定义。
|
||||
* 逻辑:上游由 useChatShipping 与 shipping/* handler 调用本文件;本文件统一请求工作台后端 `/api/workspace/*` 路由并抛出标准错误。
|
||||
*/
|
||||
import { getAuthHeaders } from '@/shared/utils/auth';
|
||||
import { BusinessError, requestJson } from '@/shared/api/client';
|
||||
import type {
|
||||
ShippingBatchSummary,
|
||||
ShippingChatActionsResponse,
|
||||
@@ -19,13 +19,38 @@ import type {
|
||||
ShippingTaskSummary,
|
||||
} from '../types/shipping.api.types';
|
||||
|
||||
async function getJson<T>(url: string): Promise<T> {
|
||||
const res = await fetch(url, { headers: getAuthHeaders() });
|
||||
if (!res.ok) {
|
||||
const body = await res.json().catch(() => ({}));
|
||||
throw new Error((body as { error?: string }).error || res.statusText);
|
||||
type ShippingApiStatusPayload = {
|
||||
status?: string;
|
||||
error?: string;
|
||||
message?: string;
|
||||
code?: string;
|
||||
details?: Record<string, unknown>;
|
||||
request_id?: string;
|
||||
};
|
||||
|
||||
export type ShippingChatAgentOption = {
|
||||
id: number;
|
||||
name: string;
|
||||
};
|
||||
|
||||
function jsonPost(body?: unknown): RequestInit {
|
||||
return {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify(body ?? {}),
|
||||
};
|
||||
}
|
||||
|
||||
function assertShippingOk<T extends ShippingApiStatusPayload>(body: T): T {
|
||||
if (body.status === 'failed') {
|
||||
throw new BusinessError({
|
||||
message: body.error || body.message || 'Shipping request failed',
|
||||
code: body.code || 'SHIPPING.REQUEST_FAILED',
|
||||
details: body.details,
|
||||
requestId: body.request_id,
|
||||
});
|
||||
}
|
||||
return res.json() as Promise<T>;
|
||||
return body;
|
||||
}
|
||||
|
||||
export const listWorkspaceShippingTasks = (params?: { process_status?: string; limit?: number }) => {
|
||||
@@ -34,7 +59,7 @@ export const listWorkspaceShippingTasks = (params?: { process_status?: string; l
|
||||
if (params?.process_status) sp.set('process_status', params.process_status);
|
||||
if (params?.limit) sp.set('limit', String(params.limit));
|
||||
const qs = sp.toString();
|
||||
return getJson<ShippingTaskSummary[]>(`/api/workspace/shipping-tasks${qs ? '?' + qs : ''}`);
|
||||
return requestJson<ShippingTaskSummary[]>(`/api/workspace/shipping-tasks${qs ? '?' + qs : ''}`);
|
||||
};
|
||||
|
||||
export const listWorkspaceShippingBatches = (params?: { limit?: number }) => {
|
||||
@@ -42,30 +67,33 @@ export const listWorkspaceShippingBatches = (params?: { limit?: number }) => {
|
||||
const sp = new URLSearchParams();
|
||||
if (params?.limit) sp.set('limit', String(params.limit));
|
||||
const qs = sp.toString();
|
||||
return getJson<ShippingBatchSummary[]>(`/api/workspace/shipping-batches${qs ? '?' + qs : ''}`);
|
||||
return requestJson<ShippingBatchSummary[]>(`/api/workspace/shipping-batches${qs ? '?' + qs : ''}`);
|
||||
};
|
||||
|
||||
/** 拉取用户可见 Agent 列表,供发货工作台跳转 Chat 时定位目标 Agent。 */
|
||||
export const listShippingChatAgents = () => requestJson<ShippingChatAgentOption[]>('/api/agents');
|
||||
|
||||
/** 获取批次详情、批次任务列表与当前焦点任务。 */
|
||||
export const getWorkspaceShippingBatch = (batchNo: string) =>
|
||||
getJson<ShippingBatchSummary & { tasks?: ShippingTaskSummary[]; focus_task?: ShippingTaskSummary | null }>(
|
||||
requestJson<ShippingBatchSummary & { tasks?: ShippingTaskSummary[]; focus_task?: ShippingTaskSummary | null }>(
|
||||
`/api/workspace/shipping-batches/${encodeURIComponent(batchNo)}`,
|
||||
);
|
||||
|
||||
/** 获取一个 Agent 会话下的多批次执行工作台快照。 */
|
||||
export const getWorkspaceShippingConversationBatches = (conversationId: string) =>
|
||||
getJson<ShippingConversationWorkspace>(
|
||||
requestJson<ShippingConversationWorkspace>(
|
||||
`/api/workspace/shipping-conversations/${encodeURIComponent(conversationId)}/batch-workspace`,
|
||||
);
|
||||
|
||||
/** 获取指定批次当前焦点任务。 */
|
||||
export const getWorkspaceShippingBatchFocusTask = (batchNo: string) =>
|
||||
getJson<ShippingTaskSummary>(
|
||||
requestJson<ShippingTaskSummary>(
|
||||
`/api/workspace/shipping-batches/${encodeURIComponent(batchNo)}/focus-task`,
|
||||
);
|
||||
|
||||
/** 获取单个发货任务详情。 */
|
||||
export const getWorkspaceShippingTask = (taskNo: string) =>
|
||||
getJson<ShippingTaskDetail>(`/api/workspace/shipping-tasks/${encodeURIComponent(taskNo)}`);
|
||||
requestJson<ShippingTaskDetail>(`/api/workspace/shipping-tasks/${encodeURIComponent(taskNo)}`);
|
||||
|
||||
/** 生成任务导出文件的前端下载 URL。 */
|
||||
export const workspaceShippingExportUrl = (taskNo: string) =>
|
||||
@@ -73,7 +101,7 @@ export const workspaceShippingExportUrl = (taskNo: string) =>
|
||||
|
||||
/** 获取聊天气泡动作按钮、检查点和 human options。 */
|
||||
export const getShippingChatActions = (taskNo: string) =>
|
||||
getJson<ShippingChatActionsResponse>(
|
||||
requestJson<ShippingChatActionsResponse>(
|
||||
`/api/workspace/shipping-tasks/${encodeURIComponent(taskNo)}/chat-actions`,
|
||||
);
|
||||
|
||||
@@ -86,17 +114,11 @@ export const getShippingChatActions = (taskNo: string) =>
|
||||
export async function uploadWorkspaceShippingInventory(taskNo: string, file: File) {
|
||||
const form = new FormData();
|
||||
form.append('file', file);
|
||||
const headers = getAuthHeaders();
|
||||
delete (headers as Record<string, string>)['Content-Type'];
|
||||
const res = await fetch(
|
||||
const body = await requestJson<ShippingInventoryUploadResponse & ShippingApiStatusPayload>(
|
||||
`/api/workspace/shipping-tasks/${encodeURIComponent(taskNo)}/upload-inventory`,
|
||||
{ method: 'POST', headers, body: form },
|
||||
{ method: 'POST', body: form },
|
||||
);
|
||||
const body = (await res.json().catch(() => ({}))) as ShippingInventoryUploadResponse & { error?: string };
|
||||
if (!res.ok) {
|
||||
throw new Error(body.error || body.message || res.statusText);
|
||||
}
|
||||
return body;
|
||||
return assertShippingOk(body);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -106,19 +128,11 @@ export async function uploadWorkspaceShippingInventory(taskNo: string, file: Fil
|
||||
* @returns RPA 库存导出触发结果
|
||||
*/
|
||||
export async function confirmWorkspaceShippingInventorySource(taskNo: string, sourceCode: string) {
|
||||
const res = await fetch(
|
||||
const body = await requestJson<ShippingDecisionResponse & ShippingApiStatusPayload>(
|
||||
`/api/workspace/shipping-tasks/${encodeURIComponent(taskNo)}/confirm-inventory-source`,
|
||||
{
|
||||
method: 'POST',
|
||||
headers: { ...getAuthHeaders(), 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ source_code: sourceCode }),
|
||||
},
|
||||
jsonPost({ source_code: sourceCode }),
|
||||
);
|
||||
const body = (await res.json().catch(() => ({}))) as ShippingDecisionResponse & { error?: string };
|
||||
if (!res.ok || body.status === 'failed') {
|
||||
throw new Error(body.error || body.message || res.statusText);
|
||||
}
|
||||
return body;
|
||||
return assertShippingOk(body);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -128,19 +142,11 @@ export async function confirmWorkspaceShippingInventorySource(taskNo: string, so
|
||||
* @returns 映射应用与库存解析结果
|
||||
*/
|
||||
export async function applyWorkspaceShippingInventoryMapping(taskNo: string, columnMappingJson: Record<string, unknown>) {
|
||||
const res = await fetch(
|
||||
const body = await requestJson<ShippingInventoryUploadResponse & ShippingApiStatusPayload>(
|
||||
`/api/workspace/shipping-tasks/${encodeURIComponent(taskNo)}/apply-inventory-mapping`,
|
||||
{
|
||||
method: 'POST',
|
||||
headers: { ...getAuthHeaders(), 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ map_json: columnMappingJson }),
|
||||
},
|
||||
jsonPost({ map_json: columnMappingJson }),
|
||||
);
|
||||
const body = (await res.json().catch(() => ({}))) as ShippingInventoryUploadResponse & { error?: string };
|
||||
if (!res.ok) {
|
||||
throw new Error(body.error || body.message || res.statusText);
|
||||
}
|
||||
return body;
|
||||
return assertShippingOk(body);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -153,16 +159,11 @@ export async function createWorkspaceShippingTask(params?: {
|
||||
conversation_id?: string;
|
||||
raw_content?: string;
|
||||
}) {
|
||||
const res = await fetch('/api/workspace/shipping-tasks', {
|
||||
method: 'POST',
|
||||
headers: { ...getAuthHeaders(), 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify(params || {}),
|
||||
});
|
||||
const body = (await res.json().catch(() => ({}))) as ShippingTaskCreateResponse & { error?: string };
|
||||
if (!res.ok || body.status === 'failed') {
|
||||
throw new Error(body.error || body.message || res.statusText);
|
||||
}
|
||||
return body;
|
||||
const body = await requestJson<ShippingTaskCreateResponse & ShippingApiStatusPayload>(
|
||||
'/api/workspace/shipping-tasks',
|
||||
jsonPost(params || {}),
|
||||
);
|
||||
return assertShippingOk(body);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -175,18 +176,11 @@ export async function createWorkspaceShippingTaskFromNotice(file: File, conversa
|
||||
const form = new FormData();
|
||||
form.append('file', file);
|
||||
if (conversationId) form.append('conversation_id', conversationId);
|
||||
const headers = getAuthHeaders();
|
||||
delete (headers as Record<string, string>)['Content-Type'];
|
||||
const res = await fetch('/api/workspace/shipping-tasks/create-from-notice', {
|
||||
method: 'POST',
|
||||
headers,
|
||||
body: form,
|
||||
});
|
||||
const body = (await res.json().catch(() => ({}))) as ShippingNoticeUploadResponse & { error?: string };
|
||||
if (!res.ok || body.status === 'failed') {
|
||||
throw new Error(body.error || body.message || res.statusText);
|
||||
}
|
||||
return body;
|
||||
const body = await requestJson<ShippingNoticeUploadResponse & ShippingApiStatusPayload>(
|
||||
'/api/workspace/shipping-tasks/create-from-notice',
|
||||
{ method: 'POST', body: form },
|
||||
);
|
||||
return assertShippingOk(body);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -198,17 +192,11 @@ export async function createWorkspaceShippingTaskFromNotice(file: File, conversa
|
||||
export async function replaceWorkspaceShippingTaskNotice(taskNo: string, file: File) {
|
||||
const form = new FormData();
|
||||
form.append('file', file);
|
||||
const headers = getAuthHeaders();
|
||||
delete (headers as Record<string, string>)['Content-Type'];
|
||||
const res = await fetch(
|
||||
const body = await requestJson<ShippingNoticeUploadResponse & ShippingApiStatusPayload>(
|
||||
`/api/workspace/shipping-tasks/${encodeURIComponent(taskNo)}/replace-notice`,
|
||||
{ method: 'POST', headers, body: form },
|
||||
{ method: 'POST', body: form },
|
||||
);
|
||||
const body = (await res.json().catch(() => ({}))) as ShippingNoticeUploadResponse & { error?: string };
|
||||
if (!res.ok || body.status === 'failed') {
|
||||
throw new Error(body.error || body.message || res.statusText);
|
||||
}
|
||||
return body;
|
||||
return assertShippingOk(body);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -221,22 +209,12 @@ export async function createWorkspaceShippingBatchFromNotices(files: File[], con
|
||||
const form = new FormData();
|
||||
files.forEach((file) => form.append('files', file));
|
||||
if (conversationId) form.append('conversation_id', conversationId);
|
||||
const headers = getAuthHeaders();
|
||||
delete (headers as Record<string, string>)['Content-Type'];
|
||||
const res = await fetch('/api/workspace/shipping-batches/create-from-notices', {
|
||||
method: 'POST',
|
||||
headers,
|
||||
body: form,
|
||||
});
|
||||
const body = (await res.json().catch(() => ({}))) as ShippingNoticeUploadResponse & {
|
||||
const body = await requestJson<ShippingNoticeUploadResponse & ShippingApiStatusPayload & {
|
||||
error?: string;
|
||||
batch_no?: string;
|
||||
data?: unknown;
|
||||
};
|
||||
if (!res.ok || body.status === 'failed') {
|
||||
throw new Error(body.error || body.message || res.statusText);
|
||||
}
|
||||
return body;
|
||||
}>('/api/workspace/shipping-batches/create-from-notices', { method: 'POST', body: form });
|
||||
return assertShippingOk(body);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -246,23 +224,14 @@ export async function createWorkspaceShippingBatchFromNotices(files: File[], con
|
||||
* @returns 更新后的批次摘要与焦点任务
|
||||
*/
|
||||
export async function switchWorkspaceShippingBatchFocusTask(batchNo: string, taskNo: string) {
|
||||
const res = await fetch(
|
||||
`/api/workspace/shipping-batches/${encodeURIComponent(batchNo)}/focus-task`,
|
||||
{
|
||||
method: 'POST',
|
||||
headers: { ...getAuthHeaders(), 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ task_no: taskNo }),
|
||||
},
|
||||
);
|
||||
const body = (await res.json().catch(() => ({}))) as {
|
||||
error?: string;
|
||||
const body = await requestJson<ShippingApiStatusPayload & {
|
||||
batch?: ShippingBatchSummary;
|
||||
focus_task?: ShippingTaskSummary;
|
||||
};
|
||||
if (!res.ok) {
|
||||
throw new Error(body.error || res.statusText);
|
||||
}
|
||||
return body;
|
||||
}>(
|
||||
`/api/workspace/shipping-batches/${encodeURIComponent(batchNo)}/focus-task`,
|
||||
jsonPost({ task_no: taskNo }),
|
||||
);
|
||||
return assertShippingOk(body);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -272,19 +241,11 @@ export async function switchWorkspaceShippingBatchFocusTask(batchNo: string, tas
|
||||
* @returns 重试结果
|
||||
*/
|
||||
export async function retryWorkspaceShippingTask(taskNo: string, comment?: string) {
|
||||
const res = await fetch(
|
||||
const body = await requestJson<ShippingDecisionResponse & ShippingApiStatusPayload>(
|
||||
`/api/workspace/shipping-tasks/${encodeURIComponent(taskNo)}/retry`,
|
||||
{
|
||||
method: 'POST',
|
||||
headers: { ...getAuthHeaders(), 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify(comment ? { comment } : {}),
|
||||
},
|
||||
jsonPost(comment ? { comment } : {}),
|
||||
);
|
||||
const body = (await res.json().catch(() => ({}))) as ShippingDecisionResponse & { error?: string };
|
||||
if (!res.ok || body.status === 'failed') {
|
||||
throw new Error(body.error || body.message || res.statusText);
|
||||
}
|
||||
return body;
|
||||
return assertShippingOk(body);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -293,19 +254,11 @@ export async function retryWorkspaceShippingTask(taskNo: string, comment?: strin
|
||||
* @returns 批次重试结果
|
||||
*/
|
||||
export async function retryWorkspaceShippingBatchPending(batchNo: string) {
|
||||
const res = await fetch(
|
||||
const body = await requestJson<ShippingApiStatusPayload>(
|
||||
`/api/workspace/shipping-batches/${encodeURIComponent(batchNo)}/retry-pending`,
|
||||
{
|
||||
method: 'POST',
|
||||
headers: { ...getAuthHeaders(), 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({}),
|
||||
},
|
||||
jsonPost(),
|
||||
);
|
||||
const body = (await res.json().catch(() => ({}))) as { status?: string; message?: string; error?: string };
|
||||
if (!res.ok || body.status === 'failed') {
|
||||
throw new Error(body.error || body.message || res.statusText);
|
||||
}
|
||||
return body;
|
||||
return assertShippingOk(body);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -316,19 +269,11 @@ export async function retryWorkspaceShippingBatchPending(batchNo: string) {
|
||||
* @returns 决策执行结果
|
||||
*/
|
||||
export async function submitWorkspaceShippingDecision(taskNo: string, decision: string, comment?: string) {
|
||||
const res = await fetch(
|
||||
const body = await requestJson<ShippingDecisionResponse & ShippingApiStatusPayload>(
|
||||
`/api/workspace/shipping-tasks/${encodeURIComponent(taskNo)}/submit-decision`,
|
||||
{
|
||||
method: 'POST',
|
||||
headers: { ...getAuthHeaders(), 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ decision, ...(comment ? { comment } : {}) }),
|
||||
},
|
||||
jsonPost({ decision, ...(comment ? { comment } : {}) }),
|
||||
);
|
||||
const body = (await res.json().catch(() => ({}))) as ShippingDecisionResponse & { error?: string };
|
||||
if (!res.ok || body.status === 'failed') {
|
||||
throw new Error(body.error || body.message || res.statusText);
|
||||
}
|
||||
return body;
|
||||
return assertShippingOk(body);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -343,19 +288,11 @@ export async function updateWorkspaceShippingNoticeFields(
|
||||
fields: Partial<ShippingNoticeHeader>,
|
||||
comment?: string,
|
||||
) {
|
||||
const res = await fetch(
|
||||
const body = await requestJson<ShippingDecisionResponse & ShippingApiStatusPayload>(
|
||||
`/api/workspace/shipping-tasks/${encodeURIComponent(taskNo)}/update-notice-fields`,
|
||||
{
|
||||
method: 'POST',
|
||||
headers: { ...getAuthHeaders(), 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ fields, ...(comment ? { comment } : {}) }),
|
||||
},
|
||||
jsonPost({ fields, ...(comment ? { comment } : {}) }),
|
||||
);
|
||||
const body = (await res.json().catch(() => ({}))) as ShippingDecisionResponse & { error?: string };
|
||||
if (!res.ok || body.status === 'failed') {
|
||||
throw new Error(body.error || body.message || res.statusText);
|
||||
}
|
||||
return body;
|
||||
return assertShippingOk(body);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -372,19 +309,11 @@ export async function updateWorkspaceShippingNoticeLine(
|
||||
patch: Partial<ShippingNoticeLine> & { quantity?: number },
|
||||
comment?: string,
|
||||
) {
|
||||
const res = await fetch(
|
||||
const body = await requestJson<ShippingDecisionResponse & ShippingApiStatusPayload>(
|
||||
`/api/workspace/shipping-tasks/${encodeURIComponent(taskNo)}/update-notice-line`,
|
||||
{
|
||||
method: 'POST',
|
||||
headers: { ...getAuthHeaders(), 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ line_index: lineIndex, patch, ...(comment ? { comment } : {}) }),
|
||||
},
|
||||
jsonPost({ line_index: lineIndex, patch, ...(comment ? { comment } : {}) }),
|
||||
);
|
||||
const body = (await res.json().catch(() => ({}))) as ShippingDecisionResponse & { error?: string };
|
||||
if (!res.ok || body.status === 'failed') {
|
||||
throw new Error(body.error || body.message || res.statusText);
|
||||
}
|
||||
return body;
|
||||
return assertShippingOk(body);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -399,19 +328,11 @@ export async function addWorkspaceShippingNoticeLine(
|
||||
line: Partial<ShippingNoticeLine> & { quantity?: number },
|
||||
comment?: string,
|
||||
) {
|
||||
const res = await fetch(
|
||||
const body = await requestJson<ShippingDecisionResponse & ShippingApiStatusPayload>(
|
||||
`/api/workspace/shipping-tasks/${encodeURIComponent(taskNo)}/add-notice-line`,
|
||||
{
|
||||
method: 'POST',
|
||||
headers: { ...getAuthHeaders(), 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ line, ...(comment ? { comment } : {}) }),
|
||||
},
|
||||
jsonPost({ line, ...(comment ? { comment } : {}) }),
|
||||
);
|
||||
const body = (await res.json().catch(() => ({}))) as ShippingDecisionResponse & { error?: string };
|
||||
if (!res.ok || body.status === 'failed') {
|
||||
throw new Error(body.error || body.message || res.statusText);
|
||||
}
|
||||
return body;
|
||||
return assertShippingOk(body);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -426,19 +347,11 @@ export async function removeWorkspaceShippingNoticeLine(
|
||||
lineIndex: number,
|
||||
comment?: string,
|
||||
) {
|
||||
const res = await fetch(
|
||||
const body = await requestJson<ShippingDecisionResponse & ShippingApiStatusPayload>(
|
||||
`/api/workspace/shipping-tasks/${encodeURIComponent(taskNo)}/remove-notice-line`,
|
||||
{
|
||||
method: 'POST',
|
||||
headers: { ...getAuthHeaders(), 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ line_index: lineIndex, ...(comment ? { comment } : {}) }),
|
||||
},
|
||||
jsonPost({ line_index: lineIndex, ...(comment ? { comment } : {}) }),
|
||||
);
|
||||
const body = (await res.json().catch(() => ({}))) as ShippingDecisionResponse & { error?: string };
|
||||
if (!res.ok || body.status === 'failed') {
|
||||
throw new Error(body.error || body.message || res.statusText);
|
||||
}
|
||||
return body;
|
||||
return assertShippingOk(body);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -447,19 +360,11 @@ export async function removeWorkspaceShippingNoticeLine(
|
||||
* @returns 匹配结果与后续动作提示
|
||||
*/
|
||||
export async function matchWorkspaceShippingInventory(taskNo: string) {
|
||||
const res = await fetch(
|
||||
const body = await requestJson<ShippingDecisionResponse & ShippingApiStatusPayload>(
|
||||
`/api/workspace/shipping-tasks/${encodeURIComponent(taskNo)}/match-inventory`,
|
||||
{
|
||||
method: 'POST',
|
||||
headers: { ...getAuthHeaders(), 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({}),
|
||||
},
|
||||
jsonPost(),
|
||||
);
|
||||
const body = (await res.json().catch(() => ({}))) as ShippingDecisionResponse & { error?: string };
|
||||
if (!res.ok || body.status === 'failed') {
|
||||
throw new Error(body.error || body.message || res.statusText);
|
||||
}
|
||||
return body;
|
||||
return assertShippingOk(body);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -469,41 +374,11 @@ export async function matchWorkspaceShippingInventory(taskNo: string) {
|
||||
* @returns 自动推进结果
|
||||
*/
|
||||
export async function autoProgressWorkspaceShippingTask(taskNo: string, lang?: string) {
|
||||
const res = await fetch(
|
||||
const body = await requestJson<ShippingDecisionResponse & ShippingApiStatusPayload>(
|
||||
`/api/workspace/shipping-tasks/${encodeURIComponent(taskNo)}/auto-progress`,
|
||||
{
|
||||
method: 'POST',
|
||||
headers: { ...getAuthHeaders(), 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify(lang ? { lang } : {}),
|
||||
},
|
||||
jsonPost(lang ? { lang } : {}),
|
||||
);
|
||||
const body = (await res.json().catch(() => ({}))) as ShippingDecisionResponse & { error?: string };
|
||||
if (!res.ok || body.status === 'failed') {
|
||||
throw new Error(body.error || body.message || res.statusText);
|
||||
}
|
||||
return body;
|
||||
}
|
||||
|
||||
/**
|
||||
* 以用户态触发通知解析,供批量上传后逐任务补齐首轮解析。
|
||||
* @param taskNo - 发货任务编号
|
||||
* @param lang - 可选语言代码
|
||||
* @returns 解析与可能的自动推进结果
|
||||
*/
|
||||
export async function parseWorkspaceShippingNotice(taskNo: string, lang?: string) {
|
||||
const res = await fetch(
|
||||
`/api/workspace/shipping-tasks/${encodeURIComponent(taskNo)}/parse-notice`,
|
||||
{
|
||||
method: 'POST',
|
||||
headers: { ...getAuthHeaders(), 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify(lang ? { lang } : {}),
|
||||
},
|
||||
);
|
||||
const body = (await res.json().catch(() => ({}))) as ShippingDecisionResponse & { error?: string };
|
||||
if (!res.ok || body.status === 'failed') {
|
||||
throw new Error(body.error || body.message || res.statusText);
|
||||
}
|
||||
return body;
|
||||
return assertShippingOk(body);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -512,19 +387,11 @@ export async function parseWorkspaceShippingNotice(taskNo: string, lang?: string
|
||||
* @returns 上传确认结果
|
||||
*/
|
||||
export async function markWorkspaceShippingManualUploaded(taskNo: string) {
|
||||
const res = await fetch(
|
||||
const body = await requestJson<ShippingDecisionResponse & ShippingApiStatusPayload>(
|
||||
`/api/workspace/shipping-tasks/${encodeURIComponent(taskNo)}/mark-manual-uploaded`,
|
||||
{
|
||||
method: 'POST',
|
||||
headers: { ...getAuthHeaders(), 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({}),
|
||||
},
|
||||
jsonPost(),
|
||||
);
|
||||
const body = (await res.json().catch(() => ({}))) as ShippingDecisionResponse & { error?: string };
|
||||
if (!res.ok || body.status === 'failed') {
|
||||
throw new Error(body.error || body.message || res.statusText);
|
||||
}
|
||||
return body;
|
||||
return assertShippingOk(body);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -533,19 +400,11 @@ export async function markWorkspaceShippingManualUploaded(taskNo: string) {
|
||||
* @returns RPA 上传触发或等待结果
|
||||
*/
|
||||
export async function retryWorkspaceShippingUpload(taskNo: string) {
|
||||
const res = await fetch(
|
||||
const body = await requestJson<ShippingDecisionResponse & ShippingApiStatusPayload>(
|
||||
`/api/workspace/shipping-tasks/${encodeURIComponent(taskNo)}/retry-upload`,
|
||||
{
|
||||
method: 'POST',
|
||||
headers: { ...getAuthHeaders(), 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({}),
|
||||
},
|
||||
jsonPost(),
|
||||
);
|
||||
const body = (await res.json().catch(() => ({}))) as ShippingDecisionResponse & { error?: string };
|
||||
if (!res.ok || body.status === 'failed') {
|
||||
throw new Error(body.error || body.message || res.statusText);
|
||||
}
|
||||
return body;
|
||||
return assertShippingOk(body);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -554,19 +413,11 @@ export async function retryWorkspaceShippingUpload(taskNo: string) {
|
||||
* @returns 生成结果,成功时通常会包含下载链接
|
||||
*/
|
||||
export async function generateWorkspaceShippingExcel(taskNo: string) {
|
||||
const res = await fetch(
|
||||
const body = await requestJson<ShippingDecisionResponse & ShippingApiStatusPayload>(
|
||||
`/api/workspace/shipping-tasks/${encodeURIComponent(taskNo)}/generate-excel`,
|
||||
{
|
||||
method: 'POST',
|
||||
headers: { ...getAuthHeaders(), 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({}),
|
||||
},
|
||||
jsonPost(),
|
||||
);
|
||||
const body = (await res.json().catch(() => ({}))) as ShippingDecisionResponse & { error?: string };
|
||||
if (!res.ok || body.status === 'failed') {
|
||||
throw new Error(body.error || body.message || res.statusText);
|
||||
}
|
||||
return body;
|
||||
return assertShippingOk(body);
|
||||
}
|
||||
|
||||
/** 货代发货 Agent 显示名称,用于聊天路由与 Agent 匹配。 */
|
||||
|
||||
@@ -189,6 +189,7 @@ const page = useChatPageContext();
|
||||
@switch-batch="page.switchShippingBatch"
|
||||
@focus-task="page.switchShippingFocusTask"
|
||||
@resume-task="page.resumeShippingTask"
|
||||
@retry-rpa="page.retryShippingInventoryRpa"
|
||||
@query-shortage="page.queryShippingShortageDetails"
|
||||
@retry-pending="page.retryCurrentShippingBatchPendingTasks"
|
||||
/>
|
||||
|
||||
@@ -6,10 +6,11 @@
|
||||
* 逻辑:生成式执行摘要由聊天消息流承载;本组件只提供固定状态 chrome 和明确范围的批次操作。
|
||||
*/
|
||||
import { computed, ref } from 'vue';
|
||||
import { List, RefreshCw } from 'lucide-vue-next';
|
||||
import { AlertTriangle, List, RefreshCw } from 'lucide-vue-next';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { retryWorkspaceShippingBatchPending } from '@/features/chat/api/shipping.api';
|
||||
import { useMessage } from '@/shared/composables/useMessage';
|
||||
import { buildShippingWorkflowSteps } from '@/features/chat/shipping';
|
||||
import type {
|
||||
ShippingBatchSummary,
|
||||
ShippingConversationWorkspace,
|
||||
@@ -35,11 +36,20 @@ const { t } = useI18n();
|
||||
const msg = useMessage();
|
||||
const retryingPending = ref(false);
|
||||
|
||||
const COMPLETED_PROCESS_STATUSES = new Set(['uploaded', 'closed']);
|
||||
const COMPLETED_PROCESS_STATUSES = new Set(['uploaded', 'completed', 'closed']);
|
||||
const FAILED_PROCESS_STATUSES = new Set(['rejected', 'upload_failed']);
|
||||
const workspaceBatches = computed(() => props.conversationWorkspace?.batches || []);
|
||||
const activeBatchNo = computed(() =>
|
||||
String(props.activeBatchNo || props.batchSummary?.batch_no || workspaceBatches.value[0]?.batch_no || '').trim(),
|
||||
);
|
||||
const focusedTaskNo = computed(() =>
|
||||
String(
|
||||
props.activeTaskDetail?.task_no
|
||||
|| props.batchSummary?.current_focus_task_no
|
||||
|| props.batchSummary?.process_summary?.current_task_no
|
||||
|| '',
|
||||
).trim(),
|
||||
);
|
||||
|
||||
const processSummary = computed(() => {
|
||||
const summary = props.batchSummary?.process_summary || null;
|
||||
@@ -53,14 +63,19 @@ const processSummary = computed(() => {
|
||||
(task) => !COMPLETED_PROCESS_STATUSES.has(String(task.process_status || '').trim()),
|
||||
) ? 1 : 0;
|
||||
const running = Number(summary?.running || runningFallback || 0);
|
||||
const pending = Math.max(0, Number(summary?.pending ?? (total - completed - running)));
|
||||
return { total, completed, running, pending };
|
||||
const taskAbnormal = props.batchTasks.filter((task) => {
|
||||
const status = String(task.process_status || '').trim();
|
||||
return FAILED_PROCESS_STATUSES.has(status)
|
||||
|| task.upload_status === 'failed'
|
||||
|| Boolean(task.review_status || task.pending_human_reason);
|
||||
}).length;
|
||||
const summaryAbnormal = Number(summary?.failed || 0) + Number((summary as { needs_human?: number })?.needs_human || 0);
|
||||
const abnormal = Math.max(taskAbnormal, summaryAbnormal);
|
||||
const pending = Math.max(0, Number(summary?.pending ?? (total - completed - running - abnormal)));
|
||||
return { total, completed, running, pending, abnormal };
|
||||
});
|
||||
|
||||
const abnormalCount = computed(() => {
|
||||
const batchSummary = props.batchSummary?.process_summary || {};
|
||||
return Number(batchSummary.failed || 0) + Number((batchSummary as { needs_human?: number }).needs_human || 0);
|
||||
});
|
||||
const abnormalCount = computed(() => processSummary.value.abnormal);
|
||||
|
||||
const progressPercent = computed(() =>
|
||||
processSummary.value.total
|
||||
@@ -87,6 +102,53 @@ const executionStateMeta = computed(() => {
|
||||
};
|
||||
});
|
||||
|
||||
const activeTaskSteps = computed(() => buildShippingWorkflowSteps(props.activeTaskDetail));
|
||||
const activeStepIndex = computed(() => {
|
||||
const index = activeTaskSteps.value.findIndex((step) => step.status === 'current' || step.status === 'blocked');
|
||||
return index >= 0 ? index : Math.max(0, activeTaskSteps.value.length - 1);
|
||||
});
|
||||
const activeStepLabel = computed(() => {
|
||||
const step = activeTaskSteps.value[activeStepIndex.value];
|
||||
return step ? t('chat.shippingNoticeUi.stepHeadline', {
|
||||
current: activeStepIndex.value + 1,
|
||||
total: activeTaskSteps.value.length,
|
||||
label: t(step.label),
|
||||
}) : '--';
|
||||
});
|
||||
|
||||
const blockingMeta = computed(() => {
|
||||
const task = props.activeTaskDetail;
|
||||
if (!task) return null;
|
||||
const reason = String(task.pending_human_reason || '').trim();
|
||||
const reviewStatus = String(task.review_status || '').trim();
|
||||
const processStatus = String(task.process_status || '').trim();
|
||||
if (processStatus === 'upload_failed' || task.upload_status === 'failed') {
|
||||
return {
|
||||
text: t('chat.shippingNoticeUi.blockedUploadRetryable'),
|
||||
className: 'border-rose-200 bg-rose-50 text-rose-700',
|
||||
};
|
||||
}
|
||||
if (reason === 'shortage' || reason === 'shortage_review' || reviewStatus === 'shortage_review') {
|
||||
return {
|
||||
text: t('chat.shippingNoticeUi.blockedShortage'),
|
||||
className: 'border-amber-200 bg-amber-50 text-amber-700',
|
||||
};
|
||||
}
|
||||
if (reason === 'low_confidence' || reviewStatus === 'parse_review') {
|
||||
return {
|
||||
text: t('chat.shippingNoticeUi.blockedParseReview'),
|
||||
className: 'border-amber-200 bg-amber-50 text-amber-700',
|
||||
};
|
||||
}
|
||||
if (reason || reviewStatus) {
|
||||
return {
|
||||
text: t('chat.shippingNoticeUi.blockedWaitingHuman'),
|
||||
className: 'border-amber-200 bg-amber-50 text-amber-700',
|
||||
};
|
||||
}
|
||||
return null;
|
||||
});
|
||||
|
||||
const handleRetryPending = async () => {
|
||||
const batchNo = String(props.batchSummary?.batch_no || '').trim();
|
||||
if (!batchNo || retryingPending.value) return;
|
||||
@@ -107,24 +169,39 @@ const handleRetryPending = async () => {
|
||||
<div
|
||||
class="mx-auto w-full max-w-4xl rounded-2xl border border-default bg-gradient-to-r from-sky-50 via-white to-emerald-50 px-6 py-4 shadow-sm"
|
||||
>
|
||||
<div class="flex flex-wrap items-center justify-between gap-3">
|
||||
<div class="flex flex-wrap items-start justify-between gap-3">
|
||||
<div class="min-w-0 flex-1">
|
||||
<div class="flex flex-wrap items-center gap-2 text-xs text-slate-500">
|
||||
<span class="font-mono font-semibold text-brand-700">{{ activeBatchNo || '--' }}</span>
|
||||
<span>
|
||||
{{ t('chat.shippingNoticeUi.batchChromeSummary', {
|
||||
total: processSummary.total,
|
||||
completed: processSummary.completed,
|
||||
running: processSummary.running,
|
||||
abnormal: abnormalCount,
|
||||
}) }}
|
||||
</span>
|
||||
<span>{{ t('chat.shippingNoticeUi.fileCount') }} {{ processSummary.total }}</span>
|
||||
<span>{{ t('chat.shippingNoticeUi.completedCount') }} {{ processSummary.completed }}</span>
|
||||
<span>{{ t('chat.shippingNoticeUi.runningCount') }} {{ processSummary.running }}</span>
|
||||
<span>{{ t('chat.shippingNoticeUi.pendingCount') }} {{ processSummary.pending }}</span>
|
||||
<span>{{ t('chat.shippingNoticeUi.needsIntervention') }} {{ abnormalCount }}</span>
|
||||
<span
|
||||
class="rounded-full border px-2 py-0.5 text-[11px] font-semibold"
|
||||
:class="executionStateMeta.className"
|
||||
>
|
||||
{{ executionStateMeta.text }}
|
||||
</span>
|
||||
<span
|
||||
v-if="blockingMeta"
|
||||
class="inline-flex items-center gap-1 rounded-full border px-2 py-0.5 text-[11px] font-semibold"
|
||||
:class="blockingMeta.className"
|
||||
>
|
||||
<AlertTriangle class="h-3 w-3" />
|
||||
{{ blockingMeta.text }}
|
||||
</span>
|
||||
</div>
|
||||
<div class="mt-2 flex flex-wrap items-center gap-x-4 gap-y-1 text-xs text-secondary">
|
||||
<span>
|
||||
<span class="text-muted">{{ t('chat.shippingNoticeUi.currentFocus') }}</span>
|
||||
<span class="font-mono font-semibold text-primary">{{ focusedTaskNo || '--' }}</span>
|
||||
</span>
|
||||
<span>
|
||||
<span class="text-muted">{{ t('chat.shippingNoticeUi.currentStepLabel') }}:</span>
|
||||
<span class="font-medium text-primary">{{ activeStepLabel }}</span>
|
||||
</span>
|
||||
</div>
|
||||
<div class="mt-2 h-1.5 max-w-md overflow-hidden rounded-full bg-slate-200">
|
||||
<div
|
||||
|
||||
@@ -33,12 +33,13 @@ const emit = defineEmits<{
|
||||
'switch-batch': [batchNo: string];
|
||||
'focus-task': [taskNo: string];
|
||||
'resume-task': [taskNo: string];
|
||||
'retry-rpa': [taskNo: string];
|
||||
'query-shortage': [taskNo: string];
|
||||
'retry-pending': [];
|
||||
}>();
|
||||
|
||||
const { t } = useI18n();
|
||||
const activeFilter = ref<'all' | 'abnormal' | 'completed'>('all');
|
||||
const activeFilter = ref<'all' | 'abnormal' | 'waitingHuman' | 'resumable' | 'completed'>('all');
|
||||
|
||||
const COMPLETED_PROCESS_STATUSES = new Set(['uploaded', 'completed', 'closed']);
|
||||
|
||||
@@ -59,6 +60,21 @@ const isAbnormalTask = (task: ShippingTaskSummary | ShippingTaskDetail) =>
|
||||
|| Boolean(task.review_status || task.pending_human_reason)
|
||||
|| String(task.process_status || '').trim() === 'waiting_inventory');
|
||||
|
||||
const isWaitingHumanTask = (task: ShippingTaskSummary | ShippingTaskDetail) =>
|
||||
!isCompletedTask(task) && !isFailedTask(task) && Boolean(task.review_status || task.pending_human_reason);
|
||||
|
||||
const isResumableTask = (task: ShippingTaskSummary | ShippingTaskDetail) =>
|
||||
!isCompletedTask(task) && !isWaitingHumanTask(task) && (
|
||||
isFailedTask(task)
|
||||
|| ['created', 'parsed', 'inventory_ready', 'matched', 'waiting_upload'].includes(String(task.process_status || '').trim())
|
||||
);
|
||||
|
||||
const canRetryInventoryRpa = (task: ShippingTaskSummary | ShippingTaskDetail) => {
|
||||
const reason = String(task.pending_human_reason || '').trim().toLowerCase();
|
||||
const status = String(task.process_status || '').trim().toLowerCase();
|
||||
return status === 'waiting_inventory' && ['rpa_exhausted', 'rpa_pending', 'inv_unavail'].includes(reason);
|
||||
};
|
||||
|
||||
const batchAbnormalCount = (batch: ShippingBatchSummary) => {
|
||||
const summary = batch.process_summary || {};
|
||||
return Number(summary.failed || 0) + Number((summary as { needs_human?: number }).needs_human || 0);
|
||||
@@ -74,9 +90,13 @@ const taskCounts = computed(() => {
|
||||
const tasks = props.batchTasks || [];
|
||||
const completed = tasks.filter(isCompletedTask).length;
|
||||
const abnormal = tasks.filter(isAbnormalTask).length;
|
||||
const waitingHuman = tasks.filter(isWaitingHumanTask).length;
|
||||
const resumable = tasks.filter(isResumableTask).length;
|
||||
return {
|
||||
total: tasks.length,
|
||||
abnormal,
|
||||
waitingHuman,
|
||||
resumable,
|
||||
completed,
|
||||
};
|
||||
});
|
||||
@@ -84,6 +104,8 @@ const taskCounts = computed(() => {
|
||||
const filteredTasks = computed(() => {
|
||||
const tasks = props.batchTasks || [];
|
||||
if (activeFilter.value === 'abnormal') return tasks.filter(isAbnormalTask);
|
||||
if (activeFilter.value === 'waitingHuman') return tasks.filter(isWaitingHumanTask);
|
||||
if (activeFilter.value === 'resumable') return tasks.filter(isResumableTask);
|
||||
if (activeFilter.value === 'completed') return tasks.filter(isCompletedTask);
|
||||
return tasks;
|
||||
});
|
||||
@@ -107,6 +129,17 @@ const resolveTaskStateMeta = (task: ShippingTaskSummary | ShippingTaskDetail) =>
|
||||
const taskStepNumber = (task: ShippingTaskSummary | ShippingTaskDetail) =>
|
||||
resolveActiveStep(buildShippingWorkflowSteps(task)) + 1;
|
||||
|
||||
const taskStepHeadline = (task: ShippingTaskSummary | ShippingTaskDetail) => {
|
||||
const steps = buildShippingWorkflowSteps(task);
|
||||
const index = resolveActiveStep(steps);
|
||||
const step = steps[index];
|
||||
return step ? t('chat.shippingNoticeUi.stepHeadline', {
|
||||
current: index + 1,
|
||||
total: steps.length,
|
||||
label: t(step.label),
|
||||
}) : t('chat.shippingNoticeUi.stepFraction', { current: index + 1, total: steps.length });
|
||||
};
|
||||
|
||||
const currentStepProgress = (task: ShippingTaskSummary | ShippingTaskDetail) =>
|
||||
task.step_payload?.current_step_progress || null;
|
||||
|
||||
@@ -192,6 +225,27 @@ const resolveTaskDiagnosis = (task: ShippingTaskSummary | ShippingTaskDetail) =>
|
||||
};
|
||||
};
|
||||
|
||||
const resolveSuggestedAction = (task: ShippingTaskSummary | ShippingTaskDetail) => {
|
||||
const reason = String(task.pending_human_reason || '').trim();
|
||||
const reviewStatus = String(task.review_status || '').trim();
|
||||
if (hasShortageLines(task) || reason === 'shortage' || reviewStatus === 'shortage_review') {
|
||||
return t('chat.shippingNoticeUi.suggestShortageActions');
|
||||
}
|
||||
if (reason === 'align_review' || reviewStatus === 'align_review') {
|
||||
return t('chat.shippingNoticeUi.suggestConfirmMapping');
|
||||
}
|
||||
if (reason === 'low_confidence' || reviewStatus === 'parse_review') {
|
||||
return t('chat.shippingNoticeUi.suggestReviewParse');
|
||||
}
|
||||
if (isFailedTask(task)) {
|
||||
return t('chat.shippingNoticeUi.suggestRetryStep');
|
||||
}
|
||||
if (isCompletedTask(task)) {
|
||||
return t('chat.shippingNoticeUi.suggestViewOnly');
|
||||
}
|
||||
return t('chat.shippingNoticeUi.suggestContinue');
|
||||
};
|
||||
|
||||
const resolveActiveStep = (steps: ShippingWorkflowStepItem[]) => {
|
||||
const activeIndex = steps.findIndex((step) => step.status === 'current' || step.status === 'blocked');
|
||||
return activeIndex >= 0 ? activeIndex : Math.max(0, steps.length - 1);
|
||||
@@ -258,8 +312,9 @@ const handleSwitchBatch = (batchNo: string) => {
|
||||
</div>
|
||||
|
||||
<div class="flex-1 overflow-y-auto px-6 py-6">
|
||||
<section class="rounded-2xl border border-default bg-surface p-4 shadow-sm">
|
||||
<h3 class="text-sm font-bold text-primary">{{ t('chat.shippingNoticeUi.batchActionsTitle') }}</h3>
|
||||
<section class="rounded-lg border border-default bg-surface p-4 shadow-sm">
|
||||
<h3 class="text-sm font-bold text-primary">{{ t('chat.shippingNoticeUi.taskQueueTitle') }}</h3>
|
||||
<p class="mt-1 text-xs leading-5 text-muted">{{ t('chat.shippingNoticeUi.taskQueueHint') }}</p>
|
||||
<div class="mt-4">
|
||||
<button
|
||||
type="button"
|
||||
@@ -281,7 +336,7 @@ const handleSwitchBatch = (batchNo: string) => {
|
||||
<h3 class="text-sm font-bold text-primary">
|
||||
{{ t('chat.shippingNoticeUi.taskDetailCount', { count: filteredTasks.length }) }}
|
||||
</h3>
|
||||
<div class="flex rounded-lg bg-slate-100 p-1 text-xs">
|
||||
<div class="flex flex-wrap rounded-lg bg-slate-100 p-1 text-xs">
|
||||
<button
|
||||
type="button"
|
||||
class="rounded px-3 py-1 transition-colors"
|
||||
@@ -298,6 +353,22 @@ const handleSwitchBatch = (batchNo: string) => {
|
||||
>
|
||||
{{ t('chat.shippingNoticeUi.filterAbnormal', { count: taskCounts.abnormal }) }}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="rounded px-3 py-1 transition-colors"
|
||||
:class="activeFilter === 'waitingHuman' ? 'bg-white text-primary shadow-sm' : 'text-muted hover:text-secondary'"
|
||||
@click="activeFilter = 'waitingHuman'"
|
||||
>
|
||||
{{ t('chat.shippingNoticeUi.filterWaitingHuman', { count: taskCounts.waitingHuman }) }}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="rounded px-3 py-1 transition-colors"
|
||||
:class="activeFilter === 'resumable' ? 'bg-white text-primary shadow-sm' : 'text-muted hover:text-secondary'"
|
||||
@click="activeFilter = 'resumable'"
|
||||
>
|
||||
{{ t('chat.shippingNoticeUi.filterResumable', { count: taskCounts.resumable }) }}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="rounded px-3 py-1 transition-colors"
|
||||
@@ -313,11 +384,11 @@ const handleSwitchBatch = (batchNo: string) => {
|
||||
{{ t('chat.shippingNoticeUi.emptyFilteredTasks') }}
|
||||
</div>
|
||||
|
||||
<div v-else class="space-y-4">
|
||||
<div v-else class="space-y-3">
|
||||
<article
|
||||
v-for="task in filteredTasks"
|
||||
:key="task.task_no"
|
||||
class="relative overflow-hidden rounded-2xl border bg-white p-4 shadow-sm transition-colors"
|
||||
class="relative overflow-hidden rounded-lg border bg-white p-3 shadow-sm transition-colors"
|
||||
:class="[
|
||||
isFailedTask(task) ? 'border-rose-100' : isAbnormalTask(task) ? 'border-amber-100' : 'border-default',
|
||||
isCurrentTask(task.task_no) ? 'ring-1 ring-brand-200' : '',
|
||||
@@ -327,19 +398,20 @@ const handleSwitchBatch = (batchNo: string) => {
|
||||
class="absolute left-0 top-0 h-full w-1"
|
||||
:class="isFailedTask(task) ? 'bg-rose-500' : isAbnormalTask(task) ? 'bg-amber-500' : 'bg-emerald-500'"
|
||||
></div>
|
||||
<div class="mb-4 flex items-start justify-between gap-3">
|
||||
<div class="flex items-start justify-between gap-3">
|
||||
<div class="min-w-0">
|
||||
<div class="truncate font-mono text-sm font-bold text-primary">{{ task.task_no }}</div>
|
||||
<div class="mt-0.5 truncate text-xs text-muted">
|
||||
{{ task.source_file_name || task.customer_name || t('chat.shippingNoticeUi.currentNotice') }}
|
||||
</div>
|
||||
<div class="mt-1 text-xs font-medium text-secondary">{{ taskStepHeadline(task) }}</div>
|
||||
</div>
|
||||
<span class="rounded border px-2 py-1 text-[10px] font-bold" :class="resolveTaskStateMeta(task).className">
|
||||
{{ resolveTaskStateMeta(task).text }}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div class="mb-5 mt-4">
|
||||
<div class="my-3">
|
||||
<div class="scheme-stepper">
|
||||
<template v-for="(step, index) in buildShippingWorkflowSteps(task)" :key="step.id">
|
||||
<div
|
||||
@@ -363,14 +435,18 @@ const handleSwitchBatch = (batchNo: string) => {
|
||||
</div>
|
||||
|
||||
<div
|
||||
class="mb-3 rounded-lg border p-2.5 text-xs font-medium leading-5"
|
||||
class="mb-2 rounded-lg border p-2.5 text-xs font-medium leading-5"
|
||||
:class="isFailedTask(task) ? 'border-rose-100 bg-rose-50 text-rose-700' : isAbnormalTask(task) ? 'border-amber-100 bg-amber-50 text-amber-700' : 'border-emerald-100 bg-emerald-50 text-emerald-700'"
|
||||
>
|
||||
<div class="font-semibold">{{ resolveTaskDiagnosis(task).title }}</div>
|
||||
<div class="mt-1 font-normal text-slate-600">{{ resolveTaskDiagnosis(task).advice }}</div>
|
||||
</div>
|
||||
<div class="mb-3 text-xs leading-5 text-muted">
|
||||
<span class="font-semibold text-secondary">{{ t('chat.shippingNoticeUi.suggestedAction') }}</span>
|
||||
{{ resolveSuggestedAction(task) }}
|
||||
</div>
|
||||
|
||||
<div class="flex gap-2">
|
||||
<div class="flex flex-wrap gap-2">
|
||||
<button
|
||||
v-if="hasShortageLines(task)"
|
||||
type="button"
|
||||
@@ -381,18 +457,24 @@ const handleSwitchBatch = (batchNo: string) => {
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="flex flex-1 items-center justify-center gap-1.5 rounded-lg border border-transparent bg-surface-soft py-1.5 text-xs font-medium text-secondary transition-colors hover:border-brand-200 hover:bg-brand-50 hover:text-brand-600"
|
||||
class="flex flex-1 items-center justify-center gap-1.5 rounded-lg border border-transparent bg-surface-soft px-2 py-1.5 text-xs font-medium text-secondary transition-colors hover:border-brand-200 hover:bg-brand-50 hover:text-brand-600"
|
||||
@click="emit('focus-task', task.task_no)"
|
||||
>
|
||||
<Target class="h-3.5 w-3.5" />
|
||||
{{ t('chat.shippingNoticeUi.focusRepair') }}
|
||||
{{ t('chat.shippingNoticeUi.switchCurrentTask') }}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="flex-1 rounded-lg border border-default bg-white py-1.5 text-xs font-medium text-secondary transition-colors hover:border-brand-300 hover:text-brand-700"
|
||||
@click="emit('resume-task', task.task_no)"
|
||||
class="flex-1 rounded-lg border border-default bg-white px-2 py-1.5 text-xs font-medium text-secondary transition-colors hover:border-brand-300 hover:text-brand-700"
|
||||
@click="canRetryInventoryRpa(task) ? emit('retry-rpa', task.task_no) : emit('resume-task', task.task_no)"
|
||||
>
|
||||
{{ isCompletedTask(task) ? t('chat.shippingNoticeUi.viewDetail') : t('chat.shippingNoticeUi.retrySingleTask') }}
|
||||
{{
|
||||
isCompletedTask(task)
|
||||
? t('chat.shippingNoticeUi.viewDetail')
|
||||
: canRetryInventoryRpa(task)
|
||||
? t('chat.shippingNoticeUi.retryRpa')
|
||||
: t('chat.shippingNoticeUi.continueTask')
|
||||
}}
|
||||
</button>
|
||||
</div>
|
||||
</article>
|
||||
|
||||
@@ -489,6 +489,7 @@ export function useChatPage() {
|
||||
switchShippingFocusTask: shipping.switchShippingFocusTask,
|
||||
clearShippingFocus: shipping.clearShippingFocus,
|
||||
resumeShippingTask: shipping.resumeShippingTask,
|
||||
retryShippingInventoryRpa: shipping.retryShippingInventoryRpa,
|
||||
retryCurrentShippingBatchPendingTasks: shipping.retryCurrentShippingBatchPendingTasks,
|
||||
queryShippingShortageDetails: shipping.queryShippingShortageDetails,
|
||||
selectShippingInventoryUploadTask: shipping.selectShippingInventoryUploadTask,
|
||||
|
||||
@@ -595,6 +595,7 @@ export function useChatShipping(options: UseChatShippingOptions) {
|
||||
shippingInventorySchemaPreviewCache,
|
||||
getActiveShippingTaskId,
|
||||
sendShippingMenuMessage,
|
||||
pushShippingLocalUserMessage,
|
||||
pushShippingLocalAssistantMessage,
|
||||
refreshShippingActions,
|
||||
msg,
|
||||
@@ -727,6 +728,19 @@ export function useChatShipping(options: UseChatShippingOptions) {
|
||||
return true;
|
||||
};
|
||||
|
||||
const retryShippingInventoryRpa = async (taskNo: string) => {
|
||||
const normalizedTaskNo = String(taskNo || '').trim().toUpperCase();
|
||||
if (!normalizedTaskNo || !isShippingNoticeAgent.value || isThinking.value) return false;
|
||||
const switched = await switchShippingFocusTask(normalizedTaskNo);
|
||||
if (!switched) return false;
|
||||
const ok = await executeShippingDecision('retry_rpa', t('chat.shippingNoticeUi.retryRpa'));
|
||||
await syncShippingConversationWorkspace();
|
||||
const batchNo = getActiveShippingBatchNo();
|
||||
if (batchNo) await syncShippingBatchSummary(batchNo);
|
||||
await refreshShippingActions();
|
||||
return ok;
|
||||
};
|
||||
|
||||
const retryCurrentShippingBatchPendingTasks = async () => {
|
||||
const batchNo = getActiveShippingBatchNo();
|
||||
if (!batchNo || retryingShippingPendingTasks.value) return false;
|
||||
@@ -883,6 +897,7 @@ export function useChatShipping(options: UseChatShippingOptions) {
|
||||
switchShippingFocusTask,
|
||||
clearShippingFocus,
|
||||
resumeShippingTask,
|
||||
retryShippingInventoryRpa,
|
||||
retryCurrentShippingBatchPendingTasks,
|
||||
queryShippingShortageDetails,
|
||||
resetShippingConversationState,
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
/**
|
||||
* features/chat/shipping/shippingText.test.ts
|
||||
* 用途:锁定货代发货 Agent 消息净化规则,避免按钮动作列表和工程语言重新泄漏到用户界面。
|
||||
* 依赖:Vitest、shippingText 纯函数。
|
||||
* 逻辑:输入典型 Agent 回复,断言冗余 1/2/3 操作列表被移除,同时普通业务编号列表不受影响。
|
||||
*/
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { sanitizeShippingConversationText } from './shippingText';
|
||||
|
||||
describe('shippingText', () => {
|
||||
it('removes numbered action lists that duplicate structured shipping buttons', () => {
|
||||
// 关键断言:按钮已经结构化展示时,正文里的 1/2/3 操作清单不能再露给业务用户。
|
||||
const result = sanitizeShippingConversationText(
|
||||
[
|
||||
'⏳ 当前卡点 — 待上传库存',
|
||||
'',
|
||||
'目前任务已进入库存上传环节,您需要提供当前库存数据。请使用下方按钮选择以下任一方式:',
|
||||
'',
|
||||
'1. 📁 选择库存文件 — 在本对话中上传库存 Excel 文件',
|
||||
'2. 🔄 重试 RPA — 让系统重新尝试从 RPA 导出库存快照',
|
||||
'3. 📋 粘贴库存 — 直接粘贴库存小表内容',
|
||||
'',
|
||||
'请使用下方按钮继续操作。',
|
||||
].join('\n'),
|
||||
true,
|
||||
);
|
||||
|
||||
expect(result).toContain('当前卡点');
|
||||
expect(result).not.toContain('1.');
|
||||
expect(result).not.toContain('选择库存文件');
|
||||
expect(result).not.toContain('重试 RPA');
|
||||
expect(result).not.toContain('粘贴库存');
|
||||
expect(result).not.toContain('下方按钮');
|
||||
});
|
||||
|
||||
it('keeps normal numbered business lists', () => {
|
||||
// 关键断言:正常订单/业务明细仍可用编号展示,不能被动作列表规则误删。
|
||||
const result = sanitizeShippingConversationText(
|
||||
[
|
||||
'本次识别到 2 行订单:',
|
||||
'1. SKU A001,数量 10',
|
||||
'2. SKU B002,数量 5',
|
||||
].join('\n'),
|
||||
true,
|
||||
);
|
||||
|
||||
expect(result).toContain('1. SKU A001');
|
||||
expect(result).toContain('2. SKU B002');
|
||||
});
|
||||
});
|
||||
@@ -24,6 +24,77 @@ const isActionListContextLine = (line: string) =>
|
||||
const isActionListTailLine = (line: string) =>
|
||||
/(?:选择哪|希望.*(?:处理|执行|操作)|要.*哪一项|点击.*按钮)/.test(line);
|
||||
|
||||
const isShippingActionListContextLine = (line: string) =>
|
||||
/(?:请选择操作|选择操作|操作选项|下方按钮|按钮继续操作|以下.*方式|任一方式|库存上传|提供当前库存|提供.*库存数据)/.test(line);
|
||||
|
||||
const isShippingActionChoiceLine = (line: string) =>
|
||||
/(?:选择库存文件|上传库存|粘贴库存|重试\s*RPA|修改映射|确认字段|继续处理|查看卡点|返回修订|重新匹配|重试当前步骤|切换为当前任务)/i.test(line);
|
||||
|
||||
/**
|
||||
* 移除 Agent 正文里重复描述按钮的 1/2/3 编号动作列表。
|
||||
*
|
||||
* 这些动作已经由结构化按钮承载,正文再展示会显得像提示词/后端兜底泄漏。
|
||||
* 为避免误删订单行,只在“按钮/库存/操作方式”上下文中,且编号行命中动作词时移除。
|
||||
*/
|
||||
export function stripShippingRedundantNumberedActionList(text: string): string {
|
||||
const lines = String(text || '').split('\n');
|
||||
const remove = new Set<number>();
|
||||
|
||||
for (let index = 0; index < lines.length; index += 1) {
|
||||
if (!isNumberedActionLine(lines[index] || '')) continue;
|
||||
|
||||
const block: number[] = [];
|
||||
let cursor = index;
|
||||
while (cursor < lines.length && isNumberedActionLine(lines[cursor] || '')) {
|
||||
block.push(cursor);
|
||||
cursor += 1;
|
||||
}
|
||||
|
||||
const actionLineCount = block.filter((lineIndex) => isShippingActionChoiceLine(lines[lineIndex] || '')).length;
|
||||
if (block.length < 2 || actionLineCount === 0) {
|
||||
index = cursor - 1;
|
||||
continue;
|
||||
}
|
||||
|
||||
const nearbyStart = Math.max(0, index - 3);
|
||||
const nearbyEnd = Math.min(lines.length - 1, cursor + 2);
|
||||
const hasActionContext = lines
|
||||
.slice(nearbyStart, nearbyEnd + 1)
|
||||
.some((line) => isShippingActionListContextLine(line));
|
||||
if (!hasActionContext) {
|
||||
index = cursor - 1;
|
||||
continue;
|
||||
}
|
||||
|
||||
block.forEach((lineIndex) => remove.add(lineIndex));
|
||||
|
||||
for (let before = index - 1; before >= nearbyStart; before -= 1) {
|
||||
const line = lines[before] || '';
|
||||
if (!line.trim() || isShippingActionListContextLine(line)) {
|
||||
remove.add(before);
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
for (let after = cursor; after <= nearbyEnd; after += 1) {
|
||||
const line = lines[after] || '';
|
||||
if (!line.trim() || isShippingActionListContextLine(line)) {
|
||||
remove.add(after);
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
index = cursor - 1;
|
||||
}
|
||||
|
||||
return lines
|
||||
.filter((_, index) => !remove.has(index))
|
||||
.join('\n')
|
||||
.replace(/\n{3,}/g, '\n\n')
|
||||
.trim();
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据后端 action_buttons 移除 Agent 正文中重复生成的编号操作列表。
|
||||
*
|
||||
@@ -80,11 +151,11 @@ export function stripShippingActionListByButtons(
|
||||
}
|
||||
}
|
||||
|
||||
return lines
|
||||
return stripShippingRedundantNumberedActionList(lines
|
||||
.filter((_, index) => !remove.has(index))
|
||||
.join('\n')
|
||||
.replace(/\n{3,}/g, '\n\n')
|
||||
.trim();
|
||||
.trim());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -93,6 +164,18 @@ export function stripShippingActionListByButtons(
|
||||
export function sanitizeShippingConversationText(text: string, enabled: boolean): string {
|
||||
if (!enabled) return text;
|
||||
let result = String(text || '')
|
||||
.replace(
|
||||
/已回到列映射步骤。?请根据\s*schema_preview\s*提供新的\s*map_json\s*[,,]\s*再调用\s*(?:应用库存字段映射|apply_inventory_mapping)[^。.\n]*[。.]?/gi,
|
||||
'已回到库存字段确认步骤。请检查系统识别的库存列名,确认无误后继续;如有问题请修改映射。',
|
||||
)
|
||||
.replace(
|
||||
/请根据\s*schema_preview\s*提供新的\s*map_json\s*[,,]\s*再调用\s*(?:应用库存字段映射|apply_inventory_mapping)[^。.\n]*[。.]?/gi,
|
||||
'请检查系统识别的库存列名,确认无误后继续;如有问题请修改映射。',
|
||||
)
|
||||
.replace(
|
||||
/根据\s*data\.schema_preview\.headers\s*与\s*sample_rows\s*推断\s*JSON[^。.\n]*再调用\s*(?:应用库存字段映射|apply_inventory_mapping)[^。.\n]*[。.]?/gi,
|
||||
'请根据库存表头和样例行确认字段对应关系。',
|
||||
)
|
||||
.replace(/通过\s*(?:Hxops|HXOPS|hxops)\s*聊天区上传/gi, '在当前对话中上传')
|
||||
.replace(/在\s*(?:Hxops|HXOPS|hxops)\s*聊天区上传/gi, '在当前对话中上传')
|
||||
.replace(/(?:Hxops|HXOPS|hxops)\s*聊天区/gi, '当前对话')
|
||||
@@ -112,6 +195,10 @@ export function sanitizeShippingConversationText(text: string, enabled: boolean)
|
||||
.replace(/\bupload_to_freight\b/gi, '上传货代系统')
|
||||
.replace(/\bapply_inventory_mapping\b/gi, '应用库存字段映射')
|
||||
.replace(/\bget_inventory_schema_preview\b/gi, '读取库存表头预览')
|
||||
.replace(/\bschema_preview(?:\.headers)?\b/gi, '库存表头预览')
|
||||
.replace(/\bdata\.库存表头预览\b/gi, '库存表头预览')
|
||||
.replace(/\bmap_json\b/gi, '字段映射')
|
||||
.replace(/\bsample_rows\b/gi, '样例行')
|
||||
.replace(/\bretry_rpa\b/gi, '重试库存抓取')
|
||||
.replace(/\bretry_upload\b/gi, '重试上传货代')
|
||||
.replace(/\bstructured\b/gi, '结构化内容')
|
||||
@@ -126,7 +213,7 @@ export function sanitizeShippingConversationText(text: string, enabled: boolean)
|
||||
result = result.replace(quoted, '');
|
||||
result = result.replace(new RegExp(`\`${token}\``, 'gi'), '');
|
||||
}
|
||||
return result.replace(/\n{3,}/g, '\n\n').trim();
|
||||
return stripShippingRedundantNumberedActionList(result.replace(/\n{3,}/g, '\n\n').trim());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -34,6 +34,7 @@ export interface ShippingUploadHandlerContext {
|
||||
shippingInventorySchemaPreviewCache: Ref<Record<string, unknown>>;
|
||||
getActiveShippingTaskId: () => string;
|
||||
sendShippingMenuMessage: (message: string) => Promise<void>;
|
||||
pushShippingLocalUserMessage: (text: string) => Promise<void>;
|
||||
pushShippingLocalAssistantMessage: (text: string) => Promise<void>;
|
||||
refreshShippingActions: () => Promise<void>;
|
||||
msg: { warning: (text: string) => void };
|
||||
@@ -72,6 +73,7 @@ export function createShippingUploadHandlers(ctx: ShippingUploadHandlerContext)
|
||||
|
||||
const uploadInventoryForTask = async (taskId: string, file: File) => {
|
||||
ctx.resolvedShippingTaskId.value = taskId;
|
||||
await ctx.pushShippingLocalUserMessage(ctx.t('chat.shippingNoticeInventoryUploadStarted', { fileName: file.name }));
|
||||
const result = await uploadWorkspaceShippingInventory(taskId, file);
|
||||
const batchNo = String(
|
||||
((result as unknown as { data?: { batch_no?: string } }).data?.batch_no)
|
||||
|
||||
@@ -2,64 +2,41 @@
|
||||
/**
|
||||
* features/workspace/views/ShippingNoticeView.vue
|
||||
* 用途:货代发货任务只读工作台,提供任务筛选、详情查看与跳转 Chat 继续处理入口。
|
||||
* 依赖:ShippingWorkflowStepper、ShippingParseReviewMessage、ShippingMatchResultCard、shipping.api。
|
||||
* 逻辑:先拉取任务列表与详情,再复用 Chat 区的发货组件展示步骤、匹配结果和 parse review。
|
||||
* 依赖:ShippingWorkflowStepper、ShippingMatchResultCard、shipping.api。
|
||||
* 逻辑:先拉取任务列表与详情,再以只读方式展示步骤、匹配结果和事件记录;所有写操作回到 Chat 主路径完成。
|
||||
*/
|
||||
import { computed, onMounted, ref, watch } from 'vue';
|
||||
import { useRouter } from 'vue-router';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { ArrowLeft, Download, ExternalLink, RefreshCw } from 'lucide-vue-next';
|
||||
import ShippingWorkflowStepper from '@/features/chat/components/ShippingWorkflowStepper.vue';
|
||||
import ShippingParseReviewMessage, {
|
||||
type ShippingParseReviewHandlers,
|
||||
} from '@/features/chat/components/messages/ShippingParseReviewMessage.vue';
|
||||
import ShippingMatchResultCard from '@/features/chat/components/messages/ShippingMatchResultCard.vue';
|
||||
import { formatLocalDateTime } from '@/shared/utils/dateTime';
|
||||
import {
|
||||
addWorkspaceShippingNoticeLine,
|
||||
autoProgressWorkspaceShippingTask,
|
||||
generateWorkspaceShippingExcel,
|
||||
getShippingChatActions,
|
||||
getWorkspaceShippingTask,
|
||||
listShippingChatAgents,
|
||||
listWorkspaceShippingTasks,
|
||||
markWorkspaceShippingManualUploaded,
|
||||
matchWorkspaceShippingInventory,
|
||||
removeWorkspaceShippingNoticeLine,
|
||||
retryWorkspaceShippingTask,
|
||||
SHIPPING_NOTICE_AGENT_NAME,
|
||||
submitWorkspaceShippingDecision,
|
||||
updateWorkspaceShippingNoticeFields,
|
||||
updateWorkspaceShippingNoticeLine,
|
||||
workspaceShippingExportUrl,
|
||||
type ShippingChatAction,
|
||||
type ShippingCurrentStepProgress,
|
||||
type ShippingNoticeHeader,
|
||||
type ShippingNoticeLine,
|
||||
type ShippingTaskDetail,
|
||||
type ShippingTaskSummary,
|
||||
} from '@/features/chat/api/shipping.api';
|
||||
import type { ChatMessage } from '@/features/chat/types/chat.types';
|
||||
import type { ShippingParseReviewPayload } from '@/features/chat/types/shipping.types';
|
||||
import { getAuthHeaders } from '@/shared/utils/auth';
|
||||
import { useMessage } from '@/shared/composables/useMessage';
|
||||
import { buildShippingWorkflowSteps, shippingActionButtonClass } from '@/features/chat/shipping';
|
||||
import { buildShippingWorkflowSteps } from '@/features/chat/shipping';
|
||||
|
||||
const props = defineProps<{
|
||||
embedded?: boolean;
|
||||
}>();
|
||||
|
||||
const router = useRouter();
|
||||
const { t } = useI18n();
|
||||
const msg = useMessage();
|
||||
const { t, te } = useI18n();
|
||||
|
||||
const loading = ref(false);
|
||||
const detailLoading = ref(false);
|
||||
const tasks = ref<ShippingTaskSummary[]>([]);
|
||||
const selectedTaskNo = ref<string | null>(null);
|
||||
const detail = ref<ShippingTaskDetail | null>(null);
|
||||
const detailSaving = ref(false);
|
||||
const detailActionBusy = ref(false);
|
||||
const detailRetrying = ref(false);
|
||||
const detailActionButtons = ref<ShippingChatAction[]>([]);
|
||||
const statusFilter = ref('all');
|
||||
const chatAgentId = ref<number | null>(null);
|
||||
const batchProgressLabel = computed(() => {
|
||||
@@ -81,17 +58,54 @@ const statusOptions = computed(() => [
|
||||
{ value: 'upload_failed', label: t('workspace.shippingNotice.status.uploadFailed') },
|
||||
]);
|
||||
|
||||
const statusBadge = (status: string) => {
|
||||
type ShippingStatusSource = Pick<
|
||||
ShippingTaskSummary,
|
||||
'process_status' | 'review_status' | 'pending_human_reason' | 'match_status'
|
||||
>;
|
||||
|
||||
const displayStatusCode = (source: ShippingStatusSource | string) => {
|
||||
if (typeof source === 'string') return source;
|
||||
const reason = String(source.pending_human_reason || '').trim();
|
||||
const reviewStatus = String(source.review_status || '').trim();
|
||||
if (reason === 'shortage' || reason === 'shortage_review' || reviewStatus === 'shortage_review') return 'shortage_review';
|
||||
if (reason === 'align_review' || reviewStatus === 'align_review') return 'align_review';
|
||||
return String(source.process_status || '').trim();
|
||||
};
|
||||
|
||||
const statusBadge = (source: ShippingStatusSource | string) => {
|
||||
const status = displayStatusCode(source);
|
||||
const map: Record<string, { cls: string; label: string }> = {
|
||||
created: { cls: 'bg-slate-100 text-secondary', label: t('workspace.shippingNotice.status.created') },
|
||||
parsed: { cls: 'bg-blue-100 text-blue-700', label: t('workspace.shippingNotice.status.parsed') },
|
||||
pending_review: { cls: 'bg-amber-100 text-amber-700', label: t('workspace.shippingNotice.status.pendingReview') },
|
||||
align_review: { cls: 'bg-amber-100 text-amber-700', label: t('workspace.shippingNotice.status.alignReview') },
|
||||
shortage_review: { cls: 'bg-rose-100 text-rose-700', label: t('workspace.shippingNotice.status.shortageReview') },
|
||||
waiting_inventory: { cls: 'bg-amber-100 text-amber-700', label: t('workspace.shippingNotice.status.waitingInventory') },
|
||||
inventory_ready: { cls: 'bg-blue-100 text-blue-700', label: t('workspace.shippingNotice.status.inventoryReady') },
|
||||
matched: { cls: 'bg-emerald-100 text-emerald-700', label: t('workspace.shippingNotice.status.matched') },
|
||||
waiting_upload: { cls: 'bg-amber-100 text-amber-700', label: t('workspace.shippingNotice.status.waitingUpload') },
|
||||
uploaded: { cls: 'bg-emerald-100 text-emerald-700', label: t('workspace.shippingNotice.status.uploaded') },
|
||||
upload_failed: { cls: 'bg-rose-100 text-rose-700', label: t('workspace.shippingNotice.status.uploadFailed') },
|
||||
rejected: { cls: 'bg-slate-100 text-secondary', label: t('workspace.shippingNotice.status.rejected') },
|
||||
closed: { cls: 'bg-slate-100 text-secondary', label: t('workspace.shippingNotice.status.closed') },
|
||||
};
|
||||
return map[status] || { cls: 'bg-slate-100 text-secondary', label: status };
|
||||
return map[status] || { cls: 'bg-slate-100 text-secondary', label: t('workspace.shippingNotice.status.unknown') };
|
||||
};
|
||||
|
||||
const matchStatusLabel = (status?: string | null) => {
|
||||
const key = String(status || '').trim();
|
||||
const map: Record<string, string> = {
|
||||
fulfillable: t('workspace.shippingNotice.matchStatus.fulfillable'),
|
||||
partial: t('workspace.shippingNotice.matchStatus.partial'),
|
||||
unfulfillable: t('workspace.shippingNotice.matchStatus.unfulfillable'),
|
||||
};
|
||||
return map[key] || (key ? t('workspace.shippingNotice.matchStatus.unknown') : '—');
|
||||
};
|
||||
|
||||
const eventLabel = (eventType: string) => {
|
||||
const normalized = String(eventType || '').trim().replace(/[^a-zA-Z0-9_]/g, '');
|
||||
const key = `workspace.shippingNotice.eventTypes.${normalized}`;
|
||||
return te(key) ? t(key) : t('workspace.shippingNotice.eventTypes.system');
|
||||
};
|
||||
|
||||
const detailWorkflowSteps = computed(() => buildShippingWorkflowSteps(detail.value));
|
||||
@@ -122,15 +136,9 @@ const loadCases = async () => {
|
||||
const loadDetail = async (taskNo: string) => {
|
||||
detailLoading.value = true;
|
||||
try {
|
||||
const [taskDetail, chatActions] = await Promise.all([
|
||||
getWorkspaceShippingTask(taskNo),
|
||||
getShippingChatActions(taskNo).catch(() => null),
|
||||
]);
|
||||
detail.value = taskDetail;
|
||||
detailActionButtons.value = chatActions?.action_buttons || [];
|
||||
detail.value = await getWorkspaceShippingTask(taskNo);
|
||||
} catch {
|
||||
detail.value = null;
|
||||
detailActionButtons.value = [];
|
||||
} finally {
|
||||
detailLoading.value = false;
|
||||
}
|
||||
@@ -138,9 +146,7 @@ const loadDetail = async (taskNo: string) => {
|
||||
|
||||
const resolveChatAgent = async () => {
|
||||
try {
|
||||
const res = await fetch('/api/agents', { headers: getAuthHeaders() });
|
||||
if (!res.ok) return;
|
||||
const agents = (await res.json()) as Array<{ id: number; name: string }>;
|
||||
const agents = await listShippingChatAgents();
|
||||
const found = agents.find((a) => a.name === SHIPPING_NOTICE_AGENT_NAME);
|
||||
if (found) chatAgentId.value = found.id;
|
||||
} catch {
|
||||
@@ -170,86 +176,6 @@ const downloadExport = async (taskNo: string) => {
|
||||
URL.revokeObjectURL(a.href);
|
||||
};
|
||||
|
||||
const parseReviewPayload = computed<ShippingParseReviewPayload | null>(() => {
|
||||
if (!detail.value || detail.value.review_status !== 'pending_confirm') return null;
|
||||
return {
|
||||
taskId: detail.value.task_no,
|
||||
checkpoint: 'parse_review',
|
||||
header: {
|
||||
customer_name: detail.value.customer_name ?? null,
|
||||
customer_code: detail.value.customer_code ?? null,
|
||||
ship_to: detail.value.ship_to ?? null,
|
||||
po_number: detail.value.po_number ?? null,
|
||||
required_date: detail.value.required_date ?? null,
|
||||
},
|
||||
lines: Array.isArray(detail.value.lines) ? detail.value.lines : [],
|
||||
saving: detailSaving.value,
|
||||
};
|
||||
});
|
||||
|
||||
const parseReviewMessage = computed<ChatMessage>(() => ({
|
||||
role: 'assistant',
|
||||
type: 'shipping-parse-review',
|
||||
content: `${t('chat.shippingNoticeUi.parseReviewIntro')}\n${t('chat.shippingNoticeUi.taskId', { taskId: detail.value?.task_no || '' })}`.trim(),
|
||||
payload: parseReviewPayload.value || undefined,
|
||||
}));
|
||||
|
||||
const parseReviewHandlers: ShippingParseReviewHandlers = {
|
||||
getPayload: () => parseReviewPayload.value,
|
||||
updateHeader: async (_msg, fields: Partial<ShippingNoticeHeader>) => {
|
||||
if (!detail.value || detailSaving.value) return false;
|
||||
detailSaving.value = true;
|
||||
try {
|
||||
await updateWorkspaceShippingNoticeFields(detail.value.task_no, fields, '工作台订单表修订');
|
||||
await Promise.all([loadDetail(detail.value.task_no), loadCases()]);
|
||||
return true;
|
||||
} catch {
|
||||
return false;
|
||||
} finally {
|
||||
detailSaving.value = false;
|
||||
}
|
||||
},
|
||||
updateLine: async (_msg, lineIndex: number, patch: Partial<ShippingNoticeLine>) => {
|
||||
if (!detail.value || detailSaving.value) return false;
|
||||
detailSaving.value = true;
|
||||
try {
|
||||
await updateWorkspaceShippingNoticeLine(detail.value.task_no, lineIndex, patch, '工作台订单表修订');
|
||||
await Promise.all([loadDetail(detail.value.task_no), loadCases()]);
|
||||
return true;
|
||||
} catch {
|
||||
return false;
|
||||
} finally {
|
||||
detailSaving.value = false;
|
||||
}
|
||||
},
|
||||
addLine: async (_msg, line: Partial<ShippingNoticeLine>) => {
|
||||
if (!detail.value || detailSaving.value) return false;
|
||||
detailSaving.value = true;
|
||||
try {
|
||||
await addWorkspaceShippingNoticeLine(detail.value.task_no, line, '工作台订单表新增行');
|
||||
await Promise.all([loadDetail(detail.value.task_no), loadCases()]);
|
||||
return true;
|
||||
} catch {
|
||||
return false;
|
||||
} finally {
|
||||
detailSaving.value = false;
|
||||
}
|
||||
},
|
||||
removeLine: async (_msg, lineIndex: number) => {
|
||||
if (!detail.value || detailSaving.value) return false;
|
||||
detailSaving.value = true;
|
||||
try {
|
||||
await removeWorkspaceShippingNoticeLine(detail.value.task_no, lineIndex, '工作台订单表删除行');
|
||||
await Promise.all([loadDetail(detail.value.task_no), loadCases()]);
|
||||
return true;
|
||||
} catch {
|
||||
return false;
|
||||
} finally {
|
||||
detailSaving.value = false;
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
const shortageLines = computed(() => detail.value?.shortage?.lines || []);
|
||||
const hasMatchCard = computed(() =>
|
||||
!!detail.value && (
|
||||
@@ -258,59 +184,6 @@ const hasMatchCard = computed(() =>
|
||||
),
|
||||
);
|
||||
|
||||
const handleWorkspaceAction = async (action: ShippingChatAction) => {
|
||||
if (!detail.value || detailActionBusy.value) return;
|
||||
const taskNo = detail.value.task_no;
|
||||
detailActionBusy.value = true;
|
||||
try {
|
||||
if (action.id === 'download_excel') {
|
||||
await downloadExport(taskNo);
|
||||
return;
|
||||
}
|
||||
if (action.id === 'generate_excel') {
|
||||
await generateWorkspaceShippingExcel(taskNo);
|
||||
} else if (action.id === 'match_inventory') {
|
||||
await matchWorkspaceShippingInventory(taskNo);
|
||||
} else if (action.id === 'mark_manual_uploaded') {
|
||||
await markWorkspaceShippingManualUploaded(taskNo);
|
||||
} else if (action.id === 'refresh') {
|
||||
await loadDetail(taskNo);
|
||||
return;
|
||||
} else if (action.id === 'confirm_inventory_mapping') {
|
||||
await autoProgressWorkspaceShippingTask(taskNo);
|
||||
} else if ([
|
||||
'confirm',
|
||||
'reject',
|
||||
'reparse',
|
||||
'correct_inventory_mapping',
|
||||
'reparse_inventory',
|
||||
'rematch',
|
||||
].includes(action.id)) {
|
||||
await submitWorkspaceShippingDecision(taskNo, action.id);
|
||||
} else {
|
||||
openInChat(taskNo, detail.value.conversation_id, detail.value.batch_no);
|
||||
return;
|
||||
}
|
||||
await Promise.all([loadDetail(taskNo), loadCases()]);
|
||||
} finally {
|
||||
detailActionBusy.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
const handleRetryCurrentTask = async () => {
|
||||
if (!detail.value || detailRetrying.value) return;
|
||||
detailRetrying.value = true;
|
||||
try {
|
||||
const result = await retryWorkspaceShippingTask(detail.value.task_no, '工作台重试当前票');
|
||||
msg.success(result.message || t('workspace.shippingNotice.retryCurrentDone'));
|
||||
await Promise.all([loadDetail(detail.value.task_no), loadCases()]);
|
||||
} catch (error) {
|
||||
msg.error(error instanceof Error ? error.message : t('workspace.shippingNotice.retryFailed'));
|
||||
} finally {
|
||||
detailRetrying.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
watch(selectedTaskNo, (val) => {
|
||||
if (val) loadDetail(val);
|
||||
else detail.value = null;
|
||||
@@ -382,13 +255,17 @@ onMounted(async () => {
|
||||
>
|
||||
<div class="flex items-center justify-between gap-2">
|
||||
<span class="font-mono text-sm font-semibold text-primary">{{ item.task_no }}</span>
|
||||
<span class="rounded-full px-2 py-0.5 text-xs font-medium" :class="statusBadge(item.process_status).cls">
|
||||
{{ statusBadge(item.process_status).label }}
|
||||
<span
|
||||
class="rounded-full px-2 py-0.5 text-xs font-medium"
|
||||
:class="statusBadge(item).cls"
|
||||
:title="item.process_status"
|
||||
>
|
||||
{{ statusBadge(item).label }}
|
||||
</span>
|
||||
</div>
|
||||
<div class="mt-1 truncate text-sm text-secondary">{{ item.customer_name || '—' }}</div>
|
||||
<div class="mt-1 flex flex-wrap items-center gap-2 text-xs text-muted">
|
||||
<span>{{ item.created_at || '' }}</span>
|
||||
<span>{{ formatLocalDateTime(item.created_at) }}</span>
|
||||
<span v-if="item.batch_index && item.batch_total" class="rounded-full bg-sky-50 px-2 py-0.5 font-medium text-sky-700">
|
||||
{{ t('chat.shippingNoticeUi.batchProgress', { index: item.batch_index, total: item.batch_total }) }}
|
||||
</span>
|
||||
@@ -418,15 +295,6 @@ onMounted(async () => {
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex flex-wrap gap-2">
|
||||
<button
|
||||
type="button"
|
||||
class="inline-flex items-center gap-1 rounded-xl border border-default px-3 py-1.5 text-sm font-medium text-secondary hover:bg-surface-soft disabled:cursor-not-allowed disabled:opacity-60"
|
||||
:disabled="detailRetrying"
|
||||
@click="handleRetryCurrentTask"
|
||||
>
|
||||
<RefreshCw class="h-3.5 w-3.5" />
|
||||
{{ detailRetrying ? $t('workspace.shippingNotice.retrying') : $t('workspace.shippingNotice.retryCurrentTask') }}
|
||||
</button>
|
||||
<button
|
||||
v-if="chatAgentId"
|
||||
type="button"
|
||||
@@ -486,8 +354,14 @@ onMounted(async () => {
|
||||
</div>
|
||||
|
||||
<dl class="grid gap-3 sm:grid-cols-2 text-sm">
|
||||
<div><dt class="text-muted">{{ $t('workspace.shippingNotice.fields.status') }}</dt><dd>{{ detail.process_status }}</dd></div>
|
||||
<div><dt class="text-muted">{{ $t('workspace.shippingNotice.fields.match') }}</dt><dd>{{ detail.match_status || '—' }}</dd></div>
|
||||
<div>
|
||||
<dt class="text-muted">{{ $t('workspace.shippingNotice.fields.status') }}</dt>
|
||||
<dd :title="detail.process_status">{{ statusBadge(detail).label }}</dd>
|
||||
</div>
|
||||
<div>
|
||||
<dt class="text-muted">{{ $t('workspace.shippingNotice.fields.match') }}</dt>
|
||||
<dd :title="detail.match_status || ''">{{ matchStatusLabel(detail.match_status) }}</dd>
|
||||
</div>
|
||||
<div><dt class="text-muted">{{ $t('workspace.shippingNotice.fields.shipTo') }}</dt><dd>{{ detail.ship_to || '—' }}</dd></div>
|
||||
<div><dt class="text-muted">{{ $t('workspace.shippingNotice.fields.freightRef') }}</dt><dd>{{ detail.freight_ref_no || '—' }}</dd></div>
|
||||
</dl>
|
||||
@@ -502,20 +376,11 @@ onMounted(async () => {
|
||||
:match-status="detail.match_status"
|
||||
:line-results="detail.line_results"
|
||||
:shortage-lines="shortageLines"
|
||||
:action-buttons="detailActionButtons"
|
||||
:action-busy="detailActionBusy"
|
||||
:action-button-class="shippingActionButtonClass"
|
||||
:on-action-click="handleWorkspaceAction"
|
||||
:action-buttons="[]"
|
||||
:action-busy="false"
|
||||
/>
|
||||
|
||||
<div v-if="parseReviewPayload">
|
||||
<ShippingParseReviewMessage
|
||||
:message="parseReviewMessage"
|
||||
:handlers="parseReviewHandlers"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div v-else-if="detail.lines?.length">
|
||||
<div v-if="detail.lines?.length">
|
||||
<h3 class="mb-2 text-sm font-semibold text-secondary">{{ $t('workspace.shippingNotice.lines') }}</h3>
|
||||
<div class="overflow-x-auto rounded-xl border border-default">
|
||||
<table class="min-w-full text-sm">
|
||||
@@ -539,8 +404,8 @@ onMounted(async () => {
|
||||
<h3 class="mb-2 text-sm font-semibold text-secondary">{{ $t('workspace.shippingNotice.events') }}</h3>
|
||||
<ul class="max-h-48 space-y-1 overflow-y-auto text-xs text-muted">
|
||||
<li v-for="(ev, idx) in [...detail.events].reverse()" :key="idx">
|
||||
<span class="font-medium text-secondary">{{ ev.event_type }}</span>
|
||||
<span class="ml-2">{{ ev.created_at }}</span>
|
||||
<span class="font-medium text-secondary" :title="ev.event_type">{{ eventLabel(ev.event_type) }}</span>
|
||||
<span class="ml-2">{{ formatLocalDateTime(ev.created_at) }}</span>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
"shippingNoticeActionsHint": "Choose an action:",
|
||||
"shippingNoticeMissingTaskId": "Task ID not found. Complete shipping notice parsing first.",
|
||||
"shippingNoticeUploadDone": "Inventory file uploaded: {fileName}.",
|
||||
"shippingNoticeInventoryUploadStarted": "I selected inventory file {fileName}. Uploading it and reading the inventory columns now.",
|
||||
"shippingNoticeUploadOk": "Upload succeeded.",
|
||||
"shippingNoticeUploadFailed": "Inventory upload failed.",
|
||||
"shippingNoticeRefreshDone": "Current task status refreshed.",
|
||||
@@ -33,10 +34,10 @@
|
||||
"prefixWithFile": "I have uploaded the inventory file \"{fileName}\"",
|
||||
"prefixBatch": "I have uploaded the batch inventory snapshot for batch {batchNo}",
|
||||
"prefixBatchWithFile": "I have uploaded the batch inventory snapshot \"{fileName}\" for batch {batchNo}",
|
||||
"mapInferSuggested": "{prefix}. Please continue the inventory column mapping. If the system has already identified a complete mapping, apply it directly and show me the field alignment result for confirmation.",
|
||||
"mapInferPending": "{prefix}. Please continue parsing the inventory column mapping, and after a usable mapping is available, show me the field alignment result for confirmation.",
|
||||
"alignReview": "{prefix}. Please show the inventory field alignment result and guide me to confirm or correct the mapping.",
|
||||
"default": "{prefix}. Please continue the inventory import and tell me the next step."
|
||||
"mapInferSuggested": "{prefix}. Continue the inventory column mapping. If a complete mapping is available, apply it directly and reply with one short status sentence that the inventory field confirmation is ready. Do not list operation menus, numbered options, button lists, or phrases like \"choose one of the following\"; clickable actions are rendered by system buttons.",
|
||||
"mapInferPending": "{prefix}. Continue parsing the inventory column mapping, then reply with one short status sentence when the inventory field confirmation is ready. Do not list operation menus, numbered options, button lists, or phrases like \"choose one of the following\"; clickable actions are rendered by system buttons.",
|
||||
"alignReview": "{prefix}. Reply with one short sentence saying the inventory field confirmation is ready and ask me to check the columns before continuing. Do not list operation menus, numbered options, button lists, or phrases like \"choose one of the following\"; clickable actions are rendered by system buttons.",
|
||||
"default": "{prefix}. Continue the inventory import and only state the current status. Do not list operation menus, numbered options, button lists, or phrases like \"choose one of the following\"; clickable actions are rendered by system buttons."
|
||||
},
|
||||
"notice": {
|
||||
"fileLabelSingleFile": "\"{fileName}\"",
|
||||
@@ -123,18 +124,25 @@
|
||||
"hideWorkspace": "Hide workspace",
|
||||
"batchWorkspaceTitle": "Batch workspace",
|
||||
"batchWorkspaceSubtitle": "Switch batches, filter tasks, and diagnose steps",
|
||||
"taskQueueTitle": "Task queue",
|
||||
"taskQueueHint": "Use this panel to spot blockers and recovery entries. Final confirmations stay in chat.",
|
||||
"batchActionsTitle": "Batch actions",
|
||||
"retryFailedTasks": "Retry all failed",
|
||||
"batchActionSafetyNotice": "Human-review tasks are not retried in bulk; completed tasks are not uploaded again. Batch recovery only handles failed or queued tasks.",
|
||||
"taskDetailCount": "Task details ({count})",
|
||||
"filterAll": "All",
|
||||
"filterAbnormal": "Abnormal ({count})",
|
||||
"filterWaitingHuman": "Waiting human ({count})",
|
||||
"filterResumable": "Resumable ({count})",
|
||||
"filterCompleted": "Done ({count})",
|
||||
"emptyFilteredTasks": "No matching tasks",
|
||||
"focusRepair": "Focus repair",
|
||||
"switchCurrentTask": "Make current",
|
||||
"queryShortageDetails": "Query shortage details",
|
||||
"retryRpa": "Retry RPA",
|
||||
"retrySingleTask": "Retry single task",
|
||||
"retrySingleTaskMessage": "Retry current task {taskId}",
|
||||
"continueTask": "Continue",
|
||||
"viewDetail": "View details",
|
||||
"mobileWorkspaceHint": "The workspace is open on mobile. Pick a task from the list to continue.",
|
||||
"diagnosisAdviceRetryOrFocus": "Focus this task first to inspect context; retry only if it is a transient external-system failure.",
|
||||
@@ -168,6 +176,17 @@
|
||||
"needsIntervention": "Needs intervention",
|
||||
"currentNotice": "Current notice",
|
||||
"currentStepLabel": "Current",
|
||||
"blockedWaitingHuman": "Waiting for confirmation",
|
||||
"blockedShortage": "Blocked by shortage",
|
||||
"blockedParseReview": "Parse review required",
|
||||
"blockedUploadRetryable": "Upload failed, retry available",
|
||||
"suggestedAction": "Suggested action:",
|
||||
"suggestShortageActions": "View shortage / revise notice / rematch",
|
||||
"suggestConfirmMapping": "Confirm column mapping, then continue matching",
|
||||
"suggestReviewParse": "Review parsed fields, then confirm or revise",
|
||||
"suggestRetryStep": "Inspect the blocker, then retry this step",
|
||||
"suggestViewOnly": "Review export files or receipts",
|
||||
"suggestContinue": "Make it current and continue in chat",
|
||||
"stepHeadline": "Step {current}/{total} · {label}",
|
||||
"stepFraction": "Step {current}/{total}",
|
||||
"stepNeedsConfirm": "Step {step} needs confirmation",
|
||||
|
||||
@@ -183,12 +183,39 @@
|
||||
"status": {
|
||||
"all": "All",
|
||||
"created": "Created",
|
||||
"parsed": "Parsed",
|
||||
"pendingReview": "Pending review",
|
||||
"alignReview": "Confirm fields",
|
||||
"shortageReview": "Inventory shortage",
|
||||
"waitingInventory": "Waiting inventory",
|
||||
"inventoryReady": "Inventory ready",
|
||||
"matched": "Matched",
|
||||
"waitingUpload": "Waiting upload",
|
||||
"uploaded": "Uploaded",
|
||||
"uploadFailed": "Upload failed"
|
||||
"uploadFailed": "Upload failed",
|
||||
"rejected": "Rejected",
|
||||
"closed": "Closed",
|
||||
"unknown": "Processing"
|
||||
},
|
||||
"matchStatus": {
|
||||
"fulfillable": "Fulfillable",
|
||||
"partial": "Partially short",
|
||||
"unfulfillable": "Not fulfillable",
|
||||
"unknown": "Pending"
|
||||
},
|
||||
"eventTypes": {
|
||||
"system": "System event",
|
||||
"created": "Task created",
|
||||
"parsed": "Notice parsed",
|
||||
"parse_failed": "Parse failed",
|
||||
"inventory_uploaded": "Inventory uploaded",
|
||||
"inventory_parsed": "Inventory parsed",
|
||||
"matched_fulfillable": "Inventory matched",
|
||||
"match_needs_review": "Inventory match needs review",
|
||||
"excel_generated": "Shipment file generated",
|
||||
"uploaded": "Uploaded to freight",
|
||||
"upload_failed": "Freight upload failed",
|
||||
"backend_orchestrator_task_finished": "Background task completed"
|
||||
}
|
||||
},
|
||||
"profile": {
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
"shippingNoticeActionsHint": "เลือกการทำงาน:",
|
||||
"shippingNoticeMissingTaskId": "ไม่พบรหัสงาน โปรดแยกใบแจ้งส่งสินค้าก่อน",
|
||||
"shippingNoticeUploadDone": "อัปโหลดไฟล์สต็อกแล้ว: {fileName}",
|
||||
"shippingNoticeInventoryUploadStarted": "เลือกไฟล์สต็อก {fileName} แล้ว กำลังอัปโหลดและอ่านคอลัมน์สต็อก",
|
||||
"shippingNoticeUploadOk": "อัปโหลดสำเร็จ",
|
||||
"shippingNoticeUploadFailed": "อัปโหลดไฟล์สต็อกล้มเหลว",
|
||||
"shippingNoticeRefreshDone": "รีเฟรชสถานะงานปัจจุบันแล้ว",
|
||||
@@ -33,10 +34,10 @@
|
||||
"prefixWithFile": "ฉันได้อัปโหลดไฟล์สต็อก \"{fileName}\" แล้ว",
|
||||
"prefixBatch": "ฉันได้อัปโหลดสแนปช็อตสต็อกของชุดงาน {batchNo} แล้ว",
|
||||
"prefixBatchWithFile": "ฉันได้อัปโหลดสแนปช็อตสต็อก \"{fileName}\" ของชุดงาน {batchNo} แล้ว",
|
||||
"mapInferSuggested": "{prefix} กรุณาดำเนินการจับคู่คอลัมน์สต็อกต่อ หากระบบรู้จักการจับคู่ครบแล้ว ให้ใช้การจับคู่นั้นได้ทันทีและแสดงผลการจัดแนวฟิลด์ให้ฉันยืนยัน",
|
||||
"mapInferPending": "{prefix} กรุณาแยกการจับคู่คอลัมน์สต็อกต่อ และเมื่อได้การจับคู่ที่ใช้ได้แล้ว ให้แสดงผลการจัดแนวฟิลด์ให้ฉันยืนยัน",
|
||||
"alignReview": "{prefix} กรุณาแสดงผลการจัดแนวฟิลด์สต็อก และแนะนำให้ฉันยืนยันหรือแก้ไขการจับคู่",
|
||||
"default": "{prefix} กรุณาดำเนินการนำเข้าสต็อกต่อ และบอกฉันว่าขั้นตอนถัดไปคืออะไร"
|
||||
"mapInferSuggested": "{prefix} กรุณาดำเนินการจับคู่คอลัมน์สต็อกต่อ หากระบบรู้จักการจับคู่ครบแล้ว ให้ใช้การจับคู่นั้นได้ทันที และตอบเพียงประโยคสั้น ๆ ว่าพร้อมให้ยืนยันฟิลด์สต็อกแล้ว ห้ามแสดงเมนูการทำงาน ตัวเลือกแบบมีหมายเลข รายการปุ่ม หรือข้อความแนว \"เลือกวิธีต่อไปนี้\" เพราะปุ่มให้ระบบแสดงเอง",
|
||||
"mapInferPending": "{prefix} กรุณาแยกการจับคู่คอลัมน์สต็อกต่อ และเมื่อพร้อมแล้วให้ตอบเพียงประโยคสั้น ๆ ว่าพร้อมให้ยืนยันฟิลด์สต็อกแล้ว ห้ามแสดงเมนูการทำงาน ตัวเลือกแบบมีหมายเลข รายการปุ่ม หรือข้อความแนว \"เลือกวิธีต่อไปนี้\" เพราะปุ่มให้ระบบแสดงเอง",
|
||||
"alignReview": "{prefix} กรุณาตอบเพียงประโยคสั้น ๆ ว่าพร้อมให้ยืนยันฟิลด์สต็อกแล้ว และให้ฉันตรวจคอลัมน์ก่อนดำเนินการต่อ ห้ามแสดงเมนูการทำงาน ตัวเลือกแบบมีหมายเลข รายการปุ่ม หรือข้อความแนว \"เลือกวิธีต่อไปนี้\" เพราะปุ่มให้ระบบแสดงเอง",
|
||||
"default": "{prefix} กรุณาดำเนินการนำเข้าสต็อกต่อและบอกเฉพาะสถานะปัจจุบัน ห้ามแสดงเมนูการทำงาน ตัวเลือกแบบมีหมายเลข รายการปุ่ม หรือข้อความแนว \"เลือกวิธีต่อไปนี้\" เพราะปุ่มให้ระบบแสดงเอง"
|
||||
},
|
||||
"notice": {
|
||||
"fileLabelSingleFile": "\"{fileName}\"",
|
||||
@@ -123,18 +124,25 @@
|
||||
"hideWorkspace": "ซ่อนเวิร์กสเปซ",
|
||||
"batchWorkspaceTitle": "เวิร์กสเปซชุดงาน",
|
||||
"batchWorkspaceSubtitle": "สลับชุดงาน กรองงาน และวิเคราะห์ขั้นตอน",
|
||||
"taskQueueTitle": "คิวงาน",
|
||||
"taskQueueHint": "ใช้แผงนี้เพื่อดูจุดที่ติดขัดและทางกลับไปดำเนินการต่อ การยืนยันหลักยังทำในแชต",
|
||||
"batchActionsTitle": "การทำงานแบบชุด",
|
||||
"retryFailedTasks": "ลองงานที่ล้มเหลวทั้งหมดอีกครั้ง",
|
||||
"batchActionSafetyNotice": "งานที่ต้องให้คนตรวจจะไม่ถูกลองใหม่แบบชุด งานที่เสร็จแล้วจะไม่ถูกอัปโหลดซ้ำ การกู้คืนแบบชุดจะจัดการเฉพาะงานที่ล้มเหลวหรืออยู่ในคิว",
|
||||
"taskDetailCount": "รายละเอียดงาน ({count})",
|
||||
"filterAll": "ทั้งหมด",
|
||||
"filterAbnormal": "ผิดปกติ ({count})",
|
||||
"filterWaitingHuman": "รอคนยืนยัน ({count})",
|
||||
"filterResumable": "ทำต่อได้ ({count})",
|
||||
"filterCompleted": "เสร็จแล้ว ({count})",
|
||||
"emptyFilteredTasks": "ไม่มีงานที่ตรงเงื่อนไข",
|
||||
"focusRepair": "โฟกัสแก้ไข",
|
||||
"switchCurrentTask": "ตั้งเป็นงานปัจจุบัน",
|
||||
"queryShortageDetails": "ดูรายละเอียดส่วนขาด",
|
||||
"retryRpa": "ลอง RPA อีกครั้ง",
|
||||
"retrySingleTask": "ลองงานเดียวอีกครั้ง",
|
||||
"retrySingleTaskMessage": "ลองงานปัจจุบัน {taskId} อีกครั้ง",
|
||||
"continueTask": "ดำเนินการต่อ",
|
||||
"viewDetail": "ดูรายละเอียด",
|
||||
"mobileWorkspaceHint": "เปิดเวิร์กสเปซบนมือถือแล้ว โปรดเลือกงานจากรายการเพื่อดำเนินการต่อ",
|
||||
"diagnosisAdviceRetryOrFocus": "ควรโฟกัสงานนี้เพื่อตรวจบริบทก่อน หากเป็นปัญหาระบบภายนอกชั่วคราวจึงค่อยลองใหม่",
|
||||
@@ -168,6 +176,17 @@
|
||||
"needsIntervention": "ต้องแทรกแซง",
|
||||
"currentNotice": "ใบแจ้งปัจจุบัน",
|
||||
"currentStepLabel": "ปัจจุบัน",
|
||||
"blockedWaitingHuman": "รอการยืนยันจากผู้ใช้",
|
||||
"blockedShortage": "ถูกบล็อกเพราะสต็อกขาด",
|
||||
"blockedParseReview": "ต้องตรวจทานผลแยกข้อมูล",
|
||||
"blockedUploadRetryable": "อัปโหลดล้มเหลว ลองใหม่ได้",
|
||||
"suggestedAction": "คำแนะนำ:",
|
||||
"suggestShortageActions": "ดูส่วนขาด / กลับไปแก้ไข / จับคู่ใหม่",
|
||||
"suggestConfirmMapping": "ยืนยันการแมปคอลัมน์ แล้วจับคู่ต่อ",
|
||||
"suggestReviewParse": "ตรวจข้อมูลที่อ่านได้ แล้วค่อยยืนยันหรือแก้ไข",
|
||||
"suggestRetryStep": "ตรวจจุดที่ติดขัด แล้วลองขั้นตอนนี้อีกครั้ง",
|
||||
"suggestViewOnly": "ตรวจไฟล์ส่งออกหรือใบตอบรับ",
|
||||
"suggestContinue": "ตั้งเป็นงานปัจจุบันแล้วดำเนินการต่อในแชต",
|
||||
"stepHeadline": "ขั้นตอน {current}/{total} · {label}",
|
||||
"stepFraction": "ขั้นตอน {current}/{total}",
|
||||
"stepNeedsConfirm": "ขั้นตอน {step} รอยืนยัน",
|
||||
|
||||
@@ -83,5 +83,69 @@
|
||||
"reason": "เหตุผลในการขอ",
|
||||
"submit": "ส่งคำขอ"
|
||||
},
|
||||
"wecomEntryNotice": "เปิดมาจากข้อความ WeCom และเตรียมบริบทที่เกี่ยวข้องไว้ให้แล้ว"
|
||||
"wecomEntryNotice": "เปิดมาจากข้อความ WeCom และเตรียมบริบทที่เกี่ยวข้องไว้ให้แล้ว",
|
||||
"shippingNotice": {
|
||||
"title": "ใบแจ้งส่งสินค้า",
|
||||
"subtitle": "พื้นที่ทำงานแบบอ่านอย่างเดียว โปรดดำเนินการต่อใน Chat",
|
||||
"refresh": "รีเฟรช",
|
||||
"search": "ค้นหา",
|
||||
"loading": "กำลังโหลด...",
|
||||
"empty": "ยังไม่มีงานส่งสินค้า",
|
||||
"selectCase": "เลือกงานทางซ้ายเพื่อดูรายละเอียด",
|
||||
"loadFailed": "โหลดไม่สำเร็จ",
|
||||
"openChat": "ดำเนินการต่อใน Chat",
|
||||
"download": "ดาวน์โหลด Excel",
|
||||
"lines": "รายการส่งสินค้า",
|
||||
"qty": "จำนวน",
|
||||
"columns": {
|
||||
"sku": "SKU"
|
||||
},
|
||||
"events": "บันทึกเหตุการณ์",
|
||||
"filters": {
|
||||
"status": "สถานะ"
|
||||
},
|
||||
"fields": {
|
||||
"status": "สถานะกระบวนการ",
|
||||
"match": "สถานะการจับคู่",
|
||||
"shipTo": "ที่อยู่จัดส่ง",
|
||||
"freightRef": "เลขอ้างอิงขนส่ง"
|
||||
},
|
||||
"status": {
|
||||
"all": "ทั้งหมด",
|
||||
"created": "สร้างแล้ว",
|
||||
"parsed": "แยกข้อมูลแล้ว",
|
||||
"pendingReview": "รอตรวจสอบ",
|
||||
"alignReview": "รอยืนยันฟิลด์",
|
||||
"shortageReview": "สต็อกขาด",
|
||||
"waitingInventory": "รอสต็อก",
|
||||
"inventoryReady": "สต็อกพร้อม",
|
||||
"matched": "จับคู่แล้ว",
|
||||
"waitingUpload": "รออัปโหลด",
|
||||
"uploaded": "อัปโหลดแล้ว",
|
||||
"uploadFailed": "อัปโหลดล้มเหลว",
|
||||
"rejected": "ถูกปฏิเสธ",
|
||||
"closed": "ปิดแล้ว",
|
||||
"unknown": "กำลังดำเนินการ"
|
||||
},
|
||||
"matchStatus": {
|
||||
"fulfillable": "ส่งได้ครบ",
|
||||
"partial": "ขาดบางส่วน",
|
||||
"unfulfillable": "ส่งไม่ได้",
|
||||
"unknown": "รอยืนยัน"
|
||||
},
|
||||
"eventTypes": {
|
||||
"system": "เหตุการณ์ระบบ",
|
||||
"created": "สร้างงานแล้ว",
|
||||
"parsed": "แยกใบแจ้งส่งสินค้าแล้ว",
|
||||
"parse_failed": "แยกข้อมูลไม่สำเร็จ",
|
||||
"inventory_uploaded": "อัปโหลดไฟล์สต็อกแล้ว",
|
||||
"inventory_parsed": "แยกข้อมูลสต็อกแล้ว",
|
||||
"matched_fulfillable": "จับคู่สต็อกเสร็จแล้ว",
|
||||
"match_needs_review": "การจับคู่สต็อกรอตรวจสอบ",
|
||||
"excel_generated": "สร้างไฟล์ส่งสินค้าแล้ว",
|
||||
"uploaded": "อัปโหลดไปยังระบบขนส่งแล้ว",
|
||||
"upload_failed": "อัปโหลดไปยังระบบขนส่งไม่สำเร็จ",
|
||||
"backend_orchestrator_task_finished": "งานเบื้องหลังเสร็จแล้ว"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -19,6 +19,7 @@
|
||||
"shippingNoticeActionsHint": "请选择操作:",
|
||||
"shippingNoticeMissingTaskId": "未找到任务编号,请先完成发货通知解析。",
|
||||
"shippingNoticeUploadDone": "库存文件已上传:{fileName}。",
|
||||
"shippingNoticeInventoryUploadStarted": "我已选择库存文件《{fileName}》,正在上传并读取库存列名。",
|
||||
"shippingNoticeUploadOk": "上传成功。",
|
||||
"shippingNoticeUploadFailed": "库存文件上传失败。",
|
||||
"shippingNoticeRefreshDone": "已刷新当前任务状态。",
|
||||
@@ -33,10 +34,10 @@
|
||||
"prefixWithFile": "我已上传库存文件《{fileName}》",
|
||||
"prefixBatch": "我已为批次 {batchNo} 上传本批库存快照",
|
||||
"prefixBatchWithFile": "我已为批次 {batchNo} 上传本批库存快照《{fileName}》",
|
||||
"mapInferSuggested": "{prefix}。请继续处理库存列映射;如果系统已识别出完整映射,请直接应用映射,并展示字段对齐结果给我确认。",
|
||||
"mapInferPending": "{prefix}。请继续解析库存列映射,并在拿到可用映射后展示字段对齐结果给我确认。",
|
||||
"alignReview": "{prefix}。请展示库存字段对齐结果,并引导我确认或更正映射。",
|
||||
"default": "{prefix}。请继续处理库存导入,并告诉我下一步。"
|
||||
"mapInferSuggested": "{prefix}。请继续处理库存列映射;如果系统已识别出完整映射,请直接应用映射,并只用一句话说明已进入库存字段确认。禁止在正文列出操作菜单、编号选项、按钮清单或“请选择以下方式”;可点击动作由系统按钮展示。",
|
||||
"mapInferPending": "{prefix}。请继续解析库存列映射,并在拿到可用映射后只用一句话说明已进入库存字段确认。禁止在正文列出操作菜单、编号选项、按钮清单或“请选择以下方式”;可点击动作由系统按钮展示。",
|
||||
"alignReview": "{prefix}。请只用一句话说明已进入库存字段确认,并提示我检查列名后继续。禁止在正文列出操作菜单、编号选项、按钮清单或“请选择以下方式”;可点击动作由系统按钮展示。",
|
||||
"default": "{prefix}。请继续处理库存导入,并只说明当前状态。禁止在正文列出操作菜单、编号选项、按钮清单或“请选择以下方式”;可点击动作由系统按钮展示。"
|
||||
},
|
||||
"notice": {
|
||||
"fileLabelSingleFile": "《{fileName}》",
|
||||
@@ -123,18 +124,25 @@
|
||||
"hideWorkspace": "隐藏工作台",
|
||||
"batchWorkspaceTitle": "批次工作台",
|
||||
"batchWorkspaceSubtitle": "多批次切换、筛选与步骤诊断",
|
||||
"taskQueueTitle": "任务队列",
|
||||
"taskQueueHint": "这里用于查看卡点和恢复入口,具体确认仍在聊天区完成。",
|
||||
"batchActionsTitle": "批量操作",
|
||||
"retryFailedTasks": "重试所有失败",
|
||||
"batchActionSafetyNotice": "待人工任务不会被批量重试;已完成任务不会重复上传。批量恢复仅处理失败或排队任务。",
|
||||
"taskDetailCount": "任务明细 ({count})",
|
||||
"filterAll": "全部",
|
||||
"filterAbnormal": "异常 ({count})",
|
||||
"filterWaitingHuman": "等待人工 ({count})",
|
||||
"filterResumable": "可继续 ({count})",
|
||||
"filterCompleted": "完成 ({count})",
|
||||
"emptyFilteredTasks": "暂无相关任务",
|
||||
"focusRepair": "聚焦修正",
|
||||
"switchCurrentTask": "切为当前任务",
|
||||
"queryShortageDetails": "查询缺口明细",
|
||||
"retryRpa": "重试 RPA",
|
||||
"retrySingleTask": "单独重试",
|
||||
"retrySingleTaskMessage": "重试当前任务 {taskId}",
|
||||
"continueTask": "继续处理",
|
||||
"viewDetail": "查看明细",
|
||||
"mobileWorkspaceHint": "移动端工作台已打开,请在任务列表中选择要处理的单票。",
|
||||
"diagnosisAdviceRetryOrFocus": "建议先聚焦此单查看上下文;若属于外部系统临时失败,可单独重试。",
|
||||
@@ -168,6 +176,17 @@
|
||||
"needsIntervention": "需介入",
|
||||
"currentNotice": "当前通知",
|
||||
"currentStepLabel": "当前",
|
||||
"blockedWaitingHuman": "等待人工确认",
|
||||
"blockedShortage": "库存缺口阻断",
|
||||
"blockedParseReview": "解析失败待处理",
|
||||
"blockedUploadRetryable": "上传失败可重试",
|
||||
"suggestedAction": "建议动作:",
|
||||
"suggestShortageActions": "查看缺口 / 返回修订 / 重新匹配",
|
||||
"suggestConfirmMapping": "确认字段对齐后继续匹配",
|
||||
"suggestReviewParse": "核对解析结果并确认或修订",
|
||||
"suggestRetryStep": "查看卡点后重试当前步骤",
|
||||
"suggestViewOnly": "查看导出文件或回执",
|
||||
"suggestContinue": "切换为当前任务并在聊天区继续",
|
||||
"stepHeadline": "步骤 {current}/{total} · {label}",
|
||||
"stepFraction": "步骤 {current}/{total}",
|
||||
"stepNeedsConfirm": "步骤 {step} 待确认",
|
||||
|
||||
@@ -166,10 +166,6 @@
|
||||
"loadFailed": "加载失败",
|
||||
"openChat": "在 Chat 中继续",
|
||||
"download": "下载 Excel",
|
||||
"retryCurrentTask": "重试当前票",
|
||||
"retryCurrentDone": "已重新提交当前票",
|
||||
"retryFailed": "重试失败",
|
||||
"retrying": "重试中...",
|
||||
"lines": "发货明细",
|
||||
"qty": "数量",
|
||||
"columns": {
|
||||
@@ -188,12 +184,39 @@
|
||||
"status": {
|
||||
"all": "全部",
|
||||
"created": "已创建",
|
||||
"parsed": "已解析",
|
||||
"pendingReview": "待复核",
|
||||
"alignReview": "待确认字段",
|
||||
"shortageReview": "库存缺口",
|
||||
"waitingInventory": "等待库存",
|
||||
"inventoryReady": "库存就绪",
|
||||
"matched": "已匹配",
|
||||
"waitingUpload": "等待上传",
|
||||
"uploaded": "已上传",
|
||||
"uploadFailed": "上传失败"
|
||||
"uploadFailed": "上传失败",
|
||||
"rejected": "已驳回",
|
||||
"closed": "已关闭",
|
||||
"unknown": "处理中"
|
||||
},
|
||||
"matchStatus": {
|
||||
"fulfillable": "满足发货",
|
||||
"partial": "部分缺货",
|
||||
"unfulfillable": "无法发货",
|
||||
"unknown": "待确认"
|
||||
},
|
||||
"eventTypes": {
|
||||
"system": "系统事件",
|
||||
"created": "任务已创建",
|
||||
"parsed": "发货通知解析完成",
|
||||
"parse_failed": "解析失败",
|
||||
"inventory_uploaded": "库存文件已上传",
|
||||
"inventory_parsed": "库存解析完成",
|
||||
"matched_fulfillable": "库存匹配完成",
|
||||
"match_needs_review": "库存匹配待复核",
|
||||
"excel_generated": "发货文件已生成",
|
||||
"uploaded": "已上传货代",
|
||||
"upload_failed": "上传货代失败",
|
||||
"backend_orchestrator_task_finished": "后台任务已完成"
|
||||
}
|
||||
},
|
||||
"profile": {
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
"shippingNoticeActionsHint": "請選擇操作:",
|
||||
"shippingNoticeMissingTaskId": "找不到任務編號,請先完成發貨通知解析。",
|
||||
"shippingNoticeUploadDone": "庫存檔案已上傳:{fileName}。",
|
||||
"shippingNoticeInventoryUploadStarted": "我已選擇庫存檔案《{fileName}》,正在上傳並讀取庫存欄位。",
|
||||
"shippingNoticeUploadOk": "上傳成功。",
|
||||
"shippingNoticeUploadFailed": "庫存檔案上傳失敗。",
|
||||
"shippingNoticeRefreshDone": "已重新整理目前任務狀態。",
|
||||
@@ -33,10 +34,10 @@
|
||||
"prefixWithFile": "我已上傳庫存檔案《{fileName}》",
|
||||
"prefixBatch": "我已為批次 {batchNo} 上傳本批庫存快照",
|
||||
"prefixBatchWithFile": "我已為批次 {batchNo} 上傳本批庫存快照《{fileName}》",
|
||||
"mapInferSuggested": "{prefix}。請繼續處理庫存欄位映射;如果系統已辨識出完整映射,請直接套用映射,並展示欄位對齊結果給我確認。",
|
||||
"mapInferPending": "{prefix}。請繼續解析庫存欄位映射,並在取得可用映射後展示欄位對齊結果給我確認。",
|
||||
"alignReview": "{prefix}。請展示庫存欄位對齊結果,並引導我確認或更正映射。",
|
||||
"default": "{prefix}。請繼續處理庫存匯入,並告訴我下一步。"
|
||||
"mapInferSuggested": "{prefix}。請繼續處理庫存欄位映射;如果系統已辨識出完整映射,請直接套用映射,並只用一句話說明已進入庫存欄位確認。禁止在正文列出操作選單、編號選項、按鈕清單或「請選擇以下方式」;可點擊動作由系統按鈕展示。",
|
||||
"mapInferPending": "{prefix}。請繼續解析庫存欄位映射,並在取得可用映射後只用一句話說明已進入庫存欄位確認。禁止在正文列出操作選單、編號選項、按鈕清單或「請選擇以下方式」;可點擊動作由系統按鈕展示。",
|
||||
"alignReview": "{prefix}。請只用一句話說明已進入庫存欄位確認,並提示我檢查欄位後繼續。禁止在正文列出操作選單、編號選項、按鈕清單或「請選擇以下方式」;可點擊動作由系統按鈕展示。",
|
||||
"default": "{prefix}。請繼續處理庫存匯入,並只說明目前狀態。禁止在正文列出操作選單、編號選項、按鈕清單或「請選擇以下方式」;可點擊動作由系統按鈕展示。"
|
||||
},
|
||||
"notice": {
|
||||
"fileLabelSingleFile": "《{fileName}》",
|
||||
@@ -123,18 +124,25 @@
|
||||
"hideWorkspace": "隱藏工作台",
|
||||
"batchWorkspaceTitle": "批次工作台",
|
||||
"batchWorkspaceSubtitle": "多批次切換、篩選與步驟診斷",
|
||||
"taskQueueTitle": "任務佇列",
|
||||
"taskQueueHint": "這裡用於查看卡點與恢復入口,具體確認仍在聊天區完成。",
|
||||
"batchActionsTitle": "批量操作",
|
||||
"retryFailedTasks": "重試所有失敗",
|
||||
"batchActionSafetyNotice": "待人工任務不會被批量重試;已完成任務不會重複上傳。批量恢復僅處理失敗或排隊任務。",
|
||||
"taskDetailCount": "任務明細 ({count})",
|
||||
"filterAll": "全部",
|
||||
"filterAbnormal": "異常 ({count})",
|
||||
"filterWaitingHuman": "等待人工 ({count})",
|
||||
"filterResumable": "可繼續 ({count})",
|
||||
"filterCompleted": "完成 ({count})",
|
||||
"emptyFilteredTasks": "暫無相關任務",
|
||||
"focusRepair": "聚焦修正",
|
||||
"switchCurrentTask": "切為目前任務",
|
||||
"queryShortageDetails": "查詢缺口明細",
|
||||
"retryRpa": "重試 RPA",
|
||||
"retrySingleTask": "單獨重試",
|
||||
"retrySingleTaskMessage": "重試目前任務 {taskId}",
|
||||
"continueTask": "繼續處理",
|
||||
"viewDetail": "查看明細",
|
||||
"mobileWorkspaceHint": "行動端工作台已開啟,請在任務列表中選擇要處理的單票。",
|
||||
"diagnosisAdviceRetryOrFocus": "建議先聚焦此單查看上下文;若屬於外部系統暫時失敗,可單獨重試。",
|
||||
@@ -168,6 +176,17 @@
|
||||
"needsIntervention": "需介入",
|
||||
"currentNotice": "當前通知",
|
||||
"currentStepLabel": "目前",
|
||||
"blockedWaitingHuman": "等待人工確認",
|
||||
"blockedShortage": "庫存缺口阻斷",
|
||||
"blockedParseReview": "解析失敗待處理",
|
||||
"blockedUploadRetryable": "上傳失敗可重試",
|
||||
"suggestedAction": "建議動作:",
|
||||
"suggestShortageActions": "查看缺口 / 返回修訂 / 重新匹配",
|
||||
"suggestConfirmMapping": "確認欄位對齊後繼續匹配",
|
||||
"suggestReviewParse": "核對解析結果並確認或修訂",
|
||||
"suggestRetryStep": "查看卡點後重試目前步驟",
|
||||
"suggestViewOnly": "查看匯出檔或回執",
|
||||
"suggestContinue": "切換為目前任務並在聊天區繼續",
|
||||
"stepHeadline": "步驟 {current}/{total} · {label}",
|
||||
"stepFraction": "步驟 {current}/{total}",
|
||||
"stepNeedsConfirm": "步驟 {step} 待確認",
|
||||
|
||||
@@ -154,6 +154,70 @@
|
||||
"downloadExcelFailed": "下載 Excel 失敗"
|
||||
}
|
||||
},
|
||||
"shippingNotice": {
|
||||
"title": "貨代發貨通知",
|
||||
"subtitle": "只讀工作台,請在 Chat 中繼續處理。",
|
||||
"refresh": "刷新",
|
||||
"search": "查詢",
|
||||
"loading": "正在載入...",
|
||||
"empty": "暫無發貨任務",
|
||||
"selectCase": "選擇左側任務查看詳情",
|
||||
"loadFailed": "載入失敗",
|
||||
"openChat": "在 Chat 中繼續",
|
||||
"download": "下載 Excel",
|
||||
"lines": "發貨明細",
|
||||
"qty": "數量",
|
||||
"columns": {
|
||||
"sku": "SKU"
|
||||
},
|
||||
"events": "事件記錄",
|
||||
"filters": {
|
||||
"status": "狀態"
|
||||
},
|
||||
"fields": {
|
||||
"status": "流程狀態",
|
||||
"match": "匹配狀態",
|
||||
"shipTo": "收貨地址",
|
||||
"freightRef": "貨代單號"
|
||||
},
|
||||
"status": {
|
||||
"all": "全部",
|
||||
"created": "已建立",
|
||||
"parsed": "已解析",
|
||||
"pendingReview": "待覆核",
|
||||
"alignReview": "待確認欄位",
|
||||
"shortageReview": "庫存缺口",
|
||||
"waitingInventory": "等待庫存",
|
||||
"inventoryReady": "庫存就緒",
|
||||
"matched": "已匹配",
|
||||
"waitingUpload": "等待上傳",
|
||||
"uploaded": "已上傳",
|
||||
"uploadFailed": "上傳失敗",
|
||||
"rejected": "已駁回",
|
||||
"closed": "已關閉",
|
||||
"unknown": "處理中"
|
||||
},
|
||||
"matchStatus": {
|
||||
"fulfillable": "滿足發貨",
|
||||
"partial": "部分缺貨",
|
||||
"unfulfillable": "無法發貨",
|
||||
"unknown": "待確認"
|
||||
},
|
||||
"eventTypes": {
|
||||
"system": "系統事件",
|
||||
"created": "任務已建立",
|
||||
"parsed": "發貨通知解析完成",
|
||||
"parse_failed": "解析失敗",
|
||||
"inventory_uploaded": "庫存文件已上傳",
|
||||
"inventory_parsed": "庫存解析完成",
|
||||
"matched_fulfillable": "庫存匹配完成",
|
||||
"match_needs_review": "庫存匹配待覆核",
|
||||
"excel_generated": "發貨文件已生成",
|
||||
"uploaded": "已上傳貨代",
|
||||
"upload_failed": "上傳貨代失敗",
|
||||
"backend_orchestrator_task_finished": "後台任務已完成"
|
||||
}
|
||||
},
|
||||
"profile": {
|
||||
"msg": {
|
||||
"loadFailed": "載入個人中心失敗",
|
||||
|
||||
+1067
-66
File diff suppressed because it is too large.
Load diff
Reference in new issue
Block a user