springboot-activiti-get进程变量

js5cn81o  于 2021-07-09  发布在  Java
关注(0)|答案(2)|浏览(336)

我有一段代码:

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为空,但在表上有以下信息:

select * from ACT_RU_VARIABLE where PROC_INST_ID_ = 76759;
flmtquvp

flmtquvp1#

出于性能原因,默认查询不返回流程变量。必须显式地告诉查询包含以下变量:

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

bvjxkvbb2#

尝试以下代码段,

ProcessInstanceQuery processInstanceQuery = runtimeService.createProcessInstanceQuery().processInstanceIds(processInstanceIds);

    List<ProcessInstance> processInstances = processInstanceQuery.list();

    for (ProcessInstance processInstance : processInstances) {
      log.info(processInstance.getId());
      log.info(processInstance.getProcessVariables());
    }

相关问题