工艺节点树: 新增结束分支(终止)接口 + 前端🏁结束分支按钮 + WIP可无下游完结
This commit is contained in:
@ -223,6 +223,36 @@ async def get_all_tasks(
|
||||
return TaskListResponse(tasks=all_tasks, total=len(all_tasks))
|
||||
|
||||
|
||||
# ============================================================
|
||||
# 核心业务 0:结束分支(终止当前节点)
|
||||
# ============================================================
|
||||
|
||||
async def end_task(
|
||||
db: AsyncSession, task_id: uuid.UUID, operator_id: str | None = None
|
||||
) -> TaskResponse:
|
||||
"""
|
||||
结束当前分支:标记任务为 COMPLETED,不创建下游任务。
|
||||
用于工序已完结、无需转交下一人的场景。
|
||||
"""
|
||||
task = await _get_task_or_404(db, task_id)
|
||||
|
||||
if task.status == TASK_STATUS_COMPLETED:
|
||||
raise HTTPException(status_code=409, detail="此分支已经结束")
|
||||
if task.status == TASK_STATUS_PENDING:
|
||||
raise HTTPException(status_code=409, detail="请先接收任务再结束分支")
|
||||
|
||||
now = get_beijing_time()
|
||||
task.status = TASK_STATUS_COMPLETED
|
||||
task.completed_at = now
|
||||
|
||||
await _create_task_log(db, task_id, action_type="end",
|
||||
operator_id=operator_id, remark=f"分支「{task.task_name}」已终止(无下游)")
|
||||
|
||||
await db.commit()
|
||||
await db.refresh(task)
|
||||
return _to_response(task)
|
||||
|
||||
|
||||
# ============================================================
|
||||
# 核心业务 1:确认接收 (PENDING → WIP)
|
||||
# ============================================================
|
||||
|
||||
Reference in New Issue
Block a user