删除 src/main/java/com/bonus/autoweb/base/DutyChangeShifts.java
This commit is contained in:
parent
794dbc71df
commit
f258b7cb9e
|
|
@ -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);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue