protected void assertHistoricTasksDeleteReason(ProcessInstance processInstance, String expectedDeleteReason, String ... taskNames) { if (processEngineConfiguration.getHistoryLevel().isAtLeast(HistoryLevel.AUDIT)) { for (String taskName : taskNames) { List<HistoricTaskInstance> historicTaskInstances = historyService.createHistoricTaskInstanceQuery() .processInstanceId(processInstance.getId()).taskName(taskName).list(); assertTrue(historicTaskInstances.size() > 0); for (HistoricTaskInstance historicTaskInstance : historicTaskInstances) { assertNotNull(historicTaskInstance.getEndTime()); if (expectedDeleteReason == null) { assertNull(historicTaskInstance.getDeleteReason()); } else { assertTrue(historicTaskInstance.getDeleteReason().startsWith(expectedDeleteReason)); } } } } }
private List<WorkflowTask> queryHistoricTasks(WorkflowTaskQuery query) { HistoricTaskInstanceQuery historicQuery = createHistoricTaskQuery(query); List<HistoricTaskInstance> results; int limit = query.getLimit(); if (limit > 0) { results = historicQuery.listPage(0, limit); } else { results = historicQuery.list(); } return getValidHistoricTasks(results); }
.processInstanceId(processInstanceId).list(); if (historicTaskInstances != null && historicTaskInstances.size() > 0) { for (HistoricTaskInstance historicTaskInstance : historicTaskInstances) {
private List<WorkflowTask> queryHistoricTasks(WorkflowTaskQuery query) { HistoricTaskInstanceQuery historicQuery = createHistoricTaskQuery(query); List<HistoricTaskInstance> results; int limit = query.getLimit(); if (limit > 0) { results = historicQuery.listPage(0, limit); } else { results = historicQuery.list(); } return getValidHistoricTasks(results); }
.processInstanceId(processInstanceId).list(); if (historicTaskInstances != null && historicTaskInstances.size() > 0) { for (HistoricTaskInstance historicTaskInstance : historicTaskInstances) {
/** * 判断流程是否可撤回 * 历史流程节点中最后一个审批人是userId */ @Override public Result canWithdraw(HistoricProcessInstance processInstance, String userId) { List<HistoricTaskInstance> taskInstances = historyService.createHistoricTaskInstanceQuery().processUnfinished() .processInstanceId(processInstance.getId()).orderByTaskCreateTime().desc().orderByTaskId().desc() .list(); //Task activeTask=taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult(); if (taskInstances.isEmpty() || taskInstances.size() < 2) return new Result(false, null, "已办理,不可撤回"); else { HistoricTaskInstance taskInstance = taskInstances.get(1); HistoricTaskInstance taskCurrent = taskInstances.get(0); //流程审批人未未指定(未签收+未办理) if (StrUtil.isEmpty(taskCurrent.getAssignee())) { if (taskInstance.getAssignee() != null && taskInstance.getAssignee().equals(userId)) { return new Result(true, taskInstance, "可以撤回"); } } //流程定义时指定了办理人,也可以撤回 else if (getTaskState(taskCurrent.getId())) { if (taskInstance.getAssignee() != null && taskInstance.getAssignee().equals(userId)) { return new Result(true, taskInstance, "可以撤回"); } } } return new Result(false, null, "任务被签收或办理,不可撤回"); }
(userId).finished().orderByTaskCreateTime().desc().list(); for (HistoricTaskInstance taskInstance : taskInstances) { processInstanceIdSet.add(taskInstance.getProcessInstanceId());
/** * 获得历史任务实例by流程实例ID * * @param processId * 流程实例ID * @return */ public List<HistoricTaskInstance> getHisTaskByProcessId(String processId) { // historyService = processEngine.getHistoryService(); List<HistoricTaskInstance> historyList = historyService .createHistoricTaskInstanceQuery().processInstanceId(processId) .list(); return historyList; }
/** * simulate task execution * take randomly one task from the history and use its duration for simulation * */ public long simulateTaskExecution(TaskEntity execTask, Map<String, Object> variables) { List<HistoricTaskInstance> historicInstances = historyService.createHistoricTaskInstanceQuery() .taskDefinitionKey( execTask.getTaskDefinitionKey() ).finished().list(); if ( historicInstances.isEmpty() ) //use backupExecutor return backUpExecutor.simulateTaskExecution(execTask, variables); // get random historic instance HistoricTaskInstance historicTask = historicInstances.get( SimUtils.getRandomInt( historicInstances.size() )); //@TODO in version 5.12 use time spend on task return historicTask.getDurationInMillis(); }
.taskAssignee(assignee).list(); if (historicTaskInstances.isEmpty()) { return Repositories.emptyQuery();
protected void initSubTasks() { List<HistoricTaskInstance> subTasks = historyService.createHistoricTaskInstanceQuery() .taskParentTaskId(parentTask.getId()) .list(); initSubTasksLayout(); populateSubTasks(subTasks); }
public void refreshSubTasks() { subTaskLayout.removeAllComponents(); List<HistoricTaskInstance> subTasks = historyService.createHistoricTaskInstanceQuery() .taskParentTaskId(parentTask.getId()) .list(); populateSubTasks(subTasks); }
@Override public List<TaskHistoryVo> records(String busykey) { List<TaskHistoryVo> result = new ArrayList<TaskHistoryVo>(); List<HistoricTaskInstance> instances = historyService.createHistoricTaskInstanceQuery().processInstanceBusinessKey(busykey).list(); if (instances != null) { for (HistoricTaskInstance historicTaskInstance : instances) { List<HistoricVariableInstance> v = historyService.createHistoricVariableInstanceQuery().taskId(historicTaskInstance.getId()).list(); Map<String, Object> maxps = new HashMap<String, Object>(); if (v != null) { for (HistoricVariableInstance historicVariableInstance : v) { maxps.put(historicVariableInstance.getVariableName(), historicVariableInstance.getValue()); } } TaskHistoryVo vo = new TaskHistoryVo(); vo.setNote("" + maxps.get("note")); vo.setUser("" + maxps.get("user")); vo.setState("" + maxps.get("state")); vo.setAddDate(historicTaskInstance.getTime()); if (vo.getState() != null && !"null".equals(vo.getState())) { result.add(vo); } } } return result; }
private BpmTask getMostRecentProcessHistoryTask(final ProcessInstance pi, final UserData user, final Calendar minDate, ProcessToolContext ctx) { HistoryService hs = getProcessEngine().getHistoryService(); HistoricTaskInstanceQuery q = hs.createHistoricTaskInstanceQuery() .taskAssignee(user.getLogin()) .processInstanceId(pi.getInternalId()); q = q.orderByHistoricTaskInstanceEndTime().asc(); List<HistoricTaskInstance> tasks = q.list(); List<HistoricTaskInstance> pastTasks = new ArrayList<HistoricTaskInstance>(); for (HistoricTaskInstance task : tasks) { if (task.getEndTime() != null && task.getEndTime().compareTo(minDate.getTime()) > 0) { pastTasks.add(task); } } if (pastTasks.isEmpty()) return null; MutableBpmTask task = collectHistoryActivity(pastTasks.get(0), pi, user); String endTaskName = findEndActivityName(pi, ctx); if (Strings.hasText(endTaskName)) { task.setTaskName(endTaskName); } return task; }
List<HistoricTaskInstance> tasks = q.list(); List<HistoricTaskInstance> pastTasks = new ArrayList<HistoricTaskInstance>(); for (HistoricTaskInstance task : tasks) {
protected void initSubTasks() { subTasksLayout = new VerticalLayout(); subTasksLayout.addStyleName(ExplorerLayout.STYLE_DETAIL_BLOCK); addComponent(subTasksLayout); initSubTaskTitle(); List<HistoricTaskInstance> subTasks = historyService.createHistoricTaskInstanceQuery() .taskParentTaskId(historicTask.getId()) .list(); if (!subTasks.isEmpty()) { initSubTaskGrid(); populateSubTasks(subTasks); } else { initNoSubTasksLabel(); } }
protected void assertHistoricTasksDeleteReason(ProcessInstance processInstance, String expectedDeleteReason, String ... taskNames) { if (processEngineConfiguration.getHistoryLevel().isAtLeast(HistoryLevel.AUDIT)) { for (String taskName : taskNames) { List<HistoricTaskInstance> historicTaskInstances = historyService.createHistoricTaskInstanceQuery() .processInstanceId(processInstance.getId()).taskName(taskName).list(); assertTrue(historicTaskInstances.size() > 0); for (HistoricTaskInstance historicTaskInstance : historicTaskInstances) { assertNotNull(historicTaskInstance.getEndTime()); if (expectedDeleteReason == null) { assertNull(historicTaskInstance.getDeleteReason()); } else { assertTrue(historicTaskInstance.getDeleteReason().startsWith(expectedDeleteReason)); } } } } }
UserInfo user = UserUtil.getCurrentUser(); Page<MyTaskHistoryVo> result = null; List<HistoricTaskInstance> instances = historyService.createHistoricTaskInstanceQuery().taskAssignee(user.getId() + "").list(); List<MyTaskHistoryVo> myTaskHistoryVoList = new ArrayList<MyTaskHistoryVo>(); if (instances != null) {
.processInstanceId(processInstanceId).list(); if (historicTaskInstances != null && historicTaskInstances.size() > 0) { for (HistoricTaskInstance historicTaskInstance : historicTaskInstances) {
.orderByHistoricTaskInstanceEndTime().desc() .orderByHistoricTaskInstanceStartTime().desc() .list();