fix -- 更换表达式解析引擎为aviator

This commit is contained in:
konbai
2022-05-06 23:51:22 +08:00
parent f6995953d8
commit fd4ff7d9d0
3 changed files with 17 additions and 21 deletions

View File

@@ -27,11 +27,10 @@
<artifactId>flowable-spring-boot-starter-process</artifactId>
</dependency>
<!-- https://mvnrepository.com/artifact/org.eweb4j/fel -->
<dependency>
<groupId>org.eweb4j</groupId>
<artifactId>fel</artifactId>
<version>0.8</version>
<groupId>com.googlecode.aviator</groupId>
<artifactId>aviator</artifactId>
<version>5.3.1</version>
</dependency>
</dependencies>

View File

@@ -1,8 +1,7 @@
package com.ruoyi.flowable.flow;
import com.greenpineyu.fel.FelEngine;
import com.greenpineyu.fel.FelEngineImpl;
import com.greenpineyu.fel.context.FelContext;
import com.googlecode.aviator.AviatorEvaluator;
import com.googlecode.aviator.Expression;
import org.flowable.bpmn.model.Process;
import org.flowable.bpmn.model.*;
import org.flowable.engine.RepositoryService;
@@ -65,10 +64,7 @@ public class FindNextNodeUtil {
//1.有表达式且为true
//2.无表达式
String expression = sequenceFlow.getConditionExpression();
if (expression == null ||
Boolean.parseBoolean(
String.valueOf(
result(map, expression.substring(expression.lastIndexOf("{") + 1, expression.lastIndexOf("}")))))) {
if (expression == null || expressionResult(map, expression.substring(expression.lastIndexOf("{") + 1, expression.lastIndexOf("}")))) {
//出线的下一节点
String nextFlowElementID = sequenceFlow.getTargetRef();
if (checkSubProcess(nextFlowElementID, flowElements, nextUser)) {
@@ -211,19 +207,15 @@ public class FindNextNodeUtil {
}
/**
* 校验el表达示例
* 校验el表达
*
* @param map
* @param expression
* @return
*/
public static Object result(Map<String, Object> map, String expression) {
FelEngine fel = new FelEngineImpl();
FelContext ctx = fel.getContext();
for (Map.Entry<String, Object> entry : map.entrySet()) {
ctx.set(entry.getKey(), entry.getValue());
}
Object result = fel.eval(expression);
return result;
public static boolean expressionResult(Map<String, Object> map, String expression) {
Expression exp = AviatorEvaluator.compile(expression);
final Object execute = exp.execute(map);
return Boolean.parseBoolean(String.valueOf(execute));
}
}