perf: 设置一天只发一个触发

dev
huangfeng 12 months ago
parent ac83b310cb
commit 5504168578

@ -1,18 +1,24 @@
package com.xydl.cac.comparator;
import com.xydl.cac.exception.BusinessException;
import java.util.Date;
import java.util.LinkedHashMap;
public class MissCompare extends Comparator {
// 一天触发一次
boolean done = false;
@Override
public boolean compare(Object source, String threshold, Date lastDTime) {
if (source == null && lastDTime != null) {
if (!done && source == null && lastDTime != null) {
long t2 = Long.parseLong(threshold);
long last = System.currentTimeMillis() - lastDTime.getTime();
hours = last / 1000 / 60 / 60;
if (hours >= t2) {
done = true;
return true;
}
}
@ -28,6 +34,10 @@ public class MissCompare extends Comparator {
@Override
public void valid(String operator, String threshold) throws Exception {
Integer hours = Integer.parseInt(threshold);
if (hours <= 1) {
throw new BusinessException("阈值必须大于1");
}
}
}

@ -27,7 +27,7 @@ public class CacheTask {
public static List<Zsb> zsb_Cache = null;
public static ConcurrentHashMap<Integer, WarnRule> rule_Cache = new ConcurrentHashMap<>();
@Scheduled(cron = "0 1 * * * ?")
@Scheduled(cron = "0 9 * * * ?")
private void clearCache() {
unit_Cache.clear();
modevType_Cache = null;

Loading…
Cancel
Save