fix(production): 去掉我的生产任务列表工单详情 N+1 并避免批量任务截断
承接 #176 后生产侧残留:mine 列表不再对本页工单逐条打详情;list-by-work-orders / pageBy 拉取当页任务时避免 500 上限静默截断。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
90b62d96d7
commit
6aad64b7fb
4 files changed
+30
-18
No files matched your search
@@ -2340,24 +2340,32 @@ async def list_production_tasks_by_work_orders(
|
||||
return success_response(
|
||||
{"list": [], "total": 0, "page": 1, "pageSize": body.page_size, "totalPages": 0}
|
||||
)
|
||||
# 当前页工单卡片需要这些工单下的全部任务;避免单页 pageSize 上限静默截断
|
||||
effective_page_size = min(max(body.page_size, len(wo_ids) * 100), 500)
|
||||
items, total = production_task_svc.list_production_tasks(
|
||||
db,
|
||||
tenant_no=tenant_no,
|
||||
page=1,
|
||||
page_size=effective_page_size,
|
||||
work_order_ids=wo_ids,
|
||||
user_info=user,
|
||||
include_step_summary=body.include_step_summary,
|
||||
)
|
||||
tp = production_task_svc.total_pages(total, effective_page_size)
|
||||
all_items = []
|
||||
total = 0
|
||||
page = 1
|
||||
while page <= 20:
|
||||
items, total = production_task_svc.list_production_tasks(
|
||||
db,
|
||||
tenant_no=tenant_no,
|
||||
page=page,
|
||||
page_size=effective_page_size,
|
||||
work_order_ids=wo_ids,
|
||||
user_info=user,
|
||||
include_step_summary=body.include_step_summary,
|
||||
)
|
||||
all_items.extend(items or [])
|
||||
if not items or len(all_items) >= int(total or 0):
|
||||
break
|
||||
page += 1
|
||||
return success_response(
|
||||
{
|
||||
"list": items,
|
||||
"list": all_items,
|
||||
"total": total,
|
||||
"page": 1,
|
||||
"pageSize": effective_page_size,
|
||||
"totalPages": tp,
|
||||
"pageSize": len(all_items),
|
||||
"totalPages": 1 if all_items else 0,
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
Reference in new issue
Block a user