Ver Fonte

规则引擎,修改bug

zhaoxian há 3 anos atrás
pai
commit
3a81a4aa72

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

@@ -530,7 +530,12 @@ public class RuleGroupServiceImpl extends ServiceImpl<RuleGroupMapper, RuleGroup
                     }
                     Long newBid = 0L;
                     if ("to".equals(operationType)) {
-                        newBid = new BigDecimal(operationThreshold).multiply(new BigDecimal(1000 + "")).longValue();
+                        //金额直接赋值
+                        if ("price".equals(operationValue)) {
+                            newBid = new BigDecimal(operationThreshold).multiply(new BigDecimal(1000 + "")).longValue();
+                        } else {//百分比需计算
+                            newBid = new BigDecimal(operationThreshold).multiply(oldBid).longValue();
+                        }
                     } else {
                         newBid = calculatedValue(oldBid, operationType, operationValue, operationThreshold, maxValue, minValue);
                     }
@@ -552,7 +557,12 @@ public class RuleGroupServiceImpl extends ServiceImpl<RuleGroupMapper, RuleGroup
                     }
                     Long newBudget = 0L;
                     if ("to".equals(operationType)) {
-                        newBudget = new BigDecimal(operationThreshold).multiply(new BigDecimal(1000 + "")).longValue();
+                        //金额直接赋值
+                        if ("price".equals(operationValue)) {
+                            newBudget = new BigDecimal(operationThreshold).multiply(new BigDecimal(1000 + "")).longValue();
+                        } else {//百分比需计算
+                            newBudget = new BigDecimal(operationThreshold).multiply(oldBudget).longValue();
+                        }
                     } else {
                         newBudget = calculatedValue(oldBudget, operationType, operationValue, operationThreshold, maxValue, minValue);
                     }
@@ -603,7 +613,12 @@ public class RuleGroupServiceImpl extends ServiceImpl<RuleGroupMapper, RuleGroup
                     }
                     Long newBid = 0L;
                     if ("to".equals(operationType)) {
-                        newBid = new BigDecimal(operationThreshold).multiply(new BigDecimal(1000 + "")).longValue();
+                        //金额直接赋值
+                        if ("price".equals(operationValue)) {
+                            newBid = new BigDecimal(operationThreshold).multiply(new BigDecimal(1000 + "")).longValue();
+                        } else {//百分比需计算
+                            newBid = new BigDecimal(operationThreshold).multiply(oldBidDecimal).longValue();
+                        }
                     } else {
                         newBid = calculatedValue(oldBidDecimal, operationType, operationValue, operationThreshold, maxValue, minValue);
                     }
@@ -645,7 +660,12 @@ public class RuleGroupServiceImpl extends ServiceImpl<RuleGroupMapper, RuleGroup
                     }
                     Long newBudget = 0L;
                     if ("to".equals(operationType)) {
-                        newBudget = new BigDecimal(operationThreshold).multiply(new BigDecimal(1000 + "")).longValue();
+                        //金额直接赋值
+                        if ("price".equals(operationValue)) {
+                            newBudget = new BigDecimal(operationThreshold).multiply(new BigDecimal(1000 + "")).longValue();
+                        } else {//百分比需计算
+                            newBudget = new BigDecimal(operationThreshold).multiply(oldBudgetDecimal).longValue();
+                        }
                     } else {
                         newBudget = calculatedValue(oldBudgetDecimal, operationType, operationValue, operationThreshold, maxValue, minValue);
                     }
@@ -1621,6 +1641,7 @@ public class RuleGroupServiceImpl extends ServiceImpl<RuleGroupMapper, RuleGroup
                     RuleBase ruleBase = new RuleBase();
                     ruleBase.setRuleName(ruleDetailJson.getString("ruleName"));
                     ruleBase.setIndicatorCode(ruleDetailJson.getString("indicatorCode"));
+                    ruleBase.setCindicatorCode(ruleDetailJson.getString("cindicatorCode"));
                     ruleBase.setRuleCondition(ruleDetailJson.getString("ruleCondition"));
                     ruleBase.setThreshold(ruleDetailJson.getString("threshold"));
                     ruleBase.setVariableType(ruleDetailJson.getInteger("variableType"));