feat(api): 核心端点 — 接收/驳回/转交/打印/上传/用户/物料/记录CRUD
新增端点:
- POST /tasks/{id}/receive — 确认接收 (PENDING→WIP)
- POST /tasks/{id}/reject — 品质驳回 + 自动返工
- POST /tasks/{id}/transfer — 完工裂变转交 (多路分支+入库)
- PATCH /tasks/{id}/records — 追加图文记录
- PATCH /products/scan/{sn}/status — 宏观状态定调
- POST /upload/ + GET /upload/files/{name} — 文件上传
- GET /users/ — MOM用户列表
- GET /materials/groups + /materials/items — BOM物料手风琴
- POST /print/preview + /execute — 标签预览/打印
- PUT/DELETE /records/{id} — 记录编辑/删除
- GET /tasks/ 新增 assignee_id 过滤
This commit is contained in:
@ -12,6 +12,7 @@ from app.schemas.task import (
|
||||
TaskRejectRequest,
|
||||
TaskTransferRequest,
|
||||
SubtaskCreate,
|
||||
TaskRecordCreate,
|
||||
TaskResponse,
|
||||
TaskCompleteResponse,
|
||||
TaskTransferResponse,
|
||||
@ -30,13 +31,14 @@ router = APIRouter(prefix="/tasks", tags=["任务管理"])
|
||||
@router.get("/", response_model=TaskListResponse)
|
||||
async def list_tasks(
|
||||
product_id: str | None = Query(None, description="按产品ID筛选"),
|
||||
assignee_id: str | None = Query(None, description="按负责人ID筛选(逻辑外键→老系统)"),
|
||||
skip: int = Query(0, ge=0),
|
||||
limit: int = Query(50, ge=1, le=200),
|
||||
db: AsyncSession = Depends(get_db),
|
||||
):
|
||||
"""获取任务列表,可按产品筛选(只返回顶层任务)"""
|
||||
"""获取任务列表,可按产品/负责人筛选(只返回顶层任务)"""
|
||||
pid = uuid.UUID(product_id) if product_id else None
|
||||
return await task_service.get_all_tasks(db, product_id=pid, skip=skip, limit=limit)
|
||||
return await task_service.get_all_tasks(db, product_id=pid, assignee_id=assignee_id, skip=skip, limit=limit)
|
||||
|
||||
|
||||
@router.get("/{task_id}", response_model=TaskResponse)
|
||||
@ -208,3 +210,17 @@ async def get_tasks_by_product(
|
||||
):
|
||||
"""获取指定产品的顶层任务列表(不含子任务嵌套)"""
|
||||
return await task_service.get_top_level_tasks(db, uuid.UUID(product_id))
|
||||
|
||||
|
||||
# ============================================================
|
||||
# 任务进度记录 — 备注/传图
|
||||
# ============================================================
|
||||
|
||||
@router.patch("/{task_id}/records", response_model=TaskResponse)
|
||||
async def add_task_record_endpoint(
|
||||
task_id: str,
|
||||
data: TaskRecordCreate,
|
||||
db: AsyncSession = Depends(get_db),
|
||||
):
|
||||
"""追加进度记录(备注+图片),不改变任务状态"""
|
||||
return await task_service.add_task_record(db, uuid.UUID(task_id), data)
|
||||
|
||||
Reference in New Issue
Block a user