/** * 判断流程是否可撤回 * 历史流程节点中最后一个审批人是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, "任务被签收或办理,不可撤回"); }
historicQuery.processUnfinished();
historicQuery.processUnfinished();
query.processFinished(); } else { query.processUnfinished();