fix(透视表): 在库按设备实际位置判断,修复数量不匹配
- 之前按最新主任务 task_name='在库' 判断,漏掉实际在库但无在库任务的历史设备 - 改为 current_location_id='virtual_warehouse' → 在库(生产完成) - 其他设备按最新主任务工序归属(活跃/完成态都归该工序) - 在库数量与实际在库设备一致
This commit is contained in:
@ -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,7 +668,11 @@ async def get_wip_matrix(
|
||||
continue
|
||||
|
||||
if dimension == "task_name":
|
||||
# 设备当前工序 = 最新主任务的工序名(不区分状态,不强制完成态归在库)
|
||||
# 🔧 在库按设备实际位置判断:virtual_warehouse → 在库(生产完成)
|
||||
# 否则按最新主任务工序名(活跃/完成态都归该工序)
|
||||
if loc == "virtual_warehouse":
|
||||
key = "在库"
|
||||
else:
|
||||
key = task_name or "—"
|
||||
else:
|
||||
key = assignee or "未分配"
|
||||
|
||||
Reference in New Issue
Block a user