Commit 6140f643 authored by zhangsen's avatar zhangsen

修改bug5980 维保定时任务

parent c453e3ef
......@@ -44,8 +44,10 @@ import org.springframework.util.StringUtils;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
import java.math.BigDecimal;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.LocalTime;
import java.util.*;
import java.util.concurrent.CompletionException;
import java.util.function.Function;
......@@ -239,6 +241,20 @@ public class PlanTaskServiceImpl implements IPlanTaskService {
}
/**
* startTime > stopTime 且 startTime 与 stopTime相差1小时内返回true
* @param startTime
* @param stopTime
* @return
*/
public static boolean getTimeDifference(LocalTime startTime, LocalTime stopTime) {
int startSecond = startTime.getHour() * 3600 + startTime.getMinute() * 60 + startTime.getSecond();
int stopSecond = stopTime.getHour() * 3600 + stopTime.getMinute() * 60 + stopTime.getSecond();
BigDecimal bigDecimal = BigDecimal.valueOf((float) (startSecond - stopSecond) / 3600).setScale(3, BigDecimal.ROUND_HALF_UP);
BigDecimal bigDecimal1 = new BigDecimal(1).setScale(3, BigDecimal.ROUND_HALF_UP);
return bigDecimal.compareTo(bigDecimal1) <= 0 && bigDecimal.compareTo(new BigDecimal(0)) >= 0;
}
/**
* 自动任务执行
*/
@Override
......@@ -257,6 +273,23 @@ public class PlanTaskServiceImpl implements IPlanTaskService {
log.info(strDate + " " + " 暂无待生成执行数据的计划");
return;
}
//bug 5980 待办任务消息应只触发执行中的任务,漏检的任务和未开始的任务不需要触发待办任务消息.
List<Plan> planListTwo = new ArrayList<>();
//将日期格式化
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("HH:mm:ss");
LocalTime nowTime = LocalTime.parse(simpleDateFormat.format(new Date()));
for (Plan plan : planList) {
LocalTime dayTime = LocalTime.parse(plan.getDayTime());
// LocalTime plusHoursTime = dayTime.plusHours(1);
if (getTimeDifference(nowTime, dayTime)) {
planListTwo.add(plan);
}
}
if (planListTwo == null || planListTwo.size() <= 0) {
log.info(strDate + " " + " 暂无待生成执行数据的计划 (更改后,只执行进行中的数据)");
return;
}
planList = planListTwo;
//2.循环遍历执行
HashMap<String, Object> paramMap = new HashMap<String, Object>();
for (Plan plan : planList) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment