fix:bug
This commit is contained in:
parent
5ab82f8883
commit
0de89da6f6
|
@ -82,14 +82,14 @@ public class NumUtil {
|
|||
.doubleValue());
|
||||
}
|
||||
|
||||
public static boolean compare(Number current, Number threshold, String op){
|
||||
public static boolean compare(Number current, Double threshold, String op){
|
||||
boolean cNull = ObjectUtil.isNull(current);
|
||||
boolean tNull = ObjectUtil.isNull(threshold);
|
||||
if (cNull || tNull) return false;
|
||||
|
||||
if (current instanceof Double && threshold instanceof Double){
|
||||
if (current instanceof Double){
|
||||
double currentV = (double) current;
|
||||
double thresholdV = (double) threshold;
|
||||
double thresholdV = threshold;
|
||||
|
||||
if (EQ.getOp().equals(op)){
|
||||
return currentV == thresholdV;
|
||||
|
@ -104,9 +104,9 @@ public class NumUtil {
|
|||
}else {
|
||||
return false;
|
||||
}
|
||||
} else if (current instanceof Integer && threshold instanceof Double) {
|
||||
} else if (current instanceof Integer) {
|
||||
int currentV = (int) current;
|
||||
int thresholdV = (int) threshold;
|
||||
int thresholdV = threshold.intValue();
|
||||
|
||||
if (EQ.getOp().equals(op)){
|
||||
return currentV == thresholdV;
|
||||
|
|
|
@ -12,7 +12,7 @@ public class Rule implements Serializable {
|
|||
|
||||
private String operator; // 比较符
|
||||
|
||||
private Number threshold; // 阈值
|
||||
private Double threshold; // 阈值
|
||||
|
||||
private String units; // 单位
|
||||
}
|
||||
|
|
|
@ -90,7 +90,7 @@ public class DatabaseJob extends Monitor implements Job{
|
|||
ObjectMapper mapper = new ObjectMapper();
|
||||
Rule rule = mapper.readValue(operator, Rule.class);
|
||||
String op = rule.getOperator();
|
||||
Number threshold = rule.getThreshold();
|
||||
Double threshold = rule.getThreshold();
|
||||
boolean needWarn = NumUtil.compare(current, threshold, op);
|
||||
if (needWarn){
|
||||
// 记录报警日志
|
||||
|
|
|
@ -85,7 +85,7 @@ public class ServerJob extends Monitor implements Job {
|
|||
ObjectMapper mapper = new ObjectMapper();
|
||||
Rule rule = mapper.readValue(operator, Rule.class);
|
||||
String op = rule.getOperator();
|
||||
Number threshold = rule.getThreshold();
|
||||
Double threshold = rule.getThreshold();
|
||||
boolean needWarn = NumUtil.compare(current, threshold, op);
|
||||
if (needWarn){
|
||||
// 记录报警日志
|
||||
|
|
Loading…
Reference in New Issue
Block a user