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);
}
use of io.choerodon.agile.infra.dto.business.IssueDTO in project agile-service by open-hand.
the class StateMachineClientServiceImpl method updateStatusMove.
@UpdateStatus(code = UPDATE_STATUS_MOVE)
public void updateStatusMove(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");
}
IssueUpdateVO issueUpdateVO = issueAssembler.toTarget(issue, IssueUpdateVO.class);
if (input != null && !Objects.equals(input, "null")) {
JSONObject jsonObject = JSON.parseObject(input, JSONObject.class);
issueUpdateVO.setRank(jsonObject.getString(RANK));
}
if (!issue.getStatusId().equals(targetStatusId)) {
issueUpdateVO.setStatusId(targetStatusId);
issueUpdateVO.setStayDate(new Date());
issueService.handleUpdateIssueWithoutRuleNotice(issueUpdateVO, new ArrayList<>(Arrays.asList(STATUS_ID, RANK, STAY_DATE)), issue.getProjectId());
logger.info("stateMachine updateStatusMove successful");
} else {
issueService.handleUpdateIssueWithoutRuleNotice(issueUpdateVO, new ArrayList<>(Collections.singletonList(RANK)), issue.getProjectId());
}
}
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");
}
use of io.choerodon.agile.infra.dto.business.IssueDTO in project agile-service by open-hand.
the class SprintServiceImpl method queryIssueByOptions.
@Override
public Page<IssueListVO> queryIssueByOptions(Long projectId, Long sprintId, String status, PageRequest pageRequest, Long organizationId) {
SprintDTO sprintDTO = new SprintDTO();
sprintDTO.setProjectId(projectId);
sprintDTO.setSprintId(sprintId);
SprintDTO sprint = sprintMapper.selectOne(sprintDTO);
if (sprint == null || Objects.equals(sprint.getStatusCode(), SPRINT_PLANNING_CODE)) {
throw new CommonException(SPRINT_REPORT_ERROR);
}
Date actualEndDate = sprint.getActualEndDate() == null ? new Date() : sprint.getActualEndDate();
sprint.setActualEndDate(actualEndDate);
Date startDate = sprint.getStartDate();
Page<Long> reportIssuePage = new Page<>();
Map<String, String> maps = new HashMap<>();
maps.put("issueNum", "issue_num_convert");
Sort sort = PageUtil.sortResetOrder(pageRequest.getSort(), "ai", maps);
pageRequest.setSort(sort);
switch(status) {
case DONE:
reportIssuePage = PageHelper.doPageAndSort(pageRequest, () -> reportMapper.queryReportIssueIds(projectId, sprintId, actualEndDate, true));
break;
case UNFINISHED:
reportIssuePage = PageHelper.doPageAndSort(pageRequest, () -> reportMapper.queryReportIssueIds(projectId, sprintId, actualEndDate, false));
break;
case REMOVE:
reportIssuePage = PageHelper.doPageAndSort(pageRequest, () -> reportMapper.queryRemoveIssueIdsDuringSprintWithOutSubEpicIssue(sprint));
break;
default:
break;
}
List<Long> reportIssueIds = reportIssuePage.getContent();
if (reportIssueIds.isEmpty()) {
return new Page<>();
}
Map<Long, StatusVO> statusMapDTOMap = statusService.queryAllStatusMap(organizationId);
// 冲刺报告查询的issue
List<IssueDTO> reportIssues = reportMapper.queryIssueByIssueIds(projectId, reportIssueIds);
// 冲刺中新添加的issue
List<Long> issueIdBeforeSprintList = reportMapper.queryIssueIdsBeforeSprintStart(sprint, new BurnDownSearchVO(), null);
List<Long> issueIdAddList = issueIdBeforeSprintList.isEmpty() ? new ArrayList<>() : reportMapper.queryAddIssueIdsDuringSprint(sprint, new BurnDownSearchVO(), null);
// 冲刺报告中issue的故事点
List<SprintReportIssueStatusDO> reportIssueStoryPoints = reportMapper.queryIssueStoryPoints(projectId, reportIssueIds, actualEndDate);
Map<Long, SprintReportIssueStatusDO> reportIssueStoryPointsMap = reportIssueStoryPoints.stream().collect(Collectors.toMap(SprintReportIssueStatusDO::getIssueId, sprintReportIssueStatusDO -> sprintReportIssueStatusDO));
// 冲刺完成前issue的最后变更状态
List<SprintReportIssueStatusDO> reportIssueBeforeStatus = reportMapper.queryBeforeIssueStatus(projectId, reportIssueIds, startDate, actualEndDate);
Map<Long, SprintReportIssueStatusDO> reportIssueBeforeStatusMap = new HashMap<>();
for (SprintReportIssueStatusDO sprintReportIssueStatusDO : reportIssueBeforeStatus) {
StatusVO statusMapVO = statusMapDTOMap.get(sprintReportIssueStatusDO.getStatusId());
sprintReportIssueStatusDO.setCategoryCode(statusMapVO.getType());
sprintReportIssueStatusDO.setStatusName(statusMapVO.getName());
reportIssueBeforeStatusMap.put(sprintReportIssueStatusDO.getIssueId(), sprintReportIssueStatusDO);
}
// 冲刺完成后issue的最初变更状态
reportIssueIds.removeAll(reportIssueBeforeStatusMap.keySet());
List<SprintReportIssueStatusDO> reportIssueAfterStatus = reportIssueIds.isEmpty() ? new ArrayList<>() : reportMapper.queryAfterIssueStatus(projectId, reportIssueIds, actualEndDate);
Map<Long, SprintReportIssueStatusDO> reportIssueAfterStatusMap = new HashMap<>();
for (SprintReportIssueStatusDO sprintReportIssueStatusDO : reportIssueAfterStatus) {
StatusVO statusMapVO = statusMapDTOMap.get(sprintReportIssueStatusDO.getStatusId());
sprintReportIssueStatusDO.setCategoryCode(statusMapVO.getType());
sprintReportIssueStatusDO.setStatusName(statusMapVO.getName());
reportIssueAfterStatusMap.put(sprintReportIssueStatusDO.getIssueId(), sprintReportIssueStatusDO);
}
reportIssues = reportIssues.stream().map(reportIssue -> {
updateReportIssue(reportIssue, reportIssueStoryPointsMap, reportIssueBeforeStatusMap, reportIssueAfterStatusMap, issueIdAddList);
return reportIssue;
}).collect(Collectors.toList());
Map<Long, PriorityVO> priorityMap = priorityService.queryByOrganizationId(organizationId);
Map<Long, IssueTypeVO> issueTypeDTOMap = issueTypeService.listIssueTypeMap(organizationId, projectId);
return PageUtil.buildPageInfoWithPageInfoList(reportIssuePage, issueAssembler.issueDoToIssueListDto(reportIssues, priorityMap, statusMapDTOMap, issueTypeDTOMap));
}
use of io.choerodon.agile.infra.dto.business.IssueDTO in project agile-service by open-hand.
the class PageFieldServiceImpl method getFieldValueMap.
private Map<Long, Map<String, Object>> getFieldValueMap(Long organizationId, List<Long> projectIds, List<Long> instanceIds, Boolean isJustStr) {
Map<Long, Map<String, Object>> result = new HashMap<>();
List<FieldValueDTO> values = fieldValueMapper.queryListByInstanceIds(projectIds, instanceIds, "agile_issue", null);
if (CollectionUtils.isEmpty(values)) {
return result;
}
List<IssueDTO> issueDTOList = issueMapper.queryIssueListWithSubByIssueIds(instanceIds, null, false, false);
Set<Long> fieldIds = values.stream().map(FieldValueDTO::getFieldId).collect(Collectors.toSet());
Map<Long, List<IssueDTO>> issueProjectMap = issueDTOList.stream().collect(Collectors.groupingBy(IssueDTO::getProjectId));
Map<Long, UserDTO> userMap = FieldValueUtil.handleUserMap(values.stream().filter(x -> (FieldType.MEMBER.equals(x.getFieldType()) || FieldType.MULTI_MEMBER.equals(x.getFieldType()))).map(FieldValueDTO::getOptionId).collect(Collectors.toList()));
issueProjectMap.keySet().forEach(projectId -> {
List<IssueDTO> issues = issueProjectMap.get(projectId);
Set<Long> issueTypeIds = issues.stream().map(IssueDTO::getIssueTypeId).collect(Collectors.toSet());
List<ObjectSchemeFieldDTO> fieldDTOS = objectSchemeFieldMapper.listFieldWithExtendList(organizationId, projectId, fieldIds, issueTypeIds);
Map<Long, ObjectSchemeFieldDTO> fieldMap = fieldDTOS.stream().collect(Collectors.toMap(ObjectSchemeFieldDTO::getId, Function.identity()));
Map<Long, List<FieldValueDTO>> valuesMap = values.stream().collect(Collectors.groupingBy(FieldValueDTO::getInstanceId));
for (IssueDTO issue : issues) {
List<FieldValueDTO> issueValues = valuesMap.get(issue.getIssueId());
Map<String, Object> codeValueMap = getCodeValueMap(fieldMap, userMap, isJustStr, issue, issueValues);
result.put(issue.getIssueId(), codeValueMap);
}
});
return result;
}
Aggregations