Search in sources :

Example 16 with IssueDTO

use of io.choerodon.agile.infra.dto.business.IssueDTO in project agile-service by open-hand.

the class DataLogAspect method batchUpdateIssueEpicId.

private void batchUpdateIssueEpicId(Object[] args) {
    Long projectId = (Long) args[0];
    Long issueId = (Long) args[1];
    if (projectId != null && issueId != null) {
        IssueDTO query = new IssueDTO();
        query.setProjectId(projectId);
        query.setEpicId(issueId);
        List<IssueDTO> issueDTOList = issueMapper.select(query);
        issueDTOList.forEach(issueDO -> createIssueEpicLog(0L, issueDO));
    }
}
Also used : IssueDTO(io.choerodon.agile.infra.dto.business.IssueDTO)

Example 17 with IssueDTO

use of io.choerodon.agile.infra.dto.business.IssueDTO in project agile-service by open-hand.

the class ReportServiceImpl method queryIssueByOptions.

@Override
public Page<IssueListVO> queryIssueByOptions(Long projectId, Long versionId, String status, String type, PageRequest pageRequest, Long organizationId) {
    ProductVersionDTO versionDO = new ProductVersionDTO();
    versionDO.setProjectId(projectId);
    versionDO.setVersionId(versionId);
    versionDO = versionMapper.selectOne(versionDO);
    if (versionDO == null || Objects.equals(versionDO.getStatusCode(), VERSION_ARCHIVED_CODE)) {
        throw new CommonException(VERSION_REPORT_ERROR);
    }
    Map<String, String> orders = new HashMap<>();
    orders.put("issueNum", "issue_num_convert");
    Sort sort = PageUtil.sortResetOrder(pageRequest.getSort(), "ai", orders);
    pageRequest.setSort(sort);
    Page<IssueDTO> reportIssuePage = PageHelper.doPageAndSort(pageRequest, () -> reportMapper.queryReportIssues(projectId, versionId, status, type));
    Map<Long, PriorityVO> priorityMap = priorityService.queryByOrganizationId(organizationId);
    Map<Long, IssueTypeVO> issueTypeDTOMap = issueTypeService.listIssueTypeMap(organizationId, projectId);
    Map<Long, StatusVO> statusMapDTOMap = statusService.queryAllStatusMap(organizationId);
    return PageUtil.buildPageInfoWithPageInfoList(reportIssuePage, issueAssembler.issueDoToIssueListDto(reportIssuePage.getContent(), priorityMap, statusMapDTOMap, issueTypeDTOMap));
}
Also used : Sort(io.choerodon.mybatis.pagehelper.domain.Sort) IssueDTO(io.choerodon.agile.infra.dto.business.IssueDTO) CommonException(io.choerodon.core.exception.CommonException)

Example 18 with IssueDTO

use of io.choerodon.agile.infra.dto.business.IssueDTO in project agile-service by open-hand.

the class ReportServiceImpl method handleSprintListAndStartDate.

private JSONObject handleSprintListAndStartDate(Long id, Long projectId, String type) {
    Date startDate;
    List<SprintDTO> sprintDTOList;
    if (E_PIC.equals(type)) {
        IssueDTO issueDTO = issueMapper.queryEpicWithStatusByIssueId(id, projectId);
        if (issueDTO != null) {
            startDate = issueDTO.getCreationDate();
            if (issueDTO.getCompleted() && issueDTO.getDoneDate() != null) {
                sprintDTOList = sprintMapper.queryNotPlanSprintByProjectId(projectId, startDate, issueDTO.getDoneDate());
            } else {
                sprintDTOList = sprintMapper.queryNotPlanSprintByProjectId(projectId, startDate, null);
            }
        } else {
            throw new CommonException(EPIC_OR_VERSION_NOT_FOUND_ERROR);
        }
    } else {
        ProductVersionDTO query = new ProductVersionDTO();
        query.setProjectId(projectId);
        query.setVersionId(id);
        ProductVersionDTO productVersionDTO = versionMapper.selectOne(query);
        if (productVersionDTO != null) {
            startDate = productVersionDTO.getStartDate() == null ? productVersionDTO.getCreationDate() : productVersionDTO.getStartDate();
            sprintDTOList = sprintMapper.queryNotPlanSprintByProjectId(projectId, startDate, productVersionDTO.getReleaseDate());
        } else {
            throw new CommonException(EPIC_OR_VERSION_NOT_FOUND_ERROR);
        }
    }
    JSONObject jsonObject = new JSONObject();
    jsonObject.put(SPRINT_DO_LIST, sprintDTOList);
    jsonObject.put(START_DATE, startDate);
    return jsonObject;
}
Also used : JSONObject(com.alibaba.fastjson.JSONObject) IssueDTO(io.choerodon.agile.infra.dto.business.IssueDTO) CommonException(io.choerodon.core.exception.CommonException)

Example 19 with IssueDTO

use of io.choerodon.agile.infra.dto.business.IssueDTO 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 20 with IssueDTO

use of io.choerodon.agile.infra.dto.business.IssueDTO in project agile-service by open-hand.

the class StateMachineClientServiceImpl method updateStatusMove.

@UpdateStatus(code = UPDATE_STATUS_MOVE)
public void updateStatusMove(Long instanceId, Long targetStatusId, String input) {
    IssueDTO issue = issueMapper.selectByPrimaryKey(instanceId);
    if (issue == null) {
        throw new CommonException("error.updateStatus.instanceId.notFound");
    }
    if (targetStatusId == null) {
        throw new CommonException("error.updateStatus.targetStateId.null");
    }
    IssueUpdateVO issueUpdateVO = issueAssembler.toTarget(issue, IssueUpdateVO.class);
    if (input != null && !Objects.equals(input, "null")) {
        JSONObject jsonObject = JSON.parseObject(input, JSONObject.class);
        issueUpdateVO.setRank(jsonObject.getString(RANK));
    }
    if (!issue.getStatusId().equals(targetStatusId)) {
        issueUpdateVO.setStatusId(targetStatusId);
        issueUpdateVO.setStayDate(new Date());
        issueService.handleUpdateIssueWithoutRuleNotice(issueUpdateVO, new ArrayList<>(Arrays.asList(STATUS_ID, RANK, STAY_DATE)), issue.getProjectId());
        logger.info("stateMachine updateStatusMove successful");
    } else {
        issueService.handleUpdateIssueWithoutRuleNotice(issueUpdateVO, new ArrayList<>(Collections.singletonList(RANK)), issue.getProjectId());
    }
}
Also used : JSONObject(com.alibaba.fastjson.JSONObject) IssueDTO(io.choerodon.agile.infra.dto.business.IssueDTO) CommonException(io.choerodon.core.exception.CommonException) IssueUpdateVO(io.choerodon.agile.api.vo.business.IssueUpdateVO) UpdateStatus(io.choerodon.agile.infra.statemachineclient.annotation.UpdateStatus)

Aggregations

IssueDTO (io.choerodon.agile.infra.dto.business.IssueDTO)105 CommonException (io.choerodon.core.exception.CommonException)51 IssueConvertDTO (io.choerodon.agile.infra.dto.business.IssueConvertDTO)10 BigDecimal (java.math.BigDecimal)9 Collectors (java.util.stream.Collectors)8 Autowired (org.springframework.beans.factory.annotation.Autowired)8 JSONObject (com.alibaba.fastjson.JSONObject)7 io.choerodon.agile.api.vo (io.choerodon.agile.api.vo)7 java.util (java.util)7 ModelMapper (org.modelmapper.ModelMapper)7 ObjectUtils (org.springframework.util.ObjectUtils)7 IssueUpdateVO (io.choerodon.agile.api.vo.business.IssueUpdateVO)6 io.choerodon.agile.infra.dto (io.choerodon.agile.infra.dto)6 Sort (io.choerodon.mybatis.pagehelper.domain.Sort)5 Function (java.util.function.Function)5 Transactional (org.springframework.transaction.annotation.Transactional)5 CollectionUtils (org.springframework.util.CollectionUtils)5 IssueListVO (io.choerodon.agile.api.vo.business.IssueListVO)4 TriggerCarrierVO (io.choerodon.agile.api.vo.business.TriggerCarrierVO)4 DataLog (io.choerodon.agile.infra.annotation.DataLog)4