|
@@ -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;
|
|
@@ -88,6 +96,7 @@ public class RuleTemplateServiceImpl extends ServiceImpl<RuleTemplateMapper, Rul
|
|
|
RuleBase ruleBase = new RuleBase();
|
|
|
ruleBase.setRuleName(ruleDetailJson.getString("ruleName"));
|
|
|
ruleBase.setIndicatorCode(ruleDetailJson.getString("indicatorCode"));
|
|
|
+ ruleBase.setCindicatorCode(Check.isNull(ruleDetailJson.getString("cindicatorCode")) ? ruleDetailJson.getString("indicatorCode") : ruleDetailJson.getString("cindicatorCode"));
|
|
|
ruleBase.setRuleCondition(ruleDetailJson.getString("ruleCondition"));
|
|
|
ruleBase.setThreshold(ruleDetailJson.getString("threshold"));
|
|
|
ruleBase.setVariableType(ruleDetailJson.getInteger("variableType"));
|
|
@@ -110,6 +119,9 @@ public class RuleTemplateServiceImpl extends ServiceImpl<RuleTemplateMapper, Rul
|
|
|
ruleGroup.setIsRequired(ruleGroupJson.getInteger("isRequired"));
|
|
|
ruleGroup.setSendType(ruleGroupJson.getString("sendType"));
|
|
|
ruleGroup.setOperate(ruleGroupJson.getString("operate"));
|
|
|
+ ruleGroup.setOperation(ruleGroupJson.getInteger("operation"));
|
|
|
+ ruleGroup.setOperationType(ruleGroupJson.getString("operationType"));
|
|
|
+ ruleGroup.setOperationValue(ruleGroupJson.getString("operationValue"));
|
|
|
boolean save = ruleGroupService.save(ruleGroup);
|
|
|
if (save) {
|
|
|
String ruleIdsArrStr = ruleGroup.getRuleIds();
|
|
@@ -196,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;
|
|
@@ -212,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());
|
|
@@ -227,7 +243,7 @@ public class RuleTemplateServiceImpl extends ServiceImpl<RuleTemplateMapper, Rul
|
|
|
indicatorQueryWrapper.last("limit 1");
|
|
|
RuleIndicator ruleIndicator = ruleIndicatorService.getOne(indicatorQueryWrapper);
|
|
|
if (!Check.isNull(ruleIndicator)) {
|
|
|
- ruleJson.put("dataType", ruleIndicator.getDataType());
|
|
|
+ ruleJson.put("dataType", ruleIndicator.getConditionType());
|
|
|
ruleJson.put("dictId", ruleIndicator.getDictId());
|
|
|
ruleJson.put("dataUnit", ruleIndicator.getDataUnit());
|
|
|
ruleJson.put("name", ruleIndicator.getName());
|
|
@@ -286,6 +302,19 @@ 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());
|
|
|
+ QueryWrapper<RuleAccountThreshold> wrapper = new QueryWrapper<>();
|
|
|
+ wrapper.eq("account_id", accountId);
|
|
|
+ wrapper.eq("group_id", groupId);
|
|
|
+ wrapper.orderByDesc("operation_threshold").last("limit 1");
|
|
|
+ RuleAccountThreshold thresholds = accountThresholdService.getOne(wrapper); // 查询基础规则绑定的阈值
|
|
|
+ if (!Check.isNull(thresholds)) {
|
|
|
+ groupJson.put("operationThreshold", thresholds.getOperationThreshold());
|
|
|
+ groupJson.put("maxValue", thresholds.getMaxValue());
|
|
|
+ groupJson.put("minValue", thresholds.getMinValue());
|
|
|
+ }
|
|
|
JSONArray ruleDetail = new JSONArray();
|
|
|
|
|
|
if (group.getIsCopy() == 0) { // 规则不可复制
|
|
@@ -304,6 +333,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);
|
|
@@ -453,6 +483,19 @@ 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());
|
|
|
+ QueryWrapper<RuleAccountThreshold> wrapper = new QueryWrapper<>();
|
|
|
+// wrapper.eq("account_id", accountId);
|
|
|
+ wrapper.eq("group_id", groupId);
|
|
|
+ wrapper.orderByDesc("operation_threshold").last("limit 1");
|
|
|
+ RuleAccountThreshold thresholds = accountThresholdService.getOne(wrapper); // 查询基础规则绑定的阈值
|
|
|
+ if (!Check.isNull(thresholds)) {
|
|
|
+ groupJson.put("operationThreshold", thresholds.getOperationThreshold());
|
|
|
+ groupJson.put("maxValue", thresholds.getMaxValue());
|
|
|
+ groupJson.put("minValue", thresholds.getMinValue());
|
|
|
+ }
|
|
|
JSONArray ruleIds = JSONArray.parseArray(group.getRuleIds());
|
|
|
if (Check.isNull(ruleIds)) {
|
|
|
continue;
|
|
@@ -470,6 +513,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());
|