Просмотр исходного кода

预警规则匹配逻辑——调试优化

zhaoxian 4 лет назад
Родитель
Сommit
32083c6610

+ 6 - 3
module-alarm/src/main/java/cn/com/ctop/alarm/modules/constant/MatchLogic.java

@@ -32,6 +32,9 @@ public class MatchLogic {
     public static boolean matchCondition(String type, String condition, String threshold, String value) {
         try {
             if ("number".equals(type)) {
+                if (Check.isNull(threshold) || Check.isNull(value)) {
+                    return false;
+                }
                 BigDecimal bigThr = new BigDecimal(threshold);
                 BigDecimal bigVal = new BigDecimal(value);
                 switch (condition) {
@@ -87,7 +90,7 @@ public class MatchLogic {
                 }
             }
         } catch (Exception e) {
-            log.error("条件匹配", e);
+            log.error("条件匹配异常", e);
         }
         return false;
     }
@@ -101,7 +104,7 @@ public class MatchLogic {
                 append("预警账户:").append(accountId).append("<br/>");
         if (!Check.isNull(planId) && !Check.isNull(creativeId)) {
             header.append("预警计划:").append(planId).append("<br/>").append("预警创意:").append(creativeId).append("<br/>");
-        } else if (!Check.isNull(creativeId) && Check.isNull(creativeId)) {
+        } else if (!Check.isNull(planId) && Check.isNull(creativeId)) {
             header.append("预警计划:").append(planId).append("<br/>");
         } else if (!Check.isNull(creativeId)) {
             header.append("预警创意:").append(creativeId).append("<br/>");
@@ -129,7 +132,7 @@ public class MatchLogic {
                 ids.add(String.valueOf(id));
             }
         } catch (Exception e) {
-            log.error("ids格式转换异常", e);
+            log.error("数据({})转list异常", strings, e);
         }
         return ids;
     }

+ 27 - 3
module-alarm/src/main/java/cn/com/ctop/alarm/modules/controller/RuleGroupController.java

@@ -26,7 +26,15 @@ import org.jeecgframework.poi.excel.entity.ExportParams;
 import org.jeecgframework.poi.excel.entity.ImportParams;
 import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.*;
+import org.springframework.web.bind.annotation.DeleteMapping;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.PutMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
 import org.springframework.web.multipart.MultipartFile;
 import org.springframework.web.multipart.MultipartHttpServletRequest;
 import org.springframework.web.servlet.ModelAndView;
@@ -36,7 +44,11 @@ import javax.servlet.http.HttpServletResponse;
 import java.io.IOException;
 import java.io.UnsupportedEncodingException;
 import java.net.URLDecoder;
-import java.util.*;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
 
 /**
  * 规则组
@@ -74,7 +86,6 @@ public class RuleGroupController {
             if (Check.isNull(requestJson)) {
                 throw new Exception("请输出需要创建的参数");
             }
-
             JSONObject returnJson = ruleGroupService.createRuleGroup(requestJson);
             if (returnJson.getInteger("code") == 0) {
                 result.setSuccess(true);
@@ -186,6 +197,19 @@ public class RuleGroupController {
         return result;
     }
 
+    @GetMapping(value = "/checkRules")
+    public Result<RuleGroup> checkRules() {
+        Result<RuleGroup> result = new Result<>();
+        try {
+            ruleGroupService.checkRules();
+            result.success("成功!");
+        } catch (Exception e) {
+            log.error(e.getMessage(), e);
+            result.error500("操作失败");
+        }
+        return result;
+    }
+
     /**
      * 编辑
      *

+ 9 - 1
module-alarm/src/main/java/cn/com/ctop/alarm/modules/service/impl/RuleGroupServiceImpl.java

@@ -268,11 +268,19 @@ public class RuleGroupServiceImpl extends ServiceImpl<RuleGroupMapper, RuleGroup
         }
     }
 
+    /**
+     * 根据accountId获取人员对象
+     *
+     * @param
+     * @return com.alibaba.fastjson.JSONObject
+     * @throws
+     * @author ZHAOXA
+     */
     private JSONObject getUserByAccountId(Long accountId) {
         JSONObject obj = userObj.getJSONObject(accountId.toString());
         if (Check.isNull(obj)) {
             JSONObject user = sysUserMapper.selectUserByAccount(accountId);
-            obj.put(accountId.toString(), user);
+            userObj.put(accountId.toString(), user);
             return user;
         }
         return obj;