use of io.choerodon.agile.infra.dto.business.IssueConvertDTO in project agile-service by open-hand.
the class IssueServiceImpl method handleInitSubIssue.
@Override
public void handleInitSubIssue(IssueConvertDTO subIssueConvertDTO, Long statusId, ProjectInfoDTO projectInfoDTO) {
IssueConvertDTO parentIssueConvertDTO = modelMapper.map(issueMapper.queryIssueSprintNotClosed(subIssueConvertDTO.getProjectId(), subIssueConvertDTO.getParentIssueId()), IssueConvertDTO.class);
// 设置初始状态,跟随父类状态
subIssueConvertDTO = parentIssueConvertDTO.initializationSubIssue(subIssueConvertDTO, statusId, projectInfoDTO);
projectInfoService.updateIssueMaxNum(subIssueConvertDTO.getProjectId(), subIssueConvertDTO.getIssueNum());
// 初始化排序
if (subIssueConvertDTO.isIssueRank()) {
calculationRank(subIssueConvertDTO.getProjectId(), subIssueConvertDTO);
}
setRemainingTime(subIssueConvertDTO);
// 处理预计、实际时间
handleEstimateTimeAndActualTime(subIssueConvertDTO);
}
use of io.choerodon.agile.infra.dto.business.IssueConvertDTO in project agile-service by open-hand.
the class IssueServiceImpl method transformedSubTask.
@Override
public IssueSubVO transformedSubTask(Long projectId, Long organizationId, IssueTransformSubTask issueTransformSubTask) {
IssueConvertDTO issueConvertDTO = modelMapper.map(queryIssueByIssueIdAndProjectId(projectId, issueTransformSubTask.getIssueId()), IssueConvertDTO.class);
if (issueConvertDTO != null) {
if (!issueConvertDTO.getTypeCode().equals(SUB_TASK)) {
issueConvertDTO.setObjectVersionNumber(issueTransformSubTask.getObjectVersionNumber());
List<Long> subIssueIds = issueMapper.querySubIssueIdsByIssueId(projectId, issueConvertDTO.getIssueId());
if (!CollectionUtils.isEmpty(subIssueIds)) {
throw new CommonException("error.transformedSubTask.issueHaveSubIssue");
}
issueConvertDTO.setEpicSequence(null);
issueConvertDTO.setStoryPoints(null);
issueConvertDTO.setStatusId(issueTransformSubTask.getStatusId());
issueConvertDTO.setTypeCode(SUB_TASK);
issueConvertDTO.setIssueTypeId(issueTransformSubTask.getIssueTypeId());
issueConvertDTO.setParentIssueId(issueTransformSubTask.getParentIssueId());
List<String> fieldList = new ArrayList<>();
List<String> list = Arrays.asList(TYPE_CODE_FIELD, ISSUE_TYPE_ID, STATUS_ID, PARENT_ISSUE_ID, EPIC_SEQUENCE, STORY_POINTS_FIELD);
fieldList.addAll(list);
// 如果为Bug类型,就删除与原来问题的关联
if (!Objects.isNull(issueConvertDTO.getRelateIssueId())) {
issueConvertDTO.setRelateIssueId(null);
fieldList.add(RELATE_ISSUE_ID);
}
issueValidator.verifySubTask(issueTransformSubTask.getParentIssueId());
// 删除链接
List<IssueLinkDTO> issueLinkDTOS = issueLinkMapper.listIssueLinkByBatch(projectId, Arrays.asList(issueConvertDTO.getIssueId()));
if (!CollectionUtils.isEmpty(issueLinkDTOS)) {
issueLinkService.deleteIssueLinkByIssueId(issueConvertDTO, issueLinkDTOS);
}
if (agilePluginService != null) {
agilePluginService.handlerProgramValueWhenTransferSubTask(issueConvertDTO, projectId, fieldList);
}
if (agileWaterfallService != null) {
agileWaterfallService.handlerTransferSubTask(issueConvertDTO, projectId, fieldList);
}
issueAccessDataService.update(issueConvertDTO, fieldList.toArray(new String[fieldList.size()]));
Long sprintId = issueMapper.selectUnCloseSprintId(projectId, issueTransformSubTask.getParentIssueId());
List<Long> issueIds = new ArrayList<>();
issueIds.add(issueConvertDTO.getIssueId());
if (sprintId != null) {
insertSprintWhenTransform(issueConvertDTO.getIssueId(), sprintId, projectId, issueIds);
} else {
if (issueMapper.selectUnCloseSprintId(projectId, issueConvertDTO.getIssueId()) != null) {
BatchRemoveSprintDTO batchRemoveSprintDTO = new BatchRemoveSprintDTO(projectId, sprintId, issueIds);
issueAccessDataService.removeIssueFromSprintByIssueIds(batchRemoveSprintDTO);
}
}
IssueSubVO result = queryIssueSub(projectId, organizationId, issueConvertDTO.getIssueId());
setCompletedAndActualCompletedDate(result);
return result;
} else {
throw new CommonException("error.issueValidator.subTaskError");
}
} else {
throw new CommonException("error.issueValidator.issueNoFound");
}
}
use of io.choerodon.agile.infra.dto.business.IssueConvertDTO in project agile-service by open-hand.
the class IssueServiceImpl method issueParentIdUpdate.
@Override
public IssueVO issueParentIdUpdate(Long projectId, IssueUpdateParentIdVO issueUpdateParentIdVO) {
Long issueId = issueUpdateParentIdVO.getIssueId();
IssueDTO issueDTO = issueMapper.selectByPrimaryKey(issueId);
Long parentIssueId = issueUpdateParentIdVO.getParentIssueId();
IssueDTO parentIssueDTO = issueMapper.selectByPrimaryKey(parentIssueId);
IssueValidator.checkParentIdUpdate(issueDTO, parentIssueDTO);
IssueConvertDTO updateIssue = new IssueConvertDTO();
updateIssue.setIssueId(issueId);
updateIssue.setObjectVersionNumber(issueUpdateParentIdVO.getObjectVersionNumber());
updateIssue.setParentIssueId(issueUpdateParentIdVO.getParentIssueId());
// update sprint
updateSubTaskSprint(projectId, issueUpdateParentIdVO);
issueAccessDataService.updateSelective(updateIssue);
if (agileWaterfallService != null) {
agileWaterfallService.handlerSubIssueUpdateParent(projectId, issueId, parentIssueId);
}
return queryIssueCreateWithoutRuleNotice(projectId, issueId);
}
use of io.choerodon.agile.infra.dto.business.IssueConvertDTO in project agile-service by open-hand.
the class IssueServiceImpl method deleteIssue.
// @Saga(code = "agile-delete-issue", description = "删除issue", inputSchemaClass = IssuePayload.class)
@Override
public void deleteIssue(Long projectId, Long issueId) {
IssueConvertDTO issueConvertDTO = queryIssueByProjectIdAndIssueId(projectId, issueId);
if (issueConvertDTO == null) {
throw new CommonException(ERROR_ISSUE_NOT_FOUND);
}
// 更新订阅
workCalendarSubscribeService.handleWorkCalendarSubscribeChanged(projectId, issueId, false, new ArrayList<>());
// 删除issueLink
issueLinkService.deleteByIssueId(issueConvertDTO.getIssueId());
// 删除标签关联
labelIssueRelService.deleteByIssueId(issueConvertDTO.getIssueId());
// 没有issue使用的标签进行垃圾回收
issueLabelService.labelGarbageCollection(projectId);
// 删除模块关联
componentIssueRelService.deleteByIssueId(issueConvertDTO.getIssueId());
// 删除版本关联
versionIssueRelService.deleteByIssueId(issueConvertDTO.getIssueId());
// 删除冲刺关联
issueAccessDataService.deleteIssueFromSprintByIssueId(projectId, issueId);
// 删除评论信息
issueCommentService.deleteByIssueId(issueConvertDTO.getIssueId());
// 删除附件
issueAttachmentService.deleteByIssueId(issueConvertDTO.getIssueId());
// 删除issue关联的知识
if (!Objects.equals(issueConvertDTO.getTypeCode(), "feature")) {
wikiRelationMapper.deleteByIssueId(projectId, issueId);
}
// 删除自定义字段的值
FieldValueDTO fieldValueDTO = new FieldValueDTO();
fieldValueDTO.setProjectId(projectId);
fieldValueDTO.setSchemeCode(AGILE_SCHEME_CODE);
fieldValueDTO.setInstanceId(issueId);
Set<Long> fieldIds = fieldValueMapper.select(fieldValueDTO).stream().map(FieldValueDTO::getFieldId).collect(Collectors.toSet());
fieldValueMapper.deleteList(projectId, issueId, AGILE_SCHEME_CODE, null);
// 不是子任务的issue删除子任务
if (!(SUB_TASK).equals(issueConvertDTO.getTypeCode())) {
if ((ISSUE_EPIC).equals(issueConvertDTO.getTypeCode())) {
// 如果是epic,会把该epic下的issue的epicId置为0
issueAccessDataService.batchUpdateIssueEpicId(projectId, issueConvertDTO.getIssueId());
} else {
redisUtil.deleteRedisCache(new String[] { "Agile:EpicChart" + projectId + ":" + issueConvertDTO.getEpicId() + ":" + "*" });
}
List<IssueDTO> issueDTOList = issueMapper.queryIssueSubList(projectId, issueConvertDTO.getIssueId());
if (issueDTOList != null && !issueDTOList.isEmpty()) {
issueDTOList.forEach(subIssue -> deleteIssue(subIssue.getProjectId(), subIssue.getIssueId()));
}
}
// 清除故事或者任务与子bug的关联
if ("task".equals(issueConvertDTO.getTypeCode()) || STORY_TYPE.equals(issueConvertDTO.getTypeCode())) {
issueMapper.updateSubBugRelateIssueId(projectId, issueId);
}
if (agilePluginService != null) {
agilePluginService.deleteIssueForBusiness(issueConvertDTO);
agilePluginService.issueSyncByIssueId(ConvertUtil.getOrganizationId(projectId), issueId, OpenAppIssueSyncConstant.AppType.DIND.getValue(), OpenAppIssueSyncConstant.OperationType.DELETE);
}
if (backlogExpandService != null) {
backlogExpandService.deleteIssueBacklogRel(issueId);
}
if (agileWaterfallService != null) {
agileWaterfallService.deleteIssueForWaterfall(projectId, issueId, issueConvertDTO);
}
// 删除日志信息
dataLogDeleteByIssueId(projectId, issueId);
deleteRuleLogRel(projectId, issueId, fieldIds);
issueAccessDataService.delete(projectId, issueConvertDTO.getIssueId());
// 删除rank数据
rankMapper.deleteRankByIssueId(issueId);
// delete cache
dataLogRedisUtil.handleDeleteRedisByDeleteIssue(projectId);
testServiceClientOperator.deleteTestRel(projectId, issueId);
if (backlogExpandService != null) {
backlogExpandService.changeDetection(issueId, projectId, ConvertUtil.getOrganizationId(projectId));
}
// 删除issue的参与人数据
issueParticipantRelMapper.deleteByIssueIdAndParticipantIds(projectId, issueId, null);
// 删除当前issue相关的状态联动执行记录
statusLinkageExecutionLogService.deleteByIssueId(projectId, ConvertUtil.getOrganizationId(projectId), issueId);
issuePredecessorService.deleteNode(projectId, issueId);
}
use of io.choerodon.agile.infra.dto.business.IssueConvertDTO in project agile-service by open-hand.
the class IssueProjectMoveServiceImpl method handlerChangeIssueType.
private void handlerChangeIssueType(Long issueId, JSONObject jsonObject, IssueTypeVO issueTypeVO) {
List<String> fieldList = new ArrayList<>(Arrays.asList(FIELD_LIST_NO_RANK));
if (ObjectUtils.isEmpty(issueTypeVO)) {
return;
}
IssueDTO issueDTO = issueMapper.selectByPrimaryKey(issueId);
if (Objects.equals(issueDTO.getIssueTypeId(), issueTypeVO.getId())) {
return;
}
IssueConvertDTO issueConvertDTO = modelMapper.map(issueDTO, IssueConvertDTO.class);
issueConvertDTO.setProjectId(issueDTO.getProjectId());
if (!Objects.equals(issueDTO.getTypeCode(), issueTypeVO.getTypeCode())) {
if ((Objects.equals(issueDTO.getTypeCode(), STORY_TYPE) || Objects.equals(issueDTO.getTypeCode(), TASK_TYPE)) && (!Objects.equals(issueTypeVO.getTypeCode(), STORY_TYPE) && !Objects.equals(issueTypeVO.getTypeCode(), TASK_TYPE))) {
issueMapper.updateSubBugRelateIssueId(issueDTO.getProjectId(), issueDTO.getIssueId());
}
if (issueTypeVO.getTypeCode().equals(ISSUE_EPIC)) {
issueConvertDTO.setRank(null);
fieldList.add(RANK_FIELD);
issueConvertDTO.setTypeCode(issueTypeVO.getTypeCode());
issueConvertDTO.setEpicName(jsonObject.getString(EPIC_NAME_FIELD));
List<LookupValueDTO> colorList = lookupValueMapper.queryLookupValueByCode(EPIC_COLOR_TYPE).getLookupValues();
issueConvertDTO.initializationColor(colorList);
issueConvertDTO.setRemainingTime(null);
issueConvertDTO.setEpicId(0L);
// 排序编号
Integer sequence = issueMapper.queryMaxEpicSequenceByProject(issueConvertDTO.getProjectId());
issueConvertDTO.setEpicSequence(sequence == null ? 0 : sequence + 1);
} else if (issueDTO.getTypeCode().equals(ISSUE_EPIC)) {
// 如果之前类型是epic,会把该epic下的issue的epicId置为0
issueAccessDataService.batchUpdateIssueEpicId(issueConvertDTO.getProjectId(), issueConvertDTO.getIssueId());
issueConvertDTO.setTypeCode(issueTypeVO.getTypeCode());
issueConvertDTO.setColorCode(null);
issueConvertDTO.setEpicName(null);
issueConvertDTO.setEpicSequence(null);
// rank值重置
calculationRank(issueConvertDTO.getProjectId(), issueConvertDTO);
fieldList.add(RANK_FIELD);
} else if ("bug".equals(issueDTO.getTypeCode()) && Objects.nonNull(issueDTO.getRelateIssueId())) {
issueConvertDTO.setTypeCode(issueTypeVO.getTypeCode());
issueConvertDTO.setRelateIssueId(0L);
} else {
issueConvertDTO.setTypeCode(issueTypeVO.getTypeCode());
}
}
issueConvertDTO.setIssueTypeId(issueTypeVO.getId());
issueConvertDTO.setTypeCode(issueTypeVO.getTypeCode());
issueAccessDataService.update(issueConvertDTO, fieldList.toArray(new String[fieldList.size()]));
}
Aggregations