(十)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 流程说明: 直接导入流程包文件,即可使用本流程 表单: 流程: ...
随机推荐
- ngx.shared.DICT.get 详解
ngx.shared.DICT.get 原文: ngx.shared.DICT.get syntax: value, flags = ngx.shared.DICT:get(key) context: ...
- SQL语言Select经典语句
-- 示例数据 Select * From Employee Select * From Department -- 返回工资最高的员工的信息 Select * From Employee where ...
- lua table操作
求最大值,最小值及长度: function maxn(t) local mn = nil for i, v in pairs(t) do if (mn==nil) then mn=v end if ( ...
- std::function以及std::bind
转自:https://blog.csdn.net/shuilan0066/article/details/82788954 示例1 : 普通函数 void gFunc() { cout << ...
- Maven打包SpringBoot
Pom文件提交plugin <build> <finalName>Site</finalName><!--文件名可自定义--> <plugins& ...
- PAT 甲级 1036 Boys vs Girls (25 分)(简单题)
1036 Boys vs Girls (25 分) This time you are asked to tell the difference between the lowest grade ...
- LeetCode_119. Pascal's Triangle II
119. Pascal's Triangle II Easy Given a non-negative index k where k ≤ 33, return the kth index row o ...
- Mac 高效 软件
彻底卸载软件: cleanmymac 软件转移: AppDelete,选择一个软件归档,换台电脑从归档安装 finder类chrme标签页: XtraFinder
- [转]NopCommerce中的多商店支持:权威指南
[转]NopCommerce中的多商店支持:权威指南 多商店支持是最强大的nopCommerce功能之一.但究竟什么是多店支持?它是谁的?如何在nopCommerce中设置多个商店?在今天的帖子中,我 ...
- gcc 与g++的区别
原文 http://www.cnblogs.com/wb118115/p/5969775.html 什么是gcc / g++ 首先说明:gcc 和 GCC 是两个不同的东西 GCC:GNU Compi ...