Search in sources :

Example 16 with UserMessageDTO

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

the class SendMsgUtil method sendMsgByIssueMoveComplete.

@Async
public void sendMsgByIssueMoveComplete(Long projectId, IssueMoveVO issueMoveVO, IssueDTO issueDTO, Long operatorId) {
    // 发送消息
    Boolean completed = issueStatusMapper.selectByStatusId(projectId, issueMoveVO.getStatusId()).getCompleted();
    if (completed != null && completed && issueDTO.getAssigneeId() != null && SchemeApplyType.AGILE.equals(issueDTO.getApplyType())) {
        List<Long> userIds = noticeService.queryUserIdsByProjectId(projectId, ISSUE_SOLVE, modelMapper.map(issueDTO, IssueVO.class));
        ProjectVO projectVO = getProjectVO(projectId, ERROR_PROJECT_NOTEXIST);
        StringBuilder url = new StringBuilder();
        ProjectInfoDTO projectInfoDTO = new ProjectInfoDTO();
        projectInfoDTO.setProjectId(projectId);
        List<ProjectInfoDTO> pioList = projectInfoMapper.select(projectInfoDTO);
        ProjectInfoDTO pio = null;
        if (pioList != null && !pioList.isEmpty()) {
            pio = pioList.get(0);
        }
        String pioCode = (pio == null ? "" : pio.getProjectCode());
        issueDTO.setIssueNum(pioCode + "-" + issueDTO.getIssueNum());
        IssueVO issueVO = modelMapper.map(issueDTO, IssueVO.class);
        if (SUB_TASK.equals(issueDTO.getTypeCode())) {
            url.append(getIssueUrl(issueVO, projectVO, issueVO.getParentIssueId()));
        } else {
            url.append(getIssueUrl(issueVO, projectVO, issueVO.getIssueId()));
        }
        String summary = issueDTO.getIssueNum() + "-" + issueDTO.getSummary();
        List<Long> assigneeIds = new ArrayList<>();
        assigneeIds.add(issueDTO.getAssigneeId());
        Map<Long, UserMessageDTO> usersMap = userService.queryUsersMap(assigneeIds, true);
        String userName = Optional.ofNullable(usersMap.get(issueDTO.getAssigneeId())).map(UserMessageDTO::getName).orElse("");
        siteMsgUtil.issueSolve(userIds, userName, summary, url.toString(), projectId, getOperatorNameFromUserDetail(), operatorId);
    }
}
Also used : UserMessageDTO(io.choerodon.agile.infra.dto.UserMessageDTO) IssueVO(io.choerodon.agile.api.vo.business.IssueVO) ProjectVO(io.choerodon.agile.api.vo.ProjectVO) ProjectInfoDTO(io.choerodon.agile.infra.dto.ProjectInfoDTO) Async(org.springframework.scheduling.annotation.Async)

Example 17 with UserMessageDTO

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

the class IssueLinkAssembler method issueLinkDTOToVO.

public List<IssueLinkVO> issueLinkDTOToVO(Long projectId, List<IssueLinkDTO> issueLinkDTOList) {
    List<IssueLinkVO> issueLinkVOList = new ArrayList<>(issueLinkDTOList.size());
    if (!issueLinkDTOList.isEmpty()) {
        Map<Long, IssueTypeVO> issueTypeDTOMap = issueTypeService.listIssueTypeMap(ConvertUtil.getOrganizationId(projectId), projectId);
        Map<Long, StatusVO> statusMapDTOMap = ConvertUtil.getIssueStatusMap(projectId);
        Map<Long, PriorityVO> priorityDTOMap = ConvertUtil.getIssuePriorityMap(projectId);
        List<Long> assigneeIds = issueLinkDTOList.stream().filter(issue -> issue.getAssigneeId() != null && !Objects.equals(issue.getAssigneeId(), 0L)).map(IssueLinkDTO::getAssigneeId).distinct().collect(Collectors.toList());
        Map<Long, UserMessageDTO> usersMap = userService.queryUsersMap(assigneeIds, true);
        issueLinkDTOList.forEach(issueLinkDO -> {
            String assigneeName = usersMap.get(issueLinkDO.getAssigneeId()) != null ? usersMap.get(issueLinkDO.getAssigneeId()).getName() : null;
            String imageUrl = assigneeName != null ? usersMap.get(issueLinkDO.getAssigneeId()).getImageUrl() : null;
            IssueLinkVO issueLinkVO = new IssueLinkVO();
            BeanUtils.copyProperties(issueLinkDO, issueLinkVO);
            issueLinkVO.setIssueTypeVO(issueTypeDTOMap.get(issueLinkDO.getIssueTypeId()));
            issueLinkVO.setStatusVO(statusMapDTOMap.get(issueLinkDO.getStatusId()));
            issueLinkVO.setPriorityVO(priorityDTOMap.get(issueLinkDO.getPriorityId()));
            issueLinkVO.setAssigneeName(assigneeName);
            issueLinkVO.setImageUrl(imageUrl);
            issueLinkVOList.add(issueLinkVO);
        });
    }
    return issueLinkVOList;
}
Also used : StatusVO(io.choerodon.agile.api.vo.StatusVO) IssueTypeVO(io.choerodon.agile.api.vo.IssueTypeVO) Autowired(org.springframework.beans.factory.annotation.Autowired) Collectors(java.util.stream.Collectors) ArrayList(java.util.ArrayList) PriorityVO(io.choerodon.agile.api.vo.PriorityVO) Objects(java.util.Objects) IssueLinkDTO(io.choerodon.agile.infra.dto.IssueLinkDTO) Component(org.springframework.stereotype.Component) List(java.util.List) Map(java.util.Map) UserService(io.choerodon.agile.app.service.UserService) UserMessageDTO(io.choerodon.agile.infra.dto.UserMessageDTO) IssueTypeService(io.choerodon.agile.app.service.IssueTypeService) ConvertUtil(io.choerodon.agile.infra.utils.ConvertUtil) IssueLinkVO(io.choerodon.agile.api.vo.IssueLinkVO) BeanUtils(org.springframework.beans.BeanUtils) ArrayList(java.util.ArrayList) IssueLinkDTO(io.choerodon.agile.infra.dto.IssueLinkDTO) IssueTypeVO(io.choerodon.agile.api.vo.IssueTypeVO) IssueLinkVO(io.choerodon.agile.api.vo.IssueLinkVO) UserMessageDTO(io.choerodon.agile.infra.dto.UserMessageDTO) StatusVO(io.choerodon.agile.api.vo.StatusVO) PriorityVO(io.choerodon.agile.api.vo.PriorityVO)

Example 18 with UserMessageDTO

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

the class IssueSearchAssembler method dtoListToVO.

public List<IssueSearchVO> dtoListToVO(List<IssueSearchDTO> issueSearchDTOList, Map<Long, UserMessageDTO> usersMap, Map<Long, PriorityVO> priorityMap, Map<Long, StatusVO> statusMapDTOMap, Map<Long, IssueTypeVO> issueTypeDTOMap) {
    if (issueSearchDTOList != null && !issueSearchDTOList.isEmpty()) {
        List<IssueSearchVO> issueSearchVOList = new ArrayList<>(issueSearchDTOList.size());
        issueSearchDTOList.forEach(issueSearch -> {
            UserMessageDTO userMessageDTO = usersMap.get(issueSearch.getAssigneeId());
            String assigneeName = userMessageDTO != null ? userMessageDTO.getName() : null;
            String imageUrl = assigneeName != null ? userMessageDTO.getImageUrl() : null;
            String assigneeLoginName = userMessageDTO != null ? userMessageDTO.getLoginName() : null;
            String assigneeRealName = userMessageDTO != null ? userMessageDTO.getRealName() : null;
            issueSearch.setAssigneeName(assigneeName);
            issueSearch.setImageUrl(imageUrl);
            issueSearch.setAssigneeLoginName(assigneeLoginName);
            issueSearch.setAssigneeRealName(assigneeRealName);
            issueSearch.setPriorityVO(priorityMap.get(issueSearch.getPriorityId()));
            issueSearch.setStatusVO(statusMapDTOMap.get(issueSearch.getStatusId()));
            issueSearch.setIssueTypeVO(issueTypeDTOMap.get(issueSearch.getIssueTypeId()));
            issueSearchVOList.add(toTarget(issueSearch, IssueSearchVO.class));
        });
        return issueSearchVOList;
    } else {
        return new ArrayList<>();
    }
}
Also used : IssueSearchVO(io.choerodon.agile.api.vo.business.IssueSearchVO) ArrayList(java.util.ArrayList) UserMessageDTO(io.choerodon.agile.infra.dto.UserMessageDTO)

Example 19 with UserMessageDTO

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

the class NoticeMessageAssembler method messageDTOToVO.

public List<MessageVO> messageDTOToVO(List<MessageDTO> messageDTOList, List<Long> ids) {
    List<MessageVO> messageVOList = new ArrayList<>(messageDTOList.size());
    Map<Long, UserMessageDTO> usersMap = userService.queryUsersMap(ids, true);
    messageDTOList.forEach(messageDTO -> {
        List<IdWithNameVO> idWithNameVOList = new ArrayList<>();
        Boolean checkUser = messageDTO.getEnable() && messageDTO.getUser() != null && messageDTO.getUser().length() != 0 && !"null".equals(messageDTO.getUser());
        if (Boolean.TRUE.equals(checkUser)) {
            String[] strs = messageDTO.getUser().split(",");
            for (String str : strs) {
                Long id = Long.parseLong(str);
                if (usersMap.get(id) != null) {
                    idWithNameVOList.add(new IdWithNameVO(id, usersMap.get(id).getName()));
                }
            }
        }
        MessageVO messageVO = new MessageVO();
        BeanUtils.copyProperties(messageDTO, messageVO);
        messageVO.setIdWithNameVOList(idWithNameVOList);
        messageVOList.add(messageVO);
    });
    return messageVOList;
}
Also used : ArrayList(java.util.ArrayList) UserMessageDTO(io.choerodon.agile.infra.dto.UserMessageDTO) IdWithNameVO(io.choerodon.agile.api.vo.IdWithNameVO) MessageVO(io.choerodon.agile.api.vo.MessageVO)

Example 20 with UserMessageDTO

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

the class FieldPermissionServiceImpl method processPermissionGroupByField.

private Map<Long, List<PermissionVO>> processPermissionGroupByField(Map<Long, Map<String, Map<String, Set<Long>>>> multiKeyMap, Map<Long, UserMessageDTO> userMap, Map<Long, RoleVO> roleMap) {
    Map<Long, List<PermissionVO>> resultMap = new HashMap<>();
    multiKeyMap.forEach((fieldId, map) -> {
        List<PermissionVO> permissionList = resultMap.computeIfAbsent(fieldId, x -> new ArrayList<>());
        map.forEach((permission, map1) -> {
            PermissionVO vo = new PermissionVO();
            permissionList.add(vo);
            vo.setScope(permission);
            Set<Long> userIds = map1.computeIfAbsent(USER, x -> new HashSet<>());
            Set<Long> roleIds = map1.computeIfAbsent(ROLE, x -> new HashSet<>());
            List<Long> userIdList = new ArrayList<>(userIds);
            List<Long> roleIdList = new ArrayList<>(roleIds);
            userIdList.sort(Long::compareTo);
            roleIdList.sort(Long::compareTo);
            List<UserMessageDTO> userList = new ArrayList<>();
            List<RoleVO> roleList = new ArrayList<>();
            vo.setUserList(userList);
            vo.setRoleList(roleList);
            userIdList.forEach(x -> {
                UserMessageDTO user = userMap.get(x);
                if (user != null) {
                    userList.add(user);
                }
            });
            roleIdList.forEach(x -> {
                RoleVO role = roleMap.get(x);
                if (role != null) {
                    roleList.add(role);
                }
            });
        });
    });
    return resultMap;
}
Also used : UserMessageDTO(io.choerodon.agile.infra.dto.UserMessageDTO)

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