|
|
@ -400,8 +400,9 @@ public class TaskController extends JeecgController<Task, ITaskService> { |
|
|
|
workTime += (millisecond / DAYTIME) * DAYWORKTIME; |
|
|
|
workTime += (millisecond / DAYTIME) * DAYWORKTIME; |
|
|
|
millisecond = millisecond % DAYTIME; |
|
|
|
millisecond = millisecond % DAYTIME; |
|
|
|
|
|
|
|
|
|
|
|
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd"); |
|
|
|
|
|
|
|
SimpleDateFormat sdf1 = new SimpleDateFormat("HH:mm:ss"); |
|
|
|
SimpleDateFormat sdf1 = new SimpleDateFormat("HH:mm:ss"); |
|
|
|
|
|
|
|
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd"); |
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss"); |
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss"); |
|
|
|
String time = dateFormat.format(new Date()); |
|
|
|
String time = dateFormat.format(new Date()); |
|
|
|
String start = sdf1.format(startTime); |
|
|
|
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删除 |
|
|
|
* 通过id删除 |
|
|
|
* |
|
|
|
* |
|
|
|