并发模型: spawn派发协助分支 + 转交简化为单线 + 子分支未完成拦截(409)
This commit is contained in:
@ -2,6 +2,7 @@
|
||||
from __future__ import annotations
|
||||
import uuid
|
||||
from fastapi import APIRouter, Depends, Query, Body
|
||||
from pydantic import BaseModel, Field
|
||||
from sqlalchemy.ext.asyncio import AsyncSession
|
||||
|
||||
from app.core.database import get_db
|
||||
@ -120,6 +121,30 @@ async def end_task_endpoint(
|
||||
return await task_service.end_task(db, uuid.UUID(task_id), operator_id)
|
||||
|
||||
|
||||
# ============================================================
|
||||
# 核心业务 0.5:并发派发协助分支 (WIP → 不改变状态,创建子任务)
|
||||
# ============================================================
|
||||
|
||||
class SpawnRequest(BaseModel):
|
||||
task_name: str = Field(..., max_length=200, description="工序名称")
|
||||
assignee_id: str | None = Field(None, max_length=64, description="负责人ID")
|
||||
remark: str | None = Field(None, max_length=2000, description="派发备注")
|
||||
|
||||
|
||||
@router.post("/{task_id}/spawn", response_model=TaskResponse, status_code=201)
|
||||
async def spawn_subtask_endpoint(
|
||||
task_id: str,
|
||||
data: SpawnRequest,
|
||||
operator_id: str | None = Query(None),
|
||||
db: AsyncSession = Depends(get_db),
|
||||
):
|
||||
"""
|
||||
**派发协助分支:在当前任务下创建并行子任务,父任务状态保持不变。**
|
||||
用于 WIP 期间工人需要其他人协助协同的场景。
|
||||
"""
|
||||
return await task_service.spawn_subtask(db, uuid.UUID(task_id), data, operator_id)
|
||||
|
||||
|
||||
# ============================================================
|
||||
# 核心业务 1:确认接收 (PENDING → WIP)
|
||||
# ============================================================
|
||||
|
||||
Reference in New Issue
Block a user