use of com.dtstack.taier.dao.domain.ScheduleFillDataJob in project Taier by DTStack.
the class JobService method fillData.
/**
* 生成补数据
*
* @param dto 补数据需要的参数
* @return 补数据标识
*/
public Long fillData(ScheduleFillJobParticipateDTO dto) {
// 必要的校验
checkFillData(dto);
// 生成schedule_fill_data_job数据
ScheduleFillDataJob fillDataJob = buildScheduleFillDataJob(dto);
fillDataJobService.save(fillDataJob);
// 提交补数据任务
ScheduleFillDataInfoDTO fillDataInfo = dto.getFillDataInfo();
fillDataThreadPoolExecutor.submit(new FillDataRunnable(fillDataJob.getId(), dto, fillDataInfo, fillStatusUpdateFinishEvent, applicationContext));
return fillDataJob.getId();
}
use of com.dtstack.taier.dao.domain.ScheduleFillDataJob 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);
}
use of com.dtstack.taier.dao.domain.ScheduleFillDataJob in project Taier by DTStack.
the class JobService method fillDataList.
/**
* 补数据列表
*
* @param dto 查询列表条件
* @return 补数据列表数据
*/
public PageResult<List<ReturnFillDataListVO>> fillDataList(QueryFillDataListDTO dto) {
Page<ScheduleFillDataJob> page = new Page<>(dto.getCurrentPage(), dto.getPageSize());
// 查询补数据列表
page = fillDataJobService.lambdaQuery().like(StringUtils.isNotBlank(dto.getJobName()), ScheduleFillDataJob::getJobName, dto.getJobName()).eq(dto.getOperatorId() != null, ScheduleFillDataJob::getCreateUserId, dto.getOperatorId()).eq(StringUtils.isNotBlank(dto.getRunDay()), ScheduleFillDataJob::getRunDay, dto.getRunDay()).eq(ScheduleFillDataJob::getTenantId, dto.getTenantId()).orderBy(true, false, ScheduleFillDataJob::getGmtCreate).page(page);
List<ScheduleFillDataJob> records = page.getRecords();
List<ReturnFillDataListVO> fillDataReturnListVOs = Lists.newArrayList();
if (CollectionUtils.isNotEmpty(records)) {
// 封装结果集
Map<Long, ScheduleFillDataJob> fillDataJobMap = records.stream().collect(Collectors.toMap(ScheduleFillDataJob::getId, g -> (g)));
List<Long> userIds = records.stream().map(ScheduleFillDataJob::getCreateUserId).collect(Collectors.toList());
Map<Long, User> userMap = userService.getUserMap(userIds);
List<CountFillDataJobStatusPO> statistics = this.baseMapper.countByFillIdGetAllStatus(fillDataJobMap.keySet());
Map<Long, List<CountFillDataJobStatusPO>> statisticsGroup = statistics.stream().collect(Collectors.groupingBy(CountFillDataJobStatusPO::getFillId));
for (ScheduleFillDataJob scheduleFillDataJob : records) {
ReturnFillDataListVO fillDataReturnListVO = FillDataJobMapstructTransfer.INSTANCE.fillDataListDTOToFillDataReturnListVO(scheduleFillDataJob);
User user = userMap.get(scheduleFillDataJob.getCreateUserId());
if (user != null) {
fillDataReturnListVO.setOperatorName(user.getUserName());
}
fillDataReturnListVO.setGmtCreate(DateUtil.getDate(scheduleFillDataJob.getGmtCreate(), DateUtil.STANDARD_DATETIME_FORMAT));
// 计算补数据执行进度
List<CountFillDataJobStatusPO> countFillDataJobStatusPOS = statisticsGroup.get(fillDataReturnListVO.getId());
if (CollectionUtils.isNotEmpty(countFillDataJobStatusPOS)) {
Map<Integer, IntSummaryStatistics> statusCount = countFillDataJobStatusPOS.stream().collect(Collectors.groupingBy(countFillDataJobStatusPO -> TaskStatus.getShowStatus(countFillDataJobStatusPO.getStatus()), Collectors.summarizingInt(CountFillDataJobStatusPO::getCount)));
calculateStatusCount(fillDataReturnListVO, statusCount);
}
fillDataReturnListVOs.add(fillDataReturnListVO);
}
}
return new PageResult<>(dto.getCurrentPage(), dto.getPageSize(), page.getTotal(), (int) page.getPages(), fillDataReturnListVOs);
}
use of com.dtstack.taier.dao.domain.ScheduleFillDataJob in project Taier by DTStack.
the class FillStatusUpdateFinishEvent method finishFill.
@Override
public void finishFill(Long fillId, Integer originalStatus, Integer currentStatus) {
ScheduleFillDataJob updateFillDataJob = new ScheduleFillDataJob();
updateFillDataJob.setFillGenerateStatus(currentStatus);
fillDataJobService.lambdaUpdate().eq(ScheduleFillDataJob::getId, fillId).eq(ScheduleFillDataJob::getFillGenerateStatus, originalStatus).update(updateFillDataJob);
}
use of com.dtstack.taier.dao.domain.ScheduleFillDataJob in project Taier by DTStack.
the class JobService method buildScheduleFillDataJob.
/**
* 封装ScheduleFillDataJob
*
* @param scheduleFillJobParticipateDTO 原数据
* @return ScheduleFillDataJob
*/
private ScheduleFillDataJob buildScheduleFillDataJob(ScheduleFillJobParticipateDTO scheduleFillJobParticipateDTO) {
ScheduleFillDataJob scheduleFillDataJob = new ScheduleFillDataJob();
scheduleFillDataJob.setFillDataInfo(JSON.toJSONString(scheduleFillJobParticipateDTO.getFillDataInfo()));
scheduleFillDataJob.setFillGenerateStatus(FillGeneratStatusEnum.REALLY_GENERATED.getType());
scheduleFillDataJob.setFromDay(scheduleFillJobParticipateDTO.getStartDay());
scheduleFillDataJob.setToDay(scheduleFillJobParticipateDTO.getEndDay());
scheduleFillDataJob.setJobName(scheduleFillJobParticipateDTO.getFillName());
scheduleFillDataJob.setTenantId(scheduleFillJobParticipateDTO.getTenantId());
scheduleFillDataJob.setCreateUserId(scheduleFillJobParticipateDTO.getUserId());
scheduleFillDataJob.setRunDay(DateTime.now().toString(DateUtil.DATE_FORMAT));
scheduleFillDataJob.setGmtCreate(new Timestamp(System.currentTimeMillis()));
scheduleFillDataJob.setGmtModified(new Timestamp(System.currentTimeMillis()));
return scheduleFillDataJob;
}
Aggregations