review: 代码审查

This commit is contained in:
lizhixian 2025-02-19 15:00:28 +08:00
parent 4b89f68936
commit 29a902f37e
3 changed files with 38 additions and 17 deletions

View File

@ -778,9 +778,16 @@ public class BpmnModelUtils {
if (currentElement instanceof ExclusiveGateway) {
// 查找满足条件的 SequenceFlow 路径
Gateway gateway = (Gateway) currentElement;
SequenceFlow matchSequenceFlow = CollUtil.findOne(gateway.getOutgoingFlows(),
flow -> ObjUtil.notEqual(gateway.getDefaultFlow(), flow.getId())
&& (evalConditionExpress(variables, flow.getConditionExpression())));
SequenceFlow matchSequenceFlow;
// 流程首次发起时variables值一定为空会导致条件表达式解析错误导致预测节点缺失
if (null == variables) {
matchSequenceFlow = CollUtil.findOne(gateway.getOutgoingFlows(),
flow -> ObjUtil.notEqual(gateway.getDefaultFlow(), flow.getId()));
} else {
matchSequenceFlow = CollUtil.findOne(gateway.getOutgoingFlows(),
flow -> ObjUtil.notEqual(gateway.getDefaultFlow(), flow.getId())
&& (evalConditionExpress(variables, flow.getConditionExpression())));
}
if (matchSequenceFlow == null) {
matchSequenceFlow = CollUtil.findOne(gateway.getOutgoingFlows(),
flow -> ObjUtil.equal(gateway.getDefaultFlow(), flow.getId()));
@ -800,9 +807,15 @@ public class BpmnModelUtils {
if (currentElement instanceof InclusiveGateway) {
// 查找满足条件的 SequenceFlow 路径
Gateway gateway = (Gateway) currentElement;
Collection<SequenceFlow> matchSequenceFlows = CollUtil.filterNew(gateway.getOutgoingFlows(),
flow -> ObjUtil.notEqual(gateway.getDefaultFlow(), flow.getId())
&& evalConditionExpress(variables, flow.getConditionExpression()));
Collection<SequenceFlow> matchSequenceFlows;
if (null == variables){
matchSequenceFlows = CollUtil.filterNew(gateway.getOutgoingFlows(),
flow -> ObjUtil.notEqual(gateway.getDefaultFlow(), flow.getId()));
}else {
matchSequenceFlows = CollUtil.filterNew(gateway.getOutgoingFlows(),
flow -> ObjUtil.notEqual(gateway.getDefaultFlow(), flow.getId())
&& evalConditionExpress(variables, flow.getConditionExpression()));
}
if (CollUtil.isEmpty(matchSequenceFlows)) {
matchSequenceFlows = CollUtil.filterNew(gateway.getOutgoingFlows(),
flow -> ObjUtil.equal(gateway.getDefaultFlow(), flow.getId()));

View File

@ -808,9 +808,15 @@ public class SimpleModelUtils {
// 情况CONDITION_BRANCH_NODE 排它只有一个满足条件的如果没有就走默认的
if (nodeType == BpmSimpleModelNodeTypeEnum.CONDITION_BRANCH_NODE) {
// 查找满足条件的 BpmSimpleModelNodeVO 节点
BpmSimpleModelNodeVO matchConditionNode = CollUtil.findOne(currentNode.getConditionNodes(),
conditionNode -> !BooleanUtil.isTrue(conditionNode.getConditionSetting().getDefaultFlow())
&& evalConditionExpress(variables, conditionNode.getConditionSetting()));
BpmSimpleModelNodeVO matchConditionNode;
if(null == variables) {
matchConditionNode = CollUtil.findOne(currentNode.getConditionNodes(),
conditionNode -> !BooleanUtil.isTrue(conditionNode.getConditionSetting().getDefaultFlow()));
}else {
matchConditionNode = CollUtil.findOne(currentNode.getConditionNodes(),
conditionNode -> !BooleanUtil.isTrue(conditionNode.getConditionSetting().getDefaultFlow())
&& evalConditionExpress(variables, conditionNode.getConditionSetting()));
}
if (matchConditionNode == null) {
matchConditionNode = CollUtil.findOne(currentNode.getConditionNodes(),
conditionNode -> BooleanUtil.isTrue(conditionNode.getConditionSetting().getDefaultFlow()));
@ -823,9 +829,15 @@ public class SimpleModelUtils {
// 情况INCLUSIVE_BRANCH_NODE 包容多个满足条件的如果没有就走默认的
if (nodeType == BpmSimpleModelNodeTypeEnum.INCLUSIVE_BRANCH_NODE) {
// 查找满足条件的 BpmSimpleModelNodeVO 节点
Collection<BpmSimpleModelNodeVO> matchConditionNodes = CollUtil.filterNew(currentNode.getConditionNodes(),
conditionNode -> !BooleanUtil.isTrue(conditionNode.getConditionSetting().getDefaultFlow())
&& evalConditionExpress(variables, conditionNode.getConditionSetting()));
Collection<BpmSimpleModelNodeVO> matchConditionNodes;
if (null == variables) {
matchConditionNodes = CollUtil.filterNew(currentNode.getConditionNodes(),
conditionNode -> !BooleanUtil.isTrue(conditionNode.getConditionSetting().getDefaultFlow()));
}else {
matchConditionNodes = CollUtil.filterNew(currentNode.getConditionNodes(),
conditionNode -> !BooleanUtil.isTrue(conditionNode.getConditionSetting().getDefaultFlow())
&& evalConditionExpress(variables, conditionNode.getConditionSetting()));
}
if (CollUtil.isEmpty(matchConditionNodes)) {
matchConditionNodes = CollUtil.filterNew(currentNode.getConditionNodes(),
conditionNode -> BooleanUtil.isTrue(conditionNode.getConditionSetting().getDefaultFlow()));

View File

@ -208,11 +208,7 @@ public class BpmProcessInstanceServiceImpl implements BpmProcessInstanceService
// TODO @jason有一个极端情况如果一个用户有 2 task A BA 已经通过B 需要审核这个时通过 A 进来todo 拿到
// B会不会表单权限不一致哈
BpmTaskRespVO todoTask = taskService.getFirstTodoTask(loginUserId, reqVO.getProcessInstanceId());
// 3.2 流程首次发起时variables值一定为空会导致条件表达式解析错误导致预测节点缺失
if (null == processVariables) {
processVariables = new HashMap<>();
}
// 3.3 预测未运行节点的审批信息
// 3.2 预测未运行节点的审批信息
List<ActivityNode> simulateActivityNodes = getSimulateApproveNodeList(startUserId, bpmnModel,
processDefinitionInfo,
processVariables, activities);