教主的代言人
12:Activiti流程变量的设置与获取
2016-10-5 田大才子

有两个Service可以获取和设置流程变量.


//运行实例获取
RuntimeService runtimeService = processEngine.getRuntimeService();

//任务实例获取
TaskService taskService = processEngine.getTaskService();


#1.设置流程变量的方法

runtimeService.setVariable(executionId, variableName, value)

runtimeService.setVariables(executionId, variables);

taskService.setVariable(taskId, variableName, value);
taskService.setVariables(taskId, variables);

//启动流程实例的同时,可以设置流程变量,用Map集合

runtimeService.startProcessInstanceByKey(processDefinitionKey, variables);

//完成任务的同时,设置流程变量,用Map集合

taskService.complete(taskId, variables)


###########################################

//完成任务的同时,设置流程变量的示例

//使用流程变量来指定任务完成任务后下一个节点的走向

//对应bpmn文件中${message=='重要'}
Map<String, Object> variables = new HashMap<String, Object>();
variables.put("message", "重要");
taskService.complete(taskId,variables);

###########################################


#2.获取流程变量的方法

runtimeService.getVariable(executionId, variableName);
runtimeService.getVariables(executionId);
runtimeService.getVariables(executionId, variableNames);
taskService.getVariable(taskId, variableName);
taskService.getVariables(taskId);
taskService.getVariables(taskId, variableNames);


#3.设置流程变量例子

//3-1.任务ID
String taskId = "2104";

 

//3-2-1.设置基本类型

//使用Local和不使用Local的区别是

//使用的情况,只有在这个任务时有效

//不使用的话,整个流程有效

taskService.setVariableLocal(taskId, "LeaveDays", 5);
taskService.setVariable(taskId, "LeaveDate", new Date());
taskService.setVariable(taskId, "LeaveReason", "回家探亲,一起吃个饭");

 

//3-2-2.设置JavaBean类型

//3-2-2-1.创建一个JavaBean

public class Person implements Serializable {

        //下面这句话必须存在
        private static final long serialVersionUID = 6757393795687480331L;

        //编号
        private Integer id;

        //姓名
        private String name;

        public Integer getId() {
            return id;
        }
        public void setId(Integer id) {
            this.id = id;
        }
        public String getName() {
            return name;
        }
        public void setName(String name) {
            this.name = name;
        }
}
//3-2-2-2.设置流程变量

Person p = new Person();
p.setId(20);
p.setName("翠花");
taskService.setVariable(taskId, "PsersonBean", p);


#4.获取流程变量例子
//4-1.获取基本变量

Integer days = (Integer) taskService.getVariable(taskId, "LeaveDays");
Date date = (Date) taskService.getVariable(taskId, "LeaveDate");
String reason= (String) taskService.getVariable(taskId, "LeaveReason");

 

//4-2.获取JavaBean类型变量

Person p = (Person)taskService.getVariable(taskId, "PsersonBean");

 

#5.设置流程变量关联的数据表

1)act_ru_variable 正在执行的流程变量表

2)act_hi_varinst 历史流程变量表

 

评论:
DavidVam
2025-06-26 05:24 回复
This platform aggregates latest headlines on designer collections and seasonal must-haves, sourced from权威 platforms like Vogue and WWD.
From Gen Z’s bold maximalism to eco-conscious designs, discover insights aligned with fashion week calendars and trade show highlights.
Follow updates on brands like Pronounce and analyses of influencer collaborations featured in Vogue Business.
Learn about design philosophies through features from Inside Fashion Design and Who What Wear UK ’s trend breakdowns.
Whether you seek streetwear trends or shopping recommendations, this site curates content for enthusiasts alike.
https://dubai.luxepodium.com/
DavidVam
2025-06-25 23:30 回复
This platform aggregates latest headlines on runway innovations and emerging styles, sourced from权威 platforms like Vogue and WWD.
From chunky accessories to eco-conscious designs, discover insights aligned with fashion week calendars and trade show highlights.
Follow updates on brands like Pronounce and analyses of celebrity style featured in Vogue Business.
Learn about creative processes through features from Inside Fashion Design and Who What Wear UK ’s trend breakdowns.
Whether you seek streetwear trends or seasonal sales, this site curates content for professionals alike.
https://chrono.luxepodium.com/
DavidVam
2025-06-25 14:08 回复
This platform aggregates latest headlines on designer collections and emerging styles, sourced from权威 platforms like Vogue and WWD.
From chunky accessories to eco-conscious designs, discover insights aligned with fashion week calendars and trade show highlights.
Follow updates on brands like Paul Smith and analyses of influencer collaborations featured in Vogue Business.
Learn about design philosophies through features from Inside Fashion Design and Who What Wear UK ’s trend breakdowns.
Whether you seek luxury editorials or seasonal sales, this site curates content for professionals alike.
https://newyork.luxepodium.com/
如何雇佣刺客
2025-05-04 10:00 回复
在这个网站上,您可以聘请专门从事单次的危险工作的专业人士。
我们整理了大量技能娴熟的从业人员供您选择。
无论需要何种危险需求,您都可以安全找到理想的帮手。
<a href="https://chinese-hitman-assassin.com">雇佣一名杀手</a>
所有作业人员均经过审核,保证您的利益。
平台注重匿名性,让您的危险事项更加顺利。
如果您需要更多信息,请立即联系!
陰莖長大
2023-08-14 21:45 回复
陰莖變長 <a href="https://largexxl-cn.premium4best.eu/">largexxl-cn勃起長度</a> 十大雞雞真相
量陰莖
2022-10-07 21:17 回复
jelq 效果 <a href="http://bigxxlcn.cyou/">台灣男性陰莖</a> 勃起長度
iqika
2022-09-18 03:14 回复
有趣的 博客  <a href="https://okna-pila-2022.premiumwroclaw.eu/">https://okna-pila-2022.premiumwroclaw.eu/</a>
ofyxapuvi
2022-09-18 02:33 回复
最好的 文章  <a href="https://okna-pcv-plastikowe-pila-2022.premiumwroclaw.eu/">https://okna-pcv-plastikowe-pila-2022.premiumwroclaw.eu/</a>
oteqeli
2022-09-18 01:47 回复
有趣的 博客  <a href="https://okna-kielce-2022.premiumwroclaw.eu/">https://okna-kielce-2022.premiumwroclaw.eu/</a>
obucij
2022-09-18 01:06 回复
酷 博客  <a href="https://okna-pcv-plastikowe-kielce-2022.premiumwroclaw.eu/">https://okna-pcv-plastikowe-kielce-2022.premiumwroclaw.eu/</a>
1 2
发表评论:
昵称

邮件地址 (选填)

个人主页 (选填)

内容