zoukankan      html  css  js  c++  java
  • (九)Activitivi5之使用 RuntimeService 设置和获取流程变量

    一、案例

      /** 
       * 设置流程变量数据 */ @Test public void setVariableValues(){ RuntimeService runtimeService=processEngine.getRuntimeService(); // 任务Service String executionId="90001"; runtimeService.setVariable(executionId, "days", 2); runtimeService.setVariable(executionId, "date", new Date()); runtimeService.setVariable(executionId, "reason", "发烧"); Student student=new Student(); student.setId(1); student.setName("张三"); runtimeService.setVariable(executionId, "student", student); // 存序列化对象 } /** * 获取流程变量数据 */ @Test public void getVariableValues(){ RuntimeService runtimeService=processEngine.getRuntimeService(); // 任务Service String executionId="102501"; Integer days=(Integer) runtimeService.getVariable(executionId, "days"); Date date=(Date) runtimeService.getVariable(executionId, "date"); String reason=(String) runtimeService.getVariable(executionId, "reason"); Student student=(Student) runtimeService.getVariable(executionId, "student"); System.out.println("请假天数:"+days); System.out.println("请假日期:"+date); System.out.println("请假原因:"+reason); System.out.println("请假对象:"+student.getId()+","+student.getName()); }
    • 用RuntimeService 设置/获取变量的方法跟(八)Activiti之流程变量和局部流程变量不同的是,流程变量绑定的是任务ID,如下图
    • 而RuntimeService绑定的是act_ru_execution表的executionId。任务ID随着任务节点的变化而变化,而executionId一般不会改变。

    • 同样,用RuntimeService设置的值同样在接下来的流程都可以获取,知道流程结束
  • 相关阅读:
    利用python做矩阵的简单运算(行列式、特征值、特征向量等的求解)
    numpy.linalg.svd函数
    梯度裁剪(Clipping Gradient):torch.nn.utils.clip_grad_norm
    tf.matmul()报错expected scalar type Float but found Double
    1283 最小周长
    1182 完美字符串
    1091 线段的重叠
    1090 3个数和为0
    1087 1 10 100 1000
    1083 矩阵取数问题
  • 原文地址:https://www.cnblogs.com/shyroke/p/8000606.html
Copyright © 2011-2022 走看看