Search in sources :

Example 1 with CreateSubIssuePayload

use of io.choerodon.agile.api.vo.event.CreateSubIssuePayload in project agile-service by open-hand.

the class StateMachineClientServiceImpl method handlerSubIssue.

private Long handlerSubIssue(Long projectId, IssueConvertDTO subIssueConvertDTO, IssueSubCreateVO issueSubCreateVO) {
    Long organizationId = ConvertUtil.getOrganizationId(projectId);
    // 获取状态机id
    Long stateMachineId = projectConfigService.queryStateMachineId(projectId, SchemeApplyType.AGILE, subIssueConvertDTO.getIssueTypeId());
    if (stateMachineId == null) {
        throw new CommonException(ERROR_ISSUE_STATE_MACHINE_NOT_FOUND);
    }
    Long initStatusId = issueSubCreateVO.getStatusId();
    if (ObjectUtils.isEmpty(initStatusId)) {
        // 获取初始状态
        initStatusId = instanceService.queryInitStatusId(organizationId, stateMachineId);
        if (initStatusId == null) {
            throw new CommonException(ERROR_ISSUE_STATUS_NOT_FOUND);
        }
    }
    // 获取项目信息
    ProjectInfoDTO projectInfoDTO = new ProjectInfoDTO();
    projectInfoDTO.setProjectId(subIssueConvertDTO.getProjectId());
    ProjectInfoDTO projectInfo = modelMapper.map(projectInfoMapper.selectOne(projectInfoDTO), ProjectInfoDTO.class);
    if (projectInfo == null) {
        throw new CommonException(ERROR_PROJECT_INFO_NOT_FOUND);
    }
    // 创建issue
    subIssueConvertDTO.setApplyType(SchemeApplyType.AGILE);
    // 初始化subIssue
    issueService.handleInitSubIssue(subIssueConvertDTO, initStatusId, projectInfo);
    Long issueId = issueAccessDataService.create(subIssueConvertDTO).getIssueId();
    BaseFieldUtil.updateIssueLastUpdateInfo(issueSubCreateVO.getParentIssueId(), issueSubCreateVO.getProjectId());
    CreateSubIssuePayload createSubIssuePayload = new CreateSubIssuePayload(issueSubCreateVO, subIssueConvertDTO, projectInfo);
    InputDTO inputDTO = new InputDTO(issueId, JSON.toJSONString(createSubIssuePayload));
    // 通过状态机客户端创建实例, 反射验证/条件/后置动作
    StateMachineTransformDTO initTransform = modelMapper.map(instanceService.queryInitTransform(organizationId, stateMachineId), StateMachineTransformDTO.class);
    stateMachineClient.createInstance(initTransform, inputDTO);
    issueService.afterCreateSubIssue(issueId, subIssueConvertDTO, issueSubCreateVO, projectInfo);
    if (agileWaterfallService != null) {
        agileWaterfallService.handlerAfterCreateSubIssue(projectId, issueId, issueSubCreateVO);
    }
    if (agilePluginService != null) {
        agilePluginService.issueSyncByIssueId(organizationId, issueId, OpenAppIssueSyncConstant.AppType.DIND.getValue(), OpenAppIssueSyncConstant.OperationType.CREATE);
    }
    return issueId;
}
Also used : StateMachineTransformDTO(io.choerodon.agile.infra.statemachineclient.dto.StateMachineTransformDTO) CreateSubIssuePayload(io.choerodon.agile.api.vo.event.CreateSubIssuePayload) CommonException(io.choerodon.core.exception.CommonException) InputDTO(io.choerodon.agile.infra.statemachineclient.dto.InputDTO) ProjectInfoDTO(io.choerodon.agile.infra.dto.ProjectInfoDTO)

Aggregations

CreateSubIssuePayload (io.choerodon.agile.api.vo.event.CreateSubIssuePayload)1 ProjectInfoDTO (io.choerodon.agile.infra.dto.ProjectInfoDTO)1 InputDTO (io.choerodon.agile.infra.statemachineclient.dto.InputDTO)1 StateMachineTransformDTO (io.choerodon.agile.infra.statemachineclient.dto.StateMachineTransformDTO)1 CommonException (io.choerodon.core.exception.CommonException)1