diff --git a/backend/app/services/dashboard_service.py b/backend/app/services/dashboard_service.py index de6586c..835f12b 100644 --- a/backend/app/services/dashboard_service.py +++ b/backend/app/services/dashboard_service.py @@ -638,6 +638,7 @@ async def get_wip_matrix( Task.task_name, Task.assignee_id, Task.created_at, + Product.current_location_id, ) .join(Task, Task.product_id == Product.id) .where( @@ -653,7 +654,7 @@ async def get_wip_matrix( # 每台设备 → (spec, 当前工序/负责人, 当前负责人ID) device_cur: dict[str, tuple] = {} seen: set[str] = set() - for pid, spec, task_name, assignee, created in rows: + for pid, spec, task_name, assignee, created, loc in rows: if pid in seen: continue seen.add(pid) @@ -667,8 +668,12 @@ async def get_wip_matrix( continue if dimension == "task_name": - # 设备当前工序 = 最新主任务的工序名(不区分状态,不强制完成态归在库) - key = task_name or "—" + # 🔧 在库按设备实际位置判断:virtual_warehouse → 在库(生产完成) + # 否则按最新主任务工序名(活跃/完成态都归该工序) + if loc == "virtual_warehouse": + key = "在库" + else: + key = task_name or "—" else: key = assignee or "未分配" device_cur[pid] = (spec or "未知型号", key, assignee or "")