基于若依的ruoyi-nbcio流程管理系统仿钉钉流程json转bpmn的flowable的xml格式(简单支持发起人与审批人的流程)续

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

gitee源代码地址

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

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

之前生产的xml,在bpmn设计里编辑有些内容不正确,包括审批人,关联表单等,所以这部分修正这些问题。

1、前端增加formKey

对于发起人节点,初始化时进行表单赋值

javascript 复制代码
initStartNodeData(){
      this.initInitiator()
      this.startForm.formOperates = this.initFormOperates(this.value)
      this.startForm.formKey = this.value.properties.formKey
      this.approverForm.formKey = this.value.properties.formKey
    },

同时对确认保存的时候,进行formKey的保存与更新

javascript 复制代码
/**
     * 开始节点确认保存
     */
    startNodeComfirm() {
      this.properties.initiator = this.initiator['dep&user']
      this.properties.formKey = this.startForm.formKey
      const formOperates = this.startForm.formOperates.map(t=>({formId: t.formId, formOperate: t.formOperate}))
      Object.assign(this.properties,this.startForm, {formOperates})
      this.$emit("confirm", this.properties, '所有人');
      this.visible = false;
    },

2、后端修改

对开始发起人节点进行修改,把发起人赋予的formKey写入到开始节点里,兼容现有的系统

java 复制代码
StartEvent createStartEvent(JSONObject flowNode) {
    	String nodeType = flowNode.getString("type");
        StartEvent startEvent = new StartEvent();
        startEvent.setId(id("start"));
        if (Type.INITIATOR_TASK.isEqual(nodeType)) {
        	JSONObject properties = flowNode.getJSONObject("properties");
        	if(StringUtils.isNotEmpty(properties.getString("formKey"))) {
        		startEvent.setFormKey(properties.getString("formKey"));
        	}
        }
        return startEvent;
    }

同时对创建用户任务进行修改,修正之前的用户信息与formKey信息

java 复制代码
String createUserTask(JSONObject flowNode, String nodeType) {
        List<String> incoming = flowNode.getJSONArray("incoming").toJavaList(String.class);
        // 自动生成id
        String id = id("userTask");
        if (incoming != null && !incoming.isEmpty()) {
        	UserTask userTask = new UserTask();
        	JSONObject properties = flowNode.getJSONObject("properties");
        	userTask.setName(properties.getString("title"));
        	userTask.setId(id);
        	List<ExtensionAttribute> attributes = new  ArrayList<ExtensionAttribute>();
        	if (Type.INITIATOR_TASK.isEqual(nodeType)) {
        		ExtensionAttribute extAttribute =  new ExtensionAttribute();
        		extAttribute.setNamespace(ProcessConstants.NAMASPASE);
        		extAttribute.setName("dataType");
        		extAttribute.setValue("INITIATOR");
        		attributes.add(extAttribute);
        		userTask.addAttribute(extAttribute);
        		//userTask.setFormKey(properties.getString("formKey"));
        		userTask.setAssignee("${initiator}");
        	} else if (Type.USER_TASK.isEqual(nodeType) || Type.APPROVER_TASK.isEqual(nodeType)) {
        		JSONArray approvers = properties.getJSONArray("approvers");
        		JSONObject approver = approvers.getJSONObject(0);
        		ExtensionAttribute extDataTypeAttribute =  new ExtensionAttribute();
        		extDataTypeAttribute.setNamespace(ProcessConstants.NAMASPASE);
        		extDataTypeAttribute.setName("dataType");
        		extDataTypeAttribute.setValue("USERS");
        		userTask.addAttribute(extDataTypeAttribute);
        		ExtensionAttribute extTextAttribute =  new ExtensionAttribute();
        		extTextAttribute.setNamespace(ProcessConstants.NAMASPASE);
        		extTextAttribute.setName("text");
        		extTextAttribute.setValue(approver.getString("nickName"));
        		userTask.addAttribute(extTextAttribute);
        		userTask.setFormKey(properties.getString("formKey"));
        		userTask.setAssignee(approver.getString("userName"));
        	}
        	
            ddProcess.addFlowElement(userTask);
            ddProcess.addFlowElement(connect(incoming.get(0), id));
        }
        return id;
    }

3、效果如下:

相关推荐
伍一518 天前
03-文件管理模块-一个看似简单的模块藏着多少细节
java·ruoyi·若依
假客套11 天前
记一次若依 Excel 导出踩坑:Permission denied、401 报错完整排查记录
java·若依·linux服务器
RuoyiOffice11 天前
SpringBoot3+Vue3 会议室预订系统:时段冲突三模式检测 + 会前定时提醒与 cancelByBiz
spring boot·vue3·flowable·消息中心·spring boot 3·会议室·时段冲突
大龄码农有梦想13 天前
Camunda 7 与 Camunda 8 不是升级关系:架构差异与选型边界
activiti·flowable·流程引擎·camunda·开源工作流·开源工作流引擎
天丁o22 天前
我把一套 Flowable + Spring Boot + Vue 的 BPM 流程引擎整理开源了:从流程设计器到待办闭环
spring boot·vue·工作流引擎·flowable·bpm流程引擎·流程审批
EntyIU24 天前
Flowable流程开发笔记
笔记·flowable
pursue.dreams1 个月前
基于若依(RuoYi)二次开发的自营商城系统:从架构设计到落地的全栈实践
uniapp·商城·若依
qq_185198691 个月前
骆驼任务Flowable + Apache Camel 集成
spring·apache·flowable
驰骋工作流1 个月前
开源 BPM 工作流引擎六方对比选型分析(java领域)
开源·工作流引擎·flowable·camunda·jflow·ccflow
xrl20123 个月前
JeecgBoot集成Activiti工作流实现定时器案例
activiti·定时器·flowable·camunda·jeecgboot