当前位置: 首页 > news >正文

基于若依的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 gatewaychildNode.put("incoming", incoming);FlowElement flowElement = ddBpmnModel.getFlowElement(incoming.get(0));// 1.0 先进行边连接, 暂存 nextNodeJSONObject 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,后面的审批人连接有问题,后续修改吧。

http://www.lryc.cn/news/225670.html

相关文章:

  • 【华为OD题库-007】代表团坐车-Java
  • 利用servlet实现对书籍书名、单价、数量等信息的添加,计算总价
  • 一键批量转码:将MP4视频转为MP3音频的简单方法
  • java入门,记一次微服务间feigin请求的问题
  • HarmonyOS应用开发者高级认证(88分答案)
  • 离散Hopfield神经网络分类——高校科研能力评价
  • Run highlighted commands using IDE
  • vscode文件跳转(vue项目)
  • 嵌入式Linux系统中内存分配详解
  • 4、FFmpeg命令行操作4
  • 如何通过命令查看某一文件的内容改动和提交记录
  • 更安全的ssh协议与Gui图形化界面使用
  • ❤ Uniapp使用 ( 三 配置和各种使用篇)
  • k8s 创建普通用户使用
  • 【微软技术栈】C#.NET 依赖项注入
  • 评国青、优青、杰青,到底需要什么级别的文章?五篇代表作如何选?
  • 使用双动态令牌混合器学习全局和局部动态以进行视觉识别
  • Flutter笔记 - 关于 fit 属性以及相关知识的总结
  • 如何在PPT中去除编辑密码?
  • Kotlin库实现多线程爬取数据
  • RT-Thread Env使用
  • 2011年09月21日 Go生态洞察:Go图像处理包
  • 《QT从基础到进阶·十七》QCursor鼠标的不同位置坐标获取
  • K8s----资源管理
  • java.net.UnknownServiceException: CLEARTEXT communication to 127.0.0.1 not p
  • STM32——系统时钟(概述,问题总结)
  • 魔众文库系统 v5.5.0 批量快捷上传,文档图标优化,档转换逻辑优化
  • 52. 携带研究材料
  • 局域网内部服务器访问外部网络
  • IP行业API助力于网络分析和数据挖掘