Compare commits
No commits in common. "main" and "master" have entirely different histories.
85
pom.xml
85
pom.xml
|
|
@ -1,85 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>autoWebForSuZhou</groupId>
|
||||
<artifactId>autoWebForSuZhou</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<configuration>
|
||||
<source>8</source>
|
||||
<target>8</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
<dependencies>
|
||||
<!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-java -->
|
||||
<dependency>
|
||||
<groupId>org.seleniumhq.selenium</groupId>
|
||||
<artifactId>selenium-java</artifactId>
|
||||
<version>3.141.59</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>com.google.code.gson</groupId>
|
||||
<artifactId>gson</artifactId>
|
||||
<version>2.2.4</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.thoughtworks.xstream</groupId>
|
||||
<artifactId>xstream</artifactId>
|
||||
<version>1.4.9</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.codehaus.jettison</groupId>
|
||||
<artifactId>jettison</artifactId>
|
||||
<version>1.3.7</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>1.18.26</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.quartz-scheduler</groupId>
|
||||
<artifactId>quartz</artifactId>
|
||||
<version>2.2.1</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.hynnet</groupId>
|
||||
<artifactId>jacob</artifactId>
|
||||
<version>1.18</version>
|
||||
</dependency>
|
||||
<!--log4j-->
|
||||
<dependency>
|
||||
<groupId>commons-logging</groupId>
|
||||
<artifactId>commons-logging-api</artifactId>
|
||||
<version>1.1</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
<version>1.7.26</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-log4j12</artifactId>
|
||||
<version>1.7.26</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
|
|
@ -1,3 +0,0 @@
|
|||
Manifest-Version: 1.0
|
||||
Main-Class: com.bonus.autoweb.TestMain
|
||||
|
||||
|
|
@ -1,288 +0,0 @@
|
|||
package com.bonus.autoweb;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.LocalDate;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 日期操作工具类
|
||||
*/
|
||||
public class DateTimeUtils {
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 获取当前时间是本周第几天,从周一开始计算
|
||||
* @return
|
||||
*/
|
||||
public static int getWeekOfDate(String dateString ) throws ParseException {
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
||||
Date dt= sdf.parse(dateString);
|
||||
int[] weekDays = {7, 1, 2, 3, 4,5, 6};
|
||||
Calendar cal = Calendar.getInstance();
|
||||
cal.setTime(dt);
|
||||
int w = cal.get(Calendar.DAY_OF_WEEK) - 1;
|
||||
if (w < 0){
|
||||
w = 0;
|
||||
}
|
||||
return weekDays[w];
|
||||
}
|
||||
|
||||
/**'
|
||||
*获取当前时间是本月第几周
|
||||
* @return
|
||||
*/
|
||||
public static int getWeekNum(String dateString ) throws ParseException {
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
||||
Date date= sdf.parse(dateString);
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.setTime(date);
|
||||
int weekOfMonth = calendar.get(Calendar.WEEK_OF_MONTH);
|
||||
if (getWeekOfDate(dateString) == 7){
|
||||
weekOfMonth = weekOfMonth - 1;
|
||||
}
|
||||
return weekOfMonth;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取本月第一天在第几周
|
||||
* @return true 0 false >0
|
||||
* @throws ParseException
|
||||
*/
|
||||
public static boolean getMonthOneDayIs0() throws ParseException {
|
||||
LocalDate firstDayOfMonth = LocalDate.now().withDayOfMonth(1);
|
||||
int t=getWeekNum(firstDayOfMonth.toString());
|
||||
// int t=getWeekNum(day);
|
||||
if(t>0){
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取上个月的最后一天
|
||||
*/
|
||||
public static String getBeforeLastMonthdate(){
|
||||
SimpleDateFormat sf=new SimpleDateFormat("yyyy-MM-dd");
|
||||
Calendar calendar=Calendar.getInstance();
|
||||
int month=calendar.get(Calendar.MONTH);
|
||||
calendar.set(Calendar.MONTH, month-1);
|
||||
calendar.set(Calendar.DAY_OF_MONTH, calendar.getActualMaximum(Calendar.DAY_OF_MONTH));
|
||||
String format = sf.format(calendar.getTime());
|
||||
return format;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前日期
|
||||
* @return
|
||||
*/
|
||||
public static String getCurrentDay(){
|
||||
Date date=new Date();
|
||||
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
|
||||
return formatter.format(date);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取昨天的日期
|
||||
* @return
|
||||
*/
|
||||
public static String getLastDayYYYYMMDD(){
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
||||
Calendar c = Calendar.getInstance();
|
||||
c.add(Calendar.DATE, -1);//-1.昨天时间 0.当前时间 1.明天时间 *以此类推
|
||||
String time = sdf.format(c.getTime());
|
||||
System.out.println("昨天的时间时间是:" + time);//20190704
|
||||
return time;
|
||||
}
|
||||
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; // 随机生成1到7的数字
|
||||
if (!numbers.contains(randomNumber)) {
|
||||
numbers.add(randomNumber);
|
||||
}
|
||||
}
|
||||
Collections.shuffle(numbers);
|
||||
System.out.println(numbers);
|
||||
return numbers;
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws ParseException {
|
||||
// System.out.println(getMMDDByNow());
|
||||
//获取一个随机数据集合
|
||||
List<Integer> list = getARandomCollectionOfData();
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
String type = "";
|
||||
String company = "";
|
||||
if (i < 2){
|
||||
type = "通信测试";
|
||||
}else {
|
||||
type = "日常操练";
|
||||
}
|
||||
switch(String.valueOf(list.get(i))){
|
||||
case "1":
|
||||
company = "宿州";
|
||||
break;
|
||||
case "2":
|
||||
company = "埇桥";
|
||||
break;
|
||||
case "3":
|
||||
company = "砀山";
|
||||
break;
|
||||
case "4":
|
||||
company = "萧县";
|
||||
break;
|
||||
case "5":
|
||||
company = "灵璧";
|
||||
break;
|
||||
case "6":
|
||||
company = "城郊";
|
||||
break;
|
||||
case "7":
|
||||
company = "泗县";
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
System.out.println(type);
|
||||
System.out.println(company);
|
||||
System.out.println(i+1);
|
||||
System.out.println("-------------------");
|
||||
}
|
||||
}
|
||||
public static String getCurrentDay2(){
|
||||
Date date=new Date();
|
||||
SimpleDateFormat formatter = new SimpleDateFormat("MM月dd日");
|
||||
return formatter.format(date);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取昨天的日期
|
||||
* @return
|
||||
*/
|
||||
public static String getLastDay(){
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("MM月dd日");
|
||||
Calendar c = Calendar.getInstance();
|
||||
c.add(Calendar.DATE, -1);//-1.昨天时间 0.当前时间 1.明天时间 *以此类推
|
||||
String time = sdf.format(c.getTime());
|
||||
System.out.println("昨天的时间时间是:" + time);//20190704
|
||||
return time;
|
||||
}
|
||||
/**
|
||||
* 获取明天的日期
|
||||
* @return
|
||||
*/
|
||||
public static String getTomorrowDate() {
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("MM月dd日");
|
||||
Calendar c = Calendar.getInstance();
|
||||
c.add(Calendar.DATE, 1);//-1.昨天时间 0.当前时间 1.明天时间 *以此类推
|
||||
String time = sdf.format(c.getTime());
|
||||
System.out.println("昨天的时间时间是:" + time);//20190704
|
||||
return time;
|
||||
}
|
||||
/**
|
||||
* 获取当前月日
|
||||
* @return
|
||||
*/
|
||||
public static String getCurrentDayByMonth(){
|
||||
Date date=new Date();
|
||||
SimpleDateFormat formatter = new SimpleDateFormat("MM月dd日");
|
||||
return formatter.format(date);
|
||||
}
|
||||
public static String getMMDDByNow(){
|
||||
Date date=new Date();
|
||||
SimpleDateFormat formatter = new SimpleDateFormat("MMdd");
|
||||
return formatter.format(date);
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断当前日期是否为本月第一天
|
||||
* @return
|
||||
*/
|
||||
public static boolean isOneDay(){
|
||||
// TODO Auto-generated method stub
|
||||
Date now = new Date();
|
||||
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd");//可以方便地修改日期格式
|
||||
String curr = dateFormat.format( now );
|
||||
System.out.println("当前日期:" + curr);
|
||||
|
||||
Calendar c = Calendar.getInstance();//可以对每个时间域单独修改
|
||||
|
||||
int year = c.get(Calendar.YEAR);
|
||||
int month = c.get(Calendar.MONTH);
|
||||
int date = c.get(Calendar.DATE);
|
||||
if(date == 1){
|
||||
System.out.println(curr + "是第一天");
|
||||
return true;
|
||||
}
|
||||
else{
|
||||
System.out.println(curr + "不是第一天");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断当前时间是否在[startTime, endTime]区间,注意三个参数的时间格式要一致
|
||||
* @param startTime
|
||||
* @param endTime
|
||||
* @return 在时间段内返回true,不在返回false
|
||||
*/
|
||||
public static boolean isEffectiveDate(String startTime, String endTime){
|
||||
/**
|
||||
* 判断当前时间是否在一个时间段内 HH:mm 格式
|
||||
*/
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("HH:mm");
|
||||
String now = sdf.format(new Date());
|
||||
Date nowTime;
|
||||
try{
|
||||
nowTime = sdf.parse(now);
|
||||
Date startTime1 = sdf.parse(startTime);
|
||||
Date endTime1 = sdf.parse(endTime);
|
||||
if (nowTime.getTime() == startTime1.getTime()
|
||||
|| nowTime.getTime() == endTime1.getTime()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
Calendar date = Calendar.getInstance();
|
||||
date.setTime(nowTime);
|
||||
|
||||
Calendar begin = Calendar.getInstance();
|
||||
begin.setTime(startTime1);
|
||||
|
||||
Calendar end = Calendar.getInstance();
|
||||
end.setTime(endTime1);
|
||||
|
||||
return date.after(begin) && date.before(end);
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean compareDate(String date1, String date2) throws ParseException {
|
||||
boolean tf = false;
|
||||
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
|
||||
|
||||
// 定义起始日期和结束日期
|
||||
Date startDate = dateFormat.parse(date1 + " 00:00:00");
|
||||
Date endDate = dateFormat.parse(date2 + " 23:59:59");
|
||||
|
||||
// 定义要判断的日期
|
||||
Date dateToCheck = new Date();
|
||||
|
||||
// 判断日期是否在范围内
|
||||
if (startDate.compareTo(dateToCheck) <= 0 && endDate.compareTo(dateToCheck) >= 0) {
|
||||
System.out.println("日期在范围内");
|
||||
tf = true;
|
||||
} else {
|
||||
tf = false;
|
||||
System.out.println("日期不在范围内");
|
||||
}
|
||||
return tf;
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
|
|
@ -1,825 +0,0 @@
|
|||
package com.bonus.autoweb;
|
||||
|
||||
import com.bonus.autoweb.base.DataConfig;
|
||||
import com.bonus.autoweb.task.AutoWebTask;
|
||||
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.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import javax.sound.sampled.*;
|
||||
import java.io.File;
|
||||
import java.text.ParseException;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 系统测试
|
||||
* @author 24526
|
||||
*/
|
||||
public class TestMain {
|
||||
private static Logger log = LoggerFactory.getLogger(TestMain.class);
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
log.info("执行任务开始。。。。。。");
|
||||
// testRCCL();
|
||||
// testqd();
|
||||
// testjjb();
|
||||
// testGetData();
|
||||
// testDailrb();
|
||||
// start("工作人员请注意,桌号8001顾客正在寻求帮助!!");
|
||||
// testLog();
|
||||
new Thread(new Runnable() {
|
||||
@SneakyThrows
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
new TestMain().autoJob();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
log.error("错误信息", e);
|
||||
}
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
|
||||
//签到签退测试
|
||||
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 testGetData() throws ParseException, InterruptedException {
|
||||
AutoWebTask autoWebTask = new AutoWebTask();
|
||||
Thread.sleep(2000);
|
||||
autoWebTask.getCaoLianData(1);
|
||||
Thread.sleep(2000);
|
||||
autoWebTask.getYuJingData(1);
|
||||
Thread.sleep(2000);
|
||||
GetBasicData.getYuJingActionBasicData(1);
|
||||
}
|
||||
|
||||
//日报填写测试
|
||||
private static void testDailrb() {
|
||||
try {
|
||||
//操作日报
|
||||
//日报审核工作
|
||||
AutoWebTask autoWebTask = new AutoWebTask();
|
||||
autoWebTask.dutyAddDailyLogsTask(2,DataConfig.USER_NAME3,DataConfig.PASS3);
|
||||
Thread.sleep(1000);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
//日常操练测试
|
||||
private static void testRCCL() throws InterruptedException {
|
||||
int addExercisePlan = 0;
|
||||
try {
|
||||
AutoWebTask autoWebTask = new AutoWebTask();
|
||||
addExercisePlan = autoWebTask.addExercisePlan("通信测试", "", 0, DataConfig.USER_NAME1, DataConfig.PASS1);
|
||||
Thread.sleep(2000);
|
||||
addExercisePlan = autoWebTask.addExercisePlan("日常操练", "", 0, DataConfig.USER_NAME1, DataConfig.PASS1);
|
||||
Thread.sleep(2000);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
//日志填写测试
|
||||
private static int testLog() {
|
||||
int count = 0;
|
||||
try {
|
||||
//操作日志
|
||||
AutoWebTask autoWebTask = new AutoWebTask();
|
||||
autoWebTask.dutyAddLogsTask(2,DataConfig.USER_NAME1,DataConfig.PASS1);
|
||||
count = 1;
|
||||
Thread.sleep(1000);
|
||||
log.info("count",count);
|
||||
System.out.println(count);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
private void autoAddPlan() throws InterruptedException {
|
||||
AutoWebTask autoWebTask = new AutoWebTask();
|
||||
int addExercisePlan = 0;
|
||||
while (true) {
|
||||
//延迟30s---120s
|
||||
int time = randNum(30, 120);
|
||||
log.info("随机时间为:" + time);
|
||||
try {
|
||||
Thread.sleep(1000 * time);
|
||||
} catch (Exception e) {
|
||||
log.error("时间", e);
|
||||
}
|
||||
log.info("服务正在运行。。。" + new Date());
|
||||
if (DateTimeUtils.isEffectiveDate("09:00", "10:30")) {
|
||||
getTime(1200);
|
||||
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(addExercisePlan == 0) {
|
||||
if("1".equals(num)){
|
||||
addExercisePlan = autoWebTask.addExercisePlan("通信测试", "", 0, DataConfig.USER_NAME3, DataConfig.PASS3);
|
||||
Thread.sleep(2000);
|
||||
addExercisePlan = autoWebTask.addExercisePlan("日常操练", "", 0, DataConfig.USER_NAME3, DataConfig.PASS3);
|
||||
Thread.sleep(2000);
|
||||
}else {
|
||||
addExercisePlan = autoWebTask.addExercisePlan("通信测试", "", 0, DataConfig.USER_NAME1, DataConfig.PASS1);
|
||||
Thread.sleep(2000);
|
||||
addExercisePlan = autoWebTask.addExercisePlan("日常操练", "", 0, DataConfig.USER_NAME1, DataConfig.PASS1);
|
||||
Thread.sleep(2000);
|
||||
}
|
||||
|
||||
//登录操作---陈亚账号
|
||||
|
||||
}
|
||||
// if (addExercisePlan == 0){
|
||||
// autoWebTask.addExercisePlan("日常操练","萧县",4,DataConfig.USER_NAME3,DataConfig.PASS3);
|
||||
// }
|
||||
}else if (DateTimeUtils.isEffectiveDate("20:05", "20:08")) {
|
||||
addExercisePlan = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 自动化任务
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
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 jjbwan2 = 0;
|
||||
int signOutzao = 0;
|
||||
int signOutzao2 = 0;
|
||||
int signOutwan = 0;
|
||||
int signOutwan2 = 0;
|
||||
int logzao = 0;
|
||||
int logwan = 0;
|
||||
int resetCode = 0;
|
||||
|
||||
int addExercisePlan = 0;
|
||||
|
||||
while (true) {
|
||||
//延迟30s---120s
|
||||
int time = randNum(30, 120);
|
||||
log.info("随机时间为:" + time);
|
||||
try {
|
||||
Thread.sleep(1000 * time);
|
||||
} catch (Exception e) {
|
||||
log.error("时间", e);
|
||||
}
|
||||
log.info("服务正在运行。。。" + new Date());
|
||||
// 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(DateTimeUtils.isEffectiveDate("17:31", "17:40")){
|
||||
//进行日报信息系统采集及获取工作
|
||||
try {
|
||||
if (logGatherCount == 0){
|
||||
logGatherCount = autoWebTask.getCaoLianData(1);
|
||||
|
||||
}
|
||||
Thread.sleep(3000);
|
||||
if (dailyGatherCount == 0){
|
||||
dailyGatherCount = autoWebTask.getYuJingData(1);
|
||||
Thread.sleep(2000);
|
||||
GetBasicData.getYuJingActionBasicData(1);
|
||||
}
|
||||
}catch (Exception e) {
|
||||
log.error("信息采集工作", e);
|
||||
}
|
||||
}else if (DateTimeUtils.isEffectiveDate("06:31", "07:00")) {
|
||||
//自动完成当值值班日报(早报)填写上报
|
||||
if (dailyzao == 0) {
|
||||
getTime(1100);
|
||||
try {
|
||||
// if("1".equals(num)){
|
||||
// dailyzao = autoWebTask.dutyAddDailyLogsTask(1,DataConfig.USER_NAME1,DataConfig.PASS1);
|
||||
// }else {
|
||||
// dailyzao = autoWebTask.dutyAddDailyLogsTask(1,DataConfig.USER_NAME3,DataConfig.PASS3);
|
||||
// }
|
||||
dailyzao = autoWebTask.dutyAddDailyLogsTask(1,DataConfig.USER_NAME1,DataConfig.PASS1);
|
||||
}catch (Exception e){
|
||||
log.error("日报工作", e);
|
||||
}
|
||||
}
|
||||
}else if (DateTimeUtils.isEffectiveDate("07:01", "07:30")) {
|
||||
//完成值班日志填写提交(晚班日志,此次值班日志为总结前一天晚上的情况)
|
||||
if (logzao == 0) {
|
||||
getTime(1100);
|
||||
try {
|
||||
// if("1".equals(num)){
|
||||
// logzao = autoWebTask.dutyAddLogsTask(1,DataConfig.USER_NAME1,DataConfig.PASS1);
|
||||
// }else {
|
||||
// logzao = autoWebTask.dutyAddLogsTask(1,DataConfig.USER_NAME3,DataConfig.PASS3);
|
||||
// }
|
||||
logzao = autoWebTask.dutyAddLogsTask(1,DataConfig.USER_NAME1,DataConfig.PASS1);
|
||||
}catch (Exception e){
|
||||
log.error("日志工作", e);
|
||||
}
|
||||
}
|
||||
}else if (DateTimeUtils.isEffectiveDate("07:31", "07:50")) {
|
||||
//自动完成当值值班签到(值班主任、值班人员都要签到)
|
||||
// if ("error".equals(content)) {
|
||||
// log.error("读取前一天人员数据错误");
|
||||
// }else {
|
||||
// log.info("昨天的日期:" + date + "昨天的账号类别:" + num);
|
||||
// if (signInzao == 0 && signInzao2 == 0){
|
||||
// getTime(800);
|
||||
// }
|
||||
// if ("1".equals(num)){
|
||||
// if (signInzao == 0) {
|
||||
// log.info("陈亚账号开始打卡任务---------------------");
|
||||
// //使用陈亚账号签到
|
||||
// try {
|
||||
// signInzao = autoWebTask.dutySigin(1, 1, DataConfig.USER_NAME3, DataConfig.PASS3);
|
||||
// } 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_NAME4, DataConfig.PASS4);
|
||||
// } catch (Exception e) {
|
||||
// log.error("赵静打卡任务", e);
|
||||
// }
|
||||
// }
|
||||
// }else {
|
||||
// if (signInzao == 0) {
|
||||
// log.info("方春芳账号开始打卡任务---------------------");
|
||||
// //使用方春芳账号签到
|
||||
// try {
|
||||
// signInzao = autoWebTask.dutySigin(1, 1, DataConfig.USER_NAME1, DataConfig.PASS1);
|
||||
// } 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_NAME2, DataConfig.PASS2);
|
||||
// } catch (Exception e) {
|
||||
// log.error("王鹤打卡任务", e);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
if (signInzao == 0) {
|
||||
log.info("蒋涛账号开始打卡任务---------------------");
|
||||
//使用蒋涛账号签到
|
||||
try {
|
||||
signInzao = autoWebTask.dutySigin(1, 1, DataConfig.USER_NAME1, DataConfig.PASS1);
|
||||
} 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_NAME2, DataConfig.PASS2);
|
||||
} catch (Exception e) {
|
||||
log.error("武警打卡任务", e);
|
||||
}
|
||||
}
|
||||
}else if (DateTimeUtils.isEffectiveDate("07:51", "08:10")) {
|
||||
if (jjbzao == 0 && jjbzao2 == 0){
|
||||
getTime(800);
|
||||
}
|
||||
//自动在系统内完成接班(上一值完成交班后)
|
||||
if (jjbzao == 0 || jjbzao2 == 0){
|
||||
// if("1".equals(num)){
|
||||
// if (jjbzao == 0){
|
||||
// jjbzao = autoWebTask.dutyChangeTask1(1,DataConfig.USER_NAME1,DataConfig.PASS1);
|
||||
// }
|
||||
// if (jjbzao2 == 0){
|
||||
// jjbzao2 = autoWebTask.dutyChangeTask2(1,DataConfig.USER_NAME3,DataConfig.PASS3);
|
||||
// }
|
||||
// }else {
|
||||
// if (jjbzao == 0){
|
||||
// jjbzao = autoWebTask.dutyChangeTask1(1,DataConfig.USER_NAME3,DataConfig.PASS3);
|
||||
// }
|
||||
// if (jjbzao2 == 0){
|
||||
// jjbzao2 = autoWebTask.dutyChangeTask2(1,DataConfig.USER_NAME1,DataConfig.PASS1);
|
||||
// }
|
||||
// }
|
||||
if (jjbzao == 0){
|
||||
jjbzao = autoWebTask.dutyChangeTask1(1,DataConfig.USER_NAME1,DataConfig.PASS1);
|
||||
}
|
||||
if (jjbzao2 == 0){
|
||||
jjbzao2 = autoWebTask.dutyChangeTask2(1,DataConfig.USER_NAME1,DataConfig.PASS1);
|
||||
}
|
||||
}
|
||||
}else if (DateTimeUtils.isEffectiveDate("08:30", "09:00")) {
|
||||
if(signOutzao == 0 && signOutzao2 == 0){
|
||||
getTime(700);
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
// //自动在系统内完成签退
|
||||
// if ("1".equals(num)){
|
||||
// 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 (signOutzao == 0) {
|
||||
// try {
|
||||
// signOutzao = autoWebTask.dutySignOutTask(1, DataConfig.USER_NAME3, DataConfig.PASS3);
|
||||
// }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_NAME4, DataConfig.PASS4);
|
||||
// }catch (Exception e){
|
||||
// log.error("签退",e);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
}else if (DateTimeUtils.isEffectiveDate("09:20", "10:00")){
|
||||
if(addExercisePlan == 0){
|
||||
getTime(1200);
|
||||
}
|
||||
if(addExercisePlan == 0) {
|
||||
addExercisePlan = autoWebTask.addExercisePlan("通信测试", "", 0, DataConfig.USER_NAME1,
|
||||
DataConfig.PASS1);
|
||||
Thread.sleep(1000 * 650);
|
||||
addExercisePlan = autoWebTask.addExercisePlan("日常操练", "", 0, DataConfig.USER_NAME1,
|
||||
DataConfig.PASS1);
|
||||
Thread.sleep(2000);
|
||||
}
|
||||
} else if (DateTimeUtils.isEffectiveDate("12:30", "14:30")) {
|
||||
//进行日志信息系统采集及获取工作
|
||||
try {
|
||||
if (logGatherCount1 == 0){
|
||||
logGatherCount1 = autoWebTask.getCaoLianData(2);
|
||||
}
|
||||
Thread.sleep(3000);
|
||||
if (dailyGatherCount1 == 0){
|
||||
dailyGatherCount1= autoWebTask.getYuJingData(2);
|
||||
Thread.sleep(2000);
|
||||
GetBasicData.getYuJingActionBasicData(2);
|
||||
}
|
||||
}catch (Exception e) {
|
||||
log.error("信息采集工作", e);
|
||||
}
|
||||
}else if (DateTimeUtils.isEffectiveDate("16:31", "16:50")) {
|
||||
//自动完成当值值班日报(晚报)填写上报
|
||||
if (dailywan == 0) {
|
||||
getTime(700);
|
||||
try {
|
||||
// if ("1".equals(num)) {
|
||||
// dailywan = autoWebTask.dutyAddDailyLogsTask(2,DataConfig.USER_NAME3,DataConfig.PASS3);
|
||||
// }else {
|
||||
// dailywan = autoWebTask.dutyAddDailyLogsTask(2,DataConfig.USER_NAME1,DataConfig.PASS1);
|
||||
// }
|
||||
dailywan = autoWebTask.dutyAddDailyLogsTask(2,DataConfig.USER_NAME1,DataConfig.PASS1);
|
||||
}catch (Exception e){
|
||||
log.error("日报工作", e);
|
||||
}
|
||||
}
|
||||
}else if (DateTimeUtils.isEffectiveDate("16:10", "16:30")) {
|
||||
//完成值班日志填写提交(白班日志,此次值班日志为总结前一天晚上的情况)
|
||||
if (logwan == 0) {
|
||||
getTime(800);
|
||||
try {
|
||||
// if ("1".equals(num)) {
|
||||
// logwan = autoWebTask.dutyAddLogsTask(2,DataConfig.USER_NAME3,DataConfig.PASS3);
|
||||
// }else {
|
||||
// logwan = autoWebTask.dutyAddLogsTask(2,DataConfig.USER_NAME1,DataConfig.PASS1);
|
||||
// }
|
||||
logwan = autoWebTask.dutyAddLogsTask(2,DataConfig.USER_NAME1,DataConfig.PASS1);
|
||||
}catch (Exception e){
|
||||
log.error("日志工作", e);
|
||||
}
|
||||
}
|
||||
}else if (DateTimeUtils.isEffectiveDate("16:51", "17:10")) {
|
||||
//自动完成当值值班签到(值班主任、值班人员都要签到)
|
||||
if(signInwan == 0 && signInwan2 == 0){
|
||||
getTime(650);
|
||||
}
|
||||
if (signInwan == 0) {
|
||||
log.info("蒋涛账号开始打卡任务---------------------");
|
||||
//使用蒋涛账号签到
|
||||
try {
|
||||
signInwan = autoWebTask.dutySigin(2, 1, DataConfig.USER_NAME1, DataConfig.PASS1);
|
||||
} 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_NAME2, DataConfig.PASS2);
|
||||
} catch (Exception e) {
|
||||
log.error("武警打卡任务", e);
|
||||
}
|
||||
}
|
||||
// if ("error".equals(content)) {
|
||||
// log.error("读取前一天人员数据错误");
|
||||
// }else {
|
||||
// log.info("昨天的日期:" + date + "昨天的账号类别:" + num);
|
||||
// if(signInwan == 0 && signInwan2 == 0){
|
||||
// getTime(650);
|
||||
// }
|
||||
// if ("1".equals(num)){
|
||||
// if (signInwan == 0) {
|
||||
// log.info("陈亚账号开始打卡任务---------------------");
|
||||
// //使用陈亚账号签到
|
||||
// try {
|
||||
// signInwan = autoWebTask.dutySigin(2, 1, DataConfig.USER_NAME3, DataConfig.PASS3);
|
||||
// } 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_NAME4, DataConfig.PASS4);
|
||||
// } catch (Exception e) {
|
||||
// log.error("赵静打卡任务", e);
|
||||
// }
|
||||
// }
|
||||
// }else {
|
||||
// if (signInwan == 0) {
|
||||
// log.info("方春芳账号开始打卡任务---------------------");
|
||||
// //使用方春芳账号签到
|
||||
// try {
|
||||
// signInwan = autoWebTask.dutySigin(2, 1, DataConfig.USER_NAME1, DataConfig.PASS1);
|
||||
// } 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_NAME2, DataConfig.PASS2);
|
||||
// } catch (Exception e) {
|
||||
// log.error("王鹤打卡任务", e);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
}else if (DateTimeUtils.isEffectiveDate("17:11", "17:30")) {
|
||||
//自动在系统内完成接班(上一值完成交班后)
|
||||
if(jjbwan == 0 && jjbwan2 == 0){
|
||||
getTime(700);
|
||||
}
|
||||
if (jjbwan == 0 || jjbwan2 == 0){
|
||||
if (jjbwan == 0){
|
||||
jjbwan = autoWebTask.dutyChangeTask1(2,DataConfig.USER_NAME1,DataConfig.PASS1);
|
||||
}
|
||||
if (jjbwan2 == 0){
|
||||
jjbwan2 = autoWebTask.dutyChangeTask2(2,DataConfig.USER_NAME1,DataConfig.PASS1);
|
||||
}
|
||||
// if("1".equals(num)){
|
||||
// if (jjbwan == 0){
|
||||
// jjbwan = autoWebTask.dutyChangeTask1(2,DataConfig.USER_NAME3,DataConfig.PASS3);
|
||||
// }
|
||||
// if (jjbwan2 == 0){
|
||||
// jjbwan2 = autoWebTask.dutyChangeTask2(2,DataConfig.USER_NAME3,DataConfig.PASS3);
|
||||
// }
|
||||
// }else {
|
||||
// if (jjbwan == 0){
|
||||
// jjbwan = autoWebTask.dutyChangeTask1(2,DataConfig.USER_NAME1,DataConfig.PASS1);
|
||||
// }
|
||||
// if (jjbwan2 == 0){
|
||||
// jjbwan2 = autoWebTask.dutyChangeTask2(2,DataConfig.USER_NAME1,DataConfig.PASS1);
|
||||
// }
|
||||
// }
|
||||
}
|
||||
}else if (DateTimeUtils.isEffectiveDate("17:45", "18:00")) {
|
||||
if (signOutwan == 0 && signOutwan2 == 0){
|
||||
getTime(500);
|
||||
}
|
||||
if (signOutwan == 0) {
|
||||
try {
|
||||
signOutzao = 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);
|
||||
}
|
||||
}
|
||||
// //自动在系统内完成签退
|
||||
// if ("1".equals(num)){
|
||||
// if (signOutwan == 0) {
|
||||
// try {
|
||||
// signOutwan = autoWebTask.dutySignOutTask(2, DataConfig.USER_NAME3, DataConfig.PASS3);
|
||||
// }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_NAME4, DataConfig.PASS4);
|
||||
// }catch (Exception e){
|
||||
// log.error("签退",e);
|
||||
// }
|
||||
// }
|
||||
// }else {
|
||||
// if (signOutwan == 0) {
|
||||
// try {
|
||||
// signOutzao = 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:00", "18:04")) {
|
||||
// if(resetCode == 0){
|
||||
// log.info("-----开始更新当日打卡人账号及日期-----");
|
||||
// resetCode = AutoUtils.write("E:\\bns\\config\\account.txt","data:"+DateTimeUtils.getCurrentDay()+";num:"+ ("1".equals(num) ? "ok" : "1"));
|
||||
// }
|
||||
// }
|
||||
else if (DateTimeUtils.isEffectiveDate("20:05", "20:08")) {//重置标识
|
||||
log.info("-----开始重置各标识符-----");
|
||||
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;
|
||||
jjbwan2 = 0;
|
||||
signOutzao = 0;
|
||||
signOutzao2 = 0;
|
||||
signOutwan = 0;
|
||||
signOutwan2 = 0;
|
||||
logzao = 0;
|
||||
logwan = 0;
|
||||
resetCode = 0;
|
||||
addExercisePlan = 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);
|
||||
try {
|
||||
Thread.sleep(1000 * time);
|
||||
} catch (Exception e) {
|
||||
log.error("时间", e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 随机产生随机数,包含num1和num2
|
||||
*
|
||||
* @param num1
|
||||
* @param num2
|
||||
* @return
|
||||
*/
|
||||
private int randNum(int num1, int num2) {
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
@ -1,78 +0,0 @@
|
|||
package com.bonus.autoweb.UI.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 日报实体类
|
||||
* 附件八-输配电线停运及恢复
|
||||
* @author ztq
|
||||
*/
|
||||
@Data
|
||||
public class AnnexEightBean {
|
||||
|
||||
/**
|
||||
* 特高压
|
||||
*/
|
||||
private String transmit_electricity_add_outage_uvh;
|
||||
private String transmit_electricity_add_repair_uvh;
|
||||
private String transmit_electricity_add_no_repair_uvh;
|
||||
|
||||
private String transmit_electricity_cumulative_outage_uvh;
|
||||
private String transmit_electricity_cumulative_repair_uvh;
|
||||
private String transmit_electricity_cumulative_no_repair_uvh;
|
||||
|
||||
/**
|
||||
* 500kv
|
||||
*/
|
||||
private String transmit_electricity_add_outage_five;
|
||||
private String transmit_electricity_add_repair_five;
|
||||
private String transmit_electricity_add_no_repair_five;
|
||||
|
||||
private String transmit_electricity_cumulative_outage_five;
|
||||
private String transmit_electricity_cumulative_repair_five;
|
||||
private String transmit_electricity_cumulative_no_repair_five;
|
||||
|
||||
/**
|
||||
* 220/300kv
|
||||
*/
|
||||
private String transmit_electricity_add_outage_two;
|
||||
private String transmit_electricity_add_repair_two;
|
||||
private String transmit_electricity_add_no_repair_two;
|
||||
|
||||
private String transmit_electricity_cumulative_outage_two;
|
||||
private String transmit_electricity_cumulative_repair_two;
|
||||
private String transmit_electricity_cumulative_no_repair_two;
|
||||
|
||||
/**
|
||||
* 110/66kv
|
||||
*/
|
||||
private String transmit_electricity_add_outage_one;
|
||||
private String transmit_electricity_add_repair_one;
|
||||
private String transmit_electricity_add_no_repair_one;
|
||||
|
||||
private String transmit_electricity_cumulative_outage_one;
|
||||
private String transmit_electricity_cumulative_repair_one;
|
||||
private String transmit_electricity_cumulative_no_repair_one;
|
||||
|
||||
/**
|
||||
* 35kv
|
||||
*/
|
||||
private String transmit_electricity_add_outage_three;
|
||||
private String transmit_electricity_add_repair_three;
|
||||
private String transmit_electricity_add_no_repair_three;
|
||||
|
||||
private String transmit_electricity_cumulative_outage_three;
|
||||
private String transmit_electricity_cumulative_repair_three;
|
||||
private String transmit_electricity_cumulative_no_repair_three;
|
||||
|
||||
/**
|
||||
* 10kv
|
||||
*/
|
||||
private String transmit_electricity_add_outage_ten;
|
||||
private String transmit_electricity_add_repair_ten;
|
||||
private String transmit_electricity_add_no_repair_ten;
|
||||
|
||||
private String transmit_electricity_cumulative_outage_ten;
|
||||
private String transmit_electricity_cumulative_repair_ten;
|
||||
private String transmit_electricity_cumulative_no_repair_ten;
|
||||
}
|
||||
|
|
@ -1,23 +0,0 @@
|
|||
package com.bonus.autoweb.UI.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 包名称:com.bonus.autoweb.UI.entity
|
||||
* 类名称:AnnexTenBean
|
||||
* 类描述:附件十一
|
||||
* 创建人:@author tqzhang
|
||||
* 创建时间:2023年08月01日 13:23
|
||||
*/
|
||||
@Data
|
||||
public class AnnexElevenBean {
|
||||
private String uhv;
|
||||
private String fiveHundredKv;
|
||||
private String twoHundredTwentyKv;
|
||||
private String oneHundredTenKv;
|
||||
private String thirtyFiveKv;
|
||||
private String tenKv;
|
||||
private String averageWaterLevel;
|
||||
private String measuredValue;
|
||||
private String actionHasBeenTaken;
|
||||
}
|
||||
|
|
@ -1,26 +0,0 @@
|
|||
package com.bonus.autoweb.UI.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 包名称:com.bonus.autoweb.UI.entity
|
||||
* 类名称:AnnexFiveBean
|
||||
* 类描述:附件五 入境筛查和集中观察场所供电保障情况表
|
||||
* 创建人:@author tqzhang
|
||||
* 创建时间:2023年07月27日 11:29
|
||||
*/
|
||||
|
||||
@Data
|
||||
public class AnnexFiveBean {
|
||||
//入境筛选和集中观察场所数量
|
||||
private String airportPort;
|
||||
private String venueHospital;
|
||||
private String guesthouseHotel;
|
||||
private String safeguardPersonnel;
|
||||
//投入力量
|
||||
private String electricallyGuaranteedVehicles;
|
||||
private String powerGenerationVehicles;
|
||||
private String dynamo;
|
||||
private String remark;
|
||||
|
||||
}
|
||||
|
|
@ -1,58 +0,0 @@
|
|||
package com.bonus.autoweb.UI.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 日报实体类
|
||||
* 附件四-疫情防控供电保障情况统计表
|
||||
* @author zys
|
||||
*/
|
||||
@Data
|
||||
public class AnnexFourBean {
|
||||
|
||||
/**
|
||||
* 定点医院
|
||||
*/
|
||||
private String designated_hospitals;
|
||||
|
||||
/**
|
||||
* 发热门诊
|
||||
*/
|
||||
private String fever_clinic;
|
||||
|
||||
/**
|
||||
* 防疫用品企业
|
||||
*/
|
||||
private String epidemic_enterprise;
|
||||
|
||||
/**
|
||||
* 其他重要用户
|
||||
*/
|
||||
private String other_important_users;
|
||||
|
||||
/**
|
||||
* 客户用电保障人员
|
||||
*/
|
||||
private String customer_power_personnel;
|
||||
|
||||
/**
|
||||
* 电网运维保障人员
|
||||
*/
|
||||
private String power_devops_personnel;
|
||||
|
||||
/**
|
||||
* 保电车辆
|
||||
*/
|
||||
private String electrically_vehicles;
|
||||
|
||||
/**
|
||||
* 应急发电车
|
||||
*/
|
||||
private String emergency_power_vehicles;
|
||||
|
||||
/**
|
||||
* 应急发电机
|
||||
*/
|
||||
private String emergency_generator;
|
||||
|
||||
}
|
||||
|
|
@ -1,24 +0,0 @@
|
|||
package com.bonus.autoweb.UI.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 包名称:com.bonus.autoweb.UI.entity
|
||||
* 类名称:AnnexTwelveBean
|
||||
* 类描述:附件十四 超设计风力线路数量统计表
|
||||
* 创建人:@author tqzhang
|
||||
* 创建时间:2023年07月27日 13:15
|
||||
*/
|
||||
@Data
|
||||
public class AnnexFourteenBean {
|
||||
private String uhv;
|
||||
private String fiveHundredKv;
|
||||
private String twoHundredTwentyKv;
|
||||
private String oneHundredTenKv;
|
||||
private String thirtyFiveKv;
|
||||
private String tenKv;
|
||||
private String averageWaterLevel;
|
||||
private String measuredValue;
|
||||
private String designValues;
|
||||
private String actionHasBeenTaken;
|
||||
}
|
||||
|
|
@ -1,45 +0,0 @@
|
|||
package com.bonus.autoweb.UI.entity;
|
||||
|
||||
/**
|
||||
* 日报实体类
|
||||
* 附件九-台区用户停电及恢复
|
||||
* @author ztq
|
||||
*/
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class AnnexNineBean {
|
||||
|
||||
/**
|
||||
* 台区
|
||||
*/
|
||||
private String add_blackout_tai_district;
|
||||
private String add_repair_tai_district;
|
||||
private String add_no_repair_tai_district;
|
||||
|
||||
private String cumulative_blackout_tai_district;
|
||||
private String cumulative_repair_tai_district;
|
||||
private String cumulative_no_repair_tai_district;
|
||||
|
||||
/**
|
||||
* 用户
|
||||
*/
|
||||
private String add_blackout_user;
|
||||
private String add_repair_user;
|
||||
private String add_no_repair_user;
|
||||
|
||||
private String cumulative_blackout_user;
|
||||
private String cumulative_repair_user;
|
||||
private String cumulative_no_repair_user;
|
||||
|
||||
/**
|
||||
* 出动抢修力量
|
||||
* 人员 车辆
|
||||
*/
|
||||
private String add_power_personnel;
|
||||
private String add_power_vehicle;
|
||||
|
||||
private String cumulative_power_personnel;
|
||||
private String cumulative_power_vehicle;
|
||||
}
|
||||
|
|
@ -1,55 +0,0 @@
|
|||
package com.bonus.autoweb.UI.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 日报实体类
|
||||
* 附件一-操练情况统计表
|
||||
* @author zys
|
||||
*/
|
||||
@Data
|
||||
public class AnnexOneBean {
|
||||
|
||||
/**
|
||||
* 操练内容(选择框)
|
||||
* “四要素”检查
|
||||
* 通信测试
|
||||
* 重要站线视频连线检查
|
||||
*/
|
||||
private String exercise_content;
|
||||
|
||||
/**
|
||||
* 操练数量
|
||||
* 人员
|
||||
*/
|
||||
private String exercise_person_num;
|
||||
|
||||
/**
|
||||
* 操练数量
|
||||
* 车辆
|
||||
*/
|
||||
private String exercise_vehicle_num;
|
||||
|
||||
/**
|
||||
* 操练数量
|
||||
* 发电车
|
||||
*/
|
||||
private String exercise_power_vehicle_num;
|
||||
|
||||
/**
|
||||
* 操练数量
|
||||
* 发电机
|
||||
*/
|
||||
private String exercise_dynamo_num;
|
||||
|
||||
/**
|
||||
* 操练发现的问题
|
||||
*/
|
||||
private String exercise_find_problems;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
}
|
||||
|
|
@ -1,69 +0,0 @@
|
|||
package com.bonus.autoweb.UI.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 日报实体类
|
||||
* 附件七-变电站停运及恢复
|
||||
* @author ztq
|
||||
*/
|
||||
@Data
|
||||
public class AnnexSevenBean {
|
||||
|
||||
/**
|
||||
* 特高压
|
||||
*/
|
||||
private String power_substation_add_outage_uvh;
|
||||
private String power_substation_add_repair_uvh;
|
||||
private String power_substation_add_no_repair_uvh;
|
||||
|
||||
private String power_substation_cumulative_outage_uvh;
|
||||
private String power_substation_cumulative_repair_uvh;
|
||||
private String power_substation_cumulative_no_repair_uvh;
|
||||
|
||||
/**
|
||||
* 500kv
|
||||
*/
|
||||
private String power_substation_add_outage_five;
|
||||
private String power_substation_add_repair_five;
|
||||
private String power_substation_add_no_repair_five;
|
||||
|
||||
private String power_substation_cumulative_outage_five;
|
||||
private String power_substation_cumulative_repair_five;
|
||||
private String power_substation_cumulative_no_repair_five;
|
||||
|
||||
/**
|
||||
* 220/300kv
|
||||
*/
|
||||
private String power_substation_add_outage_two;
|
||||
private String power_substation_add_repair_two;
|
||||
private String power_substation_add_no_repair_two;
|
||||
|
||||
private String power_substation_cumulative_outage_two;
|
||||
private String power_substation_cumulative_repair_two;
|
||||
private String power_substation_cumulative_no_repair_two;
|
||||
|
||||
/**
|
||||
* 110/66kv
|
||||
*/
|
||||
private String power_substation_add_outage_one;
|
||||
private String power_substation_add_repair_one;
|
||||
private String power_substation_add_no_repair_one;
|
||||
|
||||
private String power_substation_cumulative_outage_one;
|
||||
private String power_substation_cumulative_repair_one;
|
||||
private String power_substation_cumulative_no_repair_one;
|
||||
|
||||
/**
|
||||
* 35kv
|
||||
*/
|
||||
private String power_substation_add_outage_three;
|
||||
private String power_substation_add_repair_three;
|
||||
private String power_substation_add_no_repair_three;
|
||||
|
||||
private String power_substation_cumulative_outage_three;
|
||||
private String power_substation_cumulative_repair_three;
|
||||
private String power_substation_cumulative_no_repair_three;
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -1,47 +0,0 @@
|
|||
package com.bonus.autoweb.UI.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 日报实体类
|
||||
* 附件六-预警及应急响应情况跟踪表
|
||||
* @author zys
|
||||
*/
|
||||
@Data
|
||||
public class AnnexSixBean {
|
||||
|
||||
/**
|
||||
* 领导及指挥人员
|
||||
*/
|
||||
private String leaders_command_staff;
|
||||
|
||||
/**
|
||||
* 投入力量
|
||||
* 人员
|
||||
*/
|
||||
private String input_amount_person;
|
||||
|
||||
/**
|
||||
* 投入力量
|
||||
* 车辆
|
||||
*/
|
||||
private String input_amount_vehicle;
|
||||
|
||||
/**
|
||||
* 投入力量
|
||||
* 发电车
|
||||
*/
|
||||
private String input_amount_power_vehicle;
|
||||
|
||||
/**
|
||||
* 投入力量
|
||||
* 发电机
|
||||
*/
|
||||
private String input_amount_dynamo;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
}
|
||||
|
|
@ -1,24 +0,0 @@
|
|||
package com.bonus.autoweb.UI.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 包名称:com.bonus.autoweb.UI.entity
|
||||
* 类名称:AnnexTenBean
|
||||
* 类描述:附件十
|
||||
* 创建人:@author tqzhang
|
||||
* 创建时间:2023年08月01日 13:23
|
||||
*/
|
||||
@Data
|
||||
public class AnnexTenBean {
|
||||
private String uhv;
|
||||
private String fiveHundredKv;
|
||||
private String twoHundredTwentyKv;
|
||||
private String oneHundredTenKv;
|
||||
private String thirtyFiveKv;
|
||||
private String tenKv;
|
||||
private String averageWaterLevel;
|
||||
private String measuredValue;
|
||||
private String designValues;
|
||||
private String actionHasBeenTaken;
|
||||
}
|
||||
|
|
@ -1,24 +0,0 @@
|
|||
package com.bonus.autoweb.UI.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 包名称:com.bonus.autoweb.UI.entity
|
||||
* 类名称:AnnexTwelveBean
|
||||
* 类描述:附件十三 超设计水位线路数量统计表(仅6月-9月报送)
|
||||
* 创建人:@author tqzhang
|
||||
* 创建时间:2023年07月27日 13:15
|
||||
*/
|
||||
@Data
|
||||
public class AnnexThirteenBean {
|
||||
private String uhv;
|
||||
private String fiveHundredKv;
|
||||
private String twoHundredTwentyKv;
|
||||
private String oneHundredTenKv;
|
||||
private String thirtyFiveKv;
|
||||
private String tenKv;
|
||||
private String averageWaterLevel;
|
||||
private String measuredValue;
|
||||
private String designValues;
|
||||
private String actionHasBeenTaken;
|
||||
}
|
||||
|
|
@ -1,55 +0,0 @@
|
|||
package com.bonus.autoweb.UI.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 包名称:com.bonus.autoweb.UI.entity
|
||||
* 类名称:AnnexThreeBean
|
||||
* 类描述:附件三 电网生产相关专业员工感染情况统计表
|
||||
* 创建人:@author tqzhang
|
||||
* 创建时间:2023年07月27日 11:18
|
||||
*/
|
||||
|
||||
@Data
|
||||
public class AnnexThreeBean {
|
||||
//合计 新增
|
||||
private String totalAddDiagnosed;
|
||||
private String totalAddHeal;
|
||||
private String totalAddSuspected;
|
||||
//合计 现有
|
||||
private String totalExistingDiagnosed;
|
||||
private String totalExistingHeal;
|
||||
private String totalExistingSuspected;
|
||||
//电网调度 新增
|
||||
private String dispatchAddDiagnosed;
|
||||
private String dispatchAddHeal;
|
||||
private String dispatchAddSuspected;
|
||||
//电网调度 现有
|
||||
private String dispatchExistingDiagnosed;
|
||||
private String dispatchExistingHeal;
|
||||
private String dispatchExistingSuspected;
|
||||
//运维维修 新增
|
||||
private String repairAddDiagnosed;
|
||||
private String repairAddHeal;
|
||||
private String repairAddSuspected;
|
||||
//运维维修 现有
|
||||
private String repairExistingDiagnosed;
|
||||
private String repairExistingHeal;
|
||||
private String repairExistingSuspected;
|
||||
//营销服务 新增
|
||||
private String marketingAddDiagnosed;
|
||||
private String marketingAddHeal;
|
||||
private String marketingAddSuspected;
|
||||
//营销服务 现有
|
||||
private String marketingExistingDiagnosed;
|
||||
private String marketingExistingHeal;
|
||||
private String marketingExistingSuspected;
|
||||
//电网建设 新增
|
||||
private String constructionAddDiagnosed;
|
||||
private String constructionAddHeal;
|
||||
private String constructionAddSuspected;
|
||||
//电网建设 现有
|
||||
private String constructionExistingDiagnosed;
|
||||
private String constructionExistingHeal;
|
||||
private String constructionExistingSuspected;
|
||||
}
|
||||
|
|
@ -1,24 +0,0 @@
|
|||
package com.bonus.autoweb.UI.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 包名称:com.bonus.autoweb.UI.entity
|
||||
* 类名称:AnnexTwelveBean
|
||||
* 类描述:附件十二 超设计水位变电站数量统计表(仅6月-9月报送)
|
||||
* 创建人:@author tqzhang
|
||||
* 创建时间:2023年07月27日 13:15
|
||||
*/
|
||||
@Data
|
||||
public class AnnexTwelveBean {
|
||||
private String uhv;
|
||||
private String fiveHundredKv;
|
||||
private String twoHundredTwentyKv;
|
||||
private String oneHundredTenKv;
|
||||
private String thirtyFiveKv;
|
||||
private String tenKv;
|
||||
private String averageWaterLevel;
|
||||
private String measuredValue;
|
||||
private String designValues;
|
||||
private String actionHasBeenTaken;
|
||||
}
|
||||
|
|
@ -1,53 +0,0 @@
|
|||
package com.bonus.autoweb.UI.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 日报实体类
|
||||
* 附件二-资源核查问题数量统计表
|
||||
* @author zys
|
||||
*/
|
||||
@Data
|
||||
public class AnnexTwoBean {
|
||||
|
||||
/**
|
||||
* 核查数量
|
||||
* 人员
|
||||
*/
|
||||
private String verification_person_num;
|
||||
|
||||
/**
|
||||
* 核查数量
|
||||
* 队伍
|
||||
*/
|
||||
private String verification_team_num;
|
||||
|
||||
/**
|
||||
* 核查数量
|
||||
* 装备
|
||||
*/
|
||||
private String verification_equip_num;
|
||||
|
||||
/**
|
||||
* 核查数量
|
||||
* 物资
|
||||
*/
|
||||
private String verification_material_num;
|
||||
|
||||
/**
|
||||
* 核查数量
|
||||
* 车辆
|
||||
*/
|
||||
private String verification_vehicle_num;
|
||||
|
||||
/**
|
||||
* 核查发现的问题
|
||||
*/
|
||||
private String verification_find_problems;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
}
|
||||
|
|
@ -1,140 +0,0 @@
|
|||
package com.bonus.autoweb.UI.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 日报实体类
|
||||
* @author zys
|
||||
*/
|
||||
@Data
|
||||
public class DailyBean {
|
||||
|
||||
/**
|
||||
* 总体情况
|
||||
*/
|
||||
private String overall;
|
||||
|
||||
/**
|
||||
* 重要事项
|
||||
*/
|
||||
private String important_matters;
|
||||
|
||||
/**
|
||||
* 安全生产情况
|
||||
*/
|
||||
private String safety_production;
|
||||
|
||||
/**
|
||||
* 值班员日常工作情况
|
||||
*/
|
||||
private String personnel_daily_work;
|
||||
|
||||
/**
|
||||
* 供电保障情况
|
||||
* 今日重大活动保电情况
|
||||
*/
|
||||
private String power_guarantee_today_work;
|
||||
|
||||
/**
|
||||
* 供电保障情况
|
||||
* 明日重大保电情况
|
||||
*/
|
||||
private String power_guarantee_tomorrow_work;
|
||||
|
||||
/**
|
||||
* 供电保障情况
|
||||
* 今日疫情防控应急保电情况
|
||||
*/
|
||||
private String power_guarantee_today_pestilence;
|
||||
|
||||
/**
|
||||
* 预警及应急响应情况
|
||||
* 公司预警情况
|
||||
*/
|
||||
private String warning_company;
|
||||
|
||||
/**
|
||||
* 预警及应急响应情况
|
||||
* 公司应急响应情况
|
||||
*/
|
||||
private String warning_company_impatient;
|
||||
|
||||
/**
|
||||
* 预警及应急响应情况
|
||||
* 社会突发事件救援及处置情况
|
||||
*/
|
||||
private String warning_society_emergency;
|
||||
|
||||
/**
|
||||
* 其他情况说明
|
||||
*/
|
||||
private String other_situations;
|
||||
|
||||
/**
|
||||
* 附件一
|
||||
*/
|
||||
private AnnexOneBean oneBean;
|
||||
|
||||
/**
|
||||
* 附件二
|
||||
*/
|
||||
private AnnexTwoBean twoBean;
|
||||
|
||||
/**
|
||||
* 附件三
|
||||
*/
|
||||
private AnnexThreeBean threeBean;
|
||||
|
||||
/**
|
||||
* 附件四
|
||||
*/
|
||||
private AnnexFourBean fourBean;
|
||||
|
||||
/**
|
||||
* 附件五
|
||||
*/
|
||||
private AnnexFiveBean fiveBean;
|
||||
|
||||
/**
|
||||
* 附件六
|
||||
*/
|
||||
private AnnexSixBean sixBean;
|
||||
|
||||
/**
|
||||
* 附件七
|
||||
*/
|
||||
private AnnexSevenBean sevenBean;
|
||||
|
||||
/**
|
||||
* 附件八
|
||||
*/
|
||||
private AnnexEightBean eightBean;
|
||||
|
||||
/**
|
||||
* 附件九
|
||||
*/
|
||||
private AnnexNineBean nineBean;
|
||||
|
||||
/**
|
||||
* 附件十
|
||||
*/
|
||||
private AnnexTenBean tenBean;
|
||||
/**
|
||||
* 附件十一
|
||||
*/
|
||||
private AnnexElevenBean elevenBean;
|
||||
/**
|
||||
* 附件十二
|
||||
*/
|
||||
private AnnexTwelveBean twelveBean;
|
||||
|
||||
/**
|
||||
* 附件十三
|
||||
*/
|
||||
private AnnexThirteenBean thirteenBean;
|
||||
|
||||
/**
|
||||
* 附件十四
|
||||
*/
|
||||
private AnnexFourteenBean fourteenBean;
|
||||
}
|
||||
|
|
@ -1,108 +0,0 @@
|
|||
package com.bonus.autoweb.UI.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 日志实体类
|
||||
* @author zys
|
||||
*/
|
||||
@Data
|
||||
public class LogBean implements Serializable {
|
||||
|
||||
/**
|
||||
* 天气
|
||||
*/
|
||||
private String weather;
|
||||
/**
|
||||
* 最低气温 0/10
|
||||
*/
|
||||
private String min_temperature;
|
||||
|
||||
/**
|
||||
* 最高气温 0/10
|
||||
*/
|
||||
private String max_temperature;
|
||||
|
||||
/**
|
||||
* 事件检测标题
|
||||
*/
|
||||
private String event_detection_title;
|
||||
|
||||
/**
|
||||
* 事件检测内容
|
||||
*/
|
||||
private String event_detection_content;
|
||||
|
||||
/**
|
||||
* 保电工作标题
|
||||
*/
|
||||
private String power_work_title;
|
||||
|
||||
/**
|
||||
* 保电工作内容
|
||||
*/
|
||||
private String power_work_content;
|
||||
|
||||
/**
|
||||
* 资源核查情况标题
|
||||
*/
|
||||
private String resource_check_title;
|
||||
|
||||
/**
|
||||
* 资源核查情况内容
|
||||
*/
|
||||
private String resource_check_content;
|
||||
|
||||
/**
|
||||
* 通信测试标题
|
||||
*/
|
||||
private String communications_test_title;
|
||||
|
||||
/**
|
||||
* 通信测试内容
|
||||
*/
|
||||
private String communications_test_content;
|
||||
|
||||
/**
|
||||
* 日常操作情况标题
|
||||
*/
|
||||
private String daily_operation_title;
|
||||
|
||||
/**
|
||||
* 日常操作情况内容
|
||||
*/
|
||||
private String daily_operation_content;
|
||||
|
||||
/**
|
||||
* 日报提报情况标题
|
||||
*/
|
||||
private String daily_submission_title;
|
||||
|
||||
/**
|
||||
* 日报提报情况内容
|
||||
*/
|
||||
private String daily_submission_content;
|
||||
|
||||
/**
|
||||
* 预警处置标题
|
||||
*/
|
||||
private String warning_disposal_title;
|
||||
|
||||
/**
|
||||
* 预警处置内容
|
||||
*/
|
||||
private String warning_disposal_content;
|
||||
|
||||
/**
|
||||
* 一般记事标题
|
||||
*/
|
||||
private String general_chronicles_title;
|
||||
|
||||
/**
|
||||
* 一般记事内容
|
||||
*/
|
||||
private String general_chronicles_content;
|
||||
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
|
|
@ -1,69 +0,0 @@
|
|||
package com.bonus.autoweb.UI.frame;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.border.EmptyBorder;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
|
||||
public class Jframe extends JFrame {
|
||||
|
||||
private JPanel contentPane;
|
||||
|
||||
public static void main(String[] args) {
|
||||
Jframe frame = new Jframe();
|
||||
frame.setVisible(true);
|
||||
}
|
||||
|
||||
public Jframe() {
|
||||
setTitle("信息填报");
|
||||
//设置窗口显示尺寸
|
||||
Dimension dimension = Toolkit.getDefaultToolkit().getScreenSize();
|
||||
setSize(dimension.width / 2, dimension.height / 2);
|
||||
Point p = GraphicsEnvironment.getLocalGraphicsEnvironment().getCenterPoint();
|
||||
setBounds(p.x - (dimension.width + 100) / 3 * 2 / 2, p.y - dimension.height / 2 / 2,
|
||||
(dimension.width + 200) / 3 * 2, dimension.height / 5 * 3);
|
||||
//设置窗口是否可以关闭
|
||||
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
contentPane = new JPanel();
|
||||
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
|
||||
setContentPane(contentPane);
|
||||
contentPane.setLayout(null);
|
||||
JButton logButton = new JButton("日志");
|
||||
logButton.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
new LogAction();
|
||||
}
|
||||
});
|
||||
logButton.setFont(new Font("微软雅黑",Font.BOLD,50));
|
||||
logButton.setForeground(Color.BLACK);
|
||||
logButton.setBounds(80, 50, 1100, 100);
|
||||
contentPane.add(logButton);
|
||||
|
||||
JButton morningButton = new JButton("早报");
|
||||
morningButton.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
new DailyAction("morning_daily");
|
||||
}
|
||||
});
|
||||
morningButton.setFont(new Font("微软雅黑",Font.BOLD,50));
|
||||
morningButton.setForeground(Color.BLACK);
|
||||
morningButton.setBounds(80, 250, 1100, 100);
|
||||
contentPane.add(morningButton);
|
||||
|
||||
JButton eveningButton = new JButton("晚报");
|
||||
eveningButton.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
new DailyAction("evening_daily");
|
||||
}
|
||||
});
|
||||
eveningButton.setFont(new Font("微软雅黑",Font.BOLD,50));
|
||||
eveningButton.setForeground(Color.BLACK);
|
||||
eveningButton.setBounds(80, 450, 1100, 100);
|
||||
contentPane.add(eveningButton);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,734 +0,0 @@
|
|||
package com.bonus.autoweb.UI.frame;
|
||||
|
||||
import com.bonus.autoweb.UI.entity.LogBean;
|
||||
import com.bonus.autoweb.base.DataConfig;
|
||||
import com.thoughtworks.xstream.XStream;
|
||||
import com.thoughtworks.xstream.io.json.JettisonMappedXmlDriver;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.FocusEvent;
|
||||
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;
|
||||
|
||||
/**
|
||||
* 日志页面
|
||||
*
|
||||
* @author zys
|
||||
*/
|
||||
public class LogAction extends JFrame implements MouseListener {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
JPanel jp;
|
||||
|
||||
JTextField weatherJt, lowTemperatureJt, temperatureJt, eventDetectionTitleJt, powerWorkTitleJt, resourceCheckTitleJt,
|
||||
communicationsTestTitleJt, dailyOperationTitleJt, dailySubmissionTitleJt, warningDisposalTitleJt, generalChroniclesTitleJt;
|
||||
JTextArea eventDetectionContentJt,powerWorkContentJt,resourceCheckContentJt,communicationsTestContentJt,
|
||||
dailyOperationContentJt,dailySubmissionContentJt,warningDisposalContentJt,generalChroniclesContentJt;
|
||||
|
||||
JButton btn;
|
||||
|
||||
JScrollPane jScroller;
|
||||
|
||||
public static void main(String[] args) {
|
||||
new LogAction();
|
||||
}
|
||||
|
||||
public LogAction() {
|
||||
//设置显示窗口标题
|
||||
setTitle("日志填报");
|
||||
Dimension dimension = Toolkit.getDefaultToolkit().getScreenSize();
|
||||
//设置窗口显示尺寸
|
||||
setSize((dimension.width + 420) / 2, dimension.height);
|
||||
Point p = GraphicsEnvironment.getLocalGraphicsEnvironment().getCenterPoint();
|
||||
setBounds(p.x - (dimension.width + 180) / 3 * 2 / 2, p.y - dimension.height / 2 + 25,
|
||||
(dimension.width + 420) / 3 * 2, dimension.height - 50);
|
||||
setResizable(false);
|
||||
//设置窗口是否可以关闭
|
||||
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
//获取本窗口的内容窗格
|
||||
Container c = getContentPane();
|
||||
JPanel jPanel = initMainJpanel();
|
||||
jScroller = new JScrollPane(jPanel, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS,
|
||||
ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
|
||||
//设置滚轮速度
|
||||
jScroller.getVerticalScrollBar().setUnitIncrement(20);
|
||||
c.add(jScroller);
|
||||
//设置本窗口是否可见
|
||||
setVisible(true);
|
||||
initData();
|
||||
}
|
||||
|
||||
private void initData() {
|
||||
if (new File(DataConfig.filePath + "\\log.xml").exists()) {
|
||||
// 反序列化--> 解决乱码问题
|
||||
File file = new File(DataConfig.filePath + "\\log.xml");
|
||||
InputStreamReader in = null;
|
||||
String xml = null;
|
||||
try {
|
||||
//主要就是这里的设置
|
||||
in = new InputStreamReader(new FileInputStream(file), Charset.forName("gbk") );
|
||||
StringBuffer sb = new StringBuffer();
|
||||
char[] array= new char[1024];
|
||||
int length = -1;
|
||||
while((length=in.read(array))!= -1){
|
||||
sb.append(array, 0, length);
|
||||
}
|
||||
in.close();
|
||||
xml=sb.toString().trim();
|
||||
System.out.println(xml);
|
||||
} catch (Exception e) {
|
||||
// TODO: handle exception
|
||||
}
|
||||
|
||||
XStream xstream = new XStream(new JettisonMappedXmlDriver());
|
||||
xstream.alias("log", LogBean.class);
|
||||
LogBean bean = (LogBean) xstream.fromXML(xml);
|
||||
weatherJt.setText(bean.getWeather());
|
||||
lowTemperatureJt.setText(bean.getMin_temperature());
|
||||
temperatureJt.setText(bean.getMax_temperature());
|
||||
eventDetectionTitleJt.setText(bean.getEvent_detection_title());
|
||||
eventDetectionContentJt.setText(bean.getEvent_detection_content());
|
||||
powerWorkTitleJt.setText(bean.getPower_work_title());
|
||||
powerWorkContentJt.setText(bean.getPower_work_content());
|
||||
resourceCheckTitleJt.setText(bean.getResource_check_title());
|
||||
resourceCheckContentJt.setText(bean.getResource_check_content());
|
||||
communicationsTestTitleJt.setText(bean.getCommunications_test_title());
|
||||
communicationsTestContentJt.setText(bean.getCommunications_test_content());
|
||||
dailyOperationTitleJt.setText(bean.getDaily_operation_title());
|
||||
dailyOperationContentJt.setText(bean.getDaily_operation_content());
|
||||
dailySubmissionTitleJt.setText(bean.getDaily_submission_title());
|
||||
dailySubmissionContentJt.setText(bean.getDaily_submission_content());
|
||||
warningDisposalTitleJt.setText(bean.getWarning_disposal_title());
|
||||
warningDisposalContentJt.setText(bean.getWarning_disposal_content());
|
||||
generalChroniclesTitleJt.setText(bean.getGeneral_chronicles_title());
|
||||
generalChroniclesContentJt.setText(bean.getGeneral_chronicles_content());
|
||||
}
|
||||
}
|
||||
|
||||
private JPanel initMainJpanel() {
|
||||
int height = 120 * 40 + 35;
|
||||
Dimension dimension = Toolkit.getDefaultToolkit().getScreenSize();
|
||||
jp = new JPanel();
|
||||
jp.setOpaque(false);
|
||||
jp.setLayout(null);
|
||||
jp.setSize(dimension);
|
||||
jp.setPreferredSize(new Dimension((dimension.width + 100) / 2, height));
|
||||
int oneLabelY = 20;
|
||||
int oneTextY = 35;
|
||||
/**
|
||||
* 天气
|
||||
*/
|
||||
JLabel weatherLabel = new JLabel("天气");
|
||||
weatherLabel.setFont(new Font("微软雅黑", Font.BOLD, 50));
|
||||
weatherLabel.setForeground(new Color(11, 24, 76));
|
||||
int weatherJlx = 30;
|
||||
weatherLabel.setBounds(weatherJlx, oneLabelY, 400, 100);
|
||||
/**
|
||||
* 天气输入框
|
||||
*/
|
||||
weatherJt = new JTextField();
|
||||
setTextFiledColor(weatherJt);
|
||||
int weatherJtX = weatherJlx + 150;
|
||||
weatherJt.setBounds(weatherJtX, oneTextY, 250, 80);
|
||||
|
||||
/**添加最低气温 调整整体宽度位置*/
|
||||
/**
|
||||
* 最低气温
|
||||
*/
|
||||
JLabel lowTemperatureLabel = new JLabel("最低气温");
|
||||
lowTemperatureLabel.setFont(new Font("微软雅黑", Font.BOLD, 50));
|
||||
lowTemperatureLabel.setForeground(new Color(11, 24, 76));
|
||||
int lowTemperatureJlx = weatherJtX + 270;
|
||||
lowTemperatureLabel.setBounds(lowTemperatureJlx, oneLabelY, 200, 100);
|
||||
/**
|
||||
* 最低气温输入框
|
||||
*/
|
||||
lowTemperatureJt = new JTextField();
|
||||
setTextFiledColor(lowTemperatureJt);
|
||||
int lowTemperatureJtX = lowTemperatureJlx + 220;
|
||||
lowTemperatureJt.setBounds(lowTemperatureJtX, oneTextY, 160, 80);
|
||||
|
||||
|
||||
/**
|
||||
* 最高气温
|
||||
*/
|
||||
JLabel temperatureLabel = new JLabel("最高气温");
|
||||
temperatureLabel.setFont(new Font("微软雅黑", Font.BOLD, 50));
|
||||
temperatureLabel.setForeground(new Color(11, 24, 76));
|
||||
int temperatureJlx = weatherJtX + 700;
|
||||
temperatureLabel.setBounds(temperatureJlx, oneLabelY, 200, 100);
|
||||
/**
|
||||
* 最高气温输入框
|
||||
*/
|
||||
temperatureJt = new JTextField();
|
||||
setTextFiledColor(temperatureJt);
|
||||
int temperatureJtX = temperatureJlx + 220;
|
||||
temperatureJt.setBounds(temperatureJtX, oneTextY, 160, 80);
|
||||
|
||||
/**
|
||||
* 一、事件检测
|
||||
*/
|
||||
JLabel eventDetectionLabel = new JLabel("一、事件检测");
|
||||
eventDetectionLabel.setFont(new Font("微软雅黑", Font.BOLD, 50));
|
||||
eventDetectionLabel.setForeground(new Color(11, 24, 76));
|
||||
int eventDetectionJlx = 30;
|
||||
int eventDetectionJly = oneLabelY + 120;
|
||||
eventDetectionLabel.setBounds(eventDetectionJlx, eventDetectionJly, 500, 100);
|
||||
/**
|
||||
* 事件检测标题输入框
|
||||
*/
|
||||
eventDetectionTitleJt = new JTextField();
|
||||
setTextFiledColor(eventDetectionTitleJt);
|
||||
int eventDetectionTitleJtX = eventDetectionJlx + 500;
|
||||
eventDetectionTitleJt.setBounds(eventDetectionTitleJtX, eventDetectionJly + 15, 810, 80);
|
||||
if (StringHelper.isEmptyAndNull(eventDetectionTitleJt.getText())) {
|
||||
eventDetectionTitleJt.addFocusListener(new MyFocusListener("请输入事件检测标题", eventDetectionTitleJt));
|
||||
}
|
||||
|
||||
/**
|
||||
* 事件检测内容输入框
|
||||
*/
|
||||
// eventDetectionContentJt = new JTextField();
|
||||
// setTextFiledColor(eventDetectionContentJt);
|
||||
// int eventDetectionContentJtY = eventDetectionJly + 120;
|
||||
// eventDetectionContentJt.setBounds(eventDetectionJlx, eventDetectionContentJtY, 1310, 120);
|
||||
// if (StringHelper.isEmptyAndNull(eventDetectionContentJt.getText())) {
|
||||
// eventDetectionContentJt.addFocusListener(new MyFocusListener("请输入事件检测内容", eventDetectionContentJt));
|
||||
// }
|
||||
eventDetectionContentJt=new JTextArea(7,26);
|
||||
Placeholder placeholder0 = new Placeholder(eventDetectionContentJt, "请输入事件检测内容...");
|
||||
eventDetectionContentJt.setLineWrap(true); //设置文本域中的文本为自动换行
|
||||
eventDetectionContentJt.setForeground(Color.BLACK); //设置组件的背景色
|
||||
eventDetectionContentJt.setFont(new Font("微软雅黑",Font.PLAIN,40)); //修改字体样式
|
||||
eventDetectionContentJt.setBackground(Color.WHITE); //设置按钮背景色
|
||||
JScrollPane jsp=new JScrollPane(eventDetectionContentJt); //将文本域放入滚动窗口
|
||||
Dimension size=eventDetectionContentJt.getPreferredSize(); //获得文本域的首选大小
|
||||
int eventDetectionContentJtY = eventDetectionJly + 120;
|
||||
jsp.setBounds(eventDetectionJlx,eventDetectionContentJtY,1310,size.height+20);
|
||||
|
||||
jp.add(jsp);
|
||||
|
||||
/**
|
||||
* 二、保电工作
|
||||
*/
|
||||
JLabel powerWorkLabel = new JLabel("二、保电工作");
|
||||
powerWorkLabel.setFont(new Font("微软雅黑", Font.BOLD, 50));
|
||||
powerWorkLabel.setForeground(new Color(11, 24, 76));
|
||||
int powerWorkJlx = 30;
|
||||
int powerWorkJly = size.height + 300;
|
||||
powerWorkLabel.setBounds(powerWorkJlx, powerWorkJly, 500, 100);
|
||||
/**
|
||||
* 保电工作标题输入框
|
||||
*/
|
||||
powerWorkTitleJt = new JTextField();
|
||||
setTextFiledColor(powerWorkTitleJt);
|
||||
int powerWorkTitleJtX = powerWorkJlx + 500;
|
||||
powerWorkTitleJt.setBounds(powerWorkTitleJtX, powerWorkJly + 15, 810, 80);
|
||||
if (StringHelper.isEmptyAndNull(powerWorkTitleJt.getText())) {
|
||||
powerWorkTitleJt.addFocusListener(new MyFocusListener("请输入保电工作标题", powerWorkTitleJt));
|
||||
}
|
||||
|
||||
/**
|
||||
* 保电工作内容输入框
|
||||
*/
|
||||
// powerWorkContentJt = new JTextField();
|
||||
// setTextFiledColor(powerWorkContentJt);
|
||||
//
|
||||
// powerWorkContentJt.setBounds(powerWorkJlx, powerWorkContentJtY, 1310, 120);
|
||||
// if (StringHelper.isEmptyAndNull(powerWorkContentJt.getText())) {
|
||||
// powerWorkContentJt.addFocusListener(new MyFocusListener("请输入保电工作内容", powerWorkContentJt));
|
||||
// }
|
||||
powerWorkContentJt=new JTextArea(7,26);
|
||||
Placeholder placeholder1 = new Placeholder(powerWorkContentJt, "请输入保电工作内容...");
|
||||
powerWorkContentJt.setLineWrap(true); //设置文本域中的文本为自动换行
|
||||
powerWorkContentJt.setForeground(Color.BLACK); //设置组件的背景色
|
||||
powerWorkContentJt.setFont(new Font("微软雅黑",Font.PLAIN,40)); //修改字体样式
|
||||
powerWorkContentJt.setBackground(Color.WHITE); //设置按钮背景色
|
||||
JScrollPane powerWorkContentJtJsp=new JScrollPane(powerWorkContentJt); //将文本域放入滚动窗口
|
||||
Dimension powerWorkContentJtSize=powerWorkContentJt.getPreferredSize(); //获得文本域的首选大小
|
||||
int powerWorkContentJtY = powerWorkJly + 120;
|
||||
powerWorkContentJtJsp.setBounds(eventDetectionJlx,powerWorkContentJtY,1310,powerWorkContentJtSize.height+20);
|
||||
|
||||
jp.add(powerWorkContentJtJsp);
|
||||
/**
|
||||
* 三、资源核查情况
|
||||
*/
|
||||
JLabel resourceCheckLabel = new JLabel("三、资源核查情况");
|
||||
resourceCheckLabel.setFont(new Font("微软雅黑", Font.BOLD, 50));
|
||||
resourceCheckLabel.setForeground(new Color(11, 24, 76));
|
||||
int resourceCheckJlx = 30;
|
||||
int resourceCheckJly = powerWorkContentJtY + 450;
|
||||
resourceCheckLabel.setBounds(resourceCheckJlx, resourceCheckJly, 500, 100);
|
||||
/**
|
||||
* 资源核查情况标题输入框
|
||||
*/
|
||||
resourceCheckTitleJt = new JTextField();
|
||||
setTextFiledColor(resourceCheckTitleJt);
|
||||
int resourceCheckTitleJtX = resourceCheckJlx + 500;
|
||||
resourceCheckTitleJt.setBounds(resourceCheckTitleJtX, resourceCheckJly + 15, 810, 80);
|
||||
if (StringHelper.isEmptyAndNull(resourceCheckTitleJt.getText())) {
|
||||
resourceCheckTitleJt.addFocusListener(new MyFocusListener("请输入资源核查情况标题", resourceCheckTitleJt));
|
||||
}
|
||||
|
||||
/**
|
||||
* 资源核查情况内容输入框
|
||||
*/
|
||||
// resourceCheckContentJt = new JTextField();
|
||||
// setTextFiledColor(resourceCheckContentJt);
|
||||
// int resourceCheckContentJtY = resourceCheckJly + 120;
|
||||
// resourceCheckContentJt.setBounds(resourceCheckJlx, resourceCheckContentJtY, 1310, 120);
|
||||
// if (StringHelper.isEmptyAndNull(resourceCheckContentJt.getText())) {
|
||||
// resourceCheckContentJt.addFocusListener(new MyFocusListener("请输入资源核查情况内容", resourceCheckContentJt));
|
||||
// }
|
||||
resourceCheckContentJt=new JTextArea(7,26);
|
||||
Placeholder placeholder2 = new Placeholder(resourceCheckContentJt, "请输入资源核查情况内容...");
|
||||
resourceCheckContentJt.setLineWrap(true); //设置文本域中的文本为自动换行
|
||||
resourceCheckContentJt.setForeground(Color.BLACK); //设置组件的背景色
|
||||
resourceCheckContentJt.setFont(new Font("微软雅黑",Font.PLAIN,40)); //修改字体样式
|
||||
resourceCheckContentJt.setBackground(Color.WHITE); //设置按钮背景色
|
||||
JScrollPane resourceCheckContentJtJsp=new JScrollPane(resourceCheckContentJt); //将文本域放入滚动窗口
|
||||
Dimension resourceCheckContentJtSize=resourceCheckContentJt.getPreferredSize(); //获得文本域的首选大小
|
||||
int resourceCheckContentJtY = resourceCheckJly + 120;
|
||||
resourceCheckContentJtJsp.setBounds(eventDetectionJlx,resourceCheckContentJtY,1310,resourceCheckContentJtSize.height+20);
|
||||
jp.add(resourceCheckContentJtJsp);
|
||||
/**
|
||||
* 四、通信测试情况
|
||||
*/
|
||||
JLabel communicationsTestLabel = new JLabel("四、通信测试情况");
|
||||
communicationsTestLabel.setFont(new Font("微软雅黑", Font.BOLD, 50));
|
||||
communicationsTestLabel.setForeground(new Color(11, 24, 76));
|
||||
int communicationsTestJlx = 30;
|
||||
int communicationsTestJly = resourceCheckContentJtY + 450;
|
||||
communicationsTestLabel.setBounds(communicationsTestJlx, communicationsTestJly, 500, 100);
|
||||
/**
|
||||
* 通信测试情况标题输入框
|
||||
*/
|
||||
communicationsTestTitleJt = new JTextField();
|
||||
setTextFiledColor(communicationsTestTitleJt);
|
||||
int communicationsTestTitleJtX = communicationsTestJlx + 500;
|
||||
communicationsTestTitleJt.setBounds(communicationsTestTitleJtX, communicationsTestJly + 15, 810, 80);
|
||||
if (StringHelper.isEmptyAndNull(communicationsTestTitleJt.getText())) {
|
||||
communicationsTestTitleJt.addFocusListener(new MyFocusListener("请输入通信测试情况标题", communicationsTestTitleJt));
|
||||
}
|
||||
|
||||
/**
|
||||
* 通信测试情况内容输入框
|
||||
*/
|
||||
// communicationsTestContentJt = new JTextField();
|
||||
// setTextFiledColor(communicationsTestContentJt);
|
||||
// int communicationsTestContentJtY = communicationsTestJly + 120;
|
||||
// communicationsTestContentJt.setBounds(communicationsTestJlx, communicationsTestContentJtY, 1310, 120);
|
||||
// if (StringHelper.isEmptyAndNull(communicationsTestContentJt.getText())) {
|
||||
// communicationsTestContentJt.addFocusListener(new MyFocusListener("请输入通信测试情况内容", communicationsTestContentJt));
|
||||
// }
|
||||
|
||||
communicationsTestContentJt=new JTextArea(7,26);
|
||||
Placeholder placeholder3 = new Placeholder(communicationsTestContentJt, "请输入通信测试情况内容...");
|
||||
communicationsTestContentJt.setLineWrap(true); //设置文本域中的文本为自动换行
|
||||
communicationsTestContentJt.setForeground(Color.BLACK); //设置组件的背景色
|
||||
communicationsTestContentJt.setFont(new Font("微软雅黑",Font.PLAIN,40)); //修改字体样式
|
||||
communicationsTestContentJt.setBackground(Color.WHITE); //设置按钮背景色
|
||||
JScrollPane communicationsTestContentJtJsp=new JScrollPane(communicationsTestContentJt); //将文本域放入滚动窗口
|
||||
Dimension communicationsTestContentJtSize=communicationsTestContentJt.getPreferredSize(); //获得文本域的首选大小
|
||||
int communicationsTestContentJtY = communicationsTestJly + 120;
|
||||
communicationsTestContentJtJsp.setBounds(eventDetectionJlx,communicationsTestContentJtY,1310,communicationsTestContentJtSize.height+20);
|
||||
jp.add(communicationsTestContentJtJsp);
|
||||
|
||||
/**
|
||||
* 五、日常操作情况
|
||||
*/
|
||||
JLabel dailyOperationLabel = new JLabel("五、日常操作情况");
|
||||
dailyOperationLabel.setFont(new Font("微软雅黑", Font.BOLD, 50));
|
||||
dailyOperationLabel.setForeground(new Color(11, 24, 76));
|
||||
int dailyOperationJlx = 30;
|
||||
int dailyOperationJly = communicationsTestContentJtY + 450;
|
||||
dailyOperationLabel.setBounds(dailyOperationJlx, dailyOperationJly, 500, 100);
|
||||
/**
|
||||
* 日常操作情况标题输入框
|
||||
*/
|
||||
dailyOperationTitleJt = new JTextField();
|
||||
setTextFiledColor(dailyOperationTitleJt);
|
||||
int dailyOperationTitleJtX = dailyOperationJlx + 500;
|
||||
dailyOperationTitleJt.setBounds(dailyOperationTitleJtX, dailyOperationJly + 15, 810, 80);
|
||||
if (StringHelper.isEmptyAndNull(dailyOperationTitleJt.getText())) {
|
||||
dailyOperationTitleJt.addFocusListener(new MyFocusListener("请输入日常操作情况标题", dailyOperationTitleJt));
|
||||
}
|
||||
|
||||
/**
|
||||
* 日常操作情况内容输入框
|
||||
*/
|
||||
// dailyOperationContentJt = new JTextField();
|
||||
// setTextFiledColor(dailyOperationContentJt);
|
||||
// int dailyOperationContentJtY = dailyOperationJly + 120;
|
||||
// dailyOperationContentJt.setBounds(dailyOperationJlx, dailyOperationContentJtY, 1310, 120);
|
||||
// if (StringHelper.isEmptyAndNull(dailyOperationContentJt.getText())) {
|
||||
// dailyOperationContentJt.addFocusListener(new MyFocusListener("请输入日常操作情况内容", dailyOperationContentJt));
|
||||
// }
|
||||
|
||||
dailyOperationContentJt=new JTextArea(7,26);
|
||||
Placeholder placeholder4 = new Placeholder(dailyOperationContentJt, "请输入日常操作情况内容...");
|
||||
dailyOperationContentJt.setLineWrap(true); //设置文本域中的文本为自动换行
|
||||
dailyOperationContentJt.setForeground(Color.BLACK); //设置组件的背景色
|
||||
dailyOperationContentJt.setFont(new Font("微软雅黑",Font.PLAIN,40)); //修改字体样式
|
||||
dailyOperationContentJt.setBackground(Color.WHITE); //设置按钮背景色
|
||||
JScrollPane dailyOperationContentJtJsp=new JScrollPane(dailyOperationContentJt); //将文本域放入滚动窗口
|
||||
Dimension dailyOperationContentJtSize=dailyOperationContentJt.getPreferredSize(); //获得文本域的首选大小
|
||||
int dailyOperationContentJtY = dailyOperationJly + 120;
|
||||
dailyOperationContentJtJsp.setBounds(eventDetectionJlx,dailyOperationContentJtY,1310,dailyOperationContentJtSize.height+20);
|
||||
jp.add(dailyOperationContentJtJsp);
|
||||
|
||||
/**
|
||||
* 六、日报提报情况
|
||||
*/
|
||||
JLabel dailySubmissionLabel = new JLabel("六、日报提报情况");
|
||||
dailySubmissionLabel.setFont(new Font("微软雅黑", Font.BOLD, 50));
|
||||
dailySubmissionLabel.setForeground(new Color(11, 24, 76));
|
||||
int dailySubmissionJlx = 30;
|
||||
int dailySubmissionJly = dailyOperationContentJtY + 450;
|
||||
dailySubmissionLabel.setBounds(dailySubmissionJlx, dailySubmissionJly, 500, 100);
|
||||
/**
|
||||
* 日报提报情况标题输入框
|
||||
*/
|
||||
dailySubmissionTitleJt = new JTextField();
|
||||
setTextFiledColor(dailySubmissionTitleJt);
|
||||
int dailySubmissionTitleJtX = dailySubmissionJlx + 500;
|
||||
dailySubmissionTitleJt.setBounds(dailySubmissionTitleJtX, dailySubmissionJly + 15, 810, 80);
|
||||
if (StringHelper.isEmptyAndNull(dailySubmissionTitleJt.getText())) {
|
||||
dailySubmissionTitleJt.addFocusListener(new MyFocusListener("请输入日报提报情况标题", dailySubmissionTitleJt));
|
||||
}
|
||||
|
||||
/**
|
||||
* 日报提报情况内容输入框
|
||||
*/
|
||||
// dailySubmissionContentJt = new JTextField();
|
||||
// setTextFiledColor(dailySubmissionContentJt);
|
||||
// int dailySubmissionContentJtY = dailySubmissionJly + 120;
|
||||
// dailySubmissionContentJt.setBounds(dailySubmissionJlx, dailySubmissionContentJtY, 1310, 120);
|
||||
// if (StringHelper.isEmptyAndNull(dailySubmissionContentJt.getText())) {
|
||||
// dailySubmissionContentJt.addFocusListener(new MyFocusListener("请输入日报提报情况内容", dailySubmissionContentJt));
|
||||
// }
|
||||
|
||||
dailySubmissionContentJt=new JTextArea(7,26);
|
||||
Placeholder placeholder5 = new Placeholder(dailySubmissionContentJt, "请输入日报提报情况内容...");
|
||||
dailySubmissionContentJt.setLineWrap(true); //设置文本域中的文本为自动换行
|
||||
dailySubmissionContentJt.setForeground(Color.BLACK); //设置组件的背景色
|
||||
dailySubmissionContentJt.setFont(new Font("微软雅黑",Font.PLAIN,40)); //修改字体样式
|
||||
dailySubmissionContentJt.setBackground(Color.WHITE); //设置按钮背景色
|
||||
JScrollPane dailySubmissionContentJtJsp=new JScrollPane(dailySubmissionContentJt); //将文本域放入滚动窗口
|
||||
Dimension dailySubmissionContentJtSize=dailySubmissionContentJt.getPreferredSize(); //获得文本域的首选大小
|
||||
int dailySubmissionContentJtY = dailySubmissionJly + 120;
|
||||
dailySubmissionContentJtJsp.setBounds(eventDetectionJlx,dailySubmissionContentJtY,1310,dailySubmissionContentJtSize.height+20);
|
||||
jp.add(dailySubmissionContentJtJsp);
|
||||
|
||||
/**
|
||||
* 七、预警处置
|
||||
*/
|
||||
JLabel warningDisposalLabel = new JLabel("七、预警处置");
|
||||
warningDisposalLabel.setFont(new Font("微软雅黑", Font.BOLD, 50));
|
||||
warningDisposalLabel.setForeground(new Color(11, 24, 76));
|
||||
int warningDisposalJlx = 30;
|
||||
int warningDisposalJly = dailySubmissionContentJtY + 450;
|
||||
warningDisposalLabel.setBounds(warningDisposalJlx, warningDisposalJly, 500, 100);
|
||||
/**
|
||||
* 预警处置标题输入框
|
||||
*/
|
||||
warningDisposalTitleJt = new JTextField();
|
||||
setTextFiledColor(warningDisposalTitleJt);
|
||||
int warningDisposalTitleJtX = warningDisposalJlx + 500;
|
||||
warningDisposalTitleJt.setBounds(warningDisposalTitleJtX, warningDisposalJly + 15, 810, 80);
|
||||
if (StringHelper.isEmptyAndNull(warningDisposalTitleJt.getText())) {
|
||||
warningDisposalTitleJt.addFocusListener(new MyFocusListener("请输入预警处置标题", warningDisposalTitleJt));
|
||||
}
|
||||
|
||||
/**
|
||||
* 预警处置内容输入框
|
||||
*/
|
||||
// warningDisposalContentJt = new JTextField();
|
||||
// setTextFiledColor(warningDisposalContentJt);
|
||||
// int warningDisposalContentJtY = warningDisposalJly + 120;
|
||||
// warningDisposalContentJt.setBounds(warningDisposalJlx, warningDisposalContentJtY, 1310, 120);
|
||||
// if (StringHelper.isEmptyAndNull(warningDisposalContentJt.getText())) {
|
||||
// warningDisposalContentJt.addFocusListener(new MyFocusListener("请输入预警处置内容", warningDisposalContentJt));
|
||||
// }
|
||||
|
||||
warningDisposalContentJt=new JTextArea(7,26);
|
||||
Placeholder placeholder6 = new Placeholder(warningDisposalContentJt, "请输入预警处置内容...");
|
||||
warningDisposalContentJt.setLineWrap(true); //设置文本域中的文本为自动换行
|
||||
warningDisposalContentJt.setForeground(Color.BLACK); //设置组件的背景色
|
||||
warningDisposalContentJt.setFont(new Font("微软雅黑",Font.PLAIN,40)); //修改字体样式
|
||||
warningDisposalContentJt.setBackground(Color.WHITE); //设置按钮背景色
|
||||
JScrollPane warningDisposalContentJtJsp=new JScrollPane(warningDisposalContentJt); //将文本域放入滚动窗口
|
||||
Dimension warningDisposalContentJtSize=warningDisposalContentJt.getPreferredSize(); //获得文本域的首选大小
|
||||
int warningDisposalContentJtY = warningDisposalJly + 120;
|
||||
warningDisposalContentJtJsp.setBounds(eventDetectionJlx,warningDisposalContentJtY,1310,warningDisposalContentJtSize.height+20);
|
||||
jp.add(warningDisposalContentJtJsp);
|
||||
|
||||
/**
|
||||
* 八、一般记事
|
||||
*/
|
||||
JLabel generalChroniclesLabel = new JLabel("八、一般记事");
|
||||
generalChroniclesLabel.setFont(new Font("微软雅黑", Font.BOLD, 50));
|
||||
generalChroniclesLabel.setForeground(new Color(11, 24, 76));
|
||||
int generalChroniclesJlx = 30;
|
||||
int generalChroniclesJly = warningDisposalContentJtY + 450;
|
||||
generalChroniclesLabel.setBounds(generalChroniclesJlx, generalChroniclesJly, 500, 100);
|
||||
/**
|
||||
* 一般记事标题输入框
|
||||
*/
|
||||
generalChroniclesTitleJt = new JTextField();
|
||||
setTextFiledColor(generalChroniclesTitleJt);
|
||||
int generalChroniclesTitleJtX = generalChroniclesJlx + 500;
|
||||
generalChroniclesTitleJt.setBounds(generalChroniclesTitleJtX, generalChroniclesJly + 15, 810, 80);
|
||||
if (StringHelper.isEmptyAndNull(generalChroniclesTitleJt.getText())) {
|
||||
generalChroniclesTitleJt.addFocusListener(new MyFocusListener("请输入一般记事标题", generalChroniclesTitleJt));
|
||||
}
|
||||
|
||||
/**
|
||||
* 一般记事内容输入框
|
||||
*/
|
||||
// generalChroniclesContentJt = new JTextField();
|
||||
// setTextFiledColor(generalChroniclesContentJt);
|
||||
// int generalChroniclesContentJtY = generalChroniclesJly + 120;
|
||||
// generalChroniclesContentJt.setBounds(generalChroniclesJlx, generalChroniclesContentJtY, 1310, 120);
|
||||
// if (StringHelper.isEmptyAndNull(generalChroniclesContentJt.getText())) {
|
||||
// generalChroniclesContentJt.addFocusListener(new MyFocusListener("请输入一般记事内容", generalChroniclesContentJt));
|
||||
// }
|
||||
|
||||
generalChroniclesContentJt=new JTextArea(7,26);
|
||||
Placeholder placeholder7 = new Placeholder(generalChroniclesContentJt, "请输入一般记事内容...");
|
||||
generalChroniclesContentJt.setLineWrap(true); //设置文本域中的文本为自动换行
|
||||
generalChroniclesContentJt.setForeground(Color.BLACK); //设置组件的背景色
|
||||
generalChroniclesContentJt.setFont(new Font("微软雅黑",Font.PLAIN,40)); //修改字体样式
|
||||
generalChroniclesContentJt.setBackground(Color.WHITE); //设置按钮背景色
|
||||
JScrollPane generalChroniclesContentJtJsp=new JScrollPane(generalChroniclesContentJt); //将文本域放入滚动窗口
|
||||
Dimension generalChroniclesContentJtSize=generalChroniclesContentJt.getPreferredSize(); //获得文本域的首选大小
|
||||
int generalChroniclesContentJtY = generalChroniclesJly + 120;
|
||||
generalChroniclesContentJtJsp.setBounds(eventDetectionJlx,generalChroniclesContentJtY,1310,generalChroniclesContentJtSize.height+20);
|
||||
jp.add(generalChroniclesContentJtJsp);
|
||||
|
||||
btn = new JButton();
|
||||
btn.setFont(new Font("微软雅黑", Font.BOLD, 50));
|
||||
btn.setForeground(Color.BLACK);
|
||||
btn.setText("提交");
|
||||
btn.addMouseListener(this);
|
||||
int btnX = (dimension.width - 100) / 4;
|
||||
btn.setBounds(btnX, generalChroniclesContentJtY + 450, 200, 100);
|
||||
|
||||
jp.add(weatherLabel);
|
||||
jp.add(weatherJt);
|
||||
jp.add(lowTemperatureLabel);
|
||||
jp.add(lowTemperatureJt);
|
||||
jp.add(temperatureLabel);
|
||||
jp.add(temperatureJt);
|
||||
jp.add(eventDetectionLabel);
|
||||
jp.add(eventDetectionTitleJt);
|
||||
// jp.add(eventDetectionContentJt);
|
||||
jp.add(powerWorkLabel);
|
||||
jp.add(powerWorkTitleJt);
|
||||
// jp.add(powerWorkContentJt);
|
||||
jp.add(resourceCheckLabel);
|
||||
jp.add(resourceCheckTitleJt);
|
||||
// jp.add(resourceCheckContentJt);
|
||||
jp.add(communicationsTestLabel);
|
||||
jp.add(communicationsTestTitleJt);
|
||||
// jp.add(communicationsTestContentJt);
|
||||
jp.add(dailyOperationLabel);
|
||||
jp.add(dailyOperationTitleJt);
|
||||
// jp.add(dailyOperationContentJt);
|
||||
jp.add(dailySubmissionLabel);
|
||||
jp.add(dailySubmissionTitleJt);
|
||||
// jp.add(dailySubmissionContentJt);
|
||||
jp.add(warningDisposalLabel);
|
||||
jp.add(warningDisposalTitleJt);
|
||||
// jp.add(warningDisposalContentJt);
|
||||
jp.add(generalChroniclesLabel);
|
||||
jp.add(generalChroniclesTitleJt);
|
||||
// jp.add(generalChroniclesContentJt);
|
||||
jp.add(btn);
|
||||
return jp;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置数据框中的字体颜色及大小
|
||||
*
|
||||
* @param jtf
|
||||
*/
|
||||
private void setTextFiledColor(JTextField jtf) {
|
||||
jtf.setFont(new Font("微软雅黑", Font.BOLD, 50));
|
||||
jtf.setForeground(Color.BLACK);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
JButton temp = (JButton) e.getSource();
|
||||
if (temp.equals(btn)) {
|
||||
List<String> list = getAllField();
|
||||
Boolean check = checkEmpty(list);
|
||||
if (check) {
|
||||
LogBean logBean = getLogBean();
|
||||
insertData(logBean);
|
||||
} else {
|
||||
JOptionPane.showMessageDialog(jp, "请检查数据是否填写完毕!", "错误", 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private LogBean getLogBean() {
|
||||
LogBean bean = new LogBean();
|
||||
bean.setWeather(weatherJt.getText());
|
||||
bean.setMin_temperature(lowTemperatureJt.getText());
|
||||
bean.setMax_temperature(temperatureJt.getText());
|
||||
bean.setEvent_detection_title(eventDetectionTitleJt.getText());
|
||||
bean.setEvent_detection_content(eventDetectionContentJt.getText());
|
||||
bean.setPower_work_title(powerWorkTitleJt.getText());
|
||||
bean.setPower_work_content(powerWorkContentJt.getText());
|
||||
bean.setResource_check_title(resourceCheckTitleJt.getText());
|
||||
bean.setResource_check_content(resourceCheckContentJt.getText());
|
||||
bean.setCommunications_test_title(communicationsTestTitleJt.getText());
|
||||
bean.setCommunications_test_content(communicationsTestContentJt.getText());
|
||||
bean.setDaily_operation_title(dailyOperationTitleJt.getText());
|
||||
bean.setDaily_operation_content(dailyOperationContentJt.getText());
|
||||
bean.setDaily_submission_title(dailySubmissionTitleJt.getText());
|
||||
bean.setDaily_submission_content(dailySubmissionContentJt.getText());
|
||||
bean.setWarning_disposal_title(warningDisposalTitleJt.getText());
|
||||
bean.setWarning_disposal_content(warningDisposalContentJt.getText());
|
||||
bean.setGeneral_chronicles_title(generalChroniclesTitleJt.getText());
|
||||
bean.setGeneral_chronicles_content(generalChroniclesContentJt.getText());
|
||||
return bean;
|
||||
}
|
||||
|
||||
private void insertData(LogBean logBean) {
|
||||
String xml = null;
|
||||
XStream xstream = new XStream(new JettisonMappedXmlDriver());
|
||||
xstream.setMode(XStream.NO_REFERENCES);
|
||||
xstream.alias("log", LogBean.class);
|
||||
try {
|
||||
xml = xstream.toXML(logBean);
|
||||
// 将XML字符串写入文件,并指定字符编码为UTF-8
|
||||
FileOutputStream fos = new FileOutputStream(DataConfig.filePath + "\\log.xml");
|
||||
OutputStreamWriter writer = new OutputStreamWriter(fos, "GBK");
|
||||
writer.write(xml);
|
||||
writer.close();
|
||||
System.out.println("文件保存成功");
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
if (new File(DataConfig.filePath + "\\log.xml").exists()) {
|
||||
JOptionPane.showMessageDialog(jp, "日志保存成功!", "提示", 1);
|
||||
System.exit(0);
|
||||
}
|
||||
}
|
||||
|
||||
// 使用 URLEncoder 库对字符串进行 utf-8 编码
|
||||
|
||||
public String encodePathVariable(String pathVariable) {
|
||||
String ret = "default";
|
||||
try {
|
||||
ret = URLEncoder.encode(pathVariable, "utf-8");
|
||||
System.out.println(pathVariable + " : " + ret);
|
||||
} catch (Exception e) {
|
||||
System.out.println(e);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
public List<String> getAllField() {
|
||||
List<String> list = new ArrayList<String>();
|
||||
list.add(weatherJt.getText() + "");
|
||||
list.add(lowTemperatureJt.getText() + "");
|
||||
list.add(temperatureJt.getText() + "");
|
||||
list.add(eventDetectionTitleJt.getText() + "");
|
||||
list.add(eventDetectionContentJt.getText() + "");
|
||||
list.add(powerWorkTitleJt.getText() + "");
|
||||
list.add(powerWorkContentJt.getText() + "");
|
||||
list.add(resourceCheckTitleJt.getText() + "");
|
||||
list.add(resourceCheckContentJt.getText() + "");
|
||||
list.add(communicationsTestTitleJt.getText() + "");
|
||||
list.add(communicationsTestContentJt.getText() + "");
|
||||
list.add(dailyOperationTitleJt.getText() + "");
|
||||
list.add(dailyOperationContentJt.getText() + "");
|
||||
list.add(dailySubmissionTitleJt.getText() + "");
|
||||
list.add(dailySubmissionContentJt.getText() + "");
|
||||
list.add(warningDisposalTitleJt.getText() + "");
|
||||
list.add(warningDisposalContentJt.getText() + "");
|
||||
list.add(generalChroniclesTitleJt.getText() + "");
|
||||
list.add(generalChroniclesContentJt.getText() + "");
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查数据是否填充完全
|
||||
*
|
||||
* @param list
|
||||
* @return
|
||||
*/
|
||||
public Boolean checkEmpty(List<String> list) {
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
if (!StringHelper.isEmptyAndNull(list.get(i))) {
|
||||
continue;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mousePressed(MouseEvent e) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseReleased(MouseEvent e) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseEntered(MouseEvent e) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseExited(MouseEvent e) {
|
||||
}
|
||||
|
||||
public JScrollPane view() {
|
||||
return jScroller;
|
||||
}
|
||||
class Placeholder implements FocusListener {
|
||||
private JTextArea textArea;
|
||||
private String placeholder;
|
||||
|
||||
public Placeholder(JTextArea textArea, String placeholder) {
|
||||
this.textArea = textArea;
|
||||
this.placeholder = placeholder;
|
||||
textArea.setText(placeholder);
|
||||
textArea.setForeground(Color.GRAY);
|
||||
textArea.addFocusListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void focusGained(FocusEvent e) {
|
||||
if (textArea.getText().equals(placeholder)) {
|
||||
textArea.setText("");
|
||||
textArea.setForeground(Color.BLACK);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void focusLost(FocusEvent e) {
|
||||
if (textArea.getText().isEmpty()) {
|
||||
textArea.setText(placeholder);
|
||||
textArea.setForeground(Color.GRAY);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,34 +0,0 @@
|
|||
package com.bonus.autoweb.UI.frame;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.FocusEvent;
|
||||
import java.awt.event.FocusListener;
|
||||
|
||||
public class MyFocusListener implements FocusListener {
|
||||
String info;
|
||||
JTextField jtf;
|
||||
public MyFocusListener(String info, JTextField jtf){
|
||||
this.info=info;
|
||||
this.jtf=jtf;
|
||||
jtf.setForeground(new Color(105,105,105));
|
||||
jtf.setText(info);
|
||||
}
|
||||
@Override
|
||||
public void focusGained(FocusEvent e){//获得焦点的时候,清空提示文字
|
||||
jtf.setFont(new Font("微软雅黑",Font.BOLD,50));
|
||||
jtf.setForeground(Color.BLACK);
|
||||
String temp=jtf.getText();
|
||||
if(temp.equals(info)){
|
||||
jtf.setText("");
|
||||
}
|
||||
}
|
||||
public void focusLost(FocusEvent e){//失去焦点的时候,判断如果为空,就显示提示文字
|
||||
String temp=jtf.getText();
|
||||
if(temp.equals("")){
|
||||
jtf.setFont(new Font("微软雅黑",Font.BOLD,50));
|
||||
jtf.setForeground(new Color(105,105,105));
|
||||
jtf.setText(info);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,30 +0,0 @@
|
|||
package com.bonus.autoweb.UI.frame;
|
||||
|
||||
public class StringHelper {
|
||||
public static boolean isEmpty(String str) {
|
||||
if (str == null || str.trim().equals("") || str.trim().equals("null")) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
/**
|
||||
* 判断字符串 不为空
|
||||
*/
|
||||
public static boolean isNotEmpty(String str) {
|
||||
return !isEmpty(str);
|
||||
}
|
||||
|
||||
public static boolean isEmptyAndNull(String str) {
|
||||
if (str == null || str.trim().equals("") || str.trim().equals("null")) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public static String fillPrefixZero(int v, int len) {
|
||||
String vStr = v + "";
|
||||
while (vStr.length() < len) {
|
||||
vStr = "0" + vStr;
|
||||
}
|
||||
return vStr;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,391 +0,0 @@
|
|||
package com.bonus.autoweb.base;
|
||||
|
||||
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.interactions.Actions;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
|
||||
/**
|
||||
* 自动化操作
|
||||
*
|
||||
* @author 吕继龙
|
||||
*/
|
||||
public class AutoMain {
|
||||
|
||||
Logger log = LoggerFactory.getLogger(AutoMain.class);
|
||||
//浏览器驱动对象
|
||||
private WebDriver webDriver;
|
||||
|
||||
public WebDriver getWebDriver() {
|
||||
return webDriver;
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化驱动
|
||||
*/
|
||||
public void initDrive(int type) {
|
||||
// chromedriver服务地址
|
||||
System.setProperty(DataConfig.DRIVE_NAME, DataConfig.drivePath);
|
||||
ChromeOptions option = new ChromeOptions();
|
||||
//添加浏览器地址
|
||||
// option.setBinary("C:\\Users\\Administrator\\AppData\\Local\\Google\\Chrome\\Application\\chrome.exe");//宿州
|
||||
option.setBinary("C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe");//个人本地-同砀山
|
||||
|
||||
// option.setBinary("C:\\Program Files (x86)\\ChromeCore\\ChromeCore.exe");//砀山
|
||||
// option.addArguments("start-fullscreen");
|
||||
// if (type == 2){
|
||||
option.addArguments("--start-maximized");
|
||||
option.addArguments("--force-device-scale-factor=0.75");
|
||||
// }
|
||||
option.addArguments("disable-infobars");
|
||||
// if (type != 3){
|
||||
// //隐藏页面
|
||||
// option.addArguments("--headless");
|
||||
// }
|
||||
|
||||
webDriver = new ChromeDriver(option);
|
||||
}
|
||||
|
||||
/**
|
||||
* 开始工作
|
||||
*/
|
||||
public void startAuto(String userName, String pass) throws Exception {
|
||||
openWeb();
|
||||
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();
|
||||
}
|
||||
|
||||
/**
|
||||
* 打开网站
|
||||
*/
|
||||
public void openWeb() throws InterruptedException {
|
||||
//第一步打开指定网站
|
||||
webDriver.get(DataConfig.URL);
|
||||
log.info("打开宿州应急指挥中心网站------------");
|
||||
Thread.sleep(2000);
|
||||
}
|
||||
|
||||
/**
|
||||
* 打开网站并登录系统
|
||||
*/
|
||||
private void login(String userName, String pass) throws Exception {
|
||||
//******************************************************************
|
||||
/**
|
||||
* 第二步 用户登录
|
||||
*/
|
||||
log.info("使用账号:" + userName + ",进行登录---------");
|
||||
//输入用户名
|
||||
webDriver.findElement(By.id("username")).sendKeys(userName);
|
||||
log.info("输入用户名------------");
|
||||
Thread.sleep(300);
|
||||
|
||||
//输入密码
|
||||
webDriver.findElement(By.id("password")).sendKeys(pass);
|
||||
log.info("输入密码------------");
|
||||
Thread.sleep(300);
|
||||
|
||||
//系统登录
|
||||
webDriver.findElement(By.id("submi")).click();
|
||||
log.info("系统登录------------");
|
||||
Thread.sleep(800);
|
||||
isAlert();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 判断是否有弹框,隐藏弹框
|
||||
*/
|
||||
private void isAlert() {
|
||||
try {
|
||||
WebElement alert = webDriver.findElement(By.xpath("/html/body/div[5]"));
|
||||
JavascriptExecutor js = (JavascriptExecutor) webDriver;
|
||||
js.executeScript("arguments[0].setAttribute(arguments[1],arguments[2])", alert, "style", "display:none");
|
||||
Thread.sleep(3000);
|
||||
|
||||
WebElement alert1 = webDriver.findElement(By.xpath("/html/body/div[2]"));
|
||||
JavascriptExecutor js1 = (JavascriptExecutor) webDriver;
|
||||
js1.executeScript("arguments[0].setAttribute(arguments[1],arguments[2])", alert1, "style", "display:none");
|
||||
Thread.sleep(3000);
|
||||
}catch (Exception e){
|
||||
log.error("隐藏出错或者没有弹窗");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 打开值班管理页面,并定位到值班管理的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(5000);
|
||||
//执行鼠标悬停动作-管理
|
||||
Actions action = new Actions(webDriver);
|
||||
WebElement wegl = webDriver.findElement(By.xpath("//*[@id=\"app\"]/div/div[1]/div[5]/div/div/div[6]/span/span/div"));
|
||||
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[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[2]/div[2]/div/div[1]";
|
||||
webDriver.findElement(By.xpath(zbglXpath)).click();
|
||||
log.info("打开值班管理页面------------");
|
||||
Thread.sleep(800);
|
||||
|
||||
//定位值班管理iframe的标签
|
||||
WebElement dutyIframe = webDriver.findElement(By.id("zbgln"));
|
||||
webDriver.switchTo().frame(dutyIframe);
|
||||
log.info("定位到值班管理iframe-----------");
|
||||
Thread.sleep(500);
|
||||
|
||||
//将日期改为今天的日期
|
||||
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(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[5]/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[5]/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[5]/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]";
|
||||
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[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);
|
||||
|
||||
//点击抽查按钮
|
||||
webDriver.findElement(By.xpath("/html/body/div/section/div[1]/div[1]/div/div/div/div[3]")).click();
|
||||
|
||||
//定位日常操练iframe的标签
|
||||
WebElement insideIframe = webDriver.findElement(By.xpath("/html/body/div/section/div[1]/div[2]/div[1]/iframe"));
|
||||
webDriver.switchTo().frame(insideIframe);
|
||||
log.info("定位到日常操练内部iframe-----------");
|
||||
Thread.sleep(3000);
|
||||
}
|
||||
|
||||
/**
|
||||
* 关闭浏览器驱动
|
||||
*/
|
||||
public void closeDrive() {
|
||||
log.info("工作完成,退出浏览器");
|
||||
webDriver.quit();
|
||||
}
|
||||
|
||||
public void startAddExercisePlan(String userName, String pass) throws Exception {
|
||||
openWeb();
|
||||
login(userName, pass);
|
||||
startAddExercisePlanAuto();
|
||||
}
|
||||
|
||||
private void startAddExercisePlanAuto() 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[5]/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]";
|
||||
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[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(500);
|
||||
//点击抽查按钮
|
||||
webDriver.findElement(By.xpath("/html/body/div/section/div[1]/div[1]/div/div/div/div[3]")).click();
|
||||
|
||||
// //定位日常操练iframe的标签
|
||||
// WebElement insideIframe = webDriver.findElement(By.xpath("/html/body/div/section/div[1]/div[2]/div[1]/iframe"));
|
||||
// webDriver.switchTo().frame(insideIframe);
|
||||
// log.info("定位到日常操练内部iframe-----------");
|
||||
// Thread.sleep(3000);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,54 +0,0 @@
|
|||
package com.bonus.autoweb.base;
|
||||
|
||||
import java.io.*;
|
||||
|
||||
|
||||
|
||||
public class AutoUtils {
|
||||
|
||||
|
||||
/**
|
||||
* 向text写入数据
|
||||
* @param filename
|
||||
* @param content
|
||||
*/
|
||||
public static int write(String filename, String content) {
|
||||
int code = 0;
|
||||
try {
|
||||
FileOutputStream fos = new FileOutputStream(filename);
|
||||
OutputStreamWriter osw = new OutputStreamWriter(fos, "UTF-8");
|
||||
BufferedWriter writer = new BufferedWriter(osw);
|
||||
writer.write(content);
|
||||
writer.close();
|
||||
System.out.println("Text file generated successfully.");
|
||||
code = 1;
|
||||
} catch (IOException e) {
|
||||
code = 0;
|
||||
System.out.println("An error occurred while generating the text file.");
|
||||
e.printStackTrace();
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
||||
/**
|
||||
* 从text读取数据
|
||||
* @param filename
|
||||
*/
|
||||
public static String read(String filename){
|
||||
StringBuilder content = new StringBuilder();
|
||||
try {
|
||||
BufferedReader reader = new BufferedReader(new FileReader(filename));
|
||||
String line;
|
||||
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.");
|
||||
content.append("error");
|
||||
e.printStackTrace();
|
||||
}
|
||||
return content.toString();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,67 +0,0 @@
|
|||
package com.bonus.autoweb.base;
|
||||
|
||||
public class DataConfig {
|
||||
/**
|
||||
* url 网站地址
|
||||
*/
|
||||
protected static final String URL = "http://20.50.16.10/ecs/#/yjtsgz";
|
||||
/**
|
||||
* 驱动名称
|
||||
*/
|
||||
protected static final String DRIVE_NAME = "webdriver.chrome.driver";
|
||||
// protected static final String DRIVE_NAME = "webdriver.gecko.driver";
|
||||
|
||||
/**
|
||||
* 用户名1 蒋涛
|
||||
*/
|
||||
public static final String USER_NAME1 = "jiangt0419";
|
||||
|
||||
/**
|
||||
* 密码1
|
||||
*/
|
||||
public static final String PASS1 = "ahdl@8875";
|
||||
|
||||
/**
|
||||
* 用户名2 武警
|
||||
*/
|
||||
public static final String USER_NAME2 = "wuj7534";
|
||||
|
||||
/**
|
||||
* 密码2
|
||||
*/
|
||||
public static final String PASS2 = "qwer@7534";
|
||||
|
||||
/**-----------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* 用户名3 陈亚
|
||||
*/
|
||||
public static final String USER_NAME3 = "cheny5579";
|
||||
|
||||
/**
|
||||
* 密码3
|
||||
*/
|
||||
public static final String PASS3 = "Chenya5579!";
|
||||
/**
|
||||
* 用户名4 赵静
|
||||
*/
|
||||
public static final String USER_NAME4 = "zhaoj7029";
|
||||
|
||||
/**
|
||||
* 密码4
|
||||
*/
|
||||
public static final String PASS4 = "gdgs@7890";
|
||||
|
||||
/**
|
||||
* 浏览器驱动地址
|
||||
*/
|
||||
// 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:\\bns\\chromedriver_win32\\chromedriver.exe";//砀山客户地址 -- 应急指挥中心会议室
|
||||
// x64
|
||||
|
||||
|
||||
public static final String filePath = "E:\\bns\\config";
|
||||
|
||||
}
|
||||
|
|
@ -1,178 +0,0 @@
|
|||
package com.bonus.autoweb.base;
|
||||
|
||||
import com.bonus.autoweb.DateTimeUtils;
|
||||
import org.openqa.selenium.By;
|
||||
import org.openqa.selenium.WebDriver;
|
||||
import org.openqa.selenium.WebElement;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
/**
|
||||
* 操作交接班
|
||||
*/
|
||||
public class DutyChangeShifts {
|
||||
private Logger log = LoggerFactory.getLogger(DutyChangeShifts.class);
|
||||
private WebDriver webDriver;
|
||||
|
||||
public DutyChangeShifts(WebDriver webDriver) {
|
||||
this.webDriver = webDriver;
|
||||
}
|
||||
|
||||
/**
|
||||
* 打开交接班页面
|
||||
*/
|
||||
public void openChangeShifts() throws InterruptedException {
|
||||
Thread.sleep(5000);
|
||||
//定位交接班并点击
|
||||
webDriver.findElement(By.id("tab-6")).click();
|
||||
log.info("定位交接班并点击1----------");
|
||||
Thread.sleep(300);
|
||||
}
|
||||
|
||||
/**
|
||||
* 交接班操作
|
||||
*
|
||||
* @param classes 班次,,1早班 2晚班
|
||||
* @param type 交班类型 1 交班 2接班
|
||||
*/
|
||||
public void dutychangeOper(int classes, int type) throws InterruptedException {
|
||||
// JavascriptExecutor jsExecutor = (JavascriptExecutor) webDriver;
|
||||
// boolean pageLoaded = false;
|
||||
//
|
||||
// do {
|
||||
// pageLoaded = (Boolean) jsExecutor.executeScript("return document.readyState").equals("complete");
|
||||
// } while (!pageLoaded);
|
||||
Thread.sleep(5000);
|
||||
//标签位置
|
||||
String xpaht;
|
||||
if (classes == 1) {
|
||||
if (type == 1) {
|
||||
//早班交班
|
||||
xpaht = "//*[@id=\"pane-6\"]/div/div[3]/div[1]/div[1]/div[2]/button[1]";
|
||||
} else {
|
||||
//早班接班
|
||||
xpaht = "//*[@id=\"pane-6\"]/div/div[3]/div[1]/div[1]/div[2]/button[2]";
|
||||
}
|
||||
} else {
|
||||
if (type == 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[2]/div[1]/div[2]/button[2]";
|
||||
}
|
||||
}
|
||||
log.info("交接班地址:"+xpaht+"----------");
|
||||
Thread.sleep(1000*2);
|
||||
webDriver.findElement(By.xpath(xpaht)).click();
|
||||
log.info("定位交接班并点击2----------");
|
||||
Thread.sleep(5000);
|
||||
//交接事项说明
|
||||
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("交接事项说明----------");
|
||||
Thread.sleep(500);
|
||||
//提交
|
||||
webDriver.findElement(By.xpath("/html/body/div[3]/div/div[3]/div/button[2]")).click();
|
||||
|
||||
//取消
|
||||
// webDriver.findElement(By.xpath("/html/body/div[3]/div/div[3]/div/button[1]")).click();
|
||||
|
||||
log.info("交班提交----------");
|
||||
Thread.sleep(300);
|
||||
}else{
|
||||
//提交
|
||||
webDriver.findElement(By.xpath("/html/body/div[3]/div/div[3]/div/button[2]")).click();
|
||||
// 取消
|
||||
// webDriver.findElement(By.xpath("/html/body/div[3]/div/div[3]/div/button[1]")).click();
|
||||
log.info("接班提交----------");
|
||||
Thread.sleep(300);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 选择上个晚班交班
|
||||
*/
|
||||
public void changeDay() throws Exception {
|
||||
|
||||
Thread.sleep(1000*3);
|
||||
//判断当前日期是不是每月第一天的日期,true
|
||||
log.info("选择前一天----------");
|
||||
int tr = 1;
|
||||
int td = 1;
|
||||
String xpath;
|
||||
if (!DateTimeUtils.isOneDay()) {
|
||||
//不是本月第一天
|
||||
String currentDay = DateTimeUtils.getCurrentDay();
|
||||
log.info("currentDay:"+currentDay);
|
||||
int weekNum = DateTimeUtils.getWeekNum(currentDay);
|
||||
log.info("weekNum:"+weekNum);
|
||||
int dayNum = DateTimeUtils.getWeekOfDate(currentDay);
|
||||
log.info("dayNum:"+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;
|
||||
}
|
||||
xpath = "//*[@id=\"app\"]/div/section/main/div/div[1]/div[1]/div[3]/div[2]/table/tbody/tr[" + tr + "]" + "/td[" + td + "]";
|
||||
} 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(300);
|
||||
|
||||
//获取上月最后一天日期
|
||||
String mothDay = DateTimeUtils.getBeforeLastMonthdate();
|
||||
//判断上个月最后一天的位置
|
||||
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())) {
|
||||
// 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);
|
||||
//选择前一天的日期
|
||||
webDriver.findElement(By.xpath(xpath)).click();
|
||||
log.info("选择前一天的日期----------");
|
||||
Thread.sleep(300);
|
||||
openChangeShifts();
|
||||
|
||||
|
||||
//进行晚班交班操作
|
||||
log.info("进行晚班交班操作----------");
|
||||
dutychangeOper(2, 1);
|
||||
|
||||
Thread.sleep(1000);
|
||||
|
||||
//将日期选择回当日
|
||||
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(300);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,158 +0,0 @@
|
|||
package com.bonus.autoweb.base;
|
||||
|
||||
import com.bonus.autoweb.DateTimeUtils;
|
||||
import org.openqa.selenium.By;
|
||||
import org.openqa.selenium.WebDriver;
|
||||
import org.openqa.selenium.WebElement;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
|
||||
/**
|
||||
* 值班打卡
|
||||
*/
|
||||
public class DutyClock {
|
||||
private Logger log = LoggerFactory.getLogger(DutyClock.class);
|
||||
|
||||
private WebDriver webDriver;
|
||||
|
||||
public DutyClock(WebDriver webDriver) {
|
||||
this.webDriver = webDriver;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void openDutyClock() throws InterruptedException {
|
||||
Thread.sleep(1000*4);
|
||||
//定位值班打卡并点击
|
||||
webDriver.findElement(By.id("tab-2")).click();
|
||||
log.info("定位值班打卡并点击----------");
|
||||
Thread.sleep(300);
|
||||
}
|
||||
|
||||
/**
|
||||
* 值班打卡操作
|
||||
*
|
||||
* @param classes 班次,,1早班 2晚班
|
||||
* @param type 打卡类型 1 签到 2签退
|
||||
*/
|
||||
public void dutyClockOper(int classes, int type) throws InterruptedException {
|
||||
openDutyClock();
|
||||
// JavascriptExecutor jsExecutor = (JavascriptExecutor) webDriver;
|
||||
// boolean pageLoaded = false;
|
||||
//
|
||||
// do {
|
||||
// pageLoaded = (Boolean) jsExecutor.executeScript("return document.readyState").equals("complete");
|
||||
// } while (!pageLoaded);
|
||||
Thread.sleep(5000);
|
||||
//标签位置
|
||||
String xpaht;
|
||||
if (classes == 1) {
|
||||
if (type == 1) {
|
||||
//早班签到
|
||||
xpaht = "//*[@id=\"pane-2\"]/div/div[3]/div[1]/div[1]/div[2]/button[1]";
|
||||
} else {
|
||||
//早班签退
|
||||
xpaht = "//*[@id=\"pane-2\"]/div/div[3]/div[1]/div[1]/div[2]/button[2]";
|
||||
}
|
||||
} else {
|
||||
if (type == 1) {
|
||||
//晚班签到
|
||||
xpaht = "//*[@id=\"pane-2\"]/div/div[3]/div[2]/div[1]/div[2]/button[1]";
|
||||
} else {
|
||||
//晚班签退
|
||||
xpaht = "//*[@id=\"pane-2\"]/div/div[3]/div[2]/div[1]/div[2]/button[2]";
|
||||
}
|
||||
}
|
||||
Thread.sleep(1000*4);
|
||||
webDriver.findElement(By.xpath(xpaht)).click();
|
||||
log.info("打卡签到----------");
|
||||
Thread.sleep(1000*5);
|
||||
|
||||
|
||||
//点击弹出框确认
|
||||
webDriver.findElement(By.xpath("/html/body/div[2]/div/div[2]/div/div[2]/div[1]")).click();
|
||||
log.info("点击弹出框确认----------");
|
||||
Thread.sleep(800);
|
||||
}
|
||||
|
||||
/**
|
||||
* 选择上个晚班签退
|
||||
*/
|
||||
public void changeDay() throws Exception {
|
||||
Thread.sleep(3000);
|
||||
//判断当前日期是不是每月第一天的日期,true
|
||||
boolean tf = false;
|
||||
int tr = 1;
|
||||
int td = 1;
|
||||
String xpath;
|
||||
if (!DateTimeUtils.isOneDay()) {
|
||||
//不是本月第一天
|
||||
String currentDay = DateTimeUtils.getCurrentDay();
|
||||
int weekNum = DateTimeUtils.getWeekNum(currentDay);
|
||||
int dayNum = DateTimeUtils.getWeekOfDate(currentDay);
|
||||
/*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;
|
||||
}
|
||||
xpath = "//*[@id=\"app\"]/div/section/main/div/div[1]/div[1]/div[3]/div[2]/table/tbody/tr[" + tr + "]" + "/td[" + td + "]";
|
||||
} 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(300);
|
||||
|
||||
//获取上月最后一天日期
|
||||
String mothDay=DateTimeUtils.getBeforeLastMonthdate();
|
||||
//判断上个月最后一天的位置
|
||||
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())) {
|
||||
// xpath = "//*[@id=\"app\"]/div/section/main/div/div[1]/div[1]/div[3]/div[2]/table/tbody/tr[" + (tr + 1) + "]" + "/td[" + td + "]/div";
|
||||
// }
|
||||
}
|
||||
//选择前一天的日期
|
||||
webDriver.findElement(By.xpath(xpath)).click();
|
||||
log.info("选择前一天的日期----------");
|
||||
Thread.sleep(300);
|
||||
openDutyClock();
|
||||
Thread.sleep(3000);
|
||||
//进行晚班签退操作
|
||||
log.info("进行晚班签退操作----------");
|
||||
dutyClockOper(2,2);
|
||||
|
||||
Thread.sleep(300);
|
||||
|
||||
//将日期选择回当日
|
||||
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(300);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,98 +0,0 @@
|
|||
package com.bonus.autoweb.base;
|
||||
|
||||
import org.openqa.selenium.By;
|
||||
import org.openqa.selenium.JavascriptExecutor;
|
||||
import org.openqa.selenium.WebDriver;
|
||||
import org.openqa.selenium.WebElement;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
/**
|
||||
* 日报审核工作
|
||||
*/
|
||||
public class DutyDailyCheck {
|
||||
private Logger log = LoggerFactory.getLogger(DutyDailyCheck.class);
|
||||
private WebDriver webDriver;
|
||||
|
||||
public DutyDailyCheck(WebDriver webDriver) {
|
||||
this.webDriver = webDriver;
|
||||
}
|
||||
|
||||
/**
|
||||
* 日报审核操作
|
||||
* @param type 1早报 2晚报
|
||||
*/
|
||||
public void dutyCheckOp(int type) throws Exception {
|
||||
// JavascriptExecutor jsExecutor = (JavascriptExecutor) webDriver;
|
||||
// boolean pageLoaded = false;
|
||||
//
|
||||
// do {
|
||||
// pageLoaded = (Boolean) jsExecutor.executeScript("return document.readyState").equals("complete");
|
||||
// } while (!pageLoaded);
|
||||
Thread.sleep(5000);
|
||||
//定位值班日报并点击
|
||||
webDriver.findElement(By.id("tab-4")).click();
|
||||
log.info("定位值班日报并点击-----------");
|
||||
Thread.sleep(300);
|
||||
String checkXpath;
|
||||
//早报
|
||||
if(type ==1){
|
||||
checkXpath="//*[@id=\"pane-4\"]/div/div[3]/div/div/div[3]/table/tbody/tr[1]/td[5]/div/p[2]";
|
||||
}else{
|
||||
checkXpath="//*[@id=\"pane-4\"]/div/div[3]/div/div/div[3]/table/tbody/tr[2]/td[5]/div/p[2]";
|
||||
}
|
||||
|
||||
//点击审核按钮
|
||||
log.info("日报审核类型:"+type+",地址:"+checkXpath+"--------");
|
||||
WebElement checkBtn=webDriver.findElement(By.xpath(checkXpath));
|
||||
|
||||
// JavascriptExecutor js =(JavascriptExecutor)webDriver;
|
||||
// js.executeScript("arguments[0].setAttribute(arguments[1],arguments[2])",checkBtn,"style","color:rgb(0,145,255)");
|
||||
log.info("审核按钮:",checkBtn.getText());
|
||||
Thread.sleep(1000*3);
|
||||
|
||||
checkBtn.click();
|
||||
log.info("点击日报审核按钮--------");
|
||||
Thread.sleep(1000);
|
||||
|
||||
//退出当前iframe,
|
||||
webDriver.switchTo().defaultContent();
|
||||
log.info("退出当前iframe----------");
|
||||
Thread.sleep(300);
|
||||
|
||||
//定位应急工作日报审核iframe的标签
|
||||
WebElement addIframe = webDriver.findElement(By.id("add-local-scrbsh"));
|
||||
webDriver.switchTo().frame(addIframe);
|
||||
log.info("定位应急工作日报审核iframe-----------");
|
||||
Thread.sleep(500);
|
||||
|
||||
//同意审核按钮点击
|
||||
|
||||
WebElement tyCheckBtn=webDriver.findElement(By.xpath("//*[@id=\"app\"]/div/section/div/div[4]/div[1]/div[19]/button[4]"));
|
||||
if(tyCheckBtn.isDisplayed()){
|
||||
//存在
|
||||
log.info("同意审核按钮存在-----------");
|
||||
log.info("同意审核按钮钮:"+tyCheckBtn.getAttribute("class"));
|
||||
log.info("同意审核按钮:"+tyCheckBtn.getAttribute("type"));
|
||||
log.info("同意审核按钮:"+tyCheckBtn.getText());
|
||||
tyCheckBtn.click();
|
||||
// webDriver.findElement(By.xpath("//*[@id=\"app\"]/div/section/div/div[4]/div[1]/div[19]/button[1]")).click();
|
||||
|
||||
}else{
|
||||
log.info("同意审核按钮不存在-----------");
|
||||
}
|
||||
Thread.sleep(800);
|
||||
|
||||
//退出当前iframe,
|
||||
webDriver.switchTo().defaultContent();
|
||||
log.info("退出当前iframe----------");
|
||||
Thread.sleep(1000*2);
|
||||
|
||||
|
||||
//定位值班管理iframe的标签
|
||||
WebElement dutyIframe= webDriver.findElement(By.id("zbgln"));
|
||||
webDriver.switchTo().frame(dutyIframe);
|
||||
log.info("定位值班管理iframe的标签----------");
|
||||
Thread.sleep(300);
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
|
|
@ -1,391 +0,0 @@
|
|||
package com.bonus.autoweb.base;
|
||||
|
||||
import com.bonus.autoweb.DateTimeUtils;
|
||||
import com.bonus.autoweb.UI.entity.LogBean;
|
||||
import com.thoughtworks.xstream.XStream;
|
||||
import com.thoughtworks.xstream.io.json.JettisonMappedXmlDriver;
|
||||
import org.openqa.selenium.By;
|
||||
import org.openqa.selenium.WebDriver;
|
||||
import org.openqa.selenium.WebElement;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.nio.charset.Charset;
|
||||
import java.text.ParseException;
|
||||
|
||||
/**
|
||||
* 操作值班日志类
|
||||
*/
|
||||
public class DutyLogIOp {
|
||||
private Logger log = LoggerFactory.getLogger(DutyLogIOp.class);
|
||||
private WebDriver webDriver;
|
||||
|
||||
public DutyLogIOp(WebDriver webDriver) {
|
||||
this.webDriver = webDriver;
|
||||
}
|
||||
|
||||
/**
|
||||
* 打开日志新增页面
|
||||
*
|
||||
* @param type 1 早 2晚
|
||||
*/
|
||||
public void openDutyLog(int type) throws Exception {
|
||||
if (type == 1) {
|
||||
//早上填写前一天的日志,将标签改为前一天
|
||||
changeDay();
|
||||
}
|
||||
Thread.sleep(5000);
|
||||
//定位值班日志并点击
|
||||
webDriver.findElement(By.id("tab-5")).click();
|
||||
log.info("定位值班日志并点击----------");
|
||||
Thread.sleep(5000);
|
||||
|
||||
// /html/body/div[2] 弹窗 您没有填写值班日志的排班班次
|
||||
|
||||
//定位写日志标签,打开日志页面
|
||||
webDriver.findElement(By.xpath("//*[@id=\"pane-5\"]/div/div[2]/div[2]/button")).click();
|
||||
log.info("定位写日志标签,打开日志页面----------");
|
||||
Thread.sleep(1500);
|
||||
|
||||
|
||||
//退出当前iframe,进入到日报编辑iframe
|
||||
webDriver.switchTo().defaultContent();
|
||||
log.info("退出当前iframe----------");
|
||||
Thread.sleep(3000);
|
||||
|
||||
//定位日志编辑iframe的标签
|
||||
WebElement dutyEditIframe = webDriver.findElement(By.id("add-local-zbrzbz"));
|
||||
webDriver.switchTo().frame(dutyEditIframe);
|
||||
log.info("定位日志编辑iframe的标签----------");
|
||||
Thread.sleep(3000);
|
||||
dutyLogContent();
|
||||
|
||||
if (type == 1) {
|
||||
Thread.sleep(2000);
|
||||
//昨天的日志填写完毕之后将日期改为今天
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
public void changeDay() throws Exception {
|
||||
|
||||
Thread.sleep(1000);
|
||||
//判断当前日期是不是每月第一天的日期,true
|
||||
boolean tf = false;
|
||||
int tr = 1;
|
||||
int td = 1;
|
||||
String xpath;
|
||||
if (!DateTimeUtils.isOneDay()) {
|
||||
//不是本月第一天
|
||||
String currentDay = DateTimeUtils.getCurrentDay();
|
||||
log.info("currentDay:" + currentDay);
|
||||
int weekNum = DateTimeUtils.getWeekNum(currentDay);
|
||||
log.info("weekNum:" + weekNum);
|
||||
int dayNum = DateTimeUtils.getWeekOfDate(currentDay);
|
||||
log.info("dayNum:" + 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;
|
||||
}
|
||||
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);
|
||||
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);
|
||||
|
||||
webDriver.findElement(By.xpath(xpath)).click();
|
||||
log.info("选择前一天的日期----------");
|
||||
Thread.sleep(500);
|
||||
}
|
||||
|
||||
/**
|
||||
* 内容填写
|
||||
*/
|
||||
private void dutyLogContent() throws InterruptedException {
|
||||
//值班时间
|
||||
// /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);
|
||||
webDriver.findElement(By.xpath("/html/body/div[4]/div[1]/div[1]/ul/li")).click();
|
||||
log.info("值班时间----------");
|
||||
Thread.sleep(500);
|
||||
|
||||
// 反序列化--> 解决乱码问题
|
||||
File file = new File(DataConfig.filePath + "\\log.xml");
|
||||
InputStreamReader in = null;
|
||||
String xml = null;
|
||||
try {
|
||||
//主要就是这里的设置
|
||||
in = new InputStreamReader(new FileInputStream(file), Charset.forName("gbk"));
|
||||
StringBuffer sb = new StringBuffer();
|
||||
char[] array = new char[1024];
|
||||
int length = -1;
|
||||
while ((length = in.read(array)) != -1) {
|
||||
sb.append(array, 0, length);
|
||||
}
|
||||
in.close();
|
||||
xml = sb.toString().trim();
|
||||
System.out.println(xml);
|
||||
} catch (Exception e) {
|
||||
// TODO: handle exception
|
||||
}
|
||||
|
||||
XStream xstream = new XStream(new JettisonMappedXmlDriver());
|
||||
xstream.alias("log", LogBean.class);
|
||||
LogBean bean = (LogBean) xstream.fromXML(xml);
|
||||
|
||||
|
||||
//输入天气
|
||||
String tq = bean.getWeather();
|
||||
// /html/body/div[3]/div/div[2]/div/form/div[3]/div/div/div[3]/div/div/div[1]/input
|
||||
webDriver.findElement(By.xpath("/html/body/div[3]/div/div[2]/div/form/div[3]/div/div/div[5]/div/div/div/input")).sendKeys(tq);
|
||||
log.info("输入天气----------");
|
||||
Thread.sleep(500);
|
||||
|
||||
//输入最低气温
|
||||
String zdqw = bean.getMin_temperature();
|
||||
// /html/body/div[3]/div/div[2]/div/form/div[3]/div/div/div[4]/div/div/div[1]/input
|
||||
webDriver.findElement(By.xpath("/html/body/div[3]/div/div[2]/div/form/div[3]/div/div/div[7]/div/div/div/input")).sendKeys(zdqw);
|
||||
log.info("输入最高气温----------");
|
||||
Thread.sleep(500);
|
||||
|
||||
//输入最高气温
|
||||
String zgqw = bean.getMax_temperature();
|
||||
// /html/body/div[3]/div/div[2]/div/form/div[3]/div/div/div[4]/div/div/div[1]/input
|
||||
webDriver.findElement(By.xpath("/html/body/div[3]/div/div[2]/div/form/div[3]/div/div/div[9]/div/div/div/input")).sendKeys(zgqw);
|
||||
log.info("输入最高气温----------");
|
||||
Thread.sleep(500);
|
||||
|
||||
//事件监测 标题
|
||||
String sjjc_title = bean.getEvent_detection_title();
|
||||
// /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);
|
||||
//事件监测 内容
|
||||
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(1000);
|
||||
|
||||
//保电工作 标题
|
||||
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);
|
||||
|
||||
//保电工作 内容
|
||||
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);
|
||||
log.info("保电工作 内容----------");
|
||||
Thread.sleep(2000);
|
||||
|
||||
//资源核查 标题
|
||||
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);
|
||||
//资源核查 内容
|
||||
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);
|
||||
|
||||
//通信测试 标题
|
||||
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);
|
||||
//通信测试 内容
|
||||
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);
|
||||
|
||||
|
||||
//日常操练情况 标题
|
||||
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);
|
||||
//日常操练情况 内容
|
||||
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);
|
||||
|
||||
//日报填写情况 标题
|
||||
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);
|
||||
//日常操练情况 内容
|
||||
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);
|
||||
|
||||
//预警处置 标题
|
||||
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);
|
||||
//预警处置 内容
|
||||
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);
|
||||
|
||||
//一般记事 标题
|
||||
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);
|
||||
//一般记事 内容
|
||||
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);
|
||||
|
||||
|
||||
//提交日志
|
||||
|
||||
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(2000);
|
||||
|
||||
|
||||
//点击弹出框确认 /html/body/div[4]/div/div[3]/button[2]
|
||||
WebElement qrBtn = webDriver.findElement(By.xpath("/html/body/div[4]/div/div[3]/button[2]"));
|
||||
Thread.sleep(2000);
|
||||
log.info("确认日志按钮:" + qrBtn.getText());
|
||||
qrBtn.click();
|
||||
|
||||
Thread.sleep(1000 * 3);
|
||||
//取消
|
||||
// webDriver.findElement(By.xpath("/html/body/div[4]/div/div[3]/button[1]")).click();
|
||||
|
||||
log.info("点击弹出框确认----------");
|
||||
Thread.sleep(500);
|
||||
|
||||
//测试 点击取消按钮
|
||||
/*webDriver.findElement(By.xpath("/html/body/div[3]/div/div[3]/div/button[1]")).click();
|
||||
log.info("点击取消----------");
|
||||
Thread.sleep(500);*/
|
||||
|
||||
|
||||
//退出当前iframe,
|
||||
webDriver.switchTo().defaultContent();
|
||||
log.info("退出当前iframe----------");
|
||||
Thread.sleep(500);
|
||||
|
||||
|
||||
//定位值班管理iframe的标签
|
||||
WebElement dutyIframe = webDriver.findElement(By.id("zbgln"));
|
||||
webDriver.switchTo().frame(dutyIframe);
|
||||
log.info("定位值班管理iframe的标签----------");
|
||||
Thread.sleep(500);
|
||||
|
||||
}
|
||||
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
|
@ -1,373 +0,0 @@
|
|||
package com.bonus.autoweb.task;
|
||||
|
||||
import com.bonus.autoweb.GetBasicData;
|
||||
import com.bonus.autoweb.base.*;
|
||||
import org.openqa.selenium.WebDriver;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* 应急指挥中心打卡任务类
|
||||
*/
|
||||
public class AutoWebTask {
|
||||
|
||||
Logger log = LoggerFactory.getLogger(AutoWebTask.class);
|
||||
|
||||
/**
|
||||
* 打卡任务
|
||||
*
|
||||
* @param classes 班次,,1早班 2晚班
|
||||
*/
|
||||
public void dutyClockTask(int classes) {
|
||||
log.info("开始打卡任务---------------------");
|
||||
log.info("房万春开始打卡任务---------------------");
|
||||
//使用房万春账号签到
|
||||
dutySigin(classes, 1, DataConfig.USER_NAME2, DataConfig.PASS2);
|
||||
try {
|
||||
Thread.sleep(1000 * 2);
|
||||
} catch (Exception e) {
|
||||
log.error("打卡任务", e);
|
||||
}
|
||||
//使用韩宏宇账号签到
|
||||
log.info("韩宏宇开始打卡任务---------------------");
|
||||
dutySigin(classes, 1, DataConfig.USER_NAME1, DataConfig.PASS1);
|
||||
}
|
||||
|
||||
/**
|
||||
* 签到任务
|
||||
*
|
||||
* @param classes
|
||||
* @param type
|
||||
* @param userName
|
||||
* @param pass
|
||||
* @throws Exception
|
||||
*/
|
||||
public int dutySigin(int classes, int type, String userName, String pass) {
|
||||
//打开浏览器,进入应急指挥中心网站
|
||||
AutoMain autoMain = new AutoMain();
|
||||
int count = 0;
|
||||
try {
|
||||
autoMain.initDrive(2);
|
||||
WebDriver webDriver = autoMain.getWebDriver();
|
||||
autoMain.startAuto(userName, pass);
|
||||
DutyClock dutyClock = new DutyClock(webDriver);
|
||||
dutyClock.openDutyClock();
|
||||
dutyClock.dutyClockOper(classes, type);
|
||||
//关闭浏览器
|
||||
autoMain.closeDrive();
|
||||
count = 1;
|
||||
} catch (Exception e) {
|
||||
log.error("签到任务", e);
|
||||
} finally {
|
||||
autoMain.closeDrive();
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 填报日志和日报任务
|
||||
*
|
||||
* @param type 1 早报 2晚报
|
||||
*/
|
||||
public int dutyAddDailyLogsTask(int type,String username,String password) {
|
||||
log.info("开始日报填写任务---------------------");
|
||||
//打开浏览器,进入应急指挥中心网站
|
||||
AutoMain autoMain = new AutoMain();
|
||||
WebDriver webDriver;
|
||||
int count = 0;
|
||||
try {
|
||||
autoMain.initDrive(1);
|
||||
autoMain.startAuto(username, password);
|
||||
webDriver = autoMain.getWebDriver();
|
||||
//操作日报
|
||||
DutyDailyOp ddo = new DutyDailyOp(webDriver);
|
||||
ddo.openDutyDaily(type);
|
||||
Thread.sleep(1000);
|
||||
count = 1;
|
||||
} catch (Exception e) {
|
||||
log.error("日报填写任务", e);
|
||||
}
|
||||
try {
|
||||
//日报审核工作
|
||||
webDriver = autoMain.getWebDriver();
|
||||
DutyDailyCheck dutyDailyCheck = new DutyDailyCheck(webDriver);
|
||||
dutyDailyCheck.dutyCheckOp(type);
|
||||
Thread.sleep(1000);
|
||||
count = 1;
|
||||
} catch (Exception e) {
|
||||
count = 0;
|
||||
log.error("日报审核工作", e);
|
||||
} finally {
|
||||
autoMain.closeDrive();
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
public int dutyAddLogsTask(int type,String username,String password) {
|
||||
log.info("开始日志填写任务---------------------");
|
||||
//打开浏览器,进入应急指挥中心网站
|
||||
int count = 0;
|
||||
AutoMain autoMain = new AutoMain();
|
||||
WebDriver webDriver;
|
||||
try {
|
||||
autoMain.initDrive(3);
|
||||
autoMain.startAuto(username, password);
|
||||
//操作日志
|
||||
webDriver = autoMain.getWebDriver();
|
||||
DutyLogIOp dlo = new DutyLogIOp(webDriver);
|
||||
dlo.openDutyLog(type);
|
||||
count = 1;
|
||||
} catch (Exception e) {
|
||||
count = 0;
|
||||
log.error("操作日志任务", e);
|
||||
}finally {
|
||||
autoMain.closeDrive();
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 交接班任务
|
||||
*
|
||||
* @param classes 班次,,1早班 2晚班
|
||||
*/
|
||||
public int dutyChangeTask1(int classes,String userName,String password) {
|
||||
log.info("开始交班任务---------------------");
|
||||
AutoMain autoMain = new AutoMain();
|
||||
int count = 0;
|
||||
WebDriver webDriver;
|
||||
try {
|
||||
//打开浏览器,进入应急指挥中心网站
|
||||
autoMain.initDrive(2);
|
||||
autoMain.startAuto(userName, password);
|
||||
webDriver = autoMain.getWebDriver();
|
||||
|
||||
DutyChangeShifts dutyChangeShifts = new DutyChangeShifts(webDriver);
|
||||
//进行交班工作
|
||||
if (classes == 2) {
|
||||
dutyChangeShifts.openChangeShifts();
|
||||
dutyChangeShifts.dutychangeOper(1, 1);
|
||||
} else {
|
||||
dutyChangeShifts.changeDay();
|
||||
}
|
||||
Thread.sleep(1000);
|
||||
|
||||
//关闭浏览器
|
||||
autoMain.closeDrive();
|
||||
count = 1;
|
||||
} catch (Exception e) {
|
||||
count = 0;
|
||||
log.error("交接班任务:" + e);
|
||||
} finally {
|
||||
autoMain.closeDrive();
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
public int dutyChangeTask2(int classes,String userName,String password) {
|
||||
log.info("开始接班任务---------------------");
|
||||
AutoMain autoMain = new AutoMain();
|
||||
WebDriver webDriver;
|
||||
int count = 0;
|
||||
try {
|
||||
//打开浏览器,进入应急指挥中心网站
|
||||
autoMain.initDrive(2);
|
||||
autoMain.startAuto(userName, password);
|
||||
webDriver = autoMain.getWebDriver();
|
||||
|
||||
DutyChangeShifts dutyChangeShifts = new DutyChangeShifts(webDriver);
|
||||
//进行接班工作
|
||||
dutyChangeShifts.openChangeShifts();
|
||||
dutyChangeShifts.dutychangeOper(classes, 2);
|
||||
|
||||
//关闭浏览器
|
||||
autoMain.closeDrive();
|
||||
count = 1;
|
||||
} catch (Exception e) {
|
||||
count = 0;
|
||||
log.error("交接班任务:" + e);
|
||||
} finally {
|
||||
autoMain.closeDrive();
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
/**
|
||||
* 签退任务
|
||||
*
|
||||
* @param classes 班次,,1早班 2晚班
|
||||
*/
|
||||
public int dutySignOutTask(int classes, String userName, String pass) {
|
||||
log.info("开始签退任务---------------------");
|
||||
AutoMain autoMain = new AutoMain();
|
||||
int count = 0;
|
||||
try {
|
||||
//打开浏览器,进入应急指挥中心网站
|
||||
autoMain.initDrive(2);
|
||||
autoMain.startAuto(userName, pass);
|
||||
WebDriver webDriver = autoMain.getWebDriver();
|
||||
|
||||
DutyClock dutyClock = new DutyClock(webDriver);
|
||||
if (classes == 1) {
|
||||
dutyClock.changeDay();
|
||||
} else {
|
||||
dutyClock.dutyClockOper(1, 2);
|
||||
}
|
||||
//关闭浏览器
|
||||
autoMain.closeDrive();
|
||||
count = 1;
|
||||
} catch (Exception e) {
|
||||
count = 0;
|
||||
log.error("签退任务", e);
|
||||
} finally {
|
||||
autoMain.closeDrive();
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
/**
|
||||
* 定时获取基础数据
|
||||
*/
|
||||
public int getYuJingData(int classes) {
|
||||
AutoMain autoMain = new AutoMain();
|
||||
WebDriver webDriver;
|
||||
int count = 0;
|
||||
try {
|
||||
autoMain.initDrive(2);
|
||||
log.info("初始化驱动成功");
|
||||
autoMain.startYuJingAuto(DataConfig.USER_NAME1, DataConfig.PASS1);
|
||||
log.info("startYuJingAuto成功");
|
||||
//获取基础数据
|
||||
webDriver = autoMain.getWebDriver();
|
||||
GetBasicData gbd = new GetBasicData(webDriver);
|
||||
log.info("获取天气预警值启动----");
|
||||
gbd.getYuJingBasicData(classes);
|
||||
count = 1;
|
||||
} catch (Exception e) {
|
||||
count = 0;
|
||||
log.error("获取基础数据任务", e);
|
||||
}finally {
|
||||
autoMain.closeDrive();
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
/**
|
||||
* 预警行动
|
||||
* @param classes
|
||||
* @return
|
||||
*/
|
||||
public int getYuJingActionData(int classes) {
|
||||
AutoMain autoMain = new AutoMain();
|
||||
WebDriver webDriver;
|
||||
int count = 0;
|
||||
try {
|
||||
autoMain.initDrive(2);
|
||||
log.info("初始化驱动成功");
|
||||
autoMain.startYuJingActionAuto(DataConfig.USER_NAME1, DataConfig.PASS1);
|
||||
log.info("startYuJingAuto成功");
|
||||
//获取基础数据
|
||||
webDriver = autoMain.getWebDriver();
|
||||
GetBasicData gbd = new GetBasicData(webDriver);
|
||||
log.info("获取天气预警值启动----");
|
||||
gbd.getYuJingActionBasicData(classes);
|
||||
count = 1;
|
||||
} catch (Exception e) {
|
||||
count = 0;
|
||||
log.error("获取基础数据任务", e);
|
||||
}finally {
|
||||
autoMain.closeDrive();
|
||||
}
|
||||
return count;
|
||||
}
|
||||
public int getCaoLianData(int classes) {
|
||||
AutoMain autoMain = new AutoMain();
|
||||
WebDriver webDriver;
|
||||
int count = 0;
|
||||
try {
|
||||
autoMain.initDrive(2);
|
||||
autoMain.startCaoLianAuto(DataConfig.USER_NAME1, DataConfig.PASS1);
|
||||
//获取基础数据
|
||||
webDriver = autoMain.getWebDriver();
|
||||
GetBasicData gbd = new GetBasicData(webDriver);
|
||||
gbd.getCaoLianBasicData(classes);
|
||||
count = 1;
|
||||
} catch (Exception e) {
|
||||
count = 0;
|
||||
log.error("获取基础操练数据任务", e);
|
||||
}finally {
|
||||
autoMain.closeDrive();
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
|
||||
public static void main(String[] args) {
|
||||
// String content = read("C:\\Users\\24526\\Desktop\\宿州部分代码实例\\七个公司资源核查情况.txt");
|
||||
// String[] array = content.toString().split("资源核查情况:");
|
||||
//
|
||||
// ArrayList<String> list = new ArrayList<String>();
|
||||
// list.add("1");
|
||||
// list.add("2");
|
||||
// list.add("3");
|
||||
// list.add("4");
|
||||
// list.add("5");
|
||||
// list.add("6");
|
||||
// list.add("7");
|
||||
// // 打乱顺序
|
||||
// Collections.shuffle(list);
|
||||
//// // 遍历取出元素
|
||||
//// for (String day : list) {
|
||||
//// System.out.println(day);
|
||||
//// }
|
||||
// System.out.println(list.get(0));
|
||||
// System.out.println(array[Integer.parseInt(list.get(0))].toString());
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public static String read(String filename){
|
||||
String line;
|
||||
StringBuilder content = new StringBuilder();
|
||||
try {
|
||||
BufferedReader reader = new BufferedReader(new FileReader(filename));
|
||||
while ((line = reader.readLine()) != null) {
|
||||
content.append(line).append("\n");
|
||||
}
|
||||
reader.close();
|
||||
} catch (IOException e) {
|
||||
System.out.println("An error occurred while reading the text file.");
|
||||
e.printStackTrace();
|
||||
}
|
||||
return content.toString();
|
||||
}
|
||||
|
||||
public int addExercisePlan(String type, String company,int code, String userName, String pass) {
|
||||
AutoMain autoMain = new AutoMain();
|
||||
WebDriver webDriver;
|
||||
int count = 0;
|
||||
try {
|
||||
autoMain.initDrive(3);
|
||||
autoMain.startAddExercisePlan(userName, pass);
|
||||
//获取基础数据
|
||||
webDriver = autoMain.getWebDriver();
|
||||
GetBasicData gbd = new GetBasicData(webDriver);
|
||||
gbd.addExercisePlan(type,company,code);
|
||||
count = 1;
|
||||
} catch (Exception e) {
|
||||
count = 0;
|
||||
log.error("获取基础操练数据任务", e);
|
||||
}finally {
|
||||
autoMain.closeDrive();
|
||||
}
|
||||
return count;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,3 +0,0 @@
|
|||
Manifest-Version: 1.0
|
||||
Main-Class: com.bonus.autoweb.TestMain
|
||||
|
||||
Binary file not shown.
|
|
@ -1,24 +0,0 @@
|
|||
### 设置###
|
||||
log4j.rootLogger = debug,stdout,D,E
|
||||
|
||||
### 输出信息到控制抬 ###
|
||||
log4j.appender.stdout = org.apache.log4j.ConsoleAppender
|
||||
log4j.appender.stdout.Target = System.out
|
||||
log4j.appender.stdout.layout = org.apache.log4j.PatternLayout
|
||||
log4j.appender.stdout.layout.ConversionPattern = [%-5p] %d{yyyy-MM-dd HH:mm:ss,SSS} method:%l%n%m%n
|
||||
|
||||
### 输出DEBUG 级别以上的日志到=E://logs/error.log ###
|
||||
log4j.appender.D = org.apache.log4j.DailyRollingFileAppender
|
||||
log4j.appender.D.File = logs/log.log
|
||||
log4j.appender.D.Append = true
|
||||
log4j.appender.D.Threshold = DEBUG
|
||||
log4j.appender.D.layout = org.apache.log4j.PatternLayout
|
||||
log4j.appender.D.layout.ConversionPattern = %-d{yyyy-MM-dd HH:mm:ss} [ %t:%r ] - [ %p ] %m%n
|
||||
|
||||
### 输出ERROR 级别以上的日志到=E://logs/error.log ###
|
||||
log4j.appender.E = org.apache.log4j.DailyRollingFileAppender
|
||||
log4j.appender.E.File =logs/error.log
|
||||
log4j.appender.E.Append = true
|
||||
log4j.appender.E.Threshold = ERROR
|
||||
log4j.appender.E.layout = org.apache.log4j.PatternLayout
|
||||
log4j.appender.E.layout.ConversionPattern = %-d{yyyy-MM-dd HH:mm:ss} [ %t:%r ] - [ %p ] %m%n
|
||||
|
|
@ -1,3 +0,0 @@
|
|||
Manifest-Version: 1.0
|
||||
Main-Class: com.bonus.autoweb.TestMain
|
||||
|
||||
|
|
@ -1,3 +0,0 @@
|
|||
Manifest-Version: 1.0
|
||||
Main-Class: com.bonus.autoweb.UI.frame.Jframe
|
||||
|
||||
Loading…
Reference in New Issue