review: 278 281行
This commit is contained in:
parent
4e57bd157f
commit
9e151b3966
|
@ -232,57 +232,62 @@ public class BpmProcessInstanceServiceImpl implements BpmProcessInstanceService
|
|||
|
||||
@Override
|
||||
public List<ActivityNode> getNextFlowNodes(Long loginUserId, BpmApprovalDetailReqVO reqVO) {
|
||||
// 1 校验任务存在
|
||||
// 1.1 校验任务存在
|
||||
Task task = taskService.getTask(reqVO.getTaskId());
|
||||
if (task == null) {
|
||||
throw exception(TASK_NOT_EXISTS);
|
||||
}
|
||||
// 2 校验任务是否由当前用户审批
|
||||
// 1.2 校验任务是否由当前用户审批
|
||||
if (StrUtil.isNotBlank(task.getAssignee())
|
||||
&& ObjectUtil.notEqual(loginUserId, NumberUtils.parseLong(task.getAssignee()))) {
|
||||
throw exception(TASK_OPERATE_FAIL_ASSIGN_NOT_SELF);
|
||||
}
|
||||
// 3 校验流程实例存在
|
||||
// 1.3 校验流程实例存在
|
||||
ProcessInstance instance = getProcessInstance(task.getProcessInstanceId());
|
||||
if (instance == null) {
|
||||
throw exception(PROCESS_INSTANCE_NOT_EXISTS);
|
||||
}
|
||||
// 4 获取 BpmnModel
|
||||
// 1.4 校验BpmnModel
|
||||
BpmnModel bpmnModel = processDefinitionService.getProcessDefinitionBpmnModel(task.getProcessDefinitionId());
|
||||
if (bpmnModel == null) {
|
||||
return null;
|
||||
}
|
||||
//1.5 流程实例是否存在
|
||||
HistoricProcessInstance historicProcessInstance = getHistoricProcessInstance(task.getProcessInstanceId());
|
||||
if (historicProcessInstance == null) {
|
||||
throw exception(ErrorCodeConstants.PROCESS_INSTANCE_NOT_EXISTS);
|
||||
}
|
||||
|
||||
// 2 设置流程变量
|
||||
Map<String, Object> processVariables = new HashMap<>();
|
||||
// 获取历史中流程变量
|
||||
// 2.1 获取历史中流程变量
|
||||
Map<String, Object> historicVariables = historicProcessInstance.getProcessVariables();
|
||||
if (CollUtil.isNotEmpty(historicVariables)) {
|
||||
processVariables.putAll(historicVariables);
|
||||
}
|
||||
// 合并前端传递的流程变量,以前端为准
|
||||
if (CollUtil.isNotEmpty(reqVO.getProcessVariables())){
|
||||
// 2.2 合并前端传递的流程变量,以前端为准
|
||||
if (CollUtil.isNotEmpty(reqVO.getProcessVariables())) {
|
||||
processVariables.putAll(reqVO.getProcessVariables());
|
||||
}
|
||||
// 获取流程定义信息
|
||||
BpmProcessDefinitionInfoDO processDefinitionInfo = processDefinitionService
|
||||
.getProcessDefinitionInfo(task.getProcessDefinitionId());
|
||||
// 获取当前任务节点的信息
|
||||
// 3 获取当前任务节点的信息
|
||||
FlowElement flowElement = bpmnModel.getFlowElement(task.getTaskDefinitionKey());
|
||||
// 获取下一个将要执行的节点集合
|
||||
// 3.1 获取下一个将要执行的节点集合
|
||||
List<FlowNode> nextFlowNodes = BpmnModelUtils.getNextFlowNodes(flowElement, bpmnModel, processVariables);
|
||||
return convertList(nextFlowNodes, node -> {
|
||||
List<Long> candidateUserIds = getTaskCandidateUserList(bpmnModel, node.getId(),
|
||||
loginUserId, processDefinitionInfo.getProcessDefinitionId(), processVariables);
|
||||
//存在一个节点多人审批的情况
|
||||
List<UserSimpleBaseVO> candidateUsers = new ArrayList<>();
|
||||
for (Long candidateUserId : candidateUserIds) {
|
||||
loginUserId, historicProcessInstance.getProcessDefinitionId(), processVariables);
|
||||
// 3.2 获取节点的审批人信息
|
||||
Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap(candidateUserIds);
|
||||
Map<Long, DeptRespDTO> deptMap = deptApi.getDeptMap(convertSet(userMap.values(), AdminUserRespDTO::getDeptId));
|
||||
candidateUsers.add(BpmProcessInstanceConvert.INSTANCE.buildUser(candidateUserId, userMap, deptMap));
|
||||
if (CollUtil.isEmpty(userMap)) {
|
||||
return null;
|
||||
}
|
||||
// 3.3 获取节点的审批人部门信息
|
||||
Map<Long, DeptRespDTO> deptMap = deptApi.getDeptMap(convertSet(userMap.values(), AdminUserRespDTO::getDeptId));
|
||||
// 3.4 存在一个节点多人审批的情况,组装审批人信息
|
||||
List<UserSimpleBaseVO> candidateUsers = new ArrayList<>();
|
||||
userMap.forEach((key, value) -> {
|
||||
candidateUsers.add(BpmProcessInstanceConvert.INSTANCE.buildUser(key, userMap, deptMap));
|
||||
});
|
||||
return new ActivityNode().setNodeType(BpmSimpleModelNodeTypeEnum.APPROVE_NODE.getType())
|
||||
.setId(node.getId())
|
||||
.setName(node.getName())
|
||||
|
@ -784,13 +789,13 @@ public class BpmProcessInstanceServiceImpl implements BpmProcessInstanceService
|
|||
|
||||
private void validateStartUserSelectAssignees(Long userId, ProcessDefinition definition,
|
||||
Map<String, List<Long>> startUserSelectAssignees,
|
||||
Map<String,Object> variables) {
|
||||
Map<String, Object> variables) {
|
||||
// 1. 获取预测的节点信息
|
||||
BpmApprovalDetailRespVO detailRespVO = getApprovalDetail(userId, new BpmApprovalDetailReqVO()
|
||||
.setProcessDefinitionId(definition.getId())
|
||||
.setProcessVariables(variables));
|
||||
List<ActivityNode> activityNodes = detailRespVO.getActivityNodes();
|
||||
if (CollUtil.isEmpty(activityNodes)){
|
||||
if (CollUtil.isEmpty(activityNodes)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue