feat:审批通过时,查询下一个执行的任务节点
This commit is contained in:
parent
1b08e6828f
commit
33ab961629
|
@ -15,6 +15,7 @@ import cn.iocoder.yudao.framework.common.util.number.NumberUtils;
|
||||||
import cn.iocoder.yudao.framework.common.util.object.ObjectUtils;
|
import cn.iocoder.yudao.framework.common.util.object.ObjectUtils;
|
||||||
import cn.iocoder.yudao.framework.common.util.object.PageUtils;
|
import cn.iocoder.yudao.framework.common.util.object.PageUtils;
|
||||||
import cn.iocoder.yudao.module.bpm.api.task.dto.BpmProcessInstanceCreateReqDTO;
|
import cn.iocoder.yudao.module.bpm.api.task.dto.BpmProcessInstanceCreateReqDTO;
|
||||||
|
import cn.iocoder.yudao.module.bpm.controller.admin.base.user.UserSimpleBaseVO;
|
||||||
import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.model.BpmModelMetaInfoVO;
|
import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.model.BpmModelMetaInfoVO;
|
||||||
import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.model.simple.BpmSimpleModelNodeVO;
|
import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.model.simple.BpmSimpleModelNodeVO;
|
||||||
import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.instance.*;
|
import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.instance.*;
|
||||||
|
@ -249,24 +250,43 @@ public class BpmProcessInstanceServiceImpl implements BpmProcessInstanceService
|
||||||
if (bpmnModel == null) {
|
if (bpmnModel == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
// 5. 获取当前任务节点的信息
|
HistoricProcessInstance historicProcessInstance = getHistoricProcessInstance(task.getProcessInstanceId());
|
||||||
|
if (historicProcessInstance == null) {
|
||||||
|
throw exception(ErrorCodeConstants.PROCESS_INSTANCE_NOT_EXISTS);
|
||||||
|
}
|
||||||
|
Map<String, Object> processVariables = new HashMap<>();
|
||||||
|
// 获取历史中流程变量
|
||||||
|
Map<String, Object> historicVariables = historicProcessInstance.getProcessVariables();
|
||||||
|
if (CollUtil.isNotEmpty(historicVariables)) {
|
||||||
|
processVariables.putAll(historicVariables);
|
||||||
|
}
|
||||||
|
// 合并前端传递的流程变量,以前端为准
|
||||||
|
if (CollUtil.isNotEmpty(reqVO.getProcessVariables())){
|
||||||
|
processVariables.putAll(reqVO.getProcessVariables());
|
||||||
|
}
|
||||||
|
// 获取流程定义信息
|
||||||
|
BpmProcessDefinitionInfoDO processDefinitionInfo = processDefinitionService
|
||||||
|
.getProcessDefinitionInfo(task.getProcessDefinitionId());
|
||||||
|
// 获取当前任务节点的信息
|
||||||
FlowElement flowElement = bpmnModel.getFlowElement(task.getTaskDefinitionKey());
|
FlowElement flowElement = bpmnModel.getFlowElement(task.getTaskDefinitionKey());
|
||||||
List<FlowNode> nextFlowNodes = BpmnModelUtils.getNextFlowNodes(flowElement, bpmnModel, reqVO.getProcessVariables());
|
// 获取下一个将要执行的节点集合
|
||||||
return convertList(nextFlowNodes, nodes -> {
|
List<FlowNode> nextFlowNodes = BpmnModelUtils.getNextFlowNodes(flowElement, bpmnModel, processVariables);
|
||||||
FlowElement flowNode = BpmnModelUtils.getFlowElementById(bpmnModel, nodes.getId());
|
return convertList(nextFlowNodes, node -> {
|
||||||
ActivityNode activityNode = new ActivityNode().setId(nodes.getId()).setName(nodes.getName())
|
List<Long> candidateUserIds = getTaskCandidateUserList(bpmnModel, node.getId(),
|
||||||
.setNodeType(START_USER_NODE_ID.equals(nodes.getId())
|
loginUserId, processDefinitionInfo.getProcessDefinitionId(), processVariables);
|
||||||
? BpmSimpleModelNodeTypeEnum.START_USER_NODE.getType()
|
//存在一个节点多人审批的情况
|
||||||
: ObjUtil.defaultIfNull(parseNodeType(flowNode), // 目的:解决“办理节点”的识别
|
List<UserSimpleBaseVO> candidateUsers = new ArrayList<>();
|
||||||
BpmSimpleModelNodeTypeEnum.APPROVE_NODE.getType()))
|
for (Long candidateUserId : candidateUserIds) {
|
||||||
.setStatus(FlowableUtils.getTaskStatus(task))
|
Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap(candidateUserIds);
|
||||||
.setCandidateStrategy(BpmnModelUtils.parseCandidateStrategy(flowNode));
|
Map<Long, DeptRespDTO> deptMap = deptApi.getDeptMap(convertSet(userMap.values(), AdminUserRespDTO::getDeptId));
|
||||||
|
candidateUsers.add(BpmProcessInstanceConvert.INSTANCE.buildUser(candidateUserId, userMap, deptMap));
|
||||||
// 如果是取消状态,则跳过
|
|
||||||
if (BpmTaskStatusEnum.isCancelStatus(activityNode.getStatus())) {
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
return activityNode;
|
return new ActivityNode().setNodeType(BpmSimpleModelNodeTypeEnum.APPROVE_NODE.getType())
|
||||||
|
.setId(node.getId())
|
||||||
|
.setName(node.getName())
|
||||||
|
.setStatus(BpmTaskStatusEnum.RUNNING.getStatus())
|
||||||
|
.setCandidateStrategy(BpmnModelUtils.parseCandidateStrategy(node))
|
||||||
|
.setCandidateUsers(candidateUsers);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -725,8 +745,12 @@ public class BpmProcessInstanceServiceImpl implements BpmProcessInstanceService
|
||||||
// true,不影响没配置
|
// true,不影响没配置
|
||||||
// skipExpression 的节点
|
// skipExpression 的节点
|
||||||
if (CollUtil.isNotEmpty(startUserSelectAssignees)) {
|
if (CollUtil.isNotEmpty(startUserSelectAssignees)) {
|
||||||
|
// 设置流程变量,发起人自选审批人
|
||||||
variables.put(BpmnVariableConstants.PROCESS_INSTANCE_VARIABLE_START_USER_SELECT_ASSIGNEES,
|
variables.put(BpmnVariableConstants.PROCESS_INSTANCE_VARIABLE_START_USER_SELECT_ASSIGNEES,
|
||||||
startUserSelectAssignees);
|
startUserSelectAssignees);
|
||||||
|
// 设置流程变量,审批人自选审批人
|
||||||
|
variables.put(BpmnVariableConstants.PROCESS_INSTANCE_VARIABLE_APPROVE_USER_SELECT_ASSIGNEES,
|
||||||
|
startUserSelectAssignees);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 3. 创建流程
|
// 3. 创建流程
|
||||||
|
@ -768,9 +792,10 @@ public class BpmProcessInstanceServiceImpl implements BpmProcessInstanceService
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 2.1 移除掉不是发起人自选审批人节点
|
// 2.1 移除掉不是发起人或者审批人自选审批人节点
|
||||||
activityNodes.removeIf(task ->
|
activityNodes.removeIf(task ->
|
||||||
ObjectUtil.notEqual(BpmTaskCandidateStrategyEnum.START_USER_SELECT.getStrategy(), task.getCandidateStrategy()));
|
ObjectUtil.notEqual(BpmTaskCandidateStrategyEnum.START_USER_SELECT.getStrategy(), task.getCandidateStrategy())
|
||||||
|
&& ObjectUtil.notEqual(BpmTaskCandidateStrategyEnum.APPROVE_USER_SELECT.getStrategy(), task.getCandidateStrategy()));
|
||||||
// 2.2 流程发起时要先获取当前流程的预测走向节点,发起时只校验预测的节点发起人自选审批人的审批人和抄送人是否都配置了
|
// 2.2 流程发起时要先获取当前流程的预测走向节点,发起时只校验预测的节点发起人自选审批人的审批人和抄送人是否都配置了
|
||||||
activityNodes.forEach(task -> {
|
activityNodes.forEach(task -> {
|
||||||
List<Long> assignees = startUserSelectAssignees != null ? startUserSelectAssignees.get(task.getId()) : null;
|
List<Long> assignees = startUserSelectAssignees != null ? startUserSelectAssignees.get(task.getId()) : null;
|
||||||
|
|
Loading…
Reference in New Issue