From a239ff56362f078d46cabd8e039c2c0440241a66 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=A9=AC=E4=B8=89=E7=82=AE?= <15856818120@163.com> Date: Tue, 23 Sep 2025 13:17:13 +0800 Subject: [PATCH] =?UTF-8?q?=E7=B3=BB=E7=BB=9F=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/bonus/autoweb/TestMain.java | 80 ++++++++++++++++++- .../java/com/bonus/autoweb/base/AutoMain.java | 7 +- .../com/bonus/autoweb/base/DutyLogIOp.java | 35 +++++++- .../com/bonus/autoweb/task/AutoWebTask.java | 2 +- 4 files changed, 118 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/bonus/autoweb/TestMain.java b/src/main/java/com/bonus/autoweb/TestMain.java index 747f3b1..61345f3 100644 --- a/src/main/java/com/bonus/autoweb/TestMain.java +++ b/src/main/java/com/bonus/autoweb/TestMain.java @@ -209,6 +209,19 @@ public class TestMain { int resetCode = 0; int addExercisePlan = 0; + int logGatherCountNum = 0; + int logGatherCountNum1 = 0; + int signInzaoNum = 0; + int signInwanNum = 0; + int dailyzaoNum = 0; + int dailywanNum = 0; + int jjbzaoNum = 0; + int jjbwanNum = 0; + int signOutzaoNum = 0; + int signOutwanNum = 0; + int logzaoNum = 0; + int logwanNum = 0; + int addExercisePlanNum = 0; while (true) { //延迟30s---120s @@ -221,6 +234,10 @@ public class TestMain { } log.info("服务正在运行。。。" + new Date()); if (DateTimeUtils.isEffectiveDate("18:10", "18:40")) { + logGatherCountNum++; + if (logGatherCountNum>10){ + continue; + } //进行日报信息系统采集及获取工作 try { if (logGatherCount == 0) { @@ -237,6 +254,10 @@ public class TestMain { log.error("信息采集工作", e); } } else if (DateTimeUtils.isEffectiveDate("06:29", "06:59")) { + dailyzaoNum++; + if (dailyzaoNum>10){ + continue; + } //自动完成当值值班日报(早报)填写上报 if (dailyzao == 0) { getTime(900); @@ -247,6 +268,10 @@ public class TestMain { } } } else if (DateTimeUtils.isEffectiveDate("07:01", "07:30")) { + logzaoNum++; + if (logzaoNum>10){ + continue; + } //完成值班日志填写提交(晚班日志,此次值班日志为总结前一天晚上的情况) if (logzao == 0) { getTime(600); @@ -257,6 +282,10 @@ public class TestMain { } } } else if (DateTimeUtils.isEffectiveDate("07:31", "07:59")) { + signInzaoNum++; + if (signInzaoNum>10){ + continue; + } //自动完成当值值班签到(值班主任、值班人员都要签到) if (signInzao == 0 && signInzao2 == 0) { getTime(600); @@ -285,6 +314,10 @@ public class TestMain { } } } else if (DateTimeUtils.isEffectiveDate("08:10", "08:20")) { + jjbzaoNum++; + if (jjbzaoNum>10){ + continue; + } // if (jjbzao == 0 && jjbzao2 == 0){ // getTime(420); // } @@ -304,6 +337,10 @@ public class TestMain { jjbzao = autoWebTask.dutyChangeTask(1); } } else if (DateTimeUtils.isEffectiveDate("08:31", "08:40")) { + signOutzaoNum++; + if (signOutzaoNum>10){ + continue; + } if (signOutzao == 0 && signOutzao2 == 0) { getTime(420); } @@ -327,6 +364,10 @@ public class TestMain { } } } else if (DateTimeUtils.isEffectiveDate("08:50", "09:10")) { + addExercisePlanNum++; + if (addExercisePlanNum>10){ + continue; + } if (addExercisePlan == 0) { getTime(1200); } @@ -338,7 +379,11 @@ public class TestMain { DataConfig.PASS1); Thread.sleep(2000); } - } else if (DateTimeUtils.isEffectiveDate("12:30", "16:20")) { + } else if (DateTimeUtils.isEffectiveDate("12:30", "15:20")) { + logGatherCountNum1++; + if (logGatherCountNum1>10){ + continue; + } //进行日志信息系统采集及获取工作 try { if (logGatherCount1 == 0) { @@ -354,6 +399,10 @@ public class TestMain { log.error("信息采集工作", e); } } else if (DateTimeUtils.isEffectiveDate("17:01", "17:15")) { + dailywanNum++; + if (dailywanNum>10){ + continue; + } //自动完成当值值班日报(晚报)填写上报 if (dailywan == 0) { getTime(700); @@ -365,6 +414,10 @@ public class TestMain { } } else if (DateTimeUtils.isEffectiveDate("16:30", "16:45")) { // }else if (DateTimeUtils.isEffectiveDate("10:00", "16:45")) { + logwanNum++; + if (logwanNum>10){ + continue; + } //完成值班日志填写提交(白班日志,此次值班日志为总结前一天晚上的情况) if (logwan == 0) { getTime(600); @@ -375,6 +428,10 @@ public class TestMain { } } } else if (DateTimeUtils.isEffectiveDate("16:46", "16:59")) { + signInwanNum++; + if (signInwanNum>10){ + continue; + } //自动完成当值值班签到(值班主任、值班人员都要签到) if (signInwan == 0 && signInwan2 == 0) { getTime(550); @@ -403,6 +460,10 @@ public class TestMain { } } } else if (DateTimeUtils.isEffectiveDate("17:30", "17:45")) { + jjbwanNum++; + if (jjbwanNum>10){ + continue; + } //自动在系统内完成接班(上一值完成交班后) if (jjbwan == 0 && jjbwan2 == 0) { getTime(600); @@ -416,6 +477,10 @@ public class TestMain { } } } else if (DateTimeUtils.isEffectiveDate("17:46", "18:00")) { + signOutwanNum++; + if (signOutwanNum>10){ + continue; + } if (signOutwan == 0 && signOutwan2 == 0) { getTime(500); } @@ -462,6 +527,19 @@ public class TestMain { logwan = 0; resetCode = 0; addExercisePlan = 0; + logGatherCountNum = 0; + logGatherCountNum1 = 0; + signInzaoNum = 0; + signInwanNum = 0; + dailyzaoNum = 0; + dailywanNum = 0; + jjbzaoNum = 0; + jjbwanNum = 0; + signOutzaoNum = 0; + signOutwanNum = 0; + logzaoNum = 0; + logwanNum = 0; + addExercisePlanNum = 0; } else { continue; } diff --git a/src/main/java/com/bonus/autoweb/base/AutoMain.java b/src/main/java/com/bonus/autoweb/base/AutoMain.java index 834c8bd..ffb2382 100644 --- a/src/main/java/com/bonus/autoweb/base/AutoMain.java +++ b/src/main/java/com/bonus/autoweb/base/AutoMain.java @@ -40,7 +40,10 @@ public class AutoMain { option.addArguments("--start-maximized"); // option.addArguments("--force-device-scale-factor=0.75"); - option.addArguments("--force-device-scale-factor=0.6"); + option.addArguments("--force-device-scale-factor=0.7"); + if (type==8){ + option.addArguments("--force-device-scale-factor=0.6"); + } option.addArguments("disable-infobars"); // if(type != 7) { // //隐藏浏览器 @@ -198,7 +201,7 @@ public class AutoMain { String zbglXpath = "//*[@id=\"" + attributeId + "\"]/div/div[2]/div[2]/div/div[1]"; webDriver.findElement(By.xpath(zbglXpath)).click(); log.info("打开值班管理页面------------"); - Thread.sleep(800); + Thread.sleep(2000); //定位值班管理iframe的标签 WebElement dutyIframe = webDriver.findElement(By.id("zbgln")); diff --git a/src/main/java/com/bonus/autoweb/base/DutyLogIOp.java b/src/main/java/com/bonus/autoweb/base/DutyLogIOp.java index 3831cdc..d87c14d 100644 --- a/src/main/java/com/bonus/autoweb/base/DutyLogIOp.java +++ b/src/main/java/com/bonus/autoweb/base/DutyLogIOp.java @@ -271,11 +271,42 @@ public class DutyLogIOp { //通信测试 标题 String txcs_title = bean.getCommunications_test_title(); log.info("txcs_title:{}", txcs_title); + try { + WebElement element = 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[1]/textarea")); + log.info("获取输入框-----div[3]"); + element.clear(); + element.sendKeys(txcs_title.trim()); + log.info("通信测试 标题----------"); + /* By inputLocator = 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[1]/textarea"); + log.info("获取输入框-----div[3]"); + sendKeysWithRetry(webDriver, inputLocator, txcs_title.trim()); + log.info("通信测试 标题----------");*/ + }catch (Exception e){ + log.info("通信测试 标题----------div[3]不存在",e.getMessage()); + } + try { + WebElement element =webDriver.findElement(By.xpath("/html/body/div[2]/div/div[2]/div/form/div[4]/table/tr[2]/td/table[4]/tr[1]/td/div[3]/div/div/textarea")); + log.info("获取输入框-----div[2]"); + element.clear(); + element.sendKeys(txcs_title.trim()); + log.info("通信测试 标题----------"); + }catch (Exception e){ + log.info("通信测试 标题----------div[2]不存在",e.getMessage()); + } + try { + WebElement element = webDriver.findElement(By.cssSelector("body > div.el-dialog__wrapper.ecs-dialog.otherDialog.limit.no-padding.no-radius.with-footer > div > div.el-dialog__body > div > form > div.btnShow > table > tr:nth-child(2) > td > table:nth-child(4) > tr:nth-child(1) > td > div.el-form-item.addId-box-title.is-required.el-form-item--small > div > div > textarea")); + log.info("获取输入框-----"); + element.clear(); + element.sendKeys(txcs_title.trim()); + log.info("输入成功"); + }catch (Exception e){ + log.info("通信测试 标题----------失败",e.getMessage()); + } // WebElement element = 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")); - WebElement element = webDriver.findElement(By.cssSelector("body > div.el-dialog__wrapper.ecs-dialog.otherDialog.limit.no-padding.no-radius.with-footer > div > div.el-dialog__body > div > form > div.btnShow > table > tr:nth-child(2) > td > table:nth-child(4) > tr:nth-child(1) > td > div.el-form-item.addId-box-title.is-required.el-form-item--small > div > div > textarea")); + /* WebElement element = webDriver.findElement(By.cssSelector("body > div.el-dialog__wrapper.ecs-dialog.otherDialog.limit.no-padding.no-radius.with-footer > div > div.el-dialog__body > div > form > div.btnShow > table > tr:nth-child(2) > td > table:nth-child(4) > tr:nth-child(1) > td > div.el-form-item.addId-box-title.is-required.el-form-item--small > div > div > textarea")); element.clear(); element.sendKeys(txcs_title.trim()); - log.info("输入成功"); + log.info("输入成功");*/ // try { // log.info("通信测试 走到了----------1"); // WebDriverWait wait = new WebDriverWait(webDriver, 10); diff --git a/src/main/java/com/bonus/autoweb/task/AutoWebTask.java b/src/main/java/com/bonus/autoweb/task/AutoWebTask.java index 7f71a5a..ae16f5a 100644 --- a/src/main/java/com/bonus/autoweb/task/AutoWebTask.java +++ b/src/main/java/com/bonus/autoweb/task/AutoWebTask.java @@ -115,7 +115,7 @@ public class AutoWebTask { AutoMain autoMain = new AutoMain(); WebDriver webDriver; try { - autoMain.initDrive(7); + autoMain.initDrive(8); autoMain.startAuto(username, password); //操作日志 webDriver = autoMain.getWebDriver();