Search in sources :

Example 1 with StatusCountPO

use of com.dtstack.taier.dao.domain.po.StatusCountPO in project Taier by DTStack.

the class JobService method mergeStatusAndShow.

/**
 * 统计job状态数
 *
 * @param statusCountList 从db中查询出的status数据
 * @return
 */
private List<ReturnJobStatusStatisticsVO> mergeStatusAndShow(List<StatusCountPO> statusCountList) {
    Map<String, ReturnJobStatusStatisticsVO> returnJobStatusStatisticsVOList = Maps.newHashMap();
    long totalNum = 0;
    Map<Integer, List<Integer>> statusMap = TaskStatus.getStatusFailedDetail();
    for (Map.Entry<Integer, List<Integer>> entry : statusMap.entrySet()) {
        ReturnJobStatusStatisticsVO vo = new ReturnJobStatusStatisticsVO();
        String statusName = TaskStatus.getCode(entry.getKey());
        List<Integer> statuses = entry.getValue();
        vo.setStatusKey(statusName);
        long num = 0;
        for (StatusCountPO statusCount : statusCountList) {
            if (statuses.contains(statusCount.getStatus())) {
                num += statusCount.getCount();
            }
        }
        if (!returnJobStatusStatisticsVOList.containsKey(statusName)) {
            vo.setCount(num);
            returnJobStatusStatisticsVOList.put(statusName, vo);
        } else {
            // 上一个该状态的数量
            vo.setCount(vo.getCount() + num);
            returnJobStatusStatisticsVOList.put(statusName, vo);
        }
        totalNum += num;
    }
    ReturnJobStatusStatisticsVO vo = new ReturnJobStatusStatisticsVO();
    vo.setCount(totalNum);
    vo.setStatusKey("ALL");
    Collection<ReturnJobStatusStatisticsVO> collection = returnJobStatusStatisticsVOList.values();
    List<ReturnJobStatusStatisticsVO> returnJobStatusStatisticsVOS = Lists.newArrayList(collection);
    returnJobStatusStatisticsVOS.add(vo);
    return returnJobStatusStatisticsVOS;
}
Also used : StatusCountPO(com.dtstack.taier.dao.domain.po.StatusCountPO) ReturnJobStatusStatisticsVO(com.dtstack.taier.develop.vo.schedule.ReturnJobStatusStatisticsVO)

Example 2 with StatusCountPO

use of com.dtstack.taier.dao.domain.po.StatusCountPO in project Taier by DTStack.

the class JobService method queryJobsStatusStatistics.

/**
 * 统计周期实例状态
 *
 * @param dto
 * @return
 */
public List<ReturnJobStatusStatisticsVO> queryJobsStatusStatistics(QueryJobStatusStatisticsDTO dto) {
    // 关联任务
    List<Long> taskIdList = null;
    if (StringUtils.isNotBlank(dto.getTaskName()) || dto.getOperatorId() != null) {
        List<ScheduleTaskShade> scheduleTaskShadeList = taskService.findTaskByTaskName(dto.getTaskName(), null, dto.getOperatorId());
        if (CollectionUtils.isEmpty(scheduleTaskShadeList)) {
            return Lists.newArrayList();
        } else {
            taskIdList = scheduleTaskShadeList.stream().map(ScheduleTaskShade::getTaskId).collect(Collectors.toList());
        }
    }
    // 查询db统计数据
    JobsStatusStatisticsPO jobsStatusStatistics = JobMapstructTransfer.INSTANCE.queryJobStatusStatisticsDTOToJobsStatusStatistics(dto);
    jobsStatusStatistics.setCycStartTime(getCycTime(dto.getCycStartDay()));
    jobsStatusStatistics.setCycEndTime(getCycTime(dto.getCycEndDay()));
    jobsStatusStatistics.setFillTypeList(Lists.newArrayList(FillJobTypeEnum.DEFAULT.getType(), FillJobTypeEnum.RUN_JOB.getType()));
    jobsStatusStatistics.setTaskIdList(taskIdList);
    List<StatusCountPO> statusCountList = this.baseMapper.queryJobsStatusStatistics(jobsStatusStatistics);
    // 封装结果集
    return mergeStatusAndShow(statusCountList);
}
Also used : StatusCountPO(com.dtstack.taier.dao.domain.po.StatusCountPO) JobsStatusStatisticsPO(com.dtstack.taier.dao.domain.po.JobsStatusStatisticsPO) ScheduleTaskShade(com.dtstack.taier.dao.domain.ScheduleTaskShade)

Aggregations

StatusCountPO (com.dtstack.taier.dao.domain.po.StatusCountPO)2 ScheduleTaskShade (com.dtstack.taier.dao.domain.ScheduleTaskShade)1 JobsStatusStatisticsPO (com.dtstack.taier.dao.domain.po.JobsStatusStatisticsPO)1 ReturnJobStatusStatisticsVO (com.dtstack.taier.develop.vo.schedule.ReturnJobStatusStatisticsVO)1