更新系统

This commit is contained in:
马三炮 2025-09-08 09:11:43 +08:00
parent 8a9c2a9f25
commit e00d7de36d
7 changed files with 55 additions and 14 deletions

View File

@ -346,7 +346,7 @@ public class GetBasicData {
}
log.info("code:" + code);
DailyBean dailyBean = readDailyBean("morning_daily");
DailyBean dailyBean2 = readDailyBean("evening_daily");
DailyBean dailyBean2 = readDailyBean("evening_daily");
LogBean logBean = readDutyBean();
String dailyContent = resolveGarbledCode("E:\\bns\\config\\日报基本信息.txt");
String logContent = resolveGarbledCode("E:\\bns\\config\\日志基本信息.txt");
@ -801,9 +801,10 @@ public class GetBasicData {
dailyBean2.getTwoBean().setVerification_team_num("1");
dailyBean2.getTwoBean().setVerification_equip_num(checkContentNumArrayArray[num].split("-")[2]);
//安全生产情况
dailyBean2.setSafety_production(data + dailyContentArrayArray[7].trim().split("--")[0] + (String.format(
/*dailyBean2.setSafety_production(data + dailyContentArrayArray[7].trim().split("--")[0] + (String.format(
"%.2f", Double.parseDouble(maximumLoadArr[1].split("")[1]) + numRandom)) + dailyContentArrayArray[7].trim().split("--")[2]);
insertData(dailyBean2, null, type);
insertData(dailyBean2, null, type);*/
dailyBean2.setSafety_production(dailyContentArrayArray[7]);
// logBean.setWeather(weatherNight);
// logBean.setMax_temperature(maxTemperature);

View File

@ -44,7 +44,8 @@ public class AutoMain {
// option.addArguments("start-fullscreen");
// if (type == 2){
option.addArguments("--start-maximized");
option.addArguments("--force-device-scale-factor=0.9");
/* option.addArguments("--force-device-scale-factor=0.9");*/
option.addArguments("--force-device-scale-factor=0.7");
// }
option.addArguments("disable-infobars");

View File

@ -64,7 +64,7 @@ public class DutyChangeShifts {
}
}
log.info("交接班地址:"+xpaht+"----------");
Thread.sleep(5000);
Thread.sleep(7000);
webDriver.findElement(By.xpath(xpaht)).click();
log.info("定位交接班并点击2----------");
Thread.sleep(5000);

View File

@ -53,7 +53,7 @@ public class DutyClock {
// do {
// pageLoaded = (Boolean) jsExecutor.executeScript("return document.readyState").equals("complete");
// } while (!pageLoaded);
Thread.sleep(5000);
Thread.sleep(9000);
//标签位置
String xpaht;
if (classes == 1) {

View File

@ -29,11 +29,11 @@ public class DutyDailyCheck {
// do {
// pageLoaded = (Boolean) jsExecutor.executeScript("return document.readyState").equals("complete");
// } while (!pageLoaded);
Thread.sleep(5000);
Thread.sleep(9000);
//定位值班日报并点击
webDriver.findElement(By.id("tab-4")).click();
log.info("定位值班日报并点击-----------");
Thread.sleep(300);
Thread.sleep(2000);
String checkXpath;
//早报
if(type ==1){

View File

@ -60,7 +60,7 @@ public class DutyDailyOp {
// do {
// pageLoaded = (Boolean) jsExecutor.executeScript("return document.readyState").equals("complete");
// } while (!pageLoaded);
Thread.sleep(5000);
Thread.sleep(9000);
//定位值班日报并点击
webDriver.findElement(By.id("tab-4")).click();
@ -1666,7 +1666,7 @@ public class DutyDailyOp {
cpvEle.clear();
cpvEle.sendKeys(cpv);
log.info("填写累计-出动抢修力量-用户----------");
Thread.sleep(300);
Thread.sleep(1000);
dailySchedule10(bean.getTenBean(), bean);
}

View File

@ -6,9 +6,9 @@ import com.bonus.autoweb.UI.entity.LogBean;
import com.bonus.autoweb.UI.frame.StringHelper;
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.openqa.selenium.*;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
import org.slf4j.LoggerFactory;
import java.io.File;
@ -16,6 +16,7 @@ import java.io.FileInputStream;
import java.io.InputStreamReader;
import java.nio.charset.Charset;
import java.text.ParseException;
import java.time.Duration;
import org.slf4j.Logger;
@ -69,7 +70,7 @@ public class DutyLogIOp {
//退出当前iframe,进入到日报编辑iframe
webDriver.switchTo().defaultContent();
log.info("退出当前iframe----------");
Thread.sleep(7000);
Thread.sleep(9000);
//定位日志编辑iframe的标签
WebElement dutyEditIframe = webDriver.findElement(By.id("add-local-zbrzbz"));
@ -280,6 +281,10 @@ public class DutyLogIOp {
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());
}
@ -422,6 +427,40 @@ public class DutyLogIOp {
}
// 增强版输入方法
public void sendKeysWithRetry(WebDriver driver, By locator, String text) {
WebElement element = null;
// 最多重试3次
for (int i = 0; i < 3; i++) {
try {
// 显式等待元素可交互
element = new WebDriverWait(driver, 10)
.until(ExpectedConditions.elementToBeClickable(locator));
// 确保元素可见
if (!element.isDisplayed()) {
log.info("元素存在但不可见,尝试滚动到元素");
((JavascriptExecutor) driver).executeScript("arguments[0].scrollIntoView(true);", element);
Thread.sleep(500); // 等待滚动完成
}
// 清除现有内容使用JS清除避免clear()可能的问题
((JavascriptExecutor) driver).executeScript("arguments[0].value = '';", element);
// 执行输入
element.sendKeys(text);
log.info("输入成功,内容: " + text);
} catch (ElementNotInteractableException e) {
log.warn("元素不可交互,重试第" + (i+1) + "次: " + e.getMessage());
} catch (StaleElementReferenceException e) {
log.warn("元素已失效,重试第" + (i+1) + "次: " + e.getMessage());
} catch (Exception e) {
log.warn("输入失败,重试第" + (i+1) + "次: " + e.getMessage());
}
}
log.error("多次尝试后仍无法完成输入");
}
public static void main(String[] args) throws ParseException {
int tr = 1;
int td = 1;