use of com.dtstack.taier.dao.domain.po.CountFillDataJobStatusPO 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);
}
Aggregations