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

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

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

gitee源代码地址

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

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

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

1、前端

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

 主要是以下部分修改

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

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

String createExclusiveGatewayBuilder(String formId, JSONObject flowNode) throws InvocationTargetException, IllegalAccessException {
        //String name = flowNode.getString("nodeName");
        String exclusiveGatewayId = id("exclusiveGateway");
        ExclusiveGateway exclusiveGateway = new ExclusiveGateway();
        exclusiveGateway.setId(exclusiveGatewayId);
        exclusiveGateway.setName("排它条件网关");
        ddProcess.addFlowElement(exclusiveGateway);
        ddProcess.addFlowElement(connect(formId, exclusiveGatewayId));
        if (Objects.isNull(flowNode.getJSONArray("conditionNodes")) && Objects.isNull(flowNode.getJSONObject("childNode"))) {
            return exclusiveGatewayId;
        }
        List<JSONObject> flowNodes = Optional.ofNullable(flowNode.getJSONArray("conditionNodes")).map(e -> e.toJavaList(JSONObject.class)).orElse(Collections.emptyList());
        List<String> incoming = Lists.newArrayListWithCapacity(flowNodes.size());
        List<JSONObject> conditions = Lists.newCopyOnWriteArrayList();
        for (JSONObject element : flowNodes) {
            JSONObject childNode = element.getJSONObject("childNode");
            JSONObject properties = element.getJSONObject("properties");
            String nodeName = properties.getString("title");
            String expression = properties.getString("conditions");
            if (Objects.isNull(childNode)) {
                incoming.add(exclusiveGatewayId);
                JSONObject condition = new JSONObject();
                condition.fluentPut("nodeName", nodeName)
                        .fluentPut("expression", expression);
                conditions.add(condition);
                continue;
            }
            // 只生成一个任务,同时设置当前任务的条件
            childNode.put("incoming", Collections.singletonList(exclusiveGatewayId));
            String identifier = create(exclusiveGatewayId, childNode);
            List<SequenceFlow> flows = ddSequenceFlows.stream().filter(flow -> StringUtils.equals(exclusiveGatewayId, flow.getSourceRef()))
                    .collect(Collectors.toList());
            
            flows.stream().forEach(
                    e -> {
                        if (StringUtils.isBlank(e.getName()) && StringUtils.isNotBlank(nodeName)) {
                            e.setName(nodeName);
                        }
                        // 设置条件表达式
                        if (Objects.isNull(e.getConditionExpression()) && StringUtils.isNotBlank(expression)) {
                            e.setConditionExpression(expression);
                        }
                    }
            );
            if (Objects.nonNull(identifier)) {
                incoming.add(identifier);
            }
        }
        JSONObject childNode = flowNode.getJSONObject("childNode");
        if (Objects.nonNull(childNode)) {
            if (incoming == null || incoming.isEmpty()) {
                return create(exclusiveGatewayId, childNode);
            } else {
                // 所有 service task 连接 end exclusive 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(flowElement.getId(), childNode);
                for (int i = 1; i < incoming.size(); i++) {
                  ddProcess.addFlowElement(connect(incoming.get(i), identifier));
                }
                //  针对 gateway 空任务分支 添加条件表达式
                if (!conditions.isEmpty()) {
                    FlowElement flowElement1 = ddBpmnModel.getFlowElement(identifier);
                    // 获取从 gateway 到目标节点 未设置条件表达式的节点
                    List<SequenceFlow> flows = ddSequenceFlows.stream().filter(flow -> StringUtils.equals(flowElement1.getId(), flow.getTargetRef()))
                            .filter(flow -> StringUtils.equals(flow.getSourceRef(), exclusiveGatewayId))
                            .collect(Collectors.toList());
                    flows.stream().forEach(sequenceFlow -> {
                        if (!conditions.isEmpty()) {
                            JSONObject condition = conditions.get(0);
                            String nodeName = condition.getString("content");
                            String expression = condition.getString("expression");
                            if (StringUtils.isBlank(sequenceFlow.getName()) && StringUtils.isNotBlank(nodeName)) {
                                sequenceFlow.setName(nodeName);
                            }
                            // 设置条件表达式
                            if (Objects.isNull(sequenceFlow.getConditionExpression()) && StringUtils.isNotBlank(expression)) {
                                sequenceFlow.setConditionExpression(expression);
                            }
                            conditions.remove(0);
                        }
                    });
                }
                // 1.1 边连接完成后,在进行 nextNode 创建
                if (Objects.nonNull(nextNode)) {
                    return create(identifier, nextNode);
                } else {
                    return identifier;
                }
            }
        }
        return exclusiveGatewayId;
    }

4、效果图如下:

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

相关文章
|
人工智能 自然语言处理 运维
钉钉MCP能力上新:AI如何提效你的工作流程
钉钉通讯录 & 部门管理、日程管理、待办任务、机器人&通知等高频场景API提供MCP服务
钉钉MCP能力上新:AI如何提效你的工作流程
|
10月前
|
JSON 数据格式 开发者
钉钉的待办功能怎么实现?我看着官网的流程下来,发送完之后没有收到代办?
本文对比了钉钉官方教程与实际操作界面的差异。根据官网教程(链接已附),开发员工待办任务应参考相关步骤,但实际页面中存在不一致情况:1) 缺少JSON-SCHEMA选项,需输入JSON处无法匹配;2) 连接流配置中仅有出参配置,未发现教程提及的入参配置。这些问题可能导致开发者在实现过程中遇到障碍,建议钉钉更新文档或优化界面以保持一致性。
|
11月前
|
人工智能 缓存 安全
钉钉 + AI 网关给 DeepSeek 办入职
通过 Open-WebUI 在企业内部部署一套 DeepSeek 只是第一步,给 DeepSeek 办理入职,在钉钉等企业通讯工具上和 DeepSeek 对话才是真时尚。
530 104
钉钉 + AI 网关给 DeepSeek 办入职
|
监控 物联网
工业智能网关实现北向自定义报文配置流程
北向接口是设备连接物联网云平台的接口,允许云平台统一监管各厂商设备的运行与报警状态。为解决不同公司报文格式差异导致的数据解析问题,工业智能网关支持北向自定义报文功能,用户可配置不同的报文格式,确保数据准确传输。配置流程包括网关中心、IOT数据云平台和配置工具的设置,最终通过日志或MQTTfx验证上报情况。
353 4
|
人工智能 移动开发 IDE
安利几款与钉钉平台无缝集成打通账号认证的企业文档管理系统
钉钉是很多中小企业都爱用的产品,开通账号就能直接使用了,应用生态非常丰富,尤其是AI技术的应用,走在行业前列。但仍有很多企业对于全面拥抱SaaS服务充满了顾虑,尤其在内部资料的管理这块,即使钉钉在线文档已经提供了非常优秀的协作体验,不少客户仍更偏爱私有部署在局域网里面的企业文档管理系统。那么能将企业内部部署的文档管理系统集成到钉钉平台上面,和钉钉文档并行使用呢?市面上又有哪些企业文档管理系统软件支持与钉钉的集成呢?这也是很多企业客户的疑问。
安利几款与钉钉平台无缝集成打通账号认证的企业文档管理系统
|
存储 安全 API
"解锁企业级黑科技!用阿里云视觉智能打造钉钉级人脸打卡系统,安全高效,让考勤管理秒变智能范儿!"
【8月更文挑战第14天】随着数字化办公的发展,人脸打卡成为企业考勤的新标准。利用阿里云视觉智能开放平台构建类似钉钉的人脸打卡系统,其关键在于:高精度人脸识别API支持复杂场景下的快速检测与比对;活体检测技术防止非生物特征欺骗,确保安全性;云端存储与计算能力满足大数据处理需求;丰富的SDK与API简化集成过程,实现高效、安全的考勤管理。
516 2
|
XML 算法 API
访问者模式问题之钉钉审批流程配置为什么适合使用访问者模式
访问者模式问题之钉钉审批流程配置为什么适合使用访问者模式
|
移动开发 前端开发
基于flowable没有规则的并发网关流程跳转记录分析
基于flowable没有规则的并发网关流程跳转记录分析
358 0
|
移动开发 前端开发
flowable流程跳转或退回到网关上的用户节点后流程走不下去了
flowable流程跳转或退回到网关上的用户节点后流程走不下去了
1266 2
|
移动开发 前端开发
flowable多对并发网关跳转的分析
flowable多对并发网关跳转的分析
306 0