use of com.dtstack.taier.develop.vo.fill.FillDataJobVO in project Taier by DTStack.
the class JobService method fillDataJobList.
/**
* 补数据实例列表
*
* @param dto 查询列表条件
* @return 列表
*/
public PageResult<ReturnFillDataJobListVO> fillDataJobList(QueryFillDataJobListDTO dto) {
Integer totalCount = 0;
ReturnFillDataJobListVO dataJobDetailVO = new ReturnFillDataJobListVO();
// 查询补数据是否存在,不存在直接返回结果
ScheduleFillDataJob fillDataJob = fillDataJobService.getById(dto.getFillId());
if (!checkFillDataJobList(fillDataJob, dataJobDetailVO)) {
return new PageResult<>(dto.getCurrentPage(), dto.getPageSize(), totalCount, dataJobDetailVO);
}
dataJobDetailVO.setId(fillDataJob.getId());
dataJobDetailVO.setFillDataName(fillDataJob.getJobName());
// 关联任务
List<Long> taskIds = null;
if (StringUtils.isNotBlank(dto.getTaskName()) || dto.getOperatorId() != null) {
List<ScheduleTaskShade> scheduleTaskShadeList = taskService.findTaskByTaskName(dto.getTaskName(), null, dto.getOperatorId());
if (CollectionUtils.isEmpty(scheduleTaskShadeList)) {
return new PageResult<>(dto.getCurrentPage(), dto.getPageSize(), totalCount, dataJobDetailVO);
} else {
taskIds = scheduleTaskShadeList.stream().map(ScheduleTaskShade::getTaskId).collect(Collectors.toList());
}
}
// 查询实例表
Page<ScheduleJob> page = new Page<>(dto.getCurrentPage(), dto.getPageSize());
page = this.lambdaQuery().eq(ScheduleJob::getFlowJobId, 0).eq(ScheduleJob::getIsDeleted, Deleted.NORMAL.getStatus()).eq(ScheduleJob::getTenantId, dto.getTenantId()).eq(ScheduleJob::getFillId, dto.getFillId()).eq(ScheduleJob::getType, EScheduleType.FILL_DATA.getType()).in(ScheduleJob::getFillType, Lists.newArrayList(FillJobTypeEnum.DEFAULT.getType(), FillJobTypeEnum.RUN_JOB.getType())).in(CollectionUtils.isNotEmpty(taskIds), ScheduleJob::getTaskId, taskIds).in(CollectionUtils.isNotEmpty(dto.getTaskTypeList()), ScheduleJob::getTaskType, dto.getTaskTypeList()).in(CollectionUtils.isNotEmpty(dto.getJobStatusList()), ScheduleJob::getStatus, transform(dto.getJobStatusList())).between((dto.getCycStartDay() != null && dto.getCycEndDay() != null), ScheduleJob::getCycTime, getCycTime(dto.getCycStartDay()), getCycTime(dto.getCycEndDay())).orderBy(StringUtils.isNotBlank(dto.getExecTimeSort()), isAsc(dto.getExecTimeSort()), ScheduleJob::getExecTime).orderBy(StringUtils.isNotBlank(dto.getExecStartSort()), isAsc(dto.getExecStartSort()), ScheduleJob::getExecStartTime).orderBy(StringUtils.isNotBlank(dto.getExecEndSort()), isAsc(dto.getExecEndSort()), ScheduleJob::getExecEndTime).orderBy(StringUtils.isNotBlank(dto.getCycSort()), isAsc(dto.getCycSort()), ScheduleJob::getCycTime).orderBy(StringUtils.isNotBlank(dto.getRetryNumSort()), isAsc(dto.getRetryNumSort()), ScheduleJob::getRetryNum).orderBy(Boolean.TRUE, Boolean.FALSE, ScheduleJob::getGmtCreate).page(page);
List<ScheduleJob> records = page.getRecords();
// 封装结果集
if (CollectionUtils.isNotEmpty(records)) {
List<FillDataJobVO> fillDataJobVOS = Lists.newArrayList();
List<Long> taskIdList = records.stream().map(ScheduleJob::getTaskId).collect(Collectors.toList());
Map<Long, ScheduleTaskShade> taskShadeMap = taskService.lambdaQuery().in(ScheduleTaskShade::getTaskId, taskIdList).eq(ScheduleTaskShade::getIsDeleted, Deleted.NORMAL.getStatus()).list().stream().collect(Collectors.toMap(ScheduleTaskShade::getTaskId, g -> (g)));
Map<Long, User> userMap = userService.listAll().stream().collect(Collectors.toMap(User::getId, g -> (g)));
records.forEach(record -> {
FillDataJobVO vo = FillDataJobMapstructTransfer.INSTANCE.scheduleJobToFillDataJobVO(record);
vo.setStartExecTime(DateUtil.getDate(record.getExecStartTime(), DateUtil.STANDARD_DATETIME_FORMAT));
vo.setEndExecTime(DateUtil.getDate(record.getExecEndTime(), DateUtil.STANDARD_DATETIME_FORMAT));
vo.setCycTime(DateUtil.addTimeSplit(record.getCycTime()));
vo.setExecTime(getExecTime(record));
vo.setStatus(TaskStatus.getShowStatus(record.getStatus()));
ScheduleTaskShade scheduleTaskShade = taskShadeMap.get(record.getTaskId());
if (scheduleTaskShade != null) {
vo.setTaskName(scheduleTaskShade.getName());
vo.setOperatorId(scheduleTaskShade.getCreateUserId());
vo.setOperatorName(userMap.get(scheduleTaskShade.getCreateUserId()) != null ? userMap.get(scheduleTaskShade.getCreateUserId()).getUserName() : "");
}
fillDataJobVOS.add(vo);
});
dataJobDetailVO.setFillDataJobVOLists(fillDataJobVOS);
}
dataJobDetailVO.setFillGenerateStatus(FillGeneratStatusEnum.FILL_FINISH.getType());
return new PageResult<>(dto.getCurrentPage(), dto.getPageSize(), page.getTotal(), (int) page.getPages(), dataJobDetailVO);
}
Aggregations