对于审批完成的处理也要对这种特殊情况做处理,目前暂时不支持子流程
taskService.setAssignee(taskVo.getTaskId(), loginUser.getUsername()); // 获取下一节点数据 FlowNextDto nextFlowNode = flowTaskService.getNextFlowNode(task.getId(), taskVo.getValues()); String definitionld = runtimeService.createProcessInstanceQuery().processInstanceId(taskVo.getInstanceId()).singleResult().getProcessDefinitionId(); //获取bpm(模型)对象 BpmnModel bpmnModel = repositoryService.getBpmnModel(definitionld); //传节点定义key获取当前节点 FlowNode flowNode = (FlowNode) bpmnModel.getFlowElement(task.getTaskDefinitionKey()); if(Objects.nonNull(nextFlowNode)) { if(flowNode instanceof UserTask ){//当前节点是用户任务 UserTask userTask = (UserTask) flowNode; MultiInstanceLoopCharacteristics multiInstance = userTask.getLoopCharacteristics(); if (Objects.nonNull(multiInstance)) {//当前节点是会签节点 if(nextFlowNode.getType().equals(ProcessConstants.PROCESS_MULTI_INSTANCE)) {//若下个节点也是会签节点 taskService.complete(taskVo.getTaskId()); } else if(Objects.nonNull(taskVo.getValues()) && (taskVo.getValues().containsKey("approval"))) {//不是会签而且有approval //complete方法来流传任务到下一个节点。其中第二个参数variables为下一个节点需要的参数Map,主要指流程设置的一些变量信息 taskService.complete(taskVo.getTaskId(), taskVo.getValues(),true); Task nexttask = taskService.createTaskQuery().processInstanceId(taskVo.getInstanceId()).active().singleResult(); String assignee = taskVo.getValues().get("approval").toString(); taskService.setAssignee(nexttask.getId(), assignee); } else { taskService.complete(taskVo.getTaskId()); } } else if(Objects.nonNull(taskVo.getValues())) {//当前节点不是会签节点,而且有变量值 if(nextFlowNode.getType().equals(ProcessConstants.PROCESS_MULTI_INSTANCE)) {//若下个节点也是会签节点 if(Objects.nonNull(nextFlowNode.getUserList())) {//有下个节点有用户 Map<String, Object> approvalmap = new HashMap<>(); List<String> sysuserlist = nextFlowNode.getUserList().stream().map(obj-> (String) obj.getUsername()).collect(Collectors.toList()); approvalmap.put("approval", sysuserlist); taskService.complete(taskVo.getTaskId(), approvalmap); if(!nextFlowNode.isBisSequential()){//对并发会签进行assignee单独赋值 List<Task> nexttasklist = taskService.createTaskQuery().processInstanceId(taskVo.getInstanceId()).active().list(); int i=0; for (Task nexttask : nexttasklist) { String assignee = sysuserlist.get(i).toString(); taskService.setAssignee(nexttask.getId(), assignee); i++; } } } else {//有下个节点无用户 taskService.complete(taskVo.getTaskId(),taskVo.getValues()); } } else {//下个节点也不是会签而且有approval taskService.complete(taskVo.getTaskId(), taskVo.getValues(),true); Task nexttask = taskService.createTaskQuery().processInstanceId(taskVo.getInstanceId()).active().singleResult(); if(taskVo.getValues().containsKey("approval")) {//前端传回的审批人变量值 String assignee = taskVo.getValues().get("approval").toString(); taskService.setAssignee(nexttask.getId(), assignee); } } } else {//无传值情况 taskService.complete(taskVo.getTaskId()); } } } else { //下一个节点是空 taskService.complete(taskVo.getTaskId()); }