Commit 494b80d1ebae4099d719f671a4cdfe91313f5f16
1 parent
26dd8b66
review: 优化审批时,校验选择的下一个节点的审批人,是否合法
Showing
3 changed files
with
19 additions
and
8 deletions
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/util/BpmnModelUtils.java
| ... | ... | @@ -907,9 +907,16 @@ public class BpmnModelUtils { |
| 907 | 907 | * @return 符合条件的路径 |
| 908 | 908 | */ |
| 909 | 909 | private static SequenceFlow findMatchSequenceFlowByExclusiveGateway(Gateway gateway, Map<String, Object> variables) { |
| 910 | - SequenceFlow matchSequenceFlow = CollUtil.findOne(gateway.getOutgoingFlows(), | |
| 911 | - flow -> ObjUtil.notEqual(gateway.getDefaultFlow(), flow.getId()) | |
| 912 | - && (evalConditionExpress(variables, flow.getConditionExpression()))); | |
| 910 | + // TODO 表单无可编辑字段时variables为空,流程走向会出现问题,比如流程审批过程中无需要修改的字段值, | |
| 911 | + SequenceFlow matchSequenceFlow; | |
| 912 | + if (CollUtil.isNotEmpty(variables)){ | |
| 913 | + matchSequenceFlow = CollUtil.findOne(gateway.getOutgoingFlows(), | |
| 914 | + flow -> ObjUtil.notEqual(gateway.getDefaultFlow(), flow.getId()) | |
| 915 | + && (evalConditionExpress(variables, flow.getConditionExpression()))); | |
| 916 | + }else { | |
| 917 | + matchSequenceFlow = CollUtil.findOne(gateway.getOutgoingFlows(), | |
| 918 | + flow -> ObjUtil.notEqual(gateway.getDefaultFlow(), flow.getId())); | |
| 919 | + } | |
| 913 | 920 | if (matchSequenceFlow == null) { |
| 914 | 921 | matchSequenceFlow = CollUtil.findOne(gateway.getOutgoingFlows(), |
| 915 | 922 | flow -> ObjUtil.equal(gateway.getDefaultFlow(), flow.getId())); | ... | ... |
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/util/FlowableUtils.java
| ... | ... | @@ -194,7 +194,7 @@ public class FlowableUtils { |
| 194 | 194 | @SuppressWarnings("unchecked") |
| 195 | 195 | public static Map<String, List<Long>> getStartUserSelectAssignees(Map<String, Object> processVariables) { |
| 196 | 196 | if (processVariables == null) { |
| 197 | - return new HashMap<>(); | |
| 197 | + return null; | |
| 198 | 198 | } |
| 199 | 199 | return (Map<String, List<Long>>) processVariables.get( |
| 200 | 200 | BpmnVariableConstants.PROCESS_INSTANCE_VARIABLE_START_USER_SELECT_ASSIGNEES); |
| ... | ... | @@ -214,12 +214,12 @@ public class FlowableUtils { |
| 214 | 214 | * 获得流程实例的审批用户选择的下一个节点的审批人 Map |
| 215 | 215 | * |
| 216 | 216 | * @param processVariables 流程变量 |
| 217 | - * @return 审批用户选择的下一个节点的审批人Map | |
| 217 | + * @return 审批用户选择的下一个节点的审批人Map Map | |
| 218 | 218 | */ |
| 219 | 219 | @SuppressWarnings("unchecked") |
| 220 | 220 | public static Map<String, List<Long>> getApproveUserSelectAssignees(Map<String, Object> processVariables) { |
| 221 | 221 | if (processVariables == null) { |
| 222 | - return new HashMap<>(); | |
| 222 | + return null; | |
| 223 | 223 | } |
| 224 | 224 | return (Map<String, List<Long>>) processVariables.get( |
| 225 | 225 | BpmnVariableConstants.PROCESS_INSTANCE_VARIABLE_APPROVE_USER_SELECT_ASSIGNEES); | ... | ... |
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmTaskServiceImpl.java
| ... | ... | @@ -600,7 +600,9 @@ public class BpmTaskServiceImpl implements BpmTaskService { |
| 600 | 600 | throw exception(PROCESS_INSTANCE_START_USER_SELECT_ASSIGNEES_NOT_CONFIG, nextFlowNode.getName()); |
| 601 | 601 | } |
| 602 | 602 | processVariables = FlowableUtils.getStartUserSelectAssignees(processInstance.getProcessVariables()); |
| 603 | - if (CollUtil.isNotEmpty(processVariables)) { | |
| 603 | + if (processVariables == null){ | |
| 604 | + processVariables = new HashMap<>(); | |
| 605 | + }else { | |
| 604 | 606 | List<Long> startUserSelectAssignee = processVariables.get(nextFlowNode.getId()); |
| 605 | 607 | // 特殊:如果当前节点已经存在审批人,则不允许覆盖 |
| 606 | 608 | if (CollUtil.isNotEmpty(startUserSelectAssignee)) { |
| ... | ... | @@ -619,7 +621,9 @@ public class BpmTaskServiceImpl implements BpmTaskService { |
| 619 | 621 | throw exception(PROCESS_INSTANCE_APPROVE_USER_SELECT_ASSIGNEES_NOT_CONFIG, nextFlowNode.getName()); |
| 620 | 622 | } |
| 621 | 623 | processVariables = FlowableUtils.getApproveUserSelectAssignees(processInstance.getProcessVariables()); |
| 622 | - if (CollUtil.isNotEmpty(processVariables)) { | |
| 624 | + if (processVariables == null){ | |
| 625 | + processVariables = new HashMap<>(); | |
| 626 | + }else { | |
| 623 | 627 | List<Long> approveUserSelectAssignee = processVariables.get(nextFlowNode.getId()); |
| 624 | 628 | // 特殊:如果当前节点已经存在审批人,则不允许覆盖 |
| 625 | 629 | if (CollUtil.isNotEmpty(approveUserSelectAssignee)) { | ... | ... |