删除 src/main/java/com/bonus/autoweb/task/AutoWebTask.java

This commit is contained in:
tqzhang 2024-05-07 16:48:53 +08:00
parent 3f303373bb
commit 82eae41a01
1 changed files with 0 additions and 420 deletions

View File

@ -1,420 +0,0 @@
package com.bonus.autoweb.task;
import com.bonus.autoweb.GetBasicData;
import com.bonus.autoweb.base.*;
import org.openqa.selenium.WebDriver;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
/**
* 应急指挥中心打卡任务类
*/
public class AutoWebTask {
Logger log = LoggerFactory.getLogger(AutoWebTask.class);
/**
* 打卡任务
*
* @param classes 班次1早班 2晚班
*/
public void dutyClockTask(int classes) {
log.info("开始打卡任务---------------------");
log.info("房万春开始打卡任务---------------------");
//使用房万春账号签到
dutySigin(classes, 1, DataConfig.USER_NAME2, DataConfig.PASS2);
try {
Thread.sleep(1000 * 2);
} catch (Exception e) {
log.error("打卡任务", e);
}
//使用韩宏宇账号签到
log.info("韩宏宇开始打卡任务---------------------");
dutySigin(classes, 1, DataConfig.USER_NAME1, DataConfig.PASS1);
}
/**
* 签到任务
*
* @param classes
* @param type
* @param userName
* @param pass
* @throws Exception
*/
public int dutySigin(int classes, int type, String userName, String pass) {
//打开浏览器进入应急指挥中心网站
AutoMain autoMain = new AutoMain();
int count = 0;
try {
autoMain.initDrive(2);
WebDriver webDriver = autoMain.getWebDriver();
autoMain.startAuto(userName, pass);
DutyClock dutyClock = new DutyClock(webDriver);
dutyClock.openDutyClock();
dutyClock.dutyClockOper(classes, type);
//关闭浏览器
autoMain.closeDrive();
count = 1;
} catch (Exception e) {
log.error("签到任务", e);
} finally {
autoMain.closeDrive();
}
return count;
}
/**
* 填报日志和日报任务
*
* @param type 1 早报 2晚报
*/
public int dutyAddDailyLogsTask(int type,String username,String password) {
log.info("开始日报填写任务---------------------");
//打开浏览器进入应急指挥中心网站
AutoMain autoMain = new AutoMain();
WebDriver webDriver;
int count = 0;
try {
autoMain.initDrive(1);
autoMain.startAuto(username, password);
webDriver = autoMain.getWebDriver();
//操作日报
DutyDailyOp ddo = new DutyDailyOp(webDriver);
ddo.openDutyDaily(type);
Thread.sleep(1000);
count = 1;
} catch (Exception e) {
log.error("日报填写任务", e);
}
try {
//日报审核工作
webDriver = autoMain.getWebDriver();
DutyDailyCheck dutyDailyCheck = new DutyDailyCheck(webDriver);
dutyDailyCheck.dutyCheckOp(type);
Thread.sleep(1000);
count = 1;
} catch (Exception e) {
count = 0;
log.error("日报审核工作", e);
} finally {
autoMain.closeDrive();
}
return count;
}
public int dutyAddLogsTask(int type,String username,String password) {
log.info("开始日志填写任务---------------------");
//打开浏览器进入应急指挥中心网站
int count = 0;
AutoMain autoMain = new AutoMain();
WebDriver webDriver;
try {
autoMain.initDrive(7);
autoMain.startAuto(username, password);
//操作日志
webDriver = autoMain.getWebDriver();
DutyLogIOp dlo = new DutyLogIOp(webDriver);
dlo.openDutyLog(type);
count = 1;
} catch (Exception e) {
count = 0;
log.error("操作日志任务", e);
}finally {
autoMain.closeDrive();
}
return count;
}
public int dutyChangeTask(int classes) {
log.info("开始交接班任务---------------------");
AutoMain autoMain = new AutoMain();
int count = 0;
try {
//打开浏览器进入应急指挥中心网站
autoMain.initDrive(7);
autoMain.startAuto(DataConfig.USER_NAME1, DataConfig.PASS1);
WebDriver webDriver = autoMain.getWebDriver();
DutyChangeShifts dutyChangeShifts = new DutyChangeShifts(webDriver);
//进行交班工作
try{
if (classes == 2) {
dutyChangeShifts.openChangeShifts();
dutyChangeShifts.dutychangeOper(1, 1);
} else {
dutyChangeShifts.changeDay();
}
}catch (Exception e){
log.error("交班工作已提交",e);
}
Thread.sleep(1000);
//进行接班工作
try {
log.info("开始进行第一次接班工作------------");
dutyChangeShifts.dutychangeOper(classes, 2);
Thread.sleep(1000);
}catch (Exception e){
log.error("接班工作111已提交",e);
}
try {
log.info("开始进行第二次接班工作------------");
dutyChangeShifts.dutychangeOper(classes, 2);
}catch (Exception e){
log.error("接班工作222已提交",e);
}
//关闭浏览器
autoMain.closeDrive();
count = 1;
} catch (Exception e) {
count = 0;
log.error("交接班任务:" + e);
} finally {
autoMain.closeDrive();
}
return count;
}
/**
* 交接班任务
*
* @param classes 班次1早班 2晚班
*/
public int dutyChangeTask1(int classes,String userName,String password) {
log.info("开始交班任务---------------------");
AutoMain autoMain = new AutoMain();
int count = 0;
WebDriver webDriver;
try {
//打开浏览器进入应急指挥中心网站
autoMain.initDrive(2);
autoMain.startAuto(userName, password);
webDriver = autoMain.getWebDriver();
DutyChangeShifts dutyChangeShifts = new DutyChangeShifts(webDriver);
//进行交班工作
if (classes == 2) {
dutyChangeShifts.openChangeShifts();
dutyChangeShifts.dutychangeOper(1, 1);
} else {
dutyChangeShifts.changeDay();
}
Thread.sleep(1000);
//关闭浏览器
autoMain.closeDrive();
count = 1;
} catch (Exception e) {
count = 0;
log.error("交接班任务:" + e);
} finally {
autoMain.closeDrive();
}
return count;
}
public int dutyChangeTask2(int classes,String userName,String password) {
log.info("开始接班任务---------------------");
AutoMain autoMain = new AutoMain();
WebDriver webDriver;
int count = 0;
try {
//打开浏览器进入应急指挥中心网站
autoMain.initDrive(2);
autoMain.startAuto(userName, password);
webDriver = autoMain.getWebDriver();
DutyChangeShifts dutyChangeShifts = new DutyChangeShifts(webDriver);
//进行接班工作
dutyChangeShifts.openChangeShifts();
dutyChangeShifts.dutychangeOper(classes, 2);
//关闭浏览器
autoMain.closeDrive();
count = 1;
} catch (Exception e) {
count = 0;
log.error("交接班任务:" + e);
} finally {
autoMain.closeDrive();
}
return count;
}
/**
* 签退任务
*
* @param classes 班次1早班 2晚班
*/
public int dutySignOutTask(int classes, String userName, String pass) {
log.info("开始签退任务---------------------");
AutoMain autoMain = new AutoMain();
int count = 0;
try {
//打开浏览器进入应急指挥中心网站
autoMain.initDrive(2);
autoMain.startAuto(userName, pass);
WebDriver webDriver = autoMain.getWebDriver();
DutyClock dutyClock = new DutyClock(webDriver);
if (classes == 1) {
dutyClock.changeDay();
} else {
dutyClock.dutyClockOper(1, 2);
}
//关闭浏览器
autoMain.closeDrive();
count = 1;
} catch (Exception e) {
count = 0;
log.error("签退任务", e);
} finally {
autoMain.closeDrive();
}
return count;
}
/**
* 定时获取基础数据
*/
public int getYuJingData(int classes) {
AutoMain autoMain = new AutoMain();
WebDriver webDriver;
int count = 0;
try {
autoMain.initDrive(2);
log.info("初始化驱动成功");
autoMain.startYuJingAuto(DataConfig.USER_NAME1, DataConfig.PASS1);
log.info("startYuJingAuto成功");
//获取基础数据
webDriver = autoMain.getWebDriver();
GetBasicData gbd = new GetBasicData(webDriver);
log.info("获取天气预警值启动----");
gbd.getYuJingBasicData(classes);
count = 1;
} catch (Exception e) {
count = 0;
log.error("获取基础数据任务", e);
}finally {
autoMain.closeDrive();
}
return count;
}
/**
* 预警行动
* @param classes
* @return
*/
public int getYuJingActionData(int classes) {
AutoMain autoMain = new AutoMain();
WebDriver webDriver;
int count = 0;
try {
autoMain.initDrive(2);
log.info("初始化驱动成功");
autoMain.startYuJingActionAuto(DataConfig.USER_NAME1, DataConfig.PASS1);
log.info("startYuJingAuto成功");
//获取基础数据
webDriver = autoMain.getWebDriver();
GetBasicData gbd = new GetBasicData(webDriver);
log.info("获取天气预警值启动----");
gbd.getYuJingActionBasicData(classes);
count = 1;
} catch (Exception e) {
count = 0;
log.error("获取基础数据任务", e);
}finally {
autoMain.closeDrive();
}
return count;
}
public int getCaoLianData(int classes) {
AutoMain autoMain = new AutoMain();
WebDriver webDriver;
int count = 0;
try {
autoMain.initDrive(2);
autoMain.startCaoLianAuto(DataConfig.USER_NAME1, DataConfig.PASS1);
//获取基础数据
webDriver = autoMain.getWebDriver();
GetBasicData gbd = new GetBasicData(webDriver);
gbd.getCaoLianBasicData(classes);
count = 1;
} catch (Exception e) {
count = 0;
log.error("获取基础操练数据任务", e);
}finally {
autoMain.closeDrive();
}
return count;
}
public static void main(String[] args) {
// String content = read("C:\\Users\\24526\\Desktop\\宿州部分代码实例\\七个公司资源核查情况.txt");
// String[] array = content.toString().split("资源核查情况:");
//
// ArrayList<String> list = new ArrayList<String>();
// list.add("1");
// list.add("2");
// list.add("3");
// list.add("4");
// list.add("5");
// list.add("6");
// list.add("7");
// // 打乱顺序
// Collections.shuffle(list);
//// // 遍历取出元素
//// for (String day : list) {
//// System.out.println(day);
//// }
// System.out.println(list.get(0));
// System.out.println(array[Integer.parseInt(list.get(0))].toString());
}
public static String read(String filename){
String line;
StringBuilder content = new StringBuilder();
try {
BufferedReader reader = new BufferedReader(new FileReader(filename));
while ((line = reader.readLine()) != null) {
content.append(line).append("\n");
}
reader.close();
} catch (IOException e) {
System.out.println("An error occurred while reading the text file.");
e.printStackTrace();
}
return content.toString();
}
public int addExercisePlan(String type, String company,int code, String userName, String pass) {
AutoMain autoMain = new AutoMain();
WebDriver webDriver;
int count = 0;
try {
autoMain.initDrive(7);
autoMain.startAddExercisePlan(userName, pass);
//获取基础数据
webDriver = autoMain.getWebDriver();
GetBasicData gbd = new GetBasicData(webDriver);
gbd.addExercisePlan(type,company,code);
count = 1;
} catch (Exception e) {
count = 0;
log.error("获取基础操练数据任务", e);
}finally {
autoMain.closeDrive();
}
return count;
}
}