feat(dashboard): 看板增强——流转完成率下钻明细 + 人员看板(按人聚合在制品设备)

This commit is contained in:
2026-08-13 12:00:12 +08:00
parent b6ef0751e0
commit c2e6ed240b
7 changed files with 452 additions and 8 deletions

View File

@ -6,6 +6,8 @@ from app.core.database import get_db
from app.services.dashboard_service import (
get_dashboard_stats, DashboardStats,
get_wip_tasks, WipTask,
get_completed_tasks, CompletedTask,
get_people_workload, PersonWorkload,
search_product_messages, ProductMessageList,
)
@ -38,6 +40,27 @@ async def wip_tasks(
return await get_wip_tasks(db, limit)
@router.get("/completed-tasks", response_model=list[CompletedTask])
async def completed_tasks(
since: str | None = Query(None, description="起始日期 ISO 如 2026-08-01T00:00:00"),
until: str | None = Query(None, description="截止日期 ISO"),
limit: int = Query(200, ge=1, le=500),
db: AsyncSession = Depends(get_db),
):
"""流转完成率下钻 — 按时段查询已完成任务明细"""
since_dt = datetime.fromisoformat(since) if since else None
until_dt = datetime.fromisoformat(until) if until else None
return await get_completed_tasks(db, since=since_dt, until=until_dt, limit=limit)
@router.get("/people-workload", response_model=list[PersonWorkload])
async def people_workload(
db: AsyncSession = Depends(get_db),
):
"""人员负载 — 按负责人聚合当前在制品设备数(独立人员看板)"""
return await get_people_workload(db)
@router.get("/messages", response_model=ProductMessageList)
async def dashboard_messages(
keyword: str = Query("", description="搜索: SN码/物料名/留言人/内容"),