From 55e176096eb8caa2fc7c86b5e29441a82801278e Mon Sep 17 00:00:00 2001 From: huangfeng Date: Fri, 23 Aug 2024 09:07:33 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=B0=83=E6=95=B4=E5=AE=9A=E6=97=B6?= =?UTF-8?q?=E7=BB=9F=E8=AE=A1=E4=BB=BB=E5=8A=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../timeTask/MntnDayStatTask.java | 38 +++++++++++-------- 1 file changed, 22 insertions(+), 16 deletions(-) diff --git a/xymanager_framework/src/main/java/com/shxy/xymanager_framework/timeTask/MntnDayStatTask.java b/xymanager_framework/src/main/java/com/shxy/xymanager_framework/timeTask/MntnDayStatTask.java index 6098c51..971fe27 100644 --- a/xymanager_framework/src/main/java/com/shxy/xymanager_framework/timeTask/MntnDayStatTask.java +++ b/xymanager_framework/src/main/java/com/shxy/xymanager_framework/timeTask/MntnDayStatTask.java @@ -5,6 +5,7 @@ import com.shxy.xymanager_common.util.DateUtil; import com.shxy.xymanager_service.service.MntnDayStatService; import com.shxy.xymanager_service.service.NewCacheService; import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Value; import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Service; @@ -22,24 +23,29 @@ public class MntnDayStatTask { @Resource NewCacheService newCacheService; - @Scheduled(cron = "0 0 10 * * ?") - private void storeAll() { - try { - long total = dayStatService.countTotal(); - int days = 3; - if (total <= 0) { - days = 365; - } - Date today = DateUtil.getTodayZero(); + @Value("${maintain.check}") + private boolean needCheck; - Map terminalMap = newCacheService.getTerminalMap(); - Iterator it = terminalMap.keySet().iterator(); - while (it.hasNext()) { - Integer termId = it.next(); - this.storeOne(termId, today, days); + @Scheduled(cron = "0 0 12 * * ?") + private void storeAll() { + if (needCheck) { + try { + long total = dayStatService.countTotal(); + int days = 3; + if (total <= 0) { + days = 365; + } + Date today = DateUtil.getTodayZero(); + + Map terminalMap = newCacheService.getTerminalMap(); + Iterator it = terminalMap.keySet().iterator(); + while (it.hasNext()) { + Integer termId = it.next(); + this.storeOne(termId, today, days); + } + } catch (Exception e) { + log.error("MntnDayStatTask.storeAll error.", e); } - } catch (Exception e) { - log.error("MntnDayStatTask.storeAll error.", e); } }