Compare commits

..

2 Commits

13 changed files with 347 additions and 229 deletions

View File

@@ -15,6 +15,7 @@ from page_objects.section_mileage_config_page import SectionMileageConfigPage
from page_objects.upload_config_page import UploadConfigPage
from page_objects.more_download_page import MoreDownloadPage
from page_objects.screenshot_page import ScreenshotPage
from check_station import CheckStation
import globals.driver_utils as driver_utils # 导入驱动工具模块
import globals.global_variable as global_variable
from page_objects.login_page import LoginPage
@@ -138,6 +139,7 @@ class DeviceAutomation:
logging.warning(f"设备 {self.device_id} 检查会话状态时出错: {str(inner_e)}")
return False
# # 使用全局函数初始化驱动
self.results_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'test_results')
# self.driver, self.wait = driver_utils.init_appium_driver(self.device_id)
# 初始化页面对象
logging.info(f"设备 {self.device_id} 开始初始化页面对象")
@@ -148,6 +150,7 @@ class DeviceAutomation:
self.upload_config_page = UploadConfigPage(self.driver, self.wait, self.device_id)
self.more_download_page = MoreDownloadPage(self.driver, self.wait,self.device_id)
self.screenshot_page = ScreenshotPage(self.driver, self.wait, self.device_id)
self.check_station = CheckStation(self.driver, self.wait, self.device_id)
logging.info(f"设备 {self.device_id} 所有页面对象初始化完成")
# 检查应用是否成功启动
@@ -182,7 +185,7 @@ class DeviceAutomation:
login_success = False
for attempt in range(max_retries_login + 1):
if self.login_page.login("wangshun"):
if self.login_page.login("czsczq115ykl"):
login_success = True
break
else:
@@ -199,35 +202,6 @@ class DeviceAutomation:
return False
else:
retry_count += 1
# login_btn_exists = self.login_page.is_login_page()
# if not login_btn_exists:
# logging.error(f"设备 {self.device_id} 未知应用状态,无法确定当前页面,跳转到登录页面")
# if self.login_page.navigate_to_login_page(self.driver, self.device_id):
# logging.info(f"设备 {self.device_id} 成功跳转到登录页面")
# return self.run_automation() # 递归调用处理登录后的状态
# else:
# logging.error(f"设备 {self.device_id} 跳转到登录页面失败")
# return False
# # 处理登录页面状态
# logging.info(f"设备 {self.device_id} 检测到登录页面,执行登录操作")
# max_retries = 1
# login_success = False
# for attempt in range(max_retries + 1):
# if self.login_page.login():
# login_success = True
# break
# else:
# if attempt < max_retries:
# logging.warning(f"设备 {self.device_id} 登录失败,准备重试 ({attempt + 1}/{max_retries})")
# time.sleep(2) # 等待2秒后重试
# else:
# logging.error(f"设备 {self.device_id} 登录失败,已达到最大重试次数")
# if not login_success:
# return False
logging.info(f"设备 {self.device_id} 登录成功,继续执行更新操作")
time.sleep(1)
@@ -247,13 +221,13 @@ class DeviceAutomation:
# task_data = apis.get_measurement_task()
# logging.info(f"设备 {self.device_id} 获取到的测量任务: {task_data}")
task_data = {
"id": 39,
"id": 21,
"user_name": "czsczq115ykl",
"name": "czsczq115ykl",
"line_num": "L179451",
"line_name": "CDWZQ-2标-资阳沱江特大桥-23-35-山区",
"line_num": "L220076",
"line_name": "CZSCZQ-11-五工区-列衣隧道进口-D3K638+507-D3K638+607-山区",
"remaining": "0",
"status": 1
"status": 0
}
if not task_data:
logging.info(f"设备 {self.device_id} 未获取到状态为1的测量任务等待后重试")
@@ -262,8 +236,10 @@ class DeviceAutomation:
# continue
# 设置全局变量
global_variable.GLOBAL_USERNAME = task_data.get('user_name', '')
global_variable.GLOBAL_CURRENT_PROJECT_NAME = task_data.get('line_name', '')
global_variable.GLOBAL_LINE_NUM = task_data.get('line_num', '')
global_variable.GLOBAL_ACCOUNT_ID = task_data.get('id', 0)
logging.info(f"设备 {self.device_id} 当前要处理的项目名称:{global_variable.GLOBAL_CURRENT_PROJECT_NAME}")
# 执行测量操作
@@ -289,18 +265,33 @@ class DeviceAutomation:
logging.info(f"设备 {self.device_id}{task_count}个任务完成")
task_count += 1
# +++++++++++++white+++++++++++++++++
# # +++++++++++++white+++++++++++++++++
logging.info(f"设备 {self.device_id} 已完成{task_count}个任务,结束打数据流程")
if task_count == 0:
logging.error(f"没有完成打数据的线路,结束任务")
# logging.info(f"设备 {self.device_id} 已完成{task_count}个任务,结束打数据流程")
# if task_count == 0:
# logging.error(f"没有完成打数据的线路,结束任务")
# return False
# 执行打数据加转点
if not self.check_station.run():
logging.error(f"设备 {self.device_id} 打数据加转点执行失败")
return False
# GLOBAL_TESTED_BREAKPOINT_LIST 把已打完的写入日志文件
# with open(os.path.join(self.results_dir, "打数据完成线路.txt"), "w", encoding='utf-8') as f:
# for bp in global_variable.GLOBAL_TESTED_BREAKPOINT_LIST:
# f.write(f"{bp}\n")
# 执行上传配置管理,传入当前断点名称
breakpoint_name = global_variable.GLOBAL_CURRENT_PROJECT_NAME
line_num = global_variable.GLOBAL_LINE_NUM
if self.upload_config_page.upload_config_page_manager(self.results_dir, breakpoint_name, line_num):
logging.info(f"设备 {self.device_id} 断点 '{breakpoint_name}' 上传成功")
upload_success_count += 1
else:
logging.error(f"设备 {self.device_id} 断点 '{breakpoint_name}' 上传失败")
for i in range(3):
if self.upload_config_page.upload_config_page_manager(self.results_dir, breakpoint_name, line_num):
logging.info(f"设备 {self.device_id} 断点 '{breakpoint_name}' 重试上传成功")
upload_success_count += 1
break
else:
logging.error(f"设备 {self.device_id} 断点 '{breakpoint_name}' 上传失败,第 {i+1} 次重试")
return task_count > 0

View File

@@ -11,6 +11,8 @@ import globals.driver_utils as driver_utils # 导入驱动工具模块
from selenium.common.exceptions import TimeoutException, NoSuchElementException, StaleElementReferenceException
from appium.webdriver.common.appiumby import AppiumBy
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.ui import WebDriverWait
import globals.ids as ids
@@ -200,7 +202,7 @@ class CheckStation:
logging.info("检查站点成功")
return True
def run(self, station_num: int):
def run(self):
# last_station_num = 0
url = f"https://database.yuxindazhineng.com/team-bucket/69378c5b4f42d83d9504560d/前测点表/20260309/CDWZQ-2标-龙家沟左线大桥-0-11号墩-平原.xlsx"
@@ -258,32 +260,35 @@ class CheckStation:
print(f"已处理{over_station_num}个站点")
# 滑动列表到底部
if not self.scroll_list_to_bottom(device_id):
logging.error(f"设备 {device_id} 下滑列表到底部失败")
if not self.scroll_list_to_bottom(self.device_id):
logging.error(f"设备 {self.device_id} 下滑列表到底部失败")
return False
# 2. 点击最后一个spinner
if not self.click_last_spinner_with_retry(device_id):
logging.error(f"设备 {device_id} 点击最后一个spinner失败")
if not self.click_last_spinner_with_retry(self.device_id):
logging.error(f"设备 {self.device_id} 点击最后一个spinner失败")
return False
# 3. 再下滑一次
if not self.scroll_down_once(device_id):
logging.warning(f"设备 {device_id} 再次下滑失败,但继续执行")
if not self.scroll_down_once(self.device_id):
logging.warning(f"设备 {self.device_id} 再次下滑失败,但继续执行")
# # 截图
# self.driver.save_screenshot("check_station.png")
if not self.take_screenshot():
logging.error(f"设备 {device_id} 截图失败")
logging.error(f"设备 {self.device_id} 截图失败")
# 打完数据,截图完毕,点击平差处理按钮
if not self.click_adjustment_button(device_id):
logging.error(f"设备 {device_id} 点击平差处理按钮失败")
if not self.click_adjustment_button(self.device_id):
logging.error(f"设备 {self.device_id} 点击平差处理按钮失败")
return False
item = global_variable.GLOBAL_CURRENT_PROJECT_NAME
if item.endswith('-平原'):
item = item[:-3] # 去掉最后3个字符"-平原"
# 检查是否在测量页面在就重新执行选择断点滑动列表到底部点击最后一个spinner 再下滑一次,点击平差处理按钮平差
if not self.handle_back_navigation(item, device_id):
if not self.handle_back_navigation(item, self.device_id):
logging.error(f"{item}平差失败")
@@ -293,11 +298,14 @@ class CheckStation:
# 检查在不在测量列表页面,不在就点击返回按钮并处理弹窗
if self.check_measurement_list(device_id):
logging.error(f"设备 {device_id} 未在测量列表页面")
if self.check_measurement_list(self.device_id):
logging.error(f"设备 {self.device_id} 未在测量列表页面")
# 点击返回按钮并处理弹窗
if not self.execute_back_navigation_steps(device_id):
logging.error(f"设备 {device_id} 处理返回按钮确认失败")
if not self.execute_back_navigation_steps(self.device_id):
logging.error(f"设备 {self.device_id} 处理返回按钮确认失败")
# # 点击返回按钮并处理弹窗
# if not self.execute_back_navigation_steps(self.device_id):
# logging.error(f"设备 {self.device_id} 处理返回按钮确认失败")
return True
@@ -467,15 +475,15 @@ class CheckStation:
"""查找指定关键词并点击,支持向下和向上滑动查找"""
try:
# if not check_session_valid(self.driver, self.device_id):
# self.logger.warning(f"设备 {self.device_id} 会话无效,尝试重新连接驱动...")
# logging.warning(f"设备 {self.device_id} 会话无效,尝试重新连接驱动...")
# if not reconnect_driver(self.device_id, self.driver):
# self.logger.error(f"设备 {self.device_id} 驱动重连失败")
# logging.error(f"设备 {self.device_id} 驱动重连失败")
# 等待线路列表容器出现
self.wait.until(
EC.presence_of_element_located((AppiumBy.ID, ids.MEASURE_LIST_ID))
)
self.logger.info("线路列表容器已找到")
logging.info("线路列表容器已找到")
max_scroll_attempts = 100 # 最大滚动尝试次数
scroll_count = 0
@@ -485,21 +493,21 @@ class CheckStation:
while scroll_count < max_scroll_attempts:
# 获取当前页面中的所有项目
current_items = self.get_current_items()
# self.logger.info(f"当前页面找到 {len(current_items)} 个项目: {current_items}")
logging.info(f"当前页面找到 {len(current_items)} 个项目: {current_items}")
# 检查目标文件是否在当前页面中
if fixed_filename in current_items:
self.logger.info(f"找到目标文件: {fixed_filename}")
logging.info(f"找到目标文件: {fixed_filename}")
# 点击目标文件
if self.click_item_by_text(fixed_filename):
return True
else:
self.logger.error(f"点击目标文件失败: {fixed_filename}")
logging.error(f"点击目标文件失败: {fixed_filename}")
return False
# 检查是否到达底部:连续两次获取的项目相同
if current_items == previous_items and len(current_items) > 0:
self.logger.info("连续两次获取的项目相同,已到达列表底部")
logging.info("连续两次获取的项目相同,已到达列表底部")
break
# 更新前一次项目集合
@@ -507,14 +515,14 @@ class CheckStation:
# 向下滑动列表以加载更多项目
if not self.scroll_list(direction="down"):
self.logger.error("向下滑动列表失败")
logging.error("向下滑动列表失败")
return False
scroll_count += 1
self.logger.info(f"{scroll_count} 次向下滑动,继续查找...")
logging.info(f"{scroll_count} 次向下滑动,继续查找...")
# 如果向下滑动未找到,尝试向上滑动查找
self.logger.info("向下滑动未找到目标,开始向上滑动查找")
logging.info("向下滑动未找到目标,开始向上滑动查找")
# 重置滚动计数
scroll_count = 0
@@ -524,38 +532,38 @@ class CheckStation:
# 如果返回False说明已经滑动到顶
if not self.scroll_list(direction="up"):
# 检查是否是因为滑动到顶而返回False
if "已滑动到列表顶部" in self.logger.handlers[0].buffer[-1].message:
self.logger.info("已滑动到列表顶部,停止向上滑动")
if "已滑动到列表顶部" in logging.handlers[0].buffer[-1].message:
logging.info("已滑动到列表顶部,停止向上滑动")
break
else:
self.logger.error("向上滑动列表失败")
logging.error("向上滑动列表失败")
return False
# 获取当前页面中的所有项目
current_items = self.get_current_items()
# self.logger.info(f"向上滑动后找到 {len(current_items)} 个项目: {current_items}")
# logging.info(f"向上滑动后找到 {len(current_items)} 个项目: {current_items}")
# 检查目标文件是否在当前页面中
if fixed_filename in current_items:
self.logger.info(f"找到目标文件: {fixed_filename}")
logging.info(f"找到目标文件: {fixed_filename}")
# 点击目标文件
if self.click_item_by_text(fixed_filename):
return True
else:
self.logger.error(f"点击目标文件失败: {fixed_filename}")
logging.error(f"点击目标文件失败: {fixed_filename}")
return False
scroll_count += 1
self.logger.info(f"{scroll_count} 次向上滑动,继续查找...")
logging.info(f"{scroll_count} 次向上滑动,继续查找...")
self.logger.warning(f"经过 {max_scroll_attempts * 2} 次滑动仍未找到目标文件")
logging.warning(f"经过 {max_scroll_attempts * 2} 次滑动仍未找到目标文件")
return False
except TimeoutException:
self.logger.error("等待线路列表元素超时")
logging.error("等待线路列表元素超时")
return False
except Exception as e:
self.logger.error(f"查找关键词时出错: {str(e)}")
logging.error(f"查找关键词时出错: {str(e)}")
return False
def get_current_items(self):
@@ -574,7 +582,7 @@ class CheckStation:
return item_texts
except Exception as e:
self.logger.error(f"获取当前项目失败: {str(e)}")
logging.error(f"获取当前项目失败: {str(e)}")
return []
def click_item_by_text(self, text):
@@ -588,35 +596,35 @@ class CheckStation:
title_element = item.find_element(AppiumBy.ID, ids.MEASURE_NAME_TEXT_ID)
if title_element and title_element.text == text:
title_element.click()
self.logger.info(f"已点击项目: {text}")
logging.info(f"已点击项目: {text}")
return True
except NoSuchElementException:
continue
self.logger.warning(f"未找到可点击的项目: {text}")
logging.warning(f"未找到可点击的项目: {text}")
return False
except Exception as e:
self.logger.error(f"点击项目失败: {str(e)}")
logging.error(f"点击项目失败: {str(e)}")
return False
def handle_measurement_dialog(self):
"""处理测量弹窗 - 选择继续测量"""
try:
self.logger.info("检查测量弹窗...")
logging.info("检查测量弹窗...")
# 直接尝试点击"继续测量"按钮
continue_btn = WebDriverWait(self.driver, 2).until(
EC.element_to_be_clickable((AppiumBy.ID, "com.bjjw.cjgc:id/measure_continue_btn"))
)
continue_btn.click()
self.logger.info("已点击'继续测量'按钮")
logging.info("已点击'继续测量'按钮")
return True
except TimeoutException:
self.logger.info("未找到继续测量按钮,可能没有弹窗")
logging.info("未找到继续测量按钮,可能没有弹窗")
return True # 没有弹窗也认为是成功的
except Exception as e:
self.logger.error(f"点击继续测量按钮时出错: {str(e)}")
logging.error(f"点击继续测量按钮时出错: {str(e)}")
return False
# 检查有没有平差处理按钮
@@ -629,13 +637,13 @@ class CheckStation:
if apply_btn.is_displayed():
logging.info("进入平差页面")
else:
self.logger.info("没有找到'平差处理'按钮")
logging.info("没有找到'平差处理'按钮")
return True
except TimeoutException:
self.logger.info("未找到平差处理按钮")
logging.info("未找到平差处理按钮")
return False # 没有弹窗也认为是成功的
except Exception as e:
self.logger.error(f"点击平差处理按钮时出错: {str(e)}")
logging.error(f"点击平差处理按钮时出错: {str(e)}")
return False
@@ -676,6 +684,68 @@ class CheckStation:
logging.error(f"设备 {device_id} 执行返回导航步骤时发生错误: {str(e)}")
return False
def click_back_button(self, device_id):
"""点击手机系统返回按钮"""
try:
self.driver.back()
logging.info("已点击手机系统返回按钮")
return True
except Exception as e:
logging.error(f"点击手机系统返回按钮失败: {str(e)}")
return False
def handle_confirmation_dialog(self, device_id, timeout=2):
"""
处理确认弹窗,点击""按钮
Args:
device_id: 设备ID
timeout: 等待弹窗的超时时间
Returns:
bool: 是否成功处理弹窗
"""
# 等待弹窗出现最多等待2秒
try:
max_attempts = 2
for attempt in range(max_attempts):
try:
dialog_message = WebDriverWait(self.driver, timeout).until(
EC.presence_of_element_located((AppiumBy.XPATH, "//android.widget.TextView[@text='是否退出测量界面?']"))
)
logging.info(f"设备 {device_id} 检测到确认弹窗 (第 {attempt + 1} 次)")
# 查找并点击"是"按钮
confirm_button = self.driver.find_element(
AppiumBy.XPATH,
"//android.widget.Button[@text='' and @resource-id='android:id/button1']"
)
if confirm_button.is_displayed() and confirm_button.is_enabled():
logging.info(f"设备 {device_id} 点击确认弹窗的''按钮 (第 {attempt + 1} 次)")
confirm_button.click()
time.sleep(0.5)
# 如果是第一次尝试,继续检查是否还有弹窗
if attempt < max_attempts - 1:
logging.info(f"设备 {device_id} 等待 1 秒后检查是否还有弹窗")
time.sleep(0.5)
continue
return True
else:
logging.error(f"设备 {device_id} ''按钮不可点击")
return False
except TimeoutException:
# 超时未找到弹窗,认为没有弹窗,返回成功
logging.info(f"设备 {device_id} 等待 {timeout} 秒未发现确认弹窗,可能没有弹窗,返回成功")
return True
except Exception as e:
logging.error(f"设备 {device_id} 处理确认弹窗时出错: {str(e)}")
return False
def scroll_list_to_bottom(self, device_id, max_swipes=60):
"""
@@ -806,7 +876,7 @@ class CheckStation:
# 使用self.device_id确保有默认值
actual_device_id = self.device_id if self.device_id else global_variable.get_device_id()
if not check_session_valid(self.driver, actual_device_id):
if not driver_utils.check_session_valid(self.driver, actual_device_id):
logging.warning(f"设备 {actual_device_id} 会话无效,尝试重新连接驱动...")
try:
# 使用正确的设备ID进行重连
@@ -860,7 +930,7 @@ class CheckStation:
logging.error(f"设备 {device_id} 等待下拉菜单超时 (第{retry_count+1}次尝试): {error_msg}")
# 检查是否是连接断开相关的错误
if not check_session_valid(self.driver, self.device_id):
if not driver_utils.check_session_valid(self.driver, self.device_id):
logging.warning(f"设备 {self.device_id} 会话无效,尝试重新连接驱动...")
# if any(keyword in error_msg for keyword in ['socket hang up', 'Could not proxy command']):
# logging.warning(f"设备 {device_id} 检测到连接相关错误,尝试重连...")

View File

@@ -87,12 +87,13 @@ def get_breakpoint_list():
return data
else:
logging.info(f"接口返回错误: {result.get('code')}")
return [{"id": 37,
"user_name": "wangshun",
"name": "wangshun",
"line_num": "L193588",
"line_name": "CDWZQ-2标-155号路基左线-461221-461570-155左-平原",
"status": 3
return [{
"id": 21,
"user_name": "czsczq115ykl",
"name": "czsczq115ykl",
"line_num": "L220076",
"line_name": "CZSCZQ-11-五工区-列衣隧道进口-D3K638+507-D3K638+607-山区",
"status": 3
}]
else:
logging.info(f"请求失败,状态码: {response.status_code}")
@@ -433,7 +434,7 @@ def get_user_max_variation(username: str) -> Optional[int]:
try:
# 2. 发送POST请求
logging.info(f"向接口 {api_url} 发送请求,查询用户名:{username}")
logging.info(f"向接口 {api_url} 发送请求,查询用户名:{username}账号ID{account_id}")
response = requests.post(
url=api_url,
json=payload, # 自动将字典转为JSON字符串无需手动json.dumps()

View File

@@ -1657,7 +1657,7 @@ class ScreenshotPage:
return True
def screenshot_page_manager(self, device_id, results_dir):
def screenshot_page_manager(self, device_id):
"""执行截图页面管理操作"""
max_retries = 3
retry_count = 0
@@ -1675,164 +1675,220 @@ class ScreenshotPage:
self.logger.error("重新初始化driver失败")
return False
# 加载指定文件中的线路编码和时间到全局字典
if not self.load_line_time_mapping_dict("20251022.1.CZSCZQ-3fhg0410.txt", "D:\\soft\\安卓时间修改-v0.7.13-1\\Logs\\202510"):
self.logger.error(f"设备 {device_id} 加载线路时间映射字典失败")
return False
# # 加载指定文件中的线路编码和时间到全局字典
# if not self.load_line_time_mapping_dict("20251022.1.CZSCZQ-3fhg0410.txt", "D:\\soft\\安卓时间修改-v0.7.13-1\\Logs\\202510"):
# self.logger.error(f"设备 {device_id} 加载线路时间映射字典失败")
# return False
time.sleep(5)
# time.sleep(5)
# 循环检查数据数量是否一致,直到获取到完整数据
data_retry_count = 0
while True:
# 获取断点列表和线路时间字典的数量
breakpoint_count = len(global_variable.GLOBAL_BREAKPOINT_DICT)
line_time_count = len(global_variable.LINE_TIME_MAPPING_DICT)
self.logger.info(f"设备 {device_id} 断点列表数量: {breakpoint_count}, 文件中获取的线路时间数量: {line_time_count}")
# # 循环检查数据数量是否一致,直到获取到完整数据
# data_retry_count = 0
# while True:
# # 获取断点列表和线路时间字典的数量
# breakpoint_count = len(global_variable.GLOBAL_BREAKPOINT_DICT)
# line_time_count = len(global_variable.LINE_TIME_MAPPING_DICT)
# self.logger.info(f"设备 {device_id} 断点列表数量: {breakpoint_count}, 文件中获取的线路时间数量: {line_time_count}")
# 如果断点列表为空,无法比较,直接跳出循环
if breakpoint_count == 0:
self.logger.warning(f"设备 {device_id} 断点列表为空,无法进行数量比较")
break
# # 如果断点列表为空,无法比较,直接跳出循环
# if breakpoint_count == 0:
# self.logger.warning(f"设备 {device_id} 断点列表为空,无法进行数量比较")
# break
# 如果数量一致,获取到完整数据,跳出循环
# if line_time_count >= 2:
if line_time_count >= breakpoint_count:
self.logger.info(f"设备 {device_id} 数据数量一致,已获取完整数据")
break
# # 如果数量一致,获取到完整数据,跳出循环
# # if line_time_count >= 2:
# if line_time_count >= breakpoint_count:
# self.logger.info(f"设备 {device_id} 数据数量一致,已获取完整数据")
# break
# 数量不一致,等待三分钟后再次获取文件
data_retry_count += 1
self.logger.warning(f"设备 {device_id} 数据数量不一致: 断点列表({breakpoint_count}) != 线路时间({line_time_count}),第{data_retry_count}次重试等待1分钟后重新加载文件")
time.sleep(60) # 等待1分钟
# # 数量不一致,等待三分钟后再次获取文件
# data_retry_count += 1
# self.logger.warning(f"设备 {device_id} 数据数量不一致: 断点列表({breakpoint_count}) != 线路时间({line_time_count}),第{data_retry_count}次重试等待1分钟后重新加载文件")
# time.sleep(60) # 等待1分钟
# 重新加载文件
if not self.load_line_time_mapping_dict("20251022.1.CZSCZQ-3fhg0410.txt", "D:\\soft\\安卓时间修改-v0.7.13-1\\Logs\\202510"):
self.logger.error(f"设备 {device_id} 重新加载线路时间映射字典失败")
else:
self.logger.info(f"设备 {device_id} 重新加载完成,新的线路时间数量: {len(global_variable.LINE_TIME_MAPPING_DICT)}")
# # 重新加载文件
# if not self.load_line_time_mapping_dict("20251022.1.CZSCZQ-3fhg0410.txt", "D:\\soft\\安卓时间修改-v0.7.13-1\\Logs\\202510"):
# self.logger.error(f"设备 {device_id} 重新加载线路时间映射字典失败")
# else:
# self.logger.info(f"设备 {device_id} 重新加载完成,新的线路时间数量: {len(global_variable.LINE_TIME_MAPPING_DICT)}")
# 检查GLOBAL_BREAKPOINT_DICT是否为空如果为空则初始化一些测试数据
if not global_variable.GLOBAL_BREAKPOINT_DICT:
self.logger.warning("global_variable.GLOBAL_BREAKPOINT_DICT为空正在初始化测试数据")
global_variable.GLOBAL_BREAKPOINT_DICT = {
"CZSCZQ-3-康定2号隧道-DK297+201-DK297+199-山区": {
'breakpoint_name': "CZSCZQ-3-康定2号隧道-DK297+201-DK297+199-山区",
'line_num': "L205413"
},
"CZSCZQ-3-康定2号隧道-DK296+701-DK296+699-山区": {
'breakpoint_name': "CZSCZQ-3-康定2号隧道-DK296+701-DK296+699-山区",
'line_num': "L205414"
}
}
# if not global_variable.GLOBAL_BREAKPOINT_DICT:
# self.logger.warning("global_variable.GLOBAL_BREAKPOINT_DICT为空正在初始化测试数据")
# global_variable.GLOBAL_BREAKPOINT_DICT = {
# "CZSCZQ-3-康定2号隧道-DK297+201-DK297+199-山区": {
# 'breakpoint_name': "CZSCZQ-3-康定2号隧道-DK297+201-DK297+199-山区",
# 'line_num': "L205413"
# },
# "CZSCZQ-3-康定2号隧道-DK296+701-DK296+699-山区": {
# 'breakpoint_name': "CZSCZQ-3-康定2号隧道-DK296+701-DK296+699-山区",
# 'line_num': "L205414"
# }
# }
# 创建断点列表的副本,用于重试时重新处理
breakpoint_names = list(global_variable.GLOBAL_BREAKPOINT_DICT.keys())
processed_breakpoints = []
# # 创建断点列表的副本,用于重试时重新处理
# breakpoint_names = list(global_variable.GLOBAL_BREAKPOINT_DICT.keys())
# processed_breakpoints = []
# 开始循环处理断点
for breakpoint_name in breakpoint_names:
if breakpoint_name in processed_breakpoints:
continue
breakpoint_name = global_variable.GLOBAL_CURRENT_PROJECT_NAME
self.logger.info(f"开始处理要平差截图的断点 {breakpoint_name}")
# 把断点名称给find_keyword
if not self.find_keyword(breakpoint_name):
self.logger.error(f"设备 {device_id} 未找到包含 {breakpoint_name} 的文件名")
if not self.handle_measurement_dialog():
self.logger.error(f"设备 {device_id} 处理测量弹窗失败")
if not self.check_apply_btn():
self.logger.error(f"设备 {device_id} 检查平差处理按钮失败")
# 滑动列表到底部
if not self.scroll_list_to_bottom(device_id):
self.logger.error(f"设备 {device_id} 下滑列表到底部失败")
# 2. 点击最后一个spinner
if not self.click_last_spinner_with_retry(device_id):
self.logger.error(f"设备 {device_id} 点击最后一个spinner失败")
# 3. 再下滑一次
if not self.scroll_down_once(device_id):
self.logger.warning(f"设备 {device_id} 再次下滑失败,但继续执行")
if not self.take_screenshot(breakpoint_name):
self.logger.error(f"设备 {device_id} 截图失败")
# 4. 点击平差处理按钮
if not self.click_adjustment_button(device_id):
self.logger.error(f"设备 {device_id} 点击平差处理按钮失败")
# 检查是否在测量页面在就重新执行选择断点滑动列表到底部点击最后一个spinner 再下滑一次,点击平差处理按钮平差
if not self.handle_back_navigation(breakpoint_name, device_id):
self.logger.error(f"{breakpoint_name}平差失败,未截图")
# 检测并处理"是 保留成果"弹窗
if not self.handle_adjustment_result_dialog():
self.logger.error("处理平差结果弹窗失败")
# 检查是否在测量页面在就重新执行选择断点滑动列表到底部点击最后一个spinner 再下滑一次,点击平差处理按钮平差
if not self.handle_back_navigation(breakpoint_name, device_id):
self.logger.error(f"{breakpoint_name}平差失败,未截图")
continue
# 检测并处理"是 保留成果"弹窗
if not self.handle_adjustment_result_dialog():
self.logger.error("处理平差结果弹窗失败")
continue
# 点击返回按钮并处理弹窗
if not self.execute_back_navigation_steps(device_id):
self.logger.error(f"设备 {device_id} 处理返回按钮确认失败")
continue
# for breakpoint_name in breakpoint_names:
# if breakpoint_name in processed_breakpoints:
# continue
self.logger.info(f"开始处理要平差截图的断点 {breakpoint_name}")
# self.logger.info(f"开始处理要平差截图的断点 {breakpoint_name}")
# 把断点名称给find_keyword
if not self.find_keyword(breakpoint_name):
self.logger.error(f"设备 {device_id} 未找到包含 {breakpoint_name} 的文件名")
continue # 继续处理下一个断点
# # 把断点名称给find_keyword
# if not self.find_keyword(breakpoint_name):
# self.logger.error(f"设备 {device_id} 未找到包含 {breakpoint_name} 的文件名")
# continue # 继续处理下一个断点
if not self.handle_measurement_dialog():
self.logger.error(f"设备 {device_id} 处理测量弹窗失败")
continue
# if not self.handle_measurement_dialog():
# self.logger.error(f"设备 {device_id} 处理测量弹窗失败")
# continue
if not self.check_apply_btn():
self.logger.error(f"设备 {device_id} 检查平差处理按钮失败")
continue
# if not self.check_apply_btn():
# self.logger.error(f"设备 {device_id} 检查平差处理按钮失败")
# continue
# 根据断点名称在GLOBAL_BREAKPOINT_DICT中获取对应的字典
breakpoint_info = global_variable.GLOBAL_BREAKPOINT_DICT.get(breakpoint_name)
if not breakpoint_info:
self.logger.error(f"设备 {device_id} 未找到断点 {breakpoint_name} 对应的信息")
continue
# # 根据断点名称在GLOBAL_BREAKPOINT_DICT中获取对应的字典
# breakpoint_info = global_variable.GLOBAL_BREAKPOINT_DICT.get(breakpoint_name)
# if not breakpoint_info:
# self.logger.error(f"设备 {device_id} 未找到断点 {breakpoint_name} 对应的信息")
# continue
# 从字典中获取线路编码
line_code = breakpoint_info.get('line_num')
if not line_code:
self.logger.error(f"设备 {device_id} 断点 {breakpoint_name} 没有线路编码信息")
continue
# # 从字典中获取线路编码
# line_code = breakpoint_info.get('line_num')
# if not line_code:
# self.logger.error(f"设备 {device_id} 断点 {breakpoint_name} 没有线路编码信息")
# continue
# 根据线路编码查找对应的时间
date_str, time_str = self.get_line_end_time(line_code)
if not time_str or not date_str:
self.logger.error(f"设备 {device_id} 未找到线路 {line_code} 对应的时间")
continue
# # 根据线路编码查找对应的时间
# date_str, time_str = self.get_line_end_time(line_code)
# if not time_str or not date_str:
# self.logger.error(f"设备 {device_id} 未找到线路 {line_code} 对应的时间")
# continue
# 修改时间
if not self.set_device_time(device_id, time_str, date_str):
self.logger.error(f"设备 {device_id} 设置设备时间失败")
continue
# # 修改时间
# if not self.set_device_time(device_id, time_str, date_str):
# self.logger.error(f"设备 {device_id} 设置设备时间失败")
# continue
# 滑动列表到底部
if not self.scroll_list_to_bottom(device_id):
self.logger.error(f"设备 {device_id} 下滑列表到底部失败")
continue
# # 滑动列表到底部
# if not self.scroll_list_to_bottom(device_id):
# self.logger.error(f"设备 {device_id} 下滑列表到底部失败")
# continue
# 2. 点击最后一个spinner
if not self.click_last_spinner_with_retry(device_id):
self.logger.error(f"设备 {device_id} 点击最后一个spinner失败")
continue
# # 2. 点击最后一个spinner
# if not self.click_last_spinner_with_retry(device_id):
# self.logger.error(f"设备 {device_id} 点击最后一个spinner失败")
# continue
# 3. 再下滑一次
if not self.scroll_down_once(device_id):
self.logger.warning(f"设备 {device_id} 再次下滑失败,但继续执行")
# # 3. 再下滑一次
# if not self.scroll_down_once(device_id):
# self.logger.warning(f"设备 {device_id} 再次下滑失败,但继续执行")
# 4. 点击平差处理按钮
if not self.click_adjustment_button(device_id):
self.logger.error(f"设备 {device_id} 点击平差处理按钮失败")
continue
# # 4. 点击平差处理按钮
# if not self.click_adjustment_button(device_id):
# self.logger.error(f"设备 {device_id} 点击平差处理按钮失败")
# continue
# 检查是否在测量页面在就重新执行选择断点滑动列表到底部点击最后一个spinner 再下滑一次,点击平差处理按钮平差
if not self.handle_back_navigation(breakpoint_name, device_id):
self.logger.error(f"{breakpoint_name}平差失败,未截图")
continue
# # 检查是否在测量页面在就重新执行选择断点滑动列表到底部点击最后一个spinner 再下滑一次,点击平差处理按钮平差
# if not self.handle_back_navigation(breakpoint_name, device_id):
# self.logger.error(f"{breakpoint_name}平差失败,未截图")
# continue
# 检测并处理"是 保留成果"弹窗
if not self.handle_adjustment_result_dialog():
self.logger.error("处理平差结果弹窗失败")
continue
# # 检测并处理"是 保留成果"弹窗
# if not self.handle_adjustment_result_dialog():
# self.logger.error("处理平差结果弹窗失败")
# continue
# 平差完成,将断点数据保存到上传列表中
if not self.add_breakpoint_to_upload_list(breakpoint_name, line_code):
self.logger.error(f"设备 {device_id} 保存断点 {breakpoint_name} 到上传列表失败")
continue
# # 平差完成,将断点数据保存到上传列表中
# if not self.add_breakpoint_to_upload_list(breakpoint_name, line_code):
# self.logger.error(f"设备 {device_id} 保存断点 {breakpoint_name} 到上传列表失败")
# continue
# 检查是否在测量页面在就重新执行选择断点滑动列表到底部点击最后一个spinner 再下滑一次,点击平差处理按钮平差
if not self.handle_back_navigation(breakpoint_name, device_id):
self.logger.error(f"{breakpoint_name}平差失败,未截图")
continue
# # 检查是否在测量页面在就重新执行选择断点滑动列表到底部点击最后一个spinner 再下滑一次,点击平差处理按钮平差
# if not self.handle_back_navigation(breakpoint_name, device_id):
# self.logger.error(f"{breakpoint_name}平差失败,未截图")
# continue
# 检测并处理"是 保留成果"弹窗
if not self.handle_adjustment_result_dialog():
self.logger.error("处理平差结果弹窗失败")
continue
# # 检测并处理"是 保留成果"弹窗
# if not self.handle_adjustment_result_dialog():
# self.logger.error("处理平差结果弹窗失败")
# continue
# 平差处理完成后截图
time.sleep(3) # 等待平差处理按钮点击后的界面变化
logging.info("断点保存到上传列表成功,开始截图")
if not self.take_screenshot(breakpoint_name):
self.logger.error(f"设备 {device_id} 截图失败")
continue
# # 平差处理完成后截图
# time.sleep(3) # 等待平差处理按钮点击后的界面变化
# logging.info("断点保存到上传列表成功,开始截图")
# if not self.take_screenshot(breakpoint_name):
# self.logger.error(f"设备 {device_id} 截图失败")
# continue
# 点击返回按钮并处理弹窗
if not self.execute_back_navigation_steps(device_id):
self.logger.error(f"设备 {device_id} 处理返回按钮确认失败")
continue
# # 点击返回按钮并处理弹窗
# if not self.execute_back_navigation_steps(device_id):
# self.logger.error(f"设备 {device_id} 处理返回按钮确认失败")
# continue
# 成功处理完一个断点,添加到已处理列表
processed_breakpoints.append(breakpoint_name)
self.logger.info(f"成功处理断点: {breakpoint_name}")
# # 成功处理完一个断点,添加到已处理列表
# processed_breakpoints.append(breakpoint_name)
# self.logger.info(f"成功处理断点: {breakpoint_name}")
# 检查是否所有断点都处理完成
if len(processed_breakpoints) == len(breakpoint_names):

View File

@@ -2093,12 +2093,12 @@ class UploadConfigPage:
else:
self.logger.info("页面中包含变化量属性,继续执行后续操作")
user_id = global_variable.GLOBAL_USERNAME
if user_id is None:
self.logger.error("获取用户ID失败")
user_name = global_variable.GLOBAL_USERNAME
if user_name is None:
self.logger.error("获取用户失败")
return False
max_variation = apis.get_user_max_variation(user_id)
max_variation = apis.get_user_max_variation(user_name)
if max_variation is None:
self.logger.error("获取用户最大变化量失败")
return False

Binary file not shown.

After

Width:  |  Height:  |  Size: 312 KiB

BIN
上传人员信息.xlsx Normal file

Binary file not shown.