Search in sources :

Example 1 with IssueDTO

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

the class StateMachineClientServiceImpl method justReporter.

@Condition(code = "just_reporter", name = "仅允许报告人", description = "只有该报告人才能执行转换")
public Boolean justReporter(Long instanceId, StateMachineConfigDTO configDTO) {
    IssueDTO issue = issueMapper.selectByPrimaryKey(instanceId);
    Long currentUserId = DetailsHelper.getUserDetails().getUserId();
    return issue != null && issue.getReporterId() != null && issue.getReporterId().equals(currentUserId);
}
Also used : IssueDTO(io.choerodon.agile.infra.dto.business.IssueDTO) Condition(io.choerodon.agile.infra.statemachineclient.annotation.Condition)

Example 2 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)

Example 3 with IssueDTO

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

the class StateMachineClientServiceImpl method updateStatus.

@UpdateStatus(code = UPDATE_STATUS)
public void updateStatus(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");
    }
    if (issue.getStatusId().equals(targetStatusId)) {
        return;
    }
    Long triggerIssueId = null;
    Boolean autoTranferFlag = null;
    if (input != null && !Objects.equals(input, "null")) {
        JSONObject jsonObject = JSON.parseObject(input, JSONObject.class);
        triggerIssueId = jsonObject.getLong(TRIGGER_ISSUE_ID);
        autoTranferFlag = jsonObject.getBoolean(AUTO_TRANFER_FLAG);
    }
    IssueUpdateVO issueUpdateVO = issueAssembler.toTarget(issue, IssueUpdateVO.class);
    issueUpdateVO.setStatusId(targetStatusId);
    if (Objects.nonNull(triggerIssueId)) {
        IssueDTO issueDTO = issueMapper.selectByPrimaryKey(triggerIssueId);
        issueUpdateVO.setAutoTranferFlag(autoTranferFlag);
        issueUpdateVO.setAutoTriggerId(triggerIssueId);
        issueUpdateVO.setAutoTriggerNum(projectInfoMapper.selectProjectCodeByProjectId(issueDTO.getProjectId()) + "-" + issueDTO.getIssueNum());
    }
    issueService.handleUpdateIssueWithoutRuleNotice(issueUpdateVO, new ArrayList<>(Collections.singletonList(STATUS_ID)), issue.getProjectId());
    logger.info("stateMachine updateStatus successful");
}
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)

Example 4 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 5 with IssueDTO

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

the class PageFieldServiceImpl method getFieldValueMap.

private Map<Long, Map<String, Object>> getFieldValueMap(Long organizationId, List<Long> projectIds, List<Long> instanceIds, Boolean isJustStr) {
    Map<Long, Map<String, Object>> result = new HashMap<>();
    List<FieldValueDTO> values = fieldValueMapper.queryListByInstanceIds(projectIds, instanceIds, "agile_issue", null);
    if (CollectionUtils.isEmpty(values)) {
        return result;
    }
    List<IssueDTO> issueDTOList = issueMapper.queryIssueListWithSubByIssueIds(instanceIds, null, false, false);
    Set<Long> fieldIds = values.stream().map(FieldValueDTO::getFieldId).collect(Collectors.toSet());
    Map<Long, List<IssueDTO>> issueProjectMap = issueDTOList.stream().collect(Collectors.groupingBy(IssueDTO::getProjectId));
    Map<Long, UserDTO> userMap = FieldValueUtil.handleUserMap(values.stream().filter(x -> (FieldType.MEMBER.equals(x.getFieldType()) || FieldType.MULTI_MEMBER.equals(x.getFieldType()))).map(FieldValueDTO::getOptionId).collect(Collectors.toList()));
    issueProjectMap.keySet().forEach(projectId -> {
        List<IssueDTO> issues = issueProjectMap.get(projectId);
        Set<Long> issueTypeIds = issues.stream().map(IssueDTO::getIssueTypeId).collect(Collectors.toSet());
        List<ObjectSchemeFieldDTO> fieldDTOS = objectSchemeFieldMapper.listFieldWithExtendList(organizationId, projectId, fieldIds, issueTypeIds);
        Map<Long, ObjectSchemeFieldDTO> fieldMap = fieldDTOS.stream().collect(Collectors.toMap(ObjectSchemeFieldDTO::getId, Function.identity()));
        Map<Long, List<FieldValueDTO>> valuesMap = values.stream().collect(Collectors.groupingBy(FieldValueDTO::getInstanceId));
        for (IssueDTO issue : issues) {
            List<FieldValueDTO> issueValues = valuesMap.get(issue.getIssueId());
            Map<String, Object> codeValueMap = getCodeValueMap(fieldMap, userMap, isJustStr, issue, issueValues);
            result.put(issue.getIssueId(), codeValueMap);
        }
    });
    return result;
}
Also used : 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) Function(java.util.function.Function) ModelMapper(org.modelmapper.ModelMapper) io.choerodon.agile.infra.enums(io.choerodon.agile.infra.enums) Service(org.springframework.stereotype.Service) io.choerodon.agile.app.service(io.choerodon.agile.app.service) ConvertUtil(io.choerodon.agile.infra.utils.ConvertUtil) CommonException(io.choerodon.core.exception.CommonException) CopyPageField(io.choerodon.agile.infra.annotation.CopyPageField) EnumUtil(io.choerodon.agile.infra.utils.EnumUtil) ProjectCategoryDTO(io.choerodon.agile.infra.feign.vo.ProjectCategoryDTO) ObjectUtils(org.springframework.util.ObjectUtils) BaseFeignClient(io.choerodon.agile.infra.feign.BaseFeignClient) io.choerodon.agile.api.vo(io.choerodon.agile.api.vo) io.choerodon.agile.infra.dto(io.choerodon.agile.infra.dto) Collectors(java.util.stream.Collectors) RankUtil(io.choerodon.agile.infra.utils.RankUtil) FieldValueUtil(io.choerodon.agile.infra.utils.FieldValueUtil) CollectionUtils(org.springframework.util.CollectionUtils) Isolation(org.springframework.transaction.annotation.Isolation) IssueDTO(io.choerodon.agile.infra.dto.business.IssueDTO) Transactional(org.springframework.transaction.annotation.Transactional) IssueDTO(io.choerodon.agile.infra.dto.business.IssueDTO)

Aggregations

IssueDTO (io.choerodon.agile.infra.dto.business.IssueDTO)97 CommonException (io.choerodon.core.exception.CommonException)48 IssueConvertDTO (io.choerodon.agile.infra.dto.business.IssueConvertDTO)9 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 SchemeApplyType (io.choerodon.agile.infra.enums.SchemeApplyType)6 SimpleDateFormat (java.text.SimpleDateFormat)6 Sort (io.choerodon.mybatis.pagehelper.domain.Sort)5 Function (java.util.function.Function)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