Search in sources :

Example 31 with IssueDTO

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

the class IssueServiceImpl method handleUpdateIssueWithoutRuleNotice.

@Override
public void handleUpdateIssueWithoutRuleNotice(IssueUpdateVO issueUpdateVO, List<String> fieldList, Long projectId) {
    fieldList = new ArrayList<>(fieldList);
    CustomUserDetails customUserDetails = DetailsHelper.getUserDetails();
    IssueDTO originIssue = issueMapper.queryIssueWithNoCloseSprint(issueUpdateVO.getIssueId());
    IssueConvertDTO issueConvertDTO = issueAssembler.toTarget(issueUpdateVO, IssueConvertDTO.class);
    String issueType = originIssue.getTypeCode();
    // 处理用户,前端可能会传0,处理为null
    issueConvertDTO.initializationIssueUser();
    if (fieldList.contains(SPRINT_ID_FIELD)) {
        IssueConvertDTO oldIssue = modelMapper.map(originIssue, IssueConvertDTO.class);
        Long sprintId = issueConvertDTO.getSprintId();
        // 处理子任务的冲刺
        List<Long> issueIds = issueMapper.querySubIssueIdsByIssueId(projectId, issueConvertDTO.getIssueId());
        List<Long> subBugIds = issueMapper.querySubBugIdsByIssueId(projectId, issueConvertDTO.getIssueId());
        if (subBugIds != null && !subBugIds.isEmpty()) {
            issueIds.addAll(subBugIds);
        }
        Boolean exitSprint = issueConvertDTO.getSprintId() != null && !Objects.equals(issueConvertDTO.getSprintId(), 0L);
        Boolean condition = (!Objects.equals(oldIssue.getSprintId(), issueUpdateVO.getSprintId()));
        issueIds.add(issueConvertDTO.getIssueId());
        if (condition) {
            BatchRemoveSprintDTO batchRemoveSprintDTO = new BatchRemoveSprintDTO(projectId, issueConvertDTO.getSprintId(), issueIds);
            issueAccessDataService.removeIssueFromSprintByIssueIds(batchRemoveSprintDTO);
            if (agilePluginService != null) {
                agilePluginService.updateIssueSprintChanged(oldIssue, projectId, sprintId, issueType);
            }
        }
        if (exitSprint) {
            issueAccessDataService.issueToDestinationByIds(projectId, issueConvertDTO.getSprintId(), issueIds, new Date(), customUserDetails.getUserId());
        }
        if (oldIssue.isIssueRank()) {
            calculationRank(projectId, issueConvertDTO);
            fieldList.add(RANK_FIELD);
            issueConvertDTO.setOriginSprintId(originIssue.getSprintId());
        }
    }
    if (fieldList.contains("estimateTime") && !ObjectUtils.isEmpty(issueConvertDTO.getEstimateTime()) && ObjectUtils.isEmpty(originIssue.getRemainingTime())) {
        fieldList.add("remainingTime");
        issueConvertDTO.setRemainingTime(issueConvertDTO.getEstimateTime());
    }
    if (agilePluginService != null) {
        agilePluginService.handlerBusinessUpdateIssue(issueType, fieldList, projectId, issueUpdateVO, originIssue);
        agilePluginService.issueSyncByIssueId(ConvertUtil.getOrganizationId(projectId), issueConvertDTO.getIssueId(), OpenAppIssueSyncConstant.AppType.DIND.getValue(), OpenAppIssueSyncConstant.OperationType.UPDATE);
    }
    if (agileWaterfallService != null) {
        agileWaterfallService.handlerWaterfallUpdateIssue(issueType, fieldList, projectId, issueUpdateVO, originIssue);
    }
    // 处理issue改变状态时,满足条件改变 is_pre_sprint_done 的值
    handleHistorySprintCompleted(projectId, issueConvertDTO, fieldList, originIssue);
    // 处理预计、实际时间
    handleEstimateTimeAndActualTime(issueConvertDTO);
    issueAccessDataService.update(issueConvertDTO, fieldList.toArray(new String[fieldList.size()]));
}
Also used : CustomUserDetails(io.choerodon.core.oauth.CustomUserDetails) IssueConvertDTO(io.choerodon.agile.infra.dto.business.IssueConvertDTO) IssueDTO(io.choerodon.agile.infra.dto.business.IssueDTO)

Example 32 with IssueDTO

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

the class IssueServiceImpl method dragEpic.

@Override
public synchronized EpicDataVO dragEpic(Long projectId, EpicSequenceVO epicSequenceVO) {
    if (epicSequenceVO.getAfterSequence() == null && epicSequenceVO.getBeforeSequence() == null) {
        throw new CommonException("error.dragEpic.noSequence");
    }
    IssueDTO issueDTO = new IssueDTO();
    issueDTO.setIssueId(epicSequenceVO.getEpicId());
    issueDTO.setProjectId(projectId);
    IssueConvertDTO issueConvertDTO = modelMapper.map(issueMapper.selectOne(issueDTO), IssueConvertDTO.class);
    if (issueConvertDTO == null) {
        throw new CommonException("error.issue.notFound");
    } else {
        if (epicSequenceVO.getAfterSequence() == null) {
            Integer maxSequence = productVersionMapper.queryMaxAfterSequence(epicSequenceVO.getBeforeSequence(), projectId);
            epicSequenceVO.setAfterSequence(maxSequence);
        } else if (epicSequenceVO.getBeforeSequence() == null) {
            Integer minSequence = productVersionMapper.queryMinBeforeSequence(epicSequenceVO.getAfterSequence(), projectId);
            epicSequenceVO.setBeforeSequence(minSequence);
        }
        handleSequence(epicSequenceVO, projectId, issueConvertDTO);
    }
    return epicDataAssembler.toTarget(issueMapper.queryEpicListByEpic(epicSequenceVO.getEpicId(), projectId), EpicDataVO.class);
}
Also used : IssueConvertDTO(io.choerodon.agile.infra.dto.business.IssueConvertDTO) IssueDTO(io.choerodon.agile.infra.dto.business.IssueDTO) CommonException(io.choerodon.core.exception.CommonException)

Example 33 with IssueDTO

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

the class IssueServiceImpl method buildTriggerCarrierVO.

@Override
public void buildTriggerCarrierVO(Long projectId, Long issueId, List<TriggerCarrierVO> list, List<Long> customFieldIds) {
    IssueDTO issueDTO = issueMapper.selectByPrimaryKey(issueId);
    if (ObjectUtils.isEmpty(issueDTO)) {
        return;
    }
    TriggerCarrierVO triggerCarrierVO = new TriggerCarrierVO();
    triggerCarrierVO.setInstanceId(issueId);
    triggerCarrierVO.setProjectId(projectId);
    triggerCarrierVO.setIssueTypeId(issueDTO.getIssueTypeId());
    triggerCarrierVO.setNoticeInstanceId(issueId);
    triggerCarrierVO.setFieldList(new ArrayList<>());
    triggerCarrierVO.setExecutedRules(new ArrayList<>());
    triggerCarrierVO.setMemberFieldIds(new HashSet<>(customFieldIds));
    triggerCarrierVO.setAuditDomain(issueDTO);
    list.add(triggerCarrierVO);
}
Also used : IssueDTO(io.choerodon.agile.infra.dto.business.IssueDTO)

Example 34 with IssueDTO

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

the class IssueUserRelServiceImpl method createUserRel.

@Override
@DataLog(type = "createUserRel")
public void createUserRel(Long projectId, Long issueId, List<Long> userIds, String userType) {
    if (!RELATED_PARTIES.equals(userType)) {
        throw new CommonException("error.issue.user.rel.type.illegal");
    }
    IssueDTO issueDTO = issueMapper.selectByPrimaryKey(issueId);
    if (Objects.isNull(issueDTO)) {
        throw new CommonException("error.issue.not.exist");
    }
    if (ObjectUtils.isEmpty(userIds)) {
        return;
    }
    Long organizationId = ConvertUtil.getOrganizationId(projectId);
    userIds.forEach(v -> {
        IssueUserRelDTO issueUserRelDTO = new IssueUserRelDTO();
        issueUserRelDTO.setIssueId(issueId);
        issueUserRelDTO.setUserType(userType);
        issueUserRelDTO.setUserId(v);
        issueUserRelDTO.setProjectId(projectId);
        issueUserRelDTO.setOrganizationId(organizationId);
        baseCreate(issueUserRelDTO);
    });
}
Also used : IssueDTO(io.choerodon.agile.infra.dto.business.IssueDTO) CommonException(io.choerodon.core.exception.CommonException) IssueUserRelDTO(io.choerodon.agile.infra.dto.IssueUserRelDTO) DataLog(io.choerodon.agile.infra.annotation.DataLog)

Example 35 with IssueDTO

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

the class IssueAccessDataServiceImpl method create.

@Override
@DataLog(type = "issueCreate")
public IssueConvertDTO create(IssueConvertDTO issueConvertDTO) {
    // 临时存个优先级code
    issueConvertDTO.setPriorityCode("priority-" + issueConvertDTO.getPriorityId());
    IssueDTO issueDTO = modelMapper.map(issueConvertDTO, IssueDTO.class);
    if (issueMapper.insertSelective(issueDTO) != 1) {
        throw new CommonException(INSERT_ERROR);
    }
    return modelMapper.map(issueMapper.selectByPrimaryKey(issueDTO.getIssueId()), IssueConvertDTO.class);
}
Also used : IssueDTO(io.choerodon.agile.infra.dto.business.IssueDTO) CommonException(io.choerodon.core.exception.CommonException) DataLog(io.choerodon.agile.infra.annotation.DataLog)

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