浏览代码

handle the special case of syn DO2 for sunday

master
Fai Luk 6 小时前
父节点
当前提交
c8c77b0c33
共有 1 个文件被更改,包括 21 次插入5 次删除
  1. +21
    -5
      src/main/java/com/ffii/fpsms/modules/common/scheduler/service/SchedulerService.kt

+ 21
- 5
src/main/java/com/ffii/fpsms/modules/common/scheduler/service/SchedulerService.kt 查看文件

@@ -22,6 +22,7 @@ import org.slf4j.LoggerFactory
import org.springframework.scheduling.TaskScheduler
import org.springframework.scheduling.support.CronTrigger
import org.springframework.stereotype.Service
import java.time.DayOfWeek
import java.time.LocalDate
import java.time.LocalDateTime
import java.time.format.DateTimeFormatter
@@ -449,22 +450,37 @@ open class SchedulerService(
val currentTime = LocalDateTime.now()

// .atStartOfDay() results in 00:00:00
val today = currentTime.toLocalDate().atStartOfDay()
val runDate = currentTime.toLocalDate()
val today = runDate.atStartOfDay()
val ysd = today.minusDays(1L)
val tmr = today.plusDays(1L)

// Set to 19:00:00 of yesterday
val ysdNight = ysd.withHour(19).withMinute(0).withSecond(0)
// Default: lastModified from yesterday 19:00 (aligns with nightly DO2 expectation).
// On Sunday, yesterday is Saturday: use 03:00 instead so we include DO changed after Sat 03:10 DO1
// (otherwise Sat 03:00–18:59 would be skipped until a much later sync).
val isSundayDo2 = runDate.dayOfWeek == DayOfWeek.SUNDAY
val modifiedFromStart = if (isSundayDo2) {
ysd.withHour(3).withMinute(0).withSecond(0)
} else {
ysd.withHour(19).withMinute(0).withSecond(0)
}

// Set to 11:00:00 of today
val todayEleven = today.withHour(11).withMinute(0).withSecond(0)
val todayEleven = today.withHour(11).withMinute(0).withSecond(0)

logger.info(
"DO2 modifiedDateFrom={} ({}), modifiedDateTo={}",
modifiedFromStart.format(dateTimeStringFormat),
if (isSundayDo2) "Sunday window from Sat 03:00" else "from yesterday 19:00",
todayEleven.format(dateTimeStringFormat),
)

val requestDO = M18CommonRequest(
// These will now produce "yyyy-MM-dd HH:mm:ss"
dDateTo = tmr.format(dateTimeStringFormat), // e.g. 2026-01-19 00:00:00
dDateFrom = tmr.format(dateTimeStringFormat), // e.g. 2026-01-19 00:00:00
modifiedDateTo = todayEleven.format(dateTimeStringFormat), // 2026-01-18 11:00:00
modifiedDateFrom = ysdNight.format(dateTimeStringFormat) // 2026-01-17 19:00:00
modifiedDateFrom = modifiedFromStart.format(dateTimeStringFormat),
)
val result = m18DeliveryOrderService.saveDeliveryOrders(requestDO)


正在加载...
取消
保存