|
|
|
@ -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");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|