use of com.dtstack.taier.dao.pager.PageResult in project Taier by DTStack.
the class ConsoleService method groupDetail.
public PageResult groupDetail(String jobResource, String nodeAddress, Integer stage, Integer pageSize, Integer currentPage) {
if (StringUtils.isBlank(nodeAddress)) {
nodeAddress = null;
}
List<Map<String, Object>> data = new ArrayList<>();
Long count = 0L;
int start = (currentPage - 1) * pageSize;
try {
count = scheduleEngineJobCacheMapper.countByJobResource(jobResource, stage, nodeAddress);
if (count > 0) {
List<ScheduleEngineJobCache> engineJobCaches = scheduleEngineJobCacheMapper.listByJobResource(jobResource, stage, nodeAddress, start, pageSize);
List<String> jobIds = engineJobCaches.stream().map(ScheduleEngineJobCache::getJobId).collect(Collectors.toList());
List<ScheduleJob> rdosJobByJobIds = scheduleJobMapper.getRdosJobByJobIds(jobIds);
Map<String, ScheduleJob> scheduleJobMap = rdosJobByJobIds.stream().collect(Collectors.toMap(ScheduleJob::getJobId, u -> u));
Set<Long> tenantIds = rdosJobByJobIds.stream().map(ScheduleJob::getTenantId).collect(Collectors.toSet());
Map<Long, Tenant> tenantMap = tenantMapper.selectBatchIds(tenantIds).stream().collect(Collectors.toMap(Tenant::getId, t -> t));
for (ScheduleEngineJobCache engineJobCache : engineJobCaches) {
Map<String, Object> theJobMap = PublicUtil.objectToMap(engineJobCache);
ScheduleJob scheduleJob = scheduleJobMap.getOrDefault(engineJobCache.getJobId(), new ScheduleJob());
// 补充租户信息
Tenant tenant = tenantMap.get(scheduleJob.getTenantId());
this.fillJobInfo(theJobMap, scheduleJob, engineJobCache, tenant);
data.add(theJobMap);
}
}
} catch (Exception e) {
LOGGER.error("groupDetail error", e);
}
PageQuery pageQuery = new PageQuery<>(currentPage, pageSize);
return new PageResult<>(data, count.intValue(), pageQuery);
}
use of com.dtstack.taier.dao.pager.PageResult 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.pager.PageResult 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.pager.PageResult in project Taier by DTStack.
the class TenantService method pageQuery.
public PageResult<List<ClusterTenantVO>> pageQuery(Long clusterId, String tenantName, int pageSize, int currentPage) {
PageQuery query = new PageQuery(currentPage, pageSize, "gmt_modified", Sort.DESC.name());
int count = clusterTenantMapper.generalCount(clusterId, tenantName);
if (count == 0) {
return PageResult.EMPTY_PAGE_RESULT;
}
List<ClusterTenant> clusterTenants = clusterTenantMapper.generalQuery(query, clusterId, tenantName);
List<ClusterTenantVO> clusterTenantVOS = fillQueue(clusterTenants);
return new PageResult(clusterTenantVOS, count, query);
}
use of com.dtstack.taier.dao.pager.PageResult in project Taier by DTStack.
the class DsInfoService method dsPage.
/**
* 数据源列表分页
*
* @param dsListParam
* @return
*/
public PageResult<List<DsListVO>> dsPage(DsListParam dsListParam) {
DsListQuery listQuery = DsListTransfer.INSTANCE.toInfoQuery(dsListParam);
listQuery.turn();
Integer total = this.baseMapper.countDsPage(listQuery);
if (total == 0) {
return new PageResult<>(0, 0, 0, 0, new ArrayList<>());
}
List<DsListBO> dsListBOList = baseMapper.queryDsPage(listQuery);
if (CollectionUtils.isEmpty(dsListBOList)) {
return new PageResult<>(0, 0, 0, 0, new ArrayList<>());
}
List<DsListVO> dsListVOS = new ArrayList<>();
for (DsListBO dsListBO : dsListBOList) {
DsListVO dsListVO = DsListTransfer.INSTANCE.toInfoVO(dsListBO);
String linkJson = dsListVO.getLinkJson();
JSONObject linkData = DataSourceUtils.getDataSourceJson(linkJson);
linkData.put("schemaName", dsListVO.getSchemaName());
dsListVO.setLinkJson(DataSourceUtils.getEncodeDataSource(linkData, true));
dsListVOS.add(dsListVO);
}
return new PageResult<>(dsListParam.getCurrentPage(), dsListParam.getPageSize(), total, dsListVOS);
}
Aggregations