基于若依的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、效果如下:

相关推荐
胡耀超1 个月前
解读若依微服务架构图:架构总览、核心模块解析、消息与任务处理、数据存储与缓存、监控与日志
微服务·云原生·架构·若依
想要打 Acm 的小周同学呀1 个月前
若依框架--数据字典设计使用和前后端代码分析
java·vue3·数据字典·若依
胡耀超1 个月前
解读若依框架中的 @Xss 注解
xss·若依
胡耀超1 个月前
解读若依框架中的`@Excel` 和 `@Excels` 注解
java·excel·若依
爱吃土豆的程序员1 个月前
flowable mysql 表名大小写问题
linux·windows·mysql·flowable
bjzhang752 个月前
若依使用 Undertow 替代 Tomcat 容器
tomcat·若依·undertow
bjzhang752 个月前
若依整合 Gitee 登录
gitee·若依
代码拯救不了世界2 个月前
若依框架中的上传图片后如何实现回显到页面的
java·图片上传·若依
bjzhang752 个月前
若依微服务如何获取用户登录信息
若依
bjzhang752 个月前
若依启动项目时配置为 HTTPS 协议
https·若依