fix: 三致命Bug—macro_status预计算+排除已完工脏读+flush落盘+递归深度限制10

This commit is contained in:
2026-08-09 18:23:55 +08:00
parent d8623df7de
commit 45b5376537
6 changed files with 49 additions and 5 deletions

View File

@ -74,6 +74,7 @@ async def _recalc_product_location(db: AsyncSession, product_id: uuid.UUID, comp
sa_select(Task).where(
Task.product_id == product_id,
Task.status == TASK_STATUS_WIP,
Task.id != completed_task_id, # 🔧 排除刚刚完工的任务(避免脏读)
).order_by(Task.created_at.desc())
)
wip_tasks = task_result.scalars().all()
@ -94,6 +95,7 @@ async def _recalc_product_location(db: AsyncSession, product_id: uuid.UUID, comp
if product.current_location_id != new_location:
product.current_location_id = new_location
await db.flush() # 🔧 确保位置更新落盘到当前事务
def _check_permission(task_assignee_id: str | None, operator_id: str | None, operator_role: str | None = None) -> None: