List<ProcessInstance> instanceList = runtimeService.createProcessInstanceQuery().startedBy(userName).orderByProcessInstanceId().desc().listPage(currPage,pageSize); List<MyApplication> myApplicationList = new ArrayList<>(); for (ProcessInstance instance : instanceList) { MyApplication myApplication = getApplication(instance); myApplicationList.add(myApplication); } return myApplicationList;
public MyApplication getApplication(ProcessInstance instance){ Task task= taskService.createTaskQuery().processInstanceId(instance.getId()).singleResult(); logger.info("task:"+task+"--instanceId:"+instance.getId()); String heading = runtimeService.getVariable(instance.getId(), "heading", String.class); String title = runtimeService.getVariable(instance.getId(), "title", String.class); MyApplication myApplication = new MyApplication(); myApplication.setTitle(title); myApplication.setApplyUser(instance.getStartUserId()); myApplication.setHeading(heading); myApplication.setTaskId(task.getId()); Date startTimes = instance.getStartTime(); // activiti 6 才有 myApplication.setApplyTime(startTimes); myApplication.setApplyStatus(instance.isEnded() ? "申请结束" : "等待审批"); return myApplication; };