@@ -0,0 +1,16 @@
|
||||
package com.fibo.ddp.common.dao.strategyx.guiderule;
|
||||
|
||||
import com.fibo.ddp.common.model.strategyx.guiderule.RuleBlock;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* 规则块配置表(RuleBlock)表数据库访问层
|
||||
*
|
||||
* @author andy.wang
|
||||
* @since 2022-08-05 10:32:11
|
||||
*/
|
||||
@Mapper
|
||||
public interface RuleBlockMapper extends BaseMapper<RuleBlock>{
|
||||
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.fibo.ddp.common.dao.strategyx.guiderule.RuleBlockMapper">
|
||||
|
||||
</mapper>
|
||||
@@ -12,23 +12,16 @@
|
||||
<result property="author" column="author" jdbcType="INTEGER"/>
|
||||
<result property="userId" column="user_id" jdbcType="INTEGER"/>
|
||||
<result property="organId" column="organ_id" jdbcType="INTEGER"/>
|
||||
<result property="engineId" column="engine_id" jdbcType="INTEGER"/>
|
||||
<result property="status" column="status" jdbcType="INTEGER"/>
|
||||
<result property="type" column="type" jdbcType="INTEGER"/>
|
||||
<result property="isNon" column="is_non" jdbcType="INTEGER"/>
|
||||
<result property="content" column="content" jdbcType="VARCHAR"/>
|
||||
<result property="created" column="created" jdbcType="TIMESTAMP"/>
|
||||
<result property="updated" column="updated" jdbcType="TIMESTAMP"/>
|
||||
<result property="ruleType" column="rule_type" jdbcType="INTEGER"/>
|
||||
<result property="ruleAudit" column="rule_audit" jdbcType="INTEGER"/>
|
||||
<result property="score" column="score" jdbcType="INTEGER"/>
|
||||
<result property="difficulty" column="difficulty" jdbcType="INTEGER"/>
|
||||
<result property="scriptType" column="script_type" jdbcType="VARCHAR"/>
|
||||
<result property="lastLogical" column="last_logical" jdbcType="VARCHAR"/>
|
||||
</resultMap>
|
||||
|
||||
<sql id="Base_column">
|
||||
id, name, code, description, priority, parent_id, author, user_id, organ_id, engine_id, status, type, is_non, content, created, updated, rule_type, rule_audit, score, last_logical,difficulty,script_type,result_field_en,score_field_en
|
||||
id, name, code, description, priority, parent_id, author, user_id, organ_id, status, type, created, updated,difficulty,script_type
|
||||
</sql>
|
||||
<!--查询单个-->
|
||||
<select id="queryById" resultMap="RuleMap">
|
||||
@@ -76,9 +69,6 @@
|
||||
<if test="organId != null">
|
||||
and organ_id = #{organId}
|
||||
</if>
|
||||
<if test="engineId != null">
|
||||
and engine_id = #{engineId}
|
||||
</if>
|
||||
<if test="status != null">
|
||||
and status = #{status}
|
||||
</if>
|
||||
@@ -88,30 +78,12 @@
|
||||
<if test="type != null">
|
||||
and `type` = #{type}
|
||||
</if>
|
||||
<if test="isNon != null">
|
||||
and is_non = #{isNon}
|
||||
</if>
|
||||
<if test="content != null and content != ''">
|
||||
and content = #{content}
|
||||
</if>
|
||||
<if test="created != null">
|
||||
and created >= #{created}
|
||||
</if>
|
||||
<if test="updated != null">
|
||||
and updated >= #{updated}
|
||||
</if>
|
||||
<if test="ruleType != null">
|
||||
and rule_type = #{ruleType}
|
||||
</if>
|
||||
<if test="ruleAudit != null">
|
||||
and rule_audit = #{ruleAudit}
|
||||
</if>
|
||||
<if test="score != null">
|
||||
and score = #{score}
|
||||
</if>
|
||||
<if test="lastLogical != null and lastLogical != ''">
|
||||
and last_logical = #{lastLogical}
|
||||
</if>
|
||||
<if test="difficulty != null">
|
||||
and difficulty = #{difficulty}
|
||||
</if>
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
package com.fibo.ddp.common.model.strategyx.guiderule;
|
||||
|
||||
import java.util.Date;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 规则块配置表(RuleBlock)实体类
|
||||
*
|
||||
* @author andy.wang
|
||||
* @since 2022-08-05 10:32:12
|
||||
*/
|
||||
@Data
|
||||
@ToString(callSuper = true)
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@TableName("t_rule_block")
|
||||
public class RuleBlock implements Serializable {
|
||||
private static final long serialVersionUID = 153524790651348062L;
|
||||
|
||||
@TableId(type = IdType.AUTO)
|
||||
/**
|
||||
* 主键:规则块id
|
||||
*/
|
||||
private Long id;
|
||||
/**
|
||||
* 规则id
|
||||
*/
|
||||
private Long ruleId;
|
||||
/**
|
||||
* 规则版本的id
|
||||
*/
|
||||
private Long versionId;
|
||||
/**
|
||||
* 存放执行结果的变量
|
||||
*/
|
||||
private String resultFieldEn;
|
||||
/**
|
||||
* 规则分数
|
||||
*/
|
||||
private Integer score;
|
||||
/**
|
||||
* 存放得分的变量
|
||||
*/
|
||||
private String scoreFieldEn;
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private Date createTime;
|
||||
/**
|
||||
* 修改时间
|
||||
*/
|
||||
private Date updateTime;
|
||||
}
|
||||
|
||||
@@ -49,6 +49,8 @@ public class RuleConditionInfo
|
||||
|
||||
private Long versionId;//规则版本的id
|
||||
|
||||
private Long blockId;//规则块的id
|
||||
|
||||
private Long parentId;//父节点的id
|
||||
|
||||
private Integer conditionType;//规则节点的类型:1-关系节点,2-表达式节点
|
||||
|
||||
@@ -43,35 +43,18 @@ public class RuleInfo implements Serializable {
|
||||
|
||||
private Long organId;//组织id
|
||||
|
||||
private Integer engineId;
|
||||
|
||||
private Integer status;//状态 0 :停用 ,1 : 启用,-1:删除
|
||||
|
||||
private Integer type;//规则类型 0 : 系统的规则 1:组织的规则 2: 引擎的规则
|
||||
|
||||
private Integer isNon;//逻辑关系“非”,0:否 ,1:是
|
||||
|
||||
private String content;//规则具体内容
|
||||
|
||||
private Date created;
|
||||
|
||||
private Date updated;
|
||||
|
||||
private Integer ruleType;//0硬性拒绝规则1加减分规则
|
||||
|
||||
private Integer ruleAudit;
|
||||
|
||||
private Integer score;//得分
|
||||
|
||||
private String lastLogical;//逻辑关系符
|
||||
|
||||
private Integer difficulty;//规则难度:1-简单规则,2复杂规则
|
||||
|
||||
private String scriptType;//脚本类型python,js,groovy
|
||||
|
||||
private String resultFieldEn;//存放是否命中的字段
|
||||
|
||||
private String scoreFieldEn;//存放得分的字段en
|
||||
@TableField(exist = false)
|
||||
private String authorName;//创建人名称,需要去其他表查询
|
||||
@TableField(exist = false)
|
||||
|
||||
@@ -37,18 +37,6 @@ public class RuleVersion implements Serializable {
|
||||
* 状态:-1 删除 0停用 1启用
|
||||
*/
|
||||
private Integer status;
|
||||
/**
|
||||
* 规则结果en(命中情况)
|
||||
*/
|
||||
private String resultFieldEn;
|
||||
/**
|
||||
* 规则得分
|
||||
*/
|
||||
private Integer score;
|
||||
/**
|
||||
* 规则得分的en
|
||||
*/
|
||||
private String scoreFieldEn;
|
||||
/**
|
||||
* 组织id
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.fibo.ddp.common.model.strategyx.guiderule.vo;
|
||||
|
||||
import com.fibo.ddp.common.model.strategyx.guiderule.RuleBlock;
|
||||
import com.fibo.ddp.common.model.strategyx.strategyout.StrategyOutput;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Accessors
|
||||
public class RuleBlockVo extends RuleBlock {
|
||||
|
||||
private RuleConditionVo ruleConditionVo;//规则对应的结点树
|
||||
|
||||
private List<StrategyOutput> strategyOutputList;//输出字段
|
||||
|
||||
private List<StrategyOutput> failOutputList;//失败输出字段
|
||||
}
|
||||
@@ -12,9 +12,11 @@ import java.util.List;
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class RuleVersionVo extends RuleVersion {
|
||||
private RuleConditionVo ruleConditionVo;//规则对应的结点树
|
||||
// private RuleConditionVo ruleConditionVo;//规则对应的结点树
|
||||
//
|
||||
// private List<StrategyOutput> strategyOutputList;//输出字段
|
||||
//
|
||||
// private List<StrategyOutput> failOutputList;//失败输出字段
|
||||
|
||||
private List<StrategyOutput> strategyOutputList;//输出字段
|
||||
|
||||
private List<StrategyOutput> failOutputList;//失败输出字段
|
||||
private List<RuleBlockVo> ruleBlockVoList;
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@ package com.fibo.ddp.common.model.strategyx.guiderule.vo;
|
||||
|
||||
import com.fibo.ddp.common.model.strategyx.guiderule.RuleInfo;
|
||||
import com.fibo.ddp.common.model.strategyx.scriptrule.RuleScriptVersion;
|
||||
import com.fibo.ddp.common.model.strategyx.strategyout.StrategyOutput;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
@@ -16,9 +15,9 @@ import java.util.List;
|
||||
@Accessors
|
||||
public class RuleVo extends RuleInfo {
|
||||
|
||||
private RuleConditionVo ruleConditionVo;//规则对应的结点树
|
||||
|
||||
private List<StrategyOutput> strategyOutputList;//输出字段
|
||||
// private RuleConditionVo ruleConditionVo;//规则对应的结点树
|
||||
//
|
||||
// private List<StrategyOutput> strategyOutputList;//输出字段
|
||||
|
||||
private List<RuleVersionVo> ruleVersionList;//规则版本列表
|
||||
// private List<T> ruleVersionList;//规则版本列表
|
||||
|
||||
@@ -598,7 +598,6 @@ public class EngineNodeServiceImpl extends ServiceImpl<EngineNodeMapper, EngineN
|
||||
case 3:
|
||||
scriptRuleVersionIds.add(ruleVersionId);
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
List<RuleSetNodeResultParam> ruleSetNodeResultParams = new ArrayList<>();
|
||||
@@ -610,9 +609,9 @@ public class EngineNodeServiceImpl extends ServiceImpl<EngineNodeMapper, EngineN
|
||||
for (RuleInfo rule : ruleList) {
|
||||
ruleMap.put(rule.getId(),rule);
|
||||
if (rule.getDifficulty()==null||rule.getDifficulty()==1){
|
||||
String resultEn = rule.getResultFieldEn();
|
||||
String scoreEn = rule.getScoreFieldEn();
|
||||
ruleSetNodeResultParams.add(new RuleSetNodeResultParam(rule.getId(),1,null,resultEn,scoreEn,rule.getCode(),rule.getName()));
|
||||
// String resultEn = rule.getResultFieldEn();
|
||||
// String scoreEn = rule.getScoreFieldEn();
|
||||
// ruleSetNodeResultParams.add(new RuleSetNodeResultParam(rule.getId(),1,null,resultEn,scoreEn,rule.getCode(),rule.getName()));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -622,10 +621,10 @@ public class EngineNodeServiceImpl extends ServiceImpl<EngineNodeMapper, EngineN
|
||||
List<RuleVersion> ruleVersionList = ruleVersionService.listByIds(complexRuleVersionIds);
|
||||
if (CollectionUtils.isNotEmpty(ruleVersionList)){
|
||||
for (RuleVersion ruleVersion : ruleVersionList) {
|
||||
String resultEn = ruleVersion.getResultFieldEn();
|
||||
String scoreEn = ruleVersion.getScoreFieldEn();
|
||||
RuleInfo rule = ruleMap.get(ruleVersion.getRuleId());
|
||||
ruleSetNodeResultParams.add(new RuleSetNodeResultParam(ruleVersion.getRuleId(),2,ruleVersion.getId(),resultEn,scoreEn,rule.getCode(),rule.getName()));
|
||||
// String resultEn = ruleVersion.getResultFieldEn();
|
||||
// String scoreEn = ruleVersion.getScoreFieldEn();
|
||||
// RuleInfo rule = ruleMap.get(ruleVersion.getRuleId());
|
||||
// ruleSetNodeResultParams.add(new RuleSetNodeResultParam(ruleVersion.getRuleId(),2,ruleVersion.getId(),resultEn,scoreEn,rule.getCode(),rule.getName()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.fibo.ddp.common.service.strategyx.guiderule;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.fibo.ddp.common.model.strategyx.guiderule.RuleBlock;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 规则块配置表(RuleBlock)表服务接口
|
||||
*
|
||||
* @author andy.wang
|
||||
* @since 2022-08-05 10:32:22
|
||||
*/
|
||||
public interface RuleBlockService extends IService<RuleBlock> {
|
||||
|
||||
List<RuleBlock> listObjectsByVersionId(Long versionId);
|
||||
|
||||
boolean removeObjects(Long ruleId, Long versionId);
|
||||
}
|
||||
@@ -16,9 +16,9 @@ public interface RuleConditionService extends IService<RuleConditionInfo> {
|
||||
* @param ruleConditionVo 实例对象
|
||||
* @return 实例对象
|
||||
*/
|
||||
RuleConditionVo insertRuleCondition(RuleConditionVo ruleConditionVo, Long ruleId);
|
||||
RuleConditionVo insertRuleCondition(RuleConditionVo ruleConditionVo, Long ruleId, Long blockId);
|
||||
|
||||
RuleConditionVo updateRuleCondition(Long ruleId, RuleConditionVo ruleConditionVo);
|
||||
RuleConditionVo updateRuleCondition(Long ruleId, Long blockId, RuleConditionVo ruleConditionVo);
|
||||
|
||||
boolean deleteRuleCondition(Long ruleId, Long versionId);
|
||||
|
||||
@@ -28,7 +28,7 @@ public interface RuleConditionService extends IService<RuleConditionInfo> {
|
||||
List<RuleConditionInfo> disassemble(RuleConditionVo vo, Long ruleId, boolean needTempId);
|
||||
|
||||
// runner
|
||||
RuleConditionVo queryByVersionId(Long versionId);
|
||||
RuleConditionVo queryByBlockId(Long blockId);
|
||||
|
||||
List<String> queryFieldEnByVersionIds(List<Long> versionIds);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
package com.fibo.ddp.common.service.strategyx.guiderule.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.fibo.ddp.common.dao.strategyx.guiderule.RuleBlockMapper;
|
||||
import com.fibo.ddp.common.model.strategyx.guiderule.RuleBlock;
|
||||
import com.fibo.ddp.common.service.strategyx.guiderule.RuleBlockService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 规则块配置表(RuleBlock)表服务实现类
|
||||
*
|
||||
* @author andy.wang
|
||||
* @since 2022-08-05 10:32:25
|
||||
*/
|
||||
@Service
|
||||
public class RuleBlockServiceImpl extends ServiceImpl<RuleBlockMapper, RuleBlock> implements RuleBlockService {
|
||||
|
||||
@Override
|
||||
public List<RuleBlock> listObjectsByVersionId(Long versionId) {
|
||||
LambdaQueryWrapper<RuleBlock> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(RuleBlock::getVersionId, versionId);
|
||||
return list(queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean removeObjects(Long ruleId, Long versionId) {
|
||||
LambdaQueryWrapper<RuleBlock> queryWrapper = new LambdaQueryWrapper();
|
||||
queryWrapper.eq(RuleBlock::getRuleId, ruleId);
|
||||
queryWrapper.eq(RuleBlock::getVersionId, versionId);
|
||||
return this.remove(queryWrapper);
|
||||
}
|
||||
}
|
||||
@@ -68,22 +68,15 @@ public class RuleConditionServiceImpl extends ServiceImpl<RuleConditionInfoMappe
|
||||
// }
|
||||
|
||||
@Override
|
||||
public RuleConditionVo queryByVersionId(Long versionId) {
|
||||
if (versionId == null) {
|
||||
public RuleConditionVo queryByBlockId(Long blockId) {
|
||||
if (blockId == null) {
|
||||
return null;
|
||||
}
|
||||
//构造查询条件,查询条件列表
|
||||
RuleConditionVo result = null;
|
||||
|
||||
List<RuleConditionInfo> ruleConditionInfoList = null;
|
||||
if(Constants.switchFlag.ON.equals(cacheSwitch)){
|
||||
String key = RedisUtils.getForeignKey(TableEnum.T_RULE_CONDITION, versionId);
|
||||
ruleConditionInfoList = redisManager.getByForeignKey(key, RuleConditionInfo.class);
|
||||
} else {
|
||||
LambdaQueryWrapper<RuleConditionInfo> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(RuleConditionInfo::getVersionId, versionId);
|
||||
ruleConditionInfoList = ruleConditionInfoMapper.selectList(queryWrapper);
|
||||
}
|
||||
LambdaQueryWrapper<RuleConditionInfo> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(RuleConditionInfo::getBlockId, blockId);
|
||||
List<RuleConditionInfo> ruleConditionInfoList = this.list(queryWrapper);
|
||||
|
||||
//组装为需要的树形结构
|
||||
if (ruleConditionInfoList != null) {
|
||||
@@ -100,7 +93,7 @@ public class RuleConditionServiceImpl extends ServiceImpl<RuleConditionInfoMappe
|
||||
*/
|
||||
@Override
|
||||
@Transactional
|
||||
public RuleConditionVo insertRuleCondition(RuleConditionVo ruleConditionVo, Long ruleId) {
|
||||
public RuleConditionVo insertRuleCondition(RuleConditionVo ruleConditionVo, Long ruleId, Long blockId) {
|
||||
if (ruleConditionVo == null || ruleId == null) {
|
||||
return null;
|
||||
}
|
||||
@@ -113,6 +106,7 @@ public class RuleConditionServiceImpl extends ServiceImpl<RuleConditionInfoMappe
|
||||
List<RuleConditionInfo> list = this.disassemble(ruleConditionVo, ruleId, true);
|
||||
for (RuleConditionInfo info : list) {
|
||||
info.setVersionId(versionId);
|
||||
info.setBlockId(blockId);
|
||||
}
|
||||
//找出唯一根节点
|
||||
RuleConditionInfo root = null;
|
||||
@@ -138,19 +132,13 @@ public class RuleConditionServiceImpl extends ServiceImpl<RuleConditionInfoMappe
|
||||
*/
|
||||
@Override
|
||||
@Transactional
|
||||
public RuleConditionVo updateRuleCondition(Long ruleId, RuleConditionVo ruleConditionVo) {
|
||||
public RuleConditionVo updateRuleCondition(Long ruleId, Long blockId, RuleConditionVo ruleConditionVo) {
|
||||
if (ruleId == null) {
|
||||
return null;
|
||||
}
|
||||
//删除一个规则下的所有条件
|
||||
boolean delete = this.deleteRuleCondition(ruleId,ruleConditionVo.getVersionId());
|
||||
RuleConditionVo ruleCondition = null;
|
||||
if (!delete) {
|
||||
ruleCondition = this.queryByVersionId(ruleConditionVo.getVersionId());
|
||||
}
|
||||
//插入条件树
|
||||
if ((delete || ruleCondition == null) && ruleConditionVo != null) {
|
||||
RuleConditionVo insertResult = this.insertRuleCondition(ruleConditionVo, ruleId);
|
||||
if (ruleConditionVo != null) {
|
||||
RuleConditionVo insertResult = this.insertRuleCondition(ruleConditionVo, ruleId, blockId);
|
||||
return insertResult;
|
||||
}
|
||||
return null;
|
||||
|
||||
@@ -119,7 +119,6 @@ public class RuleServiceImpl extends ServiceImpl<RuleInfoMapper, RuleInfo> imple
|
||||
return pageInfo;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public RuleVo insertRuleInfo(RuleVo vo) {
|
||||
@@ -268,21 +267,6 @@ public class RuleServiceImpl extends ServiceImpl<RuleInfoMapper, RuleInfo> imple
|
||||
//加入状态信息
|
||||
vo.setType(RuleConst.TYPE_ORGAN);
|
||||
vo.setStatus(RuleConst.STATUS_ENABLED);
|
||||
//加入规则类型
|
||||
if (vo == null || vo.getRuleAudit() == null) {
|
||||
throw new ApiException(ErrorCodeEnum.PARAMS_EXCEPTION.getCode(), ErrorCodeEnum.PARAMS_EXCEPTION.getMessage());
|
||||
}
|
||||
switch (vo.getRuleAudit()) {
|
||||
case RuleConst.RULE_AUDIT_TERMINATION:
|
||||
vo.setRuleType(RuleConst.RULE_TYPE_TERMINATION);
|
||||
break;
|
||||
case RuleConst.RULE_AUDIT_SCORING:
|
||||
vo.setRuleType(RuleConst.RULE_TYPE_SCORING);
|
||||
break;
|
||||
default:
|
||||
vo.setRuleType(RuleConst.RULE_TYPE_TERMINATION);
|
||||
}
|
||||
|
||||
return vo;
|
||||
}
|
||||
|
||||
|
||||
@@ -9,14 +9,17 @@ import com.fibo.ddp.common.dao.datax.datamanage.FieldMapper;
|
||||
import com.fibo.ddp.common.dao.strategyx.guiderule.RuleVersionMapper;
|
||||
import com.fibo.ddp.common.model.authx.system.SysUser;
|
||||
import com.fibo.ddp.common.model.common.requestParam.StatusParam;
|
||||
import com.fibo.ddp.common.model.strategyx.guiderule.RuleBlock;
|
||||
import com.fibo.ddp.common.model.strategyx.guiderule.RuleConditionInfo;
|
||||
import com.fibo.ddp.common.model.strategyx.guiderule.RuleVersion;
|
||||
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.strategyout.StrategyOutput;
|
||||
import com.fibo.ddp.common.service.common.SessionManager;
|
||||
import com.fibo.ddp.common.service.redis.RedisManager;
|
||||
import com.fibo.ddp.common.service.redis.RedisUtils;
|
||||
import com.fibo.ddp.common.service.strategyx.guiderule.RuleBlockService;
|
||||
import com.fibo.ddp.common.service.strategyx.guiderule.RuleConditionService;
|
||||
import com.fibo.ddp.common.service.strategyx.guiderule.RuleVersionService;
|
||||
import com.fibo.ddp.common.service.strategyx.strategyout.StrategyOutputService;
|
||||
@@ -43,6 +46,8 @@ public class RuleVersionServiceImpl extends ServiceImpl<RuleVersionMapper, RuleV
|
||||
@Autowired
|
||||
private RuleVersionMapper versionMapper;
|
||||
@Autowired
|
||||
private RuleBlockService ruleBlockService;
|
||||
@Autowired
|
||||
private RuleConditionService conditionService;
|
||||
@Autowired
|
||||
private StrategyOutputService outputService;
|
||||
@@ -88,13 +93,23 @@ public class RuleVersionServiceImpl extends ServiceImpl<RuleVersionMapper, RuleV
|
||||
return result;
|
||||
}
|
||||
BeanUtils.copyProperties(ruleVersion, result);
|
||||
//查询ruleCondition组装成树形结构
|
||||
RuleConditionVo ruleConditionVo = conditionService.queryByVersionId(id);
|
||||
List<StrategyOutput> strategyOutputList = outputService.queryByTactics(new StrategyOutput(id, StrategyType.COMPLEX_RULE, StrategyType.OutType.SUCCESS_OUT));
|
||||
List<StrategyOutput> failOutputList = outputService.queryByTactics(new StrategyOutput(id, StrategyType.COMPLEX_RULE, StrategyType.OutType.FAIL_OUT));
|
||||
result.setRuleConditionVo(ruleConditionVo);
|
||||
result.setStrategyOutputList(strategyOutputList);
|
||||
result.setFailOutputList(failOutputList);
|
||||
|
||||
List<RuleBlock> ruleBlockList = ruleBlockService.listObjectsByVersionId(id);
|
||||
List<RuleBlockVo> ruleBlockVoList = new ArrayList<>();
|
||||
for(RuleBlock ruleBlock : ruleBlockList){
|
||||
RuleBlockVo ruleBlockVo = new RuleBlockVo();
|
||||
BeanUtils.copyProperties(ruleBlock, ruleBlockVo);
|
||||
//查询ruleCondition组装成树形结构
|
||||
RuleConditionVo ruleConditionVo = conditionService.queryByBlockId(ruleBlock.getId());
|
||||
List<StrategyOutput> strategyOutputList = outputService.queryByTactics(new StrategyOutput(ruleBlock.getId(), StrategyType.COMPLEX_RULE, StrategyType.OutType.SUCCESS_OUT));
|
||||
List<StrategyOutput> failOutputList = outputService.queryByTactics(new StrategyOutput(ruleBlock.getId(), StrategyType.COMPLEX_RULE, StrategyType.OutType.FAIL_OUT));
|
||||
ruleBlockVo.setRuleConditionVo(ruleConditionVo);
|
||||
ruleBlockVo.setStrategyOutputList(strategyOutputList);
|
||||
ruleBlockVo.setFailOutputList(failOutputList);
|
||||
ruleBlockVoList.add(ruleBlockVo);
|
||||
}
|
||||
result.setRuleBlockVoList(ruleBlockVoList);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -132,31 +147,33 @@ public class RuleVersionServiceImpl extends ServiceImpl<RuleVersionMapper, RuleV
|
||||
|
||||
@Override
|
||||
public List<String> queryFieldEnByVersionId(Long versionId) {
|
||||
Set<String> fieldEns= new HashSet<>();
|
||||
Set<Long> fieldIds= new HashSet<>();
|
||||
RuleConditionVo ruleConditionVo = conditionService.queryByVersionId(versionId);
|
||||
List<RuleConditionInfo> ruleConditionInfoList = conditionService.disassemble(ruleConditionVo, versionId, false);
|
||||
for (RuleConditionInfo info : ruleConditionInfoList) {
|
||||
if (info.getFieldEn()!=null&&info.getFieldType()!=1&&!info.getFieldEn().startsWith("%")){
|
||||
if (info.getFieldEn().contains(".")){
|
||||
fieldEns.add(info.getFieldEn().split("\\.")[0]);
|
||||
Set<String> fieldEns = new HashSet<>();
|
||||
Set<Long> fieldIds = new HashSet<>();
|
||||
List<RuleBlock> ruleBlockList = ruleBlockService.listObjectsByVersionId(versionId);
|
||||
for (RuleBlock ruleBlock : ruleBlockList) {
|
||||
RuleConditionVo ruleConditionVo = conditionService.queryByBlockId(ruleBlock.getId());
|
||||
List<RuleConditionInfo> ruleConditionInfoList = conditionService.disassemble(ruleConditionVo, ruleBlock.getRuleId(), false);
|
||||
for (RuleConditionInfo info : ruleConditionInfoList) {
|
||||
if (info.getFieldEn() != null && info.getFieldType() != 1 && !info.getFieldEn().startsWith("%")) {
|
||||
if (info.getFieldEn().contains(".")) {
|
||||
fieldEns.add(info.getFieldEn().split("\\.")[0]);
|
||||
} else {
|
||||
fieldEns.add(info.getFieldEn());
|
||||
}
|
||||
} else if (info.getFieldId() != null) {
|
||||
fieldIds.add(info.getFieldId());
|
||||
}
|
||||
else {
|
||||
fieldEns.add(info.getFieldEn());
|
||||
}
|
||||
}else if(info.getFieldId()!=null){
|
||||
fieldIds.add(info.getFieldId());
|
||||
}
|
||||
if (info.getVariableType()!=null){
|
||||
if (info.getVariableType()==2&&info.getFieldValue()!=null&&!info.getFieldValue().contains("%")){
|
||||
fieldEns.add(info.getFieldValue());
|
||||
}else if (info.getVariableType()==3){
|
||||
fieldEns.addAll(CustomValueUtils.getFieldEnSet(info.getFieldValue()));
|
||||
if (info.getVariableType() != null) {
|
||||
if (info.getVariableType() == 2 && info.getFieldValue() != null && !info.getFieldValue().contains("%")) {
|
||||
fieldEns.add(info.getFieldValue());
|
||||
} else if (info.getVariableType() == 3) {
|
||||
fieldEns.addAll(CustomValueUtils.getFieldEnSet(info.getFieldValue()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for (Long fieldId : fieldIds) {
|
||||
String fieldName= fieldMapper.findFieldNameById(fieldId);
|
||||
String fieldName = fieldMapper.findFieldNameById(fieldId);
|
||||
fieldEns.add(fieldName);
|
||||
}
|
||||
return new ArrayList<>(fieldEns);
|
||||
@@ -201,21 +218,33 @@ public class RuleVersionServiceImpl extends ServiceImpl<RuleVersionMapper, RuleV
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public boolean addVersionDetail(RuleVersionVo version){
|
||||
RuleConditionVo ruleConditionVo = version.getRuleConditionVo();
|
||||
ruleConditionVo.setVersionId(version.getId());
|
||||
//添加条件信息
|
||||
conditionService.insertRuleCondition(ruleConditionVo,version.getRuleId());
|
||||
//添加输出字段
|
||||
List<StrategyOutput> strategyOutputList = version.getStrategyOutputList();
|
||||
if (strategyOutputList !=null&& strategyOutputList.size()>0){
|
||||
outputService.insertTacticsOutput(version.getId(), strategyOutputList);
|
||||
}
|
||||
List<StrategyOutput> failOutputList = version.getFailOutputList();
|
||||
if (failOutputList!=null&&failOutputList.size()>0){
|
||||
outputService.insertTacticsOutput(version.getId(),failOutputList );
|
||||
List<RuleBlockVo> ruleBlockVoList = version.getRuleBlockVoList();
|
||||
for (RuleBlockVo ruleBlockVo : ruleBlockVoList){
|
||||
RuleBlock ruleBlock = new RuleBlock();
|
||||
BeanUtils.copyProperties(ruleBlockVo, ruleBlock);
|
||||
ruleBlock.setRuleId(version.getRuleId());
|
||||
ruleBlock.setVersionId(version.getId());
|
||||
ruleBlockService.save(ruleBlock);
|
||||
|
||||
RuleConditionVo ruleConditionVo = ruleBlockVo.getRuleConditionVo();
|
||||
ruleConditionVo.setVersionId(version.getId());
|
||||
ruleConditionVo.setBlockId(ruleBlock.getId());
|
||||
//添加条件信息
|
||||
conditionService.insertRuleCondition(ruleConditionVo,version.getRuleId(), ruleBlock.getId());
|
||||
//添加输出字段
|
||||
List<StrategyOutput> strategyOutputList = ruleBlockVo.getStrategyOutputList();
|
||||
if (strategyOutputList !=null&& strategyOutputList.size()>0){
|
||||
outputService.insertTacticsOutput(ruleBlock.getId(), strategyOutputList);
|
||||
}
|
||||
List<StrategyOutput> failOutputList = ruleBlockVo.getFailOutputList();
|
||||
if (failOutputList!=null&&failOutputList.size()>0){
|
||||
outputService.insertTacticsOutput(ruleBlock.getId(),failOutputList );
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -232,23 +261,46 @@ public class RuleVersionServiceImpl extends ServiceImpl<RuleVersionMapper, RuleV
|
||||
@Override
|
||||
@Transactional
|
||||
public boolean updateVersion(RuleVersionVo version) {
|
||||
Long ruleId = version.getRuleId();
|
||||
Long versionId = version.getId();
|
||||
if (versionId==null){
|
||||
return false;
|
||||
}
|
||||
SysUser loginSysUser = SessionManager.getLoginAccount();
|
||||
version.setUpdateUserId(loginSysUser.getUserId());
|
||||
//修改版本主表
|
||||
// 1. 修改版本主表
|
||||
versionMapper.updateById(version);
|
||||
//修改条件表
|
||||
conditionService.updateRuleCondition(version.getRuleId(),version.getRuleConditionVo());
|
||||
//修改策略输出
|
||||
outputService.updateTacticsOutput(versionId,version.getStrategyOutputList(),version.getFailOutputList(), StrategyType.COMPLEX_RULE);
|
||||
|
||||
// 2. 删除原版本下所有子表数据
|
||||
// 删除所有规则块
|
||||
ruleBlockService.removeObjects(ruleId, versionId);
|
||||
// 删除所有条件
|
||||
conditionService.deleteRuleCondition(ruleId, versionId);
|
||||
// 删除所有策略输出(需找出原来的所有块,然后逐一删除)
|
||||
List<RuleBlock> oldRuleBlockList = ruleBlockService.listObjectsByVersionId(versionId);
|
||||
for(RuleBlock ruleBlock : oldRuleBlockList){
|
||||
StrategyOutput strategyOutput = new StrategyOutput(ruleBlock.getId(), StrategyType.COMPLEX_RULE);
|
||||
outputService.deleteByTactics(strategyOutput);
|
||||
}
|
||||
|
||||
// 3. 插入新版本下子表数据
|
||||
List<RuleBlockVo> ruleBlockVoList = version.getRuleBlockVoList();
|
||||
for(RuleBlockVo ruleBlockVo : ruleBlockVoList){
|
||||
// 修改规则块配置表
|
||||
ruleBlockVo.setRuleId(ruleId);
|
||||
ruleBlockVo.setVersionId(versionId);
|
||||
ruleBlockService.save(ruleBlockVo);
|
||||
Long blockId = ruleBlockVo.getId();
|
||||
//修改条件表
|
||||
conditionService.updateRuleCondition(ruleId, blockId, ruleBlockVo.getRuleConditionVo());
|
||||
//修改策略输出
|
||||
outputService.updateTacticsOutput(blockId,ruleBlockVo.getStrategyOutputList(),ruleBlockVo.getFailOutputList(), StrategyType.COMPLEX_RULE);
|
||||
}
|
||||
|
||||
this.saveSnapshot(versionId);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public boolean updateStatus(StatusParam statusParam) {
|
||||
|
||||
@@ -107,11 +107,6 @@ public class StrategyOutputServiceImpl extends ServiceImpl<StrategyOutputMapper,
|
||||
@Transactional
|
||||
@Override
|
||||
public boolean updateTacticsOutput(Long tacticsId, List<StrategyOutput> successList, List<StrategyOutput> failList, String tacticsType) {
|
||||
StrategyOutput strategyOutput = new StrategyOutput(tacticsId, tacticsType);
|
||||
boolean delete = this.deleteByTactics(strategyOutput);
|
||||
if (!delete && this.queryByTactics(strategyOutput).size() != 0) {
|
||||
return false;
|
||||
}
|
||||
if (successList != null && !successList.isEmpty()) {
|
||||
this.insertTacticsOutput(tacticsId, successList, StrategyType.OutType.SUCCESS_OUT);
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import com.fibo.ddp.common.model.enginex.risk.EngineNode;
|
||||
import com.fibo.ddp.common.model.enginex.runner.ExpressionParam;
|
||||
import com.fibo.ddp.common.model.strategyx.guiderule.RuleInfo;
|
||||
import com.fibo.ddp.common.model.strategyx.guiderule.RuleLoopGroupAction;
|
||||
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;
|
||||
@@ -195,7 +196,7 @@ public class RuleSetNode implements EngineRunnerNode {
|
||||
private void recordStrategySnopshot(List<RuleInfo> ruleInfoList, Map<String, Object> outMap) {
|
||||
JSONArray jsonObject = new JSONArray();
|
||||
ruleInfoList.stream().forEach(ruleInfo -> {
|
||||
logger.info("===========================监控添加策略信息快照情况==============版本id:{}=====:{}",ruleInfo.getVersion().getId(),ruleInfo.getVersion().getSnapshot());
|
||||
logger.info("===========================监控添加策略信息快照情况==============版本id:{}=====:{}", ruleInfo.getVersion().getId(), ruleInfo.getVersion().getSnapshot());
|
||||
if (ruleInfo.getVersion().getSnapshot() != null) {
|
||||
jsonObject.add(ruleInfo.getVersion().getSnapshot());
|
||||
|
||||
@@ -203,7 +204,7 @@ public class RuleSetNode implements EngineRunnerNode {
|
||||
});
|
||||
JSONObject jsonObject1 = new JSONObject();
|
||||
jsonObject1.put("snopshot", jsonObject);
|
||||
logger.info("===========================监控添加策略信息快照情况:{}",jsonObject1);
|
||||
logger.info("===========================监控添加策略信息快照情况:{}", jsonObject1);
|
||||
outMap.put("strategySnopshot", jsonObject1);
|
||||
}
|
||||
|
||||
@@ -320,7 +321,7 @@ public class RuleSetNode implements EngineRunnerNode {
|
||||
//取出本规则的条件列表
|
||||
Map<String, Object> ruleMap = new HashMap<>();
|
||||
ruleMap.put("ruleId", rule.getId());
|
||||
ruleMap.put("ruleVersionId",ruleVersion.getId());
|
||||
ruleMap.put("ruleVersionId", ruleVersion.getId());
|
||||
ruleMap.put("ruleCode", rule.getCode());
|
||||
ruleMap.put("ruleName", rule.getName());
|
||||
ruleMap.put("versionCode", ruleVersion.getVersionCode());
|
||||
@@ -328,18 +329,29 @@ public class RuleSetNode implements EngineRunnerNode {
|
||||
ruleMap.put("desc", rule.getDescription());
|
||||
ruleMap.put("ruleResult", "未命中");
|
||||
|
||||
//获取规则需要执行的condition逻辑。
|
||||
RuleConditionVo ruleCondition = ruleVersion.getRuleConditionVo();
|
||||
//传入输入参数、中间变量、输出参数和需要执行的condition逻辑获取执行结果
|
||||
// 循环执行规则块,按顺序命中第一个块就结束
|
||||
boolean result = false;
|
||||
Map<String, Object> temp = JSON.parseObject(JSON.toJSONString(input), Map.class);
|
||||
boolean result = this.executeRuleCondition(temp, output, ruleCondition);
|
||||
String resultFieldEn = ruleVersion.getResultFieldEn();
|
||||
if (resultFieldEn == null || "".equals(resultFieldEn)) {
|
||||
resultFieldEn = "rule_2_"+rule.getId()+"_"+ruleVersion.getId()+"_hitResult";
|
||||
List<RuleBlockVo> ruleBlockVoList = ruleVersion.getRuleBlockVoList();
|
||||
RuleBlockVo hitRuleBlock = ruleBlockVoList.get(0); // 规则的输出项默认用第一个块的配置
|
||||
for (RuleBlockVo ruleBlockVo : ruleBlockVoList) {
|
||||
//获取规则需要执行的condition逻辑。
|
||||
RuleConditionVo ruleCondition = ruleBlockVo.getRuleConditionVo();
|
||||
//传入输入参数、中间变量、输出参数和需要执行的condition逻辑获取执行结果
|
||||
result = this.executeRuleCondition(temp, output, ruleCondition);
|
||||
if (result) {
|
||||
hitRuleBlock = ruleBlockVo;
|
||||
break;
|
||||
}
|
||||
}
|
||||
String scoreFieldEn = ruleVersion.getScoreFieldEn();
|
||||
if (StringUtils.isBlank(scoreFieldEn)){
|
||||
scoreFieldEn = "rule_2_"+rule.getId()+"_"+ruleVersion.getId()+"_score";
|
||||
|
||||
String resultFieldEn = hitRuleBlock.getResultFieldEn();
|
||||
if (resultFieldEn == null || "".equals(resultFieldEn)) {
|
||||
resultFieldEn = "rule_" + rule.getId() + "_" + ruleVersion.getId() + "_" + hitRuleBlock.getId() + "_hitResult";
|
||||
}
|
||||
String scoreFieldEn = hitRuleBlock.getScoreFieldEn();
|
||||
if (StringUtils.isBlank(scoreFieldEn)) {
|
||||
scoreFieldEn = "rule_" + rule.getId() + "_" + ruleVersion.getId() + "_" + hitRuleBlock.getId() + "_score";
|
||||
}
|
||||
input.put(resultFieldEn, "未命中");
|
||||
//根据执行的最终结果处理此规则输出内容
|
||||
@@ -347,14 +359,14 @@ public class RuleSetNode implements EngineRunnerNode {
|
||||
JSONObject resultJson = new JSONObject();
|
||||
if (result) {
|
||||
ruleMap.put("ruleResult", "命中");
|
||||
ruleMap.put("ruleScore", rule.getScore());
|
||||
ruleMap.put("ruleScore", hitRuleBlock.getScore());
|
||||
JSONObject scoreJson = new JSONObject();
|
||||
resultJson.put(resultFieldEn, "命中");
|
||||
fieldList.add(resultJson);
|
||||
// if (StringUtils.isNotBlank(ruleVersion.getScoreFieldEn())) {
|
||||
scoreJson.put(scoreFieldEn, ruleVersion.getScore());
|
||||
fieldList.add(scoreJson);
|
||||
input.put(scoreFieldEn, ruleVersion.getScore());
|
||||
scoreJson.put(scoreFieldEn, hitRuleBlock.getScore());
|
||||
fieldList.add(scoreJson);
|
||||
input.put(scoreFieldEn, hitRuleBlock.getScore());
|
||||
// }
|
||||
input.put(resultFieldEn, "命中");
|
||||
//处理此规则需要输出的内容
|
||||
@@ -364,7 +376,7 @@ public class RuleSetNode implements EngineRunnerNode {
|
||||
} else {
|
||||
resultJson.put(resultFieldEn, "未命中");
|
||||
ruleMap.put("ruleScore", 0);
|
||||
input.put(scoreFieldEn,0);
|
||||
input.put(scoreFieldEn, 0);
|
||||
fieldList.add(resultJson);
|
||||
fieldList.addAll(ruleService.setComplexRuleOutput(ruleVersion.getId(), temp, input, StrategyType.OutType.FAIL_OUT));
|
||||
ruleMap.put("fieldList", fieldList);
|
||||
@@ -546,7 +558,7 @@ public class RuleSetNode implements EngineRunnerNode {
|
||||
}
|
||||
|
||||
|
||||
private void initLoopGroupAction(RuleLoopGroupAction loopGroupAction, Map<String, Object> input){
|
||||
private void initLoopGroupAction(RuleLoopGroupAction loopGroupAction, Map<String, Object> input) {
|
||||
Integer actionType = loopGroupAction.getActionType();
|
||||
String actionKey = loopGroupAction.getActionKey();
|
||||
String actionValue = loopGroupAction.getActionValue();
|
||||
@@ -564,7 +576,7 @@ public class RuleSetNode implements EngineRunnerNode {
|
||||
input.put(actionKey, "");
|
||||
break;
|
||||
case RuleConst.LOOP_GROUP_ACTION_TYPE_OUT_VARIABLE:
|
||||
input.put(actionKey,new HashSet<>());
|
||||
input.put(actionKey, new HashSet<>());
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -597,15 +609,15 @@ public class RuleSetNode implements EngineRunnerNode {
|
||||
}
|
||||
}
|
||||
|
||||
int totalSize = selectedHitRules.size(); // 规则命名个数
|
||||
double totalScore = selectedHitRules.stream().mapToDouble(RuleInfo::getScore).sum(); // 规则总得分
|
||||
int totalSize = selectedHitRules.size(); // 规则命中个数
|
||||
// double totalScore = selectedHitRules.stream().mapToDouble(RuleInfo::getScore).sum(); // 规则总得分
|
||||
String sizeKey = engineNode.getNodeType() + "_" + engineNode.getNodeId() + "_terminal_size";
|
||||
String scoreKey = engineNode.getNodeType() + "_" + engineNode.getNodeId() + "_terminal_score";
|
||||
Map<String, Object> variablesMap = new HashMap<>();
|
||||
variablesMap.put(sizeKey, totalSize);
|
||||
variablesMap.put(scoreKey, totalScore);
|
||||
// variablesMap.put(scoreKey, totalScore);
|
||||
|
||||
ExecuteUtils.terminalCondition(engineNode,inputParam,outMap,variablesMap);
|
||||
ExecuteUtils.terminalCondition(engineNode, inputParam, outMap, variablesMap);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -635,17 +647,13 @@ public class RuleSetNode implements EngineRunnerNode {
|
||||
case 2:
|
||||
RuleVersionVo ruleVersionVo = versionService.queryById(versionId);
|
||||
ruleInfo.setVersion(ruleVersionVo);
|
||||
ruleInfo.setScore(ruleVersionVo.getScore());
|
||||
break;
|
||||
case 3:
|
||||
RuleScriptVersion ruleScriptVersion = ruleScriptVersionService.queryById(versionId);
|
||||
ruleInfo.setScriptVersion(ruleScriptVersion);
|
||||
ruleInfo.setVersion(JSON.parseObject(JSON.toJSONString(ruleScriptVersion), RuleVersionVo.class));
|
||||
ruleInfo.setScore(0);
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
ruleInfo.setScore(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -665,7 +673,7 @@ public class RuleSetNode implements EngineRunnerNode {
|
||||
private boolean executeScriptRule(Map<String, Object> inputParam, Map<String, Object> outMap, RuleInfo rule, CopyOnWriteArrayList<Map> ruleResultList) {
|
||||
boolean hitFlag = false;
|
||||
RuleScriptVersion scriptVersion = rule.getScriptVersion();
|
||||
if (RuleConst.ScriptType.GROOVY.equals(rule.getScriptType())&&RuleConst.ScriptType.GROOVY.equals( scriptVersion.getScriptType())) {
|
||||
if (RuleConst.ScriptType.GROOVY.equals(rule.getScriptType()) && RuleConst.ScriptType.GROOVY.equals(scriptVersion.getScriptType())) {
|
||||
//groovy脚本执行
|
||||
//取出需要执行的版本
|
||||
if (scriptVersion == null || StringUtils.isBlank(scriptVersion.getScriptContent())) {
|
||||
@@ -676,7 +684,7 @@ public class RuleSetNode implements EngineRunnerNode {
|
||||
//取出本规则集的规则列表
|
||||
Map<String, Object> ruleMap = new HashMap<>();
|
||||
ruleMap.put("ruleId", rule.getId());
|
||||
ruleMap.put("ruleVersionId",scriptVersion.getId());
|
||||
ruleMap.put("ruleVersionId", scriptVersion.getId());
|
||||
ruleMap.put("ruleCode", rule.getCode());
|
||||
ruleMap.put("ruleName", rule.getName());
|
||||
ruleMap.put("versionCode", scriptVersion.getVersionCode());
|
||||
@@ -686,10 +694,10 @@ public class RuleSetNode implements EngineRunnerNode {
|
||||
|
||||
|
||||
String resultFieldEn = "hitResult";
|
||||
String resultEn = "rule_"+rule.getDifficulty()+"_"+rule.getId()+"_"+scriptVersion.getId()+"_hitResult";
|
||||
String scoreEn = "rule_"+rule.getDifficulty()+"_"+rule.getId()+"_"+scriptVersion.getId()+"_score";
|
||||
String resultEn = "rule_" + rule.getDifficulty() + "_" + rule.getId() + "_" + scriptVersion.getId() + "_hitResult";
|
||||
String scoreEn = "rule_" + rule.getDifficulty() + "_" + rule.getId() + "_" + scriptVersion.getId() + "_score";
|
||||
inputParam.put(resultEn, "未命中");
|
||||
inputParam.put(scoreEn,0);
|
||||
inputParam.put(scoreEn, 0);
|
||||
//根据执行的最终结果处理此规则输出内容
|
||||
List fieldList = new ArrayList<>();
|
||||
JSONObject resultJson = new JSONObject();
|
||||
@@ -709,7 +717,7 @@ public class RuleSetNode implements EngineRunnerNode {
|
||||
fieldList = fieldListJson.toJavaList(Object.class);
|
||||
List list = new ArrayList();
|
||||
for (Object o : fieldList) {
|
||||
if (o!=null&& o instanceof Map){
|
||||
if (o != null && o instanceof Map) {
|
||||
Map map = ExecuteUtils.handleGroovyResult((Map) o);
|
||||
list.add(map);
|
||||
}
|
||||
@@ -728,14 +736,14 @@ public class RuleSetNode implements EngineRunnerNode {
|
||||
}
|
||||
if ("命中".equals(result)) {
|
||||
hitFlag = true;
|
||||
inputParam.put(resultEn,"命中");
|
||||
inputParam.put(scoreEn,ruleScore);
|
||||
inputParam.put(resultEn, "命中");
|
||||
inputParam.put(scoreEn, ruleScore);
|
||||
}
|
||||
//更新入参
|
||||
if (updateInputMap!=null&&!updateInputMap.isEmpty()){
|
||||
Set<Map.Entry<String, Object>> entries = ExecuteUtils.handleGroovyResult(updateInputMap).entrySet();
|
||||
if (updateInputMap != null && !updateInputMap.isEmpty()) {
|
||||
Set<Map.Entry<String, Object>> entries = ExecuteUtils.handleGroovyResult(updateInputMap).entrySet();
|
||||
for (Map.Entry<String, Object> entry : entries) {
|
||||
inputParam.put(entry.getKey(),entry.getValue());
|
||||
inputParam.put(entry.getKey(), entry.getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,7 +47,6 @@ public class RuleInfoController {
|
||||
return ruleResponseEntityDto;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @api {POST} /v3/rule/getRuleList 3.20. V3规则 列表 list
|
||||
* @apiGroup knowledge
|
||||
|
||||
Reference in New Issue
Block a user