多设备启动,端口固定,时间接口未返回

This commit is contained in:
2026-02-04 10:58:46 +08:00
parent cc59e8b8da
commit 9ce1dbadc1
22 changed files with 1344 additions and 297 deletions

View File

@@ -258,8 +258,8 @@ class ScreenshotPage:
tuple: (date_str, time_str) 日期和时间字符串
"""
if line_code in global_variable.LINE_TIME_MAPPING_DICT:
end_time = global_variable.LINE_TIME_MAPPING_DICT[line_code]
if line_code in global_variable.get_line_time_mapping_dict():
end_time = global_variable.get_line_time_mapping_dict()[line_code]
date_str = end_time.strftime("%Y-%m-%d")
time_str = end_time.strftime("%H:%M:%S")
return (date_str, time_str)
@@ -273,19 +273,19 @@ class ScreenshotPage:
"""
self.logger.info("\n当前全局字典内容:")
if global_variable.LINE_TIME_MAPPING_DICT:
for line_code, end_time in sorted(global_variable.LINE_TIME_MAPPING_DICT.items()):
if global_variable.get_line_time_mapping_dict():
for line_code, end_time in sorted(global_variable.get_line_time_mapping_dict().items()):
date_str = end_time.strftime("%Y-%m-%d")
time_str = end_time.strftime("%H:%M:%S")
self.logger.info(f" {line_code}: {date_str} {time_str}")
else:
self.logger.info(" 全局字典为空")
self.logger.info(f"总计: {len(global_variable.LINE_TIME_MAPPING_DICT)} 条记录\n")
self.logger.info(f"总计: {len(global_variable.get_line_time_mapping_dict())} 条记录\n")
def clear_line_time_mapping(self):
"""
清空全局字典
"""
global_variable.LINE_TIME_MAPPING_DICT.clear()
global_variable.get_line_time_mapping_dict().clear()
self.logger.info("已清空全局字典")
def set_device_time(self, device_id, time_str=None, date_str=None, disable_auto_sync=True):
@@ -1121,10 +1121,10 @@ class ScreenshotPage:
# 确保device_id正确设置使用全局变量作为备用
if not hasattr(self, 'device_id') or not self.device_id:
# 优先使用传入的device_id其次使用全局变量
self.device_id = device_id if device_id else global_variable.GLOBAL_DEVICE_ID
self.device_id = device_id if device_id else global_variable.get_device_id()
# 使用self.device_id确保有默认值
actual_device_id = self.device_id if self.device_id else global_variable.GLOBAL_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):
self.logger.warning(f"设备 {actual_device_id} 会话无效,尝试重新连接驱动...")
@@ -1269,9 +1269,9 @@ class ScreenshotPage:
def add_breakpoint_to_upload_list(self, breakpoint_name, line_num):
"""添加平差完成的断点到上传列表和字典"""
if breakpoint_name and breakpoint_name not in global_variable.GLOBAL_UPLOAD_BREAKPOINT_LIST:
global_variable.GLOBAL_UPLOAD_BREAKPOINT_LIST.append(breakpoint_name)
global_variable.GLOBAL_UPLOAD_BREAKPOINT_DICT[breakpoint_name] = {
if breakpoint_name and breakpoint_name not in global_variable.get_upload_breakpoint_list():
global_variable.get_upload_breakpoint_list().append(breakpoint_name)
global_variable.get_upload_breakpoint_dict()[breakpoint_name] = {
'breakpoint_name': breakpoint_name,
'line_num': line_num
}
@@ -1342,19 +1342,18 @@ class ScreenshotPage:
return False
# 检查GLOBAL_UPLOAD_BREAKPOINT_DICT是否为空如果为空则初始化一些测试数据
if not global_variable.GLOBAL_UPLOAD_BREAKPOINT_DICT:
if not global_variable.get_upload_breakpoint_dict():
self.logger.warning("global_variable.GLOBAL_UPLOAD_BREAKPOINT_DICT为空正在初始化测试数据")
global_variable.GLOBAL_UPLOAD_BREAKPOINT_DICT = {'CDWZQ-2标-龙骨湾右线大桥-0-7号墩-平原': 'L156372', 'CDWZQ-2标-蓝家湾特大 桥-31-31-平原': 'L159206'}
global_variable.set_upload_breakpoint_dict({'CDWZQ-2标-龙骨湾右线大桥-0-7号墩-平原': 'L156372', 'CDWZQ-2标-蓝家湾特大 桥-31-31-平原': 'L159206'})
# 创建断点列表的副本,用于重试时重新处理
breakpoint_names = list(global_variable.GLOBAL_UPLOAD_BREAKPOINT_DICT.keys())
breakpoint_names = list(global_variable.get_upload_breakpoint_dict().keys())
processed_breakpoints = []
# 开始循环处理断点
for breakpoint_name in breakpoint_names:
if breakpoint_name in processed_breakpoints:
continue
line_code = global_variable.GLOBAL_UPLOAD_BREAKPOINT_DICT[breakpoint_name]
line_code = global_variable.get_upload_breakpoint_dict()[breakpoint_name]
self.logger.info(f"开始处理要平差的断点 {breakpoint_name}")
@@ -1409,17 +1408,19 @@ class ScreenshotPage:
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):
self.logger.info(f"设备 {device_id} 平差页面操作执行完成")
return True
else:
self.logger.warning(f"设备 {device_id} 部分断点处理失败,已成功处理 {len(processed_breakpoints)}/{len(breakpoint_names)} 个断点")
return True
# # 检查是否所有断点都处理完成
# if len(processed_breakpoints) == len(breakpoint_names):
# self.logger.info(f"设备 {device_id} 平差页面操作执行完成")
# return True
# else:
# self.logger.warning(f"设备 {device_id} 部分断点处理失败,已成功处理 {len(processed_breakpoints)}/{len(breakpoint_names)} 个断点")
# return True
self.logger.warning(f"设备 {device_id} 上传流程执行完成")
return True
except Exception as e:
retry_count += 1