use of com.dtstack.taier.develop.vo.develop.query.AllProductGlobalSearchVO in project Taier by DTStack.
the class BatchTaskService method allProductGlobalSearch.
/**
* 查找所有产品提交的任务
*
* @param searchVO
* @return
*/
public List<BatchAllProductGlobalReturnVO> allProductGlobalSearch(AllProductGlobalSearchVO searchVO) {
BatchTask batchTask = developTaskDao.getOne(searchVO.getTaskId());
if (batchTask == null) {
throw new RdosDefineException(ErrorCode.CAN_NOT_FIND_TASK);
}
if (batchTask.getTaskType().intValue() == EScheduleJobType.VIRTUAL.getVal().intValue()) {
throw new RdosDefineException(ErrorCode.VIRTUAL_TASK_UNSUPPORTED_OPERATION);
}
// 过滤掉已经依赖的任务
final List<BatchTaskTask> taskTasks = this.batchTaskTaskService.getByParentTaskId(searchVO.getTaskId());
final List<Long> excludeIds = new ArrayList<>(taskTasks.size());
excludeIds.add(searchVO.getTaskId());
taskTasks.forEach(taskTask -> excludeIds.add(taskTask.getTaskId()));
List<ScheduleTaskShade> scheduleTaskShadeList = taskService.findTaskByTaskName(searchVO.getTaskName(), searchVO.getSelectTenantId(), searchVO.getUserId());
List<ScheduleTaskShade> filterTask = scheduleTaskShadeList.stream().filter(scheduleTask -> !excludeIds.contains(scheduleTask.getTaskId())).collect(Collectors.toList());
Map<Long, Tenant> tenantMap = tenantService.listAllTenant().stream().collect(Collectors.toMap(Tenant::getId, g -> (g)));
List<BatchAllProductGlobalReturnVO> voList = Lists.newArrayList();
for (ScheduleTaskShade scheduleTaskShade : filterTask) {
BatchAllProductGlobalReturnVO vo = new BatchAllProductGlobalReturnVO();
vo.setTaskId(scheduleTaskShade.getTaskId());
vo.setTaskName(scheduleTaskShade.getName());
Tenant tenant = tenantMap.get(scheduleTaskShade.getTenantId());
if (tenant != null) {
vo.setTenantId(tenant.getId());
vo.setTenantName(tenant.getTenantName());
}
voList.add(vo);
}
return voList;
}
Aggregations