|
@@ -2,8 +2,8 @@ package com.flow.flowable.cmd;
|
|
|
|
|
|
|
|
|
import com.flow.flowable.utils.ProcessElementUtil;
|
|
|
-import org.flowable.bpmn.model.BpmnModel;
|
|
|
import org.flowable.bpmn.model.FlowElement;
|
|
|
+import org.flowable.bpmn.model.Process;
|
|
|
import org.flowable.common.engine.api.FlowableException;
|
|
|
import org.flowable.common.engine.impl.interceptor.Command;
|
|
|
import org.flowable.common.engine.impl.interceptor.CommandContext;
|
|
@@ -21,11 +21,13 @@ import java.util.stream.Collectors;
|
|
|
|
|
|
public class JumpActivityCmd implements Command<List<String>> {
|
|
|
protected String processInstanceId;
|
|
|
- protected String activityId;
|
|
|
+ protected String sourceId;
|
|
|
+ protected String targetId;
|
|
|
|
|
|
- public JumpActivityCmd(String processInstanceId, String activityId) {
|
|
|
+ public JumpActivityCmd(String processInstanceId, String sourceId, String targetId) {
|
|
|
this.processInstanceId = processInstanceId;
|
|
|
- this.activityId = activityId;
|
|
|
+ this.sourceId = sourceId;
|
|
|
+ this.targetId = targetId;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -35,10 +37,11 @@ public class JumpActivityCmd implements Command<List<String>> {
|
|
|
if (Objects.isNull(processInstance)) {
|
|
|
throw new FlowableException("流程实例不存在");
|
|
|
}
|
|
|
- BpmnModel bpmnModel = ProcessDefinitionUtil.getBpmnModel(processInstance.getProcessDefinitionId());
|
|
|
- FlowElement flowElement = bpmnModel.getFlowElement(activityId);
|
|
|
+ Process process = ProcessDefinitionUtil.getProcess(processInstance.getProcessDefinitionId());
|
|
|
+ FlowElement flowElement = process.getFlowElement(this.targetId);
|
|
|
Set<FlowElement> childElements = ProcessElementUtil.findChildElements(flowElement);
|
|
|
Set<String> nodeIds = childElements.stream().map(FlowElement::getId).collect(Collectors.toSet());
|
|
|
+ nodeIds.add(this.sourceId);
|
|
|
// 获取要跳转执行
|
|
|
List<ExecutionEntity> executions = executionManager.findChildExecutionsByParentExecutionId(processInstanceId);
|
|
|
List<String> executionIds = executions.stream()
|
|
@@ -56,7 +59,7 @@ public class JumpActivityCmd implements Command<List<String>> {
|
|
|
.getRuntimeService()
|
|
|
.createChangeActivityStateBuilder()
|
|
|
.processInstanceId(processInstanceId)
|
|
|
- .moveExecutionsToSingleActivityId(executionIds, activityId)
|
|
|
+ .moveExecutionsToSingleActivityId(executionIds, this.targetId)
|
|
|
.changeState();
|
|
|
}
|
|
|
return executionIds;
|