diff --git a/backend/app/services/task_service.py b/backend/app/services/task_service.py index 34947da..5a23a1d 100644 --- a/backend/app/services/task_service.py +++ b/backend/app/services/task_service.py @@ -902,13 +902,18 @@ async def complete_task( # --- 4. 可选:创建下一步任务(转交) --- next_task = None if request.next_task_name and request.next_assignee_id: + # 🚀 智能父节点继承算法 + # 主线任务转交 → 保持平级继承(主分支永远在一维主干上) + # 协助分支转交 → 认当前任务为父(形成向外无限延伸的孙子节点树枝) + new_parent_id = task.parent_task_id if task.task_type == "MAIN" else task.id + next_task = Task( product_id=task.product_id, - parent_task_id=task.parent_task_id, # 与已完成任务同级 + parent_task_id=new_parent_id, # 👈 智能计算 task_name=request.next_task_name, assignee_id=request.next_assignee_id, status=TASK_STATUS_PENDING, - task_type=task.task_type, # 🚀 继承父任务基因:主线→主线,协助→协助 + task_type=task.task_type, # 👈 基因严格继承(绝不篡位成 MAIN) notify_parent_on_complete=False, ) db.add(next_task)