Search in sources :

Example 21 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 22 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 23 with IssueDTO

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

the class ExcelCommonServiceImpl method checkEpicNameExist.

private Boolean checkEpicNameExist(Long projectId, String epicName) {
    IssueDTO issueDTO = new IssueDTO();
    issueDTO.setProjectId(projectId);
    issueDTO.setEpicName(epicName);
    List<IssueDTO> issueDTOList = issueMapper.select(issueDTO);
    return issueDTOList == null || issueDTOList.isEmpty();
}
Also used : IssueDTO(io.choerodon.agile.infra.dto.business.IssueDTO)

Example 24 with IssueDTO

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

the class ExcelCommonServiceImpl method validateAndSetFeature.

private void validateAndSetFeature(Row row, Integer col, ExcelColumnVO excelColumn, Map<Integer, List<Integer>> errorRowColMap, IssueCreateVO issueCreateVO, String issueTypeCode, String issueType) {
    if (IssueTypeCode.AGILE_PARENT_ISSUE_TYPES.contains(issueTypeCode) && !SUB_BUG_CN.equals(issueType)) {
        Cell cell = row.getCell(col);
        if (!isCellEmpty(cell)) {
            int rowNum = row.getRowNum();
            String value = cell.toString();
            List<String> values = excelColumn.getPredefinedValues();
            Map<String, Long> valueIdMap = excelColumn.getValueIdMap();
            if (!values.contains(value)) {
                cell.setCellValue(buildWithErrorMsg(value, "所属特性输入错误"));
                addErrorColumn(rowNum, col, errorRowColMap);
            } else {
                Long featureId = valueIdMap.get(value);
                issueCreateVO.setFeatureId(featureId);
                // 如果特性关联史诗,也要设置史诗id
                IssueDTO feature = issueMapper.selectByPrimaryKey(featureId);
                if (feature != null && Objects.equals(0L, feature.getEpicId())) {
                    issueCreateVO.setEpicId(feature.getEpicId());
                }
            }
        }
    }
}
Also used : IssueDTO(io.choerodon.agile.infra.dto.business.IssueDTO)

Example 25 with IssueDTO

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

the class ExcelServiceImpl method validateData.

private void validateData(Long projectId, Row row, Map<Integer, ExcelColumnVO> headerMap, Set<Integer> withoutParentRows, Map<Integer, List<Integer>> errorRowColMap, IssueCreateVO issueCreateVO, IssueVO parentIssue, int issueTypeCol, int parentCol, Map<Long, List<String>> requireFieldMap) {
    issueCreateVO.setProjectId(projectId);
    int rowNum = row.getRowNum();
    Cell issueTypeCell = row.getCell(issueTypeCol);
    if (issueTypeCell == null) {
        issueTypeCell = row.createCell(issueTypeCol);
    }
    String value = "";
    if (isCellEmpty(issueTypeCell)) {
        issueTypeCell.setCellValue(buildWithErrorMsg(value, IssueConstant.ISSUE_TYPE_CN + "为空"));
        addErrorColumn(rowNum, issueTypeCol, errorRowColMap);
        return;
    }
    value = issueTypeCell.toString();
    if (withoutParentRows.contains(rowNum)) {
        issueTypeCell.setCellValue(buildWithErrorMsg(value, "子任务/子缺陷必须要有父节点"));
        addErrorColumn(rowNum, issueTypeCol, errorRowColMap);
        return;
    }
    String issueTypeCode = getIssueTypeCode(headerMap, value);
    if (parentIssue == null && (IssueTypeCode.isSubTask(issueTypeCode) || SUB_BUG_CN.equals(value))) {
        Cell parentCell = row.getCell(parentCol);
        if (parentCell == null) {
            parentCell = row.createCell(parentCol);
        }
        String parentCellValue = "";
        if (isCellEmpty(parentCell)) {
            issueTypeCell.setCellValue(buildWithErrorMsg(parentCellValue, "子任务/子缺陷必须要有父节点"));
            addErrorColumn(rowNum, parentCol, errorRowColMap);
            return;
        }
        parentCellValue = parentCell.toString();
        List<String> values = headerMap.get(parentCol).getPredefinedValues();
        String issueNum = parentCellValue.split(COLON_CN)[0];
        if (!values.contains(issueNum)) {
            parentCell.setCellValue(buildWithErrorMsg(parentCellValue, "输入的父级编号有误"));
            addErrorColumn(rowNum, parentCol, errorRowColMap);
            return;
        }
        parentIssue = issueMapper.selectByIssueNum(projectId, issueNum);
        if (parentIssue == null) {
            issueTypeCell.setCellValue(buildWithErrorMsg(parentCellValue, "父节点不存在"));
            addErrorColumn(rowNum, parentCol, errorRowColMap);
            return;
        }
        IssueDTO issueDTO = issueMapper.queryIssueSprintNotClosed(projectId, parentIssue.getIssueId());
        parentIssue.setSprintId(issueDTO.getSprintId());
    }
    for (Map.Entry<Integer, ExcelColumnVO> entry : headerMap.entrySet()) {
        Integer col = entry.getKey();
        ExcelColumnVO excelColumn = entry.getValue();
        boolean isCustomField = excelColumn.isCustomField();
        excelCommonService.handlerRequireFiled(excelColumn, requireFieldMap, issueCreateVO, projectId);
        Boolean checkRequireField = excelCommonService.checkRequireField(requireFieldMap, excelColumn, issueCreateVO, row, col, errorRowColMap);
        if (!checkRequireField) {
            break;
        }
        if (isCustomField) {
            excelCommonService.validateCustomFieldData(row, col, excelColumn, errorRowColMap, issueCreateVO);
        } else {
            excelCommonService.validateCommonSystemFieldData(row, col, excelColumn, errorRowColMap, issueCreateVO, parentIssue, projectId, headerMap);
        }
    }
}
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