Search in sources :

Example 1 with PageResult

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);
}
Also used : ClusterResource(com.dtstack.taier.pluginapi.pojo.ClusterResource) java.util(java.util) ScheduleJobService(com.dtstack.taier.scheduler.service.ScheduleJobService) com.dtstack.taier.dao.mapper(com.dtstack.taier.dao.mapper) LoggerFactory(org.slf4j.LoggerFactory) PageResult(com.dtstack.taier.dao.pager.PageResult) Autowired(org.springframework.beans.factory.annotation.Autowired) RdosDefineException(com.dtstack.taier.common.exception.RdosDefineException) StringUtils(org.apache.commons.lang3.StringUtils) EJobCacheStage(com.dtstack.taier.common.enums.EJobCacheStage) ParamAction(com.dtstack.taier.pluginapi.pojo.ParamAction) Lists(com.google.common.collect.Lists) ComponentService(com.dtstack.taier.scheduler.service.ComponentService) ZkService(com.dtstack.taier.scheduler.zookeeper.ZkService) CollectionUtils(org.apache.commons.collections.CollectionUtils) Service(org.springframework.stereotype.Service) ConsoleJobInfoVO(com.dtstack.taier.develop.vo.console.ConsoleJobInfoVO) DateUtil(com.dtstack.taier.pluginapi.util.DateUtil) GroupPriorityQueue(com.dtstack.taier.scheduler.server.queue.GroupPriorityQueue) ErrorCode(com.dtstack.taier.common.exception.ErrorCode) TaskStatus(com.dtstack.taier.pluginapi.enums.TaskStatus) ForceCancelFlag(com.dtstack.taier.common.enums.ForceCancelFlag) com.dtstack.taier.dao.domain(com.dtstack.taier.dao.domain) Logger(org.slf4j.Logger) MapUtils(org.apache.commons.collections.MapUtils) JobService(com.dtstack.taier.develop.service.schedule.JobService) ConsoleJobVO(com.dtstack.taier.develop.vo.console.ConsoleJobVO) ComponentVersionUtil(com.dtstack.taier.common.util.ComponentVersionUtil) Collectors(java.util.stream.Collectors) EComponentType(com.dtstack.taier.common.enums.EComponentType) JobClient(com.dtstack.taier.pluginapi.JobClient) PublicUtil(com.dtstack.taier.pluginapi.util.PublicUtil) JobDealer(com.dtstack.taier.scheduler.jobdealer.JobDealer) PageQuery(com.dtstack.taier.dao.pager.PageQuery) WorkerOperator(com.dtstack.taier.scheduler.WorkerOperator) ConfigConstant(com.dtstack.taier.pluginapi.constrant.ConfigConstant) JSONObject(com.alibaba.fastjson.JSONObject) Preconditions(com.google.common.base.Preconditions) OperatorType(com.dtstack.taier.common.enums.OperatorType) PageQuery(com.dtstack.taier.dao.pager.PageQuery) RdosDefineException(com.dtstack.taier.common.exception.RdosDefineException) PageResult(com.dtstack.taier.dao.pager.PageResult) JSONObject(com.alibaba.fastjson.JSONObject)

Example 2 with PageResult

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);
}
Also used : ReturnJobStatusStatisticsVO(com.dtstack.taier.develop.vo.schedule.ReturnJobStatusStatisticsVO) CountFillDataJobStatusPO(com.dtstack.taier.dao.domain.po.CountFillDataJobStatusPO) UserService(com.dtstack.taier.develop.service.user.UserService) FillDataJobMapstructTransfer(com.dtstack.taier.develop.mapstruct.fill.FillDataJobMapstructTransfer) PageResult(com.dtstack.taier.dao.pager.PageResult) Autowired(org.springframework.beans.factory.annotation.Autowired) StringUtils(org.apache.commons.lang3.StringUtils) NumberUtils(org.apache.commons.lang.math.NumberUtils) DateUtil(com.dtstack.taier.pluginapi.util.DateUtil) StatusCountPO(com.dtstack.taier.dao.domain.po.StatusCountPO) TaskStatus(com.dtstack.taier.pluginapi.enums.TaskStatus) ServiceImpl(com.baomidou.mybatisplus.extension.service.impl.ServiceImpl) Wrappers(com.baomidou.mybatisplus.core.toolkit.Wrappers) ScheduleTaskShade(com.dtstack.taier.dao.domain.ScheduleTaskShade) QueryFillDataListDTO(com.dtstack.taier.scheduler.dto.fill.QueryFillDataListDTO) Timestamp(java.sql.Timestamp) ReturnJobListVO(com.dtstack.taier.develop.vo.schedule.ReturnJobListVO) QueryFillDataJobListDTO(com.dtstack.taier.scheduler.dto.fill.QueryFillDataJobListDTO) ReturnFillDataJobListVO(com.dtstack.taier.develop.vo.fill.ReturnFillDataJobListVO) ScheduleFillDataInfoDTO(com.dtstack.taier.scheduler.dto.fill.ScheduleFillDataInfoDTO) Collectors(java.util.stream.Collectors) ReturnDisplayPeriodVO(com.dtstack.taier.develop.vo.schedule.ReturnDisplayPeriodVO) FillGeneratStatusEnum(com.dtstack.taier.scheduler.enums.FillGeneratStatusEnum) Deleted(com.dtstack.taier.common.enums.Deleted) FillDataJobVO(com.dtstack.taier.develop.vo.fill.FillDataJobVO) java.util(java.util) ScheduleJob(com.dtstack.taier.dao.domain.ScheduleJob) RdosDefineException(com.dtstack.taier.common.exception.RdosDefineException) FillDataRunnable(com.dtstack.taier.scheduler.server.action.fill.FillDataRunnable) FillDataThreadPoolExecutor(com.dtstack.taier.scheduler.server.action.fill.FillDataThreadPoolExecutor) Lists(com.google.common.collect.Lists) CollectionUtils(org.apache.commons.collections.CollectionUtils) Service(org.springframework.stereotype.Service) FillStatusUpdateFinishEvent(com.dtstack.taier.develop.event.FillStatusUpdateFinishEvent) QueryJobListDTO(com.dtstack.taier.scheduler.dto.schedule.QueryJobListDTO) ErrorCode(com.dtstack.taier.common.exception.ErrorCode) ReturnFillDataListVO(com.dtstack.taier.develop.vo.fill.ReturnFillDataListVO) ScheduleFillDataJob(com.dtstack.taier.dao.domain.ScheduleFillDataJob) FillDataTypeEnum(com.dtstack.taier.scheduler.enums.FillDataTypeEnum) ScheduleJobMapper(com.dtstack.taier.dao.mapper.ScheduleJobMapper) User(com.dtstack.taier.dao.domain.User) DateTime(org.joda.time.DateTime) EScheduleType(com.dtstack.taier.common.enums.EScheduleType) Maps(com.google.common.collect.Maps) ApplicationContext(org.springframework.context.ApplicationContext) Page(com.baomidou.mybatisplus.extension.plugins.pagination.Page) ScheduleFillJobParticipateDTO(com.dtstack.taier.scheduler.dto.fill.ScheduleFillJobParticipateDTO) JSON(com.alibaba.fastjson.JSON) QueryJobStatusStatisticsDTO(com.dtstack.taier.scheduler.dto.schedule.QueryJobStatusStatisticsDTO) JobMapstructTransfer(com.dtstack.taier.develop.mapstruct.job.JobMapstructTransfer) FillJobTypeEnum(com.dtstack.taier.scheduler.enums.FillJobTypeEnum) JobsStatusStatisticsPO(com.dtstack.taier.dao.domain.po.JobsStatusStatisticsPO) ScheduleJob(com.dtstack.taier.dao.domain.ScheduleJob) User(com.dtstack.taier.dao.domain.User) ReturnFillDataJobListVO(com.dtstack.taier.develop.vo.fill.ReturnFillDataJobListVO) Page(com.baomidou.mybatisplus.extension.plugins.pagination.Page) PageResult(com.dtstack.taier.dao.pager.PageResult) ScheduleTaskShade(com.dtstack.taier.dao.domain.ScheduleTaskShade) FillDataJobVO(com.dtstack.taier.develop.vo.fill.FillDataJobVO) ScheduleFillDataJob(com.dtstack.taier.dao.domain.ScheduleFillDataJob)

Example 3 with PageResult

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);
}
Also used : ReturnJobStatusStatisticsVO(com.dtstack.taier.develop.vo.schedule.ReturnJobStatusStatisticsVO) CountFillDataJobStatusPO(com.dtstack.taier.dao.domain.po.CountFillDataJobStatusPO) UserService(com.dtstack.taier.develop.service.user.UserService) FillDataJobMapstructTransfer(com.dtstack.taier.develop.mapstruct.fill.FillDataJobMapstructTransfer) PageResult(com.dtstack.taier.dao.pager.PageResult) Autowired(org.springframework.beans.factory.annotation.Autowired) StringUtils(org.apache.commons.lang3.StringUtils) NumberUtils(org.apache.commons.lang.math.NumberUtils) DateUtil(com.dtstack.taier.pluginapi.util.DateUtil) StatusCountPO(com.dtstack.taier.dao.domain.po.StatusCountPO) TaskStatus(com.dtstack.taier.pluginapi.enums.TaskStatus) ServiceImpl(com.baomidou.mybatisplus.extension.service.impl.ServiceImpl) Wrappers(com.baomidou.mybatisplus.core.toolkit.Wrappers) ScheduleTaskShade(com.dtstack.taier.dao.domain.ScheduleTaskShade) QueryFillDataListDTO(com.dtstack.taier.scheduler.dto.fill.QueryFillDataListDTO) Timestamp(java.sql.Timestamp) ReturnJobListVO(com.dtstack.taier.develop.vo.schedule.ReturnJobListVO) QueryFillDataJobListDTO(com.dtstack.taier.scheduler.dto.fill.QueryFillDataJobListDTO) ReturnFillDataJobListVO(com.dtstack.taier.develop.vo.fill.ReturnFillDataJobListVO) ScheduleFillDataInfoDTO(com.dtstack.taier.scheduler.dto.fill.ScheduleFillDataInfoDTO) Collectors(java.util.stream.Collectors) ReturnDisplayPeriodVO(com.dtstack.taier.develop.vo.schedule.ReturnDisplayPeriodVO) FillGeneratStatusEnum(com.dtstack.taier.scheduler.enums.FillGeneratStatusEnum) Deleted(com.dtstack.taier.common.enums.Deleted) FillDataJobVO(com.dtstack.taier.develop.vo.fill.FillDataJobVO) java.util(java.util) ScheduleJob(com.dtstack.taier.dao.domain.ScheduleJob) RdosDefineException(com.dtstack.taier.common.exception.RdosDefineException) FillDataRunnable(com.dtstack.taier.scheduler.server.action.fill.FillDataRunnable) FillDataThreadPoolExecutor(com.dtstack.taier.scheduler.server.action.fill.FillDataThreadPoolExecutor) Lists(com.google.common.collect.Lists) CollectionUtils(org.apache.commons.collections.CollectionUtils) Service(org.springframework.stereotype.Service) FillStatusUpdateFinishEvent(com.dtstack.taier.develop.event.FillStatusUpdateFinishEvent) QueryJobListDTO(com.dtstack.taier.scheduler.dto.schedule.QueryJobListDTO) ErrorCode(com.dtstack.taier.common.exception.ErrorCode) ReturnFillDataListVO(com.dtstack.taier.develop.vo.fill.ReturnFillDataListVO) ScheduleFillDataJob(com.dtstack.taier.dao.domain.ScheduleFillDataJob) FillDataTypeEnum(com.dtstack.taier.scheduler.enums.FillDataTypeEnum) ScheduleJobMapper(com.dtstack.taier.dao.mapper.ScheduleJobMapper) User(com.dtstack.taier.dao.domain.User) DateTime(org.joda.time.DateTime) EScheduleType(com.dtstack.taier.common.enums.EScheduleType) Maps(com.google.common.collect.Maps) ApplicationContext(org.springframework.context.ApplicationContext) Page(com.baomidou.mybatisplus.extension.plugins.pagination.Page) ScheduleFillJobParticipateDTO(com.dtstack.taier.scheduler.dto.fill.ScheduleFillJobParticipateDTO) JSON(com.alibaba.fastjson.JSON) QueryJobStatusStatisticsDTO(com.dtstack.taier.scheduler.dto.schedule.QueryJobStatusStatisticsDTO) JobMapstructTransfer(com.dtstack.taier.develop.mapstruct.job.JobMapstructTransfer) FillJobTypeEnum(com.dtstack.taier.scheduler.enums.FillJobTypeEnum) JobsStatusStatisticsPO(com.dtstack.taier.dao.domain.po.JobsStatusStatisticsPO) CountFillDataJobStatusPO(com.dtstack.taier.dao.domain.po.CountFillDataJobStatusPO) User(com.dtstack.taier.dao.domain.User) Page(com.baomidou.mybatisplus.extension.plugins.pagination.Page) PageResult(com.dtstack.taier.dao.pager.PageResult) ReturnFillDataListVO(com.dtstack.taier.develop.vo.fill.ReturnFillDataListVO) ScheduleFillDataJob(com.dtstack.taier.dao.domain.ScheduleFillDataJob)

Example 4 with PageResult

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);
}
Also used : ClusterTenantVO(com.dtstack.taier.develop.vo.console.ClusterTenantVO) PageQuery(com.dtstack.taier.dao.pager.PageQuery) ClusterTenant(com.dtstack.taier.dao.domain.ClusterTenant) PageResult(com.dtstack.taier.dao.pager.PageResult)

Example 5 with PageResult

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);
}
Also used : DsListBO(com.dtstack.taier.dao.domain.po.DsListBO) JSONObject(com.alibaba.fastjson.JSONObject) ArrayList(java.util.ArrayList) DsListVO(com.dtstack.taier.develop.vo.datasource.DsListVO) PageResult(com.dtstack.taier.dao.pager.PageResult) DsListQuery(com.dtstack.taier.dao.domain.po.DsListQuery)

Aggregations

PageResult (com.dtstack.taier.dao.pager.PageResult)6 Page (com.baomidou.mybatisplus.extension.plugins.pagination.Page)3 ErrorCode (com.dtstack.taier.common.exception.ErrorCode)3 RdosDefineException (com.dtstack.taier.common.exception.RdosDefineException)3 ScheduleTaskShade (com.dtstack.taier.dao.domain.ScheduleTaskShade)3 User (com.dtstack.taier.dao.domain.User)3 TaskStatus (com.dtstack.taier.pluginapi.enums.TaskStatus)3 DateUtil (com.dtstack.taier.pluginapi.util.DateUtil)3 Lists (com.google.common.collect.Lists)3 java.util (java.util)3 Collectors (java.util.stream.Collectors)3 CollectionUtils (org.apache.commons.collections.CollectionUtils)3 StringUtils (org.apache.commons.lang3.StringUtils)3 Autowired (org.springframework.beans.factory.annotation.Autowired)3 Service (org.springframework.stereotype.Service)3 JSON (com.alibaba.fastjson.JSON)2 Wrappers (com.baomidou.mybatisplus.core.toolkit.Wrappers)2 ServiceImpl (com.baomidou.mybatisplus.extension.service.impl.ServiceImpl)2 Deleted (com.dtstack.taier.common.enums.Deleted)2 EScheduleType (com.dtstack.taier.common.enums.EScheduleType)2