fix -- 更换表达式解析引擎为aviator
This commit is contained in:
@@ -27,11 +27,10 @@
|
|||||||
<artifactId>flowable-spring-boot-starter-process</artifactId>
|
<artifactId>flowable-spring-boot-starter-process</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- https://mvnrepository.com/artifact/org.eweb4j/fel -->
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.eweb4j</groupId>
|
<groupId>com.googlecode.aviator</groupId>
|
||||||
<artifactId>fel</artifactId>
|
<artifactId>aviator</artifactId>
|
||||||
<version>0.8</version>
|
<version>5.3.1</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|||||||
@@ -1,8 +1,7 @@
|
|||||||
package com.ruoyi.flowable.flow;
|
package com.ruoyi.flowable.flow;
|
||||||
|
|
||||||
import com.greenpineyu.fel.FelEngine;
|
import com.googlecode.aviator.AviatorEvaluator;
|
||||||
import com.greenpineyu.fel.FelEngineImpl;
|
import com.googlecode.aviator.Expression;
|
||||||
import com.greenpineyu.fel.context.FelContext;
|
|
||||||
import org.flowable.bpmn.model.Process;
|
import org.flowable.bpmn.model.Process;
|
||||||
import org.flowable.bpmn.model.*;
|
import org.flowable.bpmn.model.*;
|
||||||
import org.flowable.engine.RepositoryService;
|
import org.flowable.engine.RepositoryService;
|
||||||
@@ -65,10 +64,7 @@ public class FindNextNodeUtil {
|
|||||||
//1.有表达式,且为true
|
//1.有表达式,且为true
|
||||||
//2.无表达式
|
//2.无表达式
|
||||||
String expression = sequenceFlow.getConditionExpression();
|
String expression = sequenceFlow.getConditionExpression();
|
||||||
if (expression == null ||
|
if (expression == null || expressionResult(map, expression.substring(expression.lastIndexOf("{") + 1, expression.lastIndexOf("}")))) {
|
||||||
Boolean.parseBoolean(
|
|
||||||
String.valueOf(
|
|
||||||
result(map, expression.substring(expression.lastIndexOf("{") + 1, expression.lastIndexOf("}")))))) {
|
|
||||||
//出线的下一节点
|
//出线的下一节点
|
||||||
String nextFlowElementID = sequenceFlow.getTargetRef();
|
String nextFlowElementID = sequenceFlow.getTargetRef();
|
||||||
if (checkSubProcess(nextFlowElementID, flowElements, nextUser)) {
|
if (checkSubProcess(nextFlowElementID, flowElements, nextUser)) {
|
||||||
@@ -211,19 +207,15 @@ public class FindNextNodeUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 校验el表达示例
|
* 校验el表达式
|
||||||
*
|
*
|
||||||
* @param map
|
* @param map
|
||||||
* @param expression
|
* @param expression
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static Object result(Map<String, Object> map, String expression) {
|
public static boolean expressionResult(Map<String, Object> map, String expression) {
|
||||||
FelEngine fel = new FelEngineImpl();
|
Expression exp = AviatorEvaluator.compile(expression);
|
||||||
FelContext ctx = fel.getContext();
|
final Object execute = exp.execute(map);
|
||||||
for (Map.Entry<String, Object> entry : map.entrySet()) {
|
return Boolean.parseBoolean(String.valueOf(execute));
|
||||||
ctx.set(entry.getKey(), entry.getValue());
|
|
||||||
}
|
|
||||||
Object result = fel.eval(expression);
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -470,11 +470,13 @@ public class WfTaskServiceImpl extends FlowServiceFactory implements IWfTaskServ
|
|||||||
Authentication.setAuthenticatedUserId(LoginHelper.getUserId().toString());
|
Authentication.setAuthenticatedUserId(LoginHelper.getUserId().toString());
|
||||||
// taskService.addComment(task.getId(), processInstance.getProcessInstanceId(), FlowComment.STOP.getType(),
|
// taskService.addComment(task.getId(), processInstance.getProcessInstanceId(), FlowComment.STOP.getType(),
|
||||||
// StringUtils.isBlank(flowTaskVo.getComment()) ? "取消申请" : flowTaskVo.getComment());
|
// StringUtils.isBlank(flowTaskVo.getComment()) ? "取消申请" : flowTaskVo.getComment());
|
||||||
|
// 获取当前流程最后一个节点
|
||||||
String endId = endNodes.get(0).getId();
|
String endId = endNodes.get(0).getId();
|
||||||
List<Execution> executions = runtimeService.createExecutionQuery()
|
List<Execution> executions = runtimeService.createExecutionQuery()
|
||||||
.parentId(processInstance.getProcessInstanceId()).list();
|
.parentId(processInstance.getProcessInstanceId()).list();
|
||||||
List<String> executionIds = new ArrayList<>();
|
List<String> executionIds = new ArrayList<>();
|
||||||
executions.forEach(execution -> executionIds.add(execution.getId()));
|
executions.forEach(execution -> executionIds.add(execution.getId()));
|
||||||
|
// 变更流程为已结束状态
|
||||||
runtimeService.createChangeActivityStateBuilder()
|
runtimeService.createChangeActivityStateBuilder()
|
||||||
.moveExecutionsToSingleActivityId(executionIds, endId).changeState();
|
.moveExecutionsToSingleActivityId(executionIds, endId).changeState();
|
||||||
}
|
}
|
||||||
@@ -777,10 +779,13 @@ public class WfTaskServiceImpl extends FlowServiceFactory implements IWfTaskServ
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public WfNextDto getNextFlowNode(WfTaskBo bo) {
|
public WfNextDto getNextFlowNode(WfTaskBo bo) {
|
||||||
|
// Step 1. 获取当前节点并找到下一步节点
|
||||||
Task task = taskService.createTaskQuery().taskId(bo.getTaskId()).singleResult();
|
Task task = taskService.createTaskQuery().taskId(bo.getTaskId()).singleResult();
|
||||||
WfNextDto nextDto = new WfNextDto();
|
WfNextDto nextDto = new WfNextDto();
|
||||||
if (Objects.nonNull(task)) {
|
if (Objects.nonNull(task)) {
|
||||||
List<UserTask> nextUserTask = FindNextNodeUtil.getNextUserTasks(repositoryService, task, new HashMap<>());
|
// Step 2. 获取当前流程所有流程变量(网关节点时需要校验表达式)
|
||||||
|
Map<String, Object> variables = taskService.getVariables(task.getId());
|
||||||
|
List<UserTask> nextUserTask = FindNextNodeUtil.getNextUserTasks(repositoryService, task, variables);
|
||||||
if (CollectionUtils.isNotEmpty(nextUserTask)) {
|
if (CollectionUtils.isNotEmpty(nextUserTask)) {
|
||||||
for (UserTask userTask : nextUserTask) {
|
for (UserTask userTask : nextUserTask) {
|
||||||
MultiInstanceLoopCharacteristics multiInstance = userTask.getLoopCharacteristics();
|
MultiInstanceLoopCharacteristics multiInstance = userTask.getLoopCharacteristics();
|
||||||
|
|||||||
Reference in New Issue
Block a user