From 247a0ec43292c852b972526f4c0a588f514a9f33 Mon Sep 17 00:00:00 2001 From: jjLv <1981429112@qq.com> Date: Mon, 30 Sep 2024 15:02:26 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=A9=E8=BE=9B=E8=87=AA=E5=8A=A8=E5=8C=96?= =?UTF-8?q?=E5=B0=8F=E7=A8=8B=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/bonus/autoweb/task/AutoWebTask.java | 30 ++++++++++++------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/src/main/java/com/bonus/autoweb/task/AutoWebTask.java b/src/main/java/com/bonus/autoweb/task/AutoWebTask.java index 04fdad6..c2f6bb5 100644 --- a/src/main/java/com/bonus/autoweb/task/AutoWebTask.java +++ b/src/main/java/com/bonus/autoweb/task/AutoWebTask.java @@ -1,5 +1,6 @@ package com.bonus.autoweb.task; +import com.bonus.autoweb.DateTimeUtils; import com.bonus.autoweb.GetBasicData; import com.bonus.autoweb.base.*; import org.apache.poi.ss.usermodel.Cell; @@ -17,6 +18,8 @@ import java.io.BufferedReader; import java.io.FileInputStream; import java.io.FileReader; import java.io.IOException; +import java.util.ArrayList; +import java.util.Collections; /** * 应急指挥中心打卡任务类 @@ -162,26 +165,31 @@ public class AutoWebTask { "]/table/tbody/tr[1]/td[2]/div/div/p[1]")); String personLeaderName = personLeaderNameEle.getText(); log.info("今日值班长:" + personLeaderName); - WebElement accountLeaderEle = webDriver.findElement(By.xpath("//*[@id='pane-1']/div/div[3]/div/div/div[3" + - "]/table/tbody/tr[1]/td[2]/div/div/p[2]")); - String accountLeader = accountLeaderEle.getText(); - log.info("今日值班长:" + accountLeader); + +// WebElement accountLeaderEle = webDriver.findElement(By.xpath("//*[@id='pane-1']/div/div[3]/div/div/div[3" + +// "]/table/tbody/tr[1]/td[2]/div/div/p[2]")); +// String accountLeader = accountLeaderEle.getText(); +// log.info("今日值班长账号:" + accountLeader); //获取值班员账号姓名 和 账号名 WebElement personNameEle = webDriver.findElement(By.xpath("//*[@id='pane-1']/div/div[3]/div/div/div[3" + "]/table/tbody/tr[2]/td[2]/div/div/p[1]")); String personName = personNameEle.getText(); log.info("今日值班人员:" + personName); - WebElement accountEle = webDriver.findElement(By.xpath("//*[@id='pane-1']/div/div[3]/div/div/div[3" + - "]/table/tbody/tr[2]/td[2]/div/div/p[2]")); - String account = accountEle.getText(); - log.info("今日值班人员账号:" + account); + +// WebElement accountEle = webDriver.findElement(By.xpath("//*[@id='pane-1']/div/div[3]/div/div/div[3" + +// "]/table/tbody/tr[2]/td[2]/div/div/p[2]")); +// String account = accountEle.getText(); +// log.info("今日值班人员账号:" + account); + Thread.sleep(3000); excelFile = new FileInputStream("E:\\bns\\config\\zhibanaccount.xlsx"); workbook = new XSSFWorkbook(excelFile); Sheet datatypeSheet = workbook.getSheetAt(0); String personLeaderPassword = ""; String personPassword = ""; + String account = ""; + String accountLeader = ""; int rowNum = 0; for (Row row : datatypeSheet) { String value = ""; @@ -190,15 +198,17 @@ public class AutoWebTask { } value = value.substring(0, value.length() - 3); try{ - if (value.contains(account)) { + if (value.contains(personName)) { personPassword = value.split("]]]")[2]; + account = value.split("]]]")[1]; } }catch (IndexOutOfBoundsException ignored){ log.error("出现异常:"+personName+"账号内容出错,在表格的第"+rowNum+"行附近"); } try{ - if (value.contains(accountLeader)) { + if (value.contains(personLeaderName)) { personLeaderPassword = value.split("]]]")[2]; + accountLeader = value.split("]]]")[1]; } }catch (IndexOutOfBoundsException ignored){ log.error("出现异常:"+personLeaderName+"账号内容出错,在表格的第"+rowNum+"行附近");