利辛自动化小程序

This commit is contained in:
jjLv 2024-09-30 15:03:52 +08:00
parent 247a0ec432
commit 6aa940158d
2 changed files with 50 additions and 13 deletions

View File

@ -3,12 +3,28 @@ package com.bonus.autoweb;
import com.bonus.autoweb.base.AutoUtils; import com.bonus.autoweb.base.AutoUtils;
import com.bonus.autoweb.base.DataConfig; import com.bonus.autoweb.base.DataConfig;
import com.bonus.autoweb.task.AutoWebTask; 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.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.openqa.selenium.By;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException; import java.io.IOException;
import java.text.ParseException; import java.text.ParseException;
import java.util.*; import java.util.*;
import javax.sound.sampled.*;
import javax.sound.sampled.AudioInputStream;
import javax.sound.sampled.AudioSystem;
/** /**
* 系统测试 * 系统测试
@ -26,11 +42,16 @@ public class TestMain {
// testDailrb(); // testDailrb();
// testRCCL(); // testRCCL();
// testLog(); // testLog();
new Thread(() -> { new Thread(new Runnable() {
@SneakyThrows
@Override
public void run() {
try { try {
new TestMain().autoJob(); new TestMain().autoJob();
} catch (Exception e) { } catch (Exception e) {
log.error("执行autoJob方法时发生错误: {}", e.getMessage(), e); e.printStackTrace();
log.error("错误信息", e);
}
} }
}).start(); }).start();
} }
@ -88,14 +109,25 @@ public class TestMain {
autoWebTask.dutyChangeTask1(2,DataConfig.USER_NAME1,DataConfig.PASS1); autoWebTask.dutyChangeTask1(2,DataConfig.USER_NAME1,DataConfig.PASS1);
} }
private static void testrccl() throws InterruptedException { private static void testRCCL() throws InterruptedException {
AutoWebTask autoWebTask = new AutoWebTask(); AutoWebTask autoWebTask = new AutoWebTask();
String content = GetBasicData.resolveGarbledCode("E:\\bns\\config\\值班账号.txt"); String content = GetBasicData.resolveGarbledCode("E:\\bns\\config\\值班账号.txt");
// 应急值班账号 // 应急值班账号
String emergencyPerson = content.toString().split("")[0].split("")[1]; String emergencyPerson = content.toString().split("")[0].split("")[1];
String emergencyPersonPassword = content.toString().split("")[1].split("")[1]; String emergencyPersonPassword = content.toString().split("")[1].split("")[1];
// autoWebTask.addExercisePlan("通信测试", "", 1, emergencyPerson,
// emergencyPersonPassword);
// Thread.sleep(5000);
// autoWebTask.addExercisePlan("日常操练", "", 1, emergencyPerson,
// emergencyPersonPassword);
// Thread.sleep(5000);
// autoWebTask.addExercisePlan("日常操练", "", 2, emergencyPerson,
// emergencyPersonPassword);
// Thread.sleep(5000);
autoWebTask.addExercisePlan("日常操练", "", 2, emergencyPerson, autoWebTask.addExercisePlan("日常操练", "", 2, emergencyPerson,
emergencyPersonPassword); emergencyPersonPassword);
// autoWebTask.addExercisePlan("日常操练", "", 0, emergencyPerson, emergencyPersonPassword);
// Thread.sleep(2000);
} }
//自动获取数据测试 //自动获取数据测试
@ -218,7 +250,7 @@ public class TestMain {
String yesterdaySignOutPerson = yesterdayContent.toString().split("")[2].split("")[1]; String yesterdaySignOutPerson = yesterdayContent.toString().split("")[2].split("")[1];
String yesterdaySignOutPersonPassword = yesterdayContent.toString().split("")[3].split("")[1]; String yesterdaySignOutPersonPassword = yesterdayContent.toString().split("")[3].split("")[1];
if(DateTimeUtils.isEffectiveDate("18:22", "16:55")){ if(DateTimeUtils.isEffectiveDate("18:22", "18:55")){
//进行日报信息系统采集及获取工作 //进行日报信息系统采集及获取工作
try { try {
if (logGatherCount == 0){ if (logGatherCount == 0){
@ -347,6 +379,11 @@ public class TestMain {
getTime(1200); getTime(1200);
} }
if(addExercisePlan == 0) { if(addExercisePlan == 0) {
// String[] array = {"蒙城","利辛","涡阳"};
// Random random = new Random();
// int index = random.nextInt(array.length);
// log.info("随机值为:" + index);
// log.info("随机值为:" + array[index]);
Thread.sleep(2000); Thread.sleep(2000);
addExercisePlan = autoWebTask.addExercisePlan("通信测试", "", 1, todaySignInLeaderPerson, addExercisePlan = autoWebTask.addExercisePlan("通信测试", "", 1, todaySignInLeaderPerson,
todaySignInLeaderPersonPassword); todaySignInLeaderPersonPassword);
@ -413,7 +450,7 @@ public class TestMain {
} }
} }
private static List<Integer> getaRandomCollectionOfData() { private static List<Integer> getARandomCollectionOfData() {
Random random = new Random(); Random random = new Random();
int minCount = 3; // 最小数量 int minCount = 3; // 最小数量
int maxCount = 5; // 最大数量 int maxCount = 5; // 最大数量

View File

@ -2,7 +2,7 @@ package com.bonus.autoweb.ui.frame;
public class StringHelper { public class StringHelper {
public static boolean isEmpty(String str) { public static boolean isEmpty(String str) {
if (str == null || str.trim().isEmpty() || "null".equals(str.trim())) { if (str == null || str.trim().equals("") || str.trim().equals("null")) {
return true; return true;
} }
return false; return false;
@ -15,16 +15,16 @@ public class StringHelper {
} }
public static boolean isEmptyAndNull(String str) { public static boolean isEmptyAndNull(String str) {
if (str == null || "".equals(str.trim()) || "null".equals(str.trim())) { if (str == null || str.trim().equals("") || str.trim().equals("null")) {
return true; return true;
} }
return false; return false;
} }
public static String fillPrefixZero(int v, int len) { public static String fillPrefixZero(int v, int len) {
StringBuilder vStr = new StringBuilder(v + ""); String vStr = v + "";
while (vStr.length() < len) { while (vStr.length() < len) {
vStr.insert(0, "0"); vStr = "0" + vStr;
} }
return vStr.toString(); return vStr;
} }
} }