基于jeecg-boot的flowable流程加签功能实现

这篇具有很好参考价值的文章主要介绍了基于jeecg-boot的flowable流程加签功能实现。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

   

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

gitee源代码地址

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

前端代码:https://gitee.com/nbacheng/nbcio-vue.git

在线演示(包括H5) : http://122.227.135.243:9888

      今天我们实现nbcio-boot的flowable的流程加签功能。

一、加签的几个概念

1、向前加签

任务在 A 这里,A 这个时候需要 B 核对一下,等 B 核对之后又回到 A 这里,这时 A 才能继续自己的任务

2、向后加签

任务在 A 这里,A 这个时候需要 B 处理这个事情,处理完毕之后就不用管了,继续后面的审批环节

3、多实例加签

任务只能对多实例任务进行加签,其它无效

二、前端实现

界面代码如下:

<!--加签流程-->
    <a-modal :z-index="100" :title="addSignTitle" @cancel="addSignOpen = false" :visible.sync="addSignOpen" :width="'40%'" append-to-body>
      <el-form ref="addSignForm" :model="addSignForm" label-width="160px">
        <el-form-item label="加签类型" prop="addSignType" :rules="[{ required: true, message: '请选择加签类型', trigger: 'blur' }]">
          <el-radio-group v-model="addSignForm.addSignType" @change="changeAddSignType">
              <el-radio :label="0">前加签</el-radio>
              <el-radio :label="1">后加签</el-radio>
              <el-radio :label="2">多实例加签</el-radio>
            </el-radio-group>
        </el-form-item>
        <el-form-item label="用户选择" prop="addSignUsers" :rules="[{ required: true, message: '请选择用户', trigger: 'blur' }]">
          <j-select-user-by-dep v-model="addSignForm.addSignUsers" />
        </el-form-item>
        <el-form-item label="处理意见" prop="comment" :rules="[{ required: true, message: '请输入处理意见', trigger: 'blur' }]">
          <el-input type="textarea" v-model="addSignForm.comment" placeholder="请输入处理意见" />
        </el-form-item>
        <el-form-item label="附件"  prop="commentFileDto.fileurl">
          <j-upload v-model="addSignForm.commentFileDto.fileurl"   ></j-upload>
        </el-form-item>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button @click="addSignOpen = false">取 消</el-button>
        <el-button type="primary" @click="addSignComplete(true)">确 定</el-button>
      </span>
    </a-modal>

加签实现代码如下:

/** 加签 */
      handleAddSign() {
        this.addSignOpen = true;
        this.addSignTitle = "前加签流程";
      },
      changeAddSignType(val) {
        this.addSignForm.addSignType = val;
        if(this.addSignForm.addSignType === 0) {
          this.addSignTitle = "前加签流程";
        }
        if(this.addSignForm.addSignType === 1) {
          this.addSignTitle = "后加签流程";
        }
        if(this.addSignForm.addSignType === 2) {
          this.addSignTitle = "多实例加签流程";
        }
        console.log("changeAddSignType =",val);
        console.log("this.addSignTitle =",this.addSignTitle);
      },
      /** 加签任务 */
      addSignComplete() {
        if (!this.addSignForm.addSignUsers ) {
            this.$message.error("请选择用户");
            return;
        }
        // 流程信息
        this.addSignForm.deployId = this.$route.query && this.$route.query.deployId;
        this.addSignForm.taskId = this.$route.query && this.$route.query.taskId;
        this.addSignForm.procInsId = this.$route.query && this.$route.query.procInsId;
        this.addSignForm.instanceId = this.$route.query && this.$route.query.procInsId;
        // 初始化表单
        this.addSignForm.procDefId = this.$route.query && this.$route.query.procDefId;
        this.addSignForm.businessKey = this.$route.query && this.$route.query.businessKey;
        this.addSignForm.category = this.$route.query && this.$route.query.category;
        this.addSignForm.dataId = this.$route.query && this.$route.query.businessKey;
        //节点类型
        this.addSignForm.nodeType = this.$route.query && this.$route.query.nodeType;
        //online表单id和数据id
        this.addSignForm.onlineId = this.$route.query && this.$route.query.onlineId;
        if (this.addSignForm.category === 'online') {
          this.addSignForm.onlineDataId = this.$route.query && this.$route.query.businessKey;
        }  
        //对formdesigner后续加签审批的时候需要用到
        this.addSignForm.values = this.taskForm.values;
        console.log("this.addSignForm=",this.addSignForm);
        
        if(this.addSignForm.addSignType === 2) {
          multiInstanceAddSignTask(this.addSignForm).then(response => {
          this.$message.success(response.message);
          this.addSignOpen = false;
          this.goBack();
          });
        }
        else {
          addSignTask(this.addSignForm).then(response => {
          this.$message.success(response.message);
          this.addSignOpen = false;
          this.goBack();
          });
        }
      },

实现效果图如下:

基于jeecg-boot的flowable流程加签功能实现,nbcio-boot,jeecg-boot,java开发,vue.js,前端,flowable

三、后端主要代码

@Override
	public void addTasksBefore(String processInstanceId, String assignee, Set<String> assignees, String description) {
		addTask(processInstanceId, assignee, assignees, description, Boolean.FALSE);
		
	}

	@Override
	public void addTasksAfter(String processInstanceId, String assignee, Set<String> assignees, String description) {
		addTask(processInstanceId, assignee, assignees, description, Boolean.TRUE);
		
	}

	@Override
	@Transactional(rollbackFor = Exception.class)
	public void addTask(String processInstanceId, String assignee, Set<String> assignees, String description,
			Boolean flag) {
		TaskEntityImpl task = (TaskEntityImpl) taskService.createTaskQuery().processInstanceId(processInstanceId).taskAssignee(assignee).singleResult();
        Assert.notNull(task, String.format("分配人 [%s] 没有待处理任务", assignee));

        //如果是加签再加签
        String parentTaskId = task.getParentTaskId();
        if (StrUtil.isBlank(parentTaskId)) {
            task.setOwner(assignee);
            task.setAssignee(null);
            task.setCountEnabled(true);
            if (flag) {
                task.setScopeType("after");
            } else {
                task.setScopeType("before");
            }
            // 设置任务为空执行者
            taskService.saveTask(task);
        }
        //添加加签数据
        this.createSignSubTasks(assignee, assignees, task);
        //添加审批意见
        String type = flag ? FlowComment.HJQ.getType() : FlowComment.QJQ.getType();
        taskService.addComment(task.getId(), processInstanceId, type, description);
		
	}
	
	/**
     * 创建加签子任务
     * @param assignees 被加签人
     * @param assignee 加签人
     * @param taskEntity 父任务
     */
    private void createSignSubTasks(String assignee, Set<String> assignees, TaskEntity taskEntity) {
        if (CollectionUtil.isNotEmpty(assignees)) {
        	//1.创建被加签人的任务列表
            assignees.forEach(userId -> {
                if (StrUtil.isNotBlank(userId)) {
                    this.createSubTask(taskEntity, taskEntity.getId(), userId);
                }
            });
        	
            String parentTaskId = taskEntity.getParentTaskId();
            if (StrUtil.isBlank(parentTaskId)) {
                parentTaskId = taskEntity.getId();
            }
            String finalParentTaskId = parentTaskId;
            //2.创建加签人的任务并执行完毕
            String taskId = taskEntity.getId();
            if (StrUtil.isBlank(taskEntity.getParentTaskId())) {
                Task task = this.createSubTask(taskEntity, finalParentTaskId, assignee);
                taskId = task.getId();
            }
            Task taskInfo = taskService.createTaskQuery().taskId(taskId).singleResult();
            if (ObjectUtil.isNotNull(taskInfo)) {
                taskService.complete(taskId);
            }
            //如果是候选人,需要删除运行时候选不中的数据。
            long candidateCount = taskService.createTaskQuery().taskId(parentTaskId).taskCandidateUser(assignee).count();
            if (candidateCount > 0) {
                taskService.deleteCandidateUser(parentTaskId, assignee);
            }
        }
    }

	
	
	public String getMultiInstanceActAssigneeParam(String processDefinitionId, String actId) {
        AtomicReference<String> resultParam = new AtomicReference<>();
        ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery()
                .processDefinitionId(processDefinitionId).singleResult();
        //获取bpmnModel并转为modelNode
        BpmnModel bpmnModel = repositoryService.getBpmnModel(processDefinition.getId());
        //获取主流程
        Process mainProcess = bpmnModel.getMainProcess();
        //获取用户任务节点类型,深入子流程
        mainProcess.findFlowElementsOfType(UserTask.class, true).forEach(userTask -> {
            String userTaskId = userTask.getId();
            if (userTaskId.equals(actId)) {
                Object behavior = userTask.getBehavior();
                if (ObjectUtil.isNotNull(behavior)) {
                    //并行多实例节点
                    if (behavior instanceof ParallelMultiInstanceBehavior) {
                        ParallelMultiInstanceBehavior parallelMultiInstanceBehavior =
                                (ParallelMultiInstanceBehavior) behavior;
                        String collectionElementVariable = parallelMultiInstanceBehavior
                                .getCollectionElementVariable();
                        if (ObjectUtil.isNotEmpty(collectionElementVariable)) {
                            resultParam.set(collectionElementVariable);
                        }
                    }
                    //串行多实例节点
                    if (behavior instanceof SequentialMultiInstanceBehavior) {
                        SequentialMultiInstanceBehavior sequentialMultiInstanceBehavior =
                                (SequentialMultiInstanceBehavior) behavior;
                        String collectionElementVariable = sequentialMultiInstanceBehavior
                                .getCollectionElementVariable();
                        if (ObjectUtil.isNotEmpty(collectionElementVariable)) {
                            resultParam.set(collectionElementVariable);
                        }
                    }
                }
            }
        });
        return resultParam.get();
    }

四、实际效果图如下:

基于jeecg-boot的flowable流程加签功能实现,nbcio-boot,jeecg-boot,java开发,vue.js,前端,flowable文章来源地址https://www.toymoban.com/news/detail-665618.html

到了这里,关于基于jeecg-boot的flowable流程加签功能实现的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • 记录一下基于jeecg-boot3.0的待办消息移植记录

        因为之前没有记录,所以还要看代码进行寻找,比较费劲,所以今天记录一下: 1、后端 SysAnnouncementController 下面函数增加待办的几个显示内容给前端用  具体代码如下: 2、前端 HeaderNotice.vue 文件 获取系统消息里增加待办内容   同时显示的地方做调整,包括样式与内容

    2024年02月12日
    浏览(29)
  • 基于jeecg-boot的nbcio-boot亿事达企业管理平台发布

    目前这个演示系统与代码都同步,以后也尽量保持同步。 更多功能看演示系统 gitee源代码地址 后端代码: https://gitee.com/nbacheng/nbcio-boot 前端代码:https://gitee.com/nbacheng/nbcio-vue.git 在线演示(包括H5) : http://122.227.135.243:9888   这次主要更新增加的内容如下: 1、我的日历    

    2024年02月17日
    浏览(35)
  • Jeecg-Boot /jeecg-boot/jmreport/qurestSql接口sql注入漏洞复现

    一、Jeecg-Boot介绍 JeecgBoot 是一款基于代码生成器的 低代码开发平台 !前后端分离架构 SpringBoot2.x,SpringCloud,Ant DesignVue,Mybatis-plus,Shiro,JWT,支持微服务。强大的代码生成器让前后端代码一键生成,实现低代码开发! JeecgBoot 引领新的低代码开发模式(OnlineCoding- 代码生成器

    2024年02月09日
    浏览(31)
  • jeecg-boot批量导入问题注意事项

    由于批量导入数据速度很快, 因为数据库中的create time字段的时间可能一样,并且jeecg框架自带的是根据生成时间排序, 因此在前端翻页查询的时候,数据每次排序可能会不一样, 会出现第一页已经出现过一次的数据在第二页还会出现。 在后端的查询接口中,要在拼接一个

    2024年02月12日
    浏览(36)
  • jeecg-boot微服务部署步骤详细说明

    大家好,我是小龙人。 通常小企业是如何成长起来的?接外包,然后将公司慢慢的养起来,最后开始研发自己的产品,产品上线,上市! 哈哈,可能有点理想化了,但是身边好多朋友都自己出去创业了,今儿个张三开了个公司,明儿个李四也注册了个公司,但是了解了下,

    2023年04月09日
    浏览(69)
  • Jeecg-Boot 集成Activiti 6 (含源码)

    本项目是2020 年集成的,采用的是当时版本的Jeecg-Boot,集成时请注意版本。 Jeecg-Boot 免费版没有工作流,于是我简单集成了一套,并且运用于公司项目中。 论坛中的Activiti 功能介绍,都来自该代码。 本项目中是多租户模式,如不需要多租户将想要接口中tenantId 赋值删除即可

    2024年02月16日
    浏览(40)
  • 【vue】vue中Mixins的用法(jeecg-boot为例):

    一、jeecg-boot本身只有JeecgListMixin.js Mixin是为将页面的一些 公共方法 放在一起处理(节省重复性代码,方便维护) 优先级: 页面里面的方法 Mixin里面的方法=》所以维护时要注意查找 二、使用Mixin: 注意: 这里import 导入的js文件,要在js文件里面有导出 三、mixins详解: 【1】由

    2024年02月14日
    浏览(34)
  • Jeecg-Boot 存在前台SQL注入漏洞(CVE-2023-1454)

    微信公众号搜索:南风漏洞复现文库 南风网络安全公众号首发 eecgBoot是一款基于BPM的低代码平台!前后端分离架构 SpringBoot 2.x,SpringCloud,Ant DesignVue,Mybatis-plus,Shiro,JWT,支持微服务。强大的代码生成器让前后端代码一键生成,实现低代码开发#x

    2024年02月06日
    浏览(112)
  • Jeecg-Boot 未授权SQL注入漏洞(CVE-2023-1454)

    原创文章创作不易,个人博客charis3306.top  JDK: 1.8+ (小于11) Maven: 3.5+ MySql: 5.7+ Redis: 3.2 + Node Js: 10.0 + Npm: 5.6.0+ Yarn: 1.21.1+ 下载源码 后端源码 https://github.com/jeecgboot/jeecg-boot/tree/v3.5.0 前端源码 https://github.com/jeecgboot/jeecgboot-vue3 安装手册 http://doc.jeecg.com/2043871 下载完成后放在bc中。

    2024年02月05日
    浏览(30)
  • Jeecg-Boot 低代码开发平台之路(一) —— 开始从零学起

    今天开始详细学习下 Jeecg-Boot 低代码开发平台,官方网站对该平台的介绍是如下。 JeecgBoot是一款基于BPM的低代码平台!前后端分离架构 SpringBoot 2.x,SpringCloud,Ant DesignVue,Mybatis-plus,Shiro,JWT,支持微服务。强大的代码生成器让前后端代码一键生成,实现低代码开发! Jee

    2023年04月08日
    浏览(37)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包