Search in sources :

Example 1 with IssueListVO

use of io.choerodon.agile.api.vo.business.IssueListVO in project agile-service by open-hand.

the class SprintServiceImpl method queryIssueByOptions.

@Override
public Page<IssueListVO> queryIssueByOptions(Long projectId, Long sprintId, String status, PageRequest pageRequest, Long organizationId) {
    SprintDTO sprintDTO = new SprintDTO();
    sprintDTO.setProjectId(projectId);
    sprintDTO.setSprintId(sprintId);
    SprintDTO sprint = sprintMapper.selectOne(sprintDTO);
    if (sprint == null || Objects.equals(sprint.getStatusCode(), SPRINT_PLANNING_CODE)) {
        throw new CommonException(SPRINT_REPORT_ERROR);
    }
    Date actualEndDate = sprint.getActualEndDate() == null ? new Date() : sprint.getActualEndDate();
    sprint.setActualEndDate(actualEndDate);
    Date startDate = sprint.getStartDate();
    Page<Long> reportIssuePage = new Page<>();
    Map<String, String> maps = new HashMap<>();
    maps.put("issueNum", "issue_num_convert");
    Sort sort = PageUtil.sortResetOrder(pageRequest.getSort(), "ai", maps);
    pageRequest.setSort(sort);
    switch(status) {
        case DONE:
            reportIssuePage = PageHelper.doPageAndSort(pageRequest, () -> reportMapper.queryReportIssueIds(projectId, sprintId, actualEndDate, true));
            break;
        case UNFINISHED:
            reportIssuePage = PageHelper.doPageAndSort(pageRequest, () -> reportMapper.queryReportIssueIds(projectId, sprintId, actualEndDate, false));
            break;
        case REMOVE:
            reportIssuePage = PageHelper.doPageAndSort(pageRequest, () -> reportMapper.queryRemoveIssueIdsDuringSprintWithOutSubEpicIssue(sprint));
            break;
        default:
            break;
    }
    List<Long> reportIssueIds = reportIssuePage.getContent();
    if (reportIssueIds.isEmpty()) {
        return new Page<>();
    }
    Map<Long, StatusVO> statusMapDTOMap = statusService.queryAllStatusMap(organizationId);
    // 冲刺报告查询的issue
    List<IssueDTO> reportIssues = reportMapper.queryIssueByIssueIds(projectId, reportIssueIds);
    // 冲刺中新添加的issue
    List<Long> issueIdBeforeSprintList = reportMapper.queryIssueIdsBeforeSprintStart(sprint, new BurnDownSearchVO(), null);
    List<Long> issueIdAddList = issueIdBeforeSprintList.isEmpty() ? new ArrayList<>() : reportMapper.queryAddIssueIdsDuringSprint(sprint, new BurnDownSearchVO(), null);
    // 冲刺报告中issue的故事点
    List<SprintReportIssueStatusDO> reportIssueStoryPoints = reportMapper.queryIssueStoryPoints(projectId, reportIssueIds, actualEndDate);
    Map<Long, SprintReportIssueStatusDO> reportIssueStoryPointsMap = reportIssueStoryPoints.stream().collect(Collectors.toMap(SprintReportIssueStatusDO::getIssueId, sprintReportIssueStatusDO -> sprintReportIssueStatusDO));
    // 冲刺完成前issue的最后变更状态
    List<SprintReportIssueStatusDO> reportIssueBeforeStatus = reportMapper.queryBeforeIssueStatus(projectId, reportIssueIds, startDate, actualEndDate);
    Map<Long, SprintReportIssueStatusDO> reportIssueBeforeStatusMap = new HashMap<>();
    for (SprintReportIssueStatusDO sprintReportIssueStatusDO : reportIssueBeforeStatus) {
        StatusVO statusMapVO = statusMapDTOMap.get(sprintReportIssueStatusDO.getStatusId());
        sprintReportIssueStatusDO.setCategoryCode(statusMapVO.getType());
        sprintReportIssueStatusDO.setStatusName(statusMapVO.getName());
        reportIssueBeforeStatusMap.put(sprintReportIssueStatusDO.getIssueId(), sprintReportIssueStatusDO);
    }
    // 冲刺完成后issue的最初变更状态
    reportIssueIds.removeAll(reportIssueBeforeStatusMap.keySet());
    List<SprintReportIssueStatusDO> reportIssueAfterStatus = reportIssueIds.isEmpty() ? new ArrayList<>() : reportMapper.queryAfterIssueStatus(projectId, reportIssueIds, actualEndDate);
    Map<Long, SprintReportIssueStatusDO> reportIssueAfterStatusMap = new HashMap<>();
    for (SprintReportIssueStatusDO sprintReportIssueStatusDO : reportIssueAfterStatus) {
        StatusVO statusMapVO = statusMapDTOMap.get(sprintReportIssueStatusDO.getStatusId());
        sprintReportIssueStatusDO.setCategoryCode(statusMapVO.getType());
        sprintReportIssueStatusDO.setStatusName(statusMapVO.getName());
        reportIssueAfterStatusMap.put(sprintReportIssueStatusDO.getIssueId(), sprintReportIssueStatusDO);
    }
    reportIssues = reportIssues.stream().map(reportIssue -> {
        updateReportIssue(reportIssue, reportIssueStoryPointsMap, reportIssueBeforeStatusMap, reportIssueAfterStatusMap, issueIdAddList);
        return reportIssue;
    }).collect(Collectors.toList());
    Map<Long, PriorityVO> priorityMap = priorityService.queryByOrganizationId(organizationId);
    Map<Long, IssueTypeVO> issueTypeDTOMap = issueTypeService.listIssueTypeMap(organizationId, projectId);
    return PageUtil.buildPageInfoWithPageInfoList(reportIssuePage, issueAssembler.issueDoToIssueListDto(reportIssues, priorityMap, statusMapDTOMap, issueTypeDTOMap));
}
Also used : SprintValidator(io.choerodon.agile.api.validator.SprintValidator) java.util(java.util) TypeToken(org.modelmapper.TypeToken) io.choerodon.agile.infra.mapper(io.choerodon.agile.infra.mapper) Autowired(org.springframework.beans.factory.annotation.Autowired) SimpleDateFormat(java.text.SimpleDateFormat) Function(java.util.function.Function) CustomUserDetails(io.choerodon.core.oauth.CustomUserDetails) ModelMapper(org.modelmapper.ModelMapper) BigDecimal(java.math.BigDecimal) io.choerodon.agile.infra.utils(io.choerodon.agile.infra.utils) IssueSearchVO(io.choerodon.agile.api.vo.business.IssueSearchVO) Sort(io.choerodon.mybatis.pagehelper.domain.Sort) Service(org.springframework.stereotype.Service) io.choerodon.agile.app.service(io.choerodon.agile.app.service) CommonException(io.choerodon.core.exception.CommonException) ParseException(java.text.ParseException) DataLogRedisUtil(io.choerodon.agile.infra.aspect.DataLogRedisUtil) DateFormat(java.text.DateFormat) io.choerodon.agile.app.assembler(io.choerodon.agile.app.assembler) DetailsHelper(io.choerodon.core.oauth.DetailsHelper) ObjectUtils(org.springframework.util.ObjectUtils) PageHelper(io.choerodon.mybatis.pagehelper.PageHelper) io.choerodon.agile.api.vo(io.choerodon.agile.api.vo) io.choerodon.agile.infra.dto(io.choerodon.agile.infra.dto) IssueListVO(io.choerodon.agile.api.vo.business.IssueListVO) Collectors(java.util.stream.Collectors) List(java.util.List) Ordering(com.google.common.collect.Ordering) SchemeApplyType(io.choerodon.agile.infra.enums.SchemeApplyType) CollectionUtils(org.springframework.util.CollectionUtils) SprintDetailVO(io.choerodon.agile.api.vo.business.SprintDetailVO) SprintConvertDTO(io.choerodon.agile.infra.dto.business.SprintConvertDTO) Page(io.choerodon.core.domain.Page) IssueSearchDTO(io.choerodon.agile.infra.dto.business.IssueSearchDTO) PageRequest(io.choerodon.mybatis.pagehelper.domain.PageRequest) IssueDTO(io.choerodon.agile.infra.dto.business.IssueDTO) BeanUtils(org.springframework.beans.BeanUtils) Transactional(org.springframework.transaction.annotation.Transactional) Page(io.choerodon.core.domain.Page) Sort(io.choerodon.mybatis.pagehelper.domain.Sort) IssueDTO(io.choerodon.agile.infra.dto.business.IssueDTO) CommonException(io.choerodon.core.exception.CommonException)

Example 2 with IssueListVO

use of io.choerodon.agile.api.vo.business.IssueListVO in project agile-service by open-hand.

the class IssuePredecessorServiceImpl method queryByIssueId.

@Override
public List<IssuePredecessorVO> queryByIssueId(Long projectId, Long currentIssueId, boolean withInfo) {
    IssuePredecessorDTO dto = new IssuePredecessorDTO();
    dto.setOrganizationId(ConvertUtil.getOrganizationId(projectId));
    dto.setProjectId(projectId);
    dto.setIssueId(currentIssueId);
    List<IssuePredecessorDTO> dtoList = issuePredecessorMapper.select(dto);
    ModelMapper modelMapper = new ModelMapper();
    List<IssuePredecessorVO> result = modelMapper.map(dtoList, new TypeToken<List<IssuePredecessorVO>>() {
    }.getType());
    if (Boolean.TRUE.equals(withInfo) && !CollectionUtils.isEmpty(result)) {
        Long organizationId = ConvertUtil.getOrganizationId(projectId);
        List<Long> issueIds = result.stream().map(IssuePredecessorVO::getPredecessorId).collect(Collectors.toList());
        // 类型、概要、编号、优先级、状态、经办人
        List<IssueDTO> issueDTOList = issueMapper.queryIssueListWithSubByIssueIds(issueIds, null, false, false);
        Map<Long, PriorityVO> priorityMap = priorityService.queryByOrganizationId(organizationId);
        Map<Long, StatusVO> statusMapDTOMap = statusService.queryAllStatusMap(organizationId);
        Map<Long, IssueTypeVO> issueTypeDTOMap = issueTypeService.listIssueTypeMap(organizationId, projectId);
        List<IssueListVO> issueList = issueAssembler.issueDoToIssueListDto(issueDTOList, priorityMap, statusMapDTOMap, issueTypeDTOMap);
        Map<Long, IssueListVO> issueMap = issueList.stream().collect(Collectors.toMap(IssueListVO::getIssueId, Function.identity()));
        result.forEach(vo -> vo.setPredecessorIssueVO(issueMap.get(vo.getPredecessorId())));
    }
    return result;
}
Also used : ModelMapper(org.modelmapper.ModelMapper) IssueListVO(io.choerodon.agile.api.vo.business.IssueListVO) IssuePredecessorDTO(io.choerodon.agile.infra.dto.IssuePredecessorDTO) TypeToken(org.modelmapper.TypeToken) IssueDTO(io.choerodon.agile.infra.dto.business.IssueDTO)

Example 3 with IssueListVO

use of io.choerodon.agile.api.vo.business.IssueListVO in project agile-service by open-hand.

the class IssueAssembler method issueDoToIssueListDto.

/**
 * issueDO转换到IssueListDTO
 *
 * @param issueDTOList issueDetailDO
 * @return IssueListVO
 */
public List<IssueListVO> issueDoToIssueListDto(List<IssueDTO> issueDTOList, Map<Long, PriorityVO> priorityMap, Map<Long, StatusVO> statusMapDTOMap, Map<Long, IssueTypeVO> issueTypeDTOMap) {
    List<IssueListVO> issueListDTOList = new ArrayList<>(issueDTOList.size());
    Set<Long> userIds = issueDTOList.stream().filter(issue -> issue.getAssigneeId() != null && !Objects.equals(issue.getAssigneeId(), 0L)).map(IssueDTO::getAssigneeId).collect(Collectors.toSet());
    userIds.addAll(issueDTOList.stream().filter(issue -> issue.getReporterId() != null && !Objects.equals(issue.getReporterId(), 0L)).map(IssueDTO::getReporterId).collect(Collectors.toSet()));
    Map<Long, UserMessageDTO> usersMap = userService.queryUsersMap(Lists.newArrayList(userIds), true);
    issueDTOList.forEach(issueDO -> {
        UserMessageDTO assigneeUserDO = usersMap.get(issueDO.getAssigneeId());
        UserMessageDTO reporterUserDO = usersMap.get(issueDO.getReporterId());
        IssueListVO issueListVO = toTarget(issueDO, IssueListVO.class);
        if (!ObjectUtils.isEmpty(assigneeUserDO)) {
            issueListVO.setAssigneeName(assigneeUserDO.getName());
            issueListVO.setAssigneeLoginName(assigneeUserDO.getLoginName());
            issueListVO.setAssigneeRealName(assigneeUserDO.getRealName());
            issueListVO.setAssigneeImageUrl(assigneeUserDO.getImageUrl());
        }
        if (!ObjectUtils.isEmpty(reporterUserDO)) {
            issueListVO.setReporterName(reporterUserDO.getName());
            issueListVO.setReporterLoginName(reporterUserDO.getLoginName());
            issueListVO.setReporterRealName(reporterUserDO.getRealName());
            issueListVO.setReporterImageUrl(reporterUserDO.getImageUrl());
        }
        issueListVO.setPriorityVO(priorityMap.get(issueDO.getPriorityId()));
        issueListVO.setIssueTypeVO(issueTypeDTOMap.get(issueDO.getIssueTypeId()));
        issueListVO.setStatusVO(statusMapDTOMap.get(issueDO.getStatusId()));
        issueListVO.setVersionIssueRelVOS(toTargetList(issueDO.getVersionIssueRelDTOS(), VersionIssueRelVO.class));
        issueListVO.setIssueComponentBriefVOS(toTargetList(issueDO.getIssueComponentBriefDTOS(), IssueComponentBriefVO.class));
        issueListVO.setIssueSprintVOS(toTargetList(issueDO.getIssueSprintDTOS(), IssueSprintVO.class));
        issueListVO.setLabelIssueRelVOS(toTargetList(issueDO.getLabelIssueRelDTOS(), LabelIssueRelVO.class));
        issueListDTOList.add(issueListVO);
    });
    return issueListDTOList;
}
Also used : java.util(java.util) TypeToken(org.modelmapper.TypeToken) DateUtil(io.choerodon.agile.infra.utils.DateUtil) Autowired(org.springframework.beans.factory.annotation.Autowired) SimpleDateFormat(java.text.SimpleDateFormat) BooleanUtils(org.apache.commons.lang3.BooleanUtils) Collectors.collectingAndThen(java.util.stream.Collectors.collectingAndThen) IssueListFieldKVVO(io.choerodon.agile.api.vo.business.IssueListFieldKVVO) Function(java.util.function.Function) CollectionUtils(org.apache.commons.collections4.CollectionUtils) ModelMapper(org.modelmapper.ModelMapper) BigDecimal(java.math.BigDecimal) Collectors.toCollection(java.util.stream.Collectors.toCollection) Lists(com.google.common.collect.Lists) AgilePluginService(io.choerodon.agile.app.service.AgilePluginService) io.choerodon.agile.infra.enums(io.choerodon.agile.infra.enums) LookupValueService(io.choerodon.agile.app.service.LookupValueService) UserService(io.choerodon.agile.app.service.UserService) IssueTypeService(io.choerodon.agile.app.service.IssueTypeService) Comparator.comparing(java.util.Comparator.comparing) ConvertUtil(io.choerodon.agile.infra.utils.ConvertUtil) CommonException(io.choerodon.core.exception.CommonException) IssueStatusMapper(io.choerodon.agile.infra.mapper.IssueStatusMapper) DateFormat(java.text.DateFormat) IssueDetailDTO(io.choerodon.agile.infra.dto.business.IssueDetailDTO) ListUtil(io.choerodon.agile.infra.utils.ListUtil) Predicate(java.util.function.Predicate) ObjectUtils(org.springframework.util.ObjectUtils) io.choerodon.agile.api.vo(io.choerodon.agile.api.vo) io.choerodon.agile.infra.dto(io.choerodon.agile.infra.dto) IssueCreateVO(io.choerodon.agile.api.vo.business.IssueCreateVO) IssueListVO(io.choerodon.agile.api.vo.business.IssueListVO) Collectors(java.util.stream.Collectors) IssueVO(io.choerodon.agile.api.vo.business.IssueVO) ImmutablePair(org.apache.commons.lang3.tuple.ImmutablePair) DateUtils(org.apache.commons.lang3.time.DateUtils) Consumer(java.util.function.Consumer) Component(org.springframework.stereotype.Component) BaseConstants(org.hzero.core.base.BaseConstants) IssueDTO(io.choerodon.agile.infra.dto.business.IssueDTO) BeanUtils(org.springframework.beans.BeanUtils) IssueListVO(io.choerodon.agile.api.vo.business.IssueListVO) IssueDTO(io.choerodon.agile.infra.dto.business.IssueDTO)

Aggregations

IssueListVO (io.choerodon.agile.api.vo.business.IssueListVO)3 IssueDTO (io.choerodon.agile.infra.dto.business.IssueDTO)3 ModelMapper (org.modelmapper.ModelMapper)3 TypeToken (org.modelmapper.TypeToken)3 io.choerodon.agile.api.vo (io.choerodon.agile.api.vo)2 io.choerodon.agile.infra.dto (io.choerodon.agile.infra.dto)2 CommonException (io.choerodon.core.exception.CommonException)2 BigDecimal (java.math.BigDecimal)2 DateFormat (java.text.DateFormat)2 SimpleDateFormat (java.text.SimpleDateFormat)2 java.util (java.util)2 Function (java.util.function.Function)2 Collectors (java.util.stream.Collectors)2 BeanUtils (org.springframework.beans.BeanUtils)2 Autowired (org.springframework.beans.factory.annotation.Autowired)2 ObjectUtils (org.springframework.util.ObjectUtils)2 Lists (com.google.common.collect.Lists)1 Ordering (com.google.common.collect.Ordering)1 SprintValidator (io.choerodon.agile.api.validator.SprintValidator)1 IssueCreateVO (io.choerodon.agile.api.vo.business.IssueCreateVO)1