"""质检工单自动完成判定(无 DB 依赖,供 CRUD 与单测共用)。""" def can_auto_complete_work_order( *, status: str, active_task_count: int, pending_task_count: int ) -> bool: """仅当工单为已配置、存在活跃任务且全部已完成时,才可标为已完成。 活跃任务数为 0 时不得完成:调整检测清空后重配若尚未产生任务, 否则会把「已配置」误标为「已完成」。 """ if (status or "").strip() != "ypz": return False if active_task_count <= 0: return False if pending_task_count > 0: return False return True