diff --git a/utils/discrete_material_plan_cleaner.py b/utils/discrete_material_plan_cleaner.py index 1699aac..664bc21 100644 --- a/utils/discrete_material_plan_cleaner.py +++ b/utils/discrete_material_plan_cleaner.py @@ -164,11 +164,12 @@ class DiscreteMaterialPlanCleaner: material_code = self._get_input_value(child_form, r"^材料编码") material_name = self._get_input_value(child_form, r"^材料名称") pending_qty = self._get_input_value(child_form, r"^累计待发数量$") - - + if material_code in self.to_delete_set: self._log(f"发现匹配物料: {material_name} ({material_code})") - if (not pending_qty) and not (row_num_int>=7000 and row_num_int<8000) : + if (not pending_qty) and not ( + row_num_int >= 7000 and row_num_int < 8000 + ): # 记录删除前的行号 old_row_number = current_row delete_row_btn.click() @@ -179,27 +180,38 @@ class DiscreteMaterialPlanCleaner: start_time = time.time() while time.time() - start_time < max_wait_time: try: - new_row_number = self._get_input_value(child_form, r"^行号$") + new_row_number = self._get_input_value( + child_form, r"^行号$" + ) if new_row_number != old_row_number: - self._log(f"✓ 删除完成,行号已从 {old_row_number} 变更为 {new_row_number}") + self._log( + f"✓ 删除完成,行号已从 {old_row_number} 变更为 {new_row_number}" + ) break time.sleep(0.2) # 每200ms检查一次 except Exception as e: self._log(f"获取新行号时出错: {e}", "warn") time.sleep(0.2) else: - self._log(f"⚠️ 等待删除完成超时({max_wait_time}秒)", "warn") - + self._log( + f"⚠️ 等待删除完成超时({max_wait_time}秒)", "warn" + ) continue - elif row_num_int>=7000 and row_num_int<8000: - self._log(f"⚠️ 行号 {row_num_int} 在 7000-8000 范围内,跳过删除", "warn") + elif row_num_int >= 7000 and row_num_int < 8000: + self._log( + f"⚠️ 行号 {row_num_int} 在 7000-8000 范围内,跳过删除", + "warn", + ) elif pending_qty: self._log(f"⚠️ 待发数量为 {pending_qty},跳过删除", "warn") else: - self._log(f"⚠️ 不满足删除条件,跳过物料 {material_name} ({material_code})", "warn") - + self._log( + f"⚠️ 不满足删除条件,跳过物料 {material_name} ({material_code})", + "warn", + ) + else: self._log( f"ℹ️ 物料 {material_name} ({material_code}) 不在删除列表中,不做处理" @@ -214,7 +226,9 @@ class DiscreteMaterialPlanCleaner: # 执行最终保存逻辑(如业务需要) save_button_locator.click() self._log("已点击保存,等待保存完成...") - save_button_locator.wait_for(state="hidden", timeout=60000) # 等待按钮消失,超时60秒 + save_button_locator.wait_for( + state="hidden", timeout=60000 + ) # 等待按钮消失,超时60秒 self._log("✅ 保存成功(保存按钮已消失)") else: self._log("订单无备料计划数据,无需处理")