利辛自动化小程序

This commit is contained in:
jjLv 2024-09-30 15:02:26 +08:00
parent 54a371441b
commit 247a0ec432
1 changed files with 20 additions and 10 deletions

View File

@ -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+"行附近");