|
@@ -15,6 +15,8 @@ import org.springframework.util.StringUtils;
|
|
|
import java.io.File;
|
|
|
import java.nio.file.Paths;
|
|
|
import java.time.Instant;
|
|
|
+import java.time.LocalDate;
|
|
|
+import java.time.format.DateTimeFormatter;
|
|
|
import java.time.temporal.ChronoUnit;
|
|
|
|
|
|
/**
|
|
@@ -42,6 +44,7 @@ public class TaskService {
|
|
|
/**
|
|
|
* 每日定时任务 每天中午1点半执行入库任务
|
|
|
*/
|
|
|
+ // 20250312 修改为 15:30执行
|
|
|
@Scheduled(cron = "0 30 15 * * *")
|
|
|
public void dailyWarehouseTask() {
|
|
|
// 这里的时间要向前一天
|
|
@@ -64,6 +67,14 @@ public class TaskService {
|
|
|
if (StringUtils.hasLength(result)) {
|
|
|
// 存在异常情况,发送运维消息
|
|
|
messageService.error(result);
|
|
|
+ // 20250312 修改延时调度逻辑 超过晚上24点后不再调度
|
|
|
+ DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMdd");
|
|
|
+ LocalDate localDate = LocalDate.parse(day, formatter);
|
|
|
+ if (ChronoUnit.DAYS.between(localDate, LocalDate.now()) > 2) {
|
|
|
+ // 因为每天执行上一天任务,如果任务时间和当前时间差超过2天,说明任务已经超时,不再继续调度
|
|
|
+ log.info("账期 {} 任务数据源不具备,已超时:{}", day, result);
|
|
|
+ return;
|
|
|
+ }
|
|
|
// 延时调度,间隔一段时间后再次调度
|
|
|
taskScheduleService.schedule(new RunnableTask()
|
|
|
.setTaskId("warehouse_reSchedule_" + day + "_" + System.currentTimeMillis())
|