|
|
|
@ -469,25 +469,29 @@ public class FlowTaskServiceImpl extends FlowServiceFactory implements IFlowTask
|
|
|
|
|
if (CollectionUtils.isEmpty(task)) {
|
|
|
|
|
throw new CustomException("流程未启动或已执行完成,取消申请失败");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SysUser loginUser = SecurityUtils.getLoginUser().getUser();
|
|
|
|
|
// 获取当前需撤回的流程实例
|
|
|
|
|
ProcessInstance processInstance =
|
|
|
|
|
runtimeService.createProcessInstanceQuery().processInstanceId(flowTaskVo.getInstanceId()).singleResult();
|
|
|
|
|
runtimeService.createProcessInstanceQuery()
|
|
|
|
|
.processInstanceId(flowTaskVo.getInstanceId())
|
|
|
|
|
.singleResult();
|
|
|
|
|
BpmnModel bpmnModel = repositoryService.getBpmnModel(processInstance.getProcessDefinitionId());
|
|
|
|
|
if (Objects.nonNull(bpmnModel)) {
|
|
|
|
|
Process process = bpmnModel.getMainProcess();
|
|
|
|
|
List<EndEvent> endNodes = process.findFlowElementsOfType(EndEvent.class, false);
|
|
|
|
|
if (CollectionUtils.isNotEmpty(endNodes)) {
|
|
|
|
|
SysUser loginUser = SecurityUtils.getLoginUser().getUser();
|
|
|
|
|
Authentication.setAuthenticatedUserId(loginUser.getUserId().toString());
|
|
|
|
|
// taskService.addComment(task.getId(), processInstance.getProcessInstanceId(), FlowComment.STOP.getType(),
|
|
|
|
|
// StringUtils.isBlank(flowTaskVo.getComment()) ? "取消申请" : flowTaskVo.getComment());
|
|
|
|
|
// 获取当前流程最后一个节点
|
|
|
|
|
String endId = endNodes.get(0).getId();
|
|
|
|
|
List<Execution> executions =
|
|
|
|
|
runtimeService.createExecutionQuery().parentId(processInstance.getProcessInstanceId()).list();
|
|
|
|
|
List<String> executionIds = new ArrayList<>();
|
|
|
|
|
executions.forEach(execution -> executionIds.add(execution.getId()));
|
|
|
|
|
runtimeService.createChangeActivityStateBuilder().moveExecutionsToSingleActivityId(executionIds,
|
|
|
|
|
endId).changeState();
|
|
|
|
|
// 变更流程为已结束状态
|
|
|
|
|
runtimeService.createChangeActivityStateBuilder()
|
|
|
|
|
.moveExecutionsToSingleActivityId(executionIds, endId).changeState();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -862,10 +866,13 @@ public class FlowTaskServiceImpl extends FlowServiceFactory implements IFlowTask
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public AjaxResult getNextFlowNode(FlowTaskVo flowTaskVo) {
|
|
|
|
|
// Step 1. 获取当前节点并找到下一步节点
|
|
|
|
|
Task task = taskService.createTaskQuery().taskId(flowTaskVo.getTaskId()).singleResult();
|
|
|
|
|
FlowNextDto flowNextDto = new FlowNextDto();
|
|
|
|
|
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)) {
|
|
|
|
|
for (UserTask userTask : nextUserTask) {
|
|
|
|
|
MultiInstanceLoopCharacteristics multiInstance = userTask.getLoopCharacteristics();
|
|
|
|
@ -908,7 +915,7 @@ public class FlowTaskServiceImpl extends FlowServiceFactory implements IFlowTask
|
|
|
|
|
flowNextDto.setType(ProcessConstants.USER_TYPE_ROUPS);
|
|
|
|
|
flowNextDto.setRoleList(sysRoles);
|
|
|
|
|
}
|
|
|
|
|
}else{
|
|
|
|
|
} else {
|
|
|
|
|
flowNextDto.setType(ProcessConstants.FIXED);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|