style: format code in discrete material cleaner

Co-Authored-By: Claude (glm-5) <noreply@anthropic.com>
This commit is contained in:
Misaka
2026-02-25 22:38:36 +08:00
parent 7819570ef3
commit c5f48eb7c8

View File

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