Search in sources :

Example 1 with ReturnJobDisplayVO

use of com.dtstack.taier.develop.vo.schedule.ReturnJobDisplayVO in project Taier by DTStack.

the class JobJobService method displayOffSpring.

public ReturnJobDisplayVO displayOffSpring(QueryJobDisplayDTO dto) {
    // 设置层级 0<level< max.level
    dto.setLevel(JobUtils.checkLevel(dto.getLevel(), context.getMaxLevel()));
    // 查询实例是否存在,如不不存在,直接抛异常,下面的逻辑不需要在走了
    ScheduleJob scheduleJob = jobService.lambdaQuery().eq(ScheduleJob::getJobId, dto.getJobId()).eq(ScheduleJob::getIsDeleted, Deleted.NORMAL.getStatus()).one();
    if (scheduleJob == null) {
        throw new RdosDefineException("job does not exist");
    }
    // 先从db里面查询数据,然后在递归封装成节点
    List<String> jobKeys = Lists.newArrayList(scheduleJob.getJobKey());
    Map<String, List<String>> jobJobMaps = findJobJobByJobKeys(dto, jobKeys);
    // 查询所有实例
    List<ScheduleJob> scheduleJobList = findJobByJobJob(jobJobMaps);
    scheduleJobList.add(scheduleJob);
    Map<String, ScheduleJob> jobMap = scheduleJobList.stream().collect(Collectors.groupingBy(ScheduleJob::getJobKey, Collectors.collectingAndThen(Collectors.toCollection(ArrayList<ScheduleJob>::new), a -> a.get(0))));
    // 查询所有任务
    Map<Long, ScheduleTaskShade> taskShadeMap = findTaskJob(scheduleJobList);
    ReturnJobDisplayVO vo = new ReturnJobDisplayVO();
    vo.setDirectType(dto.getDirectType());
    vo.setRootNode(buildRootNode(dto.getDirectType(), scheduleJob, taskShadeMap, jobMap, jobJobMaps));
    return vo;
}
Also used : ScheduleJob(com.dtstack.taier.dao.domain.ScheduleJob) RdosDefineException(com.dtstack.taier.common.exception.RdosDefineException) ArrayList(java.util.ArrayList) List(java.util.List) ReturnJobDisplayVO(com.dtstack.taier.develop.vo.schedule.ReturnJobDisplayVO) ScheduleTaskShade(com.dtstack.taier.dao.domain.ScheduleTaskShade)

Example 2 with ReturnJobDisplayVO

use of com.dtstack.taier.develop.vo.schedule.ReturnJobDisplayVO in project Taier by DTStack.

the class JobJobService method displayAllFlowSubJobs.

private ReturnJobDisplayVO displayAllFlowSubJobs(ScheduleJob scheduleJob) {
    List<ScheduleJob> scheduleJobList = jobService.lambdaQuery().eq(ScheduleJob::getFlowJobId, scheduleJob.getJobId()).eq(ScheduleJob::getIsDeleted, Deleted.NORMAL.getStatus()).list();
    Map<String, ScheduleJob> jobMap = scheduleJobList.stream().collect(Collectors.toMap(ScheduleJob::getJobKey, g -> (g)));
    // 查询实例直接的关系
    Set<String> jobKeySet = jobMap.keySet();
    jobKeySet.add(scheduleJob.getJobKey());
    List<ScheduleJobJob> scheduleJobJobs = this.lambdaQuery().in(ScheduleJobJob::getJobKey, jobKeySet).in(ScheduleJobJob::getIsDeleted, Deleted.NORMAL.getStatus()).list();
    Map<String, List<String>> jobJobMaps = scheduleJobJobs.stream().collect(Collectors.groupingBy(ScheduleJobJob::getParentJobKey, Collectors.mapping(ScheduleJobJob::getJobKey, Collectors.toList())));
    // 查询任务信息
    List<Long> taskIdList = scheduleJobList.stream().map(ScheduleJob::getTaskId).collect(Collectors.toList());
    taskIdList.add(scheduleJob.getTaskId());
    List<ScheduleTaskShade> taskShades = taskService.lambdaQuery().in(ScheduleTaskShade::getTaskId, taskIdList).eq(ScheduleTaskShade::getIsDeleted, Deleted.NORMAL.getStatus()).list();
    Map<Long, ScheduleTaskShade> taskShadeMap = taskShades.stream().collect(Collectors.toMap(ScheduleTaskShade::getTaskId, g -> (g)));
    ReturnJobDisplayVO vo = new ReturnJobDisplayVO();
    vo.setRootNode(buildRootNode(DisplayDirect.CHILD.getType(), scheduleJob, taskShadeMap, jobMap, jobJobMaps));
    return vo;
}
Also used : UserService(com.dtstack.taier.develop.service.user.UserService) ScheduleJob(com.dtstack.taier.dao.domain.ScheduleJob) EnvironmentContext(com.dtstack.taier.common.env.EnvironmentContext) Autowired(org.springframework.beans.factory.annotation.Autowired) RdosDefineException(com.dtstack.taier.common.exception.RdosDefineException) ArrayList(java.util.ArrayList) A(org.checkerframework.checker.units.qual.A) DisplayDirect(com.dtstack.taier.common.enums.DisplayDirect) Lists(com.google.common.collect.Lists) CollectionUtils(org.apache.commons.collections.CollectionUtils) Service(org.springframework.stereotype.Service) RelyType(com.dtstack.taier.scheduler.enums.RelyType) Map(java.util.Map) DateUtil(com.dtstack.taier.pluginapi.util.DateUtil) ScheduleJobJob(com.dtstack.taier.dao.domain.ScheduleJobJob) ServiceImpl(com.baomidou.mybatisplus.extension.service.impl.ServiceImpl) ScheduleTaskShade(com.dtstack.taier.dao.domain.ScheduleTaskShade) ReturnJobDisplayVO(com.dtstack.taier.develop.vo.schedule.ReturnJobDisplayVO) QueryJobDisplayDTO(com.dtstack.taier.scheduler.dto.schedule.QueryJobDisplayDTO) JobNodeVO(com.dtstack.taier.develop.vo.schedule.JobNodeVO) Set(java.util.Set) ScheduleJobJobMapper(com.dtstack.taier.dao.mapper.ScheduleJobJobMapper) Maps(com.google.common.collect.Maps) Collectors(java.util.stream.Collectors) Sets(com.google.common.collect.Sets) List(java.util.List) JobUtils(com.dtstack.taier.develop.utils.JobUtils) EScheduleJobType(com.dtstack.taier.common.enums.EScheduleJobType) Deleted(com.dtstack.taier.common.enums.Deleted) ScheduleJob(com.dtstack.taier.dao.domain.ScheduleJob) ScheduleJobJob(com.dtstack.taier.dao.domain.ScheduleJobJob) ReturnJobDisplayVO(com.dtstack.taier.develop.vo.schedule.ReturnJobDisplayVO) ScheduleTaskShade(com.dtstack.taier.dao.domain.ScheduleTaskShade) ArrayList(java.util.ArrayList) List(java.util.List)

Aggregations

RdosDefineException (com.dtstack.taier.common.exception.RdosDefineException)2 ScheduleJob (com.dtstack.taier.dao.domain.ScheduleJob)2 ScheduleTaskShade (com.dtstack.taier.dao.domain.ScheduleTaskShade)2 ReturnJobDisplayVO (com.dtstack.taier.develop.vo.schedule.ReturnJobDisplayVO)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 ServiceImpl (com.baomidou.mybatisplus.extension.service.impl.ServiceImpl)1 Deleted (com.dtstack.taier.common.enums.Deleted)1 DisplayDirect (com.dtstack.taier.common.enums.DisplayDirect)1 EScheduleJobType (com.dtstack.taier.common.enums.EScheduleJobType)1 EnvironmentContext (com.dtstack.taier.common.env.EnvironmentContext)1 ScheduleJobJob (com.dtstack.taier.dao.domain.ScheduleJobJob)1 ScheduleJobJobMapper (com.dtstack.taier.dao.mapper.ScheduleJobJobMapper)1 UserService (com.dtstack.taier.develop.service.user.UserService)1 JobUtils (com.dtstack.taier.develop.utils.JobUtils)1 JobNodeVO (com.dtstack.taier.develop.vo.schedule.JobNodeVO)1 DateUtil (com.dtstack.taier.pluginapi.util.DateUtil)1 QueryJobDisplayDTO (com.dtstack.taier.scheduler.dto.schedule.QueryJobDisplayDTO)1 RelyType (com.dtstack.taier.scheduler.enums.RelyType)1 Lists (com.google.common.collect.Lists)1