Search in sources :

Example 1 with IssuePredecessorDTO

use of io.choerodon.agile.infra.dto.IssuePredecessorDTO 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 2 with IssuePredecessorDTO

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

the class IssuePredecessorServiceImpl method queryExistedPredecessorIds.

private Set<Long> queryExistedPredecessorIds(Long organizationId, Long projectId, Long currentIssueId) {
    IssuePredecessorDTO example = new IssuePredecessorDTO();
    example.setOrganizationId(organizationId);
    example.setProjectId(projectId);
    example.setIssueId(currentIssueId);
    return issuePredecessorMapper.select(example).stream().map(IssuePredecessorDTO::getPredecessorId).collect(Collectors.toSet());
}
Also used : IssuePredecessorDTO(io.choerodon.agile.infra.dto.IssuePredecessorDTO)

Example 3 with IssuePredecessorDTO

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

the class IssuePredecessorServiceImpl method deletePredecessor.

@Override
public void deletePredecessor(Long projectId, Long predecessorId, Long currentIssueId) {
    Long organizationId = ConvertUtil.getOrganizationId(projectId);
    List<IssuePredecessorTreeClosureDTO> currentIssueDescendants = issuePredecessorTreeClosureMapper.selectByAncestorIds(organizationId, projectId, new HashSet<>(Collections.singletonList(currentIssueId)));
    List<Long> samePredecessorIssueIds = issuePredecessorMapper.selectByPredecessorId(projectId, predecessorId);
    List<Long> ignoredDescendantIds = new ArrayList<>();
    samePredecessorIssueIds.remove(currentIssueId);
    if (!samePredecessorIssueIds.isEmpty()) {
        ignoredDescendantIds = issuePredecessorTreeClosureMapper.selectByAncestorIds(organizationId, projectId, new HashSet<>(samePredecessorIssueIds)).stream().map(IssuePredecessorTreeClosureDTO::getDescendantId).collect(Collectors.toList());
    }
    // 过滤其他相同前置依赖的子级
    Set<IssuePredecessorTreeClosureDTO> deleteDescendants = new HashSet<>();
    for (IssuePredecessorTreeClosureDTO descendant : currentIssueDescendants) {
        if (!ignoredDescendantIds.contains(descendant.getDescendantId())) {
            deleteDescendants.add(descendant);
            descendant.setAncestorId(predecessorId);
        }
    }
    if (!deleteDescendants.isEmpty()) {
        issuePredecessorTreeClosureMapper.batchDelete(organizationId, projectId, deleteDescendants);
    }
    IssuePredecessorDTO delete = new IssuePredecessorDTO();
    delete.setProjectId(projectId);
    delete.setOrganizationId(organizationId);
    delete.setIssueId(currentIssueId);
    delete.setPredecessorId(predecessorId);
    issuePredecessorMapper.delete(delete);
}
Also used : IssuePredecessorDTO(io.choerodon.agile.infra.dto.IssuePredecessorDTO) IssuePredecessorTreeClosureDTO(io.choerodon.agile.infra.dto.IssuePredecessorTreeClosureDTO)

Example 4 with IssuePredecessorDTO

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

the class IssuePredecessorServiceImpl method insertIssPredecessor.

private void insertIssPredecessor(Long organizationId, Long projectId, List<IssuePredecessorVO> issuePredecessors, Long issueId) {
    IssuePredecessorDTO example = new IssuePredecessorDTO();
    example.setProjectId(projectId);
    example.setOrganizationId(organizationId);
    example.setIssueId(issueId);
    issuePredecessorMapper.delete(example);
    List<IssuePredecessorDTO> issuePredecessorList = new ArrayList<>();
    issuePredecessors.forEach(issuePredecessor -> {
        IssuePredecessorDTO dto = new IssuePredecessorDTO();
        dto.setIssueId(issuePredecessor.getIssueId());
        dto.setPredecessorId(issuePredecessor.getPredecessorId());
        dto.setPredecessorType(issuePredecessor.getPredecessorType().toLowerCase());
        dto.setProjectId(projectId);
        dto.setOrganizationId(organizationId);
        if (!issuePredecessorList.contains(dto)) {
            issuePredecessorList.add(dto);
        }
    });
    if (!issuePredecessorList.isEmpty()) {
        Long operator = DetailsHelper.getUserDetails().getUserId();
        issuePredecessorMapper.batchInsert(issuePredecessorList, operator);
    }
}
Also used : IssuePredecessorDTO(io.choerodon.agile.infra.dto.IssuePredecessorDTO)

Aggregations

IssuePredecessorDTO (io.choerodon.agile.infra.dto.IssuePredecessorDTO)4 IssueListVO (io.choerodon.agile.api.vo.business.IssueListVO)1 IssuePredecessorTreeClosureDTO (io.choerodon.agile.infra.dto.IssuePredecessorTreeClosureDTO)1 IssueDTO (io.choerodon.agile.infra.dto.business.IssueDTO)1 ModelMapper (org.modelmapper.ModelMapper)1 TypeToken (org.modelmapper.TypeToken)1