85 lines
2.7 KiB
Python
85 lines
2.7 KiB
Python
"""
|
||
services/shipping_notice/chat_actions.py
|
||
|
||
用途:发货通知状态机旧模块名的向后兼容 re-export 入口。
|
||
依赖:state_machine(ACTION_SPECS、CHECKPOINT_REGISTRY、apply_task_transition 等)。
|
||
逻辑:历史代码 import chat_actions;新代码应直接引用 state_machine.py,不再暴露已删除的 /chat-actions 读模型。
|
||
"""
|
||
|
||
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,
|
||
)
|
||
|
||
# Legacy alias
|
||
CHECKPOINT_OPTIONS = CHECKPOINT_REGISTRY
|
||
|
||
|
||
def build_chat_actions_payload(task):
|
||
"""
|
||
Build the legacy chat-actions API payload for one shipping task.
|
||
|
||
AI trigger: use this when the workspace chat panel needs the current checkpoint
|
||
and clickable action buttons for an existing ShippingTask. The payload keeps the
|
||
historical `task_id` field as `task.task_no` so older frontend code can consume it.
|
||
"""
|
||
ui_state = resolve_task_ui_state(task)
|
||
action_buttons = (
|
||
inventory_source_action_buttons(task)
|
||
if ui_state.checkpoint == CP_INVENTORY_SOURCE_REVIEW
|
||
else ui_state.action_buttons
|
||
)
|
||
return {
|
||
"task_id": task.task_no,
|
||
"task_no": task.task_no,
|
||
"checkpoint": ui_state.checkpoint,
|
||
"human_options": ui_state.human_options or [],
|
||
"action_buttons": action_buttons,
|
||
"process_status": task.process_status,
|
||
"review_status": task.review_status,
|
||
"pending_human_reason": task.pending_human_reason,
|
||
"match_status": task.match_status,
|
||
"updated_at": task.updated_at.isoformat() if task.updated_at else None,
|
||
}
|
||
|
||
__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",
|
||
]
|