Commit 902b0b5e47dba86bb18fcc5c70ba490f425ff16c
1 parent
2ef7612f
feat: 条件节点添加包含和不包含操作符
Showing
1 changed file
with
13 additions
and
4 deletions
yudao-module-bpm/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/util/SimpleModelUtils.java
| ... | ... | @@ -705,12 +705,21 @@ public class SimpleModelUtils { |
| 705 | 705 | } |
| 706 | 706 | // 构造规则表达式 |
| 707 | 707 | List<String> list = convertList(item.getRules(), (rule) -> { |
| 708 | + // TODO @芋艿:官方文档中无convertByType方法,https://flowable.me/blog/2025/04/02/back-end-expressions/ | |
| 708 | 709 | String rightSide = NumberUtil.isNumber(rule.getRightSide()) ? rule.getRightSide() |
| 709 | 710 | : "\"" + rule.getRightSide() + "\""; // 如果非数值类型加引号 |
| 710 | - return String.format(" vars:getOrDefault(%s, null) %s var:convertByType(%s,%s) ", | |
| 711 | - rule.getLeftSide(), // 左侧:读取变量 | |
| 712 | - rule.getOpCode(), // 中间:操作符,比较 | |
| 713 | - rule.getLeftSide(), rightSide); // 右侧:转换变量,VariableConvertByTypeExpressionFunction | |
| 711 | + return switch (rule.getOpCode()) { | |
| 712 | + case "contain" -> String.format(" var:contains(%s, %s) ", | |
| 713 | + rule.getLeftSide(), | |
| 714 | + rightSide); | |
| 715 | + case "!contain" -> String.format(" !var:contains(%s, %s) ", | |
| 716 | + rule.getLeftSide(), | |
| 717 | + rightSide); | |
| 718 | + default -> String.format(" var:getOrDefault(%s, null) %s %s ", | |
| 719 | + rule.getLeftSide(), // 左侧:读取变量 | |
| 720 | + rule.getOpCode(), // 中间:操作符,比较 | |
| 721 | + rightSide); // 右侧:取值变量 | |
| 722 | + }; | |
| 714 | 723 | }); |
| 715 | 724 | // 构造条件组的表达式 |
| 716 | 725 | Boolean and = item.getAnd(); | ... | ... |