Commit ae3c63eb29977d069dd986a16842411b977eb0a9
1 parent
34c8f4ca
【代码评审】BPM:Simple 设计器 - 路由分支
Showing
2 changed files
with
18 additions
and
11 deletions
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/model/simple/BpmSimpleModelNodeVO.java
| @@ -39,6 +39,7 @@ public class BpmSimpleModelNodeVO { | @@ -39,6 +39,7 @@ public class BpmSimpleModelNodeVO { | ||
| 39 | @Schema(description = "条件节点") | 39 | @Schema(description = "条件节点") |
| 40 | private List<BpmSimpleModelNodeVO> conditionNodes; // 补充说明:有且仅有条件、并行、包容等分支会使用 | 40 | private List<BpmSimpleModelNodeVO> conditionNodes; // 补充说明:有且仅有条件、并行、包容等分支会使用 |
| 41 | 41 | ||
| 42 | + // TODO @jason:conditionType、conditionExpression、defaultFlow、conditionGroups 搞成一个 condition 属性,会好点么? | ||
| 42 | @Schema(description = "条件类型", example = "1") | 43 | @Schema(description = "条件类型", example = "1") |
| 43 | @InEnum(BpmSimpleModeConditionType.class) | 44 | @InEnum(BpmSimpleModeConditionType.class) |
| 44 | private Integer conditionType; // 仅用于条件节点 BpmSimpleModelNodeType.CONDITION_NODE | 45 | private Integer conditionType; // 仅用于条件节点 BpmSimpleModelNodeType.CONDITION_NODE |
| @@ -251,6 +252,7 @@ public class BpmSimpleModelNodeVO { | @@ -251,6 +252,7 @@ public class BpmSimpleModelNodeVO { | ||
| 251 | @Schema(description = "运算符右边的值", example = "1") | 252 | @Schema(description = "运算符右边的值", example = "1") |
| 252 | @NotEmpty(message = "运算符右边的值不能为空") | 253 | @NotEmpty(message = "运算符右边的值不能为空") |
| 253 | private String rightSide; | 254 | private String rightSide; |
| 255 | + | ||
| 254 | } | 256 | } |
| 255 | 257 | ||
| 256 | @Schema(description = "延迟器设置", example = "{}") | 258 | @Schema(description = "延迟器设置", example = "{}") |
| @@ -269,8 +271,10 @@ public class BpmSimpleModelNodeVO { | @@ -269,8 +271,10 @@ public class BpmSimpleModelNodeVO { | ||
| 269 | @Schema(description = "延迟时间表达式", example = "PT1H,2025-01-01T00:00:00") | 271 | @Schema(description = "延迟时间表达式", example = "PT1H,2025-01-01T00:00:00") |
| 270 | @NotEmpty(message = "延迟时间表达式不能为空") | 272 | @NotEmpty(message = "延迟时间表达式不能为空") |
| 271 | private String delayTime; | 273 | private String delayTime; |
| 274 | + | ||
| 272 | } | 275 | } |
| 273 | 276 | ||
| 277 | + // TODO @lesan:routeGroups | ||
| 274 | @Schema(description = "路由分支组", example = "[]") | 278 | @Schema(description = "路由分支组", example = "[]") |
| 275 | private List<RouteCondition> routeGroup; | 279 | private List<RouteCondition> routeGroup; |
| 276 | 280 | ||
| @@ -282,10 +286,11 @@ public class BpmSimpleModelNodeVO { | @@ -282,10 +286,11 @@ public class BpmSimpleModelNodeVO { | ||
| 282 | @Valid | 286 | @Valid |
| 283 | public static class RouteCondition { | 287 | public static class RouteCondition { |
| 284 | 288 | ||
| 285 | - @Schema(description = "节点Id", example = "Activity_xxx") | ||
| 286 | - @NotEmpty(message = "节点Id不能为空") | 289 | + @Schema(description = "节点 Id", example = "Activity_xxx") |
| 290 | + @NotEmpty(message = "节点 Id 不能为空") | ||
| 287 | private String nodeId; | 291 | private String nodeId; |
| 288 | 292 | ||
| 293 | + // TODO @lesan:type、expression、groups;(可以晚点改,在和 conditionType、conditionExpression、defaultFlow、conditionGroups 讨论!) | ||
| 289 | @Schema(description = "条件类型", example = "1") | 294 | @Schema(description = "条件类型", example = "1") |
| 290 | @InEnum(BpmSimpleModeConditionType.class) | 295 | @InEnum(BpmSimpleModeConditionType.class) |
| 291 | @NotNull(message = "条件类型不能为空") | 296 | @NotNull(message = "条件类型不能为空") |
| @@ -296,6 +301,7 @@ public class BpmSimpleModelNodeVO { | @@ -296,6 +301,7 @@ public class BpmSimpleModelNodeVO { | ||
| 296 | 301 | ||
| 297 | @Schema(description = "条件组", example = "{}") | 302 | @Schema(description = "条件组", example = "{}") |
| 298 | private ConditionGroups conditionGroups; | 303 | private ConditionGroups conditionGroups; |
| 304 | + | ||
| 299 | } | 305 | } |
| 300 | 306 | ||
| 301 | } | 307 | } |
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/util/SimpleModelUtils.java
| @@ -42,8 +42,7 @@ public class SimpleModelUtils { | @@ -42,8 +42,7 @@ public class SimpleModelUtils { | ||
| 42 | List<NodeConvert> converts = asList(new StartNodeConvert(), new EndNodeConvert(), | 42 | List<NodeConvert> converts = asList(new StartNodeConvert(), new EndNodeConvert(), |
| 43 | new StartUserNodeConvert(), new ApproveNodeConvert(), new CopyNodeConvert(), | 43 | new StartUserNodeConvert(), new ApproveNodeConvert(), new CopyNodeConvert(), |
| 44 | new DelayTimerNodeConvert(), | 44 | new DelayTimerNodeConvert(), |
| 45 | - new ConditionBranchNodeConvert(), new ParallelBranchNodeConvert(), new InclusiveBranchNodeConvert(), | ||
| 46 | - new RouteBranchNodeConvert()); | 45 | + new ConditionBranchNodeConvert(), new ParallelBranchNodeConvert(), new InclusiveBranchNodeConvert(), new RouteBranchNodeConvert()); |
| 47 | converts.forEach(convert -> NODE_CONVERTS.put(convert.getType(), convert)); | 46 | converts.forEach(convert -> NODE_CONVERTS.put(convert.getType(), convert)); |
| 48 | } | 47 | } |
| 49 | 48 | ||
| @@ -185,7 +184,7 @@ public class SimpleModelUtils { | @@ -185,7 +184,7 @@ public class SimpleModelUtils { | ||
| 185 | BpmSimpleModelNodeType nodeType = BpmSimpleModelNodeType.valueOf(node.getType()); | 184 | BpmSimpleModelNodeType nodeType = BpmSimpleModelNodeType.valueOf(node.getType()); |
| 186 | BpmSimpleModelNodeVO childNode = node.getChildNode(); | 185 | BpmSimpleModelNodeVO childNode = node.getChildNode(); |
| 187 | List<BpmSimpleModelNodeVO> conditionNodes = node.getConditionNodes(); | 186 | List<BpmSimpleModelNodeVO> conditionNodes = node.getConditionNodes(); |
| 188 | - // TODO @芋艿 路由分支没有conditionNodes 这里注释会影响吗? | 187 | + // TODO @芋艿 路由分支没有conditionNodes 这里注释会影响吗?@jason:一起帮忙瞅瞅! |
| 189 | // Assert.notEmpty(conditionNodes, "分支节点的条件节点不能为空"); | 188 | // Assert.notEmpty(conditionNodes, "分支节点的条件节点不能为空"); |
| 190 | // 分支终点节点 ID | 189 | // 分支终点节点 ID |
| 191 | String branchEndNodeId = null; | 190 | String branchEndNodeId = null; |
| @@ -204,8 +203,8 @@ public class SimpleModelUtils { | @@ -204,8 +203,8 @@ public class SimpleModelUtils { | ||
| 204 | if (nodeType == BpmSimpleModelNodeType.ROUTE_BRANCH_NODE) { | 203 | if (nodeType == BpmSimpleModelNodeType.ROUTE_BRANCH_NODE) { |
| 205 | // 路由分支遍历 | 204 | // 路由分支遍历 |
| 206 | for (BpmSimpleModelNodeVO.RouteCondition route : node.getRouteGroup()) { | 205 | for (BpmSimpleModelNodeVO.RouteCondition route : node.getRouteGroup()) { |
| 207 | - SequenceFlow sFlow = RouteBranchNodeConvert.buildSequenceFlow(node.getId(), route); | ||
| 208 | - process.addFlowElement(sFlow); | 206 | + SequenceFlow sequenceFlow = RouteBranchNodeConvert.buildSequenceFlow(node.getId(), route); |
| 207 | + process.addFlowElement(sequenceFlow); | ||
| 209 | } | 208 | } |
| 210 | } else { | 209 | } else { |
| 211 | // 下面的注释,以如下情况举例子。分支 1:A->B->C->D->E,分支 2:A->D->E。其中,A 为分支节点, D 为 A 孩子节点 | 210 | // 下面的注释,以如下情况举例子。分支 1:A->B->C->D->E,分支 2:A->D->E。其中,A 为分支节点, D 为 A 孩子节点 |
| @@ -228,15 +227,14 @@ public class SimpleModelUtils { | @@ -228,15 +227,14 @@ public class SimpleModelUtils { | ||
| 228 | } | 227 | } |
| 229 | } | 228 | } |
| 230 | 229 | ||
| 231 | - // 4. 各分支节点所需特殊处理 | 230 | + // 4.1 如果是并行分支、包容分支,由于是程序创建的聚合网关,需要手工创建聚合网关和下一个节点的连线 |
| 232 | if (nodeType == BpmSimpleModelNodeType.PARALLEL_BRANCH_NODE | 231 | if (nodeType == BpmSimpleModelNodeType.PARALLEL_BRANCH_NODE |
| 233 | - || nodeType == BpmSimpleModelNodeType.INCLUSIVE_BRANCH_NODE ) { | ||
| 234 | - // 如果是并行分支、包容分支,由于是程序创建的聚合网关,需要手工创建聚合网关和下一个节点的连线 | 232 | + || nodeType == BpmSimpleModelNodeType.INCLUSIVE_BRANCH_NODE) { |
| 235 | String nextNodeId = isValidNode(childNode) ? childNode.getId() : targetNodeId; | 233 | String nextNodeId = isValidNode(childNode) ? childNode.getId() : targetNodeId; |
| 236 | SequenceFlow sequenceFlow = buildBpmnSequenceFlow(branchEndNodeId, nextNodeId); | 234 | SequenceFlow sequenceFlow = buildBpmnSequenceFlow(branchEndNodeId, nextNodeId); |
| 237 | process.addFlowElement(sequenceFlow); | 235 | process.addFlowElement(sequenceFlow); |
| 236 | + // 4.2 如果是路由分支,需要连接后续节点为默认路由 | ||
| 238 | } else if (nodeType == BpmSimpleModelNodeType.ROUTE_BRANCH_NODE) { | 237 | } else if (nodeType == BpmSimpleModelNodeType.ROUTE_BRANCH_NODE) { |
| 239 | - // 如果是路由分支,需要连接后续节点为默认路由 | ||
| 240 | SequenceFlow sequenceFlow = buildBpmnSequenceFlow(node.getId(), branchEndNodeId, node.getDefaultFlowId(), | 238 | SequenceFlow sequenceFlow = buildBpmnSequenceFlow(node.getId(), branchEndNodeId, node.getDefaultFlowId(), |
| 241 | null, null); | 239 | null, null); |
| 242 | process.addFlowElement(sequenceFlow); | 240 | process.addFlowElement(sequenceFlow); |
| @@ -617,10 +615,12 @@ public class SimpleModelUtils { | @@ -617,10 +615,12 @@ public class SimpleModelUtils { | ||
| 617 | return buildConditionExpression(node.getConditionType(), node.getConditionExpression(), | 615 | return buildConditionExpression(node.getConditionType(), node.getConditionExpression(), |
| 618 | node.getConditionGroups()); | 616 | node.getConditionGroups()); |
| 619 | } | 617 | } |
| 618 | + | ||
| 620 | public static String buildConditionExpression(BpmSimpleModelNodeVO.RouteCondition route) { | 619 | public static String buildConditionExpression(BpmSimpleModelNodeVO.RouteCondition route) { |
| 621 | return buildConditionExpression(route.getConditionType(), route.getConditionExpression(), | 620 | return buildConditionExpression(route.getConditionType(), route.getConditionExpression(), |
| 622 | route.getConditionGroups()); | 621 | route.getConditionGroups()); |
| 623 | } | 622 | } |
| 623 | + | ||
| 624 | public static String buildConditionExpression(Integer conditionType, String conditionExpression, | 624 | public static String buildConditionExpression(Integer conditionType, String conditionExpression, |
| 625 | ConditionGroups conditionGroups) { | 625 | ConditionGroups conditionGroups) { |
| 626 | BpmSimpleModeConditionType conditionTypeEnum = BpmSimpleModeConditionType.valueOf(conditionType); | 626 | BpmSimpleModeConditionType conditionTypeEnum = BpmSimpleModeConditionType.valueOf(conditionType); |
| @@ -711,6 +711,7 @@ public class SimpleModelUtils { | @@ -711,6 +711,7 @@ public class SimpleModelUtils { | ||
| 711 | String conditionExpression = ConditionNodeConvert.buildConditionExpression(route); | 711 | String conditionExpression = ConditionNodeConvert.buildConditionExpression(route); |
| 712 | return buildBpmnSequenceFlow(nodeId, route.getNodeId(), null, null, conditionExpression); | 712 | return buildBpmnSequenceFlow(nodeId, route.getNodeId(), null, null, conditionExpression); |
| 713 | } | 713 | } |
| 714 | + | ||
| 714 | } | 715 | } |
| 715 | 716 | ||
| 716 | private static String buildGatewayJoinId(String id) { | 717 | private static String buildGatewayJoinId(String id) { |