diff --git a/utils/离散备料计划维护数据清理.py b/utils/离散备料计划维护数据清理.py index 8b52047..460940a 100644 --- a/utils/离散备料计划维护数据清理.py +++ b/utils/离散备料计划维护数据清理.py @@ -124,14 +124,25 @@ class DiscreteMaterialPlanCleaner: detail_count = int(match.group(1)) self._print(f"详细信息数量: {detail_count}") - - if detail_count > 0: + # 提取"备料状态"信息 + detail_element = inner_frame.get_by_text(re.compile(r"^备料状态:.+$")) + detail_text = detail_element.inner_text().replace("\n", "") + # 使用正则表达式提取括号中的数字 + match = re.search(r"^备料状态:(.+)$", detail_text) + if match: + detail_status = match.group(1) + self._print(f"备料状态: {detail_status}") + + + + #page2.pause() + if detail_count > 0 and detail_status == "审批通过": inner_frame.get_by_role("button", name="修改").click() save_button_locator = inner_frame.get_by_role("button", name="保存") save_button_locator.wait_for(state="visible", timeout=10000) inner_frame.get_by_text("展开").first.click() - page2.pause() + #page2.pause() for id in range(detail_count): id_lable_locator= inner_frame.get_by_text("序号 " + str(id + 1)).wait_for(state="visible", timeout=10000) @@ -146,8 +157,6 @@ class DiscreteMaterialPlanCleaner: match_result = int(match.group(1)) self._print(f"材料编码:{match_result}") - - input_box = inner_frame.locator("div").filter(has_text=re.compile(r"^材料名称$")).nth(2).locator("input[type='text']") self._print(f"材料名称:{input_box.input_value()}") @@ -157,19 +166,14 @@ class DiscreteMaterialPlanCleaner: inner_frame.get_by_role("button").filter(has_text=re.compile(r"^$")).nth(4).click() #page2.pause() - - - pass - - - - - - - else: + elif detail_count == 0: self._print(f"第 {order_index + 1} 个订单无数据需要清理,跳过...") page2.close() return + elif detail_status != "审批通过": + self._print(f"第 {order_index + 1} 个订单备料状态: {detail_status}") + page2.close() + return