规则命中返回配置
This commit is contained in:
@@ -12,4 +12,5 @@ public class SessionData {
|
||||
private Long organId; // 组织id
|
||||
private Long engineId; // 引擎id
|
||||
private Integer reqType;//请求类型
|
||||
private Integer ruleHitRspConfig; // 规则命中返回配置,默认1(0:未命中不返回,1:未命中返回)
|
||||
}
|
||||
|
||||
@@ -272,10 +272,7 @@ public class RuleServiceImpl extends ServiceImpl<RuleInfoMapper, RuleInfo> imple
|
||||
|
||||
@Override
|
||||
public List<JSONObject> setComplexRuleOutput(Long versionId, Map<String,Object> temp, Map<String, Object> input, String outType) {
|
||||
List<JSONObject> jsonObjectList = outputService.setOutput(new StrategyOutput(versionId, StrategyType.COMPLEX_RULE,outType), temp);
|
||||
// for (JSONObject jsonObject : jsonObjectList) {
|
||||
// input.putAll(jsonObject);
|
||||
// }
|
||||
List<JSONObject> jsonObjectList = outputService.setOutput(new StrategyOutput(versionId, StrategyType.COMPLEX_RULE,outType), input, temp);
|
||||
return jsonObjectList;
|
||||
}
|
||||
|
||||
|
||||
@@ -24,5 +24,7 @@ public interface StrategyOutputService extends IService<StrategyOutput> {
|
||||
|
||||
List<JSONObject> setOutput(StrategyOutput entity, Map<String,Object> input);
|
||||
|
||||
List<JSONObject> setOutput(StrategyOutput entity, Map<String,Object> input, Map<String,Object> temp);
|
||||
|
||||
boolean judgeOutCondition(String condition,Map<String,Object> input);
|
||||
}
|
||||
|
||||
@@ -130,6 +130,11 @@ public class StrategyOutputServiceImpl extends ServiceImpl<StrategyOutputMapper,
|
||||
//设置输出,传入map向map中放入输出并且返回输出列表
|
||||
@Override
|
||||
public List<JSONObject> setOutput(StrategyOutput entity, Map<String, Object> input) {
|
||||
return setOutput(entity, input, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<JSONObject> setOutput(StrategyOutput entity, Map<String, Object> input, Map<String,Object> temp) {
|
||||
List<StrategyOutput> strategyOutputList = this.queryByTactics(entity);
|
||||
List<JSONObject> jsonList = new ArrayList<>();
|
||||
if (strategyOutputList != null && strategyOutputList.size() > 0) {
|
||||
@@ -161,6 +166,9 @@ public class StrategyOutputServiceImpl extends ServiceImpl<StrategyOutputMapper,
|
||||
if(!field.getIsLocalVariable()){
|
||||
input.put(fieldEn, value);
|
||||
}
|
||||
if(temp != null){
|
||||
temp.put(fieldEn, value);
|
||||
}
|
||||
jsonList.add(json);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,6 +42,7 @@ public class RiskEngineApi {
|
||||
sessionData.setOrganId(bizData.getOrganId());
|
||||
sessionData.setEngineId(bizData.getEngineId());
|
||||
sessionData.setReqType(1);
|
||||
sessionData.setRuleHitRspConfig(bizData.getRuleHitRspConfig());
|
||||
RunnerSessionManager.setSession(sessionData);
|
||||
|
||||
if(bizData.getFields() != null){
|
||||
|
||||
@@ -15,4 +15,5 @@ public class DecisionApiBizData {
|
||||
private Long organId; // 组织id
|
||||
private Long engineId; // 引擎id
|
||||
private Map<String, Object> fields; // 指标字段键值对
|
||||
private Integer ruleHitRspConfig; // 规则命中返回配置(0:未命中不返回,1:未命中返回)
|
||||
}
|
||||
|
||||
@@ -12,6 +12,8 @@ import com.fibo.ddp.common.model.strategyx.guiderule.vo.RuleBlockVo;
|
||||
import com.fibo.ddp.common.model.strategyx.guiderule.vo.RuleConditionVo;
|
||||
import com.fibo.ddp.common.model.strategyx.guiderule.vo.RuleVersionVo;
|
||||
import com.fibo.ddp.common.model.strategyx.scriptrule.RuleScriptVersion;
|
||||
import com.fibo.ddp.common.service.common.runner.RunnerSessionManager;
|
||||
import com.fibo.ddp.common.service.common.runner.SessionData;
|
||||
import com.fibo.ddp.common.service.datax.datamanage.FieldService;
|
||||
import com.fibo.ddp.common.service.datax.runner.CommonService;
|
||||
import com.fibo.ddp.common.service.datax.runner.ExecuteUtils;
|
||||
@@ -346,12 +348,16 @@ public class RuleSetNode implements EngineRunnerNode {
|
||||
}
|
||||
|
||||
String resultFieldEn = hitRuleBlock.getResultFieldEn();
|
||||
String outputFieldEn = hitRuleBlock.getResultFieldEn();
|
||||
if (resultFieldEn == null || "".equals(resultFieldEn)) {
|
||||
resultFieldEn = "rule_" + rule.getId() + "_" + ruleVersion.getId() + "_" + hitRuleBlock.getId() + "_hitResult";
|
||||
outputFieldEn = "ruleResult";
|
||||
}
|
||||
String scoreFieldEn = hitRuleBlock.getScoreFieldEn();
|
||||
String outputScoreEn = hitRuleBlock.getScoreFieldEn();
|
||||
if (StringUtils.isBlank(scoreFieldEn)) {
|
||||
scoreFieldEn = "rule_" + rule.getId() + "_" + ruleVersion.getId() + "_" + hitRuleBlock.getId() + "_score";
|
||||
outputScoreEn = "ruleScore";
|
||||
}
|
||||
input.put(resultFieldEn, "未命中");
|
||||
//根据执行的最终结果处理此规则输出内容
|
||||
@@ -361,27 +367,30 @@ public class RuleSetNode implements EngineRunnerNode {
|
||||
ruleMap.put("ruleResult", "命中");
|
||||
ruleMap.put("ruleScore", hitRuleBlock.getScore());
|
||||
JSONObject scoreJson = new JSONObject();
|
||||
resultJson.put(resultFieldEn, "命中");
|
||||
resultJson.put(outputFieldEn, "命中");
|
||||
fieldList.add(resultJson);
|
||||
// if (StringUtils.isNotBlank(ruleVersion.getScoreFieldEn())) {
|
||||
scoreJson.put(scoreFieldEn, hitRuleBlock.getScore());
|
||||
scoreJson.put(outputScoreEn, hitRuleBlock.getScore());
|
||||
fieldList.add(scoreJson);
|
||||
input.put(scoreFieldEn, hitRuleBlock.getScore());
|
||||
// }
|
||||
input.put(resultFieldEn, "命中");
|
||||
//处理此规则需要输出的内容
|
||||
fieldList.addAll(ruleService.setComplexRuleOutput(hitRuleBlock.getId(), temp, input, StrategyType.OutType.SUCCESS_OUT));
|
||||
ruleMap.put("fieldList", fieldList);
|
||||
hitFlag = true;
|
||||
ruleResultList.add(ruleMap);
|
||||
} else {
|
||||
resultJson.put(resultFieldEn, "未命中");
|
||||
resultJson.put(outputFieldEn, "未命中");
|
||||
ruleMap.put("ruleScore", 0);
|
||||
input.put(scoreFieldEn, 0);
|
||||
fieldList.add(resultJson);
|
||||
fieldList.addAll(ruleService.setComplexRuleOutput(hitRuleBlock.getId(), temp, input, StrategyType.OutType.FAIL_OUT));
|
||||
ruleMap.put("fieldList", fieldList);
|
||||
SessionData sessionData = RunnerSessionManager.getSession();
|
||||
if(sessionData.getRuleHitRspConfig() == null || sessionData.getRuleHitRspConfig() == 1){
|
||||
ruleResultList.add(ruleMap);
|
||||
}
|
||||
}
|
||||
ruleResultList.add(ruleMap);
|
||||
|
||||
return hitFlag;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user