Files
syops/backend/app/services/shipping_notice/chat_actions.py
T
hugo 7a9c36d16b Merge branch 'dev' into hugo-shipping-notice
# Conflicts:
#	backend/app/api/chat.py
#	backend/app/services/shipping_notice/chat_actions.py
2026-07-03 17:18:10 +08:00

87 lines
2.7 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"""
services/shipping_notice/chat_actions.py
用途:发货通知状态机旧模块名的向后兼容 re-export 入口。
依赖:state_machine(ACTION_SPECS、CHECKPOINT_REGISTRY、apply_task_transition 等)、ui_state。
逻辑:历史代码 import chat_actions;新代码应直接引用 state_machine.py / ui_state.py,本模块仅保留兼容导出。
"""
from app.services.shipping_notice.state_machine import (
ACTION_SPECS,
ALL_ACTION_IDS,
ALL_CHECKPOINT_IDS,
CHECKPOINT_REGISTRY,
CP_INVENTORY_SOURCE_REVIEW,
TaskTransition,
TaskUiState,
action_buttons_for_checkpoint,
apply_task_transition,
build_action_buttons,
build_checkpoint_catalog,
checkpoint_for_task,
human_options_for_checkpoint,
human_options_for_task,
human_options_for_task_or_checkpoint,
inventory_source_action_buttons,
resolve_task_ui_state,
ui_state_for_checkpoint,
upload_req_options_for_task,
validate_registry,
)
from app.services.shipping_notice.ui_state import build_task_ui_state
# Legacy alias
CHECKPOINT_OPTIONS = CHECKPOINT_REGISTRY
def build_chat_actions_payload(task) -> dict:
"""
构建聊天气泡侧动作按钮兼容 payload。
核心逻辑:复用统一 UI State 读模型,只抽取聊天侧需要的 checkpoint/action_buttons/summary,
避免 workspace 路由继续依赖已删除的旧读模型实现。
Args:
task: ShippingTask 模型实例。
Returns:
包含 task_no、checkpoint、action_buttons 与摘要的字典。
"""
state = build_task_ui_state(task)
return {
"task_no": state.get("task_no"),
"batch_no": state.get("batch_no"),
"checkpoint": state.get("checkpoint"),
"process_status": state.get("process_status"),
"review_status": state.get("review_status"),
"pending_human_reason": state.get("pending_human_reason"),
"match_status": state.get("match_status"),
"current_step": state.get("current_step"),
"summary": state.get("summary"),
"action_buttons": state.get("action_buttons") or [],
"updated_at": state.get("updated_at"),
}
__all__ = [
"ACTION_SPECS",
"ALL_ACTION_IDS",
"ALL_CHECKPOINT_IDS",
"CHECKPOINT_OPTIONS",
"CHECKPOINT_REGISTRY",
"TaskTransition",
"TaskUiState",
"action_buttons_for_checkpoint",
"apply_task_transition",
"build_action_buttons",
"build_chat_actions_payload",
"build_checkpoint_catalog",
"checkpoint_for_task",
"human_options_for_checkpoint",
"human_options_for_task",
"human_options_for_task_or_checkpoint",
"resolve_task_ui_state",
"ui_state_for_checkpoint",
"upload_req_options_for_task",
"validate_registry",
]