From 0de89da6f63050b745f6cb57335c2757feb3aafc Mon Sep 17 00:00:00 2001 From: nieziyan Date: Tue, 21 Nov 2023 19:15:29 +0800 Subject: [PATCH] =?UTF-8?q?fix=EF=BC=9Abug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/org/jeecg/common/util/NumUtil.java | 10 +++++----- .../main/java/org/jeecg/modules/base/entity/Rule.java | 2 +- .../java/org/jeecg/modules/quartz/job/DatabaseJob.java | 2 +- .../java/org/jeecg/modules/quartz/job/ServerJob.java | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/NumUtil.java b/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/NumUtil.java index f2499df8..9c64c389 100644 --- a/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/NumUtil.java +++ b/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/NumUtil.java @@ -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; diff --git a/jeecg-boot-base-core/src/main/java/org/jeecg/modules/base/entity/Rule.java b/jeecg-boot-base-core/src/main/java/org/jeecg/modules/base/entity/Rule.java index 334f9c84..0e8a3da3 100644 --- a/jeecg-boot-base-core/src/main/java/org/jeecg/modules/base/entity/Rule.java +++ b/jeecg-boot-base-core/src/main/java/org/jeecg/modules/base/entity/Rule.java @@ -12,7 +12,7 @@ public class Rule implements Serializable { private String operator; // 比较符 - private Number threshold; // 阈值 + private Double threshold; // 阈值 private String units; // 单位 } diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/quartz/job/DatabaseJob.java b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/quartz/job/DatabaseJob.java index 1c8ba2b6..10a9a009 100644 --- a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/quartz/job/DatabaseJob.java +++ b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/quartz/job/DatabaseJob.java @@ -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){ // 记录报警日志 diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/quartz/job/ServerJob.java b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/quartz/job/ServerJob.java index 01b3dc3a..83b9cb83 100644 --- a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/quartz/job/ServerJob.java +++ b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/quartz/job/ServerJob.java @@ -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){ // 记录报警日志