一、启动流程的时候设置流程变量

  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之启动流程/完成任务的时候设置流程变量的更多相关文章

  1. Unary模式下客户端创建 default-executor 和 resolver-executor 线程和从启动到执行grpc_connector_connect的主要流程

    (原创)C/C/1.25.0-dev grpc-c/8.0.0, 使用的例子是自带的例子GreeterClient 创建 default-executor 和 resolver-executor 线程 ...

  2. activiti7启动流程实例,动态设置assignee人

    package com.zcc.activiti03; import org.activiti.engine.ProcessEngine;import org.activiti.engine.Proc ...

  3. linux基础-第十四单元 Linux网络原理及基础设置

    第十四单元 Linux网络原理及基础设置 三种网卡模式图 使用ifconfig命令来维护网络 ifconfig命令的功能 ifconfig命令的用法举例 使用ifup和ifdown命令启动和停止网卡 ...

  4. Android Framework层Power键关机流程(二,关机流程)

    二,关机流程 从前一篇博文我们知道,当用户长按Power键时会弹出(关机.重启,飞行模式等选项)对话框,我们点击关机,则会弹出关机确认对话框.那么从选项对话框到关机确认对话框又是一个什么流程呢.下面我 ...

  5. MD中bitmap源代码分析--设置流程

    1. 同步/异步刷磁盘 Bitmap文件写磁盘分同步和异步两种: 1) 同步置位:当盘阵有写请求时,对应的bitmap文件相应bit被置位,bitmap内存页被设置了DIRTY标志.而在下发写请求给磁 ...

  6. Slickflow.NET 开源工作流引擎高级开发(一) -- 流程外部事件的调用和变量存储实现

    前言:流程实现基本流转功能外,通常也需要调用外部事件,用于和业务系统的交互,同时存储一些流程变量,用于追踪和记录业务数据变化对流程流转的影响. 1. 流程事件 流程执行过程中,伴随各种事件的发生,而且 ...

  7. JBPM4.4_jBPM4.4的流程定义语言(设计流程)

    1. jBPM4.4的流程定义语言(设计流程) 1.1. process(流程) 是.jpdl.xml的根元素,可以指定的属性有: 属性名 作用说明 name 流程定义的名称,用于显示. key 流程 ...

  8. 以太网驱动的流程浅析(一)-Ifconfig主要流程【原创】

    以太网驱动的流程浅析(一)-Ifconfig主要流程 Author:张昺华 Email:920052390@qq.com Time:2019年3月23日星期六 此文也在我的个人公众号以及<Lin ...

  9. 【干货分享】流程DEMO-固定资产转移流程

    流程名: 固定资产转移  业务描述: 固定资产从某员工转移至另一员工,转出人与转入人必须不同  流程相关文件: 流程包.xml  流程说明: 直接导入流程包文件,即可使用本流程  表单:  流程:  ...

随机推荐

  1. 制作A4纸打印的网页像素大小设置(转)

    公司内做系统,要用A4纸打印东西,A4纸标准时mm,换算成像素不知道.网上找找,找到一篇文章,转一下,备用. A4纸的尺寸是210mm*297mm,也就是21.0cm*29.7cm,而1英寸=2.54 ...

  2. OpenJudge计算概论-数字求和

    /*========================================================= 数字求和 总时间限制: 1000ms 内存限制: 65536kB 描述 给定一个 ...

  3. O(n) O(log n) blist: an asymptotically faster list-like type for Python

    https://pypi.org/project/blist/ blist: an asymptotically faster list-like type for Python — blist 1. ...

  4. LC 918. Maximum Sum Circular Subarray

    Given a circular array C of integers represented by A, find the maximum possible sum of a non-empty ...

  5. GPS nmealib学习 问题

    When building on Ubuntu 12.x the build fails with the following error… gcc  samples/generate/main.o ...

  6. mysql通过binlog恢复删除数据

    删除误操作有时会意外出现,如果你有备份表数据的好习惯,那么至少你可以追回备份前的那些数据.如果我们打开了mysql的binlog,那么可以通过它的增量操作日志来恢复数据.怎么打开binlog前篇已有说 ...

  7. mysql 对应数据库服务器配置 所能承受的tps和qps

    总结: 吞吐量实际涵盖了TPS 和 QPS TPS 是指产生事物的请求,比如对数据库 增.删.改 QTP 是对数据库查询动作,无逻辑非事物,比如 查询 假如脚本里面都是get请求,那么出来的吞吐量就是 ...

  8. Mysql常见索引介绍

    索引是一种特殊的文件,包含了对数据表中所有记录的引用指针.InnoDB引擎的数据库,其上的索引是表空间的一个组成部分. (1).索引的优缺点 优点:加快搜索速度,减少查询时间 缺点:索引是以文件的形式 ...

  9. 数据链路层学习之LLDP

    数据链路层学习之LLDP 2013年09月02日 20:38:36 goodluckwhh 阅读数 42323   一.LLDP协议概述 随着网络技术的发展,接入网络的设备的种类越来越多,配置越来越复 ...

  10. Centos7之pacemaker高可用安装配置详解

    申明: centos7的pacemaker与6使用的方法不一致,即使用centos6.x的方法在centos7.x上面配置pacemaker不能成功. 因此openstack 上面的centos7.1 ...