fix: 调整定时统计任务

dev
huangfeng 10 months ago
parent 2306b92671
commit 55e176096e

@ -5,6 +5,7 @@ import com.shxy.xymanager_common.util.DateUtil;
import com.shxy.xymanager_service.service.MntnDayStatService; import com.shxy.xymanager_service.service.MntnDayStatService;
import com.shxy.xymanager_service.service.NewCacheService; import com.shxy.xymanager_service.service.NewCacheService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Scheduled; import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -22,24 +23,29 @@ public class MntnDayStatTask {
@Resource @Resource
NewCacheService newCacheService; NewCacheService newCacheService;
@Scheduled(cron = "0 0 10 * * ?") @Value("${maintain.check}")
private void storeAll() { private boolean needCheck;
try {
long total = dayStatService.countTotal();
int days = 3;
if (total <= 0) {
days = 365;
}
Date today = DateUtil.getTodayZero();
Map<Integer, Terminals> terminalMap = newCacheService.getTerminalMap(); @Scheduled(cron = "0 0 12 * * ?")
Iterator<Integer> it = terminalMap.keySet().iterator(); private void storeAll() {
while (it.hasNext()) { if (needCheck) {
Integer termId = it.next(); try {
this.storeOne(termId, today, days); long total = dayStatService.countTotal();
int days = 3;
if (total <= 0) {
days = 365;
}
Date today = DateUtil.getTodayZero();
Map<Integer, Terminals> terminalMap = newCacheService.getTerminalMap();
Iterator<Integer> 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);
} }
} }

Loading…
Cancel
Save