|
@@ -4,6 +4,8 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
+import com.flow.cmd.GetLoopCharacteristics;
|
|
|
+import com.flow.cmd.GetMultiInstanceRootExecution;
|
|
|
import com.flow.cmd.JumpActivityCmd;
|
|
|
import com.flow.common.core.exception.BaseException;
|
|
|
import com.flow.common.core.model.PageResult;
|
|
@@ -32,10 +34,8 @@ import org.flowable.bpmn.model.BpmnModel;
|
|
|
import org.flowable.bpmn.model.MultiInstanceLoopCharacteristics;
|
|
|
import org.flowable.bpmn.model.UserTask;
|
|
|
import org.flowable.engine.*;
|
|
|
-import org.flowable.engine.impl.persistence.entity.ExecutionEntity;
|
|
|
import org.flowable.engine.runtime.ActivityInstance;
|
|
|
import org.flowable.engine.runtime.Execution;
|
|
|
-import org.flowable.engine.runtime.ProcessInstance;
|
|
|
import org.flowable.task.api.DelegationState;
|
|
|
import org.flowable.task.api.Task;
|
|
|
import org.flowable.task.api.TaskInfo;
|
|
@@ -298,10 +298,10 @@ public class FlowTaskServiceImpl extends BaseServiceImpl<FlowTaskDao, FlowTask>
|
|
|
assigneeList.add(taskForm.getAssignee());
|
|
|
}
|
|
|
runtimeService.setVariable(taskInfo.getProcessInstanceId(), collectionName, assigneeList);
|
|
|
- Execution miExecution = getMultiInstanceRootExecution(taskInfo.getProcessInstanceId(), taskInfo.getTaskDefinitionKey());
|
|
|
+ Execution miExecution = managementService.executeCommand(new GetMultiInstanceRootExecution(taskInfo.getProcessInstanceId(), taskInfo.getTaskDefinitionKey()));
|
|
|
Integer nrOfInstances = runtimeService.getVariableLocal(miExecution.getId(), "nrOfInstances", Integer.class);
|
|
|
runtimeService.setVariableLocal(miExecution.getId(), "nrOfInstances", nrOfInstances + 1);
|
|
|
- MultiInstanceLoopCharacteristics loopCharacteristics = getLoopCharacteristics(taskInfo.getProcessInstanceId(), taskInfo.getTaskDefinitionKey());
|
|
|
+ MultiInstanceLoopCharacteristics loopCharacteristics = managementService.executeCommand(new GetLoopCharacteristics(taskInfo.getProcessInstanceId(), taskInfo.getTaskDefinitionKey()));
|
|
|
if (!loopCharacteristics.isSequential()) {
|
|
|
Integer nrOfActiveInstances = runtimeService.getVariableLocal(miExecution.getId(), "nrOfActiveInstances", Integer.class);
|
|
|
runtimeService.setVariableLocal(miExecution.getId(), "nrOfActiveInstances", nrOfActiveInstances + 1);
|
|
@@ -318,10 +318,10 @@ public class FlowTaskServiceImpl extends BaseServiceImpl<FlowTaskDao, FlowTask>
|
|
|
public void removeSign(AddSignTaskForm taskForm) {
|
|
|
TaskInfo taskInfo = this.getTask(taskForm.getTaskId());
|
|
|
String collectionName = String.format("%sCollection", taskInfo.getTaskDefinitionKey());
|
|
|
- Execution miExecution = getMultiInstanceRootExecution(taskInfo.getProcessInstanceId(), taskInfo.getTaskDefinitionKey());
|
|
|
+ Execution miExecution = managementService.executeCommand(new GetMultiInstanceRootExecution(taskInfo.getProcessInstanceId(), taskInfo.getTaskDefinitionKey()));
|
|
|
Integer nrOfInstances = runtimeService.getVariableLocal(miExecution.getId(), "nrOfInstances", Integer.class);
|
|
|
runtimeService.setVariableLocal(miExecution.getId(), "nrOfInstances", nrOfInstances - 1);
|
|
|
- MultiInstanceLoopCharacteristics loopCharacteristics = getLoopCharacteristics(taskInfo.getProcessInstanceId(), taskInfo.getTaskDefinitionKey());
|
|
|
+ MultiInstanceLoopCharacteristics loopCharacteristics = managementService.executeCommand(new GetLoopCharacteristics(taskInfo.getProcessInstanceId(), taskInfo.getTaskDefinitionKey()));
|
|
|
List<String> assigneeList = runtimeService.getVariable(taskInfo.getProcessInstanceId(), collectionName, List.class);
|
|
|
if (loopCharacteristics.isSequential()) {
|
|
|
Integer loopCounter = runtimeService.getVariableLocal(taskInfo.getExecutionId(), "loopCounter", Integer.class);
|
|
@@ -357,37 +357,6 @@ public class FlowTaskServiceImpl extends BaseServiceImpl<FlowTaskDao, FlowTask>
|
|
|
.remove();
|
|
|
}
|
|
|
|
|
|
- private MultiInstanceLoopCharacteristics getLoopCharacteristics(String processInstanceId, String taskDefinitionKey) {
|
|
|
- ProcessInstance procInst = runtimeService.createProcessInstanceQuery()
|
|
|
- .processInstanceId(processInstanceId).singleResult();
|
|
|
- if (Objects.isNull(procInst)) {
|
|
|
- throw new BaseException("流程不存在");
|
|
|
- }
|
|
|
- BpmnModel bpmnModel = repositoryService.getBpmnModel(procInst.getProcessDefinitionId());
|
|
|
- MultiInstanceLoopCharacteristics loopCharacteristics = ((UserTask) bpmnModel.getFlowElement(taskDefinitionKey)).getLoopCharacteristics();
|
|
|
- if (Objects.isNull(loopCharacteristics)) {
|
|
|
- throw new BaseException("该节点不是多实例任务");
|
|
|
- }
|
|
|
- return loopCharacteristics;
|
|
|
- }
|
|
|
-
|
|
|
- private Execution getMultiInstanceRootExecution(String procInstId, String taskDefinitionKey) {
|
|
|
- List<Execution> executions = runtimeService.createExecutionQuery()
|
|
|
- .processInstanceId(procInstId).activityId(taskDefinitionKey).list();
|
|
|
- Execution multiInstanceRootExecution = null;
|
|
|
- Execution currentExecution = executions.get(0);
|
|
|
- while (currentExecution != null && multiInstanceRootExecution == null && currentExecution.getParentId() != null) {
|
|
|
- if (((ExecutionEntity) currentExecution).isMultiInstanceRoot()) {
|
|
|
- multiInstanceRootExecution = currentExecution;
|
|
|
- } else {
|
|
|
- currentExecution = runtimeService.createExecutionQuery()
|
|
|
- .executionId(currentExecution.getParentId()).singleResult();
|
|
|
- }
|
|
|
- }
|
|
|
- return multiInstanceRootExecution;
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
@Override
|
|
|
public void delegate(TransferTaskForm taskForm) {
|