| | |
| | | UserTask nextTask = nextFlowNode.getUserTask(); |
| | | Task task2 = null; |
| | | Optional<Task> first = task2List.stream().filter(t -> t.getTaskDefinitionKey().equals(nextTask.getId())).findFirst(); |
| | | task2 = first.orElseGet(() -> task2List.get(0)); |
| | | if (task2 != null) { |
| | | // 下个节点候选人 |
| | | List<String> beforeParamsCandidateUsernames = flowCallBackService.flowCandidateUsernamesOfTask(task2.getTaskDefinitionKey(), taskVo.getValues()); |
| | | List<String> candidateUsers = taskVo.getCandidateUsers(); |
| | | if (CollUtil.isNotEmpty(candidateUsers)) { |
| | | // 前端传入候选人 覆盖 |
| | | beforeParamsCandidateUsernames = candidateUsers; |
| | | } |
| | | if (task.getTaskDefinitionKey().equals(task2.getTaskDefinitionKey())) { |
| | | //多实例 会签 TODO |
| | | // * 当前节点是会签节点,没有走完 |
| | | business.setTaskId(task2.getId()) |
| | | // .setActStatus(ActStatus.doing) |
| | | .setDoneUsers(doneUserList.toJSONString()) |
| | | ; |
| | | String todoUsersStr = business.getTodoUsers(); |
| | | JSONArray todosArr = JSON.parseArray(todoUsersStr); |
| | | // 删除后重写 |
| | | for (Object oldUser : todosArr) { |
| | | taskService.deleteCandidateUser(task2.getId(), oldUser.toString()); |
| | | } |
| | | // 重写 |
| | | if (CollUtil.isNotEmpty(beforeParamsCandidateUsernames)) { |
| | | beforeParamsCandidateUsernames.remove(loginUser.getUsername()); |
| | | // 业务层有指定候选人,覆盖 |
| | | for (String newUser : beforeParamsCandidateUsernames) { |
| | | taskService.addCandidateUser(task2.getId(), newUser); |
| | | } |
| | | business.setTodoUsers(JSON.toJSONString(beforeParamsCandidateUsernames)); |
| | | } else { |
| | | todosArr.remove(loginUser.getUsername()); |
| | | for (Object oldUser : todosArr) { |
| | | taskService.addCandidateUser(task2.getId(), oldUser.toString()); |
| | | } |
| | | business.setTodoUsers(todosArr.toJSONString()); |
| | | } |
| | | |
| | | } else { |
| | | //能够处理下个节点的候选人 |
| | | List<SysUser> nextFlowNodeUserList = nextFlowNode.getUserList(); |
| | | List<String> collect_username = nextFlowNodeUserList.stream().map(SysUser::getUsername).collect(Collectors.toList()); |
| | | if(!first.isPresent() && !checkParallelCompletion(taskVo.getTaskId())){ |
| | | //下个节点任务还是并行网关的任务 |
| | | flowMyBusinessService.removeById(business.getId()); |
| | | } else { |
| | | task2 = first.orElseGet(() -> task2List.get(0)); |
| | | if (task2 != null) { |
| | | // 下个节点候选人 |
| | | List<String> beforeParamsCandidateUsernames = flowCallBackService.flowCandidateUsernamesOfTask(task2.getTaskDefinitionKey(), taskVo.getValues()); |
| | | List<String> candidateUsers = taskVo.getCandidateUsers(); |
| | | if (CollUtil.isNotEmpty(candidateUsers)) { |
| | | // 前端传入候选人 |
| | | collect_username = candidateUsers; |
| | | // 前端传入候选人 覆盖 |
| | | beforeParamsCandidateUsernames = candidateUsers; |
| | | } |
| | | business |
| | | .setTaskId(task2.getId()) |
| | | // .setActStatus(ActStatus.doing) |
| | | .setTaskNameId(nextTask.getId()) |
| | | .setTaskName(nextTask.getName()) |
| | | .setPriority(nextTask.getPriority()) |
| | | .setDoneUsers(doneUserList.toJSONString()) |
| | | .setTodoUsers(JSON.toJSONString(collect_username)) |
| | | ; |
| | | // 删除后重写 |
| | | for (String oldUser : collect_username) { |
| | | taskService.deleteCandidateUser(task2.getId(), oldUser); |
| | | } |
| | | if (CollUtil.isNotEmpty(beforeParamsCandidateUsernames)) { |
| | | // 前端没有传入候选人 && 业务层有指定候选人,覆盖 |
| | | for (String newUser : beforeParamsCandidateUsernames) { |
| | | taskService.addCandidateUser(task2.getId(), newUser); |
| | | if (task.getTaskDefinitionKey().equals(task2.getTaskDefinitionKey())) { |
| | | //多实例 会签 TODO |
| | | // * 当前节点是会签节点,没有走完 |
| | | business.setTaskId(task2.getId()) |
| | | // .setActStatus(ActStatus.doing) |
| | | .setDoneUsers(doneUserList.toJSONString()) |
| | | ; |
| | | String todoUsersStr = business.getTodoUsers(); |
| | | JSONArray todosArr = JSON.parseArray(todoUsersStr); |
| | | // 删除后重写 |
| | | for (Object oldUser : todosArr) { |
| | | taskService.deleteCandidateUser(task2.getId(), oldUser.toString()); |
| | | } |
| | | business.setTodoUsers(JSON.toJSONString(beforeParamsCandidateUsernames)); |
| | | // 重写 |
| | | if (CollUtil.isNotEmpty(beforeParamsCandidateUsernames)) { |
| | | beforeParamsCandidateUsernames.remove(loginUser.getUsername()); |
| | | // 业务层有指定候选人,覆盖 |
| | | for (String newUser : beforeParamsCandidateUsernames) { |
| | | taskService.addCandidateUser(task2.getId(), newUser); |
| | | } |
| | | business.setTodoUsers(JSON.toJSONString(beforeParamsCandidateUsernames)); |
| | | } else { |
| | | todosArr.remove(loginUser.getUsername()); |
| | | for (Object oldUser : todosArr) { |
| | | taskService.addCandidateUser(task2.getId(), oldUser.toString()); |
| | | } |
| | | business.setTodoUsers(todosArr.toJSONString()); |
| | | } |
| | | |
| | | } else { |
| | | for (String oldUser : collect_username) { |
| | | taskService.addCandidateUser(task2.getId(), oldUser); |
| | | //能够处理下个节点的候选人 |
| | | List<SysUser> nextFlowNodeUserList = nextFlowNode.getUserList(); |
| | | List<String> collect_username = nextFlowNodeUserList.stream().map(SysUser::getUsername).collect(Collectors.toList()); |
| | | if (CollUtil.isNotEmpty(candidateUsers)) { |
| | | // 前端传入候选人 |
| | | collect_username = candidateUsers; |
| | | } |
| | | business.setTodoUsers(JSON.toJSONString(collect_username)); |
| | | business |
| | | .setTaskId(task2.getId()) |
| | | // .setActStatus(ActStatus.doing) |
| | | .setTaskNameId(nextTask.getId()) |
| | | .setTaskName(nextTask.getName()) |
| | | .setPriority(nextTask.getPriority()) |
| | | .setDoneUsers(doneUserList.toJSONString()) |
| | | .setTodoUsers(JSON.toJSONString(collect_username)) |
| | | ; |
| | | // 删除后重写 |
| | | for (String oldUser : collect_username) { |
| | | taskService.deleteCandidateUser(task2.getId(), oldUser); |
| | | } |
| | | if (CollUtil.isNotEmpty(beforeParamsCandidateUsernames)) { |
| | | // 前端没有传入候选人 && 业务层有指定候选人,覆盖 |
| | | for (String newUser : beforeParamsCandidateUsernames) { |
| | | taskService.addCandidateUser(task2.getId(), newUser); |
| | | } |
| | | business.setTodoUsers(JSON.toJSONString(beforeParamsCandidateUsernames)); |
| | | } else { |
| | | for (String oldUser : collect_username) { |
| | | taskService.addCandidateUser(task2.getId(), oldUser); |
| | | } |
| | | business.setTodoUsers(JSON.toJSONString(collect_username)); |
| | | } |
| | | } |
| | | } |
| | | flowMyBusinessService.updateById(business); |
| | | } |
| | | flowMyBusinessService.updateById(business); |
| | | } |
| | | else { |
| | | for(FlowNextDto nextFlowNode : nextFlowNodeList) { |
| | |
| | | String username = iFlowThirdService.getLoginUser().getUsername(); |
| | | flowMyBusinessDto.setCurrentUser(username); |
| | | List<FlowTaskDto> list = flowMyBusinessService.ListMyBusiness(flowMyBusinessDto); |
| | | list.forEach(flowTaskDto -> { |
| | | // 流程发起人信息 |
| | | HistoricProcessInstance historicProcessInstance = historyService.createHistoricProcessInstanceQuery() |
| | | .processInstanceId(flowTaskDto.getProcInsId()) |
| | | .singleResult(); |
| | | if (historicProcessInstance != null) { |
| | | SysUser startUser = iFlowThirdService.getUserByUsername(historicProcessInstance.getStartUserId()); |
| | | if (startUser != null) { |
| | | flowTaskDto.setStartUserId(startUser.getUsername()); |
| | | flowTaskDto.setStartUserName(startUser.getRealname()); |
| | | } |
| | | List<String> departNamesByUsername = iFlowThirdService.getDepartNamesByUsername(historicProcessInstance.getStartUserId()); |
| | | flowTaskDto.setStartDeptName(CollUtil.join(departNamesByUsername, ",")); |
| | | if (flowTaskDto.getTodoUsers() == null) { |
| | | flowTaskDto.setTodoUsers(""); |
| | | } else { |
| | | //去除[] |
| | | flowTaskDto.setTodoUsers(flowTaskDto.getTodoUsers().replaceAll("\\[", "").replaceAll("\\]", "")); |
| | | flowTaskDto.setTodoUsers(flowTaskDto.getTodoUsers().replaceAll("\"", "")); |
| | | } |
| | | } |
| | | }); |
| | | // list.forEach(flowTaskDto -> { |
| | | // // 流程发起人信息 |
| | | // HistoricProcessInstance historicProcessInstance = historyService.createHistoricProcessInstanceQuery() |
| | | // .processInstanceId(flowTaskDto.getProcInsId()) |
| | | // .singleResult(); |
| | | // if (historicProcessInstance != null) { |
| | | // SysUser startUser = iFlowThirdService.getUserByUsername(historicProcessInstance.getStartUserId()); |
| | | // if (startUser != null) { |
| | | // flowTaskDto.setStartUserId(startUser.getUsername()); |
| | | // flowTaskDto.setStartUserName(startUser.getRealname()); |
| | | // } |
| | | // List<String> departNamesByUsername = iFlowThirdService.getDepartNamesByUsername(historicProcessInstance.getStartUserId()); |
| | | // flowTaskDto.setStartDeptName(CollUtil.join(departNamesByUsername, ",")); |
| | | // if (flowTaskDto.getTodoUsers() == null) { |
| | | // flowTaskDto.setTodoUsers(""); |
| | | // } else { |
| | | // //去除[] |
| | | // flowTaskDto.setTodoUsers(flowTaskDto.getTodoUsers().replaceAll("\\[", "").replaceAll("\\]", "")); |
| | | // flowTaskDto.setTodoUsers(flowTaskDto.getTodoUsers().replaceAll("\"", "")); |
| | | // } |
| | | // } |
| | | // }); |
| | | IPage<FlowTaskDto> flowTaskDtoIPage = new Page<>(); |
| | | flowTaskDtoIPage.setRecords(list); |
| | | flowTaskDtoIPage.setTotal(page.getTotal()); |