• 基于若依的ruoyi-nbcio流程管理系统仿钉钉流程json转bpmn的flowable的xml格式(排它条件网关)


    更多ruoyi-nbcio功能请看演示系统

    gitee源代码地址

    前后端代码: https://gitee.com/nbacheng/ruoyi-nbcio

    演示地址:RuoYi-Nbcio后台管理系统

    这个章节来完成并行网关与排它条件网关的功能

    1、前端

        目前就修改了排它条件网关的前端条件部分,简化条件公式,考虑与原有流程设计器兼容。

      主要是以下部分修改

    1. <!-- 条件 -->
    2. <section class="condition-pane" v-if="value && isConditionNode()">
    3. <!-- 字符串条件 -->
    4. <el-input placeholder="请输入条件表达式" v-model="pconditions">
    5. <template slot="prepend">条件表达式:</template>
    6. </el-input>
    7. </section>
    8. /**
    9. * 条件节点确认保存得回调
    10. */
    11. conditionNodeComfirm() {
    12. this.properties.conditions = this.pconditions
    13. // 发起人虽然是条件 但是这里把发起人放到外部单独判断
    14. this.properties.initiator = this.initiator['dep&user']
    15. //this.initiator['dep&user'] && (nodeContent = `[发起人: ${this.getOrgSelectLabel('condition')}]` + '\n' + nodeContent)
    16. this.$emit("confirm", this.properties, this.pconditions || '请设置条件表达式');
    17. this.visible = false;
    18. },
    19. /**
    20. * 初始化条件节点数据
    21. */
    22. initConditionNodeData(){
    23. this.pconditions = this.value.content
    24. },

    2、排它条件网关后端修改

    1. String createExclusiveGatewayBuilder(String formId, JSONObject flowNode) throws InvocationTargetException, IllegalAccessException {
    2. //String name = flowNode.getString("nodeName");
    3. String exclusiveGatewayId = id("exclusiveGateway");
    4. ExclusiveGateway exclusiveGateway = new ExclusiveGateway();
    5. exclusiveGateway.setId(exclusiveGatewayId);
    6. exclusiveGateway.setName("排它条件网关");
    7. ddProcess.addFlowElement(exclusiveGateway);
    8. ddProcess.addFlowElement(connect(formId, exclusiveGatewayId));
    9. if (Objects.isNull(flowNode.getJSONArray("conditionNodes")) && Objects.isNull(flowNode.getJSONObject("childNode"))) {
    10. return exclusiveGatewayId;
    11. }
    12. List flowNodes = Optional.ofNullable(flowNode.getJSONArray("conditionNodes")).map(e -> e.toJavaList(JSONObject.class)).orElse(Collections.emptyList());
    13. List incoming = Lists.newArrayListWithCapacity(flowNodes.size());
    14. List conditions = Lists.newCopyOnWriteArrayList();
    15. for (JSONObject element : flowNodes) {
    16. JSONObject childNode = element.getJSONObject("childNode");
    17. JSONObject properties = element.getJSONObject("properties");
    18. String nodeName = properties.getString("title");
    19. String expression = properties.getString("conditions");
    20. if (Objects.isNull(childNode)) {
    21. incoming.add(exclusiveGatewayId);
    22. JSONObject condition = new JSONObject();
    23. condition.fluentPut("nodeName", nodeName)
    24. .fluentPut("expression", expression);
    25. conditions.add(condition);
    26. continue;
    27. }
    28. // 只生成一个任务,同时设置当前任务的条件
    29. childNode.put("incoming", Collections.singletonList(exclusiveGatewayId));
    30. String identifier = create(exclusiveGatewayId, childNode);
    31. List flows = ddSequenceFlows.stream().filter(flow -> StringUtils.equals(exclusiveGatewayId, flow.getSourceRef()))
    32. .collect(Collectors.toList());
    33. flows.stream().forEach(
    34. e -> {
    35. if (StringUtils.isBlank(e.getName()) && StringUtils.isNotBlank(nodeName)) {
    36. e.setName(nodeName);
    37. }
    38. // 设置条件表达式
    39. if (Objects.isNull(e.getConditionExpression()) && StringUtils.isNotBlank(expression)) {
    40. e.setConditionExpression(expression);
    41. }
    42. }
    43. );
    44. if (Objects.nonNull(identifier)) {
    45. incoming.add(identifier);
    46. }
    47. }
    48. JSONObject childNode = flowNode.getJSONObject("childNode");
    49. if (Objects.nonNull(childNode)) {
    50. if (incoming == null || incoming.isEmpty()) {
    51. return create(exclusiveGatewayId, childNode);
    52. } else {
    53. // 所有 service task 连接 end exclusive gateway
    54. childNode.put("incoming", incoming);
    55. FlowElement flowElement = ddBpmnModel.getFlowElement(incoming.get(0));
    56. // 1.0 先进行边连接, 暂存 nextNode
    57. JSONObject nextNode = childNode.getJSONObject("childNode");
    58. childNode.put("childNode", null);
    59. String identifier = create(flowElement.getId(), childNode);
    60. for (int i = 1; i < incoming.size(); i++) {
    61. ddProcess.addFlowElement(connect(incoming.get(i), identifier));
    62. }
    63. // 针对 gateway 空任务分支 添加条件表达式
    64. if (!conditions.isEmpty()) {
    65. FlowElement flowElement1 = ddBpmnModel.getFlowElement(identifier);
    66. // 获取从 gateway 到目标节点 未设置条件表达式的节点
    67. List flows = ddSequenceFlows.stream().filter(flow -> StringUtils.equals(flowElement1.getId(), flow.getTargetRef()))
    68. .filter(flow -> StringUtils.equals(flow.getSourceRef(), exclusiveGatewayId))
    69. .collect(Collectors.toList());
    70. flows.stream().forEach(sequenceFlow -> {
    71. if (!conditions.isEmpty()) {
    72. JSONObject condition = conditions.get(0);
    73. String nodeName = condition.getString("content");
    74. String expression = condition.getString("expression");
    75. if (StringUtils.isBlank(sequenceFlow.getName()) && StringUtils.isNotBlank(nodeName)) {
    76. sequenceFlow.setName(nodeName);
    77. }
    78. // 设置条件表达式
    79. if (Objects.isNull(sequenceFlow.getConditionExpression()) && StringUtils.isNotBlank(expression)) {
    80. sequenceFlow.setConditionExpression(expression);
    81. }
    82. conditions.remove(0);
    83. }
    84. });
    85. }
    86. // 1.1 边连接完成后,在进行 nextNode 创建
    87. if (Objects.nonNull(nextNode)) {
    88. return create(identifier, nextNode);
    89. } else {
    90. return identifier;
    91. }
    92. }
    93. }
    94. return exclusiveGatewayId;
    95. }

    4、效果图如下:

    还是有bug,后面的审批人连接有问题,后续修改吧。

  • 相关阅读:
    [附源码]计算机毕业设计JAVA校园共享单车系统
    微信小程序开发记录
    App测试需要测什么
    算法通过村第八关-树(深度优先)白银笔记|深度和高度问题
    【Kotlin学习路线】讲解
    基于单片机的太阳能无线 LED 灯设计
    【二分】Pythagorean Triples—CF1487D
    25期代码随想录算法训练营第十天 | 栈与队列 part 1
    Python将.arff文件转换为.mat文件
    尚硅谷尚优选项目教程发布
  • 原文地址:https://blog.csdn.net/qq_40032778/article/details/134290364