基于若依的ruoyi-nbcio流程管理系统仿钉钉流程json转bpmn的flowable的xml格式(支持并行网关)

简介: 基于若依的ruoyi-nbcio流程管理系统仿钉钉流程json转bpmn的flowable的xml格式(支持并行网关)

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

gitee源代码地址

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

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

这个章节来完成并行网关,前端无需修改,直接后端修改就可以了。

1、并行网关后端修改如下:

String createConcurrentGatewayBuilder(String formId, JSONObject flowNode) throws InvocationTargetException, IllegalAccessException {
        //String name = flowNode.getString("nodeName");
        ParallelGateway parallelGateway = new ParallelGateway();
        String parallelGatewayId = id("parallelGateway");
        parallelGateway.setId(parallelGatewayId);
        parallelGateway.setName("并行网关");
        ddProcess.addFlowElement(parallelGateway);
        ddProcess.addFlowElement(connect(formId, parallelGatewayId));
        if (Objects.isNull(flowNode.getJSONArray("concurrentNodes"))
                && Objects.isNull(flowNode.getJSONObject("childNode"))) {
            return parallelGatewayId;
        }
        List<JSONObject> flowNodes = Optional.ofNullable(flowNode.getJSONArray("concurrentNodes")).map(e -> e.toJavaList(JSONObject.class)).orElse(Collections.emptyList());
        List<String> incoming = Lists.newArrayListWithCapacity(flowNodes.size());
        for (JSONObject element : flowNodes) {
            JSONObject childNode = element.getJSONObject("childNode");
            if (Objects.isNull(childNode)) {
                incoming.add(parallelGatewayId);
                continue;
            }
            String identifier = create(parallelGatewayId, childNode);
            if (Objects.nonNull(identifier)) {
                incoming.add(identifier);
            }
        }
        JSONObject childNode = flowNode.getJSONObject("childNode");
        if (Objects.nonNull(childNode)) {
            // 普通结束网关
            if (CollectionUtils.isEmpty(incoming)) {
                return create(parallelGatewayId, childNode);
            } else {
                // 所有 service task 连接 end parallel gateway
                childNode.put("incoming", incoming);
                FlowElement flowElement = ddBpmnModel.getFlowElement(incoming.get(0));
                // 1.0 先进行边连接, 暂存 nextNode
                JSONObject nextNode = childNode.getJSONObject("childNode");
                childNode.put("childNode", null);
                String identifier = create(incoming.get(0), childNode);
                for (int i = 1; i < incoming.size(); i++) {
                    FlowElement flowElement1 = ddBpmnModel.getFlowElement(incoming.get(i));
                    ddProcess.addFlowElement(connect(flowElement1.getId(), identifier));
                }
                // 1.1 边连接完成后,在进行 nextNode 创建
                if (Objects.nonNull(nextNode)) {
                    return create(identifier, nextNode);
                } else {
                    return identifier;
                }
            }
        }
        return parallelGatewayId;
    }

2、效果图如下:

3、生产的xml如下:

<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:flowable="http://flowable.org/bpmn" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:omgdc="http://www.omg.org/spec/DD/20100524/DC" xmlns:omgdi="http://www.omg.org/spec/DD/20100524/DI" typeLanguage="http://www.w3.org/2001/XMLSchema" expressionLanguage="http://www.w3.org/1999/XPath" targetNamespace="http://www.flowable.org/test">
  <process id="Process_1233c789-c986-4de2-8ab2-9c24ef0a2312" name="dingding演示流程" isExecutable="true">
    <startEvent id="start_36faea0bc7344384bc52078dd43c0829"></startEvent>
    <parallelGateway id="parallelGateway_31fb5c2d6062402688b9bceb230610df" name="并行网关"></parallelGateway>
    <sequenceFlow id="sequenceFlow_8f3fb2e6498847aea4e88ad7f8527720" sourceRef="start_36faea0bc7344384bc52078dd43c0829" targetRef="parallelGateway_31fb5c2d6062402688b9bceb230610df"></sequenceFlow>
    <userTask id="userTask_261260b7d3c643f08d6000f422628363" name="审批人" flowable:assignee="ry" flowable:dataType="USERS" flowable:text="若依"></userTask>
    <sequenceFlow id="sequenceFlow_ec473d524b1f4c70ac8d59c9d11cf20a" sourceRef="parallelGateway_31fb5c2d6062402688b9bceb230610df" targetRef="userTask_261260b7d3c643f08d6000f422628363"></sequenceFlow>
    <userTask id="userTask_182b04b3cc0c465589ae5bb936185fe5" name="审批人" flowable:assignee="zhangsan" flowable:dataType="USERS" flowable:text="张三"></userTask>
    <sequenceFlow id="sequenceFlow_9c0f2e6f0a434217996502850297b251" sourceRef="parallelGateway_31fb5c2d6062402688b9bceb230610df" targetRef="userTask_182b04b3cc0c465589ae5bb936185fe5"></sequenceFlow>
    <userTask id="userTask_d81ef1ca0fa2436abf543dc6cb7d80df" name="审批人" flowable:assignee="admin" flowable:dataType="USERS" flowable:text="若依管理员"></userTask>
    <sequenceFlow id="sequenceFlow_2227bd432d044dc889aa9a9132ca7589" sourceRef="userTask_261260b7d3c643f08d6000f422628363" targetRef="userTask_d81ef1ca0fa2436abf543dc6cb7d80df"></sequenceFlow>
    <sequenceFlow id="sequenceFlow_8bb051d48a654b3bba4a687c6320eb29" sourceRef="userTask_182b04b3cc0c465589ae5bb936185fe5" targetRef="userTask_d81ef1ca0fa2436abf543dc6cb7d80df"></sequenceFlow>
    <endEvent id="end_28c4b21fe4d145cfb6aa1019d13a24ac"></endEvent>
    <sequenceFlow id="sequenceFlow_008d4f7e2c0e4246af7d5c4092af6a21" sourceRef="userTask_d81ef1ca0fa2436abf543dc6cb7d80df" targetRef="end_28c4b21fe4d145cfb6aa1019d13a24ac"></sequenceFlow>
  </process>
  <bpmndi:BPMNDiagram id="BPMNDiagram_Process_1233c789-c986-4de2-8ab2-9c24ef0a2312">
    <bpmndi:BPMNPlane bpmnElement="Process_1233c789-c986-4de2-8ab2-9c24ef0a2312" id="BPMNPlane_Process_1233c789-c986-4de2-8ab2-9c24ef0a2312">
      <bpmndi:BPMNShape bpmnElement="start_36faea0bc7344384bc52078dd43c0829" id="BPMNShape_start_36faea0bc7344384bc52078dd43c0829">
        <omgdc:Bounds height="30.0" width="30.0" x="0.0" y="95.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="userTask_d81ef1ca0fa2436abf543dc6cb7d80df" id="BPMNShape_userTask_d81ef1ca0fa2436abf543dc6cb7d80df">
        <omgdc:Bounds height="60.0" width="100.0" x="320.0" y="80.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="userTask_182b04b3cc0c465589ae5bb936185fe5" id="BPMNShape_userTask_182b04b3cc0c465589ae5bb936185fe5">
        <omgdc:Bounds height="60.0" width="100.0" x="170.0" y="160.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="parallelGateway_31fb5c2d6062402688b9bceb230610df" id="BPMNShape_parallelGateway_31fb5c2d6062402688b9bceb230610df">
        <omgdc:Bounds height="40.0" width="40.0" x="80.0" y="90.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="userTask_261260b7d3c643f08d6000f422628363" id="BPMNShape_userTask_261260b7d3c643f08d6000f422628363">
        <omgdc:Bounds height="60.0" width="100.0" x="170.0" y="0.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="end_28c4b21fe4d145cfb6aa1019d13a24ac" id="BPMNShape_end_28c4b21fe4d145cfb6aa1019d13a24ac">
        <omgdc:Bounds height="30.0" width="30.0" x="470.0" y="95.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNEdge bpmnElement="sequenceFlow_8bb051d48a654b3bba4a687c6320eb29" id="BPMNEdge_sequenceFlow_8bb051d48a654b3bba4a687c6320eb29">
        <omgdi:waypoint x="270.0" y="190.0"></omgdi:waypoint>
        <omgdi:waypoint x="282.0" y="190.0"></omgdi:waypoint>
        <omgdi:waypoint x="282.0" y="110.0"></omgdi:waypoint>
        <omgdi:waypoint x="320.0" y="110.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="sequenceFlow_8f3fb2e6498847aea4e88ad7f8527720" id="BPMNEdge_sequenceFlow_8f3fb2e6498847aea4e88ad7f8527720">
        <omgdi:waypoint x="30.0" y="110.0"></omgdi:waypoint>
        <omgdi:waypoint x="80.0" y="110.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="sequenceFlow_ec473d524b1f4c70ac8d59c9d11cf20a" id="BPMNEdge_sequenceFlow_ec473d524b1f4c70ac8d59c9d11cf20a">
        <omgdi:waypoint x="120.0" y="102.5"></omgdi:waypoint>
        <omgdi:waypoint x="132.0" y="102.5"></omgdi:waypoint>
        <omgdi:waypoint x="132.0" y="30.000000000000007"></omgdi:waypoint>
        <omgdi:waypoint x="170.0" y="30.000000000000007"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="sequenceFlow_9c0f2e6f0a434217996502850297b251" id="BPMNEdge_sequenceFlow_9c0f2e6f0a434217996502850297b251">
        <omgdi:waypoint x="120.0" y="117.5"></omgdi:waypoint>
        <omgdi:waypoint x="132.0" y="117.5"></omgdi:waypoint>
        <omgdi:waypoint x="132.0" y="190.0"></omgdi:waypoint>
        <omgdi:waypoint x="170.0" y="190.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="sequenceFlow_008d4f7e2c0e4246af7d5c4092af6a21" id="BPMNEdge_sequenceFlow_008d4f7e2c0e4246af7d5c4092af6a21">
        <omgdi:waypoint x="420.0" y="110.0"></omgdi:waypoint>
        <omgdi:waypoint x="470.0" y="110.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="sequenceFlow_2227bd432d044dc889aa9a9132ca7589" id="BPMNEdge_sequenceFlow_2227bd432d044dc889aa9a9132ca7589">
        <omgdi:waypoint x="270.0" y="30.0"></omgdi:waypoint>
        <omgdi:waypoint x="282.0" y="30.0"></omgdi:waypoint>
        <omgdi:waypoint x="282.0" y="110.0"></omgdi:waypoint>
        <omgdi:waypoint x="320.0" y="110.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
    </bpmndi:BPMNPlane>
  </bpmndi:BPMNDiagram>
</definitions>

4、在原来流程设计器打开如下:


相关文章
|
2月前
|
XML Ubuntu Linux
部署08---扩展-Win10配置WSL(Ubuntu)环境,WSL系统是什么意思,是Windows系统上的一个子系统, xml的一大特点是直链系统,直接链接你的CPU,硬盘和内存,如何用 WSL部署
部署08---扩展-Win10配置WSL(Ubuntu)环境,WSL系统是什么意思,是Windows系统上的一个子系统, xml的一大特点是直链系统,直接链接你的CPU,硬盘和内存,如何用 WSL部署
|
26天前
|
XML JSON 前端开发
【Web前端揭秘】XML与JSON:数据界的双雄对决,你的选择将如何改写Web世界的未来?
【8月更文挑战第26天】本文深入探讨了XML和JSON这两种广泛使用的数据交换格式在Web前端开发中的应用。XML采用自定义标签描述数据结构,适用于复杂层次数据的表示,而JSON则以键值对形式呈现数据,更为轻量且易解析。通过对两种格式的示例代码、结构特点及应用场景的分析,本文旨在帮助读者更好地理解它们的差异,并根据实际需求选择最合适的数据交换格式。
39 1
|
1月前
|
JSON Java Android开发
Android 开发者必备秘籍:轻松攻克 JSON 格式数据解析难题,让你的应用更出色!
【8月更文挑战第18天】在Android开发中,解析JSON数据至关重要。JSON以其简洁和易读成为首选的数据交换格式。开发者可通过多种途径解析JSON,如使用内置的`JSONObject`和`JSONArray`类直接操作数据,或借助Google提供的Gson库将JSON自动映射为Java对象。无论哪种方法,正确解析JSON都是实现高效应用的关键,能帮助开发者处理网络请求返回的数据,并将其展示给用户,从而提升应用的功能性和用户体验。
42 1
|
1月前
|
存储 安全 API
"解锁企业级黑科技!用阿里云视觉智能打造钉钉级人脸打卡系统,安全高效,让考勤管理秒变智能范儿!"
【8月更文挑战第14天】随着数字化办公的发展,人脸打卡成为企业考勤的新标准。利用阿里云视觉智能开放平台构建类似钉钉的人脸打卡系统,其关键在于:高精度人脸识别API支持复杂场景下的快速检测与比对;活体检测技术防止非生物特征欺骗,确保安全性;云端存储与计算能力满足大数据处理需求;丰富的SDK与API简化集成过程,实现高效、安全的考勤管理。
53 2
|
1月前
|
XML JSON Java
使用IDEA+Maven搭建整合一个Struts2+Spring4+Hibernate4项目,混合使用传统Xml与@注解,返回JSP视图或JSON数据,快来给你的SSH老项目翻新一下吧
本文介绍了如何使用IntelliJ IDEA和Maven搭建一个整合了Struts2、Spring4、Hibernate4的J2EE项目,并配置了项目目录结构、web.xml、welcome.jsp以及多个JSP页面,用于刷新和学习传统的SSH框架。
32 0
使用IDEA+Maven搭建整合一个Struts2+Spring4+Hibernate4项目,混合使用传统Xml与@注解,返回JSP视图或JSON数据,快来给你的SSH老项目翻新一下吧
|
21天前
|
Java Spring 容器
彻底改变你的编程人生!揭秘 Spring 框架依赖注入的神奇魔力,让你的代码瞬间焕然一新!
【8月更文挑战第31天】本文介绍 Spring 框架中的依赖注入(DI),一种降低代码耦合度的设计模式。通过 Spring 的 DI 容器,开发者可专注业务逻辑而非依赖管理。文中详细解释了 DI 的基本概念及其实现方式,如构造器注入、字段注入与 setter 方法注入,并提供示例说明如何在实际项目中应用这些技术。通过 Spring 的 @Configuration 和 @Bean 注解,可轻松定义与管理应用中的组件及其依赖关系,实现更简洁、易维护的代码结构。
26 0
|
27天前
|
JSON 开发工具 数据格式
【Azure Event Hub】Event Hub的Process Data页面无法通过JSON格式预览数据
【Azure Event Hub】Event Hub的Process Data页面无法通过JSON格式预览数据
|
1月前
|
JSON JavaScript 前端开发
Vue项目使用Cookie,以Json格式存入与读取Cookie,设置过期时间以及删除操作
这篇文章介绍了在Vue项目中如何使用JavaScript操作Cookie,包括设置、读取、设置过期时间以及删除Cookie的方法。
96 0
|
2月前
|
XML Java 数据格式
支付系统----微信支付20---创建案例项目--集成Mybatis-plus的补充,target下只有接口的编译文件,xml文件了,添加日志的写法
支付系统----微信支付20---创建案例项目--集成Mybatis-plus的补充,target下只有接口的编译文件,xml文件了,添加日志的写法
|
2月前
|
JSON 数据格式
Content type ‘text/plain;charset=UTF-8‘ not supported,这里要把测试文件转为json格式
Content type ‘text/plain;charset=UTF-8‘ not supported,这里要把测试文件转为json格式