| | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ycl.common.base.Result; |
| | | import com.ycl.common.constant.ProcessConstants; |
| | | import com.ycl.common.core.domain.AjaxResult; |
| | | import com.ycl.common.core.domain.entity.SysDept; |
| | |
| | | import com.ycl.domain.entity.ProjectProcess; |
| | | import com.ycl.domain.entity.SysForm; |
| | | import com.ycl.domain.json.RejectData; |
| | | import com.ycl.domain.vo.DoFormDetailVO; |
| | | import com.ycl.domain.vo.FlowQueryVo; |
| | | import com.ycl.domain.vo.FlowTaskVo; |
| | | import com.ycl.domain.vo.FormDetailVO; |
| | | import com.ycl.domain.query.ProcessLogQuery; |
| | | import com.ycl.domain.vo.*; |
| | | import com.ycl.event.event.TaskLogEvent; |
| | | import com.ycl.factory.FlowServiceFactory; |
| | | import com.ycl.flow.CustomProcessDiagramGenerator; |
| | |
| | | // 判断前置任务是不是和当前任务为同一个executeId |
| | | // 判断当前任务是否被挂起中 |
| | | String finalProcessInsId = processInsId; |
| | | beforeNodes = beforeNodes.stream().filter(node -> { |
| | | List<FormDetailVO> dataList = new ArrayList<>(2); |
| | | Map<String, List<FormDetailVO>> map = new HashMap<>(2); |
| | | beforeNodes.stream().forEach(node -> { |
| | | if (node.getCurrent()) { |
| | | return Boolean.TRUE; |
| | | dataList.add(node); |
| | | } else { |
| | | List<HistoricTaskInstance> beforeTasks = historyService.createHistoricTaskInstanceQuery() |
| | | .processInstanceId(finalProcessInsId) |
| | | .finished() |
| | | .taskDefinitionKey(node.getBeforeNodeDefId()) |
| | | .orderByTaskCreateTime() |
| | | .desc() |
| | | .list(); |
| | | if (CollectionUtils.isNotEmpty(beforeTasks) && Objects.nonNull(beforeTasks.get(0))) { |
| | | List<FormDetailVO> l = map.get(beforeTasks.get(0)); |
| | | if (CollectionUtils.isEmpty(l)) { |
| | | map.put(beforeTasks.get(0).getExecutionId(), Arrays.asList(node)); |
| | | } else { |
| | | l.add(node); |
| | | } |
| | | } |
| | | } |
| | | List<HistoricTaskInstance> beforeTasks = historyService.createHistoricTaskInstanceQuery() |
| | | .processInstanceId(finalProcessInsId) |
| | | .finished() |
| | | .taskDefinitionKey(node.getBeforeNodeDefId()) |
| | | .orderByTaskCreateTime() |
| | | .desc() |
| | | .list(); |
| | | return CollectionUtils.isNotEmpty(beforeTasks) && Objects.nonNull(beforeTasks.get(0)); |
| | | }).collect(Collectors.toList()); |
| | | List<DoFormDetailVO> vos = beforeNodes.stream().map(node -> { |
| | | }); |
| | | for (String key : map.keySet()) { |
| | | if (StringUtils.isNotBlank(key)) { |
| | | // 同一执行器上只取最近的一个 |
| | | dataList.add(map.get(key).get(0)); |
| | | } |
| | | } |
| | | List<DoFormDetailVO> vos = dataList.stream().map(node -> { |
| | | if (node.getCurrent()) { |
| | | if (processLogService.taskIsHangup(taskId, finalProcessInsId)) { |
| | | node.setTaskStatus(TaskStatusEnum.HANGUP); |
| | | } |
| | | } |
| | | // 判断任务是否存在特殊操作(如跳过、转办等),需要在前端展示出来 |
| | | List<ProcessLog> logList = new LambdaQueryChainWrapper<>(processLogService.getBaseMapper()) |
| | | .eq(ProcessLog::getTaskDefKey, node.getBeforeNodeDefId()) |
| | | .eq(ProcessLog::getProcessInsId, finalProcessInsId) |
| | | .orderByDesc(ProcessLog::getGmtCreate) |
| | | .list(); |
| | | ProcessLogQuery query = new ProcessLogQuery(); |
| | | query.setTaskId(taskId); |
| | | query.setProcessInsId(finalProcessInsId); |
| | | Result result = processLogService.projectProcessLogPage(query); |
| | | List<ProcessLogVO> logList = (List<ProcessLogVO>) result.get("data"); |
| | | DoFormDetailVO vo = new DoFormDetailVO(); |
| | | BeanUtils.copyProperties(node, vo); |
| | | if (CollectionUtils.isNotEmpty(logList)) { |
| | |
| | | Map<String, Object> parameters = new HashMap<>(); |
| | | if (Objects.isNull(task)) { |
| | | // 如果为空,可能是任务已经结束 |
| | | HistoricTaskInstance hisTask = historyService.createHistoricTaskInstanceQuery().taskId(taskId).includeProcessVariables().singleResult(); |
| | | if (Objects.isNull(hisTask)) { |
| | | List<HistoricTaskInstance> hisTasks = historyService.createHistoricTaskInstanceQuery() |
| | | .taskId(taskId) |
| | | .finished() |
| | | .includeProcessVariables() |
| | | .orderByTaskCreateTime() |
| | | .desc() |
| | | .list(); |
| | | if (CollectionUtils.isNotEmpty(hisTasks) && Objects.isNull(hisTasks.get(0))) { |
| | | throw new RuntimeException("该任务不存在"); |
| | | } |
| | | HistoricTaskInstance hisTask = hisTasks.get(0); |
| | | parameters = hisTask.getProcessVariables(); |
| | | List<FormDetailVO> beforeNodes = this.getBeforeNodeForm(parameters, hisTask.getFormKey(), hisTask.getName(), hisTask.getProcessDefinitionId(), hisTask.getTaskDefinitionKey(), Boolean.TRUE); |
| | | List<FormDetailVO> dataList = beforeNodes.stream().filter(node -> { |
| | | List<FormDetailVO> dataList = new ArrayList<>(2); |
| | | Map<String, List<FormDetailVO>> map = new HashMap<>(2); |
| | | beforeNodes.stream().forEach(node -> { |
| | | if (node.getCurrent()) { |
| | | return Boolean.TRUE; |
| | | dataList.add(node); |
| | | } else { |
| | | List<HistoricTaskInstance> beforeTasks = historyService.createHistoricTaskInstanceQuery() |
| | | .processInstanceId(hisTask.getProcessInstanceId()) |
| | | .finished() |
| | | .taskDefinitionKey(node.getBeforeNodeDefId()) |
| | | .orderByTaskCreateTime() |
| | | .desc() |
| | | .list(); |
| | | if (CollectionUtils.isNotEmpty(beforeTasks) && Objects.nonNull(beforeTasks.get(0))) { |
| | | List<FormDetailVO> l = map.get(beforeTasks.get(0)); |
| | | if (CollectionUtils.isEmpty(l)) { |
| | | map.put(beforeTasks.get(0).getExecutionId(), Arrays.asList(node)); |
| | | } else { |
| | | l.add(node); |
| | | } |
| | | } |
| | | } |
| | | HistoricTaskInstance beforeTask = historyService.createHistoricTaskInstanceQuery().processInstanceId(hisTask.getProcessInstanceId()).finished().taskDefinitionKey(node.getBeforeNodeDefId()).singleResult(); |
| | | return Objects.nonNull(beforeTask); |
| | | }).collect(Collectors.toList()); |
| | | }); |
| | | for (String key : map.keySet()) { |
| | | if (StringUtils.isNotBlank(key)) { |
| | | // 同一执行器上只取最近的一个 |
| | | dataList.add(map.get(key).get(0)); |
| | | } |
| | | } |
| | | List<DoFormDetailVO> vos = dataList.stream().map(node -> { |
| | | if (node.getCurrent()) { |
| | | if (processLogService.taskIsHangup(taskId, hisTask.getProcessInstanceId())) { |
| | |
| | | } |
| | | } |
| | | // 判断任务是否存在特殊操作(如跳过、转办等),需要在前端展示出来 |
| | | List<ProcessLog> logList = new LambdaQueryChainWrapper<>(processLogService.getBaseMapper()) |
| | | .eq(ProcessLog::getTaskId, hisTask.getId()) |
| | | .eq(ProcessLog::getProcessInsId, hisTask.getProcessInstanceId()) |
| | | .orderByDesc(ProcessLog::getGmtCreate) |
| | | .list(); |
| | | ProcessLogQuery query = new ProcessLogQuery(); |
| | | query.setTaskId(hisTask.getId()); |
| | | query.setProcessInsId(hisTask.getProcessInstanceId()); |
| | | Result result = processLogService.projectProcessLogPage(query); |
| | | List<ProcessLogVO> logList = (List<ProcessLogVO>) result.get("data"); |
| | | DoFormDetailVO vo = new DoFormDetailVO(); |
| | | BeanUtils.copyProperties(node, vo); |
| | | if (CollectionUtils.isNotEmpty(logList)) { |
| | |
| | | } else { |
| | | parameters = taskService.getVariables(taskId); |
| | | List<FormDetailVO> beforeNodes = this.getBeforeNodeForm(parameters, task.getFormKey(), task.getName(), task.getProcessDefinitionId(), task.getTaskDefinitionKey(), Boolean.TRUE); |
| | | List<FormDetailVO> dataList = beforeNodes.stream().filter(node -> { |
| | | List<FormDetailVO> dataList = new ArrayList<>(2); |
| | | Map<String, List<FormDetailVO>> map = new HashMap<>(2); |
| | | beforeNodes.stream().forEach(node -> { |
| | | if (node.getCurrent()) { |
| | | return Boolean.TRUE; |
| | | dataList.add(node); |
| | | } else { |
| | | List<HistoricTaskInstance> beforeTasks = historyService.createHistoricTaskInstanceQuery() |
| | | .processInstanceId(task.getProcessInstanceId()) |
| | | .finished() |
| | | .taskDefinitionKey(node.getBeforeNodeDefId()) |
| | | .orderByTaskCreateTime() |
| | | .desc() |
| | | .list(); |
| | | if (CollectionUtils.isNotEmpty(beforeTasks) && Objects.nonNull(beforeTasks.get(0))) { |
| | | List<FormDetailVO> l = map.get(beforeTasks.get(0)); |
| | | if (CollectionUtils.isEmpty(l)) { |
| | | map.put(beforeTasks.get(0).getExecutionId(), Arrays.asList(node)); |
| | | } else { |
| | | l.add(node); |
| | | } |
| | | } |
| | | } |
| | | List<HistoricTaskInstance> beforeTaskList = historyService.createHistoricTaskInstanceQuery() |
| | | .processInstanceId(task.getProcessInstanceId()) |
| | | .finished() |
| | | .taskDefinitionKey(node.getBeforeNodeDefId()) |
| | | .orderByTaskCreateTime() |
| | | .desc() |
| | | .list(); |
| | | return CollectionUtils.isNotEmpty(beforeTaskList) && Objects.nonNull(beforeTaskList.get(0)); |
| | | }).collect(Collectors.toList()); |
| | | }); |
| | | for (String key : map.keySet()) { |
| | | if (StringUtils.isNotBlank(key)) { |
| | | // 同一执行器上只取最近的一个 |
| | | dataList.add(map.get(key).get(0)); |
| | | } |
| | | } |
| | | List<DoFormDetailVO> vos = dataList.stream().map(node -> { |
| | | if (node.getCurrent()) { |
| | | if (processLogService.taskIsHangup(taskId, task.getProcessInstanceId())) { |
| | |
| | | } |
| | | } |
| | | // 判断任务是否存在特殊操作(如跳过、转办等),需要在前端展示出来 |
| | | List<ProcessLog> logList = new LambdaQueryChainWrapper<>(processLogService.getBaseMapper()) |
| | | .eq(ProcessLog::getTaskId, task.getId()) |
| | | .eq(ProcessLog::getProcessInsId, task.getProcessInstanceId()) |
| | | .orderByDesc(ProcessLog::getGmtCreate) |
| | | .list(); |
| | | ProcessLogQuery query = new ProcessLogQuery(); |
| | | query.setTaskId(task.getId()); |
| | | query.setProcessInsId(task.getProcessInstanceId()); |
| | | Result result = processLogService.projectProcessLogPage(query); |
| | | List<ProcessLogVO> logList = (List<ProcessLogVO>) result.get("data"); |
| | | DoFormDetailVO vo = new DoFormDetailVO(); |
| | | BeanUtils.copyProperties(node, vo); |
| | | if (CollectionUtils.isNotEmpty(logList)) { |