Browse Source

Merge branch 'V2.0.1' into test

zhaoxian 3 years ago
parent
commit
ee682b9353

+ 24 - 12
jeecg-boot-module-system/src/main/java/cn/com/ctop/alarm/modules/service/impl/RuleGroupServiceImpl.java

@@ -803,8 +803,14 @@ public class RuleGroupServiceImpl extends ServiceImpl<RuleGroupMapper, RuleGroup
             if ("price".equals(operationValue)) {
                 if ("up".equals(operationType)) {
                     value = goal.add(threshold);
+                    if (value.compareTo(maxValue) == 1) {
+                        value = maxValue;
+                    }
                 } else if ("down".equals(operationType)) {
                     value = goal.subtract(threshold);
+                    if (value.compareTo(minValue) == -1) {
+                        value = minValue;
+                    }
                 } else if ("to".equals(operationType)) {
                     value = threshold;
                 }
@@ -812,18 +818,18 @@ public class RuleGroupServiceImpl extends ServiceImpl<RuleGroupMapper, RuleGroup
                 //操作百分数
                 if ("up".equals(operationType)) {
                     value = goal.add(goal.multiply(threshold));
+                    if (value.compareTo(maxValue) == 1) {
+                        value = maxValue;
+                    }
                 } else if ("down".equals(operationType)) {
                     value = goal.subtract(goal.multiply(threshold));
+                    if (value.compareTo(minValue) == -1) {
+                        value = minValue;
+                    }
                 } else if ("to".equals(operationType)) {
                     value = goal.multiply(threshold);
                 }
             }
-            if (value.compareTo(maxValue) == 1) {
-                value = maxValue;
-            }
-            if (value.compareTo(minValue) == -1) {
-                value = minValue;
-            }
             return value.longValue();
         } else {
             goal = goal.divide(new BigDecimal("1000"));
@@ -831,8 +837,14 @@ public class RuleGroupServiceImpl extends ServiceImpl<RuleGroupMapper, RuleGroup
             if ("price".equals(operationValue)) {
                 if ("up".equals(operationType)) {
                     value = goal.add(threshold);
+                    if (value.compareTo(maxValue) == 1) {
+                        value = maxValue;
+                    }
                 } else if ("down".equals(operationType)) {
                     value = goal.subtract(threshold);
+                    if (value.compareTo(minValue) == -1) {
+                        value = minValue;
+                    }
                 } else if ("to".equals(operationType)) {
                     value = threshold;
                 }
@@ -840,18 +852,18 @@ public class RuleGroupServiceImpl extends ServiceImpl<RuleGroupMapper, RuleGroup
                 //操作百分数
                 if ("up".equals(operationType)) {
                     value = goal.add(goal.multiply(threshold));
+                    if (value.compareTo(maxValue) == 1) {
+                        value = maxValue;
+                    }
                 } else if ("down".equals(operationType)) {
                     value = goal.subtract(goal.multiply(threshold));
+                    if (value.compareTo(minValue) == -1) {
+                        value = minValue;
+                    }
                 } else if ("to".equals(operationType)) {
                     value = goal.multiply(threshold);
                 }
             }
-            if (value.compareTo(maxValue) == 1) {
-                value = maxValue;
-            }
-            if (value.compareTo(minValue) == -1) {
-                value = minValue;
-            }
             return value.multiply(new BigDecimal("1000")).longValue();
         }
     }