修改上传人员信息表为D盘固定位置;新增上传弹窗检查

This commit is contained in:
2026-02-09 08:53:41 +08:00
parent 5c38228a1c
commit ac4d41c70b
30 changed files with 111274 additions and 883 deletions

View File

@@ -1,46 +0,0 @@
import socket
def send_tcp_command(command: str, host: str = '127.0.0.1', port: int = 8888, encoding: str = 'utf-8') -> bool:
"""
向指定TCP端口发送指令
参数:
command: 要发送的指令字符串
host: 目标主机地址默认127.0.0.1
port: 目标端口默认8888
encoding: 字符串编码格式默认utf-8
返回:
发送成功返回True失败返回False
"""
# 创建TCP socket并自动关闭with语句确保资源释放
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as sock:
try:
# 连接服务器超时时间5秒避免无限阻塞
sock.settimeout(5.0)
sock.connect((host, port))
# 发送指令(转换为字节流)
sock.sendall(command.encode(encoding))
print(f"指令 '{command}' 发送成功")
return True
except ConnectionRefusedError:
print(f"连接失败:{host}:{port} 未监听或不可达")
except socket.timeout:
print(f"连接超时超过5秒未连接到 {host}:{port}")
except UnicodeEncodeError:
print(f"编码失败:指令包含{encoding}无法编码的字符")
except Exception as e:
print(f"发送失败:{str(e)}")
return False
# 使用示例
if __name__ == "__main__":
# 发送StartConnect指令
send_tcp_command("StartConnect")
# 也可以发送其他指令,例如:
# send_tcp_command("StopConnect")

View File

@@ -633,10 +633,13 @@ class UploadConfigPage:
def _load_user_data(self):
"""加载用户数据从Excel文件只提取名字和身份证到字典"""
try:
# 默认路径:当前脚本的上一级目录下的"上传人员信息.xlsx"
current_dir = os.path.dirname(os.path.abspath(__file__))
parent_dir = os.path.dirname(current_dir)
excel_path = os.path.join(parent_dir, "上传人员信息.xlsx")
# # 默认路径:当前脚本的上一级目录下的"上传人员信息.xlsx"
# current_dir = os.path.dirname(os.path.abspath(__file__))
# parent_dir = os.path.dirname(current_dir)
# excel_path = os.path.join(parent_dir, "上传人员信息.xlsx")
# 固定路径D:\uploadInfo\上传人员信息.xlsx
excel_path = os.path.join("D:\\", "uploadInfo", "上传人员信息.xlsx")
if not os.path.exists(excel_path):
logging.error(f"Excel文件不存在: {excel_path}")
@@ -1535,16 +1538,24 @@ class UploadConfigPage:
save_upload_btn = WebDriverWait(self.driver, 10).until(
EC.element_to_be_clickable((AppiumBy.ID, "com.bjjw.cjgc:id/improve_save_btn"))
)
save_upload_btn.click()
self.logger.info("已点击保存上传按钮")
# 处理警告弹窗
time.sleep(1)
if not self.handle_warning_dialog():
self.logger.error("处理警告弹窗失败")
return False
max_retries = 3
for attempt in range(max_retries):
save_upload_btn.click()
self.logger.info(f"已点击保存上传按钮 (第 {attempt + 1} 次)")
return True
# 处理警告弹窗
time.sleep(1)
if self.handle_warning_dialog():
self.logger.info("处理警告弹窗成功")
return True
else:
self.logger.warning(f"处理警告弹窗失败,准备重试 ({attempt + 1}/{max_retries})")
if attempt < max_retries - 1:
time.sleep(1)
self.logger.error(f"处理警告弹窗失败,已达到最大重试次数 {max_retries}")
return False
except TimeoutException:
self.logger.error("点击保存上传按钮超时")
@@ -1821,6 +1832,12 @@ class UploadConfigPage:
self.logger.error("获取工况信息失败")
return False
# 遍历返回数据的所有workinfoname如果为空就打印当前在上传的线路名称
for workinfo in work_conditions.values():
if not workinfo.get('workinfoname'):
print(f"❌❌❌❌❌线路编码 '{self.line_num}' 中有工况缺失(请复制发送编码给相关人员)❌❌❌❌❌")
return False
# 提取人员姓名和身份证
if not self._load_user_data():
self.logger.error("加载用户数据失败")