结合测量仪测试完毕,准备测平差+上传
This commit is contained in:
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user