(十)Activitivi5之启动流程/完成任务的时候设置流程变量
一、启动流程的时候设置流程变量
1.1 案例
/**
* 启动流程实例
*/
@Test
public void start() {
Student student=new Student();
student.setId(1);
student.setName("张三"); Map<String, Object> variables=new HashMap<String,Object>();
variables.put("days", 2);
variables.put("date", new Date());
variables.put("reason", "发烧");
variables.put("student", student); ProcessInstance instance=processEngine.getRuntimeService() // 运行时Service
.startProcessInstanceByKey("StudentLeaveProcess",variables); // 流程定义表act_re_procdef的KEY字段值 System.out.println("流程实例ID:"+instance.getId());
System.out.println("流程定义ID:"+instance.getProcessDefinitionId());
}
- 如上述例子流程启动之后,任何任务节点都可以通过excutionId获取到流程变量的值。
/**
* 获取流程变量数据
*/
@Test
public void getVariableValues(){
RuntimeService runtimeService=processEngine.getRuntimeService();
String excutionId="52501";
Integer days=(Integer) runtimeService.getVariable(excutionId, "days");
Date date=(Date) runtimeService.getVariableLocal(excutionId, "date");
String reason=(String) runtimeService.getVariable(excutionId, "reason");
Student student=(Student) runtimeService.getVariable(excutionId, "student");
System.out.println("请假天数:"+days);
System.out.println("请假日期:"+date);
System.out.println("请假原因:"+reason);
System.out.println("请假对象:"+student.getId()+","+student.getName());
}
二、完成任务的时候设置流程变量
2.1 需求
- 在完成某个任务节点之后设置流程变量,接下来的任务节点都可以使用这个流程变量。
比如,当完成“学生请假”任务节点之后设置流程变量,然后在“班长审批”和“班主任审批”节点就可以获取该流程变量。
2.2 案例
/**
* 完成任务
*/
@Test
public void test_completeTask2() { Student student=new Student();
student.setId(1);
student.setName("张三"); Map<String, Object> variables=new HashMap<String,Object>();
variables.put("days", 2);
variables.put("date", new Date());
variables.put("reason", "发烧");
variables.put("student", student); processEngine.getTaskService().complete("62504",variables);
}
/**
* 获取流程变量数据
*/
@Test
public void getVariableValues(){
RuntimeService runtimeService=processEngine.getRuntimeService();
String excutionId="62501";
Integer days=(Integer) runtimeService.getVariable(excutionId, "days");
Date date=(Date) runtimeService.getVariableLocal(excutionId, "date");
String reason=(String) runtimeService.getVariable(excutionId, "reason");
Student student=(Student) runtimeService.getVariable(excutionId, "student");
System.out.println("请假天数:"+days);
System.out.println("请假日期:"+date);
System.out.println("请假原因:"+reason);
System.out.println("请假对象:"+student.getId()+","+student.getName());
}
(十)Activitivi5之启动流程/完成任务的时候设置流程变量的更多相关文章
- Unary模式下客户端创建 default-executor 和 resolver-executor 线程和从启动到执行grpc_connector_connect的主要流程
(原创)C/C/1.25.0-dev grpc-c/8.0.0, 使用的例子是自带的例子GreeterClient 创建 default-executor 和 resolver-executor 线程 ...
- activiti7启动流程实例,动态设置assignee人
package com.zcc.activiti03; import org.activiti.engine.ProcessEngine;import org.activiti.engine.Proc ...
- linux基础-第十四单元 Linux网络原理及基础设置
第十四单元 Linux网络原理及基础设置 三种网卡模式图 使用ifconfig命令来维护网络 ifconfig命令的功能 ifconfig命令的用法举例 使用ifup和ifdown命令启动和停止网卡 ...
- Android Framework层Power键关机流程(二,关机流程)
二,关机流程 从前一篇博文我们知道,当用户长按Power键时会弹出(关机.重启,飞行模式等选项)对话框,我们点击关机,则会弹出关机确认对话框.那么从选项对话框到关机确认对话框又是一个什么流程呢.下面我 ...
- MD中bitmap源代码分析--设置流程
1. 同步/异步刷磁盘 Bitmap文件写磁盘分同步和异步两种: 1) 同步置位:当盘阵有写请求时,对应的bitmap文件相应bit被置位,bitmap内存页被设置了DIRTY标志.而在下发写请求给磁 ...
- Slickflow.NET 开源工作流引擎高级开发(一) -- 流程外部事件的调用和变量存储实现
前言:流程实现基本流转功能外,通常也需要调用外部事件,用于和业务系统的交互,同时存储一些流程变量,用于追踪和记录业务数据变化对流程流转的影响. 1. 流程事件 流程执行过程中,伴随各种事件的发生,而且 ...
- JBPM4.4_jBPM4.4的流程定义语言(设计流程)
1. jBPM4.4的流程定义语言(设计流程) 1.1. process(流程) 是.jpdl.xml的根元素,可以指定的属性有: 属性名 作用说明 name 流程定义的名称,用于显示. key 流程 ...
- 以太网驱动的流程浅析(一)-Ifconfig主要流程【原创】
以太网驱动的流程浅析(一)-Ifconfig主要流程 Author:张昺华 Email:920052390@qq.com Time:2019年3月23日星期六 此文也在我的个人公众号以及<Lin ...
- 【干货分享】流程DEMO-固定资产转移流程
流程名: 固定资产转移 业务描述: 固定资产从某员工转移至另一员工,转出人与转入人必须不同 流程相关文件: 流程包.xml 流程说明: 直接导入流程包文件,即可使用本流程 表单: 流程: ...
随机推荐
- activemq jmx
增加: -Djava.rmi.server.hostname=<IP addr>
- javaScript(拼写树形)+ajax请求,去后台查找数据
第一步:页面加载完成时,利用jquery中的一函数,调用js方法,js方法,发送ajax请求,去后台查找父类权限集合,响应回来json格式的数据,对数据进行操作,往页面上添加内容 //页面初始化加载菜 ...
- Centos7.4服务器安装Laravel5.7详细讲解(2018-10-27)
一.在阿里云或者腾讯云选择Centos7并购买服务器 二.安装宝塔面板和php运行环境 1.输入命令 yum install -y wget && wget -O install.sh ...
- 在Springmvc普通类@Autowired注入request为null解决方法
在Springmvc普通类@Autowired注入request为null解决方法 在类中加入以下注入request对象的代码,运行时发现request为null,注入失败.在@Controlle ...
- Python - Django - 编辑作者
在作者列表页面的操作栏中加上编辑按钮 <!DOCTYPE html> <html lang="en"> <head> <meta char ...
- (五)Centos之目录处理命令
一.目录处理命令 linux中 关于目录 有几个重要概念:一个是 / 根目录 还有一个当前用户的家目录 比如 root用户的家目录是 /root ,普通用户的家目录是/home/xxx 下,如下图 ...
- Ubuntu16.04下KeepAlived+Nginx 布署
前言 网上已经有很多相关文章,对各种概念介绍的比较清楚,也有各种详细的步骤,这里主要记录本要在ubuntu16.04下的布署过程,主要记录编译安装keepalived时遇到的坑及解决办 ...
- Selenium ? 也要学...!
一.selenium 简介 Selenium是ThroughtWorks公司一个强大的开源Web功能测试工具系列,包括Selenium-IDE.Selenium-RC.Selenium-Webdriv ...
- php 生成32位随机字符串 用于支付验证 用户注册
//32位随机字符串 function randstrpay($length=32) { $rand=''; $randstr= 'ABCDEFGHIJKLMNOPQRSTUVWXYZ01234567 ...
- Android_7.1.1_r6源码编译
上篇文章讲述了如何下载Android源码,在篇文章就来说一说Android源码编译.其实一般来说如果修改的软件和底层没什么关系,直接提取相应的源代码到Android Studio编译就可以了,如果是与 ...