Search in sources :

Example 26 with IssueDTO

use of io.choerodon.agile.infra.dto.business.IssueDTO 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 27 with IssueDTO

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

the class IssueServiceImpl method pagedQueryByOptions.

@Override
public Page<IssueLinkVO> pagedQueryByOptions(Long projectId, PageRequest pageRequest, IssueQueryVO issueQueryVO) {
    List<Long> issueIds = issueQueryVO.getIssueIds();
    Page emptyPage = PageUtil.emptyPage(pageRequest.getPage(), pageRequest.getSize());
    if (ObjectUtils.isEmpty(issueIds)) {
        return emptyPage;
    }
    Page<IssueDTO> result = PageHelper.doPage(pageRequest, () -> issueMapper.listIssueInfoByIssueIds(projectId, issueIds, issueQueryVO));
    List<IssueDTO> content = result.getContent();
    if (ObjectUtils.isEmpty(content)) {
        return emptyPage;
    }
    List<IssueLinkVO> list = issueAssembler.issueDTOTOVO(projectId, content);
    return PageUtils.copyPropertiesAndResetContent(result, list);
}
Also used : IssueDTO(io.choerodon.agile.infra.dto.business.IssueDTO) Page(io.choerodon.core.domain.Page)

Example 28 with IssueDTO

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

the class IssueServiceImpl method doStateMachineTransformAndCustomFlow.

@Override
public IssueVO doStateMachineTransformAndCustomFlow(Long projectId, Long issueId, String applyType, Set<Long> influenceIssueIds, TriggerCarrierVO triggerCarrierVO, Boolean isDemo, Long transformId, InputDTO inputDTO) {
    IssueDTO issue = issueMapper.selectByPrimaryKey(issueId);
    if (Boolean.TRUE.equals(isDemo)) {
        stateMachineClientService.executeTransformForDemo(projectId, issueId, transformId, issue.getObjectVersionNumber(), applyType, inputDTO);
    } else {
        stateMachineClientService.executeTransform(projectId, issueId, transformId, issue.getObjectVersionNumber(), applyType, inputDTO);
    }
    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);
    }
    return doStateMachineCustomFlow(projectId, issueId, applyType, influenceIssueIds, triggerCarrierVO);
}
Also used : IssueConvertDTO(io.choerodon.agile.infra.dto.business.IssueConvertDTO) IssueDTO(io.choerodon.agile.infra.dto.business.IssueDTO)

Example 29 with IssueDTO

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

the class IssueServiceImpl method queryStoryAndTask.

@Override
public Page<IssueListFieldKVVO> queryStoryAndTask(Long projectId, PageRequest pageRequest, SearchVO searchVO) {
    // 连表查询需要设置主表别名
    Map<String, String> orders = new HashMap<>();
    orders.put(ISSUE_NUM, ISSUE_NUM_CONVERT);
    Sort sort = PageUtil.sortResetOrder(pageRequest.getSort(), null, orders);
    pageRequest.setSort(sort);
    Page<IssueDTO> pageInfo = PageHelper.doPageAndSort(pageRequest, () -> issueMapper.queryStoryAndTaskByProjectId(projectId, searchVO));
    List<IssueDTO> list = pageInfo.getContent();
    if (!CollectionUtils.isEmpty(list)) {
        Long organizationId = projectUtil.getOrganizationId(projectId);
        Map<Long, PriorityVO> priorityMap = priorityService.queryByOrganizationId(organizationId);
        Map<Long, IssueTypeVO> issueTypeDTOMap = issueTypeService.listIssueTypeMap(organizationId, projectId);
        Map<Long, StatusVO> statusMapDTOMap = statusService.queryAllStatusMap(organizationId);
        List<IssueListFieldKVVO> listFieldKVVOS = new ArrayList<>();
        list.forEach(v -> {
            IssueListFieldKVVO map = modelMapper.map(v, IssueListFieldKVVO.class);
            map.setPriorityVO(priorityMap.get(v.getPriorityId()) == null ? null : priorityMap.get(v.getPriorityId()));
            map.setStatusVO(statusMapDTOMap.get(v.getStatusId()) == null ? null : statusMapDTOMap.get(v.getStatusId()));
            map.setIssueTypeVO(issueTypeDTOMap.get(v.getIssueTypeId()) == null ? null : issueTypeDTOMap.get(v.getIssueTypeId()));
            listFieldKVVOS.add(map);
        });
        return PageUtil.buildPageInfoWithPageInfoList(pageInfo, listFieldKVVOS);
    } else {
        return PageUtil.emptyPage(pageRequest.getPage(), pageRequest.getSize());
    }
}
Also used : Sort(io.choerodon.mybatis.pagehelper.domain.Sort) IssueDTO(io.choerodon.agile.infra.dto.business.IssueDTO)

Example 30 with IssueDTO

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

the class IssueServiceImpl method queryIssueByProjectIdAndIssueId.

@Override
public IssueConvertDTO queryIssueByProjectIdAndIssueId(Long projectId, Long issueId) {
    IssueDTO issueDTO = new IssueDTO();
    issueDTO.setProjectId(projectId);
    issueDTO.setIssueId(issueId);
    return modelMapper.map(issueMapper.selectOne(issueDTO), IssueConvertDTO.class);
}
Also used : IssueDTO(io.choerodon.agile.infra.dto.business.IssueDTO)

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