多设备启动,端口固定,时间接口未返回
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -295,25 +295,25 @@ class DownloadTabbarPage:
|
||||
"""执行基础更新操作"""
|
||||
try:
|
||||
# 执行基础更新流程
|
||||
self.logger.info(f"设备 {global_variable.GLOBAL_DEVICE_ID} 开始执行更新流程")
|
||||
self.logger.info(f"设备 {global_variable.get_device_id()} 开始执行更新流程")
|
||||
|
||||
# 点击下载标签栏
|
||||
if not self.click_download_tabbar():
|
||||
self.logger.error(f"设备 {global_variable.GLOBAL_DEVICE_ID} 点击下载标签栏失败")
|
||||
self.logger.error(f"设备 {global_variable.get_device_id()} 点击下载标签栏失败")
|
||||
return False
|
||||
|
||||
# 更新工作基点
|
||||
if not self.update_work_base():
|
||||
self.logger.error(f"设备 {global_variable.GLOBAL_DEVICE_ID} 更新工作基点失败")
|
||||
self.logger.error(f"设备 {global_variable.get_device_id()} 更新工作基点失败")
|
||||
return False
|
||||
|
||||
# 更新水准线路
|
||||
if not self.update_level_line():
|
||||
self.logger.error(f"设备 {global_variable.GLOBAL_DEVICE_ID} 更新水准线路失败")
|
||||
self.logger.error(f"设备 {global_variable.get_device_id()} 更新水准线路失败")
|
||||
return False
|
||||
|
||||
self.logger.info(f"设备 {global_variable.GLOBAL_DEVICE_ID} 更新操作执行成功")
|
||||
self.logger.info(f"设备 {global_variable.get_device_id()} 更新操作执行成功")
|
||||
return True
|
||||
except Exception as e:
|
||||
self.logger.error(f"设备 {global_variable.GLOBAL_DEVICE_ID} 执行更新操作时出错: {str(e)}")
|
||||
self.logger.error(f"设备 {global_variable.get_device_id()} 执行更新操作时出错: {str(e)}")
|
||||
return False
|
||||
@@ -35,14 +35,40 @@ class LoginPage:
|
||||
|
||||
# 读取文本框内已有的用户名(.text属性获取元素显示的文本内容)
|
||||
existing_username = username_field.text
|
||||
# 3. 将获取到的用户名写入全局变量中
|
||||
global_variable.GLOBAL_USERNAME = existing_username # 关键:给全局变量赋值
|
||||
# 3. 将获取到的用户名写入全局变量中
|
||||
# global_variable.GLOBAL_USERNAME = existing_username # 关键:给全局变量赋值
|
||||
global_variable.set_username(existing_username)
|
||||
|
||||
# 日志记录获取到的已有用户名(若为空,也需明确记录,避免后续误解)
|
||||
if existing_username.strip(): # 去除空格后判断是否有有效内容
|
||||
self.logger.info(f"已获取文本框中的已有用户名: {existing_username}")
|
||||
else:
|
||||
self.logger.info("文本框中未检测到已有用户名(内容为空)")
|
||||
|
||||
# 1. 定位密码输入框
|
||||
password_field = self.wait.until(
|
||||
EC.element_to_be_clickable((AppiumBy.ID, ids.LOGIN_PASSWORD))
|
||||
)
|
||||
|
||||
# 2. 清空密码框(如果需要)
|
||||
try:
|
||||
password_field.clear()
|
||||
# time.sleep(0.5) # 等待清除完成
|
||||
except:
|
||||
# 如果clear方法不可用,尝试其他方式
|
||||
pass
|
||||
|
||||
# 3. 输入密码
|
||||
if existing_username=="wangshun":
|
||||
password_field.send_keys("Wang93534.")
|
||||
else:
|
||||
password_field.send_keys("Liang/1974.")
|
||||
|
||||
# 4. 可选:隐藏键盘
|
||||
try:
|
||||
self.driver.hide_keyboard()
|
||||
except:
|
||||
pass
|
||||
|
||||
# 点击登录按钮
|
||||
login_btn = self.wait.until(
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -671,7 +671,7 @@ class UploadConfigPage:
|
||||
logging.warning(f"跳过无效数据: 姓名='{name}', 身份证='{id_card}'")
|
||||
|
||||
# 将字典保存到全局变量
|
||||
global_variable.GLOBAL_NAME_TO_ID_MAP = name_id_map
|
||||
global_variable.set_name_to_id_map(name_id_map)
|
||||
|
||||
logging.info(f"成功加载用户数据,共 {len(df)} 条记录,{len(name_id_map)} 个有效姓名-身份证映射")
|
||||
|
||||
@@ -711,7 +711,7 @@ class UploadConfigPage:
|
||||
logging.info(f"使用第一个数据员: {sjname}")
|
||||
|
||||
# 获取身份证号码
|
||||
id_card = global_variable.GLOBAL_NAME_TO_ID_MAP.get(sjname)
|
||||
id_card = global_variable.get_name_to_id_map().get(sjname)
|
||||
logging.info(f"id_card: {id_card}")
|
||||
if not id_card:
|
||||
logging.error(f"未找到数据员 {sjname} 对应的身份证号")
|
||||
@@ -1759,7 +1759,7 @@ class UploadConfigPage:
|
||||
else:
|
||||
self.logger.info("页面中包含变化量属性,继续执行后续操作")
|
||||
|
||||
user_id = global_variable.GLOBAL_USERNAME
|
||||
user_id = global_variable.get_username()
|
||||
if user_id is None:
|
||||
self.logger.error("获取用户ID失败")
|
||||
return False
|
||||
@@ -1859,7 +1859,7 @@ class UploadConfigPage:
|
||||
|
||||
self.logger.info("上传配置页面操作执行完成")
|
||||
# 把上传成功的断点写入全局变量GLOBAL_UPLOAD_SUCCESS_BREAKPOINT_LIST
|
||||
global_variable.GLOBAL_UPLOAD_SUCCESS_BREAKPOINT_LIST.append(breakpoint_name)
|
||||
global_variable.get_upload_success_breakpoint_list().append(breakpoint_name)
|
||||
|
||||
return True
|
||||
|
||||
|
||||
Reference in New Issue
Block a user