55 lines
1.7 KiB
Python
55 lines
1.7 KiB
Python
"""
|
||
services/shipping_notice/chat_actions.py
|
||
|
||
用途:发货通知聊天只读状态适配。
|
||
依赖:state_machine(位置/用户模式与内部状态迁移)、ui_state。
|
||
逻辑:Chat 不再拥有动作目录或写入口;仅输出 Gate 已裁决的只读 UI State。
|
||
"""
|
||
|
||
from app.services.shipping_notice.state_machine import (
|
||
TaskTransition,
|
||
apply_task_transition,
|
||
position_for_task,
|
||
resolve_task_ui_state,
|
||
validate_registry,
|
||
)
|
||
from app.services.shipping_notice.ui_state import build_task_ui_state
|
||
|
||
|
||
def build_chat_actions_payload(task) -> dict:
|
||
"""
|
||
构建聊天气泡侧动作按钮兼容 payload。
|
||
|
||
核心逻辑:复用统一 UI State 读模型,抽取聊天侧 position/user_mode/summary/process_gate;
|
||
业务动作只从 ui_state.actions 返回,Chat 不再暴露旧 action_buttons。
|
||
|
||
Args:
|
||
task: ShippingNotice 模型实例。
|
||
|
||
Returns:
|
||
包含 task_no、position、user_mode、process_gate、actions 与摘要的字典。
|
||
"""
|
||
state = build_task_ui_state(task)
|
||
return {
|
||
"task_no": state.get("task_no"),
|
||
"position": state.get("position"),
|
||
"user_mode": state.get("user_mode"),
|
||
"stage": state.get("stage"),
|
||
"todo": state.get("todo"),
|
||
"actions": state.get("actions"),
|
||
"reason": state.get("reason"),
|
||
"lifecycle_status": state.get("lifecycle_status"),
|
||
"summary": state.get("summary"),
|
||
"process_gate": state.get("process_gate"),
|
||
"updated_at": state.get("updated_at"),
|
||
}
|
||
|
||
__all__ = [
|
||
"TaskTransition",
|
||
"apply_task_transition",
|
||
"build_chat_actions_payload",
|
||
"position_for_task",
|
||
"resolve_task_ui_state",
|
||
"validate_registry",
|
||
]
|