fix(流转树): 在库任务无创建日志时兜底显示转入人
- 有 create 日志的在库任务用真实转入人(张欣欣/孔贺等) - 无日志的历史在库任务,用该产品在库前最近一道主工序的负责人兜底 - 解决『流转树到负责人就结束、不显示谁入库』的问题
This commit is contained in:
@ -136,6 +136,24 @@ async def get_product_by_serial(db: AsyncSession, serial_number: str) -> Product
|
||||
t.created_by = creator_map.get(t.id)
|
||||
if t.created_by: assignee_ids.add(t.created_by)
|
||||
|
||||
# 🔧 兜底:在库/入库任务无创建日志时,用该产品在库前最近一道主工序的负责人作为「转入人」
|
||||
all_mains: list = []
|
||||
def _collect_main(tasks):
|
||||
for t in tasks:
|
||||
if not t.parent_task_id or t.task_type in ("TRANSFER", "RECOVERY"):
|
||||
all_mains.append(t)
|
||||
if t.child_tasks:
|
||||
_collect_main(t.child_tasks)
|
||||
_collect_main(task_tree)
|
||||
all_mains.sort(key=lambda t: t.created_at)
|
||||
for t in all_mains:
|
||||
is_w = t.task_name and ("在库" in t.task_name or "入库" in t.task_name)
|
||||
if is_w and not t.created_by:
|
||||
prev = [m for m in all_mains if m.created_at < t.created_at and m.assignee_id]
|
||||
if prev:
|
||||
t.created_by = prev[-1].assignee_id
|
||||
assignee_ids.add(t.created_by)
|
||||
|
||||
# 🔧 中文名映射(负责人 + 创建人,供前端显示"谁转入在库"等)
|
||||
assignee_names = _lookup_display_names(list(assignee_ids))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user