129 changed files with 2025 additions and 3472 deletions
			
			
		@ -0,0 +1,64 @@ | 
				
			|||
package io.sc.engine.rule.core.code.impl.support.processor; | 
				
			|||
 | 
				
			|||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; | 
				
			|||
import io.sc.engine.rule.core.enums.ProcessorType; | 
				
			|||
 | 
				
			|||
import java.util.List; | 
				
			|||
 | 
				
			|||
@JsonIgnoreProperties(ignoreUnknown=true) | 
				
			|||
public class ScoreCardItem { | 
				
			|||
    private String code; | 
				
			|||
    private String name; | 
				
			|||
    private Double weight; | 
				
			|||
    private ProcessorType type; | 
				
			|||
    private List<ConditionRange> conditionRange; | 
				
			|||
    private List<NumberRange> numberRange; | 
				
			|||
 | 
				
			|||
    public String getCode() { | 
				
			|||
        return code; | 
				
			|||
    } | 
				
			|||
 | 
				
			|||
    public void setCode(String code) { | 
				
			|||
        this.code = code; | 
				
			|||
    } | 
				
			|||
 | 
				
			|||
    public String getName() { | 
				
			|||
        return name; | 
				
			|||
    } | 
				
			|||
 | 
				
			|||
    public void setName(String name) { | 
				
			|||
        this.name = name; | 
				
			|||
    } | 
				
			|||
 | 
				
			|||
    public Double getWeight() { | 
				
			|||
        return weight; | 
				
			|||
    } | 
				
			|||
 | 
				
			|||
    public void setWeight(Double weight) { | 
				
			|||
        this.weight = weight; | 
				
			|||
    } | 
				
			|||
 | 
				
			|||
    public ProcessorType getType() { | 
				
			|||
        return type; | 
				
			|||
    } | 
				
			|||
 | 
				
			|||
    public void setType(ProcessorType type) { | 
				
			|||
        this.type = type; | 
				
			|||
    } | 
				
			|||
 | 
				
			|||
    public List<ConditionRange> getConditionRange() { | 
				
			|||
        return conditionRange; | 
				
			|||
    } | 
				
			|||
 | 
				
			|||
    public void setConditionRange(List<ConditionRange> conditionRange) { | 
				
			|||
        this.conditionRange = conditionRange; | 
				
			|||
    } | 
				
			|||
 | 
				
			|||
    public List<NumberRange> getNumberRange() { | 
				
			|||
        return numberRange; | 
				
			|||
    } | 
				
			|||
 | 
				
			|||
    public void setNumberRange(List<NumberRange> numberRange) { | 
				
			|||
        this.numberRange = numberRange; | 
				
			|||
    } | 
				
			|||
} | 
				
			|||
@ -0,0 +1,25 @@ | 
				
			|||
package io.sc.engine.rule.core.po.model.processor; | 
				
			|||
 | 
				
			|||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; | 
				
			|||
import com.fasterxml.jackson.annotation.JsonTypeName; | 
				
			|||
import io.sc.engine.rule.core.enums.ProcessorType; | 
				
			|||
import io.sc.engine.rule.core.po.model.ParameterProcessor; | 
				
			|||
 | 
				
			|||
@JsonTypeName("SCORE_CARD") | 
				
			|||
@JsonIgnoreProperties(ignoreUnknown=true) | 
				
			|||
public class ScoreCardParameterProcessor extends ParameterProcessor { | 
				
			|||
    private String scoreCard; | 
				
			|||
 | 
				
			|||
    public String getScoreCard() { | 
				
			|||
        return scoreCard; | 
				
			|||
    } | 
				
			|||
 | 
				
			|||
    public void setScoreCard(String scoreCard) { | 
				
			|||
        this.scoreCard = scoreCard; | 
				
			|||
    } | 
				
			|||
 | 
				
			|||
    @Override | 
				
			|||
    public ProcessorType getType() { | 
				
			|||
        return ProcessorType.SCORE_CARD; | 
				
			|||
    } | 
				
			|||
} | 
				
			|||
@ -1,29 +0,0 @@ | 
				
			|||
package io.sc.engine.rule.core.po.resource; | 
				
			|||
 | 
				
			|||
import java.util.ArrayList; | 
				
			|||
import java.util.List; | 
				
			|||
 | 
				
			|||
import io.sc.engine.rule.core.enums.ResourceType; | 
				
			|||
import io.sc.engine.rule.core.po.scorecard.ScoreCardVar; | 
				
			|||
 | 
				
			|||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; | 
				
			|||
import com.fasterxml.jackson.annotation.JsonTypeName; | 
				
			|||
 | 
				
			|||
@JsonTypeName("SCORE_CARD") | 
				
			|||
@JsonIgnoreProperties(ignoreUnknown=true) | 
				
			|||
public class ScoreCardResource extends ReleasableResource { | 
				
			|||
	protected List<ScoreCardVar> scoreCardVars =new ArrayList<ScoreCardVar>(); | 
				
			|||
 | 
				
			|||
	public List<ScoreCardVar> getScoreCardVars() { | 
				
			|||
		return scoreCardVars; | 
				
			|||
	} | 
				
			|||
 | 
				
			|||
	public void setScoreCardVars(List<ScoreCardVar> scoreCardVars) { | 
				
			|||
		this.scoreCardVars = scoreCardVars; | 
				
			|||
	} | 
				
			|||
	 | 
				
			|||
	@Override | 
				
			|||
	public ResourceType getType() { | 
				
			|||
		return ResourceType.SCORE_CARD; | 
				
			|||
	} | 
				
			|||
} | 
				
			|||
@ -1,29 +0,0 @@ | 
				
			|||
package io.sc.engine.rule.core.po.scorecard; | 
				
			|||
 | 
				
			|||
import io.sc.engine.rule.core.enums.ScoreCardVarType; | 
				
			|||
 | 
				
			|||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; | 
				
			|||
import com.fasterxml.jackson.annotation.JsonTypeName; | 
				
			|||
 | 
				
			|||
/** | 
				
			|||
 * 评分卡变量(数值分段) | 
				
			|||
 * @author wangshaoping | 
				
			|||
 * | 
				
			|||
 */ | 
				
			|||
@JsonTypeName("INDICATOR_NUMBER_RANGE") | 
				
			|||
@JsonIgnoreProperties(ignoreUnknown=true) | 
				
			|||
public class NumberRangeScoreCardIndicatorVar extends ScoreCardIndicatorVar { | 
				
			|||
	private String numberRange;//数值分段
 | 
				
			|||
	 | 
				
			|||
	@Override | 
				
			|||
	public ScoreCardVarType getType() { | 
				
			|||
		return ScoreCardVarType.INDICATOR_NUMBER_RANGE; | 
				
			|||
	} | 
				
			|||
	 | 
				
			|||
	public String getNumberRange() { | 
				
			|||
		return numberRange; | 
				
			|||
	} | 
				
			|||
	public void setNumberRange(String numberRange) { | 
				
			|||
		this.numberRange = numberRange; | 
				
			|||
	} | 
				
			|||
} | 
				
			|||
@ -1,29 +0,0 @@ | 
				
			|||
package io.sc.engine.rule.core.po.scorecard; | 
				
			|||
 | 
				
			|||
import io.sc.engine.rule.core.enums.ScoreCardVarType; | 
				
			|||
 | 
				
			|||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; | 
				
			|||
import com.fasterxml.jackson.annotation.JsonTypeName; | 
				
			|||
 | 
				
			|||
/** | 
				
			|||
 * 评分卡变量(数值分段) | 
				
			|||
 * @author wangshaoping | 
				
			|||
 * | 
				
			|||
 */ | 
				
			|||
@JsonTypeName("NUMBER_RANGE") | 
				
			|||
@JsonIgnoreProperties(ignoreUnknown=true) | 
				
			|||
public class NumberRangeScoreCardVar extends ScoreCardVar { | 
				
			|||
	private String numberRange;//数值分段
 | 
				
			|||
	 | 
				
			|||
	@Override | 
				
			|||
	public ScoreCardVarType getType() { | 
				
			|||
		return ScoreCardVarType.NUMBER_RANGE; | 
				
			|||
	} | 
				
			|||
	 | 
				
			|||
	public String getNumberRange() { | 
				
			|||
		return numberRange; | 
				
			|||
	} | 
				
			|||
	public void setNumberRange(String numberRange) { | 
				
			|||
		this.numberRange = numberRange; | 
				
			|||
	} | 
				
			|||
} | 
				
			|||
@ -1,29 +0,0 @@ | 
				
			|||
package io.sc.engine.rule.core.po.scorecard; | 
				
			|||
 | 
				
			|||
import io.sc.engine.rule.core.enums.ScoreCardVarType; | 
				
			|||
 | 
				
			|||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; | 
				
			|||
import com.fasterxml.jackson.annotation.JsonTypeName; | 
				
			|||
 | 
				
			|||
/** | 
				
			|||
 * 评分卡变量(选项) | 
				
			|||
 * @author wangshaoping | 
				
			|||
 * | 
				
			|||
 */ | 
				
			|||
@JsonTypeName("INDICATOR_OPTION") | 
				
			|||
@JsonIgnoreProperties(ignoreUnknown=true) | 
				
			|||
public class OptionScoreCardIndicatorVar extends ScoreCardIndicatorVar { | 
				
			|||
	private String option;//选项
 | 
				
			|||
	 | 
				
			|||
	@Override | 
				
			|||
	public ScoreCardVarType getType() { | 
				
			|||
		return ScoreCardVarType.INDICATOR_OPTION; | 
				
			|||
	} | 
				
			|||
	 | 
				
			|||
	public String getOption() { | 
				
			|||
		return option; | 
				
			|||
	} | 
				
			|||
	public void setOption(String option) { | 
				
			|||
		this.option = option; | 
				
			|||
	} | 
				
			|||
} | 
				
			|||
@ -1,29 +0,0 @@ | 
				
			|||
package io.sc.engine.rule.core.po.scorecard; | 
				
			|||
 | 
				
			|||
import io.sc.engine.rule.core.enums.ScoreCardVarType; | 
				
			|||
 | 
				
			|||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; | 
				
			|||
import com.fasterxml.jackson.annotation.JsonTypeName; | 
				
			|||
 | 
				
			|||
/** | 
				
			|||
 * 评分卡变量(选项) | 
				
			|||
 * @author wangshaoping | 
				
			|||
 * | 
				
			|||
 */ | 
				
			|||
@JsonTypeName("OPTION") | 
				
			|||
@JsonIgnoreProperties(ignoreUnknown=true) | 
				
			|||
public class OptionScoreCardVar extends ScoreCardVar { | 
				
			|||
	private String option;//选项
 | 
				
			|||
	 | 
				
			|||
	@Override | 
				
			|||
	public ScoreCardVarType getType() { | 
				
			|||
		return ScoreCardVarType.OPTION; | 
				
			|||
	} | 
				
			|||
	 | 
				
			|||
	public String getOption() { | 
				
			|||
		return option; | 
				
			|||
	} | 
				
			|||
	public void setOption(String option) { | 
				
			|||
		this.option = option; | 
				
			|||
	} | 
				
			|||
} | 
				
			|||
@ -1,21 +0,0 @@ | 
				
			|||
package io.sc.engine.rule.core.po.scorecard; | 
				
			|||
 | 
				
			|||
import io.sc.engine.rule.core.enums.ScoreCardVarType; | 
				
			|||
 | 
				
			|||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; | 
				
			|||
import com.fasterxml.jackson.annotation.JsonTypeName; | 
				
			|||
 | 
				
			|||
/** | 
				
			|||
 * 评分卡变量(指标值) | 
				
			|||
 * @author wangshaoping | 
				
			|||
 * | 
				
			|||
 */ | 
				
			|||
@JsonTypeName("INDICATOR_VALUE") | 
				
			|||
@JsonIgnoreProperties(ignoreUnknown=true) | 
				
			|||
public class ScoreCardIndicatorValueVar extends ScoreCardIndicatorVar { | 
				
			|||
	 | 
				
			|||
	@Override | 
				
			|||
	public ScoreCardVarType getType() { | 
				
			|||
		return ScoreCardVarType.INDICATOR_VALUE; | 
				
			|||
	} | 
				
			|||
} | 
				
			|||
@ -1,36 +0,0 @@ | 
				
			|||
package io.sc.engine.rule.core.po.scorecard; | 
				
			|||
 | 
				
			|||
/** | 
				
			|||
 * 评分卡变量(指标) | 
				
			|||
 * @author wangshaoping | 
				
			|||
 * | 
				
			|||
 */ | 
				
			|||
public abstract class ScoreCardIndicatorVar extends ScoreCardVar{ | 
				
			|||
	protected String libCode;//库代码
 | 
				
			|||
	protected Integer libVersion;//库版本
 | 
				
			|||
	protected String indicatorCode;//指标代码
 | 
				
			|||
 | 
				
			|||
	public String getLibCode() { | 
				
			|||
		return libCode; | 
				
			|||
	} | 
				
			|||
 | 
				
			|||
	public void setLibCode(String libCode) { | 
				
			|||
		this.libCode = libCode; | 
				
			|||
	} | 
				
			|||
 | 
				
			|||
	public Integer getLibVersion() { | 
				
			|||
		return libVersion; | 
				
			|||
	} | 
				
			|||
 | 
				
			|||
	public void setLibVersion(Integer libVersion) { | 
				
			|||
		this.libVersion = libVersion; | 
				
			|||
	} | 
				
			|||
 | 
				
			|||
	public String getIndicatorCode() { | 
				
			|||
		return indicatorCode; | 
				
			|||
	} | 
				
			|||
 | 
				
			|||
	public void setIndicatorCode(String indicatorCode) { | 
				
			|||
		this.indicatorCode = indicatorCode; | 
				
			|||
	} | 
				
			|||
} | 
				
			|||
@ -1,53 +0,0 @@ | 
				
			|||
package io.sc.engine.rule.core.po.scorecard; | 
				
			|||
 | 
				
			|||
import io.sc.engine.rule.core.enums.ScoreCardVarType; | 
				
			|||
 | 
				
			|||
import com.fasterxml.jackson.annotation.JsonSubTypes; | 
				
			|||
import com.fasterxml.jackson.annotation.JsonTypeInfo; | 
				
			|||
 | 
				
			|||
/** | 
				
			|||
 * 评分卡变量 | 
				
			|||
 * @author wangshaoping | 
				
			|||
 * | 
				
			|||
 */ | 
				
			|||
@JsonTypeInfo(use=JsonTypeInfo.Id.NAME, include=JsonTypeInfo.As.PROPERTY, property="type",defaultImpl=OptionScoreCardVar.class) | 
				
			|||
@JsonSubTypes({ | 
				
			|||
	@JsonSubTypes.Type(value=NumberRangeScoreCardVar.class),			//数值分段
 | 
				
			|||
	@JsonSubTypes.Type(value=OptionScoreCardVar.class),					//选项
 | 
				
			|||
	@JsonSubTypes.Type(value=NumberRangeScoreCardIndicatorVar.class),	//数值分段(指标)
 | 
				
			|||
	@JsonSubTypes.Type(value=OptionScoreCardIndicatorVar.class),		//选项(指标)
 | 
				
			|||
	@JsonSubTypes.Type(value=ScoreCardIndicatorValueVar.class)			//指标值	
 | 
				
			|||
}) | 
				
			|||
public abstract class ScoreCardVar { | 
				
			|||
	protected String id;//ID,主键
 | 
				
			|||
	protected String code;//代码
 | 
				
			|||
	protected String name;//名称
 | 
				
			|||
	protected Integer order;//排序
 | 
				
			|||
	 | 
				
			|||
	public abstract ScoreCardVarType getType(); | 
				
			|||
	 | 
				
			|||
	public String getId() { | 
				
			|||
		return id; | 
				
			|||
	} | 
				
			|||
	public void setId(String id) { | 
				
			|||
		this.id = id; | 
				
			|||
	} | 
				
			|||
	public String getCode() { | 
				
			|||
		return code; | 
				
			|||
	} | 
				
			|||
	public void setCode(String code) { | 
				
			|||
		this.code = code; | 
				
			|||
	} | 
				
			|||
	public String getName() { | 
				
			|||
		return name; | 
				
			|||
	} | 
				
			|||
	public void setName(String name) { | 
				
			|||
		this.name = name; | 
				
			|||
	} | 
				
			|||
	public Integer getOrder() { | 
				
			|||
		return order; | 
				
			|||
	} | 
				
			|||
	public void setOrder(Integer order) { | 
				
			|||
		this.order = order; | 
				
			|||
	} | 
				
			|||
} | 
				
			|||
@ -0,0 +1,30 @@ | 
				
			|||
class ValueTypeUtil { | 
				
			|||
  /** | 
				
			|||
   * 是否是基本类型 | 
				
			|||
   * @param valueType 值类型 | 
				
			|||
   * @returns 是否是基本类型 | 
				
			|||
   */ | 
				
			|||
  public static isBase(valueType: string) { | 
				
			|||
    return ( | 
				
			|||
      valueType == 'java.lang.Boolean' || | 
				
			|||
      valueType == 'Boolean' || | 
				
			|||
      valueType == 'java.lang.Long' || | 
				
			|||
      valueType == 'Long' || | 
				
			|||
      valueType == 'java.lang.Float' || | 
				
			|||
      valueType == 'Float' || | 
				
			|||
      valueType == 'java.math.BigDecimal' || | 
				
			|||
      valueType == 'java.lang.String' || | 
				
			|||
      valueType == 'String' || | 
				
			|||
      valueType == 'java.util.Date' || | 
				
			|||
      valueType == 'java.util.List' || | 
				
			|||
      valueType == 'List' || | 
				
			|||
      valueType == 'java.util.Map' || | 
				
			|||
      valueType == 'Map' || | 
				
			|||
      valueType == 'io.sc.engine.rule.core.classes.ResourceAbstract' || | 
				
			|||
      valueType == 'io.sc.engine.rule.core.classes.RuleResult' || | 
				
			|||
      valueType == 'io.sc.engine.rule.core.classes.SingleRuleResult' | 
				
			|||
    ); | 
				
			|||
  } | 
				
			|||
} | 
				
			|||
 | 
				
			|||
export { ValueTypeUtil }; | 
				
			|||
@ -0,0 +1,80 @@ | 
				
			|||
import { axios, Environment } from 'platform-core'; | 
				
			|||
import { AutoCompletionManager } from '@/views/shared/AutoCompletionManager'; | 
				
			|||
import { UserDefinedFunctionsManager } from '@/views/shared/UserDefinedFunctionsManager'; | 
				
			|||
 | 
				
			|||
/** | 
				
			|||
 * 处理器接口 | 
				
			|||
 */ | 
				
			|||
abstract class Processor { | 
				
			|||
  public static PARAMETER: string = 'parameter'; | 
				
			|||
  public static INDICATOR: string = 'indicator'; | 
				
			|||
  public static SCORE_CARD: string = 'scoreCard'; | 
				
			|||
 | 
				
			|||
  targetType: string; | 
				
			|||
  autoCompletionManager: any; | 
				
			|||
  userDefinedFunctionsManager: any; | 
				
			|||
 | 
				
			|||
  constructor(targetType: string) { | 
				
			|||
    this.targetType = targetType; | 
				
			|||
    this.autoCompletionManager = new AutoCompletionManager(); | 
				
			|||
    this.userDefinedFunctionsManager = new UserDefinedFunctionsManager(); | 
				
			|||
  } | 
				
			|||
 | 
				
			|||
  /** | 
				
			|||
   * 获取工具栏按钮对象 | 
				
			|||
   * @param target 目标对象 | 
				
			|||
   */ | 
				
			|||
  abstract getToolbarAction(target: any): any; | 
				
			|||
 | 
				
			|||
  /** | 
				
			|||
   * 表格字段显示内容 | 
				
			|||
   * @param row 表格行数据 | 
				
			|||
   */ | 
				
			|||
  abstract format(row: any): any; | 
				
			|||
 | 
				
			|||
  /** | 
				
			|||
   * 获取编辑器对话框字段列表 | 
				
			|||
   * @param context 上下文对象 | 
				
			|||
   */ | 
				
			|||
  abstract getEditorFields(context?: any): any; | 
				
			|||
 | 
				
			|||
  /** | 
				
			|||
   * 获取用于显示查看信息的字段列表 | 
				
			|||
   * @param context 上下文对象 | 
				
			|||
   */ | 
				
			|||
  abstract getViewerFields(context?: any): any; | 
				
			|||
 | 
				
			|||
  /** | 
				
			|||
   * 表单提交前的操作 | 
				
			|||
   * @param args 参数对象 | 
				
			|||
   */ | 
				
			|||
  abstract beforeEditorDataSubmit(args: any): void; | 
				
			|||
 | 
				
			|||
  /** | 
				
			|||
   * 编辑表单打开后的操作 | 
				
			|||
   * @param args 参数对象 | 
				
			|||
   */ | 
				
			|||
  abstract afterEditorOpen(args: any): void; | 
				
			|||
 | 
				
			|||
  /** | 
				
			|||
   * 初始化 code-mirror 代码提示自动完成管理器 | 
				
			|||
   * @param args 参数对象 | 
				
			|||
   */ | 
				
			|||
  initAutoCompletionManager(args: any) { | 
				
			|||
    if (this.targetType === Processor.PARAMETER) { | 
				
			|||
      this.autoCompletionManager.load(Environment.apiContextPath('/api/re/common/listParameterAndValueTypeByParameterId/' + args.target.id)); | 
				
			|||
    } else if (this.targetType === Processor.INDICATOR) { | 
				
			|||
      this.autoCompletionManager.load(Environment.apiContextPath('/api/re/common/listParameterAndValueTypeByIndicatorId/' + args.target.id)); | 
				
			|||
    } | 
				
			|||
  } | 
				
			|||
 | 
				
			|||
  /** | 
				
			|||
   * 初始化用户自定义函数管理器 | 
				
			|||
   * @param args 参数对象 | 
				
			|||
   */ | 
				
			|||
  initUserDefinedFunctionsManager(args: any) { | 
				
			|||
    this.userDefinedFunctionsManager.load(); | 
				
			|||
  } | 
				
			|||
} | 
				
			|||
 | 
				
			|||
export { Processor }; | 
				
			|||
@ -0,0 +1,154 @@ | 
				
			|||
import { Processor } from './Processor'; | 
				
			|||
import { | 
				
			|||
  Arithmetic, | 
				
			|||
  ConditionRange, | 
				
			|||
  DecisionTable, | 
				
			|||
  DecisionTable2C, | 
				
			|||
  DecisionTree, | 
				
			|||
  ExecutionFlow, | 
				
			|||
  GroovyScript, | 
				
			|||
  MathFormula, | 
				
			|||
  NumberRange, | 
				
			|||
  ObjectProperties, | 
				
			|||
  OptionValue, | 
				
			|||
  Pmml, | 
				
			|||
  Rule, | 
				
			|||
  ScoreCard, | 
				
			|||
  SingleRule, | 
				
			|||
  Sql, | 
				
			|||
  Ternary, | 
				
			|||
  WhenThen, | 
				
			|||
} from './processors'; | 
				
			|||
 | 
				
			|||
class ProcessorManager { | 
				
			|||
  static PROCESSOR_TYPES_PARAMETER: string[] = [ | 
				
			|||
    'OBJECT_PROPERTIES', | 
				
			|||
    'OPTION_VALUE', | 
				
			|||
    'MATH_FORMULA', | 
				
			|||
    'ARITHMETIC', | 
				
			|||
    'TERNARY', | 
				
			|||
    'WHEN_THEN', | 
				
			|||
    'NUMBER_RANGE', | 
				
			|||
    'CONDITION_RANGE', | 
				
			|||
    'SCORE_CARD', | 
				
			|||
    'DECISION_TABLE_2C', | 
				
			|||
    'DECISION_TABLE', | 
				
			|||
    'DECISION_TREE', | 
				
			|||
    'EXECUTION_FLOW', | 
				
			|||
    'PMML', | 
				
			|||
    'GROOVY_SCRIPT', | 
				
			|||
    'SQL', | 
				
			|||
    'RULE', | 
				
			|||
    'SINGLE_RULE', | 
				
			|||
  ]; | 
				
			|||
  static PROCESSOR_TYPES_INDICATOR = [ | 
				
			|||
    'OBJECT_PROPERTIES', | 
				
			|||
    'MATH_FORMULA', | 
				
			|||
    'ARITHMETIC', | 
				
			|||
    'TERNARY', | 
				
			|||
    'WHEN_THEN', | 
				
			|||
    'NUMBER_RANGE', | 
				
			|||
    'CONDITION_RANGE', | 
				
			|||
    'GROOVY_SCRIPT', | 
				
			|||
    'SQL', | 
				
			|||
  ]; | 
				
			|||
  targetType: string; | 
				
			|||
  processors: any; | 
				
			|||
 | 
				
			|||
  constructor(targetType: string) { | 
				
			|||
    this.targetType = targetType; | 
				
			|||
    this.processors = {}; | 
				
			|||
    this.processors.ARITHMETIC = new Arithmetic(this.targetType); | 
				
			|||
    this.processors.CONDITION_RANGE = new ConditionRange(this.targetType); | 
				
			|||
    this.processors.DECISION_TABLE = new DecisionTable(this.targetType); | 
				
			|||
    this.processors.DECISION_TABLE_2C = new DecisionTable2C(this.targetType); | 
				
			|||
    this.processors.DECISION_TREE = new DecisionTree(this.targetType); | 
				
			|||
    this.processors.EXECUTION_FLOW = new ExecutionFlow(this.targetType); | 
				
			|||
    this.processors.GROOVY_SCRIPT = new GroovyScript(this.targetType); | 
				
			|||
    this.processors.MATH_FORMULA = new MathFormula(this.targetType); | 
				
			|||
    this.processors.NUMBER_RANGE = new NumberRange(this.targetType); | 
				
			|||
    this.processors.OBJECT_PROPERTIES = new ObjectProperties(this.targetType); | 
				
			|||
    this.processors.OPTION_VALUE = new OptionValue(this.targetType); | 
				
			|||
    this.processors.PMML = new Pmml(this.targetType); | 
				
			|||
    this.processors.RULE = new Rule(this.targetType); | 
				
			|||
    this.processors.SCORE_CARD = new ScoreCard(this.targetType); | 
				
			|||
    this.processors.SINGLE_RULE = new SingleRule(this.targetType); | 
				
			|||
    this.processors.SQL = new Sql(this.targetType); | 
				
			|||
    this.processors.TERNARY = new Ternary(this.targetType); | 
				
			|||
    this.processors.WHEN_THEN = new WhenThen(this.targetType); | 
				
			|||
  } | 
				
			|||
 | 
				
			|||
  public getToolbarAction(target: any): any { | 
				
			|||
    const result: any = []; | 
				
			|||
    switch (this.targetType) { | 
				
			|||
      case Processor.PARAMETER: | 
				
			|||
        ProcessorManager.PROCESSOR_TYPES_PARAMETER.forEach((name) => { | 
				
			|||
          result.push(this.processors[name].getToolbarAction(target)); | 
				
			|||
        }); | 
				
			|||
        break; | 
				
			|||
      case Processor.INDICATOR: | 
				
			|||
        ProcessorManager.PROCESSOR_TYPES_INDICATOR.forEach((name) => { | 
				
			|||
          result.push(this.processors[name].getToolbarAction(target)); | 
				
			|||
        }); | 
				
			|||
        break; | 
				
			|||
    } | 
				
			|||
    return result; | 
				
			|||
  } | 
				
			|||
 | 
				
			|||
  public format(value: any, row: any): any { | 
				
			|||
    if (this.processors[row.type]) { | 
				
			|||
      return this.processors[row.type].format(row); | 
				
			|||
    } | 
				
			|||
    return value; | 
				
			|||
  } | 
				
			|||
 | 
				
			|||
  public getEditorFields(context?: any): any { | 
				
			|||
    const result: any = []; | 
				
			|||
    switch (this.targetType) { | 
				
			|||
      case Processor.PARAMETER: | 
				
			|||
        ProcessorManager.PROCESSOR_TYPES_PARAMETER.forEach((name) => { | 
				
			|||
          result.push(...this.processors[name].getEditorFields(context)); | 
				
			|||
        }); | 
				
			|||
        break; | 
				
			|||
      case Processor.INDICATOR: | 
				
			|||
        ProcessorManager.PROCESSOR_TYPES_INDICATOR.forEach((name) => { | 
				
			|||
          result.push(...this.processors[name].getEditorFields(context)); | 
				
			|||
        }); | 
				
			|||
        break; | 
				
			|||
    } | 
				
			|||
    return result; | 
				
			|||
  } | 
				
			|||
 | 
				
			|||
  public getViewerFields(context?: any): any { | 
				
			|||
    const result: any = []; | 
				
			|||
    switch (this.targetType) { | 
				
			|||
      case Processor.PARAMETER: | 
				
			|||
        ProcessorManager.PROCESSOR_TYPES_PARAMETER.forEach((name) => { | 
				
			|||
          result.push(...this.processors[name].getViewerFields(context)); | 
				
			|||
        }); | 
				
			|||
        break; | 
				
			|||
      case Processor.INDICATOR: | 
				
			|||
        ProcessorManager.PROCESSOR_TYPES_INDICATOR.forEach((name) => { | 
				
			|||
          result.push(...this.processors[name].getViewerFields(context)); | 
				
			|||
        }); | 
				
			|||
        break; | 
				
			|||
    } | 
				
			|||
    return result; | 
				
			|||
  } | 
				
			|||
 | 
				
			|||
  public beforeEditorDataSubmit(args: any): void { | 
				
			|||
    if (this.processors[args.data.type]) { | 
				
			|||
      this.processors[args.data.type].beforeEditorDataSubmit(args); | 
				
			|||
    } | 
				
			|||
  } | 
				
			|||
 | 
				
			|||
  public afterEditorOpen(args: any): void { | 
				
			|||
    //const type = args.grid.getEditorForm().getFieldValue('type');
 | 
				
			|||
    const type = 'OPTION_VALUE'; | 
				
			|||
    if (this.processors[type]) { | 
				
			|||
      this.processors[type].afterEditorOpen(args); | 
				
			|||
    } | 
				
			|||
  } | 
				
			|||
} | 
				
			|||
 | 
				
			|||
export { ProcessorManager }; | 
				
			|||
@ -0,0 +1,230 @@ | 
				
			|||
import { ref, toRaw } from 'vue'; | 
				
			|||
import { $t, axios, Environment, Tools } from 'platform-core'; | 
				
			|||
import { Processor } from '../Processor'; | 
				
			|||
import { ConditionRange } from './ConditionRange'; | 
				
			|||
import { NumberRange } from './NumberRange'; | 
				
			|||
 | 
				
			|||
const parameterOptionsRef = ref(<any>[]); | 
				
			|||
const varProcessorTypeOptionsRef = ref(<any>[]); | 
				
			|||
const conditionRange = new ConditionRange(Processor.SCORE_CARD); | 
				
			|||
const numberRange = new NumberRange(Processor.SCORE_CARD); | 
				
			|||
 | 
				
			|||
class ScoreCard extends Processor { | 
				
			|||
  public getToolbarAction(target: any): any { | 
				
			|||
    return { | 
				
			|||
      extend: 'add', | 
				
			|||
      name: 'scoreCard', | 
				
			|||
      label: $t('io.sc.engine.rule.core.enums.ProcessorType.SCORE_CARD'), | 
				
			|||
      icon: 'bi-credit-card-2-front', | 
				
			|||
      enableIf: (args) => { | 
				
			|||
        return target.type !== 'RULE_RESULT' && target.type !== 'SINGLE_RULE_RESULT'; | 
				
			|||
      }, | 
				
			|||
      afterClick: (args: any) => { | 
				
			|||
        args.grid.getEditorForm().setFieldValue('type', 'SCORE_CARD'); | 
				
			|||
      }, | 
				
			|||
    }; | 
				
			|||
  } | 
				
			|||
 | 
				
			|||
  public format(row: any): any { | 
				
			|||
    const objs = Tools.json2Object(row.scoreCard); | 
				
			|||
    if (objs) { | 
				
			|||
      let str = `<div class='border border-b-0'>`; | 
				
			|||
      str += `<table width='100%' height='100%'>`; | 
				
			|||
      objs.forEach((obj: any) => { | 
				
			|||
        str += '<tr>'; | 
				
			|||
        str += '	<td>' + $t('io.sc.engine.rule.core.enums.ProcessorType.' + obj.type) + '</td>'; | 
				
			|||
        str += '	<td>' + obj.name + '</td>'; | 
				
			|||
        if (obj.type === 'CONDITION_RANGE') { | 
				
			|||
          str += '	<td style="pading:0px">' + conditionRange.format({ conditionRange: Tools.object2Json(obj.conditionRange) }) + '</td>'; | 
				
			|||
        } else if (obj.type === 'NUMBER_RANGE') { | 
				
			|||
          str += '	<td>' + numberRange.format({ numberRange: Tools.object2Json(obj.numberRange) }) + '</td>'; | 
				
			|||
        } | 
				
			|||
        str += '</tr>'; | 
				
			|||
      }); | 
				
			|||
      str += '</table>'; | 
				
			|||
      str += `</div>`; | 
				
			|||
      return str; | 
				
			|||
    } | 
				
			|||
    return ''; | 
				
			|||
  } | 
				
			|||
 | 
				
			|||
  public getEditorFields(context?: any): any { | 
				
			|||
    return [ | 
				
			|||
      { | 
				
			|||
        colSpan: 5, | 
				
			|||
        name: 'scoreCard', | 
				
			|||
        label: $t('re.resources.designer.processor.grid.entity.scoreCard'), | 
				
			|||
        type: 'w-grid', | 
				
			|||
        showIf: (args: any) => { | 
				
			|||
          return 'SCORE_CARD' === args.form.getFieldValue('type'); | 
				
			|||
        }, | 
				
			|||
        height: 600, | 
				
			|||
        dbClickOperation: 'edit', | 
				
			|||
        autoFetchData: false, | 
				
			|||
        denseBody: true, | 
				
			|||
        draggable: 'local', | 
				
			|||
        pageable: false, | 
				
			|||
        configButton: false, | 
				
			|||
        toolbarConfigure: { noIcon: false }, | 
				
			|||
        toolbarActions: [ | 
				
			|||
          [ | 
				
			|||
            { | 
				
			|||
              extend: 'add', | 
				
			|||
              click: undefined, | 
				
			|||
            }, | 
				
			|||
            conditionRange.getToolbarAction({}), | 
				
			|||
            numberRange.getToolbarAction({}), | 
				
			|||
          ], | 
				
			|||
          'clone', | 
				
			|||
          'edit', | 
				
			|||
          { | 
				
			|||
            extend: 'remove', | 
				
			|||
            click: (args: any) => { | 
				
			|||
              const grid = args.grid.getEditorForm().getFieldComponent('scoreCard'); | 
				
			|||
              grid.removeLocalData(args.selecteds); | 
				
			|||
            }, | 
				
			|||
          }, | 
				
			|||
        ], | 
				
			|||
        primaryKey: 'uuid', | 
				
			|||
        columns: [ | 
				
			|||
          { width: 200, name: 'uuid', label: 'uuid', hidden: true }, | 
				
			|||
          { | 
				
			|||
            width: 120, | 
				
			|||
            name: 'code', | 
				
			|||
            label: $t('code'), | 
				
			|||
            sortable: false, | 
				
			|||
          }, | 
				
			|||
          { | 
				
			|||
            width: 120, | 
				
			|||
            name: 'name', | 
				
			|||
            label: $t('name'), | 
				
			|||
            sortable: false, | 
				
			|||
          }, | 
				
			|||
          { | 
				
			|||
            width: 80, | 
				
			|||
            name: 'weight', | 
				
			|||
            label: $t('weight'), | 
				
			|||
            sortable: false, | 
				
			|||
          }, | 
				
			|||
          { | 
				
			|||
            width: 100, | 
				
			|||
            name: 'type', | 
				
			|||
            label: $t('type'), | 
				
			|||
            sortable: false, | 
				
			|||
            format: (value, row: any) => { | 
				
			|||
              return $t('io.sc.engine.rule.core.enums.ProcessorType.' + row.type); | 
				
			|||
            }, | 
				
			|||
          }, | 
				
			|||
          { | 
				
			|||
            width: '100%', | 
				
			|||
            name: 'content', | 
				
			|||
            label: $t('content'), | 
				
			|||
            sortable: false, | 
				
			|||
            format: (value, row: any) => { | 
				
			|||
              const data = JSON.parse(JSON.stringify(row)); | 
				
			|||
              data.conditionRange = Tools.object2Json(data.conditionRange); | 
				
			|||
              data.numberRange = Tools.object2Json(data.numberRange); | 
				
			|||
              switch (data.type) { | 
				
			|||
                case 'CONDITION_RANGE': | 
				
			|||
                  return conditionRange.format(data); | 
				
			|||
                case 'NUMBER_RANGE': | 
				
			|||
                  return numberRange.format(data); | 
				
			|||
              } | 
				
			|||
              return ''; | 
				
			|||
            }, | 
				
			|||
          }, | 
				
			|||
        ], | 
				
			|||
        editor: { | 
				
			|||
          dialog: { | 
				
			|||
            width: '800px', | 
				
			|||
          }, | 
				
			|||
          form: { | 
				
			|||
            colsNum: 5, | 
				
			|||
            fields: [ | 
				
			|||
              { name: 'uuid', label: 'uuid', showIf: false, colSpan: 4 }, | 
				
			|||
              { colSpan: 3, name: 'name', label: $t('name'), type: 'w-select', options: parameterOptionsRef.value }, | 
				
			|||
              { colSpan: 2, name: 'weight', label: $t('weight'), type: 'w-number', precision: 6 }, | 
				
			|||
              { name: 'type', label: $t('type'), type: 'w-text', showIf: false }, | 
				
			|||
              ...conditionRange.getEditorFields(), | 
				
			|||
              ...numberRange.getEditorFields(), | 
				
			|||
            ], | 
				
			|||
          }, | 
				
			|||
        }, | 
				
			|||
        // 评分卡变量对话框
 | 
				
			|||
        onBeforeEditorDataSubmit: (args: any) => { | 
				
			|||
          switch (args.data.type) { | 
				
			|||
            case 'CONDITION_RANGE': | 
				
			|||
              // args.data.conditionRange = Tools.object2Json(args.data.conditionRange);
 | 
				
			|||
              return conditionRange.beforeEditorDataSubmit(data); | 
				
			|||
            case 'NUMBER_RANGE': | 
				
			|||
              //args.data.numberRange = Tools.object2Json(args.data.numberRange);
 | 
				
			|||
              return numberRange.beforeEditorDataSubmit(data); | 
				
			|||
          } | 
				
			|||
        }, | 
				
			|||
        onAfterEditorOpen: (args: any) => { | 
				
			|||
          // const args: any = {};
 | 
				
			|||
          // args.grid = _args.grid;
 | 
				
			|||
          // args.data = Tools.deepClone(toValue(_args.data));
 | 
				
			|||
          // args.data.conditionRange = Tools.object2Json(args.data.conditionRange);
 | 
				
			|||
          // args.data.numberRange = Tools.object2Json(args.data.numberRange);
 | 
				
			|||
 | 
				
			|||
          // const data = Tools.deepClone(toValue(args.data));
 | 
				
			|||
          // data.conditionRange = Tools.object2Json(data.conditionRange);
 | 
				
			|||
          // data.numberRange = Tools.object2Json(data.numberRange);
 | 
				
			|||
          // args.data = data;
 | 
				
			|||
          const newArgs: any = {}; | 
				
			|||
          newArgs.grid = args.grid; | 
				
			|||
          newArgs.data = { | 
				
			|||
            conditionRange: Tools.object2Json(JSON.parse(JSON.stringify(args.data.conditionRange))), | 
				
			|||
            numberRange: Tools.object2Json(JSON.parse(JSON.stringify(args.data.numberRange))), | 
				
			|||
          }; | 
				
			|||
 | 
				
			|||
          switch (args.grid.getEditorForm().getFieldValue('type')) { | 
				
			|||
            case 'CONDITION_RANGE': | 
				
			|||
              //args.data.conditionRange = Tools.object2Json(JSON.parse(JSON.stringify(args.data.conditionRange)));
 | 
				
			|||
              return conditionRange.afterEditorOpen(newArgs); | 
				
			|||
            case 'NUMBER_RANGE': | 
				
			|||
              //args.data.numberRange = Tools.object2Json(JSON.parse(JSON.stringify(args.data.numberRange)));
 | 
				
			|||
              return numberRange.afterEditorOpen(newArgs); | 
				
			|||
          } | 
				
			|||
        }, | 
				
			|||
      }, | 
				
			|||
    ]; | 
				
			|||
  } | 
				
			|||
 | 
				
			|||
  public getViewerFields(context?: any): any { | 
				
			|||
    return [{ name: 'scoreCard', label: $t('re.resources.designer.processor.grid.entity.scoreCard') }]; | 
				
			|||
  } | 
				
			|||
 | 
				
			|||
  public beforeEditorDataSubmit(args: any): void { | 
				
			|||
    console.log(args); | 
				
			|||
  } | 
				
			|||
 | 
				
			|||
  public afterEditorOpen(args: any): void { | 
				
			|||
    varProcessorTypeOptionsRef.value = [ | 
				
			|||
      { label: $t('io.sc.engine.rule.core.enums.ProcessorType.CONDITION_RANGE'), value: 'CONDITION_RANGE' }, | 
				
			|||
      { label: $t('io.sc.engine.rule.core.enums.ProcessorType.NUMBER_RANGE'), value: 'NUMBER_RANGE' }, | 
				
			|||
    ]; | 
				
			|||
 | 
				
			|||
    axios.get(Environment.apiContextPath('/api/re/model/parameter/listParemtersByParameterId/' + args.target.id)).then((response) => { | 
				
			|||
      const data: any[] = response.data; | 
				
			|||
      const options: any[] = []; | 
				
			|||
      if (data && data.length > 0) { | 
				
			|||
        data.forEach((item) => { | 
				
			|||
          options.push({ | 
				
			|||
            label: item.name, | 
				
			|||
            value: item.code, | 
				
			|||
          }); | 
				
			|||
        }); | 
				
			|||
      } | 
				
			|||
      parameterOptionsRef.value = options; | 
				
			|||
    }); | 
				
			|||
 | 
				
			|||
    const grid = args.grid.getEditorForm().getFieldComponent('scoreCard'); | 
				
			|||
    const row = args.data; | 
				
			|||
    const rows = Tools.json2Object(row.scoreCard); | 
				
			|||
    grid.setLocalData(rows); | 
				
			|||
  } | 
				
			|||
} | 
				
			|||
 | 
				
			|||
export { ScoreCard }; | 
				
			|||
@ -1,96 +0,0 @@ | 
				
			|||
package io.sc.engine.rule.server.jpa.listener.handler; | 
				
			|||
 | 
				
			|||
import java.util.ArrayList; | 
				
			|||
import java.util.Date; | 
				
			|||
import java.util.HashMap; | 
				
			|||
import java.util.List; | 
				
			|||
import java.util.Map; | 
				
			|||
 | 
				
			|||
import org.springframework.beans.factory.annotation.Autowired; | 
				
			|||
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate; | 
				
			|||
import org.springframework.stereotype.Service; | 
				
			|||
import io.sc.engine.rule.server.resource.entity.ResourceEntity; | 
				
			|||
import io.sc.engine.rule.server.resource.service.ResourceService; | 
				
			|||
import io.sc.engine.rule.server.scorecard.entity.ScoreCardVarEntity; | 
				
			|||
import io.sc.engine.rule.server.testcase.entity.ResourceTestCaseEntity; | 
				
			|||
import io.sc.engine.rule.server.testcase.entity.TestCaseEntity; | 
				
			|||
import io.sc.platform.orm.entity.support.AbstractJpaEntityPersistentEventHandler; | 
				
			|||
 | 
				
			|||
/** | 
				
			|||
 * 评分卡变量实体持久化事件处理器 | 
				
			|||
 */ | 
				
			|||
@Service("io.sc.engine.rule.server.jpa.listener.handler.ScoreCardVarEntityEventHandler") | 
				
			|||
public class ScoreCardVarEntityEventHandler extends AbstractJpaEntityPersistentEventHandler<ScoreCardVarEntity>{ | 
				
			|||
	@Autowired private ResourceService resourceService; | 
				
			|||
	@Autowired private NamedParameterJdbcTemplate namedParameterJdbcTemplate; | 
				
			|||
 | 
				
			|||
	@Override | 
				
			|||
	protected void afterAdd(ScoreCardVarEntity newEntity) { | 
				
			|||
		updateResourceEntityLastModifyDate(newEntity); | 
				
			|||
	} | 
				
			|||
 | 
				
			|||
	@Override | 
				
			|||
	protected void beforeUpdate(ScoreCardVarEntity oldEntity, ScoreCardVarEntity newEntity) { | 
				
			|||
		updateTestCaseParameterCode(oldEntity,newEntity);//更新测试用例参数代码
 | 
				
			|||
	} | 
				
			|||
 | 
				
			|||
	@Override | 
				
			|||
	protected void beforeDelete(ScoreCardVarEntity oldEntity) { | 
				
			|||
		updateResourceEntityLastModifyDate(oldEntity); | 
				
			|||
	} | 
				
			|||
	 | 
				
			|||
	@Override | 
				
			|||
	protected void beforeDelete(Iterable<ScoreCardVarEntity> iterable) { | 
				
			|||
		updateResourceEntityLastModifyDate(iterable.iterator().next()); | 
				
			|||
	} | 
				
			|||
	 | 
				
			|||
	/** | 
				
			|||
	 * 更新评分卡变量所属资源的最后更新日期 | 
				
			|||
	 * @param entity 评分卡变量实体 | 
				
			|||
	 */ | 
				
			|||
	private void updateResourceEntityLastModifyDate(ScoreCardVarEntity entity) { | 
				
			|||
		if(entity!=null) { | 
				
			|||
			ResourceEntity resourceEntity =entity.getResource(); | 
				
			|||
			if(resourceEntity!=null) { | 
				
			|||
				resourceEntity =resourceService.findById(resourceEntity.getId()); | 
				
			|||
			} | 
				
			|||
			if(resourceEntity!=null) { | 
				
			|||
				resourceEntity.setLastModifyDate(new Date()); | 
				
			|||
				resourceService.getRepository().save(resourceEntity); | 
				
			|||
			} | 
				
			|||
		} | 
				
			|||
	} | 
				
			|||
 | 
				
			|||
	/** | 
				
			|||
	 * 更新测试用例参数代码 | 
				
			|||
	 * 当评分卡变量代码发生改变后,那么生成的测试用例参数也需要更新。 | 
				
			|||
	 * 目的: 保持一致性 | 
				
			|||
	 * @param oldEntity 原对象 | 
				
			|||
	 * @param newEntity 新对象 | 
				
			|||
	 */ | 
				
			|||
	private void updateTestCaseParameterCode(ScoreCardVarEntity oldEntity,ScoreCardVarEntity newEntity) { | 
				
			|||
		if(oldEntity!=null && newEntity!=null && !oldEntity.getCode().equals(newEntity.getCode())) { | 
				
			|||
			ResourceEntity resourceEntity =oldEntity.getResource(); | 
				
			|||
			if(resourceEntity!=null) { | 
				
			|||
				List<ResourceTestCaseEntity> testCaseEntities =resourceEntity.getTestCases(); | 
				
			|||
				if(testCaseEntities!=null && testCaseEntities.size()>0) { | 
				
			|||
					List<String> testCaseIds =new ArrayList<String>(testCaseEntities.size()); | 
				
			|||
					for(TestCaseEntity testCaseEntity : testCaseEntities) { | 
				
			|||
						testCaseIds.add(testCaseEntity.getId()); | 
				
			|||
					} | 
				
			|||
					 | 
				
			|||
					String sql ="update RE_TEST_CASE_PARAMETER set" | 
				
			|||
							+ " CODE_=:newCode" | 
				
			|||
							+ " where CODE_=:oldCode and TEST_CASE_ID_ in (:testCaseIds)"; | 
				
			|||
					 | 
				
			|||
					Map<String, Object> params = new HashMap<String, Object>(); | 
				
			|||
					params.put("newCode", newEntity.getCode()); | 
				
			|||
					params.put("oldCode", oldEntity.getCode()); | 
				
			|||
					params.put("testCaseIds", testCaseIds); | 
				
			|||
					 | 
				
			|||
					namedParameterJdbcTemplate.update(sql, params); | 
				
			|||
				} | 
				
			|||
			} | 
				
			|||
		} | 
				
			|||
	} | 
				
			|||
} | 
				
			|||
@ -0,0 +1,97 @@ | 
				
			|||
package io.sc.engine.rule.server.model.entity.processor; | 
				
			|||
 | 
				
			|||
import com.fasterxml.jackson.annotation.JsonTypeName; | 
				
			|||
import com.fasterxml.jackson.core.type.TypeReference; | 
				
			|||
import io.sc.engine.rule.core.code.impl.support.processor.ConditionRange; | 
				
			|||
import io.sc.engine.rule.core.code.impl.support.processor.NumberRange; | 
				
			|||
import io.sc.engine.rule.core.code.impl.support.processor.ScoreCardItem; | 
				
			|||
import io.sc.engine.rule.core.enums.ProcessorType; | 
				
			|||
import io.sc.engine.rule.core.util.ExpressionReplacer; | 
				
			|||
import io.sc.engine.rule.core.util.JacksonObjectMapper; | 
				
			|||
import io.sc.engine.rule.server.model.entity.ParameterProcessorEntity; | 
				
			|||
import io.sc.engine.rule.server.model.vo.processor.ScoreCardParameterProcessorVo; | 
				
			|||
import io.sc.platform.core.util.ObjectMapper4Json; | 
				
			|||
import org.springframework.util.StringUtils; | 
				
			|||
 | 
				
			|||
import javax.persistence.Column; | 
				
			|||
import javax.persistence.DiscriminatorValue; | 
				
			|||
import javax.persistence.Entity; | 
				
			|||
import java.util.ArrayList; | 
				
			|||
import java.util.List; | 
				
			|||
import java.util.Map; | 
				
			|||
 | 
				
			|||
/** | 
				
			|||
 * 模型参数处理器(算数运算操作)实体类 | 
				
			|||
 */ | 
				
			|||
@Entity | 
				
			|||
@DiscriminatorValue("SCORE_CARD") | 
				
			|||
@JsonTypeName("SCORE_CARD") | 
				
			|||
public class ScoreCardParameterProcessorEntity extends ParameterProcessorEntity { | 
				
			|||
	//算数表达式
 | 
				
			|||
	@Column(name="SCORE_CARD_") | 
				
			|||
	private String scoreCard; | 
				
			|||
 | 
				
			|||
	@Override | 
				
			|||
	public ScoreCardParameterProcessorVo toVo() { | 
				
			|||
		ScoreCardParameterProcessorVo vo =new ScoreCardParameterProcessorVo(); | 
				
			|||
		super.toVo(vo); | 
				
			|||
		vo.setScoreCard(this.getScoreCard()); | 
				
			|||
		return vo; | 
				
			|||
	} | 
				
			|||
 | 
				
			|||
	@Override | 
				
			|||
	public ProcessorType getType() { | 
				
			|||
		return ProcessorType.SCORE_CARD; | 
				
			|||
	} | 
				
			|||
 | 
				
			|||
	public String getScoreCard() { | 
				
			|||
		return scoreCard; | 
				
			|||
	} | 
				
			|||
 | 
				
			|||
	public void setScoreCard(String scoreCard) { | 
				
			|||
		this.scoreCard = scoreCard; | 
				
			|||
	} | 
				
			|||
 | 
				
			|||
	@Override | 
				
			|||
	public boolean replace(Map<String, String> mapping) { | 
				
			|||
		List<ScoreCardItem> scoreCardItems =new ArrayList<>(); | 
				
			|||
		try { | 
				
			|||
			if(StringUtils.hasText(this.scoreCard)) { | 
				
			|||
				scoreCardItems = ObjectMapper4Json.getMapper().readValue(this.scoreCard, new TypeReference<List<ScoreCardItem>>() {}); | 
				
			|||
			} | 
				
			|||
		}catch (Exception e){ | 
				
			|||
 | 
				
			|||
		} | 
				
			|||
		if(scoreCardItems!=null && !scoreCardItems.isEmpty()){ | 
				
			|||
			for(ScoreCardItem scoreCardItem : scoreCardItems){ | 
				
			|||
				scoreCardItem.setName(ExpressionReplacer.replace(scoreCardItem.getCode(), mapping)); | 
				
			|||
				List<ConditionRange> conditionRanges =scoreCardItem.getConditionRange(); | 
				
			|||
				if(conditionRanges!=null && !conditionRanges.isEmpty()){ | 
				
			|||
					for(ConditionRange conditionRange : conditionRanges){ | 
				
			|||
						conditionRange.setCondition(ExpressionReplacer.replace(conditionRange.getCondition(), mapping)); | 
				
			|||
						conditionRange.setValue(ExpressionReplacer.replace(conditionRange.getValue(), mapping)); | 
				
			|||
					} | 
				
			|||
				} | 
				
			|||
				List<NumberRange> numberRanges =scoreCardItem.getNumberRange(); | 
				
			|||
				if(numberRanges!=null && !numberRanges.isEmpty()){ | 
				
			|||
					for(NumberRange numberRange : numberRanges){ | 
				
			|||
						numberRange.setValue(ExpressionReplacer.replace(numberRange.getValue(), mapping)); | 
				
			|||
					} | 
				
			|||
				} | 
				
			|||
			} | 
				
			|||
		} | 
				
			|||
		String replaced =""; | 
				
			|||
		try { | 
				
			|||
			replaced = ObjectMapper4Json.getMapper().writeValueAsString(scoreCardItems); | 
				
			|||
		}catch (Exception e){ | 
				
			|||
 | 
				
			|||
		} | 
				
			|||
		replaced =(replaced==null?"":replaced); | 
				
			|||
		boolean result =false; | 
				
			|||
		if(!replaced.equals(this.scoreCard)) { | 
				
			|||
			result =true; | 
				
			|||
		} | 
				
			|||
		this.scoreCard =replaced; | 
				
			|||
		return result; | 
				
			|||
	} | 
				
			|||
} | 
				
			|||
@ -0,0 +1,26 @@ | 
				
			|||
package io.sc.engine.rule.server.model.vo.processor; | 
				
			|||
 | 
				
			|||
import io.sc.engine.rule.core.enums.ProcessorType; | 
				
			|||
import io.sc.engine.rule.server.model.vo.ParameterProcessorVo; | 
				
			|||
 | 
				
			|||
/** | 
				
			|||
 * 模型参数处理器(评分卡操作)Vo 类 | 
				
			|||
 */ | 
				
			|||
public class ScoreCardParameterProcessorVo extends ParameterProcessorVo { | 
				
			|||
 | 
				
			|||
	//评分卡配置
 | 
				
			|||
	private String scoreCard; | 
				
			|||
	 | 
				
			|||
	@Override | 
				
			|||
	public ProcessorType getType() { | 
				
			|||
		return ProcessorType.SCORE_CARD; | 
				
			|||
	} | 
				
			|||
 | 
				
			|||
	public String getScoreCard() { | 
				
			|||
		return scoreCard; | 
				
			|||
	} | 
				
			|||
 | 
				
			|||
	public void setScoreCard(String scoreCard) { | 
				
			|||
		this.scoreCard = scoreCard; | 
				
			|||
	} | 
				
			|||
} | 
				
			|||
@ -1,120 +0,0 @@ | 
				
			|||
package io.sc.engine.rule.server.resource.entity; | 
				
			|||
 | 
				
			|||
import com.fasterxml.jackson.annotation.JsonTypeName; | 
				
			|||
import io.sc.engine.rule.core.enums.ResourceType; | 
				
			|||
import io.sc.engine.rule.server.resource.vo.ScoreCardResourceVo; | 
				
			|||
import io.sc.engine.rule.server.scorecard.entity.ScoreCardVarEntity; | 
				
			|||
import io.sc.engine.rule.server.testcase.entity.ResourceTestCaseEntity; | 
				
			|||
import org.springframework.beans.BeanUtils; | 
				
			|||
 | 
				
			|||
import javax.persistence.*; | 
				
			|||
import java.util.ArrayList; | 
				
			|||
import java.util.List; | 
				
			|||
 | 
				
			|||
/** | 
				
			|||
 * 评分卡资源实体类 | 
				
			|||
 */ | 
				
			|||
@Entity | 
				
			|||
@DiscriminatorValue("SCORE_CARD") | 
				
			|||
@JsonTypeName("SCORE_CARD") | 
				
			|||
public class ScoreCardResourceEntity extends ReleasableResourceEntity { | 
				
			|||
	//模型包含的评分卡变量
 | 
				
			|||
	@OneToMany(mappedBy="resource",cascade= {CascadeType.PERSIST}) | 
				
			|||
	@OrderBy("order") | 
				
			|||
	protected List<ScoreCardVarEntity> scoreCardVars =new ArrayList<ScoreCardVarEntity>(); | 
				
			|||
 | 
				
			|||
	@Override | 
				
			|||
	public ScoreCardResourceVo toVo() { | 
				
			|||
		ScoreCardResourceVo vo =new ScoreCardResourceVo(); | 
				
			|||
		super.toVo(vo); | 
				
			|||
		vo.setType(this.getType()); | 
				
			|||
		return vo; | 
				
			|||
	} | 
				
			|||
 | 
				
			|||
	public ScoreCardResourceEntity() {} | 
				
			|||
	public ScoreCardResourceEntity(String id) { | 
				
			|||
		this.id =id; | 
				
			|||
	} | 
				
			|||
	 | 
				
			|||
	@Override | 
				
			|||
	public ResourceType getType() { | 
				
			|||
		return ResourceType.SCORE_CARD; | 
				
			|||
	} | 
				
			|||
	 | 
				
			|||
	public List<ScoreCardVarEntity> getScoreCardVars() { | 
				
			|||
		return scoreCardVars; | 
				
			|||
	} | 
				
			|||
	 | 
				
			|||
	public void setScoreCardVars(List<ScoreCardVarEntity> scoreCardVars) { | 
				
			|||
		this.scoreCardVars = scoreCardVars; | 
				
			|||
	} | 
				
			|||
	 | 
				
			|||
	@Override | 
				
			|||
	public Object deepClone() throws Exception { | 
				
			|||
		ScoreCardResourceEntity entity =new ScoreCardResourceEntity(); | 
				
			|||
		BeanUtils.copyProperties(this, entity, "children","testCases","scoreCardVars","roles"); | 
				
			|||
		//children
 | 
				
			|||
		List<ResourceEntity> children =this.getChildren(); | 
				
			|||
		if(children!=null && children.size()>0) { | 
				
			|||
			for(ResourceEntity child : children) { | 
				
			|||
				ResourceEntity clone =(ResourceEntity)child.deepClone(); | 
				
			|||
				clone.setParent(entity); | 
				
			|||
				entity.getChildren().add(clone); | 
				
			|||
			} | 
				
			|||
		} | 
				
			|||
		//testCases
 | 
				
			|||
		List<ResourceTestCaseEntity> testCases =this.getTestCases(); | 
				
			|||
		if(testCases!=null && testCases.size()>0) { | 
				
			|||
			for(ResourceTestCaseEntity testCase : testCases) { | 
				
			|||
				ResourceTestCaseEntity clone =(ResourceTestCaseEntity)testCase.deepClone(); | 
				
			|||
				clone.setOwner(entity); | 
				
			|||
				entity.getTestCases().add(clone); | 
				
			|||
			} | 
				
			|||
		} | 
				
			|||
		//scoreCardVars
 | 
				
			|||
		List<ScoreCardVarEntity> vars =this.getScoreCardVars(); | 
				
			|||
		if(vars!=null && vars.size()>0) { | 
				
			|||
			for(ScoreCardVarEntity var : vars) { | 
				
			|||
				ScoreCardVarEntity clone =(ScoreCardVarEntity)var.deepClone(); | 
				
			|||
				clone.setResource(entity); | 
				
			|||
				entity.getScoreCardVars().add(clone); | 
				
			|||
			} | 
				
			|||
		} | 
				
			|||
		return entity; | 
				
			|||
	} | 
				
			|||
	 | 
				
			|||
	@Override | 
				
			|||
	public void clearId() { | 
				
			|||
		super.clearId(); | 
				
			|||
		 | 
				
			|||
		//scoreCardVars
 | 
				
			|||
		List<ScoreCardVarEntity> scoreCardVars =this.getScoreCardVars(); | 
				
			|||
		if(scoreCardVars!=null && scoreCardVars.size()>0) { | 
				
			|||
			for(ScoreCardVarEntity scoreCardVar : scoreCardVars) { | 
				
			|||
				scoreCardVar.clearId(); | 
				
			|||
			} | 
				
			|||
		} | 
				
			|||
	} | 
				
			|||
	 | 
				
			|||
	@Override | 
				
			|||
	public String toString() { | 
				
			|||
		return "ScoreCardResourceEntity [" | 
				
			|||
				+ "  type=" + type | 
				
			|||
				+ "  id=" + id  | 
				
			|||
				+ ", code=" + code | 
				
			|||
				+ ", name=" + name | 
				
			|||
				+ ", description=" + description | 
				
			|||
				+ ", order=" + order | 
				
			|||
				 | 
				
			|||
				+ ", status=" + status | 
				
			|||
				+ ", version=" + version | 
				
			|||
				+ ", effectiveDate=" + effectiveDate | 
				
			|||
				+ ", imports=" + imports | 
				
			|||
				 | 
				
			|||
				+ ", creator=" + creator  | 
				
			|||
				+ ", createDate=" + createDate | 
				
			|||
				+ ", lastModifier=" + lastModifier  | 
				
			|||
				+ ", lastModifyDate=" + lastModifyDate | 
				
			|||
				+ "]"; | 
				
			|||
	} | 
				
			|||
} | 
				
			|||
@ -1,16 +0,0 @@ | 
				
			|||
package io.sc.engine.rule.server.scorecard.controller; | 
				
			|||
 | 
				
			|||
import io.sc.engine.rule.server.scorecard.entity.ScoreCardVarEntity; | 
				
			|||
import io.sc.engine.rule.server.scorecard.repository.ScoreCardVarRepository; | 
				
			|||
import io.sc.engine.rule.server.scorecard.service.ScoreCardVarService; | 
				
			|||
import io.sc.engine.rule.server.scorecard.vo.ScoreCardVarVo; | 
				
			|||
import io.sc.platform.mvc.controller.support.RestCrudController; | 
				
			|||
import org.springframework.stereotype.Controller; | 
				
			|||
import org.springframework.web.bind.annotation.RequestMapping; | 
				
			|||
import org.springframework.web.bind.annotation.RestController; | 
				
			|||
 | 
				
			|||
@RestController("io.sc.engine.rule.server.scorecard.controller.ScoreCardVarWebController") | 
				
			|||
@RequestMapping("/api/re/scoreCardVar") | 
				
			|||
public class ScoreCardVarWebController extends RestCrudController<ScoreCardVarVo,ScoreCardVarEntity,String,ScoreCardVarRepository,ScoreCardVarService> { | 
				
			|||
	 | 
				
			|||
} | 
				
			|||
@ -1,171 +0,0 @@ | 
				
			|||
package io.sc.engine.rule.server.scorecard.converter; | 
				
			|||
 | 
				
			|||
import java.util.ArrayList; | 
				
			|||
import java.util.List; | 
				
			|||
 | 
				
			|||
import io.sc.engine.rule.core.po.scorecard.NumberRangeScoreCardIndicatorVar; | 
				
			|||
import io.sc.engine.rule.core.po.scorecard.NumberRangeScoreCardVar; | 
				
			|||
import io.sc.engine.rule.core.po.scorecard.OptionScoreCardIndicatorVar; | 
				
			|||
import io.sc.engine.rule.core.po.scorecard.OptionScoreCardVar; | 
				
			|||
import io.sc.engine.rule.core.po.scorecard.ScoreCardIndicatorValueVar; | 
				
			|||
import io.sc.engine.rule.core.po.scorecard.ScoreCardIndicatorVar; | 
				
			|||
import io.sc.engine.rule.core.po.scorecard.ScoreCardVar; | 
				
			|||
import io.sc.engine.rule.server.scorecard.entity.NumberRangeScoreCardIndicatorVarEntity; | 
				
			|||
import io.sc.engine.rule.server.scorecard.entity.NumberRangeScoreCardVarEntity; | 
				
			|||
import io.sc.engine.rule.server.scorecard.entity.OptionScoreCardIndicatorVarEntity; | 
				
			|||
import io.sc.engine.rule.server.scorecard.entity.OptionScoreCardVarEntity; | 
				
			|||
import io.sc.engine.rule.server.scorecard.entity.ScoreCardIndicatorValueVarEntity; | 
				
			|||
import io.sc.engine.rule.server.scorecard.entity.ScoreCardIndicatorVarEntity; | 
				
			|||
import io.sc.engine.rule.server.scorecard.entity.ScoreCardVarEntity; | 
				
			|||
 | 
				
			|||
/** | 
				
			|||
 * 评分卡变量实体转换器 | 
				
			|||
 * @author wangshaoping | 
				
			|||
 * | 
				
			|||
 */ | 
				
			|||
public class ScoreCardVarEntityConverter { | 
				
			|||
	/** | 
				
			|||
	 * 将实体转换成 PO 对象 | 
				
			|||
	 * @param entity 实体对象 | 
				
			|||
	 * @return PO 对象 | 
				
			|||
	 */ | 
				
			|||
	public static ScoreCardVar toPo(ScoreCardVarEntity entity) { | 
				
			|||
		if(entity!=null) { | 
				
			|||
			ScoreCardVar po =null; | 
				
			|||
			if(entity instanceof NumberRangeScoreCardVarEntity) { | 
				
			|||
				NumberRangeScoreCardVarEntity _entity =(NumberRangeScoreCardVarEntity)entity; | 
				
			|||
				NumberRangeScoreCardVar _po =new NumberRangeScoreCardVar(); | 
				
			|||
				_po.setNumberRange(_entity.getNumberRange()); | 
				
			|||
				po =_po; | 
				
			|||
			}else if(entity instanceof NumberRangeScoreCardIndicatorVarEntity) { | 
				
			|||
				NumberRangeScoreCardIndicatorVarEntity _entity =(NumberRangeScoreCardIndicatorVarEntity)entity; | 
				
			|||
				NumberRangeScoreCardIndicatorVar _po =new NumberRangeScoreCardIndicatorVar(); | 
				
			|||
				_po.setNumberRange(_entity.getNumberRange()); | 
				
			|||
				po =_po; | 
				
			|||
			}else if(entity instanceof OptionScoreCardVarEntity) { | 
				
			|||
				OptionScoreCardVarEntity _entity =(OptionScoreCardVarEntity)entity; | 
				
			|||
				OptionScoreCardVar _po =new OptionScoreCardVar(); | 
				
			|||
				_po.setOption(_entity.getOption()); | 
				
			|||
				po =_po; | 
				
			|||
			}else if(entity instanceof OptionScoreCardIndicatorVarEntity) { | 
				
			|||
				OptionScoreCardIndicatorVarEntity _entity =(OptionScoreCardIndicatorVarEntity)entity; | 
				
			|||
				OptionScoreCardIndicatorVar _po =new OptionScoreCardIndicatorVar(); | 
				
			|||
				_po.setOption(_entity.getOption()); | 
				
			|||
				po =_po; | 
				
			|||
			}else if(entity instanceof ScoreCardIndicatorValueVarEntity) { | 
				
			|||
				po =new ScoreCardIndicatorValueVar(); | 
				
			|||
			}else { | 
				
			|||
				OptionScoreCardVarEntity _entity =(OptionScoreCardVarEntity)entity; | 
				
			|||
				OptionScoreCardVar _po =new OptionScoreCardVar(); | 
				
			|||
				_po.setOption(_entity.getOption()); | 
				
			|||
				po =_po; | 
				
			|||
			} | 
				
			|||
			 | 
				
			|||
			if(entity instanceof ScoreCardIndicatorVarEntity) { | 
				
			|||
				ScoreCardIndicatorVarEntity _entity =(ScoreCardIndicatorVarEntity)entity; | 
				
			|||
				((ScoreCardIndicatorVar)po).setLibCode(_entity.getLibCode()); | 
				
			|||
				((ScoreCardIndicatorVar)po).setLibVersion(_entity.getLibVersion()); | 
				
			|||
				((ScoreCardIndicatorVar)po).setIndicatorCode(_entity.getIndicatorCode()); | 
				
			|||
			} | 
				
			|||
			 | 
				
			|||
			po.setId(entity.getId()); | 
				
			|||
			po.setCode(entity.getCode()); | 
				
			|||
			po.setName(entity.getName()); | 
				
			|||
			po.setOrder(entity.getOrder()); | 
				
			|||
			return po; | 
				
			|||
		} | 
				
			|||
		return null; | 
				
			|||
	} | 
				
			|||
	 | 
				
			|||
	/** | 
				
			|||
	 * 将实体集合转换成 PO 对象集合 | 
				
			|||
	 * @param entities 实体集合 | 
				
			|||
	 * @return PO 对象集合 | 
				
			|||
	 */ | 
				
			|||
	public static List<ScoreCardVar> toPo(List<ScoreCardVarEntity> entities){ | 
				
			|||
		if(entities!=null && entities.size()>0) { | 
				
			|||
			List<ScoreCardVar> pos =new ArrayList<ScoreCardVar>(entities.size()); | 
				
			|||
			for(ScoreCardVarEntity entity : entities) { | 
				
			|||
				pos.add(toPo(entity)); | 
				
			|||
			} | 
				
			|||
			return pos; | 
				
			|||
		} | 
				
			|||
		return null; | 
				
			|||
	} | 
				
			|||
	 | 
				
			|||
	/** | 
				
			|||
	 * 将 PO 对象转换成实体对象 | 
				
			|||
	 * @param po PO 对象 | 
				
			|||
	 * @return 实体对象 | 
				
			|||
	 */ | 
				
			|||
	public static ScoreCardVarEntity fromPo(ScoreCardVar po) { | 
				
			|||
		if(po!=null) { | 
				
			|||
			ScoreCardVarEntity entity =null; | 
				
			|||
			if(po instanceof NumberRangeScoreCardVar) { | 
				
			|||
				NumberRangeScoreCardVar _po =(NumberRangeScoreCardVar)po; | 
				
			|||
				NumberRangeScoreCardVarEntity _entity =new NumberRangeScoreCardVarEntity(); | 
				
			|||
				_entity.setNumberRange(_po.getNumberRange()); | 
				
			|||
				entity =_entity; | 
				
			|||
			}else if(po instanceof NumberRangeScoreCardIndicatorVar) { | 
				
			|||
				NumberRangeScoreCardIndicatorVar _po =(NumberRangeScoreCardIndicatorVar)po; | 
				
			|||
				NumberRangeScoreCardIndicatorVarEntity _entity =new NumberRangeScoreCardIndicatorVarEntity(); | 
				
			|||
				_entity.setNumberRange(_po.getNumberRange()); | 
				
			|||
				entity =_entity; | 
				
			|||
			}else if(po instanceof OptionScoreCardVar) { | 
				
			|||
				OptionScoreCardVar _po =(OptionScoreCardVar)po; | 
				
			|||
				OptionScoreCardVarEntity _entity =new OptionScoreCardVarEntity(); | 
				
			|||
				_entity.setOption(_po.getOption()); | 
				
			|||
				entity =_entity; | 
				
			|||
			}else if(po instanceof OptionScoreCardIndicatorVar) { | 
				
			|||
				OptionScoreCardIndicatorVar _po =(OptionScoreCardIndicatorVar)po; | 
				
			|||
				OptionScoreCardIndicatorVarEntity _entity =new OptionScoreCardIndicatorVarEntity(); | 
				
			|||
				_entity.setOption(_po.getOption()); | 
				
			|||
				entity =_entity; | 
				
			|||
			}else if(po instanceof ScoreCardIndicatorValueVar) { | 
				
			|||
				ScoreCardIndicatorValueVar _po =(ScoreCardIndicatorValueVar)po; | 
				
			|||
				ScoreCardIndicatorValueVarEntity _entity =new ScoreCardIndicatorValueVarEntity(); | 
				
			|||
				_entity.setLibCode(_po.getLibCode()); | 
				
			|||
				_entity.setLibVersion(_po.getLibVersion()); | 
				
			|||
				_entity.setIndicatorCode(_po.getIndicatorCode()); | 
				
			|||
				entity =_entity; | 
				
			|||
			}else { | 
				
			|||
				OptionScoreCardVar _po =(OptionScoreCardVar)po; | 
				
			|||
				OptionScoreCardVarEntity _entity =new OptionScoreCardVarEntity(); | 
				
			|||
				_entity.setOption(_po.getOption()); | 
				
			|||
				entity =_entity; | 
				
			|||
			} | 
				
			|||
			 | 
				
			|||
			if(entity!=null) { | 
				
			|||
				if(po instanceof ScoreCardIndicatorVar) { | 
				
			|||
					ScoreCardIndicatorVar _po =(ScoreCardIndicatorVar)po; | 
				
			|||
					((ScoreCardIndicatorVarEntity)entity).setLibCode(_po.getLibCode()); | 
				
			|||
					((ScoreCardIndicatorVarEntity)entity).setLibVersion(_po.getLibVersion()); | 
				
			|||
					((ScoreCardIndicatorVarEntity)entity).setIndicatorCode(_po.getIndicatorCode()); | 
				
			|||
				} | 
				
			|||
				 | 
				
			|||
				entity.setId(po.getId()); | 
				
			|||
				entity.setCode(po.getCode()); | 
				
			|||
				entity.setName(po.getName()); | 
				
			|||
				entity.setOrder(po.getOrder()); | 
				
			|||
				return entity; | 
				
			|||
			} | 
				
			|||
		} | 
				
			|||
		return null; | 
				
			|||
	} | 
				
			|||
	 | 
				
			|||
	/** | 
				
			|||
	 * 将 PO 对象集合转换成实体对象集合 | 
				
			|||
	 * @param pos PO 对象集合 | 
				
			|||
	 * @return 实体对象集合 | 
				
			|||
	 */ | 
				
			|||
	public static List<ScoreCardVarEntity> fromPo(List<ScoreCardVar> pos){ | 
				
			|||
		if(pos!=null && pos.size()>0) { | 
				
			|||
			List<ScoreCardVarEntity> entities =new ArrayList<ScoreCardVarEntity>(pos.size()); | 
				
			|||
			for(ScoreCardVar po : pos) { | 
				
			|||
				entities.add(fromPo(po)); | 
				
			|||
			} | 
				
			|||
			return entities; | 
				
			|||
		} | 
				
			|||
		return null; | 
				
			|||
	} | 
				
			|||
} | 
				
			|||
@ -1,66 +0,0 @@ | 
				
			|||
package io.sc.engine.rule.server.scorecard.entity; | 
				
			|||
 | 
				
			|||
import com.fasterxml.jackson.annotation.JsonTypeName; | 
				
			|||
import io.sc.engine.rule.core.enums.ScoreCardVarType; | 
				
			|||
import io.sc.engine.rule.server.scorecard.vo.NumberRangeScoreCardIndicatorVarVo; | 
				
			|||
import io.sc.engine.rule.server.testcase.wrapper.TestCaseParameterWrapper; | 
				
			|||
 | 
				
			|||
import javax.persistence.Column; | 
				
			|||
import javax.persistence.DiscriminatorValue; | 
				
			|||
import javax.persistence.Entity; | 
				
			|||
 | 
				
			|||
/** | 
				
			|||
 * 评分卡变量(指标选项)实体类 | 
				
			|||
 */ | 
				
			|||
@Entity | 
				
			|||
@DiscriminatorValue("INDICATOR_NUMBER_RANGE") | 
				
			|||
@JsonTypeName("INDICATOR_NUMBER_RANGE") | 
				
			|||
public class NumberRangeScoreCardIndicatorVarEntity extends ScoreCardIndicatorVarEntity { | 
				
			|||
	//数值分段
 | 
				
			|||
	@Column(name="NUMBER_RANGE_") | 
				
			|||
	private String numberRange; | 
				
			|||
 | 
				
			|||
	@Override | 
				
			|||
	public NumberRangeScoreCardIndicatorVarVo toVo() { | 
				
			|||
		NumberRangeScoreCardIndicatorVarVo vo =new NumberRangeScoreCardIndicatorVarVo(); | 
				
			|||
		super.toVo(vo); | 
				
			|||
		vo.setType(this.getType()); | 
				
			|||
		vo.setNumberRange(this.getNumberRange()); | 
				
			|||
		return vo; | 
				
			|||
	} | 
				
			|||
 | 
				
			|||
	public NumberRangeScoreCardIndicatorVarEntity() {} | 
				
			|||
	public NumberRangeScoreCardIndicatorVarEntity(String id) { | 
				
			|||
		this.id =id; | 
				
			|||
	} | 
				
			|||
	 | 
				
			|||
	@Override | 
				
			|||
	public ScoreCardVarType getType() { | 
				
			|||
		return ScoreCardVarType.INDICATOR_NUMBER_RANGE; | 
				
			|||
	} | 
				
			|||
	 | 
				
			|||
	public String getNumberRange() { | 
				
			|||
		return numberRange; | 
				
			|||
	} | 
				
			|||
	public void setNumberRange(String numberRange) { | 
				
			|||
		this.numberRange = numberRange; | 
				
			|||
	} | 
				
			|||
	 | 
				
			|||
	@Override | 
				
			|||
	public TestCaseParameterWrapper toTestCaseParameterWrapper() { | 
				
			|||
		TestCaseParameterWrapper wrapper =new TestCaseParameterWrapper(this.getId(),this.getCode(),null,null,null,null,false); | 
				
			|||
		 | 
				
			|||
		wrapper.setTestCaseId(null); | 
				
			|||
		wrapper.setParent(null); | 
				
			|||
		wrapper.setCategory("P"); | 
				
			|||
		wrapper.setName(this.getName()); | 
				
			|||
		wrapper.setParameterType(null); | 
				
			|||
		wrapper.setScoreCardVarType(this.getType()); | 
				
			|||
		wrapper.setIndicatorType(null); | 
				
			|||
		wrapper.setValueType("java.math.BigDecimal"); | 
				
			|||
		wrapper.setDefaultValue(null); | 
				
			|||
		wrapper.setOrder(this.getOrder()); | 
				
			|||
		 | 
				
			|||
		return wrapper; | 
				
			|||
	} | 
				
			|||
} | 
				
			|||
@ -1,66 +0,0 @@ | 
				
			|||
package io.sc.engine.rule.server.scorecard.entity; | 
				
			|||
 | 
				
			|||
import com.fasterxml.jackson.annotation.JsonTypeName; | 
				
			|||
import io.sc.engine.rule.core.enums.ScoreCardVarType; | 
				
			|||
import io.sc.engine.rule.server.scorecard.vo.NumberRangeScoreCardVarVo; | 
				
			|||
import io.sc.engine.rule.server.testcase.wrapper.TestCaseParameterWrapper; | 
				
			|||
 | 
				
			|||
import javax.persistence.Column; | 
				
			|||
import javax.persistence.DiscriminatorValue; | 
				
			|||
import javax.persistence.Entity; | 
				
			|||
 | 
				
			|||
/** | 
				
			|||
 * 评分卡变量(数值分段)实体类 | 
				
			|||
 */ | 
				
			|||
@Entity | 
				
			|||
@DiscriminatorValue("NUMBER_RANGE") | 
				
			|||
@JsonTypeName("NUMBER_RANGE") | 
				
			|||
public class NumberRangeScoreCardVarEntity extends ScoreCardVarEntity { | 
				
			|||
	//数值分段
 | 
				
			|||
	@Column(name="NUMBER_RANGE_") | 
				
			|||
	private String numberRange; | 
				
			|||
 | 
				
			|||
	@Override | 
				
			|||
	public NumberRangeScoreCardVarVo toVo() { | 
				
			|||
		NumberRangeScoreCardVarVo vo =new NumberRangeScoreCardVarVo(); | 
				
			|||
		super.toVo(vo); | 
				
			|||
		vo.setType(this.getType()); | 
				
			|||
		vo.setNumberRange(this.getNumberRange()); | 
				
			|||
		return vo; | 
				
			|||
	} | 
				
			|||
	 | 
				
			|||
	public NumberRangeScoreCardVarEntity() {} | 
				
			|||
	public NumberRangeScoreCardVarEntity(String id) { | 
				
			|||
		this.id =id; | 
				
			|||
	} | 
				
			|||
	 | 
				
			|||
	@Override | 
				
			|||
	public ScoreCardVarType getType() { | 
				
			|||
		return ScoreCardVarType.NUMBER_RANGE; | 
				
			|||
	} | 
				
			|||
	 | 
				
			|||
	public String getNumberRange() { | 
				
			|||
		return numberRange; | 
				
			|||
	} | 
				
			|||
	public void setNumberRange(String numberRange) { | 
				
			|||
		this.numberRange = numberRange; | 
				
			|||
	} | 
				
			|||
	 | 
				
			|||
	@Override | 
				
			|||
	public TestCaseParameterWrapper toTestCaseParameterWrapper() { | 
				
			|||
		TestCaseParameterWrapper wrapper =new TestCaseParameterWrapper(this.getId(),this.getCode(),null,null,null,null,false); | 
				
			|||
		 | 
				
			|||
		wrapper.setTestCaseId(null); | 
				
			|||
		wrapper.setParent(null); | 
				
			|||
		wrapper.setCategory("P"); | 
				
			|||
		wrapper.setName(this.getName()); | 
				
			|||
		wrapper.setParameterType(null); | 
				
			|||
		wrapper.setScoreCardVarType(this.getType()); | 
				
			|||
		wrapper.setIndicatorType(null); | 
				
			|||
		wrapper.setValueType("java.math.BigDecimal"); | 
				
			|||
		wrapper.setDefaultValue(null); | 
				
			|||
		wrapper.setOrder(this.getOrder()); | 
				
			|||
		 | 
				
			|||
		return wrapper; | 
				
			|||
	} | 
				
			|||
} | 
				
			|||
@ -1,66 +0,0 @@ | 
				
			|||
package io.sc.engine.rule.server.scorecard.entity; | 
				
			|||
 | 
				
			|||
import com.fasterxml.jackson.annotation.JsonTypeName; | 
				
			|||
import io.sc.engine.rule.core.enums.ScoreCardVarType; | 
				
			|||
import io.sc.engine.rule.server.scorecard.vo.OptionScoreCardIndicatorVarVo; | 
				
			|||
import io.sc.engine.rule.server.testcase.wrapper.TestCaseParameterWrapper; | 
				
			|||
 | 
				
			|||
import javax.persistence.Column; | 
				
			|||
import javax.persistence.DiscriminatorValue; | 
				
			|||
import javax.persistence.Entity; | 
				
			|||
 | 
				
			|||
/** | 
				
			|||
 * 评分卡变量(指标选项)实体类 | 
				
			|||
 */ | 
				
			|||
@Entity | 
				
			|||
@DiscriminatorValue("INDICATOR_OPTION") | 
				
			|||
@JsonTypeName("INDICATOR_OPTION") | 
				
			|||
public class OptionScoreCardIndicatorVarEntity extends ScoreCardIndicatorVarEntity { | 
				
			|||
	//选项
 | 
				
			|||
	@Column(name="OPTION_") | 
				
			|||
	private String option; | 
				
			|||
 | 
				
			|||
	@Override | 
				
			|||
	public OptionScoreCardIndicatorVarVo toVo() { | 
				
			|||
		OptionScoreCardIndicatorVarVo vo =new OptionScoreCardIndicatorVarVo(); | 
				
			|||
		super.toVo(vo); | 
				
			|||
		vo.setType(this.getType()); | 
				
			|||
		vo.setOption(this.getOption()); | 
				
			|||
		return vo; | 
				
			|||
	} | 
				
			|||
	 | 
				
			|||
	public OptionScoreCardIndicatorVarEntity() {} | 
				
			|||
	public OptionScoreCardIndicatorVarEntity(String id) { | 
				
			|||
		this.id =id; | 
				
			|||
	} | 
				
			|||
	 | 
				
			|||
	@Override | 
				
			|||
	public ScoreCardVarType getType() { | 
				
			|||
		return ScoreCardVarType.INDICATOR_OPTION; | 
				
			|||
	} | 
				
			|||
	 | 
				
			|||
	public String getOption() { | 
				
			|||
		return option; | 
				
			|||
	} | 
				
			|||
	public void setOption(String option) { | 
				
			|||
		this.option = option; | 
				
			|||
	} | 
				
			|||
	 | 
				
			|||
	@Override | 
				
			|||
	public TestCaseParameterWrapper toTestCaseParameterWrapper() { | 
				
			|||
		TestCaseParameterWrapper wrapper =new TestCaseParameterWrapper(this.getId(),this.getCode(),null,null,null,null,false); | 
				
			|||
		 | 
				
			|||
		wrapper.setTestCaseId(null); | 
				
			|||
		wrapper.setParent(null); | 
				
			|||
		wrapper.setCategory("P"); | 
				
			|||
		wrapper.setName(this.getName()); | 
				
			|||
		wrapper.setParameterType(null); | 
				
			|||
		wrapper.setScoreCardVarType(this.getType()); | 
				
			|||
		wrapper.setIndicatorType(null); | 
				
			|||
		wrapper.setValueType("java.lang.String"); | 
				
			|||
		wrapper.setDefaultValue(null); | 
				
			|||
		wrapper.setOrder(this.getOrder()); | 
				
			|||
		 | 
				
			|||
		return wrapper; | 
				
			|||
	} | 
				
			|||
} | 
				
			|||
@ -1,69 +0,0 @@ | 
				
			|||
package io.sc.engine.rule.server.scorecard.entity; | 
				
			|||
 | 
				
			|||
import com.fasterxml.jackson.annotation.JsonTypeName; | 
				
			|||
import io.sc.engine.rule.core.enums.ScoreCardVarType; | 
				
			|||
import io.sc.engine.rule.server.scorecard.vo.OptionScoreCardVarVo; | 
				
			|||
import io.sc.engine.rule.server.testcase.wrapper.TestCaseParameterWrapper; | 
				
			|||
 | 
				
			|||
import javax.persistence.Column; | 
				
			|||
import javax.persistence.DiscriminatorValue; | 
				
			|||
import javax.persistence.Entity; | 
				
			|||
 | 
				
			|||
/** | 
				
			|||
 * 评分卡变量(选项)实体类 | 
				
			|||
 * @author wangshaoping | 
				
			|||
 * | 
				
			|||
 */ | 
				
			|||
@Entity | 
				
			|||
@DiscriminatorValue("OPTION") | 
				
			|||
@JsonTypeName("OPTION") | 
				
			|||
public class OptionScoreCardVarEntity extends ScoreCardVarEntity { | 
				
			|||
	//选项
 | 
				
			|||
	@Column(name="OPTION_") | 
				
			|||
	private String option; | 
				
			|||
 | 
				
			|||
	@Override | 
				
			|||
	public OptionScoreCardVarVo toVo() { | 
				
			|||
		OptionScoreCardVarVo vo =new OptionScoreCardVarVo(); | 
				
			|||
		super.toVo(vo); | 
				
			|||
		vo.setType(this.getType()); | 
				
			|||
		vo.setOption(this.getOption()); | 
				
			|||
		return vo; | 
				
			|||
	} | 
				
			|||
	 | 
				
			|||
	public OptionScoreCardVarEntity() {} | 
				
			|||
	public OptionScoreCardVarEntity(String id) { | 
				
			|||
		this.id =id; | 
				
			|||
	} | 
				
			|||
	 | 
				
			|||
	@Override | 
				
			|||
	public ScoreCardVarType getType() { | 
				
			|||
		return ScoreCardVarType.OPTION; | 
				
			|||
	} | 
				
			|||
	 | 
				
			|||
	 | 
				
			|||
	public String getOption() { | 
				
			|||
		return option; | 
				
			|||
	} | 
				
			|||
	public void setOption(String option) { | 
				
			|||
		this.option = option; | 
				
			|||
	} | 
				
			|||
	 | 
				
			|||
	@Override | 
				
			|||
	public TestCaseParameterWrapper toTestCaseParameterWrapper() { | 
				
			|||
		TestCaseParameterWrapper wrapper =new TestCaseParameterWrapper(this.getId(),this.getCode(),null,null,null,null,false); | 
				
			|||
		 | 
				
			|||
		wrapper.setTestCaseId(null); | 
				
			|||
		wrapper.setParent(null); | 
				
			|||
		wrapper.setCategory("P"); | 
				
			|||
		wrapper.setName(this.getName()); | 
				
			|||
		wrapper.setParameterType(null); | 
				
			|||
		wrapper.setScoreCardVarType(this.getType()); | 
				
			|||
		wrapper.setIndicatorType(null); | 
				
			|||
		wrapper.setValueType("java.lang.String"); | 
				
			|||
		wrapper.setDefaultValue(null); | 
				
			|||
		wrapper.setOrder(this.getOrder()); | 
				
			|||
		 | 
				
			|||
		return wrapper; | 
				
			|||
	} | 
				
			|||
} | 
				
			|||
@ -1,50 +0,0 @@ | 
				
			|||
package io.sc.engine.rule.server.scorecard.entity; | 
				
			|||
 | 
				
			|||
import com.fasterxml.jackson.annotation.JsonTypeName; | 
				
			|||
import io.sc.engine.rule.core.enums.ScoreCardVarType; | 
				
			|||
import io.sc.engine.rule.server.scorecard.vo.ScoreCardIndicatorValueVarVo; | 
				
			|||
import io.sc.engine.rule.server.testcase.wrapper.TestCaseParameterWrapper; | 
				
			|||
 | 
				
			|||
import javax.persistence.DiscriminatorValue; | 
				
			|||
import javax.persistence.Entity; | 
				
			|||
 | 
				
			|||
/** | 
				
			|||
 * 评分卡变量(指标值)实体类 | 
				
			|||
 * @author wangshaoping | 
				
			|||
 * | 
				
			|||
 */ | 
				
			|||
@Entity | 
				
			|||
@DiscriminatorValue("INDICATOR_VALUE") | 
				
			|||
@JsonTypeName("INDICATOR_VALUE") | 
				
			|||
public class ScoreCardIndicatorValueVarEntity extends ScoreCardIndicatorVarEntity { | 
				
			|||
	@Override | 
				
			|||
	public ScoreCardIndicatorValueVarVo toVo() { | 
				
			|||
		ScoreCardIndicatorValueVarVo vo =new ScoreCardIndicatorValueVarVo(); | 
				
			|||
		super.toVo(vo); | 
				
			|||
		vo.setType(this.getType()); | 
				
			|||
		return vo; | 
				
			|||
	} | 
				
			|||
 | 
				
			|||
	@Override | 
				
			|||
	public ScoreCardVarType getType() { | 
				
			|||
		return ScoreCardVarType.INDICATOR_VALUE; | 
				
			|||
	} | 
				
			|||
	 | 
				
			|||
	@Override | 
				
			|||
	public TestCaseParameterWrapper toTestCaseParameterWrapper() { | 
				
			|||
		TestCaseParameterWrapper wrapper =new TestCaseParameterWrapper(this.getId(),this.getCode(),null,null,null,null,false); | 
				
			|||
		 | 
				
			|||
		wrapper.setTestCaseId(null); | 
				
			|||
		wrapper.setParent(null); | 
				
			|||
		wrapper.setCategory("P"); | 
				
			|||
		wrapper.setName(this.getName()); | 
				
			|||
		wrapper.setParameterType(null); | 
				
			|||
		wrapper.setScoreCardVarType(this.getType()); | 
				
			|||
		wrapper.setIndicatorType(null); | 
				
			|||
		wrapper.setValueType("java.math.BigDecimal"); | 
				
			|||
		wrapper.setDefaultValue(null); | 
				
			|||
		wrapper.setOrder(this.getOrder()); | 
				
			|||
		 | 
				
			|||
		return wrapper; | 
				
			|||
	} | 
				
			|||
} | 
				
			|||
@ -1,77 +0,0 @@ | 
				
			|||
package io.sc.engine.rule.server.scorecard.entity; | 
				
			|||
 | 
				
			|||
import javax.persistence.Column; | 
				
			|||
import javax.persistence.Entity; | 
				
			|||
 | 
				
			|||
import io.sc.engine.rule.server.scorecard.vo.ScoreCardIndicatorValueVarVo; | 
				
			|||
import io.sc.engine.rule.server.scorecard.vo.ScoreCardIndicatorVarVo; | 
				
			|||
import io.sc.engine.rule.server.testcase.wrapper.TestCaseParameterWrapper; | 
				
			|||
 | 
				
			|||
@Entity | 
				
			|||
public class ScoreCardIndicatorVarEntity extends ScoreCardVarEntity{ | 
				
			|||
 | 
				
			|||
	//库代码
 | 
				
			|||
	@Column(name="LIB_CODE_") | 
				
			|||
	protected String libCode; | 
				
			|||
	 | 
				
			|||
	//库版本
 | 
				
			|||
	@Column(name="LIB_VERSION_") | 
				
			|||
	protected Integer libVersion; | 
				
			|||
	 | 
				
			|||
	//指标代码
 | 
				
			|||
	@Column(name="INDICATOR_CODE_") | 
				
			|||
	protected String indicatorCode; | 
				
			|||
 | 
				
			|||
	@Override | 
				
			|||
	public ScoreCardIndicatorVarVo toVo() { | 
				
			|||
		ScoreCardIndicatorVarVo vo =new ScoreCardIndicatorVarVo(); | 
				
			|||
		super.toVo(vo); | 
				
			|||
		vo.setType(this.getType()); | 
				
			|||
		vo.setLibCode(this.getLibCode()); | 
				
			|||
		vo.setLibVersion(this.getLibVersion()); | 
				
			|||
		vo.setIndicatorCode(this.getIndicatorCode()); | 
				
			|||
		return vo; | 
				
			|||
	} | 
				
			|||
 | 
				
			|||
	public String getLibCode() { | 
				
			|||
		return libCode; | 
				
			|||
	} | 
				
			|||
 | 
				
			|||
	public void setLibCode(String libCode) { | 
				
			|||
		this.libCode = libCode; | 
				
			|||
	} | 
				
			|||
 | 
				
			|||
	public Integer getLibVersion() { | 
				
			|||
		return libVersion; | 
				
			|||
	} | 
				
			|||
 | 
				
			|||
	public void setLibVersion(Integer libVersion) { | 
				
			|||
		this.libVersion = libVersion; | 
				
			|||
	} | 
				
			|||
 | 
				
			|||
	public String getIndicatorCode() { | 
				
			|||
		return indicatorCode; | 
				
			|||
	} | 
				
			|||
 | 
				
			|||
	public void setIndicatorCode(String indicatorCode) { | 
				
			|||
		this.indicatorCode = indicatorCode; | 
				
			|||
	} | 
				
			|||
	 | 
				
			|||
	@Override | 
				
			|||
	public TestCaseParameterWrapper toTestCaseParameterWrapper() { | 
				
			|||
		TestCaseParameterWrapper wrapper =new TestCaseParameterWrapper(this.getId(),this.getCode(),null,null,null,null,false); | 
				
			|||
		 | 
				
			|||
		wrapper.setTestCaseId(null); | 
				
			|||
		wrapper.setParent(null); | 
				
			|||
		wrapper.setCategory("P"); | 
				
			|||
		wrapper.setName(this.getName()); | 
				
			|||
		wrapper.setParameterType(null); | 
				
			|||
		wrapper.setScoreCardVarType(this.getType()); | 
				
			|||
		wrapper.setIndicatorType(null); | 
				
			|||
		wrapper.setValueType("java.math.BigDecimal"); | 
				
			|||
		wrapper.setDefaultValue(null); | 
				
			|||
		wrapper.setOrder(this.getOrder()); | 
				
			|||
		 | 
				
			|||
		return wrapper; | 
				
			|||
	} | 
				
			|||
} | 
				
			|||
@ -1,155 +0,0 @@ | 
				
			|||
package io.sc.engine.rule.server.scorecard.entity; | 
				
			|||
 | 
				
			|||
import java.io.Serializable; | 
				
			|||
 | 
				
			|||
import javax.persistence.Column; | 
				
			|||
import javax.persistence.DiscriminatorColumn; | 
				
			|||
import javax.persistence.DiscriminatorType; | 
				
			|||
import javax.persistence.Entity; | 
				
			|||
import javax.persistence.EnumType; | 
				
			|||
import javax.persistence.Enumerated; | 
				
			|||
import javax.persistence.FetchType; | 
				
			|||
import javax.persistence.GeneratedValue; | 
				
			|||
import javax.persistence.Id; | 
				
			|||
import javax.persistence.Inheritance; | 
				
			|||
import javax.persistence.InheritanceType; | 
				
			|||
import javax.persistence.JoinColumn; | 
				
			|||
import javax.persistence.ManyToOne; | 
				
			|||
import javax.persistence.Table; | 
				
			|||
import javax.validation.constraints.Size; | 
				
			|||
 | 
				
			|||
import io.sc.engine.rule.server.scorecard.vo.ScoreCardVarVo; | 
				
			|||
import io.sc.platform.orm.DeepClone; | 
				
			|||
import io.sc.platform.orm.IdClearable; | 
				
			|||
import io.sc.platform.orm.api.vo.AuditorVo; | 
				
			|||
import org.hibernate.annotations.GenericGenerator; | 
				
			|||
import org.springframework.beans.BeanUtils; | 
				
			|||
import io.sc.engine.rule.core.enums.ScoreCardVarType; | 
				
			|||
import io.sc.engine.rule.server.resource.entity.ResourceEntity; | 
				
			|||
import io.sc.engine.rule.server.testcase.annotation.TestCaseParameterAble; | 
				
			|||
import io.sc.engine.rule.server.testcase.wrapper.TestCaseParameterWrapper; | 
				
			|||
import io.sc.platform.orm.entity.AuditorEntity; | 
				
			|||
 | 
				
			|||
import com.fasterxml.jackson.annotation.JsonSubTypes; | 
				
			|||
import com.fasterxml.jackson.annotation.JsonTypeInfo; | 
				
			|||
 | 
				
			|||
/** | 
				
			|||
 * 评分卡变量实体类 | 
				
			|||
 */ | 
				
			|||
@Entity | 
				
			|||
@Inheritance(strategy = InheritanceType.SINGLE_TABLE) | 
				
			|||
@DiscriminatorColumn(name="TYPE_",discriminatorType=DiscriminatorType.STRING,length=20) | 
				
			|||
@Table(name="RE_SCORE_CARD_VAR") | 
				
			|||
@JsonTypeInfo(use=JsonTypeInfo.Id.NAME, include=JsonTypeInfo.As.PROPERTY, property="type",defaultImpl=OptionScoreCardVarEntity.class) | 
				
			|||
@JsonSubTypes({ | 
				
			|||
	@JsonSubTypes.Type(value=NumberRangeScoreCardIndicatorVarEntity.class),	//指标数值分段
 | 
				
			|||
	@JsonSubTypes.Type(value=NumberRangeScoreCardVarEntity.class),			//数值分段
 | 
				
			|||
	 | 
				
			|||
	@JsonSubTypes.Type(value=OptionScoreCardIndicatorVarEntity.class),		//指标选项
 | 
				
			|||
	@JsonSubTypes.Type(value=OptionScoreCardVarEntity.class),				//选项
 | 
				
			|||
	 | 
				
			|||
	@JsonSubTypes.Type(value=ScoreCardIndicatorValueVarEntity.class)		//值
 | 
				
			|||
}) | 
				
			|||
public abstract class ScoreCardVarEntity extends AuditorEntity<ScoreCardVarVo> implements DeepClone, IdClearable, TestCaseParameterAble { | 
				
			|||
	//ID,主键
 | 
				
			|||
	@Id | 
				
			|||
	@GeneratedValue(generator = "system-uuid") | 
				
			|||
	@GenericGenerator(name = "system-uuid", strategy = "uuid2") | 
				
			|||
	@Column(name="ID_", length=36) | 
				
			|||
	@Size(max=36) | 
				
			|||
	protected String id; | 
				
			|||
	 | 
				
			|||
	//代码
 | 
				
			|||
	@Column(name="CODE_") | 
				
			|||
	protected String code; | 
				
			|||
	 | 
				
			|||
	//名称
 | 
				
			|||
	@Column(name="NAME_", length=254) | 
				
			|||
	@Size(max=254) | 
				
			|||
	protected String name; | 
				
			|||
	 | 
				
			|||
	//类型
 | 
				
			|||
	@Column(name="TYPE_",insertable = false,updatable = false) | 
				
			|||
	@Enumerated(EnumType.STRING) | 
				
			|||
	protected ScoreCardVarType type; | 
				
			|||
	 | 
				
			|||
	//排序
 | 
				
			|||
	@Column(name="ORDER_") | 
				
			|||
	protected Integer order; | 
				
			|||
	 | 
				
			|||
	//所属资源
 | 
				
			|||
	@ManyToOne(fetch=FetchType.LAZY) | 
				
			|||
	@JoinColumn(name="RESOURCE_ID_") | 
				
			|||
	protected ResourceEntity resource; | 
				
			|||
 | 
				
			|||
	public void toVo(ScoreCardVarVo vo) { | 
				
			|||
		if(vo!=null) { | 
				
			|||
			super.toVo(vo); | 
				
			|||
			vo.setId(this.getId()); | 
				
			|||
			vo.setCode(this.getCode()); | 
				
			|||
			vo.setName(this.getName()); | 
				
			|||
			vo.setType(this.getType()); | 
				
			|||
			vo.setOrder(this.getOrder()); | 
				
			|||
			vo.setResource(this.getResource()==null?null:this.getResource().getId()); | 
				
			|||
		} | 
				
			|||
	} | 
				
			|||
 | 
				
			|||
	public ScoreCardVarEntity() {} | 
				
			|||
	public ScoreCardVarEntity(String id) { | 
				
			|||
		this.id =id; | 
				
			|||
	} | 
				
			|||
	 | 
				
			|||
	public String getId() { | 
				
			|||
		return id; | 
				
			|||
	} | 
				
			|||
	public void setId(String id) { | 
				
			|||
		this.id = id; | 
				
			|||
	} | 
				
			|||
	public String getCode() { | 
				
			|||
		return code; | 
				
			|||
	} | 
				
			|||
	public void setCode(String code) { | 
				
			|||
		this.code = code; | 
				
			|||
	} | 
				
			|||
	public String getName() { | 
				
			|||
		return name; | 
				
			|||
	} | 
				
			|||
	public void setName(String name) { | 
				
			|||
		this.name = name; | 
				
			|||
	} | 
				
			|||
	public ScoreCardVarType getType() { | 
				
			|||
		return type; | 
				
			|||
	} | 
				
			|||
	public void setType(ScoreCardVarType type) { | 
				
			|||
		this.type = type; | 
				
			|||
	} | 
				
			|||
	public Integer getOrder() { | 
				
			|||
		return order; | 
				
			|||
	} | 
				
			|||
	public void setOrder(Integer order) { | 
				
			|||
		this.order = order; | 
				
			|||
	} | 
				
			|||
	public ResourceEntity getResource() { | 
				
			|||
		return resource; | 
				
			|||
	} | 
				
			|||
	public void setResource(ResourceEntity resource) { | 
				
			|||
		this.resource = resource; | 
				
			|||
	} | 
				
			|||
	 | 
				
			|||
	@Override | 
				
			|||
	public Object deepClone() throws Exception{ | 
				
			|||
		ScoreCardVarEntity entity =this.getClass().newInstance(); | 
				
			|||
		BeanUtils.copyProperties(this, entity); | 
				
			|||
		return entity; | 
				
			|||
	} | 
				
			|||
	 | 
				
			|||
	@Override | 
				
			|||
	public void clearId() { | 
				
			|||
		this.setId(null); | 
				
			|||
	} | 
				
			|||
	 | 
				
			|||
	@Override | 
				
			|||
	public TestCaseParameterWrapper toTestCaseParameterWrapper() { | 
				
			|||
		return null; | 
				
			|||
	} | 
				
			|||
} | 
				
			|||
@ -1,28 +0,0 @@ | 
				
			|||
package io.sc.engine.rule.server.scorecard.exception; | 
				
			|||
 | 
				
			|||
/** | 
				
			|||
 * 评分卡变量已经存在违例类 | 
				
			|||
 */ | 
				
			|||
public class ScoreCardVarAlreadyExistsException extends RuntimeException{ | 
				
			|||
	private static final long serialVersionUID = 3989145728367307746L; | 
				
			|||
 | 
				
			|||
	public ScoreCardVarAlreadyExistsException() { | 
				
			|||
		super(); | 
				
			|||
	} | 
				
			|||
 | 
				
			|||
	public ScoreCardVarAlreadyExistsException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { | 
				
			|||
		super(message, cause, enableSuppression, writableStackTrace); | 
				
			|||
	} | 
				
			|||
 | 
				
			|||
	public ScoreCardVarAlreadyExistsException(String message, Throwable cause) { | 
				
			|||
		super(message, cause); | 
				
			|||
	} | 
				
			|||
 | 
				
			|||
	public ScoreCardVarAlreadyExistsException(String message) { | 
				
			|||
		super(message); | 
				
			|||
	} | 
				
			|||
 | 
				
			|||
	public ScoreCardVarAlreadyExistsException(Throwable cause) { | 
				
			|||
		super(cause); | 
				
			|||
	} | 
				
			|||
} | 
				
			|||
@ -1,28 +0,0 @@ | 
				
			|||
package io.sc.engine.rule.server.scorecard.exception; | 
				
			|||
 | 
				
			|||
/** | 
				
			|||
 * 评分卡变量代码和指标代码相同违例类 | 
				
			|||
 */ | 
				
			|||
public class ScoreCardVarCodeAndIndicatorCodeSameException extends RuntimeException{ | 
				
			|||
	private static final long serialVersionUID = -5557697135493816729L; | 
				
			|||
 | 
				
			|||
	public ScoreCardVarCodeAndIndicatorCodeSameException() { | 
				
			|||
		super(); | 
				
			|||
	} | 
				
			|||
 | 
				
			|||
	public ScoreCardVarCodeAndIndicatorCodeSameException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { | 
				
			|||
		super(message, cause, enableSuppression, writableStackTrace); | 
				
			|||
	} | 
				
			|||
 | 
				
			|||
	public ScoreCardVarCodeAndIndicatorCodeSameException(String message, Throwable cause) { | 
				
			|||
		super(message, cause); | 
				
			|||
	} | 
				
			|||
 | 
				
			|||
	public ScoreCardVarCodeAndIndicatorCodeSameException(String message) { | 
				
			|||
		super(message); | 
				
			|||
	} | 
				
			|||
 | 
				
			|||
	public ScoreCardVarCodeAndIndicatorCodeSameException(Throwable cause) { | 
				
			|||
		super(cause); | 
				
			|||
	} | 
				
			|||
} | 
				
			|||
@ -1,26 +0,0 @@ | 
				
			|||
package io.sc.engine.rule.server.scorecard.repository; | 
				
			|||
 | 
				
			|||
import java.util.List; | 
				
			|||
 | 
				
			|||
import org.springframework.data.jpa.repository.Query; | 
				
			|||
import org.springframework.data.repository.query.Param; | 
				
			|||
import io.sc.engine.rule.server.scorecard.entity.ScoreCardIndicatorVarEntity; | 
				
			|||
import io.sc.engine.rule.server.scorecard.entity.ScoreCardVarEntity; | 
				
			|||
import io.sc.platform.orm.repository.DaoRepository; | 
				
			|||
import org.springframework.stereotype.Repository; | 
				
			|||
 | 
				
			|||
@Repository("io.sc.engine.rule.server.scorecard.repository.ScoreCardVarRepository") | 
				
			|||
public interface ScoreCardVarRepository extends DaoRepository<ScoreCardVarEntity,String>{ | 
				
			|||
	@Query("select max(e.order)+1 from ScoreCardVarEntity e where e.resource.id=:id") | 
				
			|||
	public Integer getNextOrder(@Param("id") String id); | 
				
			|||
	 | 
				
			|||
	@Query("select e from ScoreCardVarEntity e where e.resource.id=:resourceId") | 
				
			|||
	public List<ScoreCardVarEntity> findByResourceId(@Param("resourceId")String resourceId); | 
				
			|||
	 | 
				
			|||
	@Query("select e from ScoreCardIndicatorVarEntity e where e.libCode=:libCode") | 
				
			|||
	public List<ScoreCardIndicatorVarEntity> findScoreCardIndicatorVarEntityByLibCode(@Param("libCode")String libCode); | 
				
			|||
	 | 
				
			|||
	@Query("select e from ScoreCardIndicatorVarEntity e where e.libCode=:libCode and e.libVersion=:libVersion and e.indicatorCode=:indicatorCode") | 
				
			|||
	public List<ScoreCardIndicatorVarEntity> findScoreCardIndicatorVarEntityByIndicatorCode(@Param("libCode")String libCode,@Param("libVersion")Integer libVersion,@Param("indicatorCode")String indicatorCode); | 
				
			|||
} | 
				
			|||
 | 
				
			|||
@ -1,17 +0,0 @@ | 
				
			|||
package io.sc.engine.rule.server.scorecard.service; | 
				
			|||
 | 
				
			|||
import java.util.List; | 
				
			|||
 | 
				
			|||
import org.springframework.data.repository.query.Param; | 
				
			|||
import io.sc.engine.rule.server.scorecard.entity.ScoreCardVarEntity; | 
				
			|||
import io.sc.engine.rule.server.scorecard.repository.ScoreCardVarRepository; | 
				
			|||
import io.sc.platform.orm.service.DaoService; | 
				
			|||
 | 
				
			|||
public interface ScoreCardVarService extends DaoService<ScoreCardVarEntity, String, ScoreCardVarRepository>{ | 
				
			|||
	/** | 
				
			|||
	 * 通过资源ID查询评分卡变量集合 | 
				
			|||
	 * @param resourceId 资源ID | 
				
			|||
	 * @return 评分卡变量集合 | 
				
			|||
	 */ | 
				
			|||
	public List<ScoreCardVarEntity> findByResourceId(@Param("resourceId")String resourceId); | 
				
			|||
} | 
				
			|||
@ -1,151 +0,0 @@ | 
				
			|||
package io.sc.engine.rule.server.scorecard.service.impl; | 
				
			|||
 | 
				
			|||
import io.sc.engine.rule.core.util.Strings; | 
				
			|||
import io.sc.engine.rule.server.resource.entity.ResourceEntity; | 
				
			|||
import io.sc.engine.rule.server.resource.entity.ScoreCardResourceEntity; | 
				
			|||
import io.sc.engine.rule.server.resource.service.ResourceService; | 
				
			|||
import io.sc.engine.rule.server.scorecard.entity.ScoreCardIndicatorVarEntity; | 
				
			|||
import io.sc.engine.rule.server.scorecard.entity.ScoreCardVarEntity; | 
				
			|||
import io.sc.engine.rule.server.scorecard.exception.ScoreCardVarAlreadyExistsException; | 
				
			|||
import io.sc.engine.rule.server.scorecard.exception.ScoreCardVarCodeAndIndicatorCodeSameException; | 
				
			|||
import io.sc.engine.rule.server.scorecard.repository.ScoreCardVarRepository; | 
				
			|||
import io.sc.engine.rule.server.scorecard.service.ScoreCardVarService; | 
				
			|||
import io.sc.engine.rule.server.scorecard.service.support.ScoreCardVarEntityChangedEvent; | 
				
			|||
import io.sc.platform.orm.entity.support.EntityChangedEventType; | 
				
			|||
import io.sc.platform.orm.service.impl.DaoServiceImpl; | 
				
			|||
import org.springframework.beans.factory.annotation.Autowired; | 
				
			|||
import org.springframework.context.ApplicationContext; | 
				
			|||
import org.springframework.stereotype.Service; | 
				
			|||
import org.springframework.transaction.annotation.Transactional; | 
				
			|||
import org.springframework.util.StringUtils; | 
				
			|||
 | 
				
			|||
import java.util.List; | 
				
			|||
 | 
				
			|||
@Service("io.sc.engine.rule.server.scorecard.service.impl.ScoreCardVarServiceImpl") | 
				
			|||
public class ScoreCardVarServiceImpl extends DaoServiceImpl<ScoreCardVarEntity, String, ScoreCardVarRepository> implements ScoreCardVarService{ | 
				
			|||
	@Autowired private ApplicationContext applicationContext; | 
				
			|||
	@Autowired private ResourceService resourceService; | 
				
			|||
	 | 
				
			|||
	@Override | 
				
			|||
	public ScoreCardVarEntity add(ScoreCardVarEntity entity) throws Exception { | 
				
			|||
		if(entity!=null) { | 
				
			|||
			if(entity instanceof ScoreCardIndicatorVarEntity) { | 
				
			|||
				ScoreCardIndicatorVarEntity scoreCardIndicatorVarEntity =(ScoreCardIndicatorVarEntity)entity; | 
				
			|||
				if(scoreCardIndicatorVarEntity.getCode()!=null && scoreCardIndicatorVarEntity.getCode().equals(scoreCardIndicatorVarEntity.getIndicatorCode())) { | 
				
			|||
					throw new ScoreCardVarCodeAndIndicatorCodeSameException(); | 
				
			|||
				} | 
				
			|||
			} | 
				
			|||
			 | 
				
			|||
			entity.setName(Strings.replaceCR_LF(entity.getName())); | 
				
			|||
			if(!StringUtils.hasText(entity.getCode())) { | 
				
			|||
				entity.setCode("V"+System.currentTimeMillis()); | 
				
			|||
			} | 
				
			|||
	 | 
				
			|||
			String resourceId =entity.getResource().getId(); | 
				
			|||
			ResourceEntity resourceEntity =resourceService.findById(resourceId); | 
				
			|||
			if(resourceEntity!=null && resourceEntity instanceof ScoreCardResourceEntity) { | 
				
			|||
				ScoreCardResourceEntity scoreCardResourceEntity =(ScoreCardResourceEntity)resourceEntity; | 
				
			|||
				List<ScoreCardVarEntity> vars =scoreCardResourceEntity.getScoreCardVars(); | 
				
			|||
				if(vars!=null && vars.size()>0) { | 
				
			|||
					for(ScoreCardVarEntity var : vars) { | 
				
			|||
						if(var.getCode().equals(entity.getCode()) || var.getName().equals(entity.getName())) { | 
				
			|||
							throw new ScoreCardVarAlreadyExistsException(); | 
				
			|||
						} | 
				
			|||
					} | 
				
			|||
				} | 
				
			|||
			} | 
				
			|||
				 | 
				
			|||
			Integer nextOrder =repository.getNextOrder(entity.getResource().getId()); | 
				
			|||
			if(nextOrder!=null) { | 
				
			|||
				entity.setOrder(nextOrder); | 
				
			|||
			}else { | 
				
			|||
				entity.setOrder(1); | 
				
			|||
			} | 
				
			|||
			 | 
				
			|||
			ScoreCardVarEntity newEntity =super.add(entity); | 
				
			|||
			 | 
				
			|||
			//通知其他实体进行相应的更新
 | 
				
			|||
			applicationContext.publishEvent(new ScoreCardVarEntityChangedEvent(EntityChangedEventType.ADD,null, newEntity)); | 
				
			|||
			 | 
				
			|||
			return newEntity; | 
				
			|||
		} | 
				
			|||
		return null; | 
				
			|||
	} | 
				
			|||
	 | 
				
			|||
	@Override | 
				
			|||
	@Transactional | 
				
			|||
	public ScoreCardVarEntity update(String primaryKey, ScoreCardVarEntity entity) throws Exception { | 
				
			|||
		if(primaryKey==null){ | 
				
			|||
			throw exceptionProvider.getUpdateNullOldObjectPrimaryKeyException(); | 
				
			|||
		} | 
				
			|||
		if(entity==null){ | 
				
			|||
			throw exceptionProvider.getUpdateNullNewObjectException(); | 
				
			|||
		} | 
				
			|||
		 | 
				
			|||
		//当参数变化时,通知其他监听器
 | 
				
			|||
		ScoreCardVarEntity oldEntity =findById(primaryKey); | 
				
			|||
		applicationContext.publishEvent(new ScoreCardVarEntityChangedEvent(EntityChangedEventType.UPDATE,oldEntity, entity)); | 
				
			|||
		 | 
				
			|||
		entity.setName(Strings.replaceCR_LF(entity.getName())); | 
				
			|||
		if(!StringUtils.hasText(entity.getCode())) { | 
				
			|||
			entity.setCode("V"+System.currentTimeMillis()); | 
				
			|||
		} | 
				
			|||
 | 
				
			|||
		String resourceId =entity.getResource().getId(); | 
				
			|||
		ResourceEntity resourceEntity =resourceService.findById(resourceId); | 
				
			|||
		if(resourceEntity!=null && resourceEntity instanceof ScoreCardResourceEntity) { | 
				
			|||
			ScoreCardResourceEntity scoreCardResourceEntity =(ScoreCardResourceEntity)resourceEntity; | 
				
			|||
			List<ScoreCardVarEntity> vars =scoreCardResourceEntity.getScoreCardVars(); | 
				
			|||
			if(vars!=null && vars.size()>0) { | 
				
			|||
				for(ScoreCardVarEntity var : vars) { | 
				
			|||
					if(!var.getId().equals(entity.getId())) { | 
				
			|||
						if(var.getCode().equals(entity.getCode()) || var.getName().equals(entity.getName())) { | 
				
			|||
							throw new ScoreCardVarAlreadyExistsException(); | 
				
			|||
						} | 
				
			|||
					} | 
				
			|||
				} | 
				
			|||
			} | 
				
			|||
		} | 
				
			|||
		 | 
				
			|||
		//如果没有顺序则自动生成顺序
 | 
				
			|||
		if(entity.getOrder()==null) { | 
				
			|||
			Integer nextOrder =repository.getNextOrder(entity.getResource().getId()); | 
				
			|||
			if(nextOrder!=null) { | 
				
			|||
				entity.setOrder(nextOrder); | 
				
			|||
			}else { | 
				
			|||
				entity.setOrder(1); | 
				
			|||
			} | 
				
			|||
		} | 
				
			|||
		 | 
				
			|||
		//通知其他实体进行相应的更新
 | 
				
			|||
		applicationContext.publishEvent(new ScoreCardVarEntityChangedEvent(EntityChangedEventType.UPDATE,oldEntity, entity)); | 
				
			|||
		return super.update(primaryKey, entity); | 
				
			|||
	} | 
				
			|||
	 | 
				
			|||
	@Override | 
				
			|||
	public String remove(String primaryKey) throws Exception { | 
				
			|||
		ScoreCardVarEntity oldEntity =findById(primaryKey); | 
				
			|||
		//通知其他实体进行相应的更新
 | 
				
			|||
		applicationContext.publishEvent(new ScoreCardVarEntityChangedEvent(EntityChangedEventType.DELETE,oldEntity, null)); | 
				
			|||
		return super.remove(primaryKey); | 
				
			|||
	} | 
				
			|||
 | 
				
			|||
	@Override | 
				
			|||
	public List<String> remove(List<String> primaryKeys) throws Exception { | 
				
			|||
		if(primaryKeys!=null && !primaryKeys.isEmpty()) { | 
				
			|||
			List<ScoreCardVarEntity> willBeDeleted =repository.findAllById(primaryKeys); | 
				
			|||
			if(willBeDeleted!=null && willBeDeleted.size()>0) { | 
				
			|||
				for(ScoreCardVarEntity entity : willBeDeleted) { | 
				
			|||
					//通知其他实体进行相应的更新
 | 
				
			|||
					applicationContext.publishEvent(new ScoreCardVarEntityChangedEvent(EntityChangedEventType.DELETE,entity, null)); | 
				
			|||
				} | 
				
			|||
			} | 
				
			|||
		} | 
				
			|||
		return super.remove(primaryKeys); | 
				
			|||
	} | 
				
			|||
 | 
				
			|||
	@Override | 
				
			|||
	public List<ScoreCardVarEntity> findByResourceId(String resourceId) { | 
				
			|||
		return repository.findByResourceId(resourceId); | 
				
			|||
	} | 
				
			|||
} | 
				
			|||
@ -1,11 +0,0 @@ | 
				
			|||
package io.sc.engine.rule.server.scorecard.service.support; | 
				
			|||
 | 
				
			|||
import io.sc.engine.rule.server.scorecard.entity.ScoreCardVarEntity; | 
				
			|||
import io.sc.platform.orm.entity.support.EntityChangedEvent; | 
				
			|||
import io.sc.platform.orm.entity.support.EntityChangedEventType; | 
				
			|||
 | 
				
			|||
public class ScoreCardVarEntityChangedEvent extends EntityChangedEvent<ScoreCardVarEntity>{ | 
				
			|||
	public ScoreCardVarEntityChangedEvent(EntityChangedEventType type, ScoreCardVarEntity oldEntity, ScoreCardVarEntity newEntity) { | 
				
			|||
		super(type, oldEntity, newEntity); | 
				
			|||
	} | 
				
			|||
} | 
				
			|||
@ -1,26 +0,0 @@ | 
				
			|||
package io.sc.engine.rule.server.scorecard.vo; | 
				
			|||
 | 
				
			|||
import io.sc.engine.rule.core.enums.ScoreCardVarType; | 
				
			|||
 | 
				
			|||
import javax.persistence.DiscriminatorValue; | 
				
			|||
import javax.persistence.Entity; | 
				
			|||
 | 
				
			|||
/** | 
				
			|||
 * 评分卡变量(指标选项) Vo 类 | 
				
			|||
 */ | 
				
			|||
public class NumberRangeScoreCardIndicatorVarVo extends ScoreCardIndicatorVarVo { | 
				
			|||
	//数值分段
 | 
				
			|||
	private String numberRange; | 
				
			|||
	 | 
				
			|||
	@Override | 
				
			|||
	public ScoreCardVarType getType() { | 
				
			|||
		return ScoreCardVarType.INDICATOR_NUMBER_RANGE; | 
				
			|||
	} | 
				
			|||
	 | 
				
			|||
	public String getNumberRange() { | 
				
			|||
		return numberRange; | 
				
			|||
	} | 
				
			|||
	public void setNumberRange(String numberRange) { | 
				
			|||
		this.numberRange = numberRange; | 
				
			|||
	} | 
				
			|||
} | 
				
			|||
@ -1,23 +0,0 @@ | 
				
			|||
package io.sc.engine.rule.server.scorecard.vo; | 
				
			|||
 | 
				
			|||
import io.sc.engine.rule.core.enums.ScoreCardVarType; | 
				
			|||
 | 
				
			|||
/** | 
				
			|||
 * 评分卡变量(数值分段) Vo 类 | 
				
			|||
 */ | 
				
			|||
public class NumberRangeScoreCardVarVo extends ScoreCardVarVo { | 
				
			|||
	//数值分段
 | 
				
			|||
	private String numberRange; | 
				
			|||
	 | 
				
			|||
	@Override | 
				
			|||
	public ScoreCardVarType getType() { | 
				
			|||
		return ScoreCardVarType.NUMBER_RANGE; | 
				
			|||
	} | 
				
			|||
	 | 
				
			|||
	public String getNumberRange() { | 
				
			|||
		return numberRange; | 
				
			|||
	} | 
				
			|||
	public void setNumberRange(String numberRange) { | 
				
			|||
		this.numberRange = numberRange; | 
				
			|||
	} | 
				
			|||
} | 
				
			|||
@ -1,24 +0,0 @@ | 
				
			|||
package io.sc.engine.rule.server.scorecard.vo; | 
				
			|||
 | 
				
			|||
import io.sc.engine.rule.core.enums.ScoreCardVarType; | 
				
			|||
 | 
				
			|||
/** | 
				
			|||
 * 评分卡变量(指标选项) Vo 类 | 
				
			|||
 */ | 
				
			|||
public class OptionScoreCardIndicatorVarVo extends ScoreCardIndicatorVarVo { | 
				
			|||
	//选项
 | 
				
			|||
	private String option; | 
				
			|||
	 | 
				
			|||
	@Override | 
				
			|||
	public ScoreCardVarType getType() { | 
				
			|||
		return ScoreCardVarType.INDICATOR_OPTION; | 
				
			|||
	} | 
				
			|||
	 | 
				
			|||
	public String getOption() { | 
				
			|||
		return option; | 
				
			|||
	} | 
				
			|||
	public void setOption(String option) { | 
				
			|||
		this.option = option; | 
				
			|||
	} | 
				
			|||
 | 
				
			|||
} | 
				
			|||
@ -1,24 +0,0 @@ | 
				
			|||
package io.sc.engine.rule.server.scorecard.vo; | 
				
			|||
 | 
				
			|||
import io.sc.engine.rule.core.enums.ScoreCardVarType; | 
				
			|||
 | 
				
			|||
/** | 
				
			|||
 * 评分卡变量(选项) Vo 类 | 
				
			|||
 */ | 
				
			|||
public class OptionScoreCardVarVo extends ScoreCardVarVo { | 
				
			|||
	//选项
 | 
				
			|||
	private String option; | 
				
			|||
	 | 
				
			|||
	@Override | 
				
			|||
	public ScoreCardVarType getType() { | 
				
			|||
		return ScoreCardVarType.OPTION; | 
				
			|||
	} | 
				
			|||
	 | 
				
			|||
	 | 
				
			|||
	public String getOption() { | 
				
			|||
		return option; | 
				
			|||
	} | 
				
			|||
	public void setOption(String option) { | 
				
			|||
		this.option = option; | 
				
			|||
	} | 
				
			|||
} | 
				
			|||
@ -1,13 +0,0 @@ | 
				
			|||
package io.sc.engine.rule.server.scorecard.vo; | 
				
			|||
 | 
				
			|||
import io.sc.engine.rule.core.enums.ScoreCardVarType; | 
				
			|||
 | 
				
			|||
/** | 
				
			|||
 * 评分卡变量(指标值) Vo 类 | 
				
			|||
 */ | 
				
			|||
public class ScoreCardIndicatorValueVarVo extends ScoreCardIndicatorVarVo { | 
				
			|||
	@Override | 
				
			|||
	public ScoreCardVarType getType() { | 
				
			|||
		return ScoreCardVarType.INDICATOR_VALUE; | 
				
			|||
	} | 
				
			|||
} | 
				
			|||
@ -1,41 +0,0 @@ | 
				
			|||
package io.sc.engine.rule.server.scorecard.vo; | 
				
			|||
 | 
				
			|||
import io.sc.engine.rule.server.testcase.wrapper.TestCaseParameterWrapper; | 
				
			|||
 | 
				
			|||
import javax.persistence.Column; | 
				
			|||
import javax.persistence.Entity; | 
				
			|||
 | 
				
			|||
public class ScoreCardIndicatorVarVo extends ScoreCardVarVo { | 
				
			|||
	//库代码
 | 
				
			|||
	protected String libCode; | 
				
			|||
	 | 
				
			|||
	//库版本
 | 
				
			|||
	protected Integer libVersion; | 
				
			|||
	 | 
				
			|||
	//指标代码
 | 
				
			|||
	protected String indicatorCode; | 
				
			|||
 | 
				
			|||
	public String getLibCode() { | 
				
			|||
		return libCode; | 
				
			|||
	} | 
				
			|||
 | 
				
			|||
	public void setLibCode(String libCode) { | 
				
			|||
		this.libCode = libCode; | 
				
			|||
	} | 
				
			|||
 | 
				
			|||
	public Integer getLibVersion() { | 
				
			|||
		return libVersion; | 
				
			|||
	} | 
				
			|||
 | 
				
			|||
	public void setLibVersion(Integer libVersion) { | 
				
			|||
		this.libVersion = libVersion; | 
				
			|||
	} | 
				
			|||
 | 
				
			|||
	public String getIndicatorCode() { | 
				
			|||
		return indicatorCode; | 
				
			|||
	} | 
				
			|||
 | 
				
			|||
	public void setIndicatorCode(String indicatorCode) { | 
				
			|||
		this.indicatorCode = indicatorCode; | 
				
			|||
	} | 
				
			|||
} | 
				
			|||
@ -1,64 +0,0 @@ | 
				
			|||
package io.sc.engine.rule.server.scorecard.vo; | 
				
			|||
 | 
				
			|||
import io.sc.engine.rule.core.enums.ScoreCardVarType; | 
				
			|||
import io.sc.platform.orm.api.vo.AuditorVo; | 
				
			|||
 | 
				
			|||
/** | 
				
			|||
 * 评分卡变量 Vo 类 | 
				
			|||
 */ | 
				
			|||
public class ScoreCardVarVo extends AuditorVo { | 
				
			|||
	//ID,主键
 | 
				
			|||
	protected String id; | 
				
			|||
	 | 
				
			|||
	//代码
 | 
				
			|||
	protected String code; | 
				
			|||
	 | 
				
			|||
	//名称
 | 
				
			|||
	protected String name; | 
				
			|||
	 | 
				
			|||
	//类型
 | 
				
			|||
	protected ScoreCardVarType type; | 
				
			|||
	 | 
				
			|||
	//排序
 | 
				
			|||
	protected Integer order; | 
				
			|||
	 | 
				
			|||
	//所属资源
 | 
				
			|||
	protected String resource; | 
				
			|||
	 | 
				
			|||
	public String getId() { | 
				
			|||
		return id; | 
				
			|||
	} | 
				
			|||
	public void setId(String id) { | 
				
			|||
		this.id = id; | 
				
			|||
	} | 
				
			|||
	public String getCode() { | 
				
			|||
		return code; | 
				
			|||
	} | 
				
			|||
	public void setCode(String code) { | 
				
			|||
		this.code = code; | 
				
			|||
	} | 
				
			|||
	public String getName() { | 
				
			|||
		return name; | 
				
			|||
	} | 
				
			|||
	public void setName(String name) { | 
				
			|||
		this.name = name; | 
				
			|||
	} | 
				
			|||
	public ScoreCardVarType getType() { | 
				
			|||
		return type; | 
				
			|||
	} | 
				
			|||
	public void setType(ScoreCardVarType type) { | 
				
			|||
		this.type = type; | 
				
			|||
	} | 
				
			|||
	public Integer getOrder() { | 
				
			|||
		return order; | 
				
			|||
	} | 
				
			|||
	public void setOrder(Integer order) { | 
				
			|||
		this.order = order; | 
				
			|||
	} | 
				
			|||
	public String getResource() { | 
				
			|||
		return resource; | 
				
			|||
	} | 
				
			|||
	public void setResource(String resource) { | 
				
			|||
		this.resource = resource; | 
				
			|||
	} | 
				
			|||
} | 
				
			|||
@ -1,136 +0,0 @@ | 
				
			|||
package io.sc.engine.rule.server.testcase.bean; | 
				
			|||
 | 
				
			|||
import java.util.ArrayList; | 
				
			|||
import java.util.HashMap; | 
				
			|||
import java.util.List; | 
				
			|||
import java.util.Map; | 
				
			|||
import java.util.UUID; | 
				
			|||
 | 
				
			|||
import org.springframework.beans.factory.annotation.Autowired; | 
				
			|||
import org.springframework.stereotype.Component; | 
				
			|||
import org.springframework.util.StringUtils; | 
				
			|||
import io.sc.engine.rule.core.enums.IndicatorType; | 
				
			|||
import io.sc.engine.rule.core.enums.ScoreCardVarType; | 
				
			|||
import io.sc.engine.rule.core.enums.TestCaseOwnerType; | 
				
			|||
import io.sc.engine.rule.server.lib.entity.IndicatorEntity; | 
				
			|||
import io.sc.engine.rule.server.lib.service.IndicatorService; | 
				
			|||
import io.sc.engine.rule.server.model.service.ModelService; | 
				
			|||
import io.sc.engine.rule.server.resource.service.ResourceService; | 
				
			|||
import io.sc.engine.rule.server.scorecard.entity.ScoreCardIndicatorVarEntity; | 
				
			|||
import io.sc.engine.rule.server.scorecard.entity.ScoreCardVarEntity; | 
				
			|||
import io.sc.engine.rule.server.scorecard.service.ScoreCardVarService; | 
				
			|||
import io.sc.engine.rule.server.testcase.annotation.TestCaseParameterBuilderType; | 
				
			|||
import io.sc.engine.rule.server.testcase.entity.TestCaseParameterEntity; | 
				
			|||
import io.sc.engine.rule.server.testcase.service.TestCaseParameterBuilder; | 
				
			|||
import io.sc.engine.rule.server.testcase.service.TestCaseParameterService; | 
				
			|||
import io.sc.engine.rule.server.testcase.service.TestCaseService; | 
				
			|||
import io.sc.engine.rule.server.testcase.wrapper.TestCaseParameterWrapper; | 
				
			|||
 | 
				
			|||
@Component | 
				
			|||
@TestCaseParameterBuilderType(TestCaseOwnerType.SCORE_CARD) | 
				
			|||
public class ScoreCardTestCaseParameterBuilder implements TestCaseParameterBuilder{ | 
				
			|||
	@Autowired ResourceService resourceService; | 
				
			|||
	@Autowired ModelService modelService; | 
				
			|||
	@Autowired private ScoreCardVarService scoreCardVarService; | 
				
			|||
	@Autowired private TestCaseParameterService testCaseParameterService; | 
				
			|||
	@Autowired TestCaseService testCaseService; | 
				
			|||
	@Autowired IndicatorService indicatorService; | 
				
			|||
 | 
				
			|||
	public List<TestCaseParameterWrapper> buildTestCaseParameterWrappers(String ownerId, String testCaseId) throws Exception { | 
				
			|||
		if(StringUtils.hasText(ownerId)) { | 
				
			|||
			List<TestCaseParameterWrapper> wrappers =new ArrayList<TestCaseParameterWrapper>(); | 
				
			|||
			//通过评分卡实体所定义的结构构建测试用例参数树
 | 
				
			|||
			buildTestCaseParameterList(wrappers,null,scoreCardVarService.findByResourceId(ownerId)); | 
				
			|||
			//将已经配置的测试用例参数合并到上述树型结构中
 | 
				
			|||
			mergeTestCaseParameterList(testCaseId,wrappers); | 
				
			|||
			return wrappers; | 
				
			|||
		} | 
				
			|||
		return null; | 
				
			|||
	} | 
				
			|||
	 | 
				
			|||
	private void buildTestCaseParameterList(List<TestCaseParameterWrapper> list,TestCaseParameterWrapper parentNode,List<ScoreCardVarEntity> scoreCardVars) { | 
				
			|||
		if(list!=null) { | 
				
			|||
			if(scoreCardVars!=null && scoreCardVars.size()>0) { | 
				
			|||
				for(ScoreCardVarEntity scoreCardVar : scoreCardVars) { | 
				
			|||
					if(ScoreCardVarType.INDICATOR_NUMBER_RANGE.equals(scoreCardVar.getType())  | 
				
			|||
						|| ScoreCardVarType.INDICATOR_OPTION.equals(scoreCardVar.getType()) | 
				
			|||
						|| ScoreCardVarType.INDICATOR_VALUE.equals(scoreCardVar.getType()) | 
				
			|||
					){ | 
				
			|||
						ScoreCardIndicatorVarEntity scoreCardIndicatorVarEntity =(ScoreCardIndicatorVarEntity)scoreCardVar; | 
				
			|||
						String libCode =scoreCardIndicatorVarEntity.getLibCode(); | 
				
			|||
						Integer libVersion =scoreCardIndicatorVarEntity.getLibVersion(); | 
				
			|||
						String indicatorCode =scoreCardIndicatorVarEntity.getIndicatorCode(); | 
				
			|||
						IndicatorEntity indicatorEntity =indicatorService.getRepository().findByLibCodeAndVersionAndIndicatorCode(libCode, libVersion, indicatorCode); | 
				
			|||
						if(indicatorEntity!=null && IndicatorType.INTERFACE.equals(indicatorEntity.getType())) { | 
				
			|||
							list.add(indicatorEntity.toTestCaseParameterWrapper()); | 
				
			|||
						} | 
				
			|||
					} | 
				
			|||
					list.add(scoreCardVar.toTestCaseParameterWrapper()); | 
				
			|||
				} | 
				
			|||
				//添加评分卡最终结果测试用例参数
 | 
				
			|||
				TestCaseParameterWrapper wrapper =new TestCaseParameterWrapper(); | 
				
			|||
				wrapper.setId(UUID.randomUUID().toString()); | 
				
			|||
				wrapper.setCode("_SCORE_"); | 
				
			|||
				wrapper.setName("评分卡结果值"); | 
				
			|||
				wrapper.setCategory("P"); | 
				
			|||
				wrapper.setParameterType(null); | 
				
			|||
				wrapper.setScoreCardVarType(ScoreCardVarType.RESULT); | 
				
			|||
				wrapper.setOrder(Integer.MAX_VALUE); | 
				
			|||
				list.add(wrapper); | 
				
			|||
			} | 
				
			|||
		} | 
				
			|||
	} | 
				
			|||
	 | 
				
			|||
	 | 
				
			|||
	private void mergeTestCaseParameterList(String testCaseId,List<TestCaseParameterWrapper> wrappers) throws Exception { | 
				
			|||
		//根据评分卡结构构建的测试用例参数列表
 | 
				
			|||
		Map<String,TestCaseParameterWrapper> modelStructMap =new HashMap<String,TestCaseParameterWrapper>(); | 
				
			|||
		for(TestCaseParameterWrapper wrapper : wrappers) { | 
				
			|||
			wrapper.setTestCaseId(testCaseId); | 
				
			|||
			modelStructMap.put(wrapper.getCode(), wrapper); | 
				
			|||
		} | 
				
			|||
		 | 
				
			|||
		//已经配置的测试用例参数
 | 
				
			|||
		Map<String,TestCaseParameterEntity> configuredMap =new HashMap<String,TestCaseParameterEntity>(); | 
				
			|||
		List<TestCaseParameterEntity> entities =testCaseParameterService.getRepository().findByTestCase(testCaseId); | 
				
			|||
		for(TestCaseParameterEntity entity : entities) { | 
				
			|||
			configuredMap.put(entity.getCode(), entity); | 
				
			|||
		} | 
				
			|||
		 | 
				
			|||
		//将要删除的
 | 
				
			|||
		List<String> deleteds =new ArrayList<String>(); | 
				
			|||
		for(String key : configuredMap.keySet()) { | 
				
			|||
			if(!modelStructMap.containsKey(key)) { | 
				
			|||
				TestCaseParameterEntity entity =configuredMap.get(key); | 
				
			|||
				deleteds.add(entity.getId()); | 
				
			|||
			} | 
				
			|||
		} | 
				
			|||
		testCaseParameterService.remove(deleteds); | 
				
			|||
		 | 
				
			|||
		//将要插入的
 | 
				
			|||
		List<TestCaseParameterEntity> inserts =new ArrayList<TestCaseParameterEntity>(); | 
				
			|||
		for(String key : modelStructMap.keySet()) { | 
				
			|||
			TestCaseParameterWrapper wrapper =modelStructMap.get(key); | 
				
			|||
			if(!configuredMap.containsKey(key) && "P".equals(wrapper.getCategory())) { | 
				
			|||
				inserts.add(wrapper.toTestCaseParameterEntity()); | 
				
			|||
			} | 
				
			|||
		} | 
				
			|||
		testCaseParameterService.getRepository().saveAll(inserts); | 
				
			|||
		 | 
				
			|||
		//合并
 | 
				
			|||
		entities =testCaseParameterService.findByTestCase(testCaseId); | 
				
			|||
		if(entities!=null && entities.size()>0) { | 
				
			|||
			for(TestCaseParameterEntity entity : entities) { | 
				
			|||
				TestCaseParameterWrapper wrapper =modelStructMap.get(entity.getCode()); | 
				
			|||
				if(wrapper!=null) { | 
				
			|||
					wrapper.setId(entity.getId()); | 
				
			|||
					wrapper.setSkipCheck(entity.getSkipCheck()); | 
				
			|||
					wrapper.setInputValue(entity.getInputValue()); | 
				
			|||
					wrapper.setExpectValue(entity.getExpectValue()); | 
				
			|||
					wrapper.setResultValue(entity.getResultValue()); | 
				
			|||
					wrapper.setTestResult(entity.getTestResult()); | 
				
			|||
				} | 
				
			|||
			} | 
				
			|||
		} | 
				
			|||
	} | 
				
			|||
} | 
				
			|||
Some files were not shown because too many files changed in this diff
					Loading…
					
					
				
		Reference in new issue