关于Activiti工作流中自定义查询和分页

自定义SQL查询:

List histList = historyService.createNativeHistoricTaskInstanceQuery().sql("select * from " + managementService.getTableName(HistoricTaskInstance.class)+" H "
                + "where H.END_TIME_ is not null and H.ASSIGNEE_ like #{userId}  and H.TASK_DEF_KEY_ in ('wareform','outrunform','bpbd') order by H.END_TIME_ desc")
                .parameter("userId", "%"+userId+"%").listPage(firstResult, pageSize);

其中:int firstResult = (pageNo-1)*pageSize;

对于流程变量,单查该表是不起作用的,需要另查

List list =historyService.createHistoricVariableInstanceQuery()
                    .processInstanceId(histTask.getProcessInstanceId())
                    .list();
Map map=new HashMap();
 if(list != null && list.size()>0){
       for(HistoricVariableInstance hvi:list){
            map.put(hvi.getVariableName(), hvi.getValue());
       }
 }

你可能感兴趣的:(工作流,Activiti)