Search in sources :

Example 1 with UserMessageDTO

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

the class SendMsgUtil method getOperatorNameFromUserDetail.

private String getOperatorNameFromUserDetail() {
    CustomUserDetails userDetails = DetailsHelper.getUserDetails();
    if (ObjectUtils.isEmpty(userDetails)) {
        throw new CommonException("error.user.not.login");
    }
    Long userId = userDetails.getUserId();
    Map<Long, UserMessageDTO> userMap = userService.queryUsersMap(Arrays.asList(userId), true);
    UserMessageDTO user = userMap.get(userId);
    if (ObjectUtils.isEmpty(user)) {
        return null;
    } else {
        return user.getName();
    }
}
Also used : CustomUserDetails(io.choerodon.core.oauth.CustomUserDetails) CommonException(io.choerodon.core.exception.CommonException) UserMessageDTO(io.choerodon.agile.infra.dto.UserMessageDTO)

Example 2 with UserMessageDTO

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

the class SendMsgUtil method noticeIssueStatus.

@Async
public void noticeIssueStatus(Long projectId, Set<Long> userSet, List<String> noticeTypeList, IssueDTO issueDTO, CustomUserDetails userDetails) {
    boolean onlyWebHook = CollectionUtils.isNotEmpty(noticeTypeList) && noticeTypeList.size() == 1 && noticeTypeList.contains("WEB_HOOK");
    if (!onlyWebHook && CollectionUtils.isEmpty(userSet)) {
        return;
    }
    Map<String, String> templateArgsMap = new HashMap<>();
    // 设置经办人
    Long[] ids = new Long[3];
    ids[0] = issueDTO.getAssigneeId();
    ids[1] = userDetails.getUserId();
    ids[2] = issueDTO.getReporterId();
    Map<Long, UserMessageDTO> usersMap = userService.queryUsersMap(Arrays.asList(ids), true);
    ProjectVO projectVO = getProjectVO(projectId, ERROR_PROJECT_NOTEXIST);
    Boolean isProgram = Objects.equals(issueDTO.getApplyType(), "program");
    String actionType = Boolean.TRUE.equals(isProgram) ? "报告的" : "经办的";
    UserMessageDTO assignee = Boolean.TRUE.equals(isProgram) ? usersMap.get(issueDTO.getReporterId()) : usersMap.get(issueDTO.getAssigneeId());
    String assigneeName = !Objects.isNull(assignee) ? assignee.getName() : "";
    // 设置概要
    String summary = projectVO.getCode() + "-" + issueDTO.getIssueNum() + "-" + issueDTO.getSummary();
    // 设置操作人
    UserMessageDTO operator = usersMap.get(userDetails.getUserId());
    String operatorName = !Objects.isNull(operator) ? operator.getName() : "";
    // 设置状态
    String status = ConvertUtil.getIssueStatusMap(projectId).get(issueDTO.getStatusId()).getName();
    // 设置url
    String url;
    IssueVO issueVO = modelMapper.map(issueDTO, IssueVO.class);
    if (isProgram) {
        url = getFeatureUrl(issueVO, projectVO, issueDTO.getIssueId());
    } else {
        url = getIssueUrl(issueVO, projectVO, issueDTO.getIssueId());
    }
    templateArgsMap.put("actionType", Objects.equals("", assigneeName) ? "" : actionType);
    templateArgsMap.put("assigneeName", assigneeName);
    templateArgsMap.put("summary", summary);
    templateArgsMap.put("operatorName", operatorName);
    templateArgsMap.put("status", status);
    templateArgsMap.put("url", url);
    templateArgsMap.put("link", domainUrl + "/" + url);
    siteMsgUtil.sendChangeIssueStatus(projectId, userSet, noticeTypeList, templateArgsMap, userDetails.getUserId(), onlyWebHook);
}
Also used : UserMessageDTO(io.choerodon.agile.infra.dto.UserMessageDTO) IssueVO(io.choerodon.agile.api.vo.business.IssueVO) ProjectVO(io.choerodon.agile.api.vo.ProjectVO) Async(org.springframework.scheduling.annotation.Async)

Example 3 with UserMessageDTO

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

the class TeamPerformanceServiceImpl method querySprintStoryPoint.

@Override
public List<SprintStoryPointVO> querySprintStoryPoint(Long projectId) {
    List<SprintStoryPointVO> sprintStoryPoints = teamPerformanceMapper.querySprintStoryPoints(projectId);
    BigDecimal sumStoryPoints = new BigDecimal(0);
    BigDecimal sumStoryPointsComplete = new BigDecimal(0);
    List<Long> mainResponsibleIds = new ArrayList<>();
    for (SprintStoryPointVO sprintStoryPoint : sprintStoryPoints) {
        if (Objects.nonNull(sprintStoryPoint)) {
            sumStoryPoints = DataUtil.add(sumStoryPoints, sprintStoryPoint.getStoryPoints());
            sumStoryPointsComplete = DataUtil.add(sumStoryPointsComplete, sprintStoryPoint.getStoryPointsComplete());
            Long mainResponsibleId = sprintStoryPoint.getMainResponsibleId();
            if (Objects.nonNull(mainResponsibleId)) {
                mainResponsibleIds.add(mainResponsibleId);
            }
        }
    }
    Map<Long, UserMessageDTO> usersMap = userService.queryUsersMap(mainResponsibleIds, true);
    for (SprintStoryPointVO sprintStoryPoint : sprintStoryPoints) {
        handleUser(sprintStoryPoint, usersMap);
        handleMainRate(sumStoryPoints, sumStoryPointsComplete, sprintStoryPoint);
    }
    return sprintStoryPoints;
}
Also used : SprintStoryPointVO(io.choerodon.agile.api.vo.SprintStoryPointVO) UserMessageDTO(io.choerodon.agile.infra.dto.UserMessageDTO) BigDecimal(java.math.BigDecimal)

Example 4 with UserMessageDTO

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

the class TeamPerformanceServiceImpl method handleUser.

private void handleUser(SprintStoryPointVO sprintStoryPointVO, Map<Long, UserMessageDTO> usersMap) {
    UserMessageDTO mainResponsible = usersMap.get(sprintStoryPointVO.getMainResponsibleId());
    if (Objects.isNull(mainResponsible)) {
        return;
    }
    sprintStoryPointVO.setLoginName(mainResponsible.getLoginName());
    sprintStoryPointVO.setRealName(mainResponsible.getRealName());
    sprintStoryPointVO.setName(new StringBuilder().append(mainResponsible.getRealName()).append(LEFT_PARENTHESIS).append(mainResponsible.getLoginName()).append(RIGHT_PARENTHESIS).toString());
}
Also used : UserMessageDTO(io.choerodon.agile.infra.dto.UserMessageDTO)

Example 5 with UserMessageDTO

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

the class TeamPerformanceServiceImpl method querySprintTaskTime.

@Override
public List<SprintTaskVO> querySprintTaskTime(Long projectId) {
    List<SprintTaskVO> sprintTasks = teamPerformanceMapper.querySprintTaskTime(projectId);
    BigDecimal sumRemainingTime = new BigDecimal(0);
    BigDecimal remainingTimeComplete = new BigDecimal(0);
    List<Long> mainResponsibleIds = new ArrayList<>();
    for (SprintTaskVO sprintTask : sprintTasks) {
        if (Objects.nonNull(sprintTask)) {
            sumRemainingTime = DataUtil.add(sumRemainingTime, sprintTask.getRemainingTime());
            remainingTimeComplete = DataUtil.add(remainingTimeComplete, sprintTask.getRemainingTimeComplete());
            Long mainResponsibleId = sprintTask.getMainResponsibleId();
            if (Objects.nonNull(mainResponsibleId)) {
                mainResponsibleIds.add(mainResponsibleId);
            }
        }
    }
    Map<Long, UserMessageDTO> usersMap = userService.queryUsersMap(ListUtil.filterByKey(mainResponsibleIds, 0L), true);
    for (SprintTaskVO sprintTask : sprintTasks) {
        handleUser(sprintTask, usersMap.get(sprintTask.getMainResponsibleId()));
        handleMainRate(sumRemainingTime, remainingTimeComplete, sprintTask);
    }
    return sprintTasks;
}
Also used : UserMessageDTO(io.choerodon.agile.infra.dto.UserMessageDTO) SprintTaskVO(io.choerodon.agile.api.vo.SprintTaskVO) BigDecimal(java.math.BigDecimal)

Aggregations

UserMessageDTO (io.choerodon.agile.infra.dto.UserMessageDTO)25 Collectors (java.util.stream.Collectors)7 Autowired (org.springframework.beans.factory.annotation.Autowired)7 UserService (io.choerodon.agile.app.service.UserService)5 CommonException (io.choerodon.core.exception.CommonException)5 ArrayList (java.util.ArrayList)5 TypeToken (org.modelmapper.TypeToken)5 io.choerodon.agile.api.vo (io.choerodon.agile.api.vo)4 IssueCommentDTO (io.choerodon.agile.infra.dto.IssueCommentDTO)4 UserDTO (io.choerodon.agile.infra.dto.UserDTO)4 ConvertUtil (io.choerodon.agile.infra.utils.ConvertUtil)4 java.util (java.util)4 Component (org.springframework.stereotype.Component)4 ObjectUtils (org.springframework.util.ObjectUtils)4 ProjectVO (io.choerodon.agile.api.vo.ProjectVO)3 IssueVO (io.choerodon.agile.api.vo.business.IssueVO)3 Page (io.choerodon.core.domain.Page)3 CustomUserDetails (io.choerodon.core.oauth.CustomUserDetails)3 BigDecimal (java.math.BigDecimal)3 List (java.util.List)3