|
|
|
@ -52,11 +52,14 @@ public class CalculationUtil {
|
|
|
|
|
// 初始化SpEL解析器
|
|
|
|
|
ExpressionParser parser = new SpelExpressionParser();
|
|
|
|
|
StandardEvaluationContext context = new StandardEvaluationContext();
|
|
|
|
|
// 判断并转换变量类型
|
|
|
|
|
Object leftValue = parseOperand(leftOperand);
|
|
|
|
|
Object rightValue = parseOperand(rightOperand);
|
|
|
|
|
context.setVariable("leftOperand", leftValue);
|
|
|
|
|
context.setVariable("rightOperand", rightValue);
|
|
|
|
|
// 如果是数字的比较,需要做类型转换
|
|
|
|
|
if (leftOperand.equals(IndexRuleConstants.OPERATOR_EARLY) || leftOperand.equals(IndexRuleConstants.OPERATOR_LATE) || leftOperand.equals(IndexRuleConstants.OPERATOR_CONTAIN)) {
|
|
|
|
|
context.setVariable("leftOperand", leftOperand);
|
|
|
|
|
context.setVariable("rightOperand", rightOperand);
|
|
|
|
|
} else {
|
|
|
|
|
context.setVariable("leftOperand", parseOperand(leftOperand));
|
|
|
|
|
context.setVariable("rightOperand", parseOperand(rightOperand));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 计算结果
|
|
|
|
|
return Boolean.TRUE.equals(parser.parseExpression(expression).getValue(context, Boolean.class));
|
|
|
|
|