| | |
| | | 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) { |