|
@@ -1,13 +1,11 @@
|
|
|
package com.sundata.internalevaluation.calc.calcUnit;
|
|
|
|
|
|
-import cn.hutool.extra.spring.SpringUtil;
|
|
|
import com.sundata.internalevaluation.calc.model.CalcResult;
|
|
|
import com.sundata.internalevaluation.calc.model.CalcUnit;
|
|
|
import com.sundata.internalevaluation.calc.model.finals.CalcType;
|
|
|
import com.sundata.internalevaluation.configuration.model.SysReqRule;
|
|
|
import com.sundata.internalevaluation.configuration.model.SysReqRules;
|
|
|
import com.sundata.internalevaluation.configuration.service.SysReqRuleService;
|
|
|
-import com.sundata.internalevaluation.configuration.service.SysReqRulesService;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
|
@@ -103,8 +101,8 @@ public class RulesCalcUnit extends CalcUnit {
|
|
|
public List<CalcUnit> getSourceCalcUnits() {
|
|
|
List<SysReqRule> sysReqRules = sysReqRuleService.selectRuleListByRulesNo(reqRules.getRulesNo());
|
|
|
return sysReqRules.stream()
|
|
|
- .map(rule-> new RuleCalcUnit(rule.getRuleNo(),rule.getRuleName(),
|
|
|
- CalcType.RULE, Map.of("age",15), rule)).collect(Collectors.toList());
|
|
|
+ .map(rule -> new RuleCalcUnit(rule.getRuleNo(), rule.getRuleName(),
|
|
|
+ CalcType.RULE, Map.of(), rule)).collect(Collectors.toList());
|
|
|
|
|
|
}
|
|
|
|
|
@@ -132,7 +130,7 @@ public class RulesCalcUnit extends CalcUnit {
|
|
|
/**
|
|
|
* 必须实现的主体计算内容
|
|
|
*
|
|
|
- * @param context 节点计算参数清单
|
|
|
+ * @param context 节点计算参数清单
|
|
|
* @param sourceResults 源头计算节点的结果
|
|
|
*/
|
|
|
@Override
|
|
@@ -141,33 +139,47 @@ public class RulesCalcUnit extends CalcUnit {
|
|
|
Map<String, Object> context,
|
|
|
Map<CalcUnit, CalcResult<String, Object>> sourceResults) {
|
|
|
|
|
|
- Map<Object, List<CalcUnit>> collect = sourceResults.entrySet().stream()
|
|
|
- .collect(Collectors.groupingBy(
|
|
|
- s -> s.getValue().get(s.getKey().getCalcCode()),
|
|
|
- Collectors.mapping(Map.Entry::getKey, Collectors.toList()))
|
|
|
- );
|
|
|
-
|
|
|
- List<CalcUnit> intercept = collect.get("intercept");
|
|
|
- StringBuilder sb = new StringBuilder();
|
|
|
- if (intercept != null && !intercept.isEmpty()) {
|
|
|
- sb.append("触发拦截规则:\n");
|
|
|
- intercept.forEach(a -> {
|
|
|
- sb.append(" ·").append(a.getCalcCode()).append("-").append(a.getCalcName()).append("\n");
|
|
|
- });
|
|
|
- thisResult.put(this.getCalcCode(),sb.toString());
|
|
|
+ log.debug("计算{}:编号:{},名称:{},流水号:{}", getCalcType().getName(),getCalcCode(),getCalcName(),calculateInstanceNumber);
|
|
|
+
|
|
|
+ // 规则结果为 true 的规则
|
|
|
+ List<Map.Entry<CalcUnit, CalcResult<String, Object>>> resIsTrue = sourceResults.entrySet().stream()
|
|
|
+ .filter(entry -> entry.getValue().get(entry.getKey().getCalcCode()).equals(true))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+
|
|
|
+ //
|
|
|
+ Map<String, List<SysReqRule>> ruleListMap = resIsTrue.stream()
|
|
|
+ .collect(Collectors.groupingBy(e1 -> {
|
|
|
+ SysReqRule o = (SysReqRule) e1.getValue().get("entity");
|
|
|
+ return o.getRuleResult();
|
|
|
+ }, Collectors.mapping(e ->
|
|
|
+ (SysReqRule) e.getValue().get("entity"), Collectors.toList()
|
|
|
+ )));
|
|
|
+
|
|
|
+
|
|
|
+ List<SysReqRule> interceptRuleList = ruleListMap.get("intercept");
|
|
|
+ List<SysReqRule> warnRuleList = ruleListMap.get("warn");
|
|
|
+
|
|
|
+ if (interceptRuleList != null && !interceptRuleList.isEmpty()) {
|
|
|
+ // 存在拦截的规则
|
|
|
+ // TODO 拦截处理
|
|
|
+ List<String> resList = interceptRuleList.stream().map(rule -> String.format("【%s】%s 触发 %s", rule.getRuleNo(), rule.getRuleName(), "拦截")).collect(Collectors.toList());
|
|
|
+ thisResult.put(getCalcCode(),resList);
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- List<CalcUnit> warn = collect.get("warn");
|
|
|
- if (warn != null && !warn.isEmpty()) {
|
|
|
- sb.append("触发预警规则:\n");
|
|
|
- warn.forEach(a -> {
|
|
|
- sb.append(" ·").append(a.getCalcCode()).append("-").append(a.getCalcName()).append("\n");
|
|
|
- });
|
|
|
- thisResult.put(this.getCalcCode(),sb.toString());
|
|
|
+
|
|
|
+
|
|
|
+ if (warnRuleList != null && !warnRuleList.isEmpty()) {
|
|
|
+ // 存在预警的规则
|
|
|
+ // TODO 预警处理
|
|
|
+ List<String> resList = warnRuleList.stream().map(rule -> String.format("【%s】%s 触发 %s", rule.getRuleNo(), rule.getRuleName(), "预警")).collect(Collectors.toList());
|
|
|
+ thisResult.put(getCalcCode(),resList);
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- thisResult.put(this.getCalcCode(),"规则集未拦截");
|
|
|
+
|
|
|
+ // 无拦截和预警
|
|
|
+ thisResult.put(this.getCalcCode(), "无拦截");
|
|
|
+
|
|
|
}
|
|
|
}
|