修复: MissingGreenlet_product访问try/catch + spawn_subtask不再覆盖overall_status
This commit is contained in:
@ -15,11 +15,19 @@ from app.schemas.task import TaskSummaryResponse, TaskResponse, TaskRecordRespon
|
||||
|
||||
def _task_to_response(task: Task) -> TaskResponse:
|
||||
"""将 Task ORM 对象递归转为 TaskResponse(含子任务树)"""
|
||||
product_sn = ""
|
||||
product_material = ""
|
||||
try:
|
||||
if task.product:
|
||||
product_sn = task.product.serial_number or ""
|
||||
product_material = (task.product.material_name or task.product.material_id or "")
|
||||
except Exception:
|
||||
pass
|
||||
return TaskResponse(
|
||||
id=task.id,
|
||||
product_id=task.product_id,
|
||||
product_sn=task.product.serial_number if task.product else "",
|
||||
product_material=task.product.material_name or task.product.material_id or "" if task.product else "",
|
||||
product_sn=product_sn,
|
||||
product_material=product_material,
|
||||
parent_task_id=task.parent_task_id,
|
||||
task_name=task.task_name,
|
||||
assignee_id=task.assignee_id,
|
||||
|
||||
Reference in New Issue
Block a user