/** * 判断流程是否可撤回 * 历史流程节点中最后一个审批人是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());
/** * 查询已办工作流列表 * * @param queryCondition * @return */ public PageInfo<TaskInfoBean> queryTaskHistoryList(TaskQueryCondition queryCondition) { PageInfo<TaskInfoBean> page = queryCondition.getPageInfo(); List<TaskInfoBean> list = new ArrayList<>(); try { HistoricTaskInstanceQuery taskQuery = queryCondition.createHistoricTaskInstanceQuery(historyService.createHistoricTaskInstanceQuery()); List<HistoricTaskInstance> taskList = taskQuery.orderByTaskCreateTime().desc().listPage((page.getPageNo() - 1) * page.getPageSize(), page.getPageSize()); page.setCount(taskQuery.count()); for (HistoricTaskInstance task : taskList) { list.add(transToTaskInfoBean(task)); } page.setList(list); } catch (Exception e) { logger.error(e.getMessage(), e); throw new OneBaseException("查询失败:" + e.getMessage()); } return page; }
.taskDefinitionKey(task.getTaskDefinitionKey()).executionId(executionId).orderByHistoricTaskInstanceEndTime().desc().list();