Commit 96875b1e022f03e9857f4027fd49c0785a45bfca

Authored by jason
1 parent 1784aab1

【代码评审修改】 条件节点设置修改

yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/model/simple/BpmSimpleModelNodeVO.java
@@ -101,20 +101,10 @@ public class BpmSimpleModelNodeVO { @@ -101,20 +101,10 @@ public class BpmSimpleModelNodeVO {
101 @Schema(description = "条件节点") 101 @Schema(description = "条件节点")
102 private List<BpmSimpleModelNodeVO> conditionNodes; // 补充说明:有且仅有条件、并行、包容分支会使用 102 private List<BpmSimpleModelNodeVO> conditionNodes; // 补充说明:有且仅有条件、并行、包容分支会使用
103 103
104 - // TODO @jason:conditionType、conditionExpression、defaultFlow、conditionGroups 搞成一个 condition 属性,会好点么?  
105 - @Schema(description = "条件类型", example = "1")  
106 - @InEnum(BpmSimpleModeConditionType.class)  
107 - private Integer conditionType; // 仅用于条件节点 BpmSimpleModelNodeType.CONDITION_NODE  
108 -  
109 - @Schema(description = "条件表达式", example = "${day>3}")  
110 - private String conditionExpression; // 仅用于条件节点 BpmSimpleModelNodeType.CONDITION_NODE  
111 -  
112 - @Schema(description = "是否默认条件", example = "true")  
113 - private Boolean defaultFlow; // 仅用于条件节点 BpmSimpleModelNodeType.CONDITION_NODE  
114 /** 104 /**
115 - * 条件组 105 + * 条件节点设置
116 */ 106 */
117 - private ConditionGroups conditionGroups; // 仅用于条件节点 BpmSimpleModelNodeType.CONDITION_NODE 107 + private ConditionSetting conditionSetting; // 仅用于条件节点 BpmSimpleModelNodeType.CONDITION_NODE
118 108
119 @Schema(description = "路由分支组", example = "[]") 109 @Schema(description = "路由分支组", example = "[]")
120 private List<RouterCondition> routerGroups; 110 private List<RouterCondition> routerGroups;
@@ -155,9 +145,7 @@ public class BpmSimpleModelNodeVO { @@ -155,9 +145,7 @@ public class BpmSimpleModelNodeVO {
155 145
156 @Schema(description = "值", example = "xxx") 146 @Schema(description = "值", example = "xxx")
157 private String value; 147 private String value;
158 -  
159 } 148 }
160 -  
161 } 149 }
162 150
163 @Schema(description = "审批节点拒绝处理策略") 151 @Schema(description = "审批节点拒绝处理策略")
@@ -192,7 +180,6 @@ public class BpmSimpleModelNodeVO { @@ -192,7 +180,6 @@ public class BpmSimpleModelNodeVO {
192 180
193 @Schema(description = "最大提醒次数", example = "1") 181 @Schema(description = "最大提醒次数", example = "1")
194 private Integer maxRemindCount; 182 private Integer maxRemindCount;
195 -  
196 } 183 }
197 184
198 @Schema(description = "空处理策略") 185 @Schema(description = "空处理策略")
@@ -207,7 +194,6 @@ public class BpmSimpleModelNodeVO { @@ -207,7 +194,6 @@ public class BpmSimpleModelNodeVO {
207 194
208 @Schema(description = "指定人员审批的用户编号数组", example = "1") 195 @Schema(description = "指定人员审批的用户编号数组", example = "1")
209 private List<Long> userIds; 196 private List<Long> userIds;
210 -  
211 } 197 }
212 198
213 @Schema(description = "操作按钮设置") 199 @Schema(description = "操作按钮设置")
@@ -226,6 +212,28 @@ public class BpmSimpleModelNodeVO { @@ -226,6 +212,28 @@ public class BpmSimpleModelNodeVO {
226 private Boolean enable; 212 private Boolean enable;
227 } 213 }
228 214
  215 + @Schema(description = "条件设置")
  216 + @Data
  217 + @Valid
  218 + // 仅用于条件节点 BpmSimpleModelNodeType.CONDITION_NODE
  219 + public static class ConditionSetting {
  220 +
  221 + @Schema(description = "条件类型", example = "1")
  222 + @InEnum(BpmSimpleModeConditionType.class)
  223 + private Integer conditionType;
  224 +
  225 + @Schema(description = "条件表达式", example = "${day>3}")
  226 + private String conditionExpression;
  227 +
  228 + @Schema(description = "是否默认条件", example = "true")
  229 + private Boolean defaultFlow;
  230 +
  231 + /**
  232 + * 条件组
  233 + */
  234 + private ConditionGroups conditionGroups;
  235 + }
  236 +
229 @Schema(description = "条件组") 237 @Schema(description = "条件组")
230 @Data 238 @Data
231 @Valid 239 @Valid
@@ -270,7 +278,6 @@ public class BpmSimpleModelNodeVO { @@ -270,7 +278,6 @@ public class BpmSimpleModelNodeVO {
270 @Schema(description = "运算符右边的值", example = "1") 278 @Schema(description = "运算符右边的值", example = "1")
271 @NotEmpty(message = "运算符右边的值不能为空") 279 @NotEmpty(message = "运算符右边的值不能为空")
272 private String rightSide; 280 private String rightSide;
273 -  
274 } 281 }
275 282
276 @Schema(description = "延迟器") 283 @Schema(description = "延迟器")
@@ -286,7 +293,6 @@ public class BpmSimpleModelNodeVO { @@ -286,7 +293,6 @@ public class BpmSimpleModelNodeVO {
286 @Schema(description = "延迟时间表达式", example = "PT1H,2025-01-01T00:00:00") 293 @Schema(description = "延迟时间表达式", example = "PT1H,2025-01-01T00:00:00")
287 @NotEmpty(message = "延迟时间表达式不能为空") 294 @NotEmpty(message = "延迟时间表达式不能为空")
288 private String delayTime; 295 private String delayTime;
289 -  
290 } 296 }
291 297
292 @Schema(description = "路由分支") 298 @Schema(description = "路由分支")
@@ -308,7 +314,5 @@ public class BpmSimpleModelNodeVO { @@ -308,7 +314,5 @@ public class BpmSimpleModelNodeVO {
308 314
309 @Schema(description = "条件组", example = "{}") 315 @Schema(description = "条件组", example = "{}")
310 private ConditionGroups conditionGroups; 316 private ConditionGroups conditionGroups;
311 -  
312 } 317 }
313 -  
314 } 318 }
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/util/SimpleModelUtils.java
@@ -544,7 +544,7 @@ public class SimpleModelUtils { @@ -544,7 +544,7 @@ public class SimpleModelUtils {
544 544
545 // 设置默认的序列流(条件) 545 // 设置默认的序列流(条件)
546 BpmSimpleModelNodeVO defaultSeqFlow = CollUtil.findOne(node.getConditionNodes(), 546 BpmSimpleModelNodeVO defaultSeqFlow = CollUtil.findOne(node.getConditionNodes(),
547 - item -> BooleanUtil.isTrue(item.getDefaultFlow())); 547 + item -> BooleanUtil.isTrue(item.getConditionSetting().getDefaultFlow()));
548 Assert.notNull(defaultSeqFlow, "条件分支节点({})的默认序列流不能为空", node.getId()); 548 Assert.notNull(defaultSeqFlow, "条件分支节点({})的默认序列流不能为空", node.getId());
549 exclusiveGateway.setDefaultFlow(defaultSeqFlow.getId()); 549 exclusiveGateway.setDefaultFlow(defaultSeqFlow.getId());
550 return exclusiveGateway; 550 return exclusiveGateway;
@@ -587,7 +587,7 @@ public class SimpleModelUtils { @@ -587,7 +587,7 @@ public class SimpleModelUtils {
587 inclusiveGateway.setId(node.getId()); 587 inclusiveGateway.setId(node.getId());
588 // 设置默认的序列流(条件) 588 // 设置默认的序列流(条件)
589 BpmSimpleModelNodeVO defaultSeqFlow = CollUtil.findOne(node.getConditionNodes(), 589 BpmSimpleModelNodeVO defaultSeqFlow = CollUtil.findOne(node.getConditionNodes(),
590 - item -> BooleanUtil.isTrue(item.getDefaultFlow())); 590 + item -> BooleanUtil.isTrue(item.getConditionSetting().getDefaultFlow()));
591 Assert.notNull(defaultSeqFlow, "包容分支节点({})的默认序列流不能为空", node.getId()); 591 Assert.notNull(defaultSeqFlow, "包容分支节点({})的默认序列流不能为空", node.getId());
592 inclusiveGateway.setDefaultFlow(defaultSeqFlow.getId()); 592 inclusiveGateway.setDefaultFlow(defaultSeqFlow.getId());
593 // TODO @jason:setName 593 // TODO @jason:setName
@@ -631,8 +631,8 @@ public class SimpleModelUtils { @@ -631,8 +631,8 @@ public class SimpleModelUtils {
631 * @param node 条件节点 631 * @param node 条件节点
632 */ 632 */
633 public static String buildConditionExpression(BpmSimpleModelNodeVO node) { 633 public static String buildConditionExpression(BpmSimpleModelNodeVO node) {
634 - return buildConditionExpression(node.getConditionType(), node.getConditionExpression(),  
635 - node.getConditionGroups()); 634 + return buildConditionExpression(node.getConditionSetting().getConditionType(), node.getConditionSetting().getConditionExpression(),
  635 + node.getConditionSetting().getConditionGroups());
636 } 636 }
637 637
638 public static String buildConditionExpression(BpmSimpleModelNodeVO.RouterCondition router) { 638 public static String buildConditionExpression(BpmSimpleModelNodeVO.RouterCondition router) {
@@ -771,11 +771,11 @@ public class SimpleModelUtils { @@ -771,11 +771,11 @@ public class SimpleModelUtils {
771 if (nodeType == BpmSimpleModelNodeType.CONDITION_BRANCH_NODE) { 771 if (nodeType == BpmSimpleModelNodeType.CONDITION_BRANCH_NODE) {
772 // 查找满足条件的 BpmSimpleModelNodeVO 节点 772 // 查找满足条件的 BpmSimpleModelNodeVO 节点
773 BpmSimpleModelNodeVO matchConditionNode = CollUtil.findOne(currentNode.getConditionNodes(), 773 BpmSimpleModelNodeVO matchConditionNode = CollUtil.findOne(currentNode.getConditionNodes(),
774 - conditionNode -> !BooleanUtil.isTrue(conditionNode.getDefaultFlow()) 774 + conditionNode -> !BooleanUtil.isTrue(conditionNode.getConditionSetting().getDefaultFlow())
775 && evalConditionExpress(variables, conditionNode)); 775 && evalConditionExpress(variables, conditionNode));
776 if (matchConditionNode == null) { 776 if (matchConditionNode == null) {
777 matchConditionNode = CollUtil.findOne(currentNode.getConditionNodes(), 777 matchConditionNode = CollUtil.findOne(currentNode.getConditionNodes(),
778 - conditionNode -> BooleanUtil.isTrue(conditionNode.getDefaultFlow())); 778 + conditionNode -> BooleanUtil.isTrue(conditionNode.getConditionSetting().getDefaultFlow()));
779 } 779 }
780 Assert.notNull(matchConditionNode, "找不到条件节点({})", currentNode); 780 Assert.notNull(matchConditionNode, "找不到条件节点({})", currentNode);
781 // 遍历满足条件的 BpmSimpleModelNodeVO 节点 781 // 遍历满足条件的 BpmSimpleModelNodeVO 节点
@@ -786,11 +786,11 @@ public class SimpleModelUtils { @@ -786,11 +786,11 @@ public class SimpleModelUtils {
786 if (nodeType == BpmSimpleModelNodeType.INCLUSIVE_BRANCH_NODE) { 786 if (nodeType == BpmSimpleModelNodeType.INCLUSIVE_BRANCH_NODE) {
787 // 查找满足条件的 BpmSimpleModelNodeVO 节点 787 // 查找满足条件的 BpmSimpleModelNodeVO 节点
788 Collection<BpmSimpleModelNodeVO> matchConditionNodes = CollUtil.filterNew(currentNode.getConditionNodes(), 788 Collection<BpmSimpleModelNodeVO> matchConditionNodes = CollUtil.filterNew(currentNode.getConditionNodes(),
789 - conditionNode -> !BooleanUtil.isTrue(conditionNode.getDefaultFlow()) 789 + conditionNode -> !BooleanUtil.isTrue(conditionNode.getConditionSetting().getDefaultFlow())
790 && evalConditionExpress(variables, conditionNode)); 790 && evalConditionExpress(variables, conditionNode));
791 if (CollUtil.isEmpty(matchConditionNodes)) { 791 if (CollUtil.isEmpty(matchConditionNodes)) {
792 matchConditionNodes = CollUtil.filterNew(currentNode.getConditionNodes(), 792 matchConditionNodes = CollUtil.filterNew(currentNode.getConditionNodes(),
793 - conditionNode -> BooleanUtil.isTrue(conditionNode.getDefaultFlow())); 793 + conditionNode -> BooleanUtil.isTrue(conditionNode.getConditionSetting().getDefaultFlow()));
794 } 794 }
795 Assert.isTrue(!matchConditionNodes.isEmpty(), "找不到条件节点({})", currentNode); 795 Assert.isTrue(!matchConditionNodes.isEmpty(), "找不到条件节点({})", currentNode);
796 // 遍历满足条件的 BpmSimpleModelNodeVO 节点 796 // 遍历满足条件的 BpmSimpleModelNodeVO 节点