修改java文件为class文件
This commit is contained in:
parent
9087c0aeee
commit
0bb0575106
|
|
@ -2,9 +2,6 @@ package com.bonus.autoweb;
|
|||
|
||||
import com.bonus.autoweb.UI.entity.DailyBean;
|
||||
import com.bonus.autoweb.UI.entity.LogBean;
|
||||
import com.bonus.autoweb.UI.frame.StringHelper;
|
||||
import com.bonus.autoweb.base.AutoMain;
|
||||
import com.bonus.autoweb.base.AutoUtils;
|
||||
import com.bonus.autoweb.base.DataConfig;
|
||||
import com.thoughtworks.xstream.XStream;
|
||||
import com.thoughtworks.xstream.io.json.JettisonMappedXmlDriver;
|
||||
|
|
@ -14,17 +11,17 @@ import org.openqa.selenium.WebElement;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import javax.activation.DataHandler;
|
||||
import java.io.*;
|
||||
import java.nio.charset.Charset;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
|
||||
import static java.lang.Integer.parseInt;
|
||||
import java.util.Date;
|
||||
import java.util.HashSet;
|
||||
import java.util.Random;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* 项目名称: autoWebForGuoYang
|
||||
* 项目名称: autoWebForSuZhou
|
||||
* 文件名称: getBasicData
|
||||
* 文件描述: @Description: 定时获取新一代应急系统内的数据
|
||||
* 创建人: @author tqzhang
|
||||
|
|
@ -38,6 +35,8 @@ public class GetBasicData {
|
|||
this.webDriver = webDriver;
|
||||
}
|
||||
|
||||
int num;
|
||||
|
||||
/**
|
||||
* 解决乱码问题
|
||||
*
|
||||
|
|
@ -72,23 +71,36 @@ public class GetBasicData {
|
|||
* @author tqzhang
|
||||
* @data 2024/01/16
|
||||
*/
|
||||
public static void getYuJingActionBasicData(int classes) throws ParseException, InterruptedException {
|
||||
public void getYuJingActionBasicData(int classes) throws ParseException, InterruptedException {
|
||||
Thread.sleep(5000);
|
||||
// webDriver.findElement(By.xpath("//*[@id=\"app\"]/section/header/form/div/div[2]/button[1]")).click();
|
||||
// Thread.sleep(300);
|
||||
// String date1 = DateTimeUtils.getLastDayYYYYMMDD() + " 00:00";
|
||||
// String date2 = DateTimeUtils.getLastDayYYYYMMDD() + " 23:59";
|
||||
//点击按钮 展示查询选项
|
||||
webDriver.findElement(By.xpath("//*[@id=\"app\"]/section/header/form/div/div[2]/button[1]")).click();
|
||||
Thread.sleep(300);
|
||||
//设置时间段
|
||||
String date1 = DateTimeUtils.getCurrentDay() + " 00:00";
|
||||
String date2 = DateTimeUtils.getCurrentDay() + " 23:59";
|
||||
// if (classes == 2) {
|
||||
// date1 = DateTimeUtils.getCurrentDay() + " 00:00";
|
||||
// date2 = DateTimeUtils.getCurrentDay() + " 23:59";
|
||||
// }
|
||||
// webDriver.findElement(By.xpath("//*[@id=\"app\"]/section/header/form/div/div[1]/div[3]/div[1]/div/div/div/input[1]")).sendKeys(date1);
|
||||
// Thread.sleep(300);
|
||||
// webDriver.findElement(By.xpath("//*[@id=\"app\"]/section/header/form/div/div[1]/div[3]/div[1]/div/div/div/input[2]")).sendKeys(date2);
|
||||
// Thread.sleep(300);
|
||||
// webDriver.findElement(By.xpath("//*[@id=\"app\"]/section/header/form/div/div[2]/button[2]")).click();
|
||||
// Thread.sleep(1000);
|
||||
// WebElement numEle = webDriver.findElement(By.xpath("//*[@id=\"tab-已完工\"]/div/span"));
|
||||
//将时间放入时间框
|
||||
webDriver.findElement(By.xpath("//*[@id=\"app\"]/section/header/form/div/div[1]/div[3]/div[1]/div/div/div/input[1]")).sendKeys(date1);
|
||||
Thread.sleep(300);
|
||||
webDriver.findElement(By.xpath("//*[@id=\"app\"]/section/header/form/div/div[1]/div[3]/div[1]/div/div/div/input[2]")).sendKeys(date2);
|
||||
Thread.sleep(300);
|
||||
//点击搜索按钮 搜索当天的数据
|
||||
webDriver.findElement(By.xpath("//*[@id=\"app\"]/section/header/form/div/div[2]/button[2]")).click();
|
||||
Thread.sleep(1000);
|
||||
//获取已完工的数量
|
||||
WebElement numEle = webDriver.findElement(By.xpath("//*[@id=\"tab-已完工\"]/div/span"));
|
||||
//如果数量等于0 过滤
|
||||
if (Integer.parseInt(numEle.getText()) > 0) {
|
||||
//对人员进行塞值为0
|
||||
} else {
|
||||
//获取
|
||||
}
|
||||
|
||||
|
||||
DailyBean dailyBean = readDailyBean("morning_daily");
|
||||
DailyBean dailyBean2 = readDailyBean("evening_daily");
|
||||
LogBean logBean = readDutyBean();
|
||||
|
|
@ -310,7 +322,7 @@ public class GetBasicData {
|
|||
//判断是否有发布数据
|
||||
WebElement numClasses = webDriver.findElement(By.xpath("//*[@id=\"tab-3\"]/div/span"));
|
||||
if ("0".equals(numClasses.getText())) {
|
||||
code = "利辛县未发布预警,";
|
||||
code = "泗县未发布预警,";
|
||||
} else {
|
||||
WebElement weatherEle = webDriver.findElement(By.xpath("/html/body/div[1]/div/section/main/div[1]/div[2]/div[1]/section/main/div/div[3]/table/tbody/tr[1]/td[6]/div/div"));
|
||||
Thread.sleep(300);
|
||||
|
|
@ -330,7 +342,7 @@ public class GetBasicData {
|
|||
Date date1 = inputFormat.parse(endTime);
|
||||
|
||||
SimpleDateFormat outputFormat = new SimpleDateFormat("MM月dd日");
|
||||
code = "利辛县供电公司发布" + weatherEle.getText() + "预警1项,";
|
||||
code = "泗县供电公司发布" + weatherEle.getText() + "预警1项,";
|
||||
}
|
||||
|
||||
log.info("code:" + code);
|
||||
|
|
@ -339,8 +351,10 @@ public class GetBasicData {
|
|||
LogBean logBean = readDutyBean();
|
||||
String dailyContent = resolveGarbledCode("E:\\bns\\config\\日报基本信息.txt");
|
||||
String logContent = resolveGarbledCode("E:\\bns\\config\\日志基本信息.txt");
|
||||
String videoContent = resolveGarbledCode("D:\\bns\\config\\变电站名称.txt");
|
||||
String[] dailyContentArrayArray = dailyContent.split("--头部不可修改--");
|
||||
String[] logContentArrayArray = logContent.split("--头部不可修改--");
|
||||
String[] videoContentArrayArray = videoContent.split("--头部不可修改--");
|
||||
log.info("dailyContent:" + dailyContent);
|
||||
log.info("logContent:" + logContent);
|
||||
log.info("logContentArrayArray[18]:" + logContentArrayArray[18]);
|
||||
|
|
@ -360,15 +374,15 @@ public class GetBasicData {
|
|||
|
||||
//一、总体情况
|
||||
dailyBean.setOverall(data + dailyContentArrayArray[2].trim());
|
||||
dailyBean.setWarning_company(code + dailyContentArrayArray[18]);
|
||||
dailyBean.setWarning_company(code + dailyContentArrayArray[19]);
|
||||
} else {
|
||||
data = data2 + "07:00至" + data2 + "18:00,";
|
||||
|
||||
dailyBean2.setOverall(data + dailyContentArrayArray[2].trim());
|
||||
dailyBean2.setWarning_company(code + dailyContentArrayArray[18]);
|
||||
dailyBean2.setWarning_company(code + dailyContentArrayArray[19]);
|
||||
}
|
||||
|
||||
logBean.setWarning_disposal_title("利辛县未发布预警,".equals(code) ? "今日预警情况" : "预警一项");
|
||||
logBean.setWarning_disposal_title("泗县未发布预警,".equals(code) ? "今日预警情况" : "预警一项");
|
||||
logBean.setWarning_disposal_content(logData + code + logContentArrayArray[20]);
|
||||
insertData(null, logBean, "log");
|
||||
log.info("天气预警日志更新完成");
|
||||
|
|
@ -379,7 +393,7 @@ public class GetBasicData {
|
|||
log.info("天气预警日报更新完成");
|
||||
}
|
||||
|
||||
public void getCaoLianBasicData(int classes) throws InterruptedException, ParseException {
|
||||
public void getCaoLianBasicData(int classes) throws InterruptedException, ParseException, IOException {
|
||||
Thread.sleep(5000);
|
||||
DailyBean dailyBean = readDailyBean("morning_daily");
|
||||
DailyBean dailyBean2 = readDailyBean("evening_daily");
|
||||
|
|
@ -387,21 +401,66 @@ public class GetBasicData {
|
|||
String dailyContent = resolveGarbledCode("E:\\bns\\config\\日报基本信息.txt");
|
||||
String checkContent = resolveGarbledCode("E:\\bns\\config\\资源核查情况.txt");
|
||||
String logContent = resolveGarbledCode("E:\\bns\\config\\日志基本信息.txt");
|
||||
String videoContent = resolveGarbledCode("E:\\bns\\config\\变电站名称.txt");
|
||||
String videoContent = resolveGarbledCode("E:\\bns\\config\\供电所名称.txt");
|
||||
String[] dailyContentArrayArray = dailyContent.split("--头部不可修改--");
|
||||
String[] logContentArrayArray = logContent.split("--头部不可修改--");
|
||||
String[] checkContentArrayArray = checkContent.split("资源核查情况:");
|
||||
String[] videoContentArrayArray = videoContent.split("--头部不可修改--");
|
||||
// log.info("读取本地模板数据成功");
|
||||
log.info("读取本地模板数据成功");
|
||||
|
||||
|
||||
// OkHttpClient client = new OkHttpClient().newBuilder()
|
||||
// .connectTimeout(180, TimeUnit.SECONDS)
|
||||
// .readTimeout(180, TimeUnit.SECONDS)
|
||||
// .writeTimeout(180, TimeUnit.SECONDS)
|
||||
// .build();
|
||||
//
|
||||
String dataUrl = DataConfig.weatherUrl + DateTimeUtils.getCurrentDay();
|
||||
// log.info("dataUrl:" + dataUrl);
|
||||
// Request request = new Request.Builder()
|
||||
// .url(dataUrl)
|
||||
// .get()
|
||||
// .build();
|
||||
// Response response;
|
||||
// String result;
|
||||
// String city;
|
||||
// String weatherNoon;
|
||||
// String weatherNight;
|
||||
// String minTemperature;
|
||||
// String maxTemperature;
|
||||
// try {
|
||||
// response = client.newCall(request).execute();
|
||||
// log.info("response:" + response);
|
||||
// result = response.body().string();
|
||||
// log.info("result:" + result);
|
||||
// Gson gson = new Gson();
|
||||
// WeatherData weatherData = gson.fromJson(result, WeatherData.class);
|
||||
// log.info("------weatherData:" + weatherData);
|
||||
// WeatherData.WeatherDataChild weatherDataChild = weatherData.getData();
|
||||
// log.info("------weatherDataChild:" + weatherDataChild);
|
||||
// city = weatherDataChild.getCity();
|
||||
// log.info("city:" + city);
|
||||
// weatherNoon = weatherDataChild.getWeatherNoon();
|
||||
// log.info("weatherNoon:" + weatherNoon);
|
||||
// weatherNight = weatherDataChild.getWeatherNight();
|
||||
// log.info("weatherNight:" + weatherNight);
|
||||
// minTemperature = weatherDataChild.getMinTemperature();
|
||||
// log.info("minTemperature:" + minTemperature);
|
||||
// maxTemperature = weatherDataChild.getMaxTemperature();
|
||||
// log.info("maxTemperature:" + maxTemperature);
|
||||
// } catch (IOException e) {
|
||||
// throw new IOException("天气get请求失败", e);
|
||||
// }
|
||||
|
||||
//昨天的日期
|
||||
String data1 = DateTimeUtils.getLastDay();
|
||||
// log.info("昨天的日期:" + data1);
|
||||
log.info("昨天的日期:" + data1);
|
||||
//今天的日期
|
||||
String data2 = DateTimeUtils.getCurrentDay2();
|
||||
// log.info("今天的日期:" + data2);
|
||||
log.info("今天的日期:" + data2);
|
||||
//明天的日期
|
||||
String data3 = DateTimeUtils.getTomorrowDate();
|
||||
// log.info("明天的日期:" + data2);
|
||||
log.info("明天的日期:" + data2);
|
||||
//日志时间
|
||||
String logData = data2 + "08:15至" + data3 + "8:15,";
|
||||
/**
|
||||
|
|
@ -425,6 +484,124 @@ public class GetBasicData {
|
|||
} else {
|
||||
time = DateTimeUtils.getCurrentDay();
|
||||
}
|
||||
|
||||
// webDriver.findElement(By.xpath("/html/body/div/div/header/form/div[4]/div/button[1]")).click();
|
||||
// Thread.sleep(800);
|
||||
// webDriver.findElement(By.xpath("/html/body/div[1]/div/header/form/div[6]/div/div/input[1]")).sendKeys(DateTimeUtils.getCurrentDay());
|
||||
// Thread.sleep(800);
|
||||
// webDriver.findElement(By.xpath("/html/body/div[1]/div/header/form/div[6]/div/div/input[2]")).sendKeys(DateTimeUtils.getCurrentDay());
|
||||
// Thread.sleep(800);
|
||||
// webDriver.findElement(By.xpath("/html/body/div[1]/div/header/form/div[8]/div/button[2]")).click();
|
||||
// Thread.sleep(2000);
|
||||
// int i = 1;
|
||||
// while (tf) {
|
||||
// Thread.sleep(10000);
|
||||
// WebElement numberEle = webDriver.findElement(By.xpath("/html/body/div[1]/div/main/div/div/footer/span"));
|
||||
// log.info("numberEle:" + numberEle.getText());
|
||||
//// String num = numberEle.getText().substring(2, 3);
|
||||
// String num1 = numberEle.getText().substring(2, numberEle.getText().length());
|
||||
// String num = num1.substring(0, num1.length() - 2);
|
||||
// log.info("num:" + num);
|
||||
// if ("0".equals(num)) {
|
||||
// tf = false;
|
||||
// } else {
|
||||
// WebElement timeEle;
|
||||
//// if ("1".equals(num)) {
|
||||
//// timeEle = webDriver.findElement(By.xpath("/html/body/div/div/main/div/div/div[2]/div/div[3]/table/tbody/tr/td[8]/div"));
|
||||
//// } else {
|
||||
// timeEle = webDriver.findElement(By.xpath("/html/body/div[1]/div/main/div/div/div[2]/div/div[3" +
|
||||
// "]/table/tbody/tr[" + i + "]/td[8]/div"));
|
||||
//// }
|
||||
//
|
||||
// System.out.println(timeEle.getText());
|
||||
// if (time.equals(timeEle.getText())) {
|
||||
// //操练环节 -通信测试 日常操练
|
||||
// WebElement drillSessionEle;
|
||||
//// if ("1".equals(num)) {
|
||||
//// drillSessionEle = webDriver.findElement(By.xpath("/html/body/div/div/main/div/div/div[2]/div/div[3]/table/tbody/tr/td[6]/div"));
|
||||
//// } else {
|
||||
// drillSessionEle = webDriver.findElement(By.xpath("/html/body/div[1]/div/main/div/div/div[2" +
|
||||
// "]/div/div[3]/table/tbody/tr[" + i + "]/td[6]/div"));
|
||||
//// }
|
||||
// log.info("操练环节:" + drillSessionEle.getText());
|
||||
// //供电公司
|
||||
// WebElement powerSupplyCompaniesEle;
|
||||
//// if ("1".equals(num)) {
|
||||
//// powerSupplyCompaniesEle = webDriver.findElement(By.xpath("/html/body/div/div/main/div/div/div[2]/div/div[3]/table/tbody/tr/td[5]/div"));
|
||||
//// } else {
|
||||
// powerSupplyCompaniesEle = webDriver.findElement(By.xpath("/html/body/div[1]/div/main/div/div" +
|
||||
// "/div[2]/div/div[3]/table/tbody/tr[" + i + "]/td[5]/div"));
|
||||
//// }
|
||||
// log.info("供电公司:" + powerSupplyCompaniesEle.getText());
|
||||
// if ("通信测试".equals(drillSessionEle.getText())) {
|
||||
// communicationTestNum++;
|
||||
// communicationTestName1 += getDailyName(powerSupplyCompaniesEle.getText()) + "、";
|
||||
// } else if ("重要站线视频连线检查".equals(drillSessionEle.getText())) {
|
||||
// dailyExercisesNum++;
|
||||
//// dailyExercisesName1 += powerSupplyCompaniesEle.getText().substring(0, powerSupplyCompaniesEle.getText().length() - 4) + "、";
|
||||
// dailyExercisesName1 += getDailyName(powerSupplyCompaniesEle.getText()) + "、";
|
||||
// } else {
|
||||
// dailyExercisesNum++;
|
||||
//// dailyExercisesName2 += powerSupplyCompaniesEle.getText().substring(0, powerSupplyCompaniesEle.getText().length() - 4) + "、";
|
||||
// WebElement ele = webDriver.findElement(By.xpath("/html/body/div[1]/div/main/div/div/div[2" +
|
||||
// "]/div/div[3]/table/tbody/tr[" + i + "]/td[7]/div"));
|
||||
// if ("物资".equals(ele.getText()))
|
||||
// materialName += getDailyName(powerSupplyCompaniesEle.getText()) + "、";
|
||||
// if ("车辆".equals(ele.getText()))
|
||||
// carName += getDailyName(powerSupplyCompaniesEle.getText()) + "、";
|
||||
// if ("队伍".equals(ele.getText()))
|
||||
// contingentName += getDailyName(powerSupplyCompaniesEle.getText()) + "、";
|
||||
// dailyExercisesName2 += getDailyName(powerSupplyCompaniesEle.getText()) + "、";
|
||||
// }
|
||||
// int x = parseInt(num);
|
||||
// if (i == parseInt(num)) {
|
||||
// tf = false;
|
||||
// }
|
||||
// i++;
|
||||
// } else {
|
||||
// tf = false;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// log.info("communicationTestName1:" + communicationTestName1);
|
||||
// if (communicationTestNum > 0) {
|
||||
// communicationTestName = "今日市公司本部对所属" + communicationTestNum + "家县公司(" + communicationTestName1.substring(0, communicationTestName1.length() - 1) + ")进行通信测试";
|
||||
// } else {
|
||||
// communicationTestName = "今日市公司本部对所属县公司无通信测试";
|
||||
// }
|
||||
// if (dailyExercisesName1.length() > 0) {
|
||||
// dailyExercisesName1 = dailyExercisesName1.substring(0, dailyExercisesName1.length() - 1);
|
||||
// }
|
||||
// if (dailyExercisesName2.length() > 0) {
|
||||
// dailyExercisesName2 = dailyExercisesName2.substring(0, dailyExercisesName2.length() - 1);
|
||||
// }
|
||||
// String fourElementVerification = "";
|
||||
// if (materialName.length() > 0) {
|
||||
// materialName = materialName.substring(0, materialName.length() - 1);
|
||||
// fourElementVerification += materialName + "公司四要素物资核查、";
|
||||
// }
|
||||
// if (carName.length() > 0) {
|
||||
// carName = carName.substring(0, carName.length() - 1);
|
||||
// fourElementVerification += carName + "公司四要素车辆核查、";
|
||||
// }
|
||||
// if (contingentName.length() > 0) {
|
||||
// contingentName = contingentName.substring(0, contingentName.length() - 1);
|
||||
// fourElementVerification += contingentName + "公司四要素队伍核查、";
|
||||
// }
|
||||
// if (dailyExercisesName1.length() > 0 && dailyExercisesName2.length() > 0) {
|
||||
// dailyExercisesName = "今日市公司本部对所属" + dailyExercisesNum + "家县公司进行日常操练(" + fourElementVerification + dailyExercisesName1 + "公司重要站连线检查)";
|
||||
// } else if (dailyExercisesName1.length() == 0 && dailyExercisesName2.length() > 0) {
|
||||
// dailyExercisesName = "今日市公司本部对所属" + dailyExercisesNum + "家县公司进行日常操练(" + fourElementVerification + ")";
|
||||
// } else if (dailyExercisesName1.length() > 0 && fourElementVerification.length() == 0) {
|
||||
// dailyExercisesName = "今日市公司本部对所属" + dailyExercisesNum + "家县公司进行日常操练(" + dailyExercisesName1 + "公司重要站连线检查)";
|
||||
// } else {
|
||||
// dailyExercisesName = "今日市公司本部对所属" + dailyExercisesNum + "家县公司进行日常操练";
|
||||
// }
|
||||
//// dailyExercisesName = "今日市公司本部对所属" + 0 + "家县公司进行日常操练";
|
||||
// log.info("communicationTestName:" + communicationTestName);
|
||||
// log.info("dailyExercisesName:" + dailyExercisesName);
|
||||
// log.info("communicationTestNum:" + communicationTestNum);
|
||||
// log.info("dailyExercisesNum:" + dailyExercisesNum);
|
||||
String type = "";
|
||||
Random rand = new Random();
|
||||
Set<Integer> generated = new HashSet<>();
|
||||
|
|
@ -433,15 +610,15 @@ public class GetBasicData {
|
|||
// As we're adding to a set, this will automatically do a containment check
|
||||
generated.add(next);
|
||||
}
|
||||
StringBuilder video = new StringBuilder();
|
||||
for (Integer integer : generated) {
|
||||
video.append(videoContentArrayArray[integer]).append("、");
|
||||
}
|
||||
// StringBuilder video = new StringBuilder();
|
||||
// for (Integer integer : generated) {
|
||||
// video.append(videoContentArrayArray[integer]).append("、");
|
||||
// }
|
||||
if (classes == 1) {
|
||||
type = "morning_daily";
|
||||
//早报
|
||||
boolean t = true;
|
||||
int num = getRandom(0, 10);
|
||||
num = getRandom(1, 11);
|
||||
String data = data2 + "18:00至" + data3 + "07:00,";
|
||||
|
||||
//二、重要事项
|
||||
|
|
@ -449,8 +626,8 @@ public class GetBasicData {
|
|||
//三、安全生产情况
|
||||
dailyBean.setSafety_production(data + dailyContentArrayArray[6].trim());
|
||||
//四、值班员日常工作情况
|
||||
dailyBean.setPersonnel_daily_work(data + dailyContentArrayArray[8].trim() + "(5)资源核查情况:" + checkContentArrayArray[num].trim()
|
||||
+ "(6)检查"+video+"视频显示清晰,无异常情况(7)09:00-11:00,值班人员视频轮询供电所值班情况。");
|
||||
|
||||
dailyBean.setPersonnel_daily_work(data + dailyContentArrayArray[8].replace("@@@@@", videoContentArrayArray[num].trim()));
|
||||
//五、供电保障情况
|
||||
//(一)今日重大活动保电情况
|
||||
dailyBean.setPower_guarantee_today_work(dailyContentArrayArray[11]);
|
||||
|
|
@ -476,58 +653,57 @@ public class GetBasicData {
|
|||
|
||||
insertData(dailyBean, null, type);
|
||||
|
||||
// log.info("日报数据更新完成");
|
||||
log.info("日报数据更新完成");
|
||||
//事件监测内容
|
||||
logBean.setEvent_detection_content(logData + logContentArrayArray[3].trim());
|
||||
logBean.setEvent_detection_title(logContentArrayArray[2].trim());
|
||||
// logBean.setEvent_detection_content(data + logContentArrayArray[3].trim() + data2 + logContentArrayArray[4].trim());
|
||||
logBean.setEvent_detection_content(logData + logContentArrayArray[3].trim());
|
||||
logBean.setPower_work_title(logContentArrayArray[5]);
|
||||
logBean.setPower_work_content(logData + logContentArrayArray[6]);
|
||||
logBean.setResource_check_title(logContentArrayArray[8]);
|
||||
logBean.setResource_check_content(logData + logContentArrayArray[9]);
|
||||
logBean.setCommunications_test_title(logContentArrayArray[10]);
|
||||
logBean.setCommunications_test_content(logContentArrayArray[11]);
|
||||
logBean.setDaily_operation_title(logContentArrayArray[13]);
|
||||
logBean.setDaily_operation_content(logContentArrayArray[14]);
|
||||
logBean.setDaily_submission_title(logContentArrayArray[16]);
|
||||
logBean.setDaily_submission_content(logData + logContentArrayArray[17]);
|
||||
logBean.setGeneral_chronicles_title(logContentArrayArray[21]);
|
||||
logBean.setGeneral_chronicles_content(logContentArrayArray[22]);
|
||||
logBean.setResource_check_content(logData + logContentArrayArray[9].replace("@@@@@", videoContentArrayArray[num].trim()));
|
||||
logBean.setCommunications_test_title(logContentArrayArray[11]);
|
||||
logBean.setCommunications_test_content(logData + logContentArrayArray[12].replace("@@@@@", videoContentArrayArray[num].trim()));
|
||||
logBean.setDaily_operation_title(logContentArrayArray[14]);
|
||||
logBean.setDaily_operation_content(logData + logContentArrayArray[15]);
|
||||
logBean.setDaily_submission_title(logContentArrayArray[17]);
|
||||
logBean.setDaily_submission_content(logData + logContentArrayArray[18]);
|
||||
logBean.setGeneral_chronicles_title(logContentArrayArray[22]);
|
||||
logBean.setGeneral_chronicles_content(logContentArrayArray[23]);
|
||||
insertData(null, logBean, "log");
|
||||
log.info("日志数据更新完成");
|
||||
log.info("日报数据:{}", dailyBean);
|
||||
log.info("日志数据:{}", logBean);
|
||||
log.info("日报数据:" + dailyBean);
|
||||
log.info("日志数据:" + logBean);
|
||||
} else {
|
||||
type = "evening_daily";
|
||||
//晚报
|
||||
boolean t = true;
|
||||
int num = getRandom(1, 3);
|
||||
// int num = getRandom(1, 11);
|
||||
String data = data2 + "07:00至" + data2 + "18:00,";
|
||||
//一、总体情况
|
||||
// dailyBean2.setOverall(data + dailyContentArrayArray[2].trim() + data2 + "17:30," + dailyContentArrayArray[3].trim());
|
||||
//二、重要事项
|
||||
dailyBean2.setImportant_matters(data + dailyContentArrayArray[4].trim());
|
||||
dailyBean.setImportant_matters(data + dailyContentArrayArray[4].trim());
|
||||
//三、安全生产情况
|
||||
dailyBean2.setSafety_production(data + dailyContentArrayArray[6].trim());
|
||||
dailyBean.setSafety_production(data + dailyContentArrayArray[6].trim());
|
||||
//四、值班员日常工作情况
|
||||
dailyBean2.setPersonnel_daily_work(data + dailyContentArrayArray[8].trim() + "(5)资源核查情况:" + checkContentArrayArray[num].trim()
|
||||
+ "(6)检查"+video+"视频显示清晰,无异常情况(7)09:00-11:00,值班人员视频轮询供电所值班情况。");
|
||||
|
||||
dailyBean.setPersonnel_daily_work(data + dailyContentArrayArray[8].replace("@@@@@", videoContentArrayArray[num].trim()));
|
||||
//五、供电保障情况
|
||||
//(一)今日重大活动保电情况
|
||||
dailyBean2.setPower_guarantee_today_work(dailyContentArrayArray[11]);
|
||||
dailyBean.setPower_guarantee_today_work(dailyContentArrayArray[11]);
|
||||
//(二)明日重大活动保电安排
|
||||
dailyBean2.setPower_guarantee_tomorrow_work(dailyContentArrayArray[13]);
|
||||
dailyBean.setPower_guarantee_tomorrow_work(dailyContentArrayArray[13]);
|
||||
//(三)今日疫情防控应急保电情况
|
||||
dailyBean2.setPower_guarantee_today_pestilence(dailyContentArrayArray[15]);
|
||||
dailyBean.setPower_guarantee_today_pestilence(dailyContentArrayArray[15]);
|
||||
//六、预警及应急响应情况
|
||||
//(一)公司预警情况 --另外一个方法使用
|
||||
|
||||
//(二)公司应急响应情况
|
||||
dailyBean2.setWarning_company_impatient(data + dailyContentArrayArray[20]);
|
||||
dailyBean.setWarning_company_impatient(data + dailyContentArrayArray[20]);
|
||||
//(三)社会突发事件救援及处置情况
|
||||
dailyBean2.setWarning_society_emergency(data + dailyContentArrayArray[22]);
|
||||
dailyBean.setWarning_society_emergency(data + dailyContentArrayArray[22]);
|
||||
//七、其他情况说明
|
||||
dailyBean2.setOther_situations(data + dailyContentArrayArray[24]);
|
||||
dailyBean.setOther_situations(data + dailyContentArrayArray[24]);
|
||||
//附件表一
|
||||
dailyBean2.getOneBean().setExercise_person_num(getRandom(1, 50) + "");
|
||||
dailyBean2.getOneBean().setExercise_vehicle_num(getRandom(1, 20) + "");
|
||||
|
|
@ -537,23 +713,27 @@ public class GetBasicData {
|
|||
|
||||
insertData(dailyBean2, null, type);
|
||||
|
||||
// log.info("日报数据更新完成");
|
||||
logBean.setEvent_detection_title(logContentArrayArray[2].trim());
|
||||
log.info("日报数据更新完成");
|
||||
//事件监测内容
|
||||
logBean.setEvent_detection_title(logContentArrayArray[2].trim());
|
||||
logBean.setEvent_detection_content(logData + logContentArrayArray[3].trim());
|
||||
// logBean.setEvent_detection_content(data + logContentArrayArray[3].trim() + data2 + logContentArrayArray[4].trim());
|
||||
logBean.setPower_work_title(logContentArrayArray[5]);
|
||||
logBean.setPower_work_content(logData + logContentArrayArray[6]);
|
||||
logBean.setResource_check_title(logContentArrayArray[8]);
|
||||
logBean.setResource_check_content(logData + checkContentArrayArray[num]);
|
||||
logBean.setCommunications_test_title(logContentArrayArray[10]);
|
||||
logBean.setCommunications_test_content(logContentArrayArray[11]);
|
||||
logBean.setDaily_operation_title(logContentArrayArray[13]);
|
||||
logBean.setDaily_operation_content(logContentArrayArray[14]);
|
||||
logBean.setDaily_submission_title(logContentArrayArray[16]);
|
||||
logBean.setDaily_submission_content(logData + logContentArrayArray[17]);
|
||||
logBean.setResource_check_content(logData + logContentArrayArray[9].replace("@@@@@", videoContentArrayArray[num].trim()));
|
||||
logBean.setCommunications_test_title(logContentArrayArray[11]);
|
||||
logBean.setCommunications_test_content(logData + logContentArrayArray[12].replace("@@@@@", videoContentArrayArray[num].trim()));
|
||||
logBean.setDaily_operation_title(logContentArrayArray[14]);
|
||||
logBean.setDaily_operation_content(logData + logContentArrayArray[15]);
|
||||
logBean.setDaily_submission_title(logContentArrayArray[17]);
|
||||
logBean.setDaily_submission_content(logData + logContentArrayArray[18]);
|
||||
logBean.setGeneral_chronicles_title(logContentArrayArray[22]);
|
||||
logBean.setGeneral_chronicles_content(logContentArrayArray[23]);
|
||||
|
||||
// logBean.setWeather(weatherNight);
|
||||
// logBean.setMax_temperature(maxTemperature);
|
||||
// logBean.setMin_temperature(minTemperature);
|
||||
|
||||
insertData(null, logBean, "log");
|
||||
}
|
||||
}
|
||||
|
|
@ -650,6 +830,77 @@ public class GetBasicData {
|
|||
|
||||
public static void main(String[] args) throws ParseException, InterruptedException {
|
||||
|
||||
int num = getRandom(1, 11);
|
||||
DailyBean dailyBean = readDailyBean("morning_daily");
|
||||
LogBean logBean = readDutyBean();
|
||||
String dailyContent = resolveGarbledCode("D:\\config\\日报基本信息.txt");
|
||||
String checkContent = resolveGarbledCode("D:\\config\\资源核查情况.txt");
|
||||
String logContent = resolveGarbledCode("D:\\config\\日志基本信息.txt");
|
||||
String videoContent = resolveGarbledCode("D:\\config\\供电所名称.txt");
|
||||
String[] dailyContentArrayArray = dailyContent.split("--头部不可修改--");
|
||||
String[] logContentArrayArray = logContent.split("--头部不可修改--");
|
||||
String[] checkContentArrayArray = checkContent.split("资源核查情况:");
|
||||
String[] videoContentArrayArray = videoContent.split("--头部不可修改--");
|
||||
//昨天的日期
|
||||
String data1 = DateTimeUtils.getLastDay();
|
||||
//今天的日期
|
||||
String data2 = DateTimeUtils.getCurrentDay2();
|
||||
//明天的日期
|
||||
String data3 = DateTimeUtils.getTomorrowDate();
|
||||
//日志时间
|
||||
String logData = data2 + "08:30至" + data3 + "8:30,";
|
||||
String data = data2 + "17:30至" + data3 + "08:30,";
|
||||
|
||||
String type = "morning_daily";
|
||||
|
||||
//二、重要事项
|
||||
dailyBean.setImportant_matters(data + dailyContentArrayArray[4].trim());
|
||||
//三、安全生产情况
|
||||
dailyBean.setSafety_production(data + dailyContentArrayArray[6].trim());
|
||||
//四、值班员日常工作情况
|
||||
|
||||
dailyBean.setPersonnel_daily_work(data + dailyContentArrayArray[8].replace("@@@@@", videoContentArrayArray[num].trim()));
|
||||
//五、供电保障情况
|
||||
//(一)今日重大活动保电情况
|
||||
dailyBean.setPower_guarantee_today_work(dailyContentArrayArray[11]);
|
||||
//(二)明日重大活动保电安排
|
||||
dailyBean.setPower_guarantee_tomorrow_work(dailyContentArrayArray[13]);
|
||||
//(三)今日疫情防控应急保电情况
|
||||
dailyBean.setPower_guarantee_today_pestilence(dailyContentArrayArray[15]);
|
||||
//六、预警及应急响应情况
|
||||
//(一)公司预警情况 --另外一个方法使用
|
||||
|
||||
//(二)公司应急响应情况
|
||||
dailyBean.setWarning_company_impatient(data + dailyContentArrayArray[20]);
|
||||
//(三)社会突发事件救援及处置情况
|
||||
dailyBean.setWarning_society_emergency(data + dailyContentArrayArray[22]);
|
||||
//七、其他情况说明
|
||||
dailyBean.setOther_situations(data + dailyContentArrayArray[24]);
|
||||
//附件表一
|
||||
dailyBean.getOneBean().setExercise_person_num(getRandom(1, 50) + "");
|
||||
dailyBean.getOneBean().setExercise_vehicle_num(getRandom(1, 20) + "");
|
||||
dailyBean.getOneBean().setExercise_power_vehicle_num(getRandom(1, 3) + "");
|
||||
dailyBean.getOneBean().setExercise_dynamo_num(getRandom(1, 10) + "");
|
||||
dailyBean.getOneBean().setExercise_find_problems("0");
|
||||
|
||||
insertData(dailyBean, null, type);
|
||||
|
||||
//事件监测内容
|
||||
logBean.setEvent_detection_title(logContentArrayArray[2].trim());
|
||||
logBean.setEvent_detection_content(logData + logContentArrayArray[3].trim());
|
||||
logBean.setPower_work_title(logContentArrayArray[5]);
|
||||
logBean.setPower_work_content(logData + logContentArrayArray[6]);
|
||||
logBean.setResource_check_title(logContentArrayArray[8]);
|
||||
logBean.setResource_check_content(logData + logContentArrayArray[9].replace("@@@@@", videoContentArrayArray[num].trim()));
|
||||
logBean.setCommunications_test_title(logContentArrayArray[11]);
|
||||
logBean.setCommunications_test_content(logData + logContentArrayArray[12].replace("@@@@@", videoContentArrayArray[num].trim()));
|
||||
logBean.setDaily_operation_title(logContentArrayArray[14]);
|
||||
logBean.setDaily_operation_content(logData + logContentArrayArray[15]);
|
||||
logBean.setDaily_submission_title(logContentArrayArray[17]);
|
||||
logBean.setDaily_submission_content(logData + logContentArrayArray[18]);
|
||||
logBean.setGeneral_chronicles_title(logContentArrayArray[22]);
|
||||
logBean.setGeneral_chronicles_content(logContentArrayArray[23]);
|
||||
insertData(null, logBean, "log");
|
||||
}
|
||||
|
||||
private String getDailyName(String text) {
|
||||
|
|
@ -867,14 +1118,15 @@ public class GetBasicData {
|
|||
// Thread.sleep(500);
|
||||
// projectName = "车辆";
|
||||
// }
|
||||
//// int i =getRandom(1,3);
|
||||
//// webDriver.findElement(By.xpath("/html/body/div[5]/div[1]/div[1]/ul/li[" + i + "]")).click();
|
||||
//// log.info("选择操作内容----------");
|
||||
//// Thread.sleep(500);
|
||||
//// if (i == 1) projectName = "队伍";
|
||||
//// if (i == 2) projectName = "装备";
|
||||
//// if (i == 3) projectName = "车辆";
|
||||
//// Thread.sleep(300);
|
||||
|
||||
/// / int i =getRandom(1,3);
|
||||
/// / webDriver.findElement(By.xpath("/html/body/div[5]/div[1]/div[1]/ul/li[" + i + "]")).click();
|
||||
/// / log.info("选择操作内容----------");
|
||||
/// / Thread.sleep(500);
|
||||
/// / if (i == 1) projectName = "队伍";
|
||||
/// / if (i == 2) projectName = "装备";
|
||||
/// / if (i == 3) projectName = "车辆";
|
||||
/// / Thread.sleep(300);
|
||||
// }
|
||||
// //选择被检查单位
|
||||
// webDriver.findElement(By.xpath("/html/body/div[3]/div/div[2]/div/form/div[4]/div/div")).click();
|
||||
|
|
@ -895,7 +1147,6 @@ public class GetBasicData {
|
|||
//
|
||||
// return projectName;
|
||||
// }
|
||||
|
||||
public void addExercisePlan(String type, String company, int code) throws InterruptedException {
|
||||
Thread.sleep(3000);
|
||||
//添加计划
|
||||
|
|
@ -916,20 +1167,17 @@ public class GetBasicData {
|
|||
// }
|
||||
}
|
||||
|
||||
private void executePlan(String type, String company, String projectName,int code) throws InterruptedException {
|
||||
Thread.sleep(5000);
|
||||
webDriver.findElement(By.xpath("//*[@id=\"pane-sec\"]/section/header/form/div[1]/div[8]/div/div/button[2]")).click();
|
||||
Thread.sleep(10000);
|
||||
private void executePlan(String type, String company, String projectName, int code) throws InterruptedException {
|
||||
Thread.sleep(2000);
|
||||
String checkContent = resolveGarbledCode("E:\\bns\\config\\检查计划评价.txt");
|
||||
String[] checkContentArrayArray = checkContent.split("检查评价:");
|
||||
//勾选计划
|
||||
webDriver.findElement(By.xpath("//*[@id=\"pane-sec\"]/section/main/section/main/div/div[3]/table/tbody/tr[1]")).click();
|
||||
webDriver.findElement(By.xpath("/html/body/div[1]/section/div[1]/div[2]/div[2]/section/main/section/main/div/div[3]/table/tbody/tr[1]")).click();
|
||||
Thread.sleep(800);
|
||||
//点击执行按钮--打开选择被检查对象
|
||||
webDriver.findElement(By.xpath("/html/body/div[1]/section/div[1]/div[2]/div[2]/section/main/section/header/button[4]")).click();
|
||||
Thread.sleep(2000);
|
||||
|
||||
|
||||
webDriver.switchTo().defaultContent(); // 退出第一个同级 iframe
|
||||
WebElement body = webDriver.findElement(By.tagName("body")); // 定位主文档的 body 元素
|
||||
WebElement dutyIframe = body.findElement(By.id("plancheck-to-rccl"));
|
||||
|
|
@ -938,7 +1186,11 @@ public class GetBasicData {
|
|||
Thread.sleep(1500);
|
||||
//填写项目评价
|
||||
String appraise = "";
|
||||
if("日常操练".equals(type)){
|
||||
webDriver.findElement(By.xpath("/html/body/div[1]/section/main/section/header/div/div/div")).click();
|
||||
Thread.sleep(1000);
|
||||
webDriver.findElement(By.xpath("/html/body/div[2]/div[1]/div[1]/ul/li")).click();
|
||||
Thread.sleep(1000);
|
||||
if ("日常操练".equals(type)) {
|
||||
if (code > 1){
|
||||
if (code == 2){
|
||||
//装备
|
||||
|
|
@ -957,18 +1209,16 @@ public class GetBasicData {
|
|||
webDriver.findElement(By.xpath("/html/body/div/section/main/header/div/div[1]/div/div/div/div[4]")).click();
|
||||
appraise = checkContentArrayArray[3].trim();
|
||||
}
|
||||
|
||||
|
||||
}else{
|
||||
webDriver.findElement(By.xpath("/html/body/div/section/main/header/div/div[1]/div/div/div/div[3]")).click();
|
||||
} else {
|
||||
appraise = checkContentArrayArray[4].trim();
|
||||
webDriver.findElement(By.xpath("/html/body/div/section/main/header/div/div[1]/div/div/div/div[3]")).click();
|
||||
}
|
||||
Thread.sleep(800);
|
||||
//填写发现的问题
|
||||
webDriver.findElement(By.xpath("/html/body/div/section/main/section/form/div[2]/div[1]/div/div/textarea")).sendKeys("未发现问题");
|
||||
Thread.sleep(500);
|
||||
//填写项目评分
|
||||
webDriver.findElement(By.xpath("/html/body/div/section/main/section/form/div[3]/div[1]/div/div/div/input")).sendKeys(getRandom(95, 100) + "");
|
||||
webDriver.findElement(By.xpath("/html/body/div/section/main/section/form/div[3]/div[1]/div/div/div/input")).sendKeys(getRandom(90, 97) + "");
|
||||
Thread.sleep(500);
|
||||
|
||||
log.info("appraise:" + appraise);
|
||||
|
|
@ -1036,12 +1286,13 @@ public class GetBasicData {
|
|||
"/button[1]")).click();
|
||||
Thread.sleep(2000);
|
||||
//填写主题
|
||||
if("通信测试".equals(type)){
|
||||
webDriver.findElement(By.xpath("/html/body/div[3]/div/div[2]/section/header/form/div/div[1]/div/div[2]/div[1" +
|
||||
"]/input")).sendKeys("对"+company+"公司开展通信测试");
|
||||
}else {
|
||||
webDriver.findElement(By.xpath("/html/body/div[3]/div/div[2]/section/header/form/div/div[1]/div/div[2]/div[1" +
|
||||
"]/input")).sendKeys("对"+company+"公司开展日常操练");
|
||||
if ("通信测试".equals(type)) {
|
||||
//"/html/body/div[4]/div/div[2]/section/header/form/div/div[1]/div/div[2]/div[1]/input"
|
||||
webDriver.findElement(By.xpath("/html/body/div[3]/div/div[2]/section/header/form/div/div[1]/div/div[2" +
|
||||
"]/div[1]/input")).sendKeys("日常通信测试");
|
||||
} else {
|
||||
webDriver.findElement(By.xpath("/html/body/div[3]/div/div[2]/section/header/form/div/div[1]/div/div[2" +
|
||||
"]/div[1]/input")).sendKeys("日常队伍检查");
|
||||
}
|
||||
Thread.sleep(500);
|
||||
//选择操练环节
|
||||
|
|
@ -1066,12 +1317,12 @@ public class GetBasicData {
|
|||
webDriver.findElement(By.xpath("/html/body/div[6]/div[1]/div/div/div[1]/div[1]/span[2]")).click();
|
||||
log.info("选择被检查单位----------");
|
||||
Thread.sleep(3000);
|
||||
Thread.sleep(2000);
|
||||
//提交
|
||||
try {
|
||||
webDriver.findElement(By.xpath("/html/body/div[4]/div/div[2]/section/div/button[3]")).click();
|
||||
} catch (Exception e) {
|
||||
webDriver.findElement(By.xpath("/html/body/div[3]/div/div[2]/section/div/button[3]")).click();
|
||||
}
|
||||
Thread.sleep(3000);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,27 +1,27 @@
|
|||
package com.bonus.autoweb;
|
||||
|
||||
import com.bonus.autoweb.base.AutoUtils;
|
||||
import com.bonus.autoweb.UI.entity.WeatherData;
|
||||
import com.bonus.autoweb.base.DataConfig;
|
||||
import com.bonus.autoweb.task.AutoWebTask;
|
||||
import com.google.gson.Gson;
|
||||
import com.jacob.activeX.ActiveXComponent;
|
||||
import com.jacob.com.ComFailException;
|
||||
import com.jacob.com.Dispatch;
|
||||
import com.jacob.com.Variant;
|
||||
import lombok.SneakyThrows;
|
||||
import org.apache.poi.ss.usermodel.Cell;
|
||||
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.openqa.selenium.By;
|
||||
import okhttp3.OkHttpClient;
|
||||
import okhttp3.Request;
|
||||
import okhttp3.Response;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.awt.image.DataBufferFloat;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.text.ParseException;
|
||||
import java.util.*;
|
||||
import java.util.Date;
|
||||
import java.util.Random;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import javax.sound.sampled.*;
|
||||
import javax.sound.sampled.AudioInputStream;
|
||||
import javax.sound.sampled.AudioSystem;
|
||||
|
|
@ -31,17 +31,15 @@ import javax.sound.sampled.AudioSystem;
|
|||
* @author 24526
|
||||
*/
|
||||
public class TestMain {
|
||||
|
||||
private static Logger log = LoggerFactory.getLogger(TestMain.class);
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
log.info("执行任务开始。。。。。。");
|
||||
// testWeather();
|
||||
// testqd();
|
||||
// testjjb();
|
||||
// testGetData();
|
||||
// testAccounters();
|
||||
// testDailrb();
|
||||
// testRCCL();
|
||||
// testLog();
|
||||
// start("工作人员请注意,桌号8001顾客正在寻求帮助!!");
|
||||
new Thread(new Runnable() {
|
||||
@SneakyThrows
|
||||
@Override
|
||||
|
|
@ -54,102 +52,97 @@ public class TestMain {
|
|||
}
|
||||
}
|
||||
}).start();
|
||||
// testqd();
|
||||
// testRCCL();
|
||||
// testGetData();
|
||||
}
|
||||
|
||||
private static void testAccounters() {
|
||||
try {
|
||||
AutoWebTask autoWebTask = new AutoWebTask();
|
||||
String content = GetBasicData.resolveGarbledCode("E:\\bns\\config\\值班账号.txt");
|
||||
// 应急值班账号
|
||||
String emergencyPerson = content.toString().split(";")[0].split(":")[1];
|
||||
String emergencyPersonPassword = content.toString().split(";")[1].split(":")[1];
|
||||
autoWebTask.changeTodayPersonaTask(1,emergencyPerson,emergencyPersonPassword);
|
||||
//TODO 昨日的账号在今日的签退任务完成后,拿取今天的打卡人员数据放入昨日值班账号txt即可
|
||||
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static void testQt() {
|
||||
try {
|
||||
AutoWebTask autoWebTask = new AutoWebTask();
|
||||
String content = GetBasicData.resolveGarbledCode("E:\\bns\\config\\值班账号.txt");
|
||||
// 应急值班账号
|
||||
String emergencyPerson = content.toString().split(";")[0].split(":")[1];
|
||||
String emergencyPersonPassword = content.toString().split(";")[1].split(":")[1];
|
||||
autoWebTask.changeTodayPersonaTask(1,emergencyPerson,emergencyPersonPassword);
|
||||
// TODO 更新昨日签退人员账号
|
||||
String value = GetBasicData.resolveGarbledCode("D\\bns\\config\\今日值班账号.txt");
|
||||
AutoUtils.write("E:\\bns\\config\\昨日值班账号.txt", value.replaceAll("今日","昨日"));
|
||||
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
//签到签退测试
|
||||
private static void testqd() {
|
||||
String content = GetBasicData.resolveGarbledCode("E:\\bns\\config\\account.txt");
|
||||
String date = content.toString().split(";")[0].split(":")[1];
|
||||
String num = content.toString().split(";")[1].split(":")[1];
|
||||
if("1".equals(num)){
|
||||
log.info("xgd,yj签到签退任务");
|
||||
}else {
|
||||
log.info("zkj,zh签到签退任务");
|
||||
}
|
||||
// AutoWebTask autoWebTask = new AutoWebTask();
|
||||
// autoWebTask.dutyClockTask(2);
|
||||
}
|
||||
|
||||
//交接班测试
|
||||
private static void testjjb() {
|
||||
AutoWebTask autoWebTask = new AutoWebTask();
|
||||
autoWebTask.dutyChangeTask1(2,DataConfig.USER_NAME1,DataConfig.PASS1);
|
||||
}
|
||||
|
||||
private static void testRCCL() throws InterruptedException {
|
||||
AutoWebTask autoWebTask = new AutoWebTask();
|
||||
String content = GetBasicData.resolveGarbledCode("E:\\bns\\config\\值班账号.txt");
|
||||
// 应急值班账号
|
||||
String emergencyPerson = content.toString().split(";")[0].split(":")[1];
|
||||
String emergencyPersonPassword = content.toString().split(";")[1].split(":")[1];
|
||||
// autoWebTask.addExercisePlan("通信测试", "", 1, emergencyPerson,
|
||||
// emergencyPersonPassword);
|
||||
// Thread.sleep(5000);
|
||||
// autoWebTask.addExercisePlan("日常操练", "", 1, emergencyPerson,
|
||||
// emergencyPersonPassword);
|
||||
// Thread.sleep(5000);
|
||||
// autoWebTask.addExercisePlan("日常操练", "", 2, emergencyPerson,
|
||||
// emergencyPersonPassword);
|
||||
// Thread.sleep(5000);
|
||||
autoWebTask.addExercisePlan("日常操练", "", 2, emergencyPerson,
|
||||
emergencyPersonPassword);
|
||||
Thread.sleep(2000);
|
||||
// autoWebTask.addExercisePlan("日常操练", "", 1, DataConfig.USER_NAME1,
|
||||
// DataConfig.PASS1);
|
||||
// autoWebTask.addExercisePlan("通信测试", "", 0, DataConfig.USER_NAME1,
|
||||
// DataConfig.PASS1);
|
||||
// Thread.sleep(1000);
|
||||
autoWebTask.addExercisePlan("通信测试", "", 1, DataConfig.USER_NAME1, DataConfig.PASS1);
|
||||
Thread.sleep(1000);
|
||||
// autoWebTask.addExercisePlan("日常操练", "", 3, DataConfig.USER_NAME1,
|
||||
// DataConfig.PASS1);
|
||||
// Thread.sleep(2000);
|
||||
// autoWebTask.addExercisePlan("日常操练", "", 0, emergencyPerson, emergencyPersonPassword);
|
||||
// Thread.sleep(2000);
|
||||
}
|
||||
|
||||
//自动获取数据测试
|
||||
/**
|
||||
* 自动获取数据测试
|
||||
* @throws ParseException 获取数据异常
|
||||
* @throws InterruptedException 线程等待异常
|
||||
*/
|
||||
private static void testGetData() throws ParseException, InterruptedException {
|
||||
AutoWebTask autoWebTask = new AutoWebTask();
|
||||
String content = GetBasicData.resolveGarbledCode("E:\\bns\\config\\值班账号.txt");
|
||||
// 应急值班账号
|
||||
String emergencyPerson = content.toString().split(";")[0].split(":")[1];
|
||||
String emergencyPersonPassword = content.toString().split(";")[1].split(":")[1];
|
||||
Thread.sleep(2000);
|
||||
autoWebTask.getYuJingData(1,emergencyPerson,emergencyPersonPassword);
|
||||
Thread.sleep(2000);
|
||||
autoWebTask.getCaoLianData(1,emergencyPerson,emergencyPersonPassword);
|
||||
Thread.sleep(2000);
|
||||
// GetBasicData.getYuJingActionBasicData(1);
|
||||
//登录操作---杨军账号
|
||||
// autoWebTask.addExercisePlan("日常操练","灵璧",5,DataConfig.USER_NAME3,DataConfig.PASS3);
|
||||
// Thread.sleep(2000);
|
||||
// autoWebTask.addExercisePlan("日常操练","城郊",6,DataConfig.USER_NAME3,DataConfig.PASS3);
|
||||
//// Thread.sleep(2000);
|
||||
// autoWebTask.addExercisePlan("日常操练","砀山",3,DataConfig.USER_NAME3,DataConfig.PASS3);
|
||||
// autoWebTask.addExercisePlan("通信测试","城郊",6,DataConfig.USER_NAME3,DataConfig.PASS3);
|
||||
// autoWebTask.getYuJingData(1);
|
||||
Thread.sleep(2000);
|
||||
autoWebTask.getCaoLianData(1);
|
||||
Thread.sleep(2000);
|
||||
}
|
||||
|
||||
|
||||
//签到签退测试
|
||||
private static void testWeather() throws InterruptedException, IOException {
|
||||
OkHttpClient client = new OkHttpClient().newBuilder()
|
||||
.connectTimeout(180, TimeUnit.SECONDS)
|
||||
.readTimeout(180, TimeUnit.SECONDS)
|
||||
.writeTimeout(180, TimeUnit.SECONDS)
|
||||
.build();
|
||||
|
||||
String dataUrl = DataConfig.weatherUrl;
|
||||
log.info("dataUrl:" + dataUrl);
|
||||
Request request = new Request.Builder()
|
||||
.url(dataUrl)
|
||||
.get()
|
||||
.build();
|
||||
Response response;
|
||||
String result;
|
||||
try {
|
||||
response = client.newCall(request).execute();
|
||||
log.info("response:" + response);
|
||||
result = response.body().string();
|
||||
log.info("result:" + result);
|
||||
Gson gson = new Gson();
|
||||
WeatherData weatherData = gson.fromJson(result, WeatherData.class);
|
||||
log.info("------weatherData:" + weatherData);
|
||||
WeatherData.WeatherDataChild weatherDataChild = weatherData.getData();
|
||||
log.info("------weatherDataChild:" + weatherDataChild);
|
||||
String city = weatherDataChild.getCity();
|
||||
log.info("city:"+city);
|
||||
String weatherNoon = weatherDataChild.getWeatherNoon();
|
||||
log.info("weatherNoon:"+weatherNoon);
|
||||
String weatherNight = weatherDataChild.getWeatherNight();
|
||||
log.info("weatherNight:"+weatherNight);
|
||||
String minTemperature = weatherDataChild.getMinTemperature();
|
||||
log.info("minTemperature:"+minTemperature);
|
||||
String maxTemperature = weatherDataChild.getMaxTemperature();
|
||||
log.info("maxTemperature:"+maxTemperature);
|
||||
} catch (IOException e) {
|
||||
throw new IOException("天气get请求失败", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//签到签退测试
|
||||
private static void testqd() {
|
||||
AutoWebTask autoWebTask = new AutoWebTask();
|
||||
autoWebTask.testLogin(2);
|
||||
}
|
||||
|
||||
|
||||
//交接班测试
|
||||
private static void testjjb() {
|
||||
AutoWebTask autoWebTask = new AutoWebTask();
|
||||
autoWebTask.dutyChangeTask(2);
|
||||
}
|
||||
|
||||
//日报填写测试
|
||||
|
|
@ -158,13 +151,9 @@ public class TestMain {
|
|||
//操作日报
|
||||
//日报审核工作
|
||||
AutoWebTask autoWebTask = new AutoWebTask();
|
||||
String todayContent = GetBasicData.resolveGarbledCode("E:\\bns\\config\\今日值班账号.txt");
|
||||
//今日签到值班人员
|
||||
String todaySignInLeaderPerson = todayContent.toString().split(";")[0].split(":")[1];
|
||||
String todaySignInLeaderPersonPassword = todayContent.toString().split(";")[1].split(":")[1];
|
||||
Thread.sleep(2000);
|
||||
autoWebTask.dutyAddDailyLogsTask(2,todaySignInLeaderPerson,todaySignInLeaderPersonPassword);
|
||||
autoWebTask.dutyAddDailyLogsTask(2);
|
||||
Thread.sleep(1000);
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
|
@ -176,13 +165,7 @@ public class TestMain {
|
|||
try {
|
||||
//操作日志
|
||||
AutoWebTask autoWebTask = new AutoWebTask();
|
||||
String yesterdayContent = GetBasicData.resolveGarbledCode("E:\\bns\\config\\昨日值班账号.txt");
|
||||
|
||||
String yesterdayLeaderSignOutPerson = yesterdayContent.toString().split(";")[0].split(":")[1];
|
||||
String yesterdayLeaderSignOutPersonPassword = yesterdayContent.toString().split(";")[1].split(":")[1];
|
||||
// 应急值班账号
|
||||
Thread.sleep(2000);
|
||||
autoWebTask.dutyAddLogsTask(1,yesterdayLeaderSignOutPerson,yesterdayLeaderSignOutPersonPassword);
|
||||
autoWebTask.dutyAddLogsTask(2);
|
||||
count = 1;
|
||||
Thread.sleep(1000);
|
||||
log.info("count",count);
|
||||
|
|
@ -199,55 +182,27 @@ public class TestMain {
|
|||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
private void autoJob() throws InterruptedException, IOException {
|
||||
private void autoJob() throws InterruptedException {
|
||||
AutoWebTask autoWebTask = new AutoWebTask();
|
||||
|
||||
int logGatherCount = 0;
|
||||
int dailyGatherCount = 0;
|
||||
int logGatherCount1 = 0;
|
||||
int dailyGatherCount1 = 0;
|
||||
|
||||
int signInzao = 0;
|
||||
int signInzao2 = 0;
|
||||
int signInwan = 0;
|
||||
int signInwan2 = 0;
|
||||
int dailyzao = 0;
|
||||
int dailywan = 0;
|
||||
int jjbzao = 0;
|
||||
int jjbzao2 = 0;
|
||||
int jjbwan = 0;
|
||||
int signOutzao = 0;
|
||||
int signOutzao2 = 0;
|
||||
int signOutwan = 0;
|
||||
int signOutwan2 = 0;
|
||||
int logzao = 0;
|
||||
int resetCode = 0;
|
||||
|
||||
int changeTodayPerson = 0;
|
||||
|
||||
int logwan = 0;
|
||||
int addExercisePlan = 0;
|
||||
|
||||
boolean initializationCode = true;
|
||||
|
||||
if(initializationCode){
|
||||
String content = GetBasicData.resolveGarbledCode("E:\\bns\\config\\值班账号.txt");
|
||||
// 应急值班账号
|
||||
String emergencyPerson = content.toString().split(";")[0].split(":")[1];
|
||||
String emergencyPersonPassword = content.toString().split(";")[1].split(":")[1];
|
||||
|
||||
//TODO 更新今日
|
||||
try {
|
||||
if (changeTodayPerson == 0){
|
||||
changeTodayPerson = autoWebTask.changeTodayPersonaTask(1,emergencyPerson,emergencyPersonPassword);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
log.error("更新早上打卡人员", e);
|
||||
}
|
||||
|
||||
|
||||
initializationCode = false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
while (true) {
|
||||
//延迟30s---120s
|
||||
int time = randNum(30, 120);
|
||||
|
|
@ -258,240 +213,316 @@ public class TestMain {
|
|||
log.error("时间", e);
|
||||
}
|
||||
log.info("服务正在运行。。。" + new Date());
|
||||
String content = GetBasicData.resolveGarbledCode("E:\\bns\\config\\值班账号.txt");
|
||||
String todayContent = GetBasicData.resolveGarbledCode("E:\\bns\\config\\今日值班账号.txt");
|
||||
String yesterdayContent = GetBasicData.resolveGarbledCode("E:\\bns\\config\\昨日值班账号.txt");
|
||||
// 应急值班账号
|
||||
String emergencyPerson = content.toString().split(";")[0].split(":")[1];
|
||||
String emergencyPersonPassword = content.toString().split(";")[1].split(":")[1];
|
||||
|
||||
//今日签到值班人员
|
||||
String todaySignInLeaderPerson = todayContent.toString().split(";")[0].split(":")[1];
|
||||
String todaySignInLeaderPersonPassword = todayContent.toString().split(";")[1].split(":")[1];
|
||||
String todaySignInPerson = todayContent.toString().split(";")[2].split(":")[1];
|
||||
String todaySignInPersonPassword = todayContent.toString().split(";")[3].split(":")[1];
|
||||
//昨日签退人员
|
||||
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];
|
||||
|
||||
if(DateTimeUtils.isEffectiveDate("18:22", "18:55")){
|
||||
//进行日报信息系统采集及获取工作
|
||||
try {
|
||||
if (logGatherCount == 0){
|
||||
logGatherCount = autoWebTask.getYuJingData(1,emergencyPerson,emergencyPersonPassword);
|
||||
}
|
||||
Thread.sleep(3000);
|
||||
if (dailyGatherCount == 0){
|
||||
dailyGatherCount = autoWebTask.getCaoLianData(1,emergencyPerson,emergencyPersonPassword);
|
||||
Thread.sleep(2000);
|
||||
}
|
||||
}catch (Exception e) {
|
||||
log.error("信息采集工作", e);
|
||||
//判断当前时间是否在早上7:30到8点之间
|
||||
if(DateTimeUtils.isEffectiveDate("07:00", "07:15")){
|
||||
//延迟100s
|
||||
if (signInzao == 0 && signInzao2 == 0){
|
||||
getTime(550);
|
||||
}
|
||||
}else if (DateTimeUtils.isEffectiveDate("05:00", "05:30")) {
|
||||
//TODO 更新今日
|
||||
try {
|
||||
if (changeTodayPerson == 0){
|
||||
changeTodayPerson = autoWebTask.changeTodayPersonaTask(1,emergencyPerson,emergencyPersonPassword);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
log.error("更新早上打卡人员", e);
|
||||
}
|
||||
}else if (DateTimeUtils.isEffectiveDate("06:29", "06:59")) {
|
||||
//自动完成当值值班日报(早报)填写上报
|
||||
if (dailyzao == 0) {
|
||||
getTime(600);
|
||||
if (signInzao == 0) {
|
||||
log.info("房万春账号开始打卡任务---------------------");
|
||||
//使用房万春账号签到
|
||||
try {
|
||||
dailyzao = autoWebTask.dutyAddDailyLogsTask(1,yesterdayLeaderSignOutPerson,yesterdayLeaderSignOutPersonPassword);
|
||||
|
||||
|
||||
signInzao = autoWebTask.dutySigin(1, 1, DataConfig.USER_NAME2, DataConfig.PASS2);
|
||||
}catch (Exception e){
|
||||
log.error("房万春打卡任务", e);
|
||||
}
|
||||
}
|
||||
try {
|
||||
Thread.sleep(1000 * 2);
|
||||
} catch (Exception e) {
|
||||
log.error("打卡任务", e);
|
||||
}
|
||||
if (signInzao2 == 0){
|
||||
//使用韩宏宇账号签到
|
||||
log.info("韩宏宇账号开始打卡任务---------------------");
|
||||
try {
|
||||
signInzao2 = autoWebTask.dutySigin(1, 1, DataConfig.USER_NAME1, DataConfig.PASS1);
|
||||
}catch (Exception e){
|
||||
log.error("韩宏宇打卡任务", e);
|
||||
}
|
||||
}
|
||||
}else if (DateTimeUtils.isEffectiveDate("16:31", "16:45")) {//签到 晚
|
||||
if(signInwan == 0 && signInwan2 == 0){
|
||||
getTime(550);
|
||||
}
|
||||
if (signInwan == 0) {
|
||||
log.info("房万春账号开始打卡任务---------------------");
|
||||
//使用房万春账号签到
|
||||
try {
|
||||
signInwan = autoWebTask.dutySigin(2, 1, DataConfig.USER_NAME2, DataConfig.PASS2);
|
||||
}catch (Exception e) {
|
||||
log.error("房万春打卡任务", e);
|
||||
}
|
||||
}
|
||||
try {
|
||||
Thread.sleep(1000 * 2);
|
||||
} catch (Exception e) {
|
||||
log.error("房万春打卡任务", e);
|
||||
}
|
||||
if (signInwan2 == 0){
|
||||
//使用韩宏宇账号签到
|
||||
log.info("韩宏宇账号开始打卡任务---------------------");
|
||||
try {
|
||||
signInwan2 = autoWebTask.dutySigin(2, 1, DataConfig.USER_NAME1, DataConfig.PASS1);
|
||||
}catch (Exception e) {
|
||||
log.error("韩宏宇打卡任务", e);
|
||||
}
|
||||
}
|
||||
}else if (DateTimeUtils.isEffectiveDate("06:29", "06:59")) {//日报工作
|
||||
if (dailyzao == 0) {
|
||||
try {
|
||||
getTime(1000);
|
||||
dailyzao = autoWebTask.dutyAddDailyLogsTask(1);
|
||||
}catch (Exception e){
|
||||
log.error("日报工作", e);
|
||||
}
|
||||
}
|
||||
}else if (DateTimeUtils.isEffectiveDate("07:01", "07:29")) {
|
||||
//完成值班日志填写提交(晚班日志,此次值班日志为总结前一天晚上的情况)
|
||||
}else if (DateTimeUtils.isEffectiveDate("07:16", "07:30")) {//日志工作
|
||||
if (logzao == 0) {
|
||||
getTime(600);
|
||||
try {
|
||||
logzao = autoWebTask.dutyAddLogsTask(1,yesterdayLeaderSignOutPerson,yesterdayLeaderSignOutPersonPassword);
|
||||
getTime(500);
|
||||
logzao = autoWebTask.dutyAddLogsTask(1);
|
||||
}catch (Exception e){
|
||||
log.error("日志工作", e);
|
||||
}
|
||||
}
|
||||
}else if (DateTimeUtils.isEffectiveDate("07:30", "07:59")) {
|
||||
//自动完成当值值班签到(值班主任、值班人员都要签到)
|
||||
if ("error".equals(content)) {
|
||||
log.error("读取打卡人员数据错误");
|
||||
}else {
|
||||
if (signInzao == 0 && signInzao2 == 0){
|
||||
getTime(900);
|
||||
}
|
||||
if (signInzao == 0) {
|
||||
log.info("应急值班账号开始打卡任务---------------------");
|
||||
//使用应急值班账号签到
|
||||
try {
|
||||
signInzao = autoWebTask.dutySigin(1, 1, todaySignInLeaderPerson, todaySignInLeaderPersonPassword);
|
||||
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("应急值班打卡任务", e);
|
||||
}
|
||||
}
|
||||
try {
|
||||
Thread.sleep(1000 * 2);
|
||||
} catch (Exception e) {
|
||||
log.error("打卡任务", e);
|
||||
}
|
||||
if (signInzao2 == 0) {
|
||||
//使用其他账号签到
|
||||
log.info("其他账号开始打卡任务---------------------");
|
||||
try {
|
||||
signInzao2 = autoWebTask.dutySigin(1, 1,todaySignInPerson , todaySignInPersonPassword);
|
||||
} catch (Exception e) {
|
||||
log.error("其他账号打卡任务", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}else if (DateTimeUtils.isEffectiveDate("08:00", "08:30")) {
|
||||
if (jjbzao == 0 && jjbzao2 == 0){
|
||||
getTime(600);
|
||||
}
|
||||
//自动在系统内完成接班(上一值完成交班后)
|
||||
if (jjbzao == 0 || jjbzao2 == 0){
|
||||
try {
|
||||
if (jjbzao == 0){
|
||||
jjbzao = autoWebTask.dutyChangeTask1(1,yesterdayLeaderSignOutPerson,yesterdayLeaderSignOutPersonPassword);
|
||||
}
|
||||
if (jjbzao2 == 0){
|
||||
jjbzao2 = autoWebTask.dutyChangeTask2(2,todaySignInLeaderPerson,todaySignInLeaderPersonPassword);
|
||||
}
|
||||
}catch (Exception e){
|
||||
log.error("接接班任务", e);
|
||||
}
|
||||
}
|
||||
}else if (DateTimeUtils.isEffectiveDate("09:00", "09:20")) {
|
||||
if(signOutzao == 0 && signOutzao2 == 0){
|
||||
getTime(900);
|
||||
}
|
||||
//自动在系统内完成签退
|
||||
try {
|
||||
if (signOutzao == 0) {
|
||||
try {
|
||||
signOutzao = autoWebTask.dutySignOutTask(1,yesterdayLeaderSignOutPerson,yesterdayLeaderSignOutPersonPassword);
|
||||
}catch (Exception e){
|
||||
log.error("签退",e);
|
||||
}
|
||||
}
|
||||
try {
|
||||
Thread.sleep(1000 * 3);
|
||||
} catch (Exception e) {
|
||||
log.error("时间", e);
|
||||
}
|
||||
if (signOutzao2 == 0){
|
||||
try {
|
||||
signOutzao2 = autoWebTask.dutySignOutTask(1, yesterdaySignOutPerson, yesterdaySignOutPersonPassword);
|
||||
}catch (Exception e){
|
||||
log.error("签退",e);
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
log.error("签退", e);
|
||||
}
|
||||
} else if (DateTimeUtils.isEffectiveDate("09:30", "10:00")) {
|
||||
}else if (DateTimeUtils.isEffectiveDate("09:30", "10:00")) {
|
||||
if(addExercisePlan == 0){
|
||||
getTime(1200);
|
||||
}
|
||||
if(addExercisePlan == 0) {
|
||||
// String[] array = {"蒙城","利辛","涡阳"};
|
||||
// Random random = new Random();
|
||||
// int index = random.nextInt(array.length);
|
||||
// log.info("随机值为:" + index);
|
||||
// log.info("随机值为:" + array[index]);
|
||||
Thread.sleep(2000);
|
||||
addExercisePlan = autoWebTask.addExercisePlan("通信测试", "", 1, todaySignInLeaderPerson,
|
||||
todaySignInLeaderPersonPassword);
|
||||
addExercisePlan = autoWebTask.addExercisePlan("通信测试", "", 1, DataConfig.USER_NAME1, DataConfig.PASS1);
|
||||
Thread.sleep(1000 * 700);
|
||||
addExercisePlan = autoWebTask.addExercisePlan("日常操练", "", 1, todaySignInLeaderPerson,
|
||||
todaySignInLeaderPersonPassword);
|
||||
Thread.sleep(1000 * 700);
|
||||
addExercisePlan = autoWebTask.addExercisePlan("日常操练", "", 2, todaySignInLeaderPerson,
|
||||
todaySignInLeaderPersonPassword);
|
||||
Thread.sleep(1000 * 700);
|
||||
addExercisePlan = autoWebTask.addExercisePlan("日常操练", "", 3, todaySignInLeaderPerson,
|
||||
todaySignInLeaderPersonPassword);
|
||||
Random rand = new Random();
|
||||
int randomNum = rand.nextInt(3) + 1;
|
||||
addExercisePlan = autoWebTask.addExercisePlan("日常操练", "", randomNum, DataConfig.USER_NAME1, DataConfig.PASS1);
|
||||
Thread.sleep(2000);
|
||||
}
|
||||
}else if (DateTimeUtils.isEffectiveDate("10:30", "10:35")) {
|
||||
autoWebTask.changeTodayPersonaTask(1,emergencyPerson,emergencyPersonPassword);
|
||||
// TODO 更新昨日签退人员账号
|
||||
String value = GetBasicData.resolveGarbledCode("E:\\bns\\config\\今日值班账号.txt");
|
||||
AutoUtils.write("E:\\bns\\config\\昨日值班账号.txt", value.replaceAll("今日","昨日"));
|
||||
} else if (DateTimeUtils.isEffectiveDate("17:01", "17:10")) {//日报工作
|
||||
if (dailywan == 0) {
|
||||
try {
|
||||
getTime(300);
|
||||
dailywan = autoWebTask.dutyAddDailyLogsTask(2);
|
||||
}catch (Exception e){
|
||||
log.error("日报工作", e);
|
||||
}
|
||||
}
|
||||
} else if (DateTimeUtils.isEffectiveDate("16:16", "16:30")) {//日志工作
|
||||
if (logwan == 0) {
|
||||
try {
|
||||
getTime(500);
|
||||
logwan = autoWebTask.dutyAddLogsTask(2);
|
||||
}catch (Exception e){
|
||||
log.error("日志工作", e);
|
||||
}
|
||||
}
|
||||
} else if (DateTimeUtils.isEffectiveDate("08:00", "08:15")) {//交接班早
|
||||
if (jjbzao == 0) {
|
||||
try {
|
||||
getTime(500);
|
||||
jjbzao = autoWebTask.dutyChangeTask(1);
|
||||
}catch (Exception e){
|
||||
log.error("交接班早失败",e);
|
||||
}
|
||||
}
|
||||
}else if(DateTimeUtils.isEffectiveDate("08:16", "08:20")){
|
||||
if(jjbzao == 0){
|
||||
start("值班管理播报提示:交接班未成功");
|
||||
}else{
|
||||
start("值班管理播报提示:交接班已完成");
|
||||
}
|
||||
}else if (DateTimeUtils.isEffectiveDate("16:46", "17:00")) {//交接班晚
|
||||
if (jjbwan == 0) {
|
||||
try {
|
||||
getTime(500);
|
||||
jjbwan = autoWebTask.dutyChangeTask(2);
|
||||
}catch (Exception e){
|
||||
log.error("交接班晚",e);
|
||||
}
|
||||
}
|
||||
}else if (DateTimeUtils.isEffectiveDate("08:45", "09:00")) {//签退 早
|
||||
if (signOutzao == 0 && signOutzao2 == 0) {
|
||||
getTime(450);
|
||||
}
|
||||
if (signOutzao == 0) {
|
||||
try {
|
||||
signOutzao = autoWebTask.dutySignOutTask(1, DataConfig.USER_NAME1, DataConfig.PASS1);
|
||||
}catch (Exception e){
|
||||
log.error("签退",e);
|
||||
}
|
||||
}
|
||||
try {
|
||||
Thread.sleep(1000 * 3);
|
||||
} catch (Exception e) {
|
||||
log.error("时间", e);
|
||||
}
|
||||
if (signOutzao2 == 0){
|
||||
try {
|
||||
signOutzao2 = autoWebTask.dutySignOutTask(1, DataConfig.USER_NAME2, DataConfig.PASS2);
|
||||
}catch (Exception e){
|
||||
log.error("签退",e);
|
||||
}
|
||||
}
|
||||
}else if(DateTimeUtils.isEffectiveDate("09:01", "09:05")){
|
||||
try {
|
||||
String str = "值班管理播报提示:";
|
||||
if (signOutzao == 0){
|
||||
str += "韩宏宇账号签退失败;";
|
||||
}
|
||||
if (signOutzao2 == 0){
|
||||
str += "房万春账号签退失败;";
|
||||
}
|
||||
if(signOutzao == 1 && signOutzao2 == 1){
|
||||
str += "签退成功";
|
||||
}
|
||||
start(str);
|
||||
} catch (Exception e) {
|
||||
System.out.println("播报错误");
|
||||
}
|
||||
|
||||
} else if (DateTimeUtils.isEffectiveDate("17:45", "18:10")) {//签退 晚
|
||||
if (signOutwan == 0 && signOutwan2 == 0) {
|
||||
getTime(600);
|
||||
}
|
||||
if (signOutwan == 0) {
|
||||
try {
|
||||
signOutwan = autoWebTask.dutySignOutTask(2, DataConfig.USER_NAME1, DataConfig.PASS1);
|
||||
}catch (Exception e){
|
||||
log.error("签退",e);
|
||||
}
|
||||
}
|
||||
try {
|
||||
Thread.sleep(1000 * 3);
|
||||
} catch (Exception e) {
|
||||
log.error("时间", e);
|
||||
}
|
||||
if (signOutwan2 == 0) {
|
||||
try {
|
||||
signOutwan2 = autoWebTask.dutySignOutTask(2, DataConfig.USER_NAME2, DataConfig.PASS2);
|
||||
}catch (Exception e){
|
||||
log.error("签退",e);
|
||||
}
|
||||
}
|
||||
}else if(DateTimeUtils.isEffectiveDate("18:11", "18:15")){
|
||||
try {
|
||||
String str = "值班管理播报提示:";
|
||||
if (signOutwan == 0){
|
||||
str += "韩宏宇账号签退失败;";
|
||||
}
|
||||
if (signOutwan2 == 0){
|
||||
str += "房万春账号签退失败;";
|
||||
}
|
||||
if(signOutwan == 1 && signOutwan2 == 1){
|
||||
str += "签退成功";
|
||||
}
|
||||
start(str);
|
||||
} catch (Exception e) {
|
||||
System.out.println("播报错误");
|
||||
}
|
||||
} else if (DateTimeUtils.isEffectiveDate("07:31", "07:35")) {
|
||||
try {
|
||||
String str = "值班管理播报提示:";
|
||||
if (signInzao == 0){
|
||||
str += "房万春账号打卡失败;";
|
||||
}
|
||||
if (signInzao2 == 0){
|
||||
str += "韩宏宇账号打卡失败;";
|
||||
}
|
||||
if (dailyzao == 0){
|
||||
str += "日报未提交成功;";
|
||||
}
|
||||
if (logzao == 0){
|
||||
str += "日志未提交成功;";
|
||||
}
|
||||
if (signInzao == 1 && signInzao2 == 1 && dailyzao == 1 && logzao == 1){
|
||||
str += "打卡、日报、日志填写完成";
|
||||
}
|
||||
start(str);
|
||||
} catch (Exception e) {
|
||||
System.out.println("播报错误");
|
||||
}
|
||||
} else if (DateTimeUtils.isEffectiveDate("17:13", "17:17")) {
|
||||
try {
|
||||
String str = "值班管理播报提示:";
|
||||
if (signInwan == 0){
|
||||
str += "房万春账号签到失败;";
|
||||
}
|
||||
if (signInwan2 == 0){
|
||||
str += "韩宏宇账号签到失败;";
|
||||
}
|
||||
if (dailywan == 0){
|
||||
str += "日报未提交成功;";
|
||||
}
|
||||
if (logwan == 0){
|
||||
str += "日志未提交成功;";
|
||||
}
|
||||
if(jjbwan == 0){
|
||||
start("交接班未成功");
|
||||
}
|
||||
if (signInwan == 1 && signInwan2 == 1 && dailywan == 1 && logwan == 1){
|
||||
str += "打卡、日报、日志、交接班填写完成";
|
||||
}
|
||||
start(str);
|
||||
} catch (Exception e) {
|
||||
System.out.println("播报错误");
|
||||
}
|
||||
}else if (DateTimeUtils.isEffectiveDate("12:30", "14:30")) {
|
||||
//进行日志信息系统采集及获取工作
|
||||
try {
|
||||
if (logGatherCount1 == 0){
|
||||
logGatherCount1= autoWebTask.getYuJingData(2,emergencyPerson,emergencyPersonPassword);
|
||||
logGatherCount1= autoWebTask.getYuJingData(2);
|
||||
}
|
||||
Thread.sleep(3000);
|
||||
if (dailyGatherCount1 == 0){
|
||||
dailyGatherCount1 = autoWebTask.getCaoLianData(2,emergencyPerson,emergencyPersonPassword);
|
||||
dailyGatherCount1 = autoWebTask.getCaoLianData(2);
|
||||
Thread.sleep(2000);
|
||||
}
|
||||
}catch (Exception e) {
|
||||
log.error("信息采集工作", e);
|
||||
}
|
||||
}else if (DateTimeUtils.isEffectiveDate("17:01", "17:25")) {
|
||||
//自动完成当值值班日报(晚报)填写上报
|
||||
if (dailywan == 0) {
|
||||
getTime(1200);
|
||||
try {
|
||||
dailywan = autoWebTask.dutyAddDailyLogsTask(2,todaySignInLeaderPerson,todaySignInLeaderPersonPassword);
|
||||
}catch (Exception e){
|
||||
log.error("日报工作", e);
|
||||
}else if(DateTimeUtils.isEffectiveDate("18:22", "18:55")){
|
||||
//进行日报信息系统采集及获取工作
|
||||
try {
|
||||
if (logGatherCount == 0){
|
||||
logGatherCount = autoWebTask.getYuJingData(1);
|
||||
}
|
||||
Thread.sleep(3000);
|
||||
if (dailyGatherCount == 0){
|
||||
dailyGatherCount = autoWebTask.getCaoLianData(1);
|
||||
Thread.sleep(2000);
|
||||
}
|
||||
}catch (Exception e) {
|
||||
log.error("信息采集工作", e);
|
||||
}
|
||||
} else if (DateTimeUtils.isEffectiveDate("20:05", "20:08")) {//重置标识
|
||||
log.info("-----开始重置各标识符-----");
|
||||
}else if (DateTimeUtils.isEffectiveDate("20:05", "20:08")) {
|
||||
//重置标识
|
||||
logGatherCount = 0;
|
||||
logGatherCount1 = 0;
|
||||
dailyGatherCount = 0;
|
||||
dailyGatherCount1 = 0;
|
||||
signInzao = 0;
|
||||
signInzao2 = 0;
|
||||
signInwan = 0;
|
||||
signInwan2 = 0;
|
||||
dailyzao = 0;
|
||||
dailywan = 0;
|
||||
jjbzao = 0;
|
||||
jjbzao2 = 0;
|
||||
jjbwan = 0;
|
||||
signOutzao = 0;
|
||||
signOutzao2 = 0;
|
||||
signOutwan = 0;
|
||||
signOutwan2 = 0;
|
||||
logzao = 0;
|
||||
logwan = 0;
|
||||
addExercisePlan = 0;
|
||||
changeTodayPerson = 0;
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static List<Integer> getARandomCollectionOfData() {
|
||||
Random random = new Random();
|
||||
int minCount = 3; // 最小数量
|
||||
int maxCount = 5; // 最大数量
|
||||
int count = random.nextInt(maxCount - minCount + 1) + minCount; // 随机生成数量
|
||||
List<Integer> numbers = new ArrayList<>();
|
||||
while (numbers.size() < count) {
|
||||
int randomNumber = random.nextInt(6) + 2; // 随机生成2到7的数字
|
||||
if (!numbers.contains(randomNumber)) {
|
||||
numbers.add(randomNumber);
|
||||
}
|
||||
}
|
||||
Collections.shuffle(numbers);
|
||||
return numbers;
|
||||
}
|
||||
|
||||
private void getTime(int code){
|
||||
int time = randNum(0, code);
|
||||
log.info("随机时间为:" + time);
|
||||
|
|
@ -513,7 +544,86 @@ public class TestMain {
|
|||
int result = (int) (num1 + Math.random() * (num2 - num1 + 1));
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
public static void start(String text) {
|
||||
log.info("进入播报模式");
|
||||
ActiveXComponent ax = null;
|
||||
try {
|
||||
ax = new ActiveXComponent("Sapi.SpVoice");
|
||||
// 运行时输出语音内容
|
||||
Dispatch spVoice = ax.getObject();
|
||||
// 音量 0-100
|
||||
ax.setProperty("Volume", new Variant(100));
|
||||
// 语音朗读速度 -10 到 +10
|
||||
ax.setProperty("Rate", new Variant(1));
|
||||
// 执行朗读
|
||||
// Dispatch.call(spVoice, "Speak", new Variant(text));
|
||||
// 下面是构建文件流把生成语音文件
|
||||
ax = new ActiveXComponent("Sapi.SpFileStream");
|
||||
Dispatch spFileStream = ax.getObject();
|
||||
ax = new ActiveXComponent("Sapi.SpAudioFormat");
|
||||
Dispatch spAudioFormat = ax.getObject();
|
||||
|
||||
// 设置音频流格式
|
||||
Dispatch.put(spAudioFormat, "Type", new Variant(22));
|
||||
// 设置文件输出流格式
|
||||
Dispatch.putRef(spFileStream, "Format", spAudioFormat);
|
||||
// 调用输出 文件流打开方法,创建一个.wav文件
|
||||
Dispatch.call(spFileStream, "Open", new Variant("E:\\bns\\audio.wav"), new Variant(3), new Variant(true));
|
||||
// 设置声音对象的音频输出流为输出文件对象
|
||||
Dispatch.putRef(spVoice, "AudioOutputStream", spFileStream);
|
||||
// 设置音量 0到100
|
||||
Dispatch.put(spVoice, "Volume", new Variant(100));
|
||||
// 设置朗读速度
|
||||
Dispatch.put(spVoice, "Rate", new Variant(1));
|
||||
// 开始朗读
|
||||
Dispatch.call(spVoice, "Speak", new Variant(text));
|
||||
|
||||
// 关闭输出文件
|
||||
Dispatch.call(spFileStream, "Close");
|
||||
Dispatch.putRef(spVoice, "AudioOutputStream", null);
|
||||
|
||||
spAudioFormat.safeRelease();
|
||||
spFileStream.safeRelease();
|
||||
spVoice.safeRelease();
|
||||
ax.safeRelease();
|
||||
showVoice();
|
||||
} catch (ComFailException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
log.error("没有可用的音频,请连接外接设备(耳机或音箱播放)");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
log.error("语音播放错误:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public static void showVoice() {
|
||||
try {
|
||||
// 获取音频输入流
|
||||
AudioInputStream audioInputStream = AudioSystem.getAudioInputStream(new File("E:\\bns\\audio.wav"));
|
||||
// 获取音频格式
|
||||
AudioFormat audioFormat = audioInputStream.getFormat();
|
||||
// 准备数据行格式
|
||||
DataLine.Info info = new DataLine.Info(SourceDataLine.class, audioFormat);
|
||||
// 打开数据行
|
||||
SourceDataLine dataLine = (SourceDataLine) AudioSystem.getLine(info);
|
||||
dataLine.open(audioFormat);
|
||||
// 开始播放音频
|
||||
dataLine.start();
|
||||
// 缓冲区大小
|
||||
int bufferSize = 4096;
|
||||
byte[] buffer = new byte[bufferSize];
|
||||
int bytesRead = 0;
|
||||
// 从输入流读取数据并写入数据行进行播放
|
||||
while ((bytesRead = audioInputStream.read(buffer)) != -1) {
|
||||
dataLine.write(buffer, 0, bytesRead);
|
||||
}
|
||||
// 等待播放完成
|
||||
dataLine.drain();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ import lombok.Data;
|
|||
*/
|
||||
@Data
|
||||
public class AnnexEightBean {
|
||||
|
||||
|
||||
/**
|
||||
* 特高压
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -0,0 +1,117 @@
|
|||
package com.bonus.autoweb.UI.entity;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* FileName: WeatherData
|
||||
*
|
||||
* @author tqzhang
|
||||
* Date: 2024/4/9 14:11
|
||||
* Description:天气
|
||||
*/
|
||||
@Data
|
||||
public class WeatherData {
|
||||
private int code;
|
||||
private WeatherDataChild data;
|
||||
|
||||
public static class WeatherDataChild {
|
||||
private int page;
|
||||
private int rows;
|
||||
private String city;
|
||||
@SerializedName("weather12") // 使用注解指定 JSON 中的字段名
|
||||
private String weatherNoon;
|
||||
@SerializedName("weather24") // 使用注解指定 JSON 中的字段名
|
||||
private String weatherNight;
|
||||
@SerializedName("temperature1") // 使用注解指定 JSON 中的字段名
|
||||
private String minTemperature;
|
||||
@SerializedName("temperature2") // 使用注解指定 JSON 中的字段名
|
||||
private String maxTemperature;
|
||||
private String rectime;
|
||||
|
||||
public int getPage() {
|
||||
return page;
|
||||
}
|
||||
|
||||
public void setPage(int page) {
|
||||
this.page = page;
|
||||
}
|
||||
|
||||
public int getRows() {
|
||||
return rows;
|
||||
}
|
||||
|
||||
public void setRows(int rows) {
|
||||
this.rows = rows;
|
||||
}
|
||||
|
||||
public String getCity() {
|
||||
return city;
|
||||
}
|
||||
|
||||
public void setCity(String city) {
|
||||
this.city = city;
|
||||
}
|
||||
|
||||
public String getWeatherNoon() {
|
||||
return weatherNoon;
|
||||
}
|
||||
|
||||
public void setWeatherNoon(String weatherNoon) {
|
||||
this.weatherNoon = weatherNoon;
|
||||
}
|
||||
|
||||
public String getWeatherNight() {
|
||||
return weatherNight;
|
||||
}
|
||||
|
||||
public void setWeatherNight(String weatherNight) {
|
||||
this.weatherNight = weatherNight;
|
||||
}
|
||||
|
||||
public String getMinTemperature() {
|
||||
return minTemperature;
|
||||
}
|
||||
|
||||
public void setMinTemperature(String minTemperature) {
|
||||
this.minTemperature = minTemperature;
|
||||
}
|
||||
|
||||
public String getMaxTemperature() {
|
||||
return maxTemperature;
|
||||
}
|
||||
|
||||
public void setMaxTemperature(String maxTemperature) {
|
||||
this.maxTemperature = maxTemperature;
|
||||
}
|
||||
|
||||
public String getRectime() {
|
||||
return rectime;
|
||||
}
|
||||
|
||||
public void setRectime(String rectime) {
|
||||
this.rectime = rectime;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "WeatherDataChild{" +
|
||||
"page=" + page +
|
||||
", rows=" + rows +
|
||||
", city='" + city + '\'' +
|
||||
", weatherNoon='" + weatherNoon + '\'' +
|
||||
", weatherNight='" + weatherNight + '\'' +
|
||||
", minTemperature='" + minTemperature + '\'' +
|
||||
", maxTemperature='" + maxTemperature + '\'' +
|
||||
", rectime='" + rectime + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public String toString() {
|
||||
return "WeatherData{" +
|
||||
"code=" + code +
|
||||
", data=" + data +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
|
|
@ -12,10 +12,10 @@ import java.awt.event.FocusListener;
|
|||
import java.awt.event.MouseEvent;
|
||||
import java.awt.event.MouseListener;
|
||||
import java.io.*;
|
||||
import java.net.URLEncoder;
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.net.URLEncoder;
|
||||
|
||||
/**
|
||||
* 日志页面
|
||||
|
|
|
|||
|
|
@ -1,12 +1,13 @@
|
|||
package com.bonus.autoweb.base;
|
||||
|
||||
import com.jacob.activeX.ActiveXComponent;
|
||||
import com.jacob.com.Dispatch;
|
||||
import org.openqa.selenium.By;
|
||||
import org.openqa.selenium.JavascriptExecutor;
|
||||
import org.openqa.selenium.WebDriver;
|
||||
import org.openqa.selenium.WebElement;
|
||||
import org.openqa.selenium.chrome.ChromeDriver;
|
||||
import org.openqa.selenium.chrome.ChromeOptions;
|
||||
import org.openqa.selenium.firefox.FirefoxDriver;
|
||||
import org.openqa.selenium.interactions.Actions;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
|
@ -32,24 +33,17 @@ public class AutoMain {
|
|||
/**
|
||||
* 初始化驱动
|
||||
*/
|
||||
public void initDrive(int type) {
|
||||
public void initDrive() {
|
||||
// chromedriver服务地址
|
||||
System.setProperty(DataConfig.DRIVE_NAME, DataConfig.drivePath);
|
||||
ChromeOptions option = new ChromeOptions();
|
||||
//添加浏览器地址
|
||||
// option.setBinary("C:\\Program Files\\Mozilla Firefox\\firefox.exe");//个人本地
|
||||
option.setBinary("C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe");//个人本地
|
||||
// option.setBinary("C:\\Users\\19814\\AppData\\Local\\Google\\Chrome\\Application\\chrome.exe");//个人本地
|
||||
// option.setBinary("C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe");
|
||||
// option.setBinary("C:\\Users\\Administrator\\AppData\\Local\\Google\\Chrome\\Application\\chrome.exe");//宿州
|
||||
// option.addArguments("start-fullscreen");
|
||||
option.setBinary("C:\\Users\\Administrator\\AppData\\Local\\Google\\Chrome\\Application\\chrome.exe");
|
||||
option.addArguments("--start-maximized");
|
||||
option.addArguments("--force-device-scale-factor=0.75");
|
||||
option.addArguments("disable-infobars");
|
||||
|
||||
//隐藏页面
|
||||
// option.addArguments("--headless");
|
||||
// webDriver = new FirefoxDriver(option);
|
||||
webDriver = new ChromeDriver(option);
|
||||
}
|
||||
|
||||
|
|
@ -61,25 +55,6 @@ public class AutoMain {
|
|||
login(userName, pass);
|
||||
openDuty();
|
||||
}
|
||||
public void startYuJingAuto(String userName, String pass) throws Exception {
|
||||
openWeb();
|
||||
log.info("打开网站成功");
|
||||
login(userName, pass);
|
||||
log.info("登录成功");
|
||||
openYuJing();
|
||||
}
|
||||
public void startYuJingActionAuto(String userName, String pass) throws Exception {
|
||||
openWeb();
|
||||
log.info("打开网站成功");
|
||||
login(userName, pass);
|
||||
log.info("登录成功");
|
||||
openYuJingAction();
|
||||
}
|
||||
public void startCaoLianAuto(String userName, String pass) throws Exception {
|
||||
openWeb();
|
||||
login(userName, pass);
|
||||
openCheckTheDrills();
|
||||
}
|
||||
|
||||
/**
|
||||
* 打开网站
|
||||
|
|
@ -87,7 +62,7 @@ public class AutoMain {
|
|||
public void openWeb() throws InterruptedException {
|
||||
//第一步打开指定网站
|
||||
webDriver.get(DataConfig.URL);
|
||||
log.info("打开利辛应急指挥中心网站------------");
|
||||
log.info("打开泗县应急指挥中心网站------------");
|
||||
Thread.sleep(2000);
|
||||
}
|
||||
|
||||
|
|
@ -137,26 +112,16 @@ public class AutoMain {
|
|||
* 打开值班管理页面,并定位到值班管理的iframe
|
||||
*/
|
||||
private void openDuty() throws InterruptedException {
|
||||
Thread.sleep(5000);
|
||||
//
|
||||
// try {
|
||||
// WebElement alertDiv = webDriver.findElement(By.xpath("/html/body/div[2]/div/div[1]/div/div[1]/div[1]/span"));
|
||||
// if(alertDiv.getText()) {
|
||||
//
|
||||
// }
|
||||
// }catch (Exception e){
|
||||
//
|
||||
// }
|
||||
|
||||
try {
|
||||
webDriver.manage().timeouts().implicitlyWait(3, TimeUnit.SECONDS);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
Thread.sleep(10000);
|
||||
Thread.sleep(3000);
|
||||
//执行鼠标悬停动作-管理
|
||||
Actions action = new Actions(webDriver);
|
||||
WebElement wegl = webDriver.findElement(By.xpath("//*[@id=\"app\"]/div/div[1]/div[6]/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();
|
||||
Thread.sleep(300);
|
||||
|
||||
|
|
@ -192,133 +157,6 @@ public class AutoMain {
|
|||
Thread.sleep(300);
|
||||
}
|
||||
|
||||
private void openYuJing() throws InterruptedException{
|
||||
try {
|
||||
webDriver.manage().timeouts().implicitlyWait(3, TimeUnit.SECONDS);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
Thread.sleep(5000);
|
||||
//执行鼠标悬停动作-管理
|
||||
Actions action = new Actions(webDriver);
|
||||
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();
|
||||
Thread.sleep(300);
|
||||
log.info("执行鼠标悬停动作-管理");
|
||||
//获取管理标签中的aria-describedby属性 el-popover-7909
|
||||
String attributeId = wegl.getAttribute("aria-describedby");
|
||||
log.info("管理标签的ID值为:" + attributeId);
|
||||
Thread.sleep(300);
|
||||
|
||||
|
||||
// //执行鼠标悬停动作-常态值班
|
||||
// String ctzbXpath = "//*[@id=\"" + attributeId + "\"]/div/div[1]/div[2]/div[3]";
|
||||
// WebElement wectzb = webDriver.findElement(By.xpath(ctzbXpath));
|
||||
// action.moveToElement(wectzb).build().perform();
|
||||
// Thread.sleep(300);
|
||||
|
||||
|
||||
//打开预警响应管理页面
|
||||
//*[@id=\"" + attributeId + "\"]/div/div[2]/div[2]/div[1]/div[2]
|
||||
String zbglXpath = "//*[@id=\"" + attributeId + "\"]/div/div/div[2]/div[3]";
|
||||
webDriver.findElement(By.xpath(zbglXpath)).click();
|
||||
log.info("打开预警页面------------");
|
||||
Thread.sleep(800);
|
||||
|
||||
//定位值班管理iframe的标签
|
||||
WebElement dutyIframe = webDriver.findElement(By.id("warningResTicket"));
|
||||
webDriver.switchTo().frame(dutyIframe);
|
||||
log.info("定位到预警响应管理iframe-----------");
|
||||
Thread.sleep(500);
|
||||
}
|
||||
private void openYuJingAction() throws InterruptedException{
|
||||
try {
|
||||
webDriver.manage().timeouts().implicitlyWait(3, TimeUnit.SECONDS);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
Thread.sleep(5000);
|
||||
//执行鼠标悬停动作-管理
|
||||
Actions action = new Actions(webDriver);
|
||||
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();
|
||||
Thread.sleep(300);
|
||||
log.info("执行鼠标悬停动作-管理");
|
||||
//获取管理标签中的aria-describedby属性 el-popover-7909
|
||||
String attributeId = wegl.getAttribute("aria-describedby");
|
||||
log.info("管理标签的ID值为:" + attributeId);
|
||||
Thread.sleep(300);
|
||||
|
||||
|
||||
// //执行鼠标悬停动作-预警行动
|
||||
// String ctzbXpath = "//*[@id=\"" + attributeId + "\"]/div/div[1]/div[2]/div[4]";
|
||||
// WebElement wectzb = webDriver.findElement(By.xpath(ctzbXpath));
|
||||
// action.moveToElement(wectzb).build().perform();
|
||||
// Thread.sleep(300);
|
||||
|
||||
|
||||
//打开预警响应管理页面
|
||||
//*[@id=\"" + attributeId + "\"]/div/div[2]/div[2]/div[1]/div[2]
|
||||
String zbglXpath = "//*[@id=\"" + attributeId + "\"]/div/div/div[2]/div[4]";
|
||||
webDriver.findElement(By.xpath(zbglXpath)).click();
|
||||
log.info("打开预警页面------------");
|
||||
Thread.sleep(800);
|
||||
|
||||
//定位值班管理iframe的标签
|
||||
WebElement dutyIframe = webDriver.findElement(By.id("yjczrwgl"));
|
||||
webDriver.switchTo().frame(dutyIframe);
|
||||
log.info("定位到预警响应处置任务管理iframe-----------");
|
||||
Thread.sleep(500);
|
||||
}
|
||||
|
||||
/**
|
||||
* 打开检查操练管理页面,并定位到日常操练的iframe
|
||||
*/
|
||||
private void openCheckTheDrills() throws InterruptedException {
|
||||
try {
|
||||
webDriver.manage().timeouts().implicitlyWait(3, TimeUnit.SECONDS);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
Thread.sleep(3000);
|
||||
//执行鼠标悬停动作-管理
|
||||
Actions action = new Actions(webDriver);
|
||||
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();
|
||||
Thread.sleep(300);
|
||||
|
||||
//获取管理标签中的aria-describedby属性
|
||||
String attributeId = wegl.getAttribute("aria-describedby");
|
||||
log.info("管理标签的ID值为:" + attributeId);
|
||||
Thread.sleep(300);
|
||||
|
||||
//执行鼠标悬停动作-检查操练管理
|
||||
String ctzbXpath = "//*[@id=\"" + attributeId + "\"]/div/div[1]/div[2]/div[5]";
|
||||
webDriver.findElement(By.xpath(ctzbXpath)).click();
|
||||
// WebElement wectzb =
|
||||
// action.moveToElement(wectzb).build().perform();
|
||||
Thread.sleep(1500);
|
||||
|
||||
//打开日常操练页面
|
||||
//*[@id=\"" + attributeId + "\"]/div/div[2]/div[2]/div[1]/div[2]
|
||||
// String zbglXpath = "//*[@id=\"" + attributeId + "\"]/div/div[2]/div[2]/div/div[1]";
|
||||
// webDriver.findElement(By.xpath(zbglXpath)).click();
|
||||
// log.info("打开日常操练页面------------");
|
||||
// /* TODO 800 --> 1500 */
|
||||
// Thread.sleep(1500);
|
||||
|
||||
//定位日常操练iframe的标签
|
||||
WebElement dutyIframe = webDriver.findElement(By.id("rccl"));
|
||||
webDriver.switchTo().frame(dutyIframe);
|
||||
log.info("定位到日常操练iframe-----------");
|
||||
Thread.sleep(8000);
|
||||
//定位日常操练iframe的标签
|
||||
// WebElement insideIframe = webDriver.findElement(By.xpath("/html/body/div/section/div[1]/div[2]/div/iframe"));
|
||||
// webDriver.switchTo().frame(insideIframe);
|
||||
// log.info("定位到日常操练内部iframe-----------");
|
||||
// Thread.sleep(3000);
|
||||
}
|
||||
|
||||
/**
|
||||
* 关闭浏览器驱动
|
||||
*/
|
||||
|
|
@ -342,7 +180,8 @@ public class AutoMain {
|
|||
Thread.sleep(5000);
|
||||
//执行鼠标悬停动作-管理
|
||||
Actions action = new Actions(webDriver);
|
||||
WebElement wegl = webDriver.findElement(By.xpath("//*[@id=\"app\"]/div/div[1]/div[6]/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();
|
||||
Thread.sleep(300);
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
package com.bonus.autoweb.base;
|
||||
|
||||
import com.bonus.autoweb.DateTimeUtils;
|
||||
|
||||
public class DataConfig {
|
||||
/**
|
||||
* url 网站地址
|
||||
|
|
@ -9,54 +11,36 @@ public class DataConfig {
|
|||
* 驱动名称
|
||||
*/
|
||||
protected static final String DRIVE_NAME = "webdriver.chrome.driver";
|
||||
// protected static final String DRIVE_NAME = "webdriver.gecko.driver";
|
||||
|
||||
/**
|
||||
* 用户名1 张宽杰
|
||||
* 用户名1
|
||||
*/
|
||||
public static final String USER_NAME1 = "zhangkj1533";
|
||||
public static final String USER_NAME1 = "hanhy0054";
|
||||
|
||||
/**
|
||||
* 密码1
|
||||
*/
|
||||
public static final String PASS1 = "zkj1533..";
|
||||
public static final String PASS1 = "hhylix0054++";
|
||||
|
||||
/**
|
||||
* 用户名2 张贺
|
||||
* 用户名2
|
||||
*/
|
||||
public static final String USER_NAME2 = "zhangh655x";
|
||||
public static final String USER_NAME2 = "fangwc8132";
|
||||
|
||||
/**
|
||||
* 密码2
|
||||
*/
|
||||
public static final String PASS2 = "f7ye@158";
|
||||
/**
|
||||
* 用户名3 杨军
|
||||
*/
|
||||
public static final String USER_NAME3 = "yangj0052";
|
||||
|
||||
/**
|
||||
* 密码3
|
||||
*/
|
||||
public static final String PASS3 = "QWas1357,";
|
||||
/**
|
||||
* 用户名4 肖国德
|
||||
*/
|
||||
public static final String USER_NAME4 = "xiaogd1494";
|
||||
|
||||
/**
|
||||
* 密码4
|
||||
*/
|
||||
public static final String PASS4 = "xgd**2271";
|
||||
public static final String PASS2 = "ahdl1234--";
|
||||
|
||||
/**
|
||||
* 浏览器驱动地址
|
||||
*/
|
||||
// protected static final String drivePath = "E:\\bns\\chromedriver_win32\\geckodriver.exe";//个人本地
|
||||
// protected static final String drivePath = "E:\\chromedriver_win32\\chromedriver.exe";//个人本地
|
||||
protected static final String drivePath = "E:\\bns\\chromedriver_win32\\chromedriver.exe";//宿州客户地址
|
||||
// protected static final String drivePath = "E:\\chromedriver_win32\\chromedriver.exe";
|
||||
protected static final String drivePath = "E:\\bns\\chromedriver_win32\\chromedriver.exe";
|
||||
|
||||
|
||||
public static final String filePath = "E:\\bns\\config";
|
||||
// public static final String filePath = "D:\\config";
|
||||
|
||||
public static String weatherUrl = "http://10.138.4.27:9021/EPCIM/control/ypdgt/qxyj/getQXYJ?city=泗县&rectime="+ DateTimeUtils.getCurrentDay();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ public class DutyChangeShifts {
|
|||
* 打开交接班页面
|
||||
*/
|
||||
public void openChangeShifts() throws InterruptedException {
|
||||
Thread.sleep(5000);
|
||||
Thread.sleep(3000);
|
||||
//定位交接班并点击
|
||||
webDriver.findElement(By.id("tab-6")).click();
|
||||
log.info("定位交接班并点击1----------");
|
||||
|
|
@ -56,10 +56,10 @@ public class DutyChangeShifts {
|
|||
} else {
|
||||
if (type == 1) {
|
||||
//晚交班
|
||||
xpaht = "//*[@id=\"pane-6\"]/div/div[3]/div[1]/div[1]/div[2]/button[1]";
|
||||
xpaht = "//*[@id=\"pane-6\"]/div/div[3]/div[2]/div[1]/div[2]/button[1]";
|
||||
} else {
|
||||
//晚班接班
|
||||
xpaht = "//*[@id=\"pane-6\"]/div/div[3]/div[1]/div[1]/div[2]/button[2]";
|
||||
xpaht = "//*[@id=\"pane-6\"]/div/div[3]/div[2]/div[1]/div[2]/button[2]";
|
||||
}
|
||||
}
|
||||
log.info("交接班地址:"+xpaht+"----------");
|
||||
|
|
@ -70,8 +70,18 @@ public class DutyChangeShifts {
|
|||
//交接事项说明
|
||||
if (type == 1) {
|
||||
// /html/body/div[3]/div/div[2]/div/form/div[7]/div/div[1]/textarea
|
||||
webDriver.findElement(By.xpath("/html/body/div[3]/div/div[2]/div/form/div[2]/div/div[1]/textarea")).sendKeys("正常");
|
||||
log.info("交接事项说明----------");
|
||||
|
||||
try {
|
||||
webDriver.findElement(By.xpath("/html/body/div[3]/div/div[2]/div/form/div[2]/div/div[1]/textarea")).sendKeys("正常");
|
||||
}catch (Exception e){
|
||||
log.info("交接事项说明div[3]不存在----------");
|
||||
}
|
||||
|
||||
try {
|
||||
webDriver.findElement(By.xpath("/html/body/div[8]/div/div[2]/div/form/div[2]/div/div[1]/textarea")).sendKeys("正常");
|
||||
}catch (Exception e){
|
||||
log.info("交接事项说明div[8]不存在----------");
|
||||
} log.info("交接事项说明----------");
|
||||
Thread.sleep(500);
|
||||
//提交
|
||||
webDriver.findElement(By.xpath("/html/body/div[3]/div/div[3]/div/button[2]")).click();
|
||||
|
|
@ -96,7 +106,7 @@ public class DutyChangeShifts {
|
|||
*/
|
||||
public void changeDay() throws Exception {
|
||||
|
||||
Thread.sleep(1000*3);
|
||||
Thread.sleep(1000*2);
|
||||
//判断当前日期是不是每月第一天的日期,true
|
||||
log.info("选择前一天----------");
|
||||
int tr = 1;
|
||||
|
|
@ -150,7 +160,7 @@ public class DutyChangeShifts {
|
|||
xpath = "//*[@id=\"app\"]/div/section/main/div/div[1]/div[1]/div[3]/div[2]/table/tbody/tr[" + tr + "]" + "/td[" + td + "]";
|
||||
// String dayNum = mothDay.substring(8, 10);
|
||||
// WebElement spanElement = webDriver.findElement(By.xpath("//*[@id=\"app\"]/div/section/main/div/div[1]/div[1]/div[3]/div[2]/table/tbody/tr[" + tr + "]" + "/td[" + td + "]/div/div/div[1]/span"));
|
||||
// if (dayNum.equals(spanElement.getText())) {
|
||||
// if (!dayNum.equals(spanElement.getText())) {
|
||||
// xpath = "//*[@id=\"app\"]/div/section/main/div/div[1]/div[1]/div[3]/div[2]/table/tbody/tr[" + (tr + 1) + "]" + "/td[" + td + "]/div";
|
||||
// }
|
||||
}
|
||||
|
|
@ -175,4 +185,4 @@ public class DutyChangeShifts {
|
|||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -69,9 +69,40 @@ public class DutyClock {
|
|||
log.info("打卡签到----------");
|
||||
Thread.sleep(1000*5);
|
||||
|
||||
//判断是否有相应的元素
|
||||
try {
|
||||
Thread.sleep(2000);
|
||||
webDriver.findElement(By.xpath("html/body/div[2]/div/div[3]/button[2]")).click();
|
||||
log.info("确认提前签到div[2]----------");
|
||||
} catch (Exception e) {
|
||||
log.info("无确认框,在时间范围内----------");
|
||||
}
|
||||
|
||||
//判断是否有相应的元素
|
||||
try {
|
||||
Thread.sleep(2000);
|
||||
webDriver.findElement(By.xpath("html/body/div[6]/div/div[3]/button[2]")).click();
|
||||
log.info("确认提前签到div[6]----------");
|
||||
} catch (Exception e) {
|
||||
log.info("无确认框,在时间范围内----------");
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
//点击弹出框确认
|
||||
webDriver.findElement(By.xpath("/html/body/div[2]/div/div[2]/div/div[2]/div[1]")).click();
|
||||
} catch (Exception e) {
|
||||
log.info("当前打卡确认按钮不存在div[2]");
|
||||
}
|
||||
try {
|
||||
//点击弹出框确认
|
||||
webDriver.findElement(By.xpath("/html/body/div[3]/div/div[2]/div/div[2]/div[1]")).click();
|
||||
} catch (Exception e) {
|
||||
log.info("当前打卡按钮不存在div[3]");
|
||||
}
|
||||
|
||||
//点击弹出框确认
|
||||
webDriver.findElement(By.xpath("/html/body/div[2]/div/div[2]/div/div[2]/div[1]")).click();
|
||||
//webDriver.findElement(By.xpath("/html/body/div[2]/div/div[2]/div/div[2]/div[1]")).click();
|
||||
log.info("点击弹出框确认----------");
|
||||
Thread.sleep(800);
|
||||
}
|
||||
|
|
@ -80,7 +111,7 @@ public class DutyClock {
|
|||
* 选择上个晚班签退
|
||||
*/
|
||||
public void changeDay() throws Exception {
|
||||
Thread.sleep(3000);
|
||||
Thread.sleep(800);
|
||||
//判断当前日期是不是每月第一天的日期,true
|
||||
boolean tf = false;
|
||||
int tr = 1;
|
||||
|
|
@ -128,11 +159,10 @@ public class DutyClock {
|
|||
//判断上个月最后一天的位置
|
||||
tr = DateTimeUtils.getWeekNum(mothDay);
|
||||
td = DateTimeUtils.getWeekOfDate(mothDay);
|
||||
|
||||
xpath = "//*[@id=\"app\"]/div/section/main/div/div[1]/div[1]/div[3]/div[2]/table/tbody/tr[" + tr + "]" + "/td[" + td + "]";
|
||||
// String dayNum = mothDay.substring(8, 10);
|
||||
// WebElement spanElement = webDriver.findElement(By.xpath("//*[@id=\"app\"]/div/section/main/div/div[1]/div[1]/div[3]/div[2]/table/tbody/tr[" + tr + "]" + "/td[" + td + "]/div/div/div[1]/span"));
|
||||
// if (dayNum.equals(spanElement.getText())) {
|
||||
// if (!dayNum.equals(spanElement.getText())) {
|
||||
// xpath = "//*[@id=\"app\"]/div/section/main/div/div[1]/div[1]/div[3]/div[2]/table/tbody/tr[" + (tr + 1) + "]" + "/td[" + td + "]/div";
|
||||
// }
|
||||
}
|
||||
|
|
@ -144,7 +174,7 @@ public class DutyClock {
|
|||
Thread.sleep(3000);
|
||||
//进行晚班签退操作
|
||||
log.info("进行晚班签退操作----------");
|
||||
dutyClockOper(1,2);
|
||||
dutyClockOper(2,2);
|
||||
|
||||
Thread.sleep(300);
|
||||
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ public class DutyDailyCheck {
|
|||
// do {
|
||||
// pageLoaded = (Boolean) jsExecutor.executeScript("return document.readyState").equals("complete");
|
||||
// } while (!pageLoaded);
|
||||
Thread.sleep(10000);
|
||||
Thread.sleep(5000);
|
||||
//定位值班日报并点击
|
||||
webDriver.findElement(By.id("tab-4")).click();
|
||||
log.info("定位值班日报并点击-----------");
|
||||
|
|
@ -68,7 +68,8 @@ public class DutyDailyCheck {
|
|||
|
||||
//同意审核按钮点击
|
||||
|
||||
WebElement tyCheckBtn=webDriver.findElement(By.xpath("//*[@id=\"app\"]/div/section/div/div[4]/div[1]/div[16]/button[4]"));
|
||||
WebElement tyCheckBtn=webDriver.findElement(By.xpath("//*[@id=\"app\"]/div/section/div/div[4]/div[1]/div[16" +
|
||||
"]/button[4]"));
|
||||
if(tyCheckBtn.isDisplayed()){
|
||||
//存在
|
||||
log.info("同意审核按钮存在-----------");
|
||||
|
|
@ -88,7 +89,6 @@ public class DutyDailyCheck {
|
|||
log.info("退出当前iframe----------");
|
||||
Thread.sleep(1000*2);
|
||||
|
||||
|
||||
//定位值班管理iframe的标签
|
||||
WebElement dutyIframe= webDriver.findElement(By.id("zbgln"));
|
||||
webDriver.switchTo().frame(dutyIframe);
|
||||
|
|
|
|||
|
|
@ -2162,16 +2162,19 @@ public class DutyDailyOp {
|
|||
|
||||
//点击弹出框确认
|
||||
///html/body/div[3]/div/div[3]/button[2]
|
||||
WebElement qrBtn2 = webDriver.findElement(By.xpath("/html/body/div[2]/div/div[3]/button[2]"));
|
||||
if (qrBtn2.isDisplayed()){
|
||||
WebElement qrBtn = webDriver.findElement(By.xpath("/html/body/div[2]/div/div[3]/button[2]"));
|
||||
if (qrBtn.isDisplayed()) {
|
||||
//存在
|
||||
log.info("日报确认按钮2存在-----------");
|
||||
log.info("日报确认按钮2:" + qrBtn2.getAttribute("class"));
|
||||
log.info("日报确认按钮2:" + qrBtn2.getAttribute("type"));
|
||||
log.info("日报确认按钮2:" + qrBtn2.getText());
|
||||
qrBtn2.click();
|
||||
log.info("日报确认按钮存在-----------");
|
||||
log.info("日报确认按钮:" + qrBtn.getAttribute("class"));
|
||||
log.info("日报确认按钮:" + qrBtn.getAttribute("type"));
|
||||
log.info("日报确认按钮:" + qrBtn.getText());
|
||||
qrBtn.click();
|
||||
|
||||
Thread.sleep(1000);
|
||||
}else{
|
||||
//取消弹框
|
||||
// webDriver.findElement(By.xpath("/html/body/div[3]/div/div[3]/button[1]")).click();
|
||||
} else{
|
||||
log.info("日报确认按钮不存在-----------");
|
||||
}
|
||||
log.info("点击弹出框确认----------");
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ import java.io.FileInputStream;
|
|||
import java.io.InputStreamReader;
|
||||
import java.nio.charset.Charset;
|
||||
import java.text.ParseException;
|
||||
import java.util.Calendar;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
|
||||
|
|
@ -23,7 +24,7 @@ import org.slf4j.Logger;
|
|||
* 操作值班日志类
|
||||
*/
|
||||
public class DutyLogIOp {
|
||||
private Logger log = LoggerFactory.getLogger(DutyLogIOp.class);
|
||||
private Logger log = LoggerFactory.getLogger(DutyLogIOp.class);
|
||||
private WebDriver webDriver;
|
||||
|
||||
public DutyLogIOp(WebDriver webDriver) {
|
||||
|
|
@ -40,37 +41,37 @@ public class DutyLogIOp {
|
|||
//早上填写前一天的日志,将标签改为前一天
|
||||
changeDay();
|
||||
}
|
||||
Thread.sleep(5000);
|
||||
Thread.sleep(3000);
|
||||
//定位值班日志并点击
|
||||
webDriver.findElement(By.id("tab-5")).click();
|
||||
log.info("定位值班日志并点击----------");
|
||||
Thread.sleep(5000);
|
||||
Thread.sleep(3000);
|
||||
|
||||
// /html/body/div[2] 弹窗 您没有填写值班日志的排班班次
|
||||
|
||||
//定位写日志标签,打开日志页面
|
||||
webDriver.findElement(By.xpath("//*[@id=\"pane-5\"]/div/div[2]/div[2]/button")).click();
|
||||
log.info("定位写日志标签,打开日志页面----------");
|
||||
Thread.sleep(500);
|
||||
Thread.sleep(300);
|
||||
|
||||
|
||||
//退出当前iframe,进入到日报编辑iframe
|
||||
webDriver.switchTo().defaultContent();
|
||||
log.info("退出当前iframe----------");
|
||||
Thread.sleep(5500);
|
||||
Thread.sleep(300);
|
||||
|
||||
//定位日志编辑iframe的标签
|
||||
WebElement dutyEditIframe = webDriver.findElement(By.id("add-local-zbrzbz"));
|
||||
webDriver.switchTo().frame(dutyEditIframe);
|
||||
log.info("定位日志编辑iframe的标签----------");
|
||||
Thread.sleep(1000);
|
||||
Thread.sleep(300);
|
||||
dutyLogContent();
|
||||
|
||||
if (type == 1) {
|
||||
//昨天的日志填写完毕之后将日期改为今天
|
||||
webDriver.findElement(By.xpath("//*[@id=\"app\"]/div/section/main/div/div[1]/div[1]/div[3]/div[1]/div[2]/div/button[2]")).click();
|
||||
log.info("将日期选择回当日----------");
|
||||
Thread.sleep(500);
|
||||
Thread.sleep(300);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -85,12 +86,12 @@ public class DutyLogIOp {
|
|||
if (!DateTimeUtils.isOneDay()) {
|
||||
//不是本月第一天
|
||||
String currentDay = DateTimeUtils.getCurrentDay();
|
||||
log.info("currentDay:" + currentDay);
|
||||
log.info("currentDay:"+currentDay);
|
||||
int weekNum = DateTimeUtils.getWeekNum(currentDay);
|
||||
log.info("weekNum:" + weekNum);
|
||||
log.info("weekNum:"+weekNum);
|
||||
int dayNum = DateTimeUtils.getWeekOfDate(currentDay);
|
||||
log.info("dayNum:" + dayNum);
|
||||
/*if (dayNum == 1) {
|
||||
log.info("dayNum:"+dayNum);
|
||||
/* if (dayNum == 1) {
|
||||
tr = weekNum - 1;
|
||||
td = 7;
|
||||
} else {
|
||||
|
|
@ -98,51 +99,54 @@ public class DutyLogIOp {
|
|||
td = dayNum - 1;
|
||||
}*/
|
||||
if (dayNum == 1) {
|
||||
if (DateTimeUtils.getMonthOneDayIs0()) {//第一天是0
|
||||
if(DateTimeUtils.getMonthOneDayIs0()){//第一天是0
|
||||
tr = weekNum;
|
||||
} else {
|
||||
tr = weekNum - 1;
|
||||
if (weekNum == 1) {
|
||||
}else{
|
||||
tr = weekNum-1;
|
||||
if (weekNum == 1){
|
||||
tr = 5;
|
||||
}
|
||||
}
|
||||
td = 7;
|
||||
} else {
|
||||
if (DateTimeUtils.getMonthOneDayIs0()) {//第一天是0
|
||||
tr = weekNum + 1;
|
||||
} else {
|
||||
}else {
|
||||
if(DateTimeUtils.getMonthOneDayIs0()){//第一天是0
|
||||
tr = weekNum+1;
|
||||
}else{
|
||||
tr = weekNum;
|
||||
}
|
||||
td = dayNum - 1;
|
||||
}
|
||||
log.info("标签位置:tr:" + tr + ",td:" + td);
|
||||
|
||||
log.info("标签位置:tr:"+tr+",td:"+td);
|
||||
|
||||
xpath = "//*[@id=\"app\"]/div/section/main/div/div[1]/div[1]/div[3]/div[2]/table/tbody/tr[" + tr + "]" + "/td[" + td + "]/div";
|
||||
} else {
|
||||
//点击上月按钮,切换至上月
|
||||
// 如果是本月的第一天,点击上月按钮切换到上月
|
||||
webDriver.findElement(By.xpath("//*[@id=\"app\"]/div/section/main/div/div[1]/div[1]/div[3]/div[1]/div[2]/div/button[1]")).click();
|
||||
log.info("点击上月按钮,切换至上月----------");
|
||||
Thread.sleep(500);
|
||||
|
||||
//获取上月最后一天日期
|
||||
// 获取上月的最后一天
|
||||
String mothDay = DateTimeUtils.getBeforeLastMonthdate();
|
||||
//判断上个月最后一天的位置
|
||||
tr = DateTimeUtils.getWeekNum(mothDay);
|
||||
td = DateTimeUtils.getWeekOfDate(mothDay);
|
||||
// 判断上个月最后一天的位置
|
||||
int weekNum = DateTimeUtils.getWeekNum(mothDay);
|
||||
int dayNum = DateTimeUtils.getWeekOfDate(mothDay);
|
||||
// 获取上月最后一天在日历中的位置
|
||||
if (isFirstDayOfLastMonthSunday()) {
|
||||
tr = weekNum + 1;
|
||||
} else {
|
||||
tr = weekNum;
|
||||
}
|
||||
td = dayNum;
|
||||
xpath = "//*[@id=\"app\"]/div/section/main/div/div[1]/div[1]/div[3]/div[2]/table/tbody/tr[" + tr + "]" + "/td[" + td + "]/div";
|
||||
// String dayNum = mothDay.substring(8, 10);
|
||||
// WebElement spanElement = webDriver.findElement(By.xpath("//*[@id=\"app\"]/div/section/main/div/div[1]/div[1]/div[3]/div[2]/table/tbody/tr[" + tr + "]" + "/td[" + td + "]/div/div/div[1]/span"));
|
||||
// if (dayNum.equals(spanElement.getText())) {
|
||||
// xpath = "//*[@id=\"app\"]/div/section/main/div/div[1]/div[1]/div[3]/div[2]/table/tbody/tr[" + (tr + 1) + "]" + "/td[" + td + "]/div";
|
||||
// }
|
||||
|
||||
}
|
||||
//选择前一天的日期
|
||||
|
||||
log.info("前一天的标签:" + xpath);
|
||||
log.info("前一天的标签:"+xpath);
|
||||
|
||||
webDriver.findElement(By.xpath(xpath)).click();
|
||||
log.info("选择前一天的日期----------");
|
||||
Thread.sleep(500);
|
||||
Thread.sleep(300);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -153,10 +157,10 @@ public class DutyLogIOp {
|
|||
// /html/body/div[3]/div/div[2]/div/form/div[1]/div/div/div[1]/div/div/div/div
|
||||
webDriver.findElement(By.xpath("/html/body/div[3]/div/div[2]/div/form/div[1]/div/div/div[1]/div/div/div/div[1]")).click();
|
||||
log.info("值班时间----------");
|
||||
Thread.sleep(500);
|
||||
Thread.sleep(300);
|
||||
webDriver.findElement(By.xpath("/html/body/div[4]/div[1]/div[1]/ul/li")).click();
|
||||
log.info("值班时间----------");
|
||||
Thread.sleep(500);
|
||||
Thread.sleep(300);
|
||||
|
||||
// 反序列化--> 解决乱码问题
|
||||
File file = new File(DataConfig.filePath + "\\log.xml");
|
||||
|
|
@ -164,15 +168,15 @@ public class DutyLogIOp {
|
|||
String xml = null;
|
||||
try {
|
||||
//主要就是这里的设置
|
||||
in = new InputStreamReader(new FileInputStream(file), Charset.forName("gbk"));
|
||||
in = new InputStreamReader(new FileInputStream(file), Charset.forName("gbk") );
|
||||
StringBuffer sb = new StringBuffer();
|
||||
char[] array = new char[1024];
|
||||
char[] array= new char[1024];
|
||||
int length = -1;
|
||||
while ((length = in.read(array)) != -1) {
|
||||
while((length=in.read(array))!= -1){
|
||||
sb.append(array, 0, length);
|
||||
}
|
||||
in.close();
|
||||
xml = sb.toString().trim();
|
||||
xml=sb.toString().trim();
|
||||
System.out.println(xml);
|
||||
} catch (Exception e) {
|
||||
// TODO: handle exception
|
||||
|
|
@ -221,184 +225,155 @@ public class DutyLogIOp {
|
|||
// /html/body/div[3]/div/div[2]/div/form/div[4]/table/tr[2]/td/table[1]/tr[1]/td/div[3]/div/div[1]/textarea
|
||||
webDriver.findElement(By.xpath("/html/body/div[3]/div/div[2]/div/form/div[4]/table/tr[2]/td/table[1]/tr[1]/td/div[3]/div/div/textarea")).sendKeys(sjjc_title);
|
||||
log.info("事件监测 标题----------");
|
||||
Thread.sleep(500);
|
||||
Thread.sleep(300);
|
||||
//事件监测 内容
|
||||
String sjjc_content = bean.getEvent_detection_content();
|
||||
webDriver.findElement(By.xpath("/html/body/div[3]/div/div[2]/div/form/div[4]/table/tr[2]/td/table[1]/tr[2]/td/div/div/div/textarea")).sendKeys(sjjc_content);
|
||||
log.info("事件监测 内容----------");
|
||||
Thread.sleep(500);
|
||||
Thread.sleep(300);
|
||||
|
||||
//保电工作 标题
|
||||
String bdgz_title = bean.getPower_work_title();
|
||||
webDriver.findElement(By.xpath("/html/body/div[3]/div/div[2]/div/form/div[4]/table/tr[2]/td/table[2]/tr[1]/td/div[3]/div/div/textarea")).sendKeys(bdgz_title);
|
||||
log.info("保电工作 标题----------");
|
||||
Thread.sleep(2000);
|
||||
|
||||
Thread.sleep(300);
|
||||
//保电工作 内容
|
||||
String bdgz_content = bean.getPower_work_content();
|
||||
System.out.println("bdgz_content:" + bdgz_content);
|
||||
WebElement bdgzContentElement = webDriver.findElement(By.xpath("/html/body/div[3]/div/div[2]/div/form/div[4]/table/tr[2]/td/table[2]/tr[2]/td/div/div/div[1]/textarea"));
|
||||
|
||||
bdgzContentElement.clear();
|
||||
bdgzContentElement.sendKeys(bdgz_content.trim());
|
||||
// webDriver.findElement(By.xpath("/html/body/div[3]/div/div[2]/div/form/div[4]/table/tr[2]/td/table[2]/tr[2]/td/div/div/div[1]/textarea")).sendKeys(bdgz_content);
|
||||
webDriver.findElement(By.xpath("/html/body/div[3]/div/div[2]/div/form/div[4]/table/tr[2]/td/table[2]/tr[2]/td/div/div/div/textarea")).sendKeys(bdgz_content);
|
||||
log.info("保电工作 内容----------");
|
||||
Thread.sleep(2000);
|
||||
Thread.sleep(300);
|
||||
|
||||
//资源核查 标题
|
||||
String zyhc_title = bean.getResource_check_title();
|
||||
webDriver.findElement(By.xpath("/html/body/div[3]/div/div[2]/div/form/div[4]/table/tr[2]/td/table[3]/tr[1]/td/div[3]/div/div/textarea")).sendKeys(zyhc_title);
|
||||
log.info("资源核查 标题----------");
|
||||
Thread.sleep(500);
|
||||
Thread.sleep(300);
|
||||
//资源核查 内容
|
||||
String zyhc_content = bean.getResource_check_content();
|
||||
webDriver.findElement(By.xpath("/html/body/div[3]/div/div[2]/div/form/div[4]/table/tr[2]/td/table[3]/tr[2]/td/div/div/div/textarea")).sendKeys(zyhc_content);
|
||||
log.info("资源核查 内容----------");
|
||||
Thread.sleep(500);
|
||||
Thread.sleep(300);
|
||||
|
||||
//通信测试 标题
|
||||
String txcs_title = bean.getCommunications_test_title();
|
||||
webDriver.findElement(By.xpath("/html/body/div[3]/div/div[2]/div/form/div[4]/table/tr[2]/td/table[4]/tr[1]/td/div[3]/div/div/textarea")).sendKeys(txcs_title);
|
||||
log.info("通信测试 标题----------");
|
||||
Thread.sleep(500);
|
||||
Thread.sleep(300);
|
||||
//通信测试 内容
|
||||
String txcs_content = bean.getCommunications_test_content();
|
||||
webDriver.findElement(By.xpath("/html/body/div[3]/div/div[2]/div/form/div[4]/table/tr[2]/td/table[4]/tr[2]/td/div/div/div/textarea")).sendKeys(txcs_content);
|
||||
log.info("通信测试 内容----------");
|
||||
Thread.sleep(500);
|
||||
Thread.sleep(300);
|
||||
|
||||
|
||||
//日常操练情况 标题
|
||||
String rcclqk_title = bean.getDaily_operation_title();
|
||||
webDriver.findElement(By.xpath("/html/body/div[3]/div/div[2]/div/form/div[4]/table/tr[2]/td/table[5]/tr[1]/td/div[3]/div/div/textarea")).sendKeys(rcclqk_title);
|
||||
log.info("日常操练情况 标题----------");
|
||||
Thread.sleep(500);
|
||||
Thread.sleep(300);
|
||||
//日常操练情况 内容
|
||||
String rcclqk_content = bean.getDaily_operation_content();
|
||||
webDriver.findElement(By.xpath("/html/body/div[3]/div/div[2]/div/form/div[4]/table/tr[2]/td/table[5]/tr[2]/td/div/div/div/textarea")).sendKeys(rcclqk_content);
|
||||
log.info("日常操练情况 内容----------");
|
||||
Thread.sleep(500);
|
||||
Thread.sleep(300);
|
||||
|
||||
//日报填写情况 标题
|
||||
String rbtxqk_title = bean.getDaily_submission_title();
|
||||
webDriver.findElement(By.xpath("/html/body/div[3]/div/div[2]/div/form/div[4]/table/tr[2]/td/table[6]/tr[1]/td/div[3]/div/div/textarea")).sendKeys(rbtxqk_title);
|
||||
log.info("日报填写情况 标题----------");
|
||||
Thread.sleep(500);
|
||||
Thread.sleep(300);
|
||||
//日常操练情况 内容
|
||||
String rbtxqk_content = bean.getDaily_submission_content();
|
||||
webDriver.findElement(By.xpath("/html/body/div[3]/div/div[2]/div/form/div[4]/table/tr[2]/td/table[6]/tr[2]/td/div/div/div/textarea")).sendKeys(rbtxqk_content);
|
||||
log.info("日常操练情况 内容----------");
|
||||
Thread.sleep(500);
|
||||
Thread.sleep(300);
|
||||
|
||||
//预警处置 标题
|
||||
String yjcz_title = bean.getWarning_disposal_title();
|
||||
webDriver.findElement(By.xpath("/html/body/div[3]/div/div[2]/div/form/div[4]/table/tr[2]/td/table[7]/tr[1]/td/div[3]/div/div/textarea")).sendKeys(yjcz_title);
|
||||
log.info("预警处置 标题----------");
|
||||
Thread.sleep(500);
|
||||
Thread.sleep(300);
|
||||
//预警处置 内容
|
||||
String yjcz_content = bean.getWarning_disposal_content();
|
||||
webDriver.findElement(By.xpath("/html/body/div[3]/div/div[2]/div/form/div[4]/table/tr[2]/td/table[7]/tr[2]/td/div/div/div/textarea")).sendKeys(yjcz_content);
|
||||
log.info("预警处置 内容----------");
|
||||
Thread.sleep(500);
|
||||
Thread.sleep(300);
|
||||
|
||||
//一般记事 标题
|
||||
String ybjs_title = bean.getGeneral_chronicles_title();
|
||||
webDriver.findElement(By.xpath("/html/body/div[3]/div/div[2]/div/form/div[4]/table/tr[2]/td/table[8]/tr[1]/td/div[3]/div/div/textarea")).sendKeys(ybjs_title);
|
||||
log.info("一般记事 标题----------");
|
||||
Thread.sleep(500);
|
||||
Thread.sleep(300);
|
||||
//一般记事 内容
|
||||
String ybjs_content = bean.getGeneral_chronicles_content();
|
||||
webDriver.findElement(By.xpath("/html/body/div[3]/div/div[2]/div/form/div[4]/table/tr[2]/td/table[8]/tr[2]/td/div/div/div/textarea")).sendKeys(ybjs_content);
|
||||
log.info("一般记事 内容----------");
|
||||
Thread.sleep(500);
|
||||
Thread.sleep(300);
|
||||
|
||||
|
||||
//提交日志
|
||||
|
||||
WebElement submitDay = webDriver.findElement(By.xpath("/html/body/div[3]/div/div[3]/div/button[3]"));
|
||||
log.info("提交日志按钮:" + submitDay.getText());
|
||||
WebElement submitDay=webDriver.findElement(By.xpath("/html/body/div[3]/div/div[3]/div/button[3]"));
|
||||
log.info("提交日志按钮:"+submitDay.getText());
|
||||
submitDay.click();
|
||||
log.info("提交日志----------");
|
||||
Thread.sleep(500);
|
||||
Thread.sleep(300);
|
||||
|
||||
//判断是否有相应的元素
|
||||
try{
|
||||
Thread.sleep(2000);
|
||||
webDriver.findElement(By.xpath("html/body/div[3]/div/div[3]/button[2]")).click();
|
||||
log.info("是否确认签到----------");
|
||||
}catch (Exception e){
|
||||
log.info("无确认框,在时间范围内div[3]----------");
|
||||
}
|
||||
try{
|
||||
Thread.sleep(2000);
|
||||
webDriver.findElement(By.xpath("html/body/div[4]/div/div[3]/button[2]")).click();
|
||||
log.info("是否确认签到----------");
|
||||
}catch (Exception e){
|
||||
log.info("无确认框,在时间范围内div[4]----------");
|
||||
}
|
||||
|
||||
|
||||
//点击弹出框确认
|
||||
WebElement qrBtn = webDriver.findElement(By.xpath("/html/body/div[4]/div/div[3]/button[2]"));
|
||||
log.info("确认日志按钮:" + qrBtn.getText());
|
||||
WebElement qrBtn=webDriver.findElement(By.xpath("/html/body/div[4]/div/div[3]/button[2]"));
|
||||
log.info("确认日志按钮:"+qrBtn.getText());
|
||||
qrBtn.click();
|
||||
|
||||
Thread.sleep(1000 * 3);
|
||||
Thread.sleep(1000*3);
|
||||
//取消
|
||||
// webDriver.findElement(By.xpath("/html/body/div[4]/div/div[3]/button[1]")).click();
|
||||
|
||||
log.info("点击弹出框确认----------");
|
||||
Thread.sleep(500);
|
||||
Thread.sleep(300);
|
||||
|
||||
//测试 点击取消按钮
|
||||
/*webDriver.findElement(By.xpath("/html/body/div[3]/div/div[3]/div/button[1]")).click();
|
||||
log.info("点击取消----------");
|
||||
Thread.sleep(500);*/
|
||||
Thread.sleep(300);*/
|
||||
|
||||
|
||||
//退出当前iframe,
|
||||
webDriver.switchTo().defaultContent();
|
||||
log.info("退出当前iframe----------");
|
||||
Thread.sleep(500);
|
||||
Thread.sleep(3000);
|
||||
|
||||
|
||||
//定位值班管理iframe的标签
|
||||
WebElement dutyIframe = webDriver.findElement(By.id("zbgln"));
|
||||
webDriver.switchTo().frame(dutyIframe);
|
||||
log.info("定位值班管理iframe的标签----------");
|
||||
Thread.sleep(500);
|
||||
Thread.sleep(3000);
|
||||
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws ParseException {
|
||||
int tr = 1;
|
||||
int td = 1;
|
||||
String currentDay = "2024-01-01";
|
||||
System.out.println(currentDay);
|
||||
int weekNum = DateTimeUtils.getWeekNum(currentDay);
|
||||
System.out.println(weekNum);
|
||||
int dayNum = DateTimeUtils.getWeekOfDate(currentDay);
|
||||
System.out.println(dayNum);
|
||||
/*if (dayNum == 1) {
|
||||
tr = weekNum - 1;
|
||||
td = 7;
|
||||
} else {
|
||||
tr = weekNum;
|
||||
td = dayNum - 1;
|
||||
}*/
|
||||
if (dayNum == 1) {
|
||||
if (DateTimeUtils.getMonthOneDayIs0()) {//第一天是0
|
||||
tr = weekNum;
|
||||
} else {
|
||||
tr = weekNum - 1;
|
||||
if (weekNum == 1) {
|
||||
tr = 5;
|
||||
}
|
||||
}
|
||||
td = 7;
|
||||
} else {
|
||||
if (DateTimeUtils.getMonthOneDayIs0()) {//第一天是0
|
||||
tr = weekNum + 1;
|
||||
} else {
|
||||
tr = weekNum;
|
||||
}
|
||||
td = dayNum - 1;
|
||||
}
|
||||
System.out.println(tr);
|
||||
System.out.println(td);
|
||||
System.out.println("-------------------------");
|
||||
//获取上月最后一天日期
|
||||
String mothDay = "2023-12-31";
|
||||
System.out.println(mothDay);
|
||||
//判断上个月最后一天的位置
|
||||
tr = DateTimeUtils.getWeekNum(mothDay);
|
||||
td = DateTimeUtils.getWeekOfDate(mothDay);
|
||||
System.out.println(tr);
|
||||
System.out.println(td);
|
||||
System.out.println(mothDay.substring(8,10));
|
||||
public static boolean isFirstDayOfLastMonthSunday() {
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.add(Calendar.MONTH, -1); // Move to the previous month
|
||||
calendar.set(Calendar.DAY_OF_MONTH, 1); // Set to the first day of the month
|
||||
|
||||
int dayOfWeek = calendar.get(Calendar.DAY_OF_WEEK);
|
||||
return dayOfWeek == Calendar.SUNDAY;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,26 +1,11 @@
|
|||
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;
|
||||
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.openqa.selenium.By;
|
||||
import org.openqa.selenium.WebElement;
|
||||
import org.slf4j.Logger;
|
||||
import org.openqa.selenium.WebDriver;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
|
||||
/**
|
||||
* 应急指挥中心打卡任务类
|
||||
*/
|
||||
|
|
@ -47,6 +32,29 @@ public class AutoWebTask {
|
|||
log.info("韩宏宇开始打卡任务---------------------");
|
||||
dutySigin(classes, 1, DataConfig.USER_NAME1, DataConfig.PASS1);
|
||||
}
|
||||
public void testLogin(int classes) {
|
||||
log.info("开始打卡任务---------------------");
|
||||
log.info("房万春开始打卡任务---------------------");
|
||||
//使用房万春账号签到
|
||||
loginDemo(classes, 1, DataConfig.USER_NAME2, DataConfig.PASS2);
|
||||
}
|
||||
|
||||
public int loginDemo(int classes, int type, String userName, String pass) {
|
||||
AutoMain autoMain = new AutoMain();
|
||||
int count = 0;
|
||||
try {
|
||||
autoMain.initDrive();
|
||||
WebDriver webDriver = autoMain.getWebDriver();
|
||||
autoMain.startAuto(userName, pass);
|
||||
DutyClock dutyClock = new DutyClock(webDriver);
|
||||
dutyClock.openDutyClock();
|
||||
}catch (Exception e) {
|
||||
log.error("签到任务", e);
|
||||
} finally {
|
||||
autoMain.closeDrive();
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
/**
|
||||
* 签到任务
|
||||
|
|
@ -62,15 +70,15 @@ public class AutoWebTask {
|
|||
AutoMain autoMain = new AutoMain();
|
||||
int count = 0;
|
||||
try {
|
||||
autoMain.initDrive(2);
|
||||
autoMain.initDrive();
|
||||
WebDriver webDriver = autoMain.getWebDriver();
|
||||
autoMain.startAuto(userName, pass);
|
||||
DutyClock dutyClock = new DutyClock(webDriver);
|
||||
dutyClock.openDutyClock();
|
||||
dutyClock.dutyClockOper(classes, type);
|
||||
count = 1;
|
||||
//关闭浏览器
|
||||
autoMain.closeDrive();
|
||||
count = 1;
|
||||
} catch (Exception e) {
|
||||
log.error("签到任务", e);
|
||||
} finally {
|
||||
|
|
@ -85,21 +93,20 @@ public class AutoWebTask {
|
|||
*
|
||||
* @param type 1 早报 2晚报
|
||||
*/
|
||||
public int dutyAddDailyLogsTask(int type, String username, String password) {
|
||||
public int dutyAddDailyLogsTask(int type) {
|
||||
log.info("开始日报填写任务---------------------");
|
||||
//打开浏览器,进入应急指挥中心网站
|
||||
AutoMain autoMain = new AutoMain();
|
||||
WebDriver webDriver;
|
||||
int count = 0;
|
||||
try {
|
||||
autoMain.initDrive(1);
|
||||
autoMain.startAuto(username, password);
|
||||
autoMain.initDrive();
|
||||
autoMain.startAuto(DataConfig.USER_NAME1, DataConfig.PASS1);
|
||||
webDriver = autoMain.getWebDriver();
|
||||
//操作日报
|
||||
DutyDailyOp ddo = new DutyDailyOp(webDriver);
|
||||
ddo.openDutyDaily(type);
|
||||
Thread.sleep(5000);
|
||||
count = 1;
|
||||
Thread.sleep(1000);
|
||||
} catch (Exception e) {
|
||||
log.error("日报填写任务", e);
|
||||
}
|
||||
|
|
@ -111,7 +118,6 @@ public class AutoWebTask {
|
|||
Thread.sleep(1000);
|
||||
count = 1;
|
||||
} catch (Exception e) {
|
||||
count = 0;
|
||||
log.error("日报审核工作", e);
|
||||
} finally {
|
||||
autoMain.closeDrive();
|
||||
|
|
@ -119,173 +125,113 @@ public class AutoWebTask {
|
|||
return count;
|
||||
}
|
||||
|
||||
public int dutyAddLogsTask(int type, String username, String password) {
|
||||
public int dutyAddLogsTask(int type) {
|
||||
log.info("开始日志填写任务---------------------");
|
||||
//打开浏览器,进入应急指挥中心网站
|
||||
int count = 0;
|
||||
AutoMain autoMain = new AutoMain();
|
||||
WebDriver webDriver;
|
||||
try {
|
||||
autoMain.initDrive(1);
|
||||
autoMain.startAuto(username, password);
|
||||
autoMain.initDrive();
|
||||
autoMain.startAuto(DataConfig.USER_NAME1, DataConfig.PASS1);
|
||||
//操作日志
|
||||
webDriver = autoMain.getWebDriver();
|
||||
DutyLogIOp dlo = new DutyLogIOp(webDriver);
|
||||
dlo.openDutyLog(type);
|
||||
count = 1;
|
||||
} catch (Exception e) {
|
||||
count = 0;
|
||||
log.error("操作日志任务", e);
|
||||
} finally {
|
||||
}finally {
|
||||
autoMain.closeDrive();
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
public int changeTodayPersonaTask(int type, String username, String password) throws IOException {
|
||||
log.info("开始日志填写任务---------------------");
|
||||
//打开浏览器,进入应急指挥中心网站
|
||||
int count = 0;
|
||||
/**
|
||||
* 定时获取基础数据
|
||||
*/
|
||||
public int getYuJingData(int classes) {
|
||||
AutoMain autoMain = new AutoMain();
|
||||
WebDriver webDriver;
|
||||
FileInputStream excelFile = null;
|
||||
Workbook workbook = null;
|
||||
int count = 0;
|
||||
try {
|
||||
autoMain.initDrive(1);
|
||||
autoMain.startAuto(username, password);
|
||||
//操作日志
|
||||
autoMain.initDrive();
|
||||
log.info("初始化驱动成功");
|
||||
autoMain.startAuto(DataConfig.USER_NAME1, DataConfig.PASS1);
|
||||
log.info("startYuJingAuto成功");
|
||||
//获取基础数据
|
||||
webDriver = autoMain.getWebDriver();
|
||||
Thread.sleep(3000);
|
||||
//将日期改为今天的日期
|
||||
webDriver.findElement(By.xpath("//*[@id=\"app\"]/div/section/main/div/div[1]/div[1]/div[3]/div[1]/div[2]/div/button[2]")).click();
|
||||
log.info("将日期选择回当日----------");
|
||||
Thread.sleep(1000);
|
||||
//获取值班长账号姓名 和 账号名
|
||||
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]"));
|
||||
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 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);
|
||||
|
||||
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 = "";
|
||||
for (Cell cell : row) {
|
||||
value += cell.getStringCellValue() + "]]]";
|
||||
}
|
||||
value = value.substring(0, value.length() - 3);
|
||||
try{
|
||||
if (value.contains(personName)) {
|
||||
personPassword = value.split("]]]")[2];
|
||||
account = value.split("]]]")[1];
|
||||
}
|
||||
}catch (IndexOutOfBoundsException ignored){
|
||||
log.error("出现异常:"+personName+"账号内容出错,在表格的第"+rowNum+"行附近");
|
||||
}
|
||||
try{
|
||||
if (value.contains(personLeaderName)) {
|
||||
personLeaderPassword = value.split("]]]")[2];
|
||||
accountLeader = value.split("]]]")[1];
|
||||
}
|
||||
}catch (IndexOutOfBoundsException ignored){
|
||||
log.error("出现异常:"+personLeaderName+"账号内容出错,在表格的第"+rowNum+"行附近");
|
||||
}
|
||||
rowNum++;
|
||||
}
|
||||
AutoUtils.write("E:\\bns\\config\\今日值班账号.txt", "今日值班长账号:"+accountLeader+";密码:"+personLeaderPassword+";\n" +
|
||||
"今日值班员账号:"+account+";密码:"+personPassword+";");
|
||||
excelFile.close();
|
||||
GetBasicData gbd = new GetBasicData(webDriver);
|
||||
log.info("获取天气预警值启动----");
|
||||
gbd.getYuJingBasicData(classes);
|
||||
count = 1;
|
||||
} catch (Exception e) {
|
||||
log.error("操作日志任务", 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();
|
||||
log.info("初始化驱动成功");
|
||||
autoMain.startAuto(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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 交接班任务
|
||||
*
|
||||
* @param classes 班次,,1早班 2晚班
|
||||
*/
|
||||
public int dutyChangeTask1(int classes, String userName, String password) {
|
||||
// 先交班 1 在接班 2
|
||||
//先走class1 在走class2
|
||||
log.info("开始交班任务---------------------");
|
||||
public int dutyChangeTask(int classes) {
|
||||
log.info("开始交接班任务---------------------");
|
||||
AutoMain autoMain = new AutoMain();
|
||||
int count = 0;
|
||||
WebDriver webDriver;
|
||||
try {
|
||||
//打开浏览器,进入应急指挥中心网站
|
||||
autoMain.initDrive(2);
|
||||
autoMain.startAuto(userName, password);
|
||||
webDriver = autoMain.getWebDriver();
|
||||
autoMain.initDrive();
|
||||
autoMain.startAuto(DataConfig.USER_NAME1, DataConfig.PASS1);
|
||||
WebDriver webDriver = autoMain.getWebDriver();
|
||||
|
||||
DutyChangeShifts dutyChangeShifts = new DutyChangeShifts(webDriver);
|
||||
//进行交班工作
|
||||
if (classes == 2) {
|
||||
dutyChangeShifts.openChangeShifts();
|
||||
dutyChangeShifts.dutychangeOper(1, 2);
|
||||
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);
|
||||
|
||||
try{
|
||||
dutyChangeShifts.dutychangeOper(classes, 2);
|
||||
}catch (Exception e) {
|
||||
log.error("交接班-接班已完成:", e);
|
||||
}
|
||||
count = 1;
|
||||
//关闭浏览器
|
||||
autoMain.closeDrive();
|
||||
count = 1;
|
||||
} catch (Exception e) {
|
||||
count = 0;
|
||||
log.error("交接班任务:" + e);
|
||||
|
|
@ -306,7 +252,7 @@ public class AutoWebTask {
|
|||
int count = 0;
|
||||
try {
|
||||
//打开浏览器,进入应急指挥中心网站
|
||||
autoMain.initDrive(2);
|
||||
autoMain.initDrive();
|
||||
autoMain.startAuto(userName, pass);
|
||||
WebDriver webDriver = autoMain.getWebDriver();
|
||||
|
||||
|
|
@ -316,9 +262,9 @@ public class AutoWebTask {
|
|||
} else {
|
||||
dutyClock.dutyClockOper(1, 2);
|
||||
}
|
||||
count = 1;
|
||||
//关闭浏览器
|
||||
autoMain.closeDrive();
|
||||
count = 1;
|
||||
} catch (Exception e) {
|
||||
count = 0;
|
||||
log.error("签退任务", e);
|
||||
|
|
@ -328,157 +274,12 @@ public class AutoWebTask {
|
|||
return count;
|
||||
}
|
||||
|
||||
/**
|
||||
* 定时获取基础数据
|
||||
*/
|
||||
public int getYuJingData(int classes, String username, String password) {
|
||||
AutoMain autoMain = new AutoMain();
|
||||
WebDriver webDriver;
|
||||
int count = 0;
|
||||
try {
|
||||
autoMain.initDrive(2);
|
||||
log.info("初始化驱动成功");
|
||||
autoMain.startYuJingAuto(username, password);
|
||||
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, String username, String password) {
|
||||
AutoMain autoMain = new AutoMain();
|
||||
WebDriver webDriver;
|
||||
int count = 0;
|
||||
try {
|
||||
autoMain.initDrive(2);
|
||||
log.info("初始化驱动成功");
|
||||
autoMain.startYuJingActionAuto(username, password);
|
||||
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, String username, String password) {
|
||||
AutoMain autoMain = new AutoMain();
|
||||
WebDriver webDriver;
|
||||
int count = 0;
|
||||
try {
|
||||
autoMain.initDrive(2);
|
||||
autoMain.startCaoLianAuto(username, password);
|
||||
//获取基础数据
|
||||
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) {
|
||||
try {
|
||||
String accountContent = GetBasicData.resolveGarbledCode("E:\\bns2\\config\\值班账号.txt");
|
||||
String content = GetBasicData.resolveGarbledCode("E:\\bns2\\config\\值班账号.txt");
|
||||
String todayContent = GetBasicData.resolveGarbledCode("E:\\bns2\\config\\今日值班账号.txt");
|
||||
String yesterdayContent = GetBasicData.resolveGarbledCode("E:\\bns2\\config\\昨日值班账号.txt");
|
||||
|
||||
String emergencyPerson = content.toString().split(";")[0].split(":")[1];
|
||||
String emergencyPersonPassword = content.toString().split(";")[1].split(":")[1];
|
||||
//今日签到值班人员
|
||||
String todaySignInPerson = todayContent.toString().split(";")[0].split(":")[1];
|
||||
String todaySignInPersonPassword = todayContent.toString().split(";")[1].split(":")[1];
|
||||
//昨日签退人员
|
||||
String yesterdaySignOutPerson = yesterdayContent.toString().split(";")[0].split(":")[1];
|
||||
String yesterdaySignOutPersonPassword = yesterdayContent.toString().split(";")[1].split(":")[1];
|
||||
System.out.println(emergencyPerson);
|
||||
System.out.println(emergencyPersonPassword);
|
||||
System.out.println(todaySignInPerson);
|
||||
System.out.println(todaySignInPersonPassword);
|
||||
System.out.println(yesterdaySignOutPerson);
|
||||
System.out.println(yesterdaySignOutPersonPassword);
|
||||
String[] accountArray = accountContent.split("--账号--:");
|
||||
String personName = "张天强";
|
||||
String personAccount = "ztq";
|
||||
FileInputStream excelFile = new FileInputStream("E:\\bns2\\config\\zhibanaccount.xlsx");
|
||||
Workbook workbook = new XSSFWorkbook(excelFile);
|
||||
Sheet datatypeSheet = workbook.getSheetAt(0);
|
||||
for (Row row : datatypeSheet) {
|
||||
String value = "";
|
||||
for (Cell cell : row) {
|
||||
value += cell.getStringCellValue() + "]]]";
|
||||
}
|
||||
value = value.substring(0, value.length() - 3);
|
||||
System.out.println(value);
|
||||
if (value.indexOf(personName) != -1) {
|
||||
System.out.println("今天:" + value);
|
||||
AutoUtils.write("E:\\bns2\\config\\今日值班账号.txt", "今日账号:" + value.split("]]]")[1] + ";密码:" + value.split(
|
||||
"]]]")[2]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//TODO 昨日的账号在今日的签退任务完成后,拿取今天的打卡人员数据放入昨日值班账号txt即可
|
||||
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
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(2);
|
||||
autoMain.initDrive();
|
||||
autoMain.startAddExercisePlan(userName, pass);
|
||||
//获取基础数据
|
||||
webDriver = autoMain.getWebDriver();
|
||||
|
|
@ -493,4 +294,5 @@ public class AutoWebTask {
|
|||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,3 @@
|
|||
Manifest-Version: 1.0
|
||||
Main-Class: com.bonus.autoweb.TestMain
|
||||
|
||||
Loading…
Reference in New Issue