Prechádzať zdrojové kódy

规则引擎,修改bug

zhaoxian 3 rokov pred
rodič
commit
cc9d1cce5d

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

@@ -508,6 +508,7 @@ public class RuleGroupServiceImpl extends ServiceImpl<RuleGroupMapper, RuleGroup
             String maxValue = Check.isNull(thresholdJson.getString("maxValue")) ? "-1" : thresholdJson.getString("maxValue");
             String minValue = Check.isNull(thresholdJson.getString("minValue")) ? "-1" : thresholdJson.getString("minValue");
 
+
             if (type == 1 || type == 3) {
                 Long planId = obj.getLong("planId");//头条
                 if (Check.isNull(planId)) {
@@ -593,17 +594,18 @@ public class RuleGroupServiceImpl extends ServiceImpl<RuleGroupMapper, RuleGroup
                 if ("BID".equals(operate)) {
                     Integer bidType = kuaiShouGroup.getBidType();
                     Long oldBid = Check.isNull(kuaiShouGroup.getBid()) ? 0L : kuaiShouGroup.getBid();
+                    BigDecimal oldBidDecimal = new BigDecimal(oldBid.toString());
                     if (bidType == 10) {
-                        oldBid = kuaiShouGroup.getCpaBid();
+                        oldBidDecimal = new BigDecimal(String.valueOf(kuaiShouGroup.getCpaBid()));
                     }
-                    if (("up".equals(operationType) && oldBid - Long.valueOf(maxValue) == 0) || ("down".equals(operationType) && oldBid - Long.valueOf(minValue) == 0)) {
+                    if (("up".equals(operationType) && oldBidDecimal.compareTo(new BigDecimal(maxValue)) == 0) || ("down".equals(operationType) && oldBidDecimal.compareTo(new BigDecimal(minValue)) == 0)) {
                         continue;
                     }
                     Long newBid = 0L;
                     if ("to".equals(operationType)) {
                         newBid = new BigDecimal(operationThreshold).multiply(new BigDecimal(1000 + "")).longValue();
                     } else {
-                        newBid = calculatedValue(new BigDecimal(oldBid.toString()), operationType, operationValue, operationThreshold, maxValue, minValue);
+                        newBid = calculatedValue(oldBidDecimal, operationType, operationValue, operationThreshold, maxValue, minValue);
                     }
                     JSONObject unitJson = new JSONObject();
                     unitJson.put("advertiser_id", accountId);
@@ -637,14 +639,15 @@ public class RuleGroupServiceImpl extends ServiceImpl<RuleGroupMapper, RuleGroup
                     //修改预算
                 } else if ("BUDGET".equals(operate)) {
                     Long oldBudget = Check.isNull(kuaiShouGroup.getDayBudget()) ? 0L : kuaiShouGroup.getDayBudget();
-                    if (("up".equals(operationType) && oldBudget - Long.valueOf(maxValue) == 0) || ("down".equals(operationType) && oldBudget - Long.valueOf(minValue) == 0)) {
+                    BigDecimal oldBudgetDecimal = new BigDecimal(oldBudget.toString());
+                    if (("up".equals(operationType) && oldBudgetDecimal.compareTo(new BigDecimal(maxValue)) == 0) || ("down".equals(operationType) && oldBudgetDecimal.compareTo(new BigDecimal(minValue)) == 0)) {
                         continue;
                     }
                     Long newBudget = 0L;
                     if ("to".equals(operationType)) {
                         newBudget = new BigDecimal(operationThreshold).multiply(new BigDecimal(1000 + "")).longValue();
                     } else {
-                        newBudget = calculatedValue(new BigDecimal(oldBudget.toString()), operationType, operationValue, operationThreshold, maxValue, minValue);
+                        newBudget = calculatedValue(oldBudgetDecimal, operationType, operationValue, operationThreshold, maxValue, minValue);
                     }
                     Map<String, Object> updateMap = kuaiShouUpdateService.updateUnitDayBudget(token.getAccessToken(), accountId, unitId, newBudget, "规则引擎修改预算");
                     String message = "success";
@@ -803,7 +806,7 @@ public class RuleGroupServiceImpl extends ServiceImpl<RuleGroupMapper, RuleGroup
         if (value.compareTo(minValue) == -1) {
             value = minValue;
         }
-        return value.longValue();
+        return value.multiply(new BigDecimal(1000 + "")).longValue();
     }
 
     /**
@@ -1668,6 +1671,8 @@ public class RuleGroupServiceImpl extends ServiceImpl<RuleGroupMapper, RuleGroup
                 ruleGroup.setOperate(groupJson.getString("operate"));
                 ruleGroup.setSendType(groupJson.getString("sendType"));
                 ruleGroup.setOperation(groupJson.getInteger("operation"));
+                ruleGroup.setOperationType(groupJson.getString("operationType"));
+                ruleGroup.setOperationValue(groupJson.getString("operationValue"));
                 boolean save = ruleGroupService.save(ruleGroup); // 新增规则组
                 if (save) {
                     for (int j = 0; j < ruleIds.size(); j++) {