有两个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 历史流程变量表
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/