Search in sources :

Example 1 with InputDTO

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

the class StateMachineClientServiceImpl method handlerIssue.

private Long handlerIssue(IssueCreateVO issueCreateVO, String applyType) {
    issueValidator.checkIssueCreate(issueCreateVO, applyType);
    if (agilePluginService != null) {
        agilePluginService.checkBeforeCreateIssue(issueCreateVO, applyType);
    }
    if (agileWaterfallService != null) {
        agileWaterfallService.checkBeforeCreateIssue(issueCreateVO, applyType);
    }
    IssueConvertDTO issueConvertDTO = issueAssembler.toTarget(issueCreateVO, IssueConvertDTO.class);
    Long projectId = issueConvertDTO.getProjectId();
    Long organizationId = ConvertUtil.getOrganizationId(projectId);
    // 获取状态机id
    Long stateMachineId = statusMachineSchemeConfigMapper.selectStatusMachineIdByIssueTypeId(organizationId, projectId, applyType, issueConvertDTO.getIssueTypeId());
    if (stateMachineId == null) {
        throw new CommonException(ERROR_ISSUE_STATE_MACHINE_NOT_FOUND);
    }
    Long initStatusId = issueCreateVO.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(projectId);
    ProjectInfoDTO projectInfo = projectInfoMapper.selectOne(projectInfoDTO);
    if (projectInfo == null) {
        throw new CommonException(ERROR_PROJECT_INFO_NOT_FOUND);
    }
    // 创建issue
    issueConvertDTO.setApplyType(applyType);
    issueService.handleInitIssue(issueConvertDTO, initStatusId, projectInfo);
    Long issueId = issueAccessDataService.create(issueConvertDTO).getIssueId();
    BaseFieldUtil.updateIssueLastUpdateInfo(issueConvertDTO.getRelateIssueId(), issueConvertDTO.getProjectId());
    // 创建史诗,初始化排序
    if ("issue_epic".equals(issueCreateVO.getTypeCode())) {
        initRank(issueCreateVO, issueId, "epic");
    }
    CreateIssuePayload createIssuePayload = new CreateIssuePayload(issueCreateVO, issueConvertDTO, projectInfo);
    InputDTO inputDTO = new InputDTO(issueId, JSON.toJSONString(createIssuePayload));
    // 通过状态机客户端创建实例, 反射验证/条件/后置动作
    StateMachineTransformDTO initTransform = modelMapper.map(instanceService.queryInitTransform(organizationId, stateMachineId), StateMachineTransformDTO.class);
    stateMachineClient.createInstance(initTransform, inputDTO);
    issueService.afterCreateIssue(issueId, issueConvertDTO, issueCreateVO, projectInfo);
    if (agilePluginService != null) {
        agilePluginService.handlerBusinessAfterCreateIssue(issueConvertDTO, projectId, issueId, issueCreateVO);
        // 同步工作项到第三方
        agilePluginService.issueSyncByIssueId(organizationId, issueId, OpenAppIssueSyncConstant.AppType.DIND.getValue(), OpenAppIssueSyncConstant.OperationType.CREATE);
        // 第三方实例关联:yqcloud等
        agilePluginService.createInstanceOpenRel(projectId, issueId, InstanceType.ISSUE, issueCreateVO.getInstanceOpenRelVO());
    }
    if (agileWaterfallService != null) {
        agileWaterfallService.handlerWaterfallAfterCreateIssue(projectId, issueId, issueCreateVO);
    }
    // 创建交付物
    if (agileWaterfallService != null && issueCreateVO.getTypeCode().equals(IssueTypeCode.MILESTONE.value()) && !ObjectUtils.isEmpty(issueCreateVO.getWaterfallIssueVO()) && !CollectionUtils.isEmpty(issueCreateVO.getWaterfallIssueVO().getWfDeliverableVOS())) {
        agileWaterfallService.createDeliverableService(issueId, issueCreateVO.getWaterfallIssueVO().getWfDeliverableVOS());
    }
    return issueId;
}
Also used : IssueConvertDTO(io.choerodon.agile.infra.dto.business.IssueConvertDTO) StateMachineTransformDTO(io.choerodon.agile.infra.statemachineclient.dto.StateMachineTransformDTO) CreateIssuePayload(io.choerodon.agile.api.vo.event.CreateIssuePayload) CommonException(io.choerodon.core.exception.CommonException) InputDTO(io.choerodon.agile.infra.statemachineclient.dto.InputDTO) ProjectInfoDTO(io.choerodon.agile.infra.dto.ProjectInfoDTO)

Example 2 with InputDTO

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

the class IssueServiceImpl method executionUpdateInfluenceIssue.

@Override
@Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRES_NEW)
public Boolean executionUpdateInfluenceIssue(Long issueId, Long executionStatusId, IssueDTO influenceIssue, Long projectId, String applyType, InfluenceIssueVO influenceIssueVO, Boolean isSub, Map<Long, IssueStatusLinkageVO> issueStatusLinkageMap, TriggerCarrierVO triggerCarrierVO) {
    IssueDTO issue = issueMapper.selectByPrimaryKey(issueId);
    triggerCarrierVO.setInstanceId(issue.getIssueId());
    triggerCarrierVO.setProjectId(projectId);
    triggerCarrierVO.setIssueTypeId(issue.getIssueTypeId());
    triggerCarrierVO.setExecutedRules(new ArrayList<>());
    triggerCarrierVO.setNoticeInstanceId(issue.getIssueId());
    triggerCarrierVO.setFieldList(Collections.singletonList("statusId"));
    triggerCarrierVO.setMemberFieldIds(new HashSet<>());
    if (Boolean.TRUE.equals(influenceIssueVO.getLoop()) || Boolean.TRUE.equals(influenceIssueVO.getMaxDepth())) {
        statusLinkageExecutionLog(influenceIssueVO, issue.getIssueId(), influenceIssue, isSub, issueStatusLinkageMap, null, null);
        return Boolean.TRUE;
    }
    if (Objects.equals("bug", issue.getTypeCode()) && !ObjectUtils.isEmpty(issue.getRelateIssueId()) && !Objects.equals(issue.getRelateIssueId(), 0L)) {
        return Boolean.TRUE;
    }
    if (Objects.equals(issue.getStatusId(), executionStatusId)) {
        statusLinkageExecutionLog(influenceIssueVO, issue.getIssueId(), influenceIssue, isSub, issueStatusLinkageMap, TriggerExecutionStatus.STOP.getValue(), "same_status");
        return Boolean.TRUE;
    }
    Boolean verifyStatusTransferSetting = transferSettingService.verifyStatusTransferSetting(projectId, issue, executionStatusId);
    if (Boolean.TRUE.equals(verifyStatusTransferSetting)) {
        statusLinkageExecutionLog(influenceIssueVO, issue.getIssueId(), influenceIssue, isSub, issueStatusLinkageMap, TriggerExecutionStatus.STOP.getValue(), "condition_limit");
        return Boolean.TRUE;
    }
    // 获取当前状态对应的transformId
    Long stateMachineId = projectConfigService.queryStateMachineId(projectId, applyType, issue.getIssueTypeId());
    // 获取开始状态和结束状态查询转换Id
    Long organizationId = ConvertUtil.getOrganizationId(projectId);
    List<StatusMachineTransformDTO> statusMachineTransformDTOS = statusMachineTransformMapper.selectTransformByStatusId(organizationId, stateMachineId, issue.getStatusId(), executionStatusId, false);
    if (CollectionUtils.isEmpty(statusMachineTransformDTOS)) {
        statusMachineTransformDTOS = statusMachineTransformMapper.selectTransformByStatusId(organizationId, stateMachineId, issue.getStatusId(), executionStatusId, true);
    }
    StatusMachineTransformDTO statusTransform = statusMachineTransformDTOS.get(0);
    stateMachineClientService.executeTransform(projectId, issueId, statusTransform.getId(), issue.getObjectVersionNumber(), applyType, new InputDTO(issueId, "updateStatus", updateTrigger(true, influenceIssue)));
    if (SchemeApplyType.AGILE.equals(applyType)) {
        IssueConvertDTO issueConvertDTO = new IssueConvertDTO();
        issueConvertDTO.setIssueId(issueId);
        issueConvertDTO.setStayDate(new Date());
        issueConvertDTO.setObjectVersionNumber(issueMapper.selectByPrimaryKey(issueId).getObjectVersionNumber());
        issueAccessDataService.updateSelective(issueConvertDTO);
    }
    // 更新属性
    statusFieldSettingService.handlerSettingToUpdateIssue(projectId, issueId, triggerCarrierVO);
    AgilePluginService agilePluginService = SpringBeanUtil.getExpandBean(AgilePluginService.class);
    if (agilePluginService != null) {
        agilePluginService.storyLinkageFeature(projectId, issue, applyType);
    }
    // 记录联动的执行日志
    statusLinkageExecutionLog(influenceIssueVO, issueId, influenceIssue, isSub, issueStatusLinkageMap, null, null);
    LOGGER.info("项目{}下状态联动触发{}编号为{}的issue状态变更", issue.getProjectId(), IssueConstant.ISSUE_CN, issue.getIssueNum());
    triggerCarrierVO.setAuditDomain(issueMapper.selectByPrimaryKey(issueId));
    this.self().batchUpdateInvokeTrigger(Collections.singletonList(triggerCarrierVO));
    return Boolean.FALSE;
}
Also used : IssueConvertDTO(io.choerodon.agile.infra.dto.business.IssueConvertDTO) IssueDTO(io.choerodon.agile.infra.dto.business.IssueDTO) InputDTO(io.choerodon.agile.infra.statemachineclient.dto.InputDTO) Transactional(org.springframework.transaction.annotation.Transactional)

Example 3 with InputDTO

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

the class IssueServiceImpl method updateIssueStatus.

@Override
public IssueVO updateIssueStatus(Long projectId, Long issueId, Long transformId, Long objectVersionNumber, String applyType, IssueDTO triggerIssue, boolean autoTranferFlag) {
    Set<Long> influenceIssueIds = new HashSet<>();
    IssueVO result = this.self().doStateMachineCustomFlowAndRuleNotice(projectId, issueId, applyType, influenceIssueIds, false, transformId, new InputDTO(issueId, "updateStatus", updateTrigger(autoTranferFlag, triggerIssue)));
    if (backlogExpandService != null) {
        backlogExpandService.changeDetection(issueId, projectId, ConvertUtil.getOrganizationId(projectId));
    }
    IssueVO issueVO = queryIssueByUpdate(projectId, issueId, Collections.singletonList(STATUS_ID));
    issueVO.setInfluenceIssueIds(new ArrayList<>(influenceIssueIds));
    if (result != null) {
        issueVO.setErrorMsg(result.getErrorMsg());
    }
    return issueVO;
}
Also used : InputDTO(io.choerodon.agile.infra.statemachineclient.dto.InputDTO)

Example 4 with InputDTO

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

the class IssueServiceImpl method executionUpdateInfluenceIssue.

@Override
@Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRES_NEW)
public Boolean executionUpdateInfluenceIssue(Long issueId, Long executionStatusId, IssueDTO influenceIssue, Long projectId, String applyType, InfluenceIssueVO influenceIssueVO, Boolean isSub, Map<Long, LinkIssueStatusLinkageVO> linkIssueStatusMap, TriggerCarrierVO triggerCarrierVO) {
    IssueDTO issue = issueMapper.selectByPrimaryKey(issueId);
    triggerCarrierVO.setInstanceId(issue.getIssueId());
    triggerCarrierVO.setProjectId(projectId);
    triggerCarrierVO.setIssueTypeId(issue.getIssueTypeId());
    triggerCarrierVO.setExecutedRules(new ArrayList<>());
    triggerCarrierVO.setNoticeInstanceId(issue.getIssueId());
    triggerCarrierVO.setFieldList(Collections.singletonList("statusId"));
    triggerCarrierVO.setMemberFieldIds(new HashSet<>());
    if (Boolean.TRUE.equals(influenceIssueVO.getLoop()) || Boolean.TRUE.equals(influenceIssueVO.getMaxDepth())) {
        statusLinkageExecutionLog(influenceIssueVO, issue.getIssueId(), influenceIssue, isSub, linkIssueStatusMap, null, null);
        return Boolean.TRUE;
    }
    if (Objects.equals("bug", issue.getTypeCode()) && !ObjectUtils.isEmpty(issue.getRelateIssueId()) && !Objects.equals(issue.getRelateIssueId(), 0L)) {
        return Boolean.TRUE;
    }
    if (Objects.equals(issue.getStatusId(), executionStatusId)) {
        statusLinkageExecutionLog(influenceIssueVO, issue.getIssueId(), influenceIssue, isSub, linkIssueStatusMap, TriggerExecutionStatus.STOP.getValue(), "same_status");
        return Boolean.TRUE;
    }
    Boolean verifyStatusTransferSetting = transferSettingService.verifyStatusTransferSetting(projectId, issue, executionStatusId);
    if (Boolean.TRUE.equals(verifyStatusTransferSetting)) {
        statusLinkageExecutionLog(influenceIssueVO, issue.getIssueId(), influenceIssue, isSub, linkIssueStatusMap, TriggerExecutionStatus.STOP.getValue(), "condition_limit");
        return Boolean.TRUE;
    }
    // 获取当前状态对应的transformId
    Long stateMachineId = projectConfigService.queryStateMachineId(projectId, applyType, issue.getIssueTypeId());
    // 获取开始状态和结束状态查询转换Id
    Long organizationId = ConvertUtil.getOrganizationId(projectId);
    List<StatusMachineTransformDTO> statusMachineTransformDTOS = statusMachineTransformMapper.selectTransformByStatusId(organizationId, stateMachineId, issue.getStatusId(), executionStatusId, false);
    if (CollectionUtils.isEmpty(statusMachineTransformDTOS)) {
        statusMachineTransformDTOS = statusMachineTransformMapper.selectTransformByStatusId(organizationId, stateMachineId, issue.getStatusId(), executionStatusId, true);
    }
    StatusMachineTransformDTO statusTransform = statusMachineTransformDTOS.get(0);
    stateMachineClientService.executeTransform(projectId, issueId, statusTransform.getId(), issue.getObjectVersionNumber(), applyType, new InputDTO(issueId, "updateStatus", updateTrigger(true, influenceIssue)));
    if (SchemeApplyType.AGILE.equals(applyType)) {
        IssueConvertDTO issueConvertDTO = new IssueConvertDTO();
        issueConvertDTO.setIssueId(issueId);
        issueConvertDTO.setStayDate(new Date());
        issueConvertDTO.setObjectVersionNumber(issueMapper.selectByPrimaryKey(issueId).getObjectVersionNumber());
        issueAccessDataService.updateSelective(issueConvertDTO);
    }
    // 更新属性
    statusFieldSettingService.handlerSettingToUpdateIssue(projectId, issueId, triggerCarrierVO);
    AgilePluginService agilePluginService = SpringBeanUtil.getExpandBean(AgilePluginService.class);
    if (agilePluginService != null) {
        agilePluginService.storyLinkageFeature(projectId, issue, applyType);
    }
    // 记录联动的执行日志
    statusLinkageExecutionLog(influenceIssueVO, issueId, influenceIssue, isSub, linkIssueStatusMap, null, null);
    LOGGER.info("项目{}下状态联动触发{}编号为{}的issue状态变更", issue.getProjectId(), IssueConstant.ISSUE_CN, issue.getIssueNum());
    triggerCarrierVO.setAuditDomain(issueMapper.selectByPrimaryKey(issueId));
    this.self().batchUpdateInvokeTrigger(Collections.singletonList(triggerCarrierVO));
    return Boolean.FALSE;
}
Also used : IssueConvertDTO(io.choerodon.agile.infra.dto.business.IssueConvertDTO) IssueDTO(io.choerodon.agile.infra.dto.business.IssueDTO) InputDTO(io.choerodon.agile.infra.statemachineclient.dto.InputDTO) Transactional(org.springframework.transaction.annotation.Transactional)

Example 5 with InputDTO

use of io.choerodon.agile.infra.statemachineclient.dto.InputDTO 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

InputDTO (io.choerodon.agile.infra.statemachineclient.dto.InputDTO)7 IssueConvertDTO (io.choerodon.agile.infra.dto.business.IssueConvertDTO)3 IssueDTO (io.choerodon.agile.infra.dto.business.IssueDTO)3 CommonException (io.choerodon.core.exception.CommonException)3 ProjectInfoDTO (io.choerodon.agile.infra.dto.ProjectInfoDTO)2 StateMachineTransformDTO (io.choerodon.agile.infra.statemachineclient.dto.StateMachineTransformDTO)2 Transactional (org.springframework.transaction.annotation.Transactional)2 IssueVO (io.choerodon.agile.api.vo.business.IssueVO)1 CreateIssuePayload (io.choerodon.agile.api.vo.event.CreateIssuePayload)1 CreateSubIssuePayload (io.choerodon.agile.api.vo.event.CreateSubIssuePayload)1