Merge remote-tracking branch 'origin/dev_2307' into dev_2307

dev^2
mqh 1 year ago
commit 7f3093b53c
  1. 4
      jeecg-boot/jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/common/system/base/controller/JeecgController.java
  2. 81
      jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/task/controller/TaskController.java

@ -45,7 +45,7 @@ public class JeecgController<T, S extends IService<T>> {
S service;
@Value("${jeecg.path.upload}")
private String upLoadPath;
protected String upLoadPath;
/**
* 导出excel
@ -154,7 +154,7 @@ public class JeecgController<T, S extends IService<T>> {
*
* @return
*/
private String getId(T item) {
protected String getId(T item) {
try {
return PropertyUtils.getProperty(item, "id").toString();
} catch (Exception e) {

@ -400,8 +400,9 @@ public class TaskController extends JeecgController<Task, ITaskService> {
workTime += (millisecond / DAYTIME) * DAYWORKTIME;
millisecond = millisecond % DAYTIME;
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd");
SimpleDateFormat sdf1 = new SimpleDateFormat("HH:mm:ss");
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd");
SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
String time = dateFormat.format(new Date());
String start = sdf1.format(startTime);
@ -481,6 +482,84 @@ public class TaskController extends JeecgController<Task, ITaskService> {
}
}
/**
* 计算预计结束时间
* @param task
* @return
*/
@GetMapping("/estimateTime")
public Result<?> calculating(Task task){
if (task.getStartTime() == null || task.getExpectedDuration() == null)
return Result.error("参数不足,无法计算预计结束时间");
Date date = null;
try {
date = estimateTime(task.getStartTime(), task.getExpectedDuration());
} catch (ParseException e) {
throw new RuntimeException(e);
}
return Result.OK(date);
}
/**
* 计算预计结束时间方法
* @param startTime
* @param expectedDuration
* @return
*/
private Date estimateTime(Date startTime, Double expectedDuration) throws ParseException {
long millisecond = (long) (expectedDuration * 60 * 60 * 1000);
//整天偏移量
int offset = (int) (millisecond / DAYWORKTIME);
//剩余工作量
millisecond = millisecond % DAYWORKTIME;
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd");
SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
String time = dateFormat.format(startTime);
String time1 = time + MORINGSTART;
String time2 = time + MORINGEND;
String time3 = time + AFTERNOONSTART;
String time4 = time + AFTERNOONEND;
Date date3 = sdf.parse(time3);
Date date2 = sdf.parse(time2);
Date date1 = sdf.parse(time1);
Date date4 = sdf.parse(time4);
long tempTime = 0;
if (startTime.compareTo(date1) <= 0)
startTime = date1; //任务发布在8点半之前,修正时间
if (startTime.compareTo(date2) < 0){
//上午发布任务
tempTime = date2.getTime() - startTime.getTime();
if (tempTime >= millisecond)
return new Date(startTime.getTime() + millisecond + DAYTIME*offset); //预计上午结束,直接偏移剩余时间
//上午剩余时间全部工作,时间进行修正到下午工作开始时间
millisecond -= tempTime;
startTime = date3;
}
if (startTime.compareTo(date3) <= 0)
startTime = date3; //任务是下午发布且在2点半之前,修正时间
if (startTime.compareTo(date4) < 0){
//下午发布任务
tempTime = date4.getTime() - startTime.getTime();
if (tempTime >= millisecond)
return new Date(startTime.getTime() + millisecond + DAYTIME*offset);
}
//时间修正,天数偏移量加1,到这里有两中情况,1、白天工作时间不足抵消 2、下午6点之后发布任务
offset ++;
startTime = date1;
tempTime = date2.getTime() - date1.getTime();
if (tempTime >= millisecond)
return new Date(startTime.getTime() + millisecond + DAYTIME*offset);
//上午偏移不足,下午一定够,因为不会跨两天
millisecond -= tempTime;
return new Date(startTime.getTime() + millisecond + DAYTIME*offset);
}
/**
* 通过id删除
*

Loading…
Cancel
Save