浏览代码

规则引擎2.0前后端交互代码

zhaoxian 3 年之前
父节点
当前提交
3757a83496

+ 23 - 2
jeecg-boot-module-system/src/main/java/cn/com/ctop/alarm/modules/service/impl/RuleTemplateServiceImpl.java

@@ -1,9 +1,17 @@
 package cn.com.ctop.alarm.modules.service.impl;
 
-import cn.com.ctop.alarm.modules.entity.*;
+import cn.com.ctop.alarm.modules.entity.RuleAccountThreshold;
+import cn.com.ctop.alarm.modules.entity.RuleBase;
+import cn.com.ctop.alarm.modules.entity.RuleGroup;
+import cn.com.ctop.alarm.modules.entity.RuleIndicator;
+import cn.com.ctop.alarm.modules.entity.RuleTemplate;
 import cn.com.ctop.alarm.modules.mapper.RuleBaseMapper;
 import cn.com.ctop.alarm.modules.mapper.RuleTemplateMapper;
-import cn.com.ctop.alarm.modules.service.*;
+import cn.com.ctop.alarm.modules.service.IRuleAccountThresholdService;
+import cn.com.ctop.alarm.modules.service.IRuleBaseService;
+import cn.com.ctop.alarm.modules.service.IRuleGroupService;
+import cn.com.ctop.alarm.modules.service.IRuleIndicatorService;
+import cn.com.ctop.alarm.modules.service.IRuleTemplateService;
 import cn.com.ctop.common.module.utils.Check;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
@@ -45,6 +53,7 @@ public class RuleTemplateServiceImpl extends ServiceImpl<RuleTemplateMapper, Rul
 
     /**
      * 创建规则模板
+     *
      * @param requestJson
      * @return
      */
@@ -199,6 +208,9 @@ public class RuleTemplateServiceImpl extends ServiceImpl<RuleTemplateMapper, Rul
                 groupJson.put("sendType", group.getSendType());
                 groupJson.put("isCopy", group.getIsCopy());
                 groupJson.put("isRequired", group.getIsRequired());
+                groupJson.put("operation", group.getOperation());
+                groupJson.put("operationType", group.getOperationType());
+                groupJson.put("operationValue", group.getOperationValue());
                 JSONArray ruleIds = JSONArray.parseArray(group.getRuleIds());
                 if (Check.isNull(ruleIds)) {
                     continue;
@@ -215,6 +227,7 @@ public class RuleTemplateServiceImpl extends ServiceImpl<RuleTemplateMapper, Rul
                     ruleJson.put("ruleName", ruleBase.getRuleName());
                     ruleJson.put("judgeFormat", ruleBase.getJudgeFormat());
                     ruleJson.put("indicatorCode", ruleBase.getIndicatorCode());
+                    ruleJson.put("cindicatorCode", ruleBase.getCindicatorCode());
                     ruleJson.put("ruleCondition", ruleBase.getRuleCondition());
                     ruleJson.put("threshold", ruleBase.getThreshold());
                     ruleJson.put("ruleDimension", ruleBase.getRuleDimension());
@@ -289,6 +302,9 @@ public class RuleTemplateServiceImpl extends ServiceImpl<RuleTemplateMapper, Rul
             groupJson.put("sendType", group.getSendType());
             groupJson.put("isCopy", group.getIsCopy());
             groupJson.put("isRequired", group.getIsRequired());
+            groupJson.put("operation", group.getOperation());
+            groupJson.put("operationType", group.getOperationType());
+            groupJson.put("operationValue", group.getOperationValue());
             JSONArray ruleDetail = new JSONArray();
 
             if (group.getIsCopy() == 0) { // 规则不可复制
@@ -307,6 +323,7 @@ public class RuleTemplateServiceImpl extends ServiceImpl<RuleTemplateMapper, Rul
                     ruleJson.put("ruleName", ruleBase.getRuleName());
                     ruleJson.put("judgeFormat", ruleBase.getJudgeFormat());
                     ruleJson.put("indicatorCode", ruleBase.getIndicatorCode());
+                    ruleJson.put("cindicatorCode", ruleBase.getCindicatorCode());
                     ruleJson.put("ruleCondition", ruleBase.getRuleCondition());
                     QueryWrapper<RuleAccountThreshold> accountThresholdQueryWrapper = new QueryWrapper<>();
                     accountThresholdQueryWrapper.eq("account_id", accountId);
@@ -456,6 +473,9 @@ public class RuleTemplateServiceImpl extends ServiceImpl<RuleTemplateMapper, Rul
             groupJson.put("sendType", group.getSendType());
             groupJson.put("isCopy", group.getIsCopy());
             groupJson.put("isRequired", group.getIsRequired());
+            groupJson.put("operation", group.getOperation());
+            groupJson.put("operationType", group.getOperationType());
+            groupJson.put("operationValue", group.getOperationValue());
             JSONArray ruleIds = JSONArray.parseArray(group.getRuleIds());
             if (Check.isNull(ruleIds)) {
                 continue;
@@ -473,6 +493,7 @@ public class RuleTemplateServiceImpl extends ServiceImpl<RuleTemplateMapper, Rul
                     ruleJson.put("ruleName", ruleBase.getRuleName());
                     ruleJson.put("judgeFormat", ruleBase.getJudgeFormat());
                     ruleJson.put("indicatorCode", ruleBase.getIndicatorCode());
+                    ruleJson.put("cindicatorCode", ruleBase.getCindicatorCode());
                     ruleJson.put("ruleCondition", ruleBase.getRuleCondition());
                     ruleJson.put("threshold", ruleBase.getThreshold());
                     ruleJson.put("ruleDimension", ruleBase.getRuleDimension());

+ 14 - 9
jeecg-boot-module-system/src/main/java/cn/com/ctop/common/module/service/impl/UserAllocationServiceImpl.java

@@ -3,6 +3,7 @@ package cn.com.ctop.common.module.service.impl;
 import cn.com.ctop.common.module.entity.UserAllocation;
 import cn.com.ctop.common.module.mapper.UserAllocationMapper;
 import cn.com.ctop.common.module.service.IUserAllocationService;
+import cn.com.ctop.common.module.utils.Check;
 import cn.com.ctop.common.module.utils.CtopAdConstant;
 import cn.com.ctop.common.module.utils.ResultMapUtils;
 import cn.com.ctop.common.module.utils.StatusCode;
@@ -159,8 +160,8 @@ public class UserAllocationServiceImpl extends ServiceImpl<UserAllocationMapper,
     }
 
     @Override
-    public List<UserAllocation> getAccountListByUserIdAndProductId(String userId, Long projectId,Long productId) {
-        return userAllocationMapper.getAccountListByUserIdAndProductId(userId,projectId,productId);
+    public List<UserAllocation> getAccountListByUserIdAndProductId(String userId, Long projectId, Long productId) {
+        return userAllocationMapper.getAccountListByUserIdAndProductId(userId, projectId, productId);
     }
 
     @Override
@@ -169,15 +170,19 @@ public class UserAllocationServiceImpl extends ServiceImpl<UserAllocationMapper,
         List list = new ArrayList();
         for (int i = 0; i < projectList.size(); i++) {
             JSONObject jsonObject = projectList.get(i);
-            list.add(jsonObject.getLong("projectId"));
-            map.put(jsonObject.getLong("projectId"), new ArrayList<>());
+            if (!Check.isNull(jsonObject)) {
+                list.add(jsonObject.getLong("projectId"));
+                map.put(jsonObject.getLong("projectId"), new ArrayList<>());
+            }
         }
         List<JSONObject> jsonList = userAllocationMapper.getAccountListByProjectList(list);
         for (int i = 0; i < jsonList.size(); i++) {
             JSONObject jsonObject = jsonList.get(i);
-            Long projectId = jsonObject.getLong("projectId");
-            List<JSONObject> jsonObjects = map.get(projectId);
-            jsonObjects.add(jsonObject);
+            if (!Check.isNull(jsonObject)) {
+                Long projectId = jsonObject.getLong("projectId");
+                List<JSONObject> jsonObjects = map.get(projectId);
+                jsonObjects.add(jsonObject);
+            }
         }
         return map;
     }
@@ -209,8 +214,8 @@ public class UserAllocationServiceImpl extends ServiceImpl<UserAllocationMapper,
 
     @Override
     public boolean updateProjectStrategyStatus(Long accountId, Integer projectStrategy) {
-        int num  = userAllocationMapper.updateProjectStrategyStatus(accountId, projectStrategy);
-        return num>0;
+        int num = userAllocationMapper.updateProjectStrategyStatus(accountId, projectStrategy);
+        return num > 0;
     }
 
     @Override

+ 6 - 4
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/ProjectMemberController.java

@@ -192,10 +192,12 @@ public class ProjectMemberController {
                 Map<Long, List<JSONObject>> accountMap = userAllocationService.getAccountListByProjectList(projectList);
                 for (int i = 0; i < projectList.size(); i++) {
                     JSONObject project = projectList.get(i);
-                    List<JSONObject> accountList = accountMap.get(project.getLong("projectId"));
-                    if (!Check.isNull(accountList)) {
-                        project.put("accountList", accountList);
-                        haveList.add(project);
+                    if (!Check.isNull(project)) {
+                        List<JSONObject> accountList = accountMap.get(project.getLong("projectId"));
+                        if (!Check.isNull(accountList)) {
+                            project.put("accountList", accountList);
+                            haveList.add(project);
+                        }
                     }
                 }
             }