From 0fc061728c8c2324706a3e0aff7ff2423cc1cf80 Mon Sep 17 00:00:00 2001 From: duxingchen Date: Mon, 31 Aug 2026 17:24:38 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E9=80=8F=E8=A7=86=E8=A1=A8):=20=E5=9C=A8?= =?UTF-8?q?=E5=BA=93=E6=8C=89=E8=AE=BE=E5=A4=87=E5=AE=9E=E9=99=85=E4=BD=8D?= =?UTF-8?q?=E7=BD=AE=E5=88=A4=E6=96=AD=EF=BC=8C=E4=BF=AE=E5=A4=8D=E6=95=B0?= =?UTF-8?q?=E9=87=8F=E4=B8=8D=E5=8C=B9=E9=85=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 之前按最新主任务 task_name='在库' 判断,漏掉实际在库但无在库任务的历史设备 - 改为 current_location_id='virtual_warehouse' → 在库(生产完成) - 其他设备按最新主任务工序归属(活跃/完成态都归该工序) - 在库数量与实际在库设备一致 --- backend/app/services/dashboard_service.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) 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 "")