| | |
| | | public AjaxResult currentFlowTaskForm(String taskId) { |
| | | // 流程变量 |
| | | List<HistoricTaskInstance> hisTaskList = historyService.createHistoricTaskInstanceQuery() |
| | | .includeProcessVariables() |
| | | .finished() |
| | | .taskId(taskId) |
| | | .orderByHistoricTaskInstanceStartTime() |
| | |
| | | return AjaxResult.error("未找到该任务信息"); |
| | | } |
| | | HistoricTaskInstance historicTaskInstance = hisTaskList.get(0); |
| | | Map<String, Object> parameters = historicTaskInstance.getProcessVariables(); |
| | | ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().includeProcessVariables().processInstanceId(historicTaskInstance.getProcessInstanceId()).singleResult(); |
| | | Map<String, Object> parameters = new HashMap<>(); |
| | | if (Objects.nonNull(processInstance)) { |
| | | parameters = processInstance.getProcessVariables(); |
| | | } else { |
| | | // 如果为空,表明流程已经结束 |
| | | HistoricProcessInstance historicProcessInstance = historyService.createHistoricProcessInstanceQuery().includeProcessVariables().processInstanceId(historicTaskInstance.getProcessInstanceId()).singleResult(); |
| | | if (Objects.isNull(historicProcessInstance)) { |
| | | throw new RuntimeException("流程不存在"); |
| | | } |
| | | parameters = historicProcessInstance.getProcessVariables(); |
| | | } |
| | | |
| | | String processInsId = historicTaskInstance.getProcessInstanceId(); |
| | | List<FormDetailVO> beforeNodes = this.getBeforeNodeForm(parameters, |
| | | historicTaskInstance.getFormKey(), |
| | |
| | | @Override |
| | | public AjaxResult flowTaskForm(String taskId) throws Exception { |
| | | Task task = taskService.createTaskQuery().taskId(taskId).singleResult(); |
| | | // 流程变量 |
| | | Map<String, Object> parameters = new HashMap<>(); |
| | | List<FormDetailVO> beforeNodes = new ArrayList<>(); |
| | | // 1. 获取到变量信息,因为任务可能是运行中的也可能是历史任务 |
| | | String processInsId = ""; |
| | | List<HistoricTaskInstance> hisTaskList = historyService.createHistoricTaskInstanceQuery() |
| | | .includeProcessVariables() |
| | | .finished() |
| | | .taskId(taskId) |
| | | .orderByHistoricTaskInstanceStartTime() |
| | | .desc() |
| | | .list(); |
| | | if (CollectionUtils.isNotEmpty(hisTaskList) && Objects.nonNull(hisTaskList.get(0))) { |
| | | parameters = hisTaskList.get(0).getProcessVariables(); |
| | | processInsId = hisTaskList.get(0).getProcessInstanceId(); |
| | | beforeNodes = this.getBeforeNodeForm(parameters, |
| | | hisTaskList.get(0).getFormKey(), |
| | | hisTaskList.get(0).getName(), |
| | | hisTaskList.get(0).getProcessDefinitionId(), |
| | | hisTaskList.get(0).getTaskDefinitionKey(), |
| | | Boolean.FALSE, Boolean.TRUE); |
| | | String processDefId = ""; |
| | | String formKey = ""; |
| | | String taskName = ""; |
| | | String taskDefKey = ""; |
| | | if (Objects.isNull(task)) { |
| | | List<HistoricTaskInstance> hisTaskList = historyService.createHistoricTaskInstanceQuery() |
| | | .finished() |
| | | .taskId(taskId) |
| | | .orderByHistoricTaskInstanceStartTime() |
| | | .desc() |
| | | .list(); |
| | | if (CollectionUtils.isEmpty(hisTaskList) || Objects.isNull(hisTaskList.get(0))) { |
| | | return AjaxResult.error("任务不存在"); |
| | | } |
| | | HistoricTaskInstance hisTask = hisTaskList.get(0); |
| | | processInsId = hisTask.getProcessInstanceId(); |
| | | processDefId = hisTask.getProcessDefinitionId(); |
| | | formKey = hisTask.getFormKey(); |
| | | taskName = hisTask.getName(); |
| | | taskDefKey = hisTask.getTaskDefinitionKey(); |
| | | } else { |
| | | parameters = taskService.getVariables(taskId); |
| | | processInsId = task.getProcessInstanceId(); |
| | | beforeNodes = this.getBeforeNodeForm(parameters, |
| | | task.getFormKey(), |
| | | task.getName(), |
| | | task.getProcessDefinitionId(), |
| | | task.getTaskDefinitionKey(), |
| | | Boolean.FALSE, Boolean.TRUE); |
| | | processDefId = task.getProcessDefinitionId(); |
| | | formKey = task.getFormKey(); |
| | | taskName = task.getName(); |
| | | taskDefKey = task.getTaskDefinitionKey(); |
| | | } |
| | | // 2. 获取流程变量 |
| | | ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().includeProcessVariables().processInstanceId(processInsId).singleResult(); |
| | | Map<String, Object> parameters = new HashMap<>(); |
| | | if (Objects.nonNull(processInstance)) { |
| | | parameters = processInstance.getProcessVariables(); |
| | | } else { |
| | | // 如果为空,表明流程已经结束 |
| | | HistoricProcessInstance historicProcessInstance = historyService.createHistoricProcessInstanceQuery().includeProcessVariables().processInstanceId(processInsId).singleResult(); |
| | | if (Objects.isNull(historicProcessInstance)) { |
| | | throw new RuntimeException("流程不存在"); |
| | | } |
| | | parameters = historicProcessInstance.getProcessVariables(); |
| | | } |
| | | List<FormDetailVO> beforeNodes = new ArrayList<>(); |
| | | beforeNodes = this.getBeforeNodeForm(parameters, |
| | | formKey, |
| | | taskName, |
| | | processDefId, |
| | | taskDefKey, |
| | | Boolean.TRUE, Boolean.TRUE); |
| | | // 判断前置任务是不是和当前任务为同一个executeId |
| | | // 判断当前任务是否被挂起中 |
| | | String finalProcessInsId = processInsId; |