From 0dcdb5dad7f83826c300f40c4d49390fd1ecf7d3 Mon Sep 17 00:00:00 2001 From: duxingchen Date: Fri, 28 Aug 2026 16:51:46 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E9=80=8F=E8=A7=86=E8=A1=A8):=20WIP=20?= =?UTF-8?q?=E5=88=86=E5=B8=83=E7=9F=A9=E9=98=B5=E5=8F=AA=E7=BB=9F=E8=AE=A1?= =?UTF-8?q?=E4=B8=BB=E5=88=86=E6=94=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - get_wip_matrix 过滤 parent_task_id IS NULL 或 TRANSFER/RECOVERY 的主线任务 - 排除 SPAWN 协助分支与返工任务,避免同一设备/工序重复计数 --- backend/app/services/dashboard_service.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/backend/app/services/dashboard_service.py b/backend/app/services/dashboard_service.py index 9e16cb6..d6fbf9b 100644 --- a/backend/app/services/dashboard_service.py +++ b/backend/app/services/dashboard_service.py @@ -613,6 +613,7 @@ async def get_wip_matrix( """生产分布透视表:Y=规格型号,X=人员 或 工序,单元格=设备数量。 覆盖全部任务状态(含已完成/在库),工序分布能看到「在库」(生产完成)。 + 只统计主分支(parent_task_id IS NULL 或 TRANSFER/RECOVERY),避免协助分支/返工重复计数。 since/until 按任务接手/创建时间过滤。 dimension: @@ -632,6 +633,13 @@ async def get_wip_matrix( func.array_agg(func.distinct(Task.assignee_id)), ) .join(Task, Task.product_id == Product.id) + # 🔧 只统计主分支(主线任务),排除 SPAWN 协助分支 + .where( + or_( + Task.parent_task_id.is_(None), + Task.task_type.in_(["TRANSFER", "RECOVERY"]), + ) + ) .group_by(Product.spec_model, dim_expr) .order_by(Product.spec_model, dim_expr) )