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)); } } } } }
.processInstanceId(processInstanceId).list(); if (historicTaskInstances != null && historicTaskInstances.size() > 0) { for (HistoricTaskInstance historicTaskInstance : historicTaskInstances) {
.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, "任务被签收或办理,不可撤回"); }
/** * 获得历史任务实例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; }
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; }
.processInstanceId(pi.getInternalId()); if (!taskNames.isEmpty()) //TODO what if there is > 1 task. Activiti API does not support such operation (e.g. in clause in SQL)? q = q.taskName(taskNames.iterator().next());
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)); } } } } }
.processInstanceId(processInstanceId).list(); if (historicTaskInstances != null && historicTaskInstances.size() > 0) { for (HistoricTaskInstance historicTaskInstance : historicTaskInstances) {
} else if (this.historyService.createHistoricTaskInstanceQuery().finished().processInstanceId(processInstanceId) .taskDefinitionKey(this.userTaskId).singleResult() != null) {
taskQuery = taskQuery.processInstanceId(getProcessInstanceId());
.processInstanceId(processInstance.getId()) .orderByHistoricTaskInstanceEndTime().desc() .orderByHistoricTaskInstanceStartTime().desc()
.processInstanceId(processInstance.getId()) .orderByHistoricTaskInstanceEndTime().desc() .orderByTaskCreateTime().desc()
historicQuery.processInstanceId(processInstanceId);
.processInstanceId(processInstance.getId()) .orderByHistoricTaskInstanceEndTime().desc() .orderByHistoricTaskInstanceStartTime().desc()
historicQuery.processInstanceId(processInstanceId);
.processInstanceId(processInstanceId).list(); if (historicTaskInstances != null && historicTaskInstances.size() > 0) { for (HistoricTaskInstance historicTaskInstance : historicTaskInstances) {
query.processInstanceId(queryRequest.getProcessInstanceId());