fix: 控制器新增报警开关控制,过期提醒只在8:00~21:00打电话。
This commit is contained in:
@@ -10,6 +10,7 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.time.LocalTime;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@@ -35,6 +36,13 @@ public class DeviceExpirationWarnTask {
|
||||
@Scheduled(fixedDelay = 7200000)
|
||||
public void checkDeviceExpirationAndNotify() {
|
||||
try {
|
||||
// 只在 8:00 ~ 21:00 之间拨打电话通知,避免夜间打扰用户
|
||||
LocalTime currentTime = LocalTime.now();
|
||||
if (currentTime.isBefore(LocalTime.of(8, 0)) || !currentTime.isBefore(LocalTime.of(21, 0))) {
|
||||
log.debug("[到期告警] 当前时间 {} 不在电话通知时段(08:00~21:00),跳过本次扫描", currentTime);
|
||||
return;
|
||||
}
|
||||
|
||||
Date now = new Date();
|
||||
// 24小时后的时间点
|
||||
Date deadline = new Date(now.getTime() + 24L * 60 * 60 * 1000);
|
||||
|
||||
Reference in New Issue
Block a user