【代码评审】BPM:优化流程发起预测节点审批人是否配置在后端逻辑中实现
This commit is contained in:
parent
b496ec3fd0
commit
24f1ce16c7
|
@ -6,7 +6,6 @@ import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
import cn.iocoder.yudao.framework.common.util.json.JsonUtils;
|
import cn.iocoder.yudao.framework.common.util.json.JsonUtils;
|
||||||
import cn.iocoder.yudao.framework.common.util.number.NumberUtils;
|
import cn.iocoder.yudao.framework.common.util.number.NumberUtils;
|
||||||
import cn.iocoder.yudao.framework.common.util.string.StrUtils;
|
|
||||||
import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.instance.*;
|
import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.instance.*;
|
||||||
import cn.iocoder.yudao.module.bpm.convert.task.BpmProcessInstanceConvert;
|
import cn.iocoder.yudao.module.bpm.convert.task.BpmProcessInstanceConvert;
|
||||||
import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmCategoryDO;
|
import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmCategoryDO;
|
||||||
|
@ -165,9 +164,10 @@ public class BpmProcessInstanceController {
|
||||||
@Operation(summary = "获得审批详情")
|
@Operation(summary = "获得审批详情")
|
||||||
@Parameter(name = "id", description = "流程实例的编号", required = true)
|
@Parameter(name = "id", description = "流程实例的编号", required = true)
|
||||||
@PreAuthorize("@ss.hasPermission('bpm:process-instance:query')")
|
@PreAuthorize("@ss.hasPermission('bpm:process-instance:query')")
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
public CommonResult<BpmApprovalDetailRespVO> getApprovalDetail(@Valid BpmApprovalDetailReqVO reqVO) {
|
public CommonResult<BpmApprovalDetailRespVO> getApprovalDetail(@Valid BpmApprovalDetailReqVO reqVO) {
|
||||||
if (StrUtil.isNotEmpty(reqVO.getProcessVariablesStr())){
|
if (StrUtil.isNotEmpty(reqVO.getProcessVariablesStr())) {
|
||||||
reqVO.setProcessVariables(JsonUtils.parseObject(reqVO.getProcessVariablesStr(),Map.class));
|
reqVO.setProcessVariables(JsonUtils.parseObject(reqVO.getProcessVariablesStr(), Map.class));
|
||||||
}
|
}
|
||||||
return success(processInstanceService.getApprovalDetail(getLoginUserId(), reqVO));
|
return success(processInstanceService.getApprovalDetail(getLoginUserId(), reqVO));
|
||||||
}
|
}
|
||||||
|
|
|
@ -799,8 +799,8 @@ public class BpmnModelUtils {
|
||||||
// 查找满足条件的 SequenceFlow 路径
|
// 查找满足条件的 SequenceFlow 路径
|
||||||
Gateway gateway = (Gateway) currentElement;
|
Gateway gateway = (Gateway) currentElement;
|
||||||
SequenceFlow matchSequenceFlow = CollUtil.findOne(gateway.getOutgoingFlows(),
|
SequenceFlow matchSequenceFlow = CollUtil.findOne(gateway.getOutgoingFlows(),
|
||||||
flow -> ObjUtil.notEqual(gateway.getDefaultFlow(), flow.getId())
|
flow -> ObjUtil.notEqual(gateway.getDefaultFlow(), flow.getId())
|
||||||
&& (evalConditionExpress(variables, flow.getConditionExpression())));
|
&& (evalConditionExpress(variables, flow.getConditionExpression())));
|
||||||
if (matchSequenceFlow == null) {
|
if (matchSequenceFlow == null) {
|
||||||
matchSequenceFlow = CollUtil.findOne(gateway.getOutgoingFlows(),
|
matchSequenceFlow = CollUtil.findOne(gateway.getOutgoingFlows(),
|
||||||
flow -> ObjUtil.equal(gateway.getDefaultFlow(), flow.getId()));
|
flow -> ObjUtil.equal(gateway.getDefaultFlow(), flow.getId()));
|
||||||
|
@ -857,9 +857,12 @@ public class BpmnModelUtils {
|
||||||
if (express == null) {
|
if (express == null) {
|
||||||
return Boolean.FALSE;
|
return Boolean.FALSE;
|
||||||
}
|
}
|
||||||
|
// 如果 variables 为空,则创建一个的原因?可能 expression 的计算,不依赖于 variables
|
||||||
if (variables == null) {
|
if (variables == null) {
|
||||||
return Boolean.FALSE;
|
variables = new HashMap<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 执行计算
|
||||||
try {
|
try {
|
||||||
Object result = FlowableUtils.getExpressionValue(variables, express);
|
Object result = FlowableUtils.getExpressionValue(variables, express);
|
||||||
return Boolean.TRUE.equals(result);
|
return Boolean.TRUE.equals(result);
|
||||||
|
|
|
@ -696,8 +696,9 @@ public class BpmProcessInstanceServiceImpl implements BpmProcessInstanceService
|
||||||
}
|
}
|
||||||
|
|
||||||
private void validateStartUserSelectAssignees(Long userId, ProcessDefinition definition,
|
private void validateStartUserSelectAssignees(Long userId, ProcessDefinition definition,
|
||||||
Map<String, List<Long>> startUserSelectAssignees, Map<String,Object> variables) {
|
Map<String, List<Long>> startUserSelectAssignees,
|
||||||
// 1.获取预测的节点信息
|
Map<String,Object> variables) {
|
||||||
|
// 1. 获取预测的节点信息
|
||||||
BpmApprovalDetailRespVO detailRespVO = getApprovalDetail(userId, new BpmApprovalDetailReqVO()
|
BpmApprovalDetailRespVO detailRespVO = getApprovalDetail(userId, new BpmApprovalDetailReqVO()
|
||||||
.setProcessDefinitionId(definition.getId())
|
.setProcessDefinitionId(definition.getId())
|
||||||
.setProcessVariables(variables));
|
.setProcessVariables(variables));
|
||||||
|
@ -705,9 +706,11 @@ public class BpmProcessInstanceServiceImpl implements BpmProcessInstanceService
|
||||||
if (CollUtil.isEmpty(activityNodes)){
|
if (CollUtil.isEmpty(activityNodes)){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// 2.移除掉不是发起人自选审批人节点
|
|
||||||
activityNodes.removeIf(task -> !Objects.equals(BpmTaskCandidateStrategyEnum.START_USER_SELECT.getStrategy(), task.getCandidateStrategy()));
|
// 2.1 移除掉不是发起人自选审批人节点
|
||||||
// 3.流程发起时要先获取当前流程的预测走向节点,发起时只校验预测的节点发起人自选审批人的审批人和抄送人是否都配置了
|
activityNodes.removeIf(task ->
|
||||||
|
ObjectUtil.notEqual(BpmTaskCandidateStrategyEnum.START_USER_SELECT.getStrategy(), task.getCandidateStrategy()));
|
||||||
|
// 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;
|
||||||
if (CollUtil.isEmpty(assignees)) {
|
if (CollUtil.isEmpty(assignees)) {
|
||||||
|
|
Loading…
Reference in New Issue