feat(backend): 流转树 created_by 加入中文名映射
- get_product_by_serial 把任务创建人(created_by)纳入 assignee_names 中文名映射 - 前端可显示『谁转入在库』等创建人信息
This commit is contained in:
@ -96,7 +96,6 @@ async def get_product_by_serial(db: AsyncSession, serial_number: str) -> Product
|
|||||||
all_task_ids.append(t.id)
|
all_task_ids.append(t.id)
|
||||||
if t.assignee_id: assignee_ids.add(t.assignee_id)
|
if t.assignee_id: assignee_ids.add(t.assignee_id)
|
||||||
_collect_ids(task_tree)
|
_collect_ids(task_tree)
|
||||||
assignee_names = _lookup_display_names(list(assignee_ids))
|
|
||||||
|
|
||||||
# 🔧 批量查 task_logs: 谁创建了每个任务
|
# 🔧 批量查 task_logs: 谁创建了每个任务
|
||||||
creator_map: dict[uuid.UUID, str] = {}
|
creator_map: dict[uuid.UUID, str] = {}
|
||||||
@ -125,15 +124,20 @@ async def get_product_by_serial(db: AsyncSession, serial_number: str) -> Product
|
|||||||
if row[1]:
|
if row[1]:
|
||||||
creator_map[row[0]] = row[1]
|
creator_map[row[0]] = row[1]
|
||||||
|
|
||||||
# 注入 created_by 到 task_tree 和 top_tasks
|
# 注入 created_by 到 task_tree 和 top_tasks(并收集 created_by 到中文名映射)
|
||||||
def _inject_creator(tasks):
|
def _inject_creator(tasks):
|
||||||
for t in tasks:
|
for t in tasks:
|
||||||
t.created_by = creator_map.get(t.id)
|
t.created_by = creator_map.get(t.id)
|
||||||
|
if t.created_by: assignee_ids.add(t.created_by)
|
||||||
if t.child_tasks:
|
if t.child_tasks:
|
||||||
_inject_creator(t.child_tasks)
|
_inject_creator(t.child_tasks)
|
||||||
_inject_creator(task_tree)
|
_inject_creator(task_tree)
|
||||||
for t in top_tasks:
|
for t in top_tasks:
|
||||||
t.created_by = creator_map.get(t.id)
|
t.created_by = creator_map.get(t.id)
|
||||||
|
if t.created_by: assignee_ids.add(t.created_by)
|
||||||
|
|
||||||
|
# 🔧 中文名映射(负责人 + 创建人,供前端显示"谁转入在库"等)
|
||||||
|
assignee_names = _lookup_display_names(list(assignee_ids))
|
||||||
|
|
||||||
return ProductScanResponse(
|
return ProductScanResponse(
|
||||||
id=product.id,
|
id=product.id,
|
||||||
|
|||||||
Reference in New Issue
Block a user