Commit 23b011b6f9a27918c0529b464603cba37160ccd6
1 parent
c0140a41
【代码优化】工作流:移除多余的 attachNodeId 字段,因为不需要 UserTask 后面跟 ServiceTask 实现审批通过、不通过
Showing
2 changed files
with
8 additions
and
42 deletions
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/model/simple/BpmSimpleModelNodeVO.java
| @@ -3,7 +3,6 @@ package cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.model.simple; | @@ -3,7 +3,6 @@ package cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.model.simple; | ||
| 3 | import cn.iocoder.yudao.framework.common.validation.InEnum; | 3 | import cn.iocoder.yudao.framework.common.validation.InEnum; |
| 4 | import cn.iocoder.yudao.module.bpm.enums.definition.*; | 4 | import cn.iocoder.yudao.module.bpm.enums.definition.*; |
| 5 | import cn.iocoder.yudao.module.bpm.framework.flowable.core.enums.BpmTaskCandidateStrategyEnum; | 5 | import cn.iocoder.yudao.module.bpm.framework.flowable.core.enums.BpmTaskCandidateStrategyEnum; |
| 6 | -import com.fasterxml.jackson.annotation.JsonIgnore; | ||
| 7 | import com.fasterxml.jackson.annotation.JsonInclude; | 6 | import com.fasterxml.jackson.annotation.JsonInclude; |
| 8 | import io.swagger.v3.oas.annotations.media.Schema; | 7 | import io.swagger.v3.oas.annotations.media.Schema; |
| 9 | import jakarta.validation.Valid; | 8 | import jakarta.validation.Valid; |
| @@ -79,12 +78,6 @@ public class BpmSimpleModelNodeVO { | @@ -79,12 +78,6 @@ public class BpmSimpleModelNodeVO { | ||
| 79 | @Schema(description = "操作按钮设置", example = "[]") | 78 | @Schema(description = "操作按钮设置", example = "[]") |
| 80 | private List<OperationButtonSetting> buttonsSetting; // 用于审批节点 | 79 | private List<OperationButtonSetting> buttonsSetting; // 用于审批节点 |
| 81 | 80 | ||
| 82 | - // TODO @jason:看看是不是可以简化;@芋艿: 暂时先放着。不知道后面是否会用到 | ||
| 83 | - /** | ||
| 84 | - * 附加节点 Id, 该节点不从前端传入。 由程序生成. 由于当个节点无法完成功能。 需要附加节点来完成。 | ||
| 85 | - */ | ||
| 86 | - @JsonIgnore | ||
| 87 | - private String attachNodeId; | ||
| 88 | /** | 81 | /** |
| 89 | * 审批节点拒绝处理 | 82 | * 审批节点拒绝处理 |
| 90 | */ | 83 | */ |
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/util/SimpleModelUtils.java
| @@ -68,7 +68,7 @@ public class SimpleModelUtils { | @@ -68,7 +68,7 @@ public class SimpleModelUtils { | ||
| 68 | EndEvent endEvent = BpmnModelUtils.getEndEvent(bpmnModel); | 68 | EndEvent endEvent = BpmnModelUtils.getEndEvent(bpmnModel); |
| 69 | traverseNodeToBuildSequenceFlow(process, startNode, endEvent.getId()); | 69 | traverseNodeToBuildSequenceFlow(process, startNode, endEvent.getId()); |
| 70 | 70 | ||
| 71 | - // 3. 自动布局 | 71 | + // 4. 自动布局 |
| 72 | new BpmnAutoLayout(bpmnModel).execute(); | 72 | new BpmnAutoLayout(bpmnModel).execute(); |
| 73 | return bpmnModel; | 73 | return bpmnModel; |
| 74 | } | 74 | } |
| @@ -146,30 +146,16 @@ public class SimpleModelUtils { | @@ -146,30 +146,16 @@ public class SimpleModelUtils { | ||
| 146 | */ | 146 | */ |
| 147 | private static void traverseNormalNodeToBuildSequenceFlow(Process process, BpmSimpleModelNodeVO node, String targetNodeId) { | 147 | private static void traverseNormalNodeToBuildSequenceFlow(Process process, BpmSimpleModelNodeVO node, String targetNodeId) { |
| 148 | BpmSimpleModelNodeVO childNode = node.getChildNode(); | 148 | BpmSimpleModelNodeVO childNode = node.getChildNode(); |
| 149 | + boolean isChildNodeValid = isValidNode(childNode); | ||
| 149 | // 情况一:有“子”节点,则建立连线 | 150 | // 情况一:有“子”节点,则建立连线 |
| 150 | - if (isValidNode(childNode)) { | ||
| 151 | - // TODO @jason:attachNodeId 是不是可以删除啦 | ||
| 152 | - if (StrUtil.isNotEmpty(node.getAttachNodeId())) { | ||
| 153 | - // 2.1.1.2 如果有附加节点. 需要先建立和附加节点的连线。再建立附加节点和目标节点的连线 | ||
| 154 | - List<SequenceFlow> sequenceFlows = buildAttachNodeSequenceFlow(node.getId(), node.getAttachNodeId(), childNode.getId()); | ||
| 155 | - sequenceFlows.forEach(process::addFlowElement); | ||
| 156 | - } else { | ||
| 157 | - SequenceFlow sequenceFlow = buildBpmnSequenceFlow(node.getId(), childNode.getId()); | ||
| 158 | - process.addFlowElement(sequenceFlow); | ||
| 159 | - } | 151 | + // 情况二:没有“子节点”,则直接跟 targetNodeId 建立连线。例如说,结束节点、条件分支(分支节点的孩子节点或聚合节点)的最后一个节点 |
| 152 | + String finalTargetNodeId = isChildNodeValid? childNode.getId() : targetNodeId; | ||
| 153 | + SequenceFlow sequenceFlow = buildBpmnSequenceFlow(node.getId(), finalTargetNodeId); | ||
| 154 | + process.addFlowElement(sequenceFlow); | ||
| 160 | 155 | ||
| 161 | - // 因为有子节点,递归调用后续子节点 | 156 | + // 因为有子节点,递归调用后续子节点 |
| 157 | + if (isChildNodeValid) { | ||
| 162 | traverseNodeToBuildSequenceFlow(process, childNode, targetNodeId); | 158 | traverseNodeToBuildSequenceFlow(process, childNode, targetNodeId); |
| 163 | - } else { | ||
| 164 | - // 情况二:没有“子节点”,则直接跟 targetNodeId 建立连线。例如说,结束节点、条件分支(分支节点的孩子节点或聚合节点)的最后一个节点 | ||
| 165 | - // TODO @jason:attachNodeId 是不是可以删除啦 | ||
| 166 | - if (StrUtil.isNotEmpty(node.getAttachNodeId())) { | ||
| 167 | - List<SequenceFlow> sequenceFlows = buildAttachNodeSequenceFlow(node.getId(), node.getAttachNodeId(), targetNodeId); | ||
| 168 | - sequenceFlows.forEach(process::addFlowElement); | ||
| 169 | - } else { | ||
| 170 | - SequenceFlow sequenceFlow = buildBpmnSequenceFlow(node.getId(), targetNodeId); | ||
| 171 | - process.addFlowElement(sequenceFlow); | ||
| 172 | - } | ||
| 173 | } | 159 | } |
| 174 | } | 160 | } |
| 175 | 161 | ||
| @@ -230,19 +216,6 @@ public class SimpleModelUtils { | @@ -230,19 +216,6 @@ public class SimpleModelUtils { | ||
| 230 | traverseNodeToBuildSequenceFlow(process, childNode, targetNodeId); | 216 | traverseNodeToBuildSequenceFlow(process, childNode, targetNodeId); |
| 231 | } | 217 | } |
| 232 | 218 | ||
| 233 | - /** | ||
| 234 | - * 构建有附加节点的连线 | ||
| 235 | - * | ||
| 236 | - * @param nodeId 当前节点 Id | ||
| 237 | - * @param attachNodeId 附属节点 Id | ||
| 238 | - * @param targetNodeId 目标节点 Id | ||
| 239 | - */ | ||
| 240 | - private static List<SequenceFlow> buildAttachNodeSequenceFlow(String nodeId, String attachNodeId, String targetNodeId) { | ||
| 241 | - SequenceFlow sequenceFlow = buildBpmnSequenceFlow(nodeId, attachNodeId, null, null, null); | ||
| 242 | - SequenceFlow attachSequenceFlow = buildBpmnSequenceFlow(attachNodeId, targetNodeId, null, null, null); | ||
| 243 | - return CollUtil.newArrayList(sequenceFlow, attachSequenceFlow); | ||
| 244 | - } | ||
| 245 | - | ||
| 246 | private static SequenceFlow buildBpmnSequenceFlow(String sourceId, String targetId) { | 219 | private static SequenceFlow buildBpmnSequenceFlow(String sourceId, String targetId) { |
| 247 | return buildBpmnSequenceFlow(sourceId, targetId, null, null, null); | 220 | return buildBpmnSequenceFlow(sourceId, targetId, null, null, null); |
| 248 | } | 221 | } |