(十)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 流程说明: 直接导入流程包文件,即可使用本流程 表单: 流程: ...
随机推荐
- python文件导出exe可执行程序
开门见山的说: 1.安装pyinstaller.(windows 用pip3 Mac 用pip)在cmd中输入:pip3 install pyinstaller 2.找到你要打包的文件的目录的上一个目 ...
- Windows 自动定时执行任务的方法
windows 自动定时执行任务的几种实现方法 Task Schedul Windows自动定时执行任务,常见的方法有三种: Windows 任务计划程序 Windows Service SQL ...
- VMware vSphere Client中启动虚拟机提示No boot filename received/Operating System not found解决方法
昨天下载安装 .NET Framework 3.5 SP1解决了VMware vSphere Client安装问题后,今天需要远程连接服务器搭建一台虚拟机. 根据指引步骤进行下一步.下一步的操作完成后 ...
- angular点击事件和表单事件
<div style="text-align:center"> <h1> Welcome to {{ title }}! </h1> <b ...
- 123457123457#0#-----com.threeapp.mouseRunner01----儿童老鼠跑酷游戏
com.threeapp.mouseRunner01----儿童老鼠跑酷游戏
- 第一个php文件运行
运行会发现报错,解决参考:写的很详细 http://blog.csdn.net/meegomeego/article/details/36020553
- 持续集成 Jenkins +Gitlab + SSH 自动发布 HTML 代码
目录 一.整体流程 二.Jenkins 配置 2.1.首先安装插件 2.2.配置目标服务器 2.3.创建 job 2.4.配置 gitlab 触发 三.改进 一.整体流程 二.Jenkins 配置 2 ...
- 《CNCF × Alibaba云原生技术公开课》知识点自测(二):容器基本概念
(单选)1.已运行 docker run -d -t —name demo ubuntu top 和 docker run --name demo-x --pid container:demo ubu ...
- laydate时间控件:开始时间,结束时间最大最小值
时间控件地址及插件下载链接:https://www.layui.com/doc/modules/laydate.html 填充时间已两个功能为例: 1.添加功能 :时间 规则:选择开始时间后,点击结束 ...
- 【ARM-Linux开发】TI 关于Gstreamer使用的几个参考
http://processors.wiki.ti.com/index.php/Example_GStreamer_Pipelines#H.264_RTP_Streaming http://proce ...