【问题标题】:SpringBoot - activiti - Get ProcessVariablesSpring Boot - activiti - 获取流程变量
【发布时间】:2021-04-22 14:24:25
【问题描述】:

我有这段代码:

    List<ProcessInstance> instances =
                    processEngine.getRuntimeService().createProcessInstanceQuery().processInstanceId(processInstanceId).list();

instances.forEach(this::listProcessInstance);

    private void listProcessInstance (ProcessInstance processInstance) {
    
                log.info("<-------------- ProcessInstance ---------------> {} ", processInstance);
                log.info(String.valueOf(processInstance.getProcessVariables()));
                log.info("<-------------- ProcessInstance --------------->");
    
    
        }

其中 ProcessVariables 为空,但在 tabla 上有信息:

select * from ACT_RU_VARIABLE where PROC_INST_ID_ = 76759;

【问题讨论】:

    标签: java spring spring-boot alfresco activiti


    【解决方案1】:

    出于性能原因,默认查询不返回流程变量。您必须明确告诉查询包含变量:

     List<ProcessInstance> instances = processEngine.getRuntimeService().createProcessInstanceQuery().processInstanceId(processInstanceId).includeProcessVariables().list();
    

    【讨论】:

      【解决方案2】:

      试试下面的代码sn-p,

      ProcessInstanceQuery processInstanceQuery = runtimeService.createProcessInstanceQuery().processInstanceIds(processInstanceIds);
        
          List<ProcessInstance> processInstances = processInstanceQuery.list();
        
          for (ProcessInstance processInstance : processInstances) {
            log.info(processInstance.getId());
            log.info(processInstance.getProcessVariables());
          }
      

      【讨论】:

        猜你喜欢
        • 2021-04-13
        • 1970-01-01
        • 2019-08-03
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2017-01-30
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多