涡阳自动化小程序

This commit is contained in:
jjLv 2024-09-30 14:32:45 +08:00
parent cc9f79d6e2
commit 1c9e2a8779
8 changed files with 945 additions and 671 deletions

View File

@ -546,7 +546,7 @@ public class GetBasicData {
String type = ""; String type = "";
Random rand = new Random(); Random rand = new Random();
Set<Integer> generated = new HashSet<>(); Set<Integer> generated = new HashSet<>();
while (generated.size() < 6) { while (generated.size() < 3) {
Integer next = rand.nextInt(27) + 1; Integer next = rand.nextInt(27) + 1;
// As we're adding to a set, this will automatically do a containment check // As we're adding to a set, this will automatically do a containment check
generated.add(next); generated.add(next);
@ -813,7 +813,7 @@ public class GetBasicData {
// //
// private void executePlan(String type, String company, String projectName) throws InterruptedException { // private void executePlan(String type, String company, String projectName) throws InterruptedException {
// Thread.sleep(2000); // Thread.sleep(2000);
// String checkContent = resolveGarbledCode("E:\\bns\\config\\检查计划评价.txt"); // String checkContent = resolveGarbledCode("D:\\bns\\config\\检查计划评价.txt");
// String[] checkContentArrayArray = checkContent.split("检查评价:"); // String[] checkContentArrayArray = checkContent.split("检查评价:");
//// //点击已审核按钮 //// //点击已审核按钮
//// webDriver.findElement(By.xpath("/html/body/div/div/div/div[1]/div/div/div/div[2]")).click(); //// webDriver.findElement(By.xpath("/html/body/div/div/div/div[1]/div/div/div/div[2]")).click();
@ -1186,21 +1186,21 @@ public class GetBasicData {
webDriver.findElement(By.xpath("/html/body/div[3]/div/div[2]/section/header/form/div/div[5]/div/div[2]")).click(); webDriver.findElement(By.xpath("/html/body/div[3]/div/div[2]/section/header/form/div/div[5]/div/div[2]")).click();
Thread.sleep(3000); Thread.sleep(3000);
if("通信测试".equals(type)){ if("通信测试".equals(type)){
webDriver.findElement(By.xpath("/html/body/div[7]/div/div[2]/section/section/main/div/div[3]/table/tbody" + webDriver.findElement(By.xpath("/html/body/div[7]/div/div[2]/section/main/div[1]/div[3]/table/tbody/tr[1]/td[1]/div/label")).click();
"/tr[1]")).click();
Thread.sleep(500); Thread.sleep(500);
webDriver.findElement(By.xpath("/html/body/div[7]/div/div[2]/section/section/main/div/div[3]/table/tbody" + webDriver.findElement(By.xpath("/html/body/div[7]/div/div[2]/section/main/div[1]/div[3]/table/tbody/tr[2" +
"/tr[2]")).click(); "]/td[1]/div/label")).click();
Thread.sleep(1000); Thread.sleep(1000);
webDriver.findElement(By.xpath("/html/body/div[7]/div/div[2]/section/footer/button[2]")).click();
}else { }else {
for (int i = 1; i < 3; i++) { for (int i = 1; i < 3; i++) {
webDriver.findElement(By.xpath("/html/body/div[7]/div/div[2]/section/section/main/div/div[3]/table" + webDriver.findElement(By.xpath("/html/body/div[7]/div/div[2]/section/main/div[1]/div[3]/table" +
"/tbody/tr["+i+"]")).click(); "/tbody/tr["+i+"]/td[1]/div/label")).click();
Thread.sleep(1000); Thread.sleep(1000);
} }
}
Thread.sleep(3000); Thread.sleep(3000);
webDriver.findElement(By.xpath("/html/body/div[7]/div/div[2]/section/footer/button[2]")).click(); webDriver.findElement(By.xpath("/html/body/div[7]/div/div[2]/section/footer[2]/button[2]")).click();
}
Thread.sleep(2000); Thread.sleep(2000);
//提交 //提交
webDriver.findElement(By.xpath("/html/body/div[2]/div/div[2]/section/div/button[3]")).click(); webDriver.findElement(By.xpath("/html/body/div[2]/div/div[2]/section/div/button[3]")).click();

View File

@ -38,7 +38,7 @@ public class TestMain {
// testqd(); // testqd();
// testjjb(); // testjjb();
// testGetData(); // testGetData();
// testAccounters(); // testAccounters(); //值班账号
// testDailrb(); // testDailrb();
// testRCCL(); // testRCCL();
// testLog(); // testLog();
@ -91,16 +91,29 @@ public class TestMain {
//签到签退测试 //签到签退测试
private static void testqd() { private static void testqd() {
String content = GetBasicData.resolveGarbledCode("D:\\bns\\config\\account.txt"); // String content = GetBasicData.resolveGarbledCode("D:\\bns\\config\\account.txt");
String date = content.toString().split(";")[0].split(":")[1]; // String date = content.toString().split(";")[0].split(":")[1];
String num = content.toString().split(";")[1].split(":")[1]; // String num = content.toString().split(";")[1].split(":")[1];
if("1".equals(num)){ // if("1".equals(num)){
log.info("xgd,yj签到签退任务"); // log.info("xgd,yj签到签退任务");
}else { // }else {
log.info("zkj,zh签到签退任务"); // log.info("zkj,zh签到签退任务");
// }
//// AutoWebTask autoWebTask = new AutoWebTask();
//// autoWebTask.dutyClockTask(2);
AutoWebTask autoWebTask = new AutoWebTask();
String yesterdayContent = GetBasicData.resolveGarbledCode("D:\\bns\\config\\昨日值班账号.txt");
String yesterdayLeaderSignOutPerson = yesterdayContent.toString().split("")[0].split("")[1];
String yesterdayLeaderSignOutPersonPassword = yesterdayContent.toString().split("")[1].split("")[1];
String yesterdaySignOutPerson = yesterdayContent.toString().split("")[2].split("")[1];
String yesterdaySignOutPersonPassword = yesterdayContent.toString().split("")[3].split("")[1];
try {
autoWebTask.dutySignOutTask(1,yesterdayLeaderSignOutPerson,yesterdayLeaderSignOutPersonPassword);
Thread.sleep(2000);
autoWebTask.dutySignOutTask(1,yesterdaySignOutPerson,yesterdaySignOutPersonPassword);
}catch (Exception e){
log.error("签退",e);
} }
// AutoWebTask autoWebTask = new AutoWebTask();
// autoWebTask.dutyClockTask(2);
} }
//交接班测试 //交接班测试
@ -176,12 +189,13 @@ public class TestMain {
try { try {
//操作日志 //操作日志
AutoWebTask autoWebTask = new AutoWebTask(); AutoWebTask autoWebTask = new AutoWebTask();
String content = GetBasicData.resolveGarbledCode("D:\\bns\\config\\今日值班账号.txt"); String yesterdayContent = GetBasicData.resolveGarbledCode("D:\\bns\\config\\昨日值班账号.txt");
String yesterdayLeaderSignOutPerson = yesterdayContent.toString().split("")[0].split("")[1];
String yesterdayLeaderSignOutPersonPassword = yesterdayContent.toString().split("")[1].split("")[1];
// 应急值班账号 // 应急值班账号
String emergencyPerson = content.toString().split("")[0].split("")[1];
String emergencyPersonPassword = content.toString().split("")[1].split("")[1];
Thread.sleep(2000); Thread.sleep(2000);
autoWebTask.dutyAddLogsTask(2,emergencyPerson,emergencyPersonPassword); autoWebTask.dutyAddLogsTask(1,yesterdayLeaderSignOutPerson,yesterdayLeaderSignOutPersonPassword);
count = 1; count = 1;
Thread.sleep(1000); Thread.sleep(1000);
log.info("count",count); log.info("count",count);
@ -243,13 +257,14 @@ public class TestMain {
String todaySignInLeaderPersonPassword = todayContent.toString().split("")[1].split("")[1]; String todaySignInLeaderPersonPassword = todayContent.toString().split("")[1].split("")[1];
String todaySignInPerson = todayContent.toString().split("")[2].split("")[1]; String todaySignInPerson = todayContent.toString().split("")[2].split("")[1];
String todaySignInPersonPassword = todayContent.toString().split("")[3].split("")[1]; String todaySignInPersonPassword = todayContent.toString().split("")[3].split("")[1];
//昨日签退人员 //昨日签退人员
String yesterdayLeaderSignOutPerson = yesterdayContent.toString().split("")[0].split("")[1]; String yesterdayLeaderSignOutPerson = yesterdayContent.toString().split("")[0].split("")[1];
String yesterdayLeaderSignOutPersonPassword = yesterdayContent.toString().split("")[1].split("")[1]; String yesterdayLeaderSignOutPersonPassword = yesterdayContent.toString().split("")[1].split("")[1];
String yesterdaySignOutPerson = yesterdayContent.toString().split("")[2].split("")[1]; String yesterdaySignOutPerson = yesterdayContent.toString().split("")[2].split("")[1];
String yesterdaySignOutPersonPassword = yesterdayContent.toString().split("")[3].split("")[1]; String yesterdaySignOutPersonPassword = yesterdayContent.toString().split("")[3].split("")[1];
if(DateTimeUtils.isEffectiveDate("17:26", "17:55")){ if(DateTimeUtils.isEffectiveDate("18:22", "18:55")){
//进行日报信息系统采集及获取工作 //进行日报信息系统采集及获取工作
try { try {
if (logGatherCount == 0){ if (logGatherCount == 0){
@ -272,7 +287,7 @@ public class TestMain {
} catch (IOException e) { } catch (IOException e) {
log.error("更新早上打卡人员", e); log.error("更新早上打卡人员", e);
} }
}else if (DateTimeUtils.isEffectiveDate("06:00", "06:20")) { }else if (DateTimeUtils.isEffectiveDate("06:29", "06:59")) {
//自动完成当值值班日报早报填写上报 //自动完成当值值班日报早报填写上报
if (dailyzao == 0) { if (dailyzao == 0) {
getTime(600); getTime(600);
@ -284,7 +299,7 @@ public class TestMain {
log.error("日报工作", e); log.error("日报工作", e);
} }
} }
}else if (DateTimeUtils.isEffectiveDate("06:21", "06:45")) { }else if (DateTimeUtils.isEffectiveDate("07:01", "07:29")) {
//完成值班日志填写提交晚班日志此次值班日志为总结前一天晚上的情况 //完成值班日志填写提交晚班日志此次值班日志为总结前一天晚上的情况
if (logzao == 0) { if (logzao == 0) {
getTime(600); getTime(600);
@ -294,7 +309,7 @@ public class TestMain {
log.error("日志工作", e); log.error("日志工作", e);
} }
} }
}else if (DateTimeUtils.isEffectiveDate("07:05", "07:30")) { }else if (DateTimeUtils.isEffectiveDate("07:30", "07:59")) {
//自动完成当值值班签到值班主任值班人员都要签到 //自动完成当值值班签到值班主任值班人员都要签到
if ("error".equals(content)) { if ("error".equals(content)) {
log.error("读取打卡人员数据错误"); log.error("读取打卡人员数据错误");
@ -328,7 +343,7 @@ public class TestMain {
} }
} }
} }
}else if (DateTimeUtils.isEffectiveDate("07:35", "08:00")) { }else if (DateTimeUtils.isEffectiveDate("08:00", "08:30")) {
if (jjbzao == 0 && jjbzao2 == 0){ if (jjbzao == 0 && jjbzao2 == 0){
getTime(600); getTime(600);
} }
@ -416,7 +431,22 @@ public class TestMain {
}catch (Exception e) { }catch (Exception e) {
log.error("信息采集工作", e); log.error("信息采集工作", e);
} }
}else if (DateTimeUtils.isEffectiveDate("16:50", "17:20")) { } else if (DateTimeUtils.isEffectiveDate("16:30", "17:00")) {
//进行日志信息系统采集及获取工作
try {
if (logGatherCount1 == 0){
logGatherCount1 = autoWebTask.getCaoLianData(2,emergencyPerson,emergencyPersonPassword);
}
Thread.sleep(3000);
if (dailyGatherCount1 == 0){
dailyGatherCount1= autoWebTask.getYuJingData(2,emergencyPerson,emergencyPersonPassword);
Thread.sleep(2000);
GetBasicData.getYuJingActionBasicData(2);
}
}catch (Exception e) {
log.error("信息采集工作", e);
}
} else if (DateTimeUtils.isEffectiveDate("17:01", "17:25")) {
//自动完成当值值班日报晚报填写上报 //自动完成当值值班日报晚报填写上报
if (dailywan == 0) { if (dailywan == 0) {
getTime(1200); getTime(1200);

View File

@ -156,7 +156,7 @@ public class AutoMain {
Thread.sleep(10000); Thread.sleep(10000);
//执行鼠标悬停动作-管理 //执行鼠标悬停动作-管理
Actions action = new Actions(webDriver); Actions action = new Actions(webDriver);
WebElement wegl = webDriver.findElement(By.xpath("//*[@id=\"app\"]/div/div[1]/div[5]/div/div/div[6]/span/span/div")); WebElement wegl = webDriver.findElement(By.xpath("//*[@id=\"app\"]/div/div[1]/div[6]/div/div/div[6]/span/span/div"));
action.moveToElement(wegl).build().perform(); action.moveToElement(wegl).build().perform();
Thread.sleep(300); Thread.sleep(300);
@ -201,7 +201,7 @@ public class AutoMain {
Thread.sleep(5000); Thread.sleep(5000);
//执行鼠标悬停动作-管理 //执行鼠标悬停动作-管理
Actions action = new Actions(webDriver); Actions action = new Actions(webDriver);
WebElement wegl = webDriver.findElement(By.xpath("//*[@id=\"app\"]/div/div[1]/div[5]/div/div/div[2]/span/span/div")); WebElement wegl = webDriver.findElement(By.xpath("//*[@id=\"app\"]/div/div[1]/div[6]/div/div/div[2]/span/span/div"));
action.moveToElement(wegl).build().perform(); action.moveToElement(wegl).build().perform();
Thread.sleep(300); Thread.sleep(300);
log.info("执行鼠标悬停动作-管理"); log.info("执行鼠标悬停动作-管理");
@ -240,7 +240,7 @@ public class AutoMain {
Thread.sleep(5000); Thread.sleep(5000);
//执行鼠标悬停动作-管理 //执行鼠标悬停动作-管理
Actions action = new Actions(webDriver); Actions action = new Actions(webDriver);
WebElement wegl = webDriver.findElement(By.xpath("//*[@id=\"app\"]/div/div[1]/div[5]/div/div/div[2]/span/span/div")); WebElement wegl = webDriver.findElement(By.xpath("//*[@id=\"app\"]/div/div[1]/div[6]/div/div/div[2]/span/span/div"));
action.moveToElement(wegl).build().perform(); action.moveToElement(wegl).build().perform();
Thread.sleep(300); Thread.sleep(300);
log.info("执行鼠标悬停动作-管理"); log.info("执行鼠标悬停动作-管理");
@ -283,7 +283,7 @@ public class AutoMain {
Thread.sleep(3000); Thread.sleep(3000);
//执行鼠标悬停动作-管理 //执行鼠标悬停动作-管理
Actions action = new Actions(webDriver); Actions action = new Actions(webDriver);
WebElement wegl = webDriver.findElement(By.xpath("//*[@id=\"app\"]/div/div[1]/div[5]/div/div/div[6]/span/span/div")); WebElement wegl = webDriver.findElement(By.xpath("//*[@id=\"app\"]/div/div[1]/div[6]/div/div/div[6]/span/span/div"));
action.moveToElement(wegl).build().perform(); action.moveToElement(wegl).build().perform();
Thread.sleep(300); Thread.sleep(300);
@ -342,7 +342,7 @@ public class AutoMain {
Thread.sleep(5000); Thread.sleep(5000);
//执行鼠标悬停动作-管理 //执行鼠标悬停动作-管理
Actions action = new Actions(webDriver); Actions action = new Actions(webDriver);
WebElement wegl = webDriver.findElement(By.xpath("//*[@id=\"app\"]/div/div[1]/div[5]/div/div/div[6]/span/span/div")); WebElement wegl = webDriver.findElement(By.xpath("//*[@id=\"app\"]/div/div[1]/div[6]/div/div/div[6]/span/span/div"));
action.moveToElement(wegl).build().perform(); action.moveToElement(wegl).build().perform();
Thread.sleep(300); Thread.sleep(300);

View File

@ -52,8 +52,8 @@ public class DataConfig {
/** /**
* 浏览器驱动地址 * 浏览器驱动地址
*/ */
// protected static final String drivePath = "E:\\bns\\chromedriver_win32\\geckodriver.exe";//个人本地 // protected static final String drivePath = "D:\\bns\\chromedriver_win32\\geckodriver.exe";//个人本地
// protected static final String drivePath = "E:\\chromedriver_win32\\chromedriver.exe";//个人本地 // protected static final String drivePath = "D:\\chromedriver_win32\\chromedriver.exe";//个人本地
protected static final String drivePath = "D:\\bns\\chromedriver_win32\\chromedriver.exe";//宿州客户地址 protected static final String drivePath = "D:\\bns\\chromedriver_win32\\chromedriver.exe";//宿州客户地址

View File

@ -68,7 +68,7 @@ public class DutyDailyCheck {
//同意审核按钮点击 //同意审核按钮点击
WebElement tyCheckBtn=webDriver.findElement(By.xpath("//*[@id=\"app\"]/div/section/div/div[4]/div[1]/div[19]/button[4]")); WebElement tyCheckBtn=webDriver.findElement(By.xpath("//*[@id=\"app\"]/div/section/div/div[4]/div[1]/div[16]/button[4]"));
if(tyCheckBtn.isDisplayed()){ if(tyCheckBtn.isDisplayed()){
//存在 //存在
log.info("同意审核按钮存在-----------"); log.info("同意审核按钮存在-----------");

File diff suppressed because it is too large Load Diff

View File

@ -57,7 +57,7 @@ public class DutyLogIOp {
//退出当前iframe,进入到日报编辑iframe //退出当前iframe,进入到日报编辑iframe
webDriver.switchTo().defaultContent(); webDriver.switchTo().defaultContent();
log.info("退出当前iframe----------"); log.info("退出当前iframe----------");
Thread.sleep(1500); Thread.sleep(5500);
//定位日志编辑iframe的标签 //定位日志编辑iframe的标签
WebElement dutyEditIframe = webDriver.findElement(By.id("add-local-zbrzbz")); WebElement dutyEditIframe = webDriver.findElement(By.id("add-local-zbrzbz"));

View File

@ -3,10 +3,7 @@ package com.bonus.autoweb.task;
import com.bonus.autoweb.DateTimeUtils; import com.bonus.autoweb.DateTimeUtils;
import com.bonus.autoweb.GetBasicData; import com.bonus.autoweb.GetBasicData;
import com.bonus.autoweb.base.*; import com.bonus.autoweb.base.*;
import org.apache.poi.ss.usermodel.Cell; import org.apache.poi.ss.usermodel.*;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.xssf.usermodel.XSSFWorkbook; import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.openqa.selenium.By; import org.openqa.selenium.By;
import org.openqa.selenium.WebElement; import org.openqa.selenium.WebElement;
@ -18,8 +15,12 @@ import java.io.BufferedReader;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.FileReader; import java.io.FileReader;
import java.io.IOException; import java.io.IOException;
import java.math.BigDecimal;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/** /**
* 应急指挥中心打卡任务类 * 应急指挥中心打卡任务类
@ -164,39 +165,89 @@ public class AutoWebTask {
WebElement personLeaderNameEle = webDriver.findElement(By.xpath("//*[@id='pane-1']/div/div[3]/div/div/div[3" + WebElement personLeaderNameEle = webDriver.findElement(By.xpath("//*[@id='pane-1']/div/div[3]/div/div/div[3" +
"]/table/tbody/tr[1]/td[2]/div/div/p[1]")); "]/table/tbody/tr[1]/td[2]/div/div/p[1]"));
String personLeaderName = personLeaderNameEle.getText(); String personLeaderName = personLeaderNameEle.getText();
log.info("今日值班人员:" + personLeaderName); WebElement personLeaderPhoneEle = webDriver.findElement(By.xpath("//*[@id=\"pane-1\"]/div/div[3]/div/div/div[3]/table/tbody/tr[1]/td[3]/div/span"));
WebElement accountLeaderEle = webDriver.findElement(By.xpath("//*[@id='pane-1']/div/div[3]/div/div/div[3" + String personLeaderPhone = personLeaderPhoneEle.getText();
"]/table/tbody/tr[1]/td[2]/div/div/p[2]")); log.info("今日值班长:" + personLeaderName +";手机号:"+ personLeaderPhone);
String accountLeader = accountLeaderEle.getText();
//获取值班员账号姓名 账号名 // 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" + 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]")); "]/table/tbody/tr[2]/td[2]/div/div/p[1]"));
String personName = personNameEle.getText(); String personName = personNameEle.getText();
log.info("今日值班人员:" + personName); WebElement personPhoneEle = webDriver.findElement(By.xpath("//*[@id=\"pane-1\"]/div/div[3]/div/div/div[3]/table/tbody/tr[2]/td[3]/div/span"));
WebElement accountEle = webDriver.findElement(By.xpath("//*[@id='pane-1']/div/div[3]/div/div/div[3" + String personPhone = personPhoneEle.getText();
"]/table/tbody/tr[2]/td[2]/div/div/p[2]")); log.info("今日值班人员:" + personName +";手机号:"+ personPhone);
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); Thread.sleep(3000);
excelFile = new FileInputStream("D:\\bns\\config\\zhibanaccount.xlsx"); excelFile = new FileInputStream("D:\\bns\\config\\zhibanaccount.xlsx");
workbook = new XSSFWorkbook(excelFile); workbook = new XSSFWorkbook(excelFile);
Sheet datatypeSheet = workbook.getSheetAt(0); Sheet datatypeSheet = workbook.getSheetAt(0);
String personLeaderPassword = ""; String personLeaderPassword = "获取失败";
String personPassword = ""; String personPassword = "获取失败";
String account = "获取失败";
String accountLeader = "获取失败";
int rowNum = 0;
for (Row row : datatypeSheet) { for (Row row : datatypeSheet) {
String value = ""; StringBuilder lineValueBuilder = new StringBuilder();
for (Cell cell : row) { for (Cell cell : row) {
value += cell.getStringCellValue() + "]]]"; // value += cell.getStringCellValue() + "]]]";
if (cell.getCellType() == CellType.NUMERIC) {
String phone = translateToPlainStr(String.valueOf(cell.getNumericCellValue()));
lineValueBuilder.append(phone);
} else {
lineValueBuilder.append(cell.getStringCellValue());
} }
value = value.substring(0, value.length() - 3); // 除了最后一个单元格每个单元格后追加分隔符
if (value.contains(account)) { if (cell.getColumnIndex() < row.getLastCellNum() - 1) {
lineValueBuilder.append("]]]");
}
}
String value = String.valueOf(lineValueBuilder);
// log.info(value);
try{
if (value.contains(personPhone)) {
personPassword = value.split("]]]")[2]; personPassword = value.split("]]]")[2];
account = value.split("]]]")[1];
// matchedRecords.add(value);
// if (matchedRecords.size() == 1) {
// // 只有一个匹配的记录直接提取账号和密码信息
// String record = matchedRecords.get(0);
// personPassword = record.split("]]]")[2];
// account = record.split("]]]")[1];
// } else {
// for (String record : matchedRecords) {
// // 获取手机号或其他用于进一步判断的信息
// if (record.contains(personLeaderPhone)) {
// personPassword = record.split("]]]")[2];
// account = record.split("]]]")[1];
// }
// }
// }
} }
if (value.contains(accountLeader)) { }catch (IndexOutOfBoundsException ignored){
log.error("出现异常:"+personName+"账号内容出错,在表格的第"+rowNum+"行附近");
}
//值班长账号密码获取
try{
if (value.contains(personLeaderPhone)) {
personLeaderPassword = value.split("]]]")[2]; personLeaderPassword = value.split("]]]")[2];
accountLeader = value.split("]]]")[1];
} }
}catch (IndexOutOfBoundsException ignored){
log.error("出现异常:"+personLeaderName+"账号内容出错,在表格的第"+rowNum+"行附近");
} }
rowNum++;
}
AutoUtils.write("D:\\bns\\config\\今日值班账号.txt", "今日值班长账号:"+accountLeader+";密码:"+personLeaderPassword+"\n" + AutoUtils.write("D:\\bns\\config\\今日值班账号.txt", "今日值班长账号:"+accountLeader+";密码:"+personLeaderPassword+"\n" +
"今日值班员账号:"+account+";密码:"+personPassword+""); "今日值班员账号:"+account+";密码:"+personPassword+"");
excelFile.close(); excelFile.close();
@ -209,6 +260,25 @@ public class AutoWebTask {
return count; return count;
} }
public String translateToPlainStr(String number) {
String regEx="^([\\+|-]?\\d+(.{0}|.\\d+))[Ee]{1}([\\+|-]?\\d+)$";
// 编译正则表达式
Pattern pattern = Pattern.compile(regEx);
// 忽略大小写的写法
// Pattern pat = Pattern.compile(regEx, Pattern.CASE_INSENSITIVE);
Matcher matcher = pattern.matcher(number);
// 字符串是否与正则表达式相匹配
boolean rs = matcher.matches();
// 判断是否为字符串的科学计数法
if(rs){
// 科学计数法转数字
BigDecimal originValue = new BigDecimal(number);
// 数字转字符串
return originValue.toPlainString();
}
return number;
}
/** /**
* 交接班任务 * 交接班任务