From 7ae9d8e8a25fe57650dcc34f9c6ccddf70c673e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=A9=AC=E4=B8=89=E7=82=AE?= <15856818120@163.com> Date: Mon, 11 Aug 2025 15:58:32 +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 --- .../java/com/bonus/autoweb/GetBasicData.java | 19 ++-- .../java/com/bonus/autoweb/base/AutoMain.java | 98 +++++++++++++++---- .../com/bonus/autoweb/base/DutyLogIOp.java | 22 ++++- 3 files changed, 106 insertions(+), 33 deletions(-) diff --git a/src/main/java/com/bonus/autoweb/GetBasicData.java b/src/main/java/com/bonus/autoweb/GetBasicData.java index 5190352..c812b8a 100644 --- a/src/main/java/com/bonus/autoweb/GetBasicData.java +++ b/src/main/java/com/bonus/autoweb/GetBasicData.java @@ -408,11 +408,11 @@ public class GetBasicData { logBean.setEvent_detection_content(data + logContentArrayArray[3].trim() + data2 + logContentArrayArray[4].trim()); logBean.setPower_work_title(logContentArrayArray[6]); logBean.setPower_work_content(data + logContentArrayArray[7]); - logBean.setResource_check_title("开展县公司应急车辆及应急物资储备情况核查"); + logBean.setResource_check_title("开展本部资源核查工作"); logBean.setResource_check_content(data + checkContentArrayArray[num]); - logBean.setCommunications_test_title("今日开展通信测试1项,均正常"); + logBean.setCommunications_test_title("今日开展通信测试1项"); logBean.setCommunications_test_content(logContentArrayArray[11]); - logBean.setDaily_operation_title("今日开展日常操练1次"); + logBean.setDaily_operation_title("今日开展队伍操练核查1项"); logBean.setDaily_operation_content(logContentArrayArray[13]); logBean.setDaily_submission_title(logContentArrayArray[15]); logBean.setDaily_submission_content(data + logContentArrayArray[16]); @@ -464,11 +464,11 @@ public class GetBasicData { logBean.setEvent_detection_content(data + logContentArrayArray[3].trim() + data2 + logContentArrayArray[4].trim()); logBean.setPower_work_title(logContentArrayArray[6]); logBean.setPower_work_content(data + logContentArrayArray[7]); - logBean.setResource_check_title("开展县公司应急车辆及应急物资储备情况核查"); + logBean.setResource_check_title("开展本部资源核查工作"); logBean.setResource_check_content(data + checkContentArrayArray[num]); - logBean.setCommunications_test_title("今日开展通信测试1项,均正常"); + logBean.setCommunications_test_title("今日开展通信测试1项"); logBean.setCommunications_test_content(logContentArrayArray[11]); - logBean.setDaily_operation_title("今日开展日常操练1次"); + logBean.setDaily_operation_title("今日开展队伍操练核查1项"); logBean.setDaily_operation_content(logContentArrayArray[13]); logBean.setDaily_submission_title(logContentArrayArray[15]); logBean.setDaily_submission_content(data + logContentArrayArray[16]); @@ -622,15 +622,16 @@ public class GetBasicData { dailyBean.getTwoBean().setVerification_team_num("8"); dailyBean.getTwoBean().setVerification_equip_num("501"); + insertData(dailyBean, null, type); logBean.setEvent_detection_content(data + logContentArrayArray[3].trim() + data2 + logContentArrayArray[4].trim()); logBean.setPower_work_title(logContentArrayArray[6]); logBean.setPower_work_content(data + logContentArrayArray[7]); - logBean.setResource_check_title("开展县公司应急车辆及应急物资储备情况核查"); + logBean.setResource_check_title("开展本部资源核查工作"); logBean.setResource_check_content(data + logContentArrayArray[9]); - logBean.setCommunications_test_title("今日开展通信测试1项,均正常"); + logBean.setCommunications_test_title("今日开展通信测试1项"); logBean.setCommunications_test_content(logContentArrayArray[11]); - logBean.setDaily_operation_title("今日开展日常操练1次"); + logBean.setDaily_operation_title("今日开展队伍操练核查1项"); logBean.setDaily_operation_content(logContentArrayArray[13]); logBean.setDaily_submission_title(logContentArrayArray[15]); logBean.setDaily_submission_content(data + logContentArrayArray[16]); diff --git a/src/main/java/com/bonus/autoweb/base/AutoMain.java b/src/main/java/com/bonus/autoweb/base/AutoMain.java index 09d3b77..834c8bd 100644 --- a/src/main/java/com/bonus/autoweb/base/AutoMain.java +++ b/src/main/java/com/bonus/autoweb/base/AutoMain.java @@ -160,18 +160,36 @@ public class AutoMain { WebElement wegl = webDriver.findElement(By.xpath("//*[@id=\"app\"]/div/div[1]/div[6]/div/div/div[6]/span/span" + "/div")); action.moveToElement(wegl).build().perform(); - Thread.sleep(300); + Thread.sleep(2000); //获取管理标签中的aria-describedby属性 String attributeId = wegl.getAttribute("aria-describedby"); log.info("管理标签的ID值为:" + attributeId); - Thread.sleep(300); + Thread.sleep(2000); - //执行鼠标悬停动作-常态值班 - String ctzbXpath = "//*[@id=\"" + attributeId + "\"]/div/div[1]/div[2]/div[4]"; - WebElement wectzb = webDriver.findElement(By.xpath(ctzbXpath)); - action.moveToElement(wectzb).build().perform(); + + //判断是否有相应的元素 + try { + Thread.sleep(2000); + //执行鼠标悬停动作-常态值班 + String ctzbXpath = "//*[@id=\"" + attributeId + "\"]/div/div[1]/div[2]/div[4]"; + WebElement wectzb = webDriver.findElement(By.xpath(ctzbXpath)); + action.moveToElement(wectzb).build().perform(); + } catch (Exception e) { + log.info("无确认框,在时间范围内----------"); + } + //判断是否有相应的元素 + try { + Thread.sleep(2000); + //执行鼠标悬停动作-常态值班 + String ctzbXpath = "//*[@id=\"" + attributeId + "\"]/div/div[1]/div/div[4]/div"; + WebElement wectzb = webDriver.findElement(By.xpath(ctzbXpath)); + action.moveToElement(wectzb).build().perform(); + } catch (Exception e) { + log.info("无确认框,在时间范围内----------"); + } + Thread.sleep(300); @@ -211,9 +229,23 @@ public class AutoMain { //获取管理标签中的aria-describedby属性 el-popover-7909 String attributeId = wegl.getAttribute("aria-describedby"); log.info("管理标签的ID值为:" + attributeId); - Thread.sleep(300); - String zbglXpath = "//*[@id=\"" + attributeId + "\"]/div/div/div[2]/div[3]"; - webDriver.findElement(By.xpath(zbglXpath)).click(); + + //判断是否有相应的元素 + try { + Thread.sleep(2000); + String zbglXpath = "//*[@id=\"" + attributeId + "\"]/div/div/div[2]/div[3]"; + webDriver.findElement(By.xpath(zbglXpath)).click(); + } catch (Exception e) { + log.info("无确认框,在时间范围内----------"); + } + //判断是否有相应的元素 + try { + Thread.sleep(2000); + String zbglXpath = "//*[@id=\"" + attributeId + "\"]/div/div/div/div[3]/div"; + webDriver.findElement(By.xpath(zbglXpath)).click(); + } catch (Exception e) { + log.info("无确认框,在时间范围内----------"); + } log.info("打开预警页面------------"); Thread.sleep(800); @@ -240,7 +272,7 @@ public class AutoMain { //获取管理标签中的aria-describedby属性 el-popover-7909 String attributeId = wegl.getAttribute("aria-describedby"); log.info("管理标签的ID值为:" + attributeId); - Thread.sleep(300); + Thread.sleep(2000); // //执行鼠标悬停动作-预警行动 @@ -267,7 +299,8 @@ public class AutoMain { /** * 打开检查操练管理页面,并定位到日常操练的iframe */ - private void openCheckTheDrills() throws InterruptedException { + private void + openCheckTheDrills() throws InterruptedException { try { webDriver.manage().timeouts().implicitlyWait(3, TimeUnit.SECONDS); } catch (Exception e) { @@ -279,16 +312,29 @@ public class AutoMain { WebElement wegl = webDriver.findElement(By.xpath("//*[@id=\"app\"]/div/div[1]/div[6]/div/div/div[6]/span/span" + "/div")); action.moveToElement(wegl).build().perform(); - Thread.sleep(300); + Thread.sleep(2000); //获取管理标签中的aria-describedby属性 String attributeId = wegl.getAttribute("aria-describedby"); log.info("管理标签的ID值为:" + attributeId); - Thread.sleep(300); + Thread.sleep(2000); //执行鼠标悬停动作-检查操练管理 - String ctzbXpath = "//*[@id=\"" + attributeId + "\"]/div/div[1]/div[2]/div[5]"; - webDriver.findElement(By.xpath(ctzbXpath)).click(); + //判断是否有相应的元素 + try { + Thread.sleep(2000); + String ctzbXpath = "//*[@id=\"" + attributeId + "\"]/div/div[1]/div[2]/div[5]"; + webDriver.findElement(By.xpath(ctzbXpath)).click(); + } catch (Exception e) { + log.info("无确认框,在时间范围内----------"); + } + try { + Thread.sleep(2000); + String ctzbXpath = "//*[@id=\"" + attributeId + "\"]/div/div/div/div[5]/div"; + webDriver.findElement(By.xpath(ctzbXpath)).click(); + } catch (Exception e) { + log.info("无确认框,在时间范围内----------"); + } // WebElement wectzb = webDriver.findElement(By.xpath(ctzbXpath)); // action.moveToElement(wectzb).build().perform(); Thread.sleep(300); @@ -343,18 +389,32 @@ public class AutoMain { WebElement wegl = webDriver.findElement(By.xpath("//*[@id=\"app\"]/div/div[1]/div[6]/div/div/div[6]/span/span" + "/div")); action.moveToElement(wegl).build().perform(); - Thread.sleep(300); + Thread.sleep(2000); //获取管理标签中的aria-describedby属性 String attributeId = wegl.getAttribute("aria-describedby"); log.info("管理标签的ID值为:" + attributeId); - Thread.sleep(300); //执行鼠标悬停动作-检查操练管理 - String ctzbXpath = "//*[@id=\"" + attributeId + "\"]/div/div[1]/div[2]/div[5]"; - webDriver.findElement(By.xpath(ctzbXpath)).click(); + // WebElement wectzb = // action.moveToElement(wectzb).build().perform(); + //判断是否有相应的元素 + try { + Thread.sleep(2000); + String ctzbXpath = "//*[@id=\"" + attributeId + "\"]/div/div[1]/div[2]/div[5]"; + webDriver.findElement(By.xpath(ctzbXpath)).click(); + } catch (Exception e) { + log.info("无确认框,在时间范围内----------"); + } + //判断是否有相应的元素 + try { + Thread.sleep(2000); + String ctzbXpath = "//*[@id=\"" + attributeId + "\"]/div/div/div/div[5]/div"; + webDriver.findElement(By.xpath(ctzbXpath)).click(); + } catch (Exception e) { + log.info("无确认框,在时间范围内----------"); + } Thread.sleep(300); // //打开检查计划页面 diff --git a/src/main/java/com/bonus/autoweb/base/DutyLogIOp.java b/src/main/java/com/bonus/autoweb/base/DutyLogIOp.java index 2cac4ce..3831cdc 100644 --- a/src/main/java/com/bonus/autoweb/base/DutyLogIOp.java +++ b/src/main/java/com/bonus/autoweb/base/DutyLogIOp.java @@ -37,7 +37,7 @@ public class DutyLogIOp { * * @param type 1 早 2晚 */ - public void openDutyLog(int type) throws Exception { + public void openDutyLog(int type) throws Exception { if (type == 1) { //早上填写前一天的日志,将标签改为前一天 changeDay(); @@ -49,11 +49,23 @@ public class DutyLogIOp { Thread.sleep(5000); // /html/body/div[2] 弹窗 您没有填写值班日志的排班班次 + try { + //定位写日志标签,打开日志页面 + webDriver.findElement(By.xpath("//*[@id=\"pane-5\"]/div/div[2]/div[2]/button")).click(); + log.info("定位写日志标签,打开日志页面----------/div/div[2]/div[2]/button"); + Thread.sleep(1500); + } catch (Exception e) { + log.info("无确认框,在时间范围内----------"); + } + try { + //定位写日志标签,打开日志页面 + webDriver.findElement(By.xpath("//*[@id=\"pane-5\"]/div/div[2]/div[2]/button/span")).click(); + log.info("定位写日志标签,打开日志页面----------"); + Thread.sleep(1500); + } catch (Exception e) { + log.info("无确认框,在时间范围内----------/div/div[2]/div[2]/button/span"); + } - //定位写日志标签,打开日志页面 - webDriver.findElement(By.xpath("//*[@id=\"pane-5\"]/div/div[2]/div[2]/button")).click(); - log.info("定位写日志标签,打开日志页面----------"); - Thread.sleep(1500); //退出当前iframe,进入到日报编辑iframe