|
@@ -61,12 +61,41 @@ public class FillGatherTaskTask {
|
|
|
// 生成巡检任务
|
|
|
for(FillGatherTask task : handleList){
|
|
|
FillGatherTask newTask = BeanConverterUtil.copyObjectProperties(task,FillGatherTask.class);
|
|
|
- newTask.setCreatedTime(LocalDateTime.now());
|
|
|
newTask.setId(IdGeneratorUtils.getObjectId());
|
|
|
newTask.setStatus(FillGatherTaskStatusEnum.PROCESSING.getValue());
|
|
|
newTask.setWaitNum(task.getTotalNum());
|
|
|
- newTask.setName(task.getName() + "_" + nowDateStr);
|
|
|
+ String originName = task.getName().split("_")[0];
|
|
|
+ newTask.setName(originName + "_" + nowDateStr);
|
|
|
newTask.setLateHistoryHours(0);
|
|
|
+ // 巡检开始时间
|
|
|
+ int period = newTask.getPeriod();
|
|
|
+ int currentHour = DateUtils.getCurrentHour();
|
|
|
+ LocalDateTime startTime = null;
|
|
|
+ int diffHour = 0; // 当前时间距离巡检时间间隔小时
|
|
|
+ if(period <= 12){
|
|
|
+ // 12小时周期的,21点之后到次日的8点,任务开始时间T+1 早上八点
|
|
|
+ if(currentHour >= 0 && currentHour <= 8){ // 当日八点
|
|
|
+ startTime = LocalDateTime.now().withHour(8);
|
|
|
+ diffHour = 8-currentHour;
|
|
|
+ }else if(currentHour > 21){
|
|
|
+ startTime = LocalDateTime.now().plusDays(1).withHour(8);
|
|
|
+ diffHour = 24-currentHour + 8;
|
|
|
+ }else{
|
|
|
+ startTime = LocalDateTime.now();
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ // 24小时制的,晚上六点之后到第二天八点,统一到明日八点
|
|
|
+ if(currentHour >= 0 && currentHour <= 8){
|
|
|
+ startTime = LocalDateTime.now().withHour(8);
|
|
|
+ diffHour = 8-currentHour;
|
|
|
+ }else if(currentHour > 17){
|
|
|
+ startTime = LocalDateTime.now().plusDays(1).withHour(8);
|
|
|
+ diffHour = 24-currentHour + 8;
|
|
|
+ }else{
|
|
|
+ startTime = LocalDateTime.now();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ newTask.setCreatedTime(startTime); // 巡检开始时间
|
|
|
fillGatherTaskService.saveModelNoId(newTask);
|
|
|
// 老旧巡检任务,修改为已生成
|
|
|
FillGatherTask updTask = new FillGatherTask();
|
|
@@ -81,12 +110,18 @@ public class FillGatherTaskTask {
|
|
|
sendMessageToChecker(newTask,1);
|
|
|
sendMessageToChecker(newTask,2);
|
|
|
// 4、启动超时监控预警信息
|
|
|
- int initMin = newTask.getRequireHour()*60;
|
|
|
+ int initMin = newTask.getRequireHour()*60 + diffHour*60;
|
|
|
int hours = newTask.getWarningHour() == null ? initMin + 120 : newTask.getWarningHour()*60 + initMin;
|
|
|
RedisUtils.setString(RedisKeyConstants.EXPIRE_BUSINESS_KEY_FILL_PREFIX + RedisKeyConstants.EXPIRE_BUSINESS_SEP + task.getId(), task.getId(), hours, TimeUnit.MINUTES);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ public static void main(String[] args) {
|
|
|
+ String name = "甲三巡检_2023-02-23_2023-02-24_2023-02-24_2023-02-25";
|
|
|
+ String[] arr = name.split("_");
|
|
|
+ System.out.println(LocalDateTime.now().plusDays(1).withHour(8));
|
|
|
+ }
|
|
|
+
|
|
|
private void saveDetails(String content,String newTaskId,String taskId){
|
|
|
List<FillGatherTaskDetail> details = new ArrayList<>();
|
|
|
FillGatherTaskDetail queryDetail = new FillGatherTaskDetail();
|