igl 9 месяцев назад
Родитель
Сommit
c08ae05ad3

+ 28 - 12
vehicle-server/src/main/java/com/chelvc/cloud/vehicle/server/service/impl/UserInviteServiceImpl.java

@@ -124,22 +124,30 @@ public class UserInviteServiceImpl extends ServiceImpl<UserInviteMapper, UserInv
         if(param.getType() == null){
         if(param.getType() == null){
             List<Long> userIds = records.stream().filter(e -> e.getSourceType() == 1).map(TeamDetailsDTO::getInviteUserId).collect(Collectors.toList());
             List<Long> userIds = records.stream().filter(e -> e.getSourceType() == 1).map(TeamDetailsDTO::getInviteUserId).collect(Collectors.toList());
             List<UserDTO> users = this.userService.listUsers(userIds);
             List<UserDTO> users = this.userService.listUsers(userIds);
-            map = users.stream().collect(Collectors.toMap(UserDTO::getId, UserDTO::getNickname));
-            avatar = users.stream().filter(e -> StringUtils.isNotBlank(e.getAvatar())).collect(Collectors.toMap(UserDTO::getId, UserDTO::getAvatar));
+            if(!CollectionUtils.isEmpty(users)){
+                map = users.stream().collect(Collectors.toMap(UserDTO::getId, UserDTO::getNickname));
+                avatar = users.stream().filter(e -> StringUtils.isNotBlank(e.getAvatar())).collect(Collectors.toMap(UserDTO::getId, UserDTO::getAvatar));
+            }
             List<Long> merchantIds = records.stream().filter(e -> e.getSourceType() == 2).map(TeamDetailsDTO::getInviteUserId).collect(Collectors.toList());
             List<Long> merchantIds = records.stream().filter(e -> e.getSourceType() == 2).map(TeamDetailsDTO::getInviteUserId).collect(Collectors.toList());
             List<MerchantDTO> merchants = this.merchantService.getMerchantByIds(merchantIds);
             List<MerchantDTO> merchants = this.merchantService.getMerchantByIds(merchantIds);
-            map.putAll(merchants.stream().collect(Collectors.toMap(MerchantDTO::getId, MerchantDTO::getName)));
-            avatar.putAll(merchants.stream().collect(Collectors.toMap(MerchantDTO::getId, MerchantDTO::getLogo)));
+            if(!CollectionUtils.isEmpty(users)){
+                map.putAll(merchants.stream().collect(Collectors.toMap(MerchantDTO::getId, MerchantDTO::getName)));
+                avatar.putAll(merchants.stream().collect(Collectors.toMap(MerchantDTO::getId, MerchantDTO::getLogo)));
+            }
         } else if(param.getType() == 1){
         } else if(param.getType() == 1){
             List<Long> ids = records.stream().map(TeamDetailsDTO::getInviteUserId).collect(Collectors.toList());
             List<Long> ids = records.stream().map(TeamDetailsDTO::getInviteUserId).collect(Collectors.toList());
             List<UserDTO> users = this.userService.listUsers(ids);
             List<UserDTO> users = this.userService.listUsers(ids);
-            map = users.stream().collect(Collectors.toMap(UserDTO::getId, UserDTO::getNickname));
-            avatar = users.stream().filter(e -> StringUtils.isNotBlank(e.getAvatar())).collect(Collectors.toMap(UserDTO::getId, UserDTO::getAvatar));
+            if(!CollectionUtils.isEmpty(users)){
+                map = users.stream().collect(Collectors.toMap(UserDTO::getId, UserDTO::getNickname));
+                avatar = users.stream().filter(e -> StringUtils.isNotBlank(e.getAvatar())).collect(Collectors.toMap(UserDTO::getId, UserDTO::getAvatar));
+            }
         } else if(param.getType() == 2){
         } else if(param.getType() == 2){
             List<Long> ids = records.stream().map(TeamDetailsDTO::getInviteUserId).collect(Collectors.toList());
             List<Long> ids = records.stream().map(TeamDetailsDTO::getInviteUserId).collect(Collectors.toList());
             List<MerchantDTO> merchants = this.merchantService.getMerchantByIds(ids);
             List<MerchantDTO> merchants = this.merchantService.getMerchantByIds(ids);
-            map = merchants.stream().collect(Collectors.toMap(MerchantDTO::getId, MerchantDTO::getName));
-            avatar = merchants.stream().filter(e -> StringUtils.isNotBlank(e.getLogo())).collect(Collectors.toMap(MerchantDTO::getId, MerchantDTO::getLogo));
+            if(!CollectionUtils.isEmpty(merchants)) {
+                map = merchants.stream().collect(Collectors.toMap(MerchantDTO::getId, MerchantDTO::getName));
+                avatar = merchants.stream().filter(e -> StringUtils.isNotBlank(e.getLogo())).collect(Collectors.toMap(MerchantDTO::getId, MerchantDTO::getLogo));
+            }
         }
         }
         for(TeamDetailsDTO detailsDTO : records){
         for(TeamDetailsDTO detailsDTO : records){
             detailsDTO.setName(map.get(detailsDTO.getInviteUserId()));
             detailsDTO.setName(map.get(detailsDTO.getInviteUserId()));
@@ -190,18 +198,26 @@ public class UserInviteServiceImpl extends ServiceImpl<UserInviteMapper, UserInv
         if(param.getType() == null){
         if(param.getType() == null){
             List<Long> userIds = records.stream().filter(e -> e.getSourceType() == 1).map(TeamDetailsDTO::getInviteUserId).collect(Collectors.toList());
             List<Long> userIds = records.stream().filter(e -> e.getSourceType() == 1).map(TeamDetailsDTO::getInviteUserId).collect(Collectors.toList());
             List<UserDTO> users = this.userService.listUsers(userIds);
             List<UserDTO> users = this.userService.listUsers(userIds);
-            map = users.stream().collect(Collectors.toMap(UserDTO::getId, UserDTO::getNickname));
+            if(!CollectionUtils.isEmpty(users)){
+                map = users.stream().collect(Collectors.toMap(UserDTO::getId, UserDTO::getNickname));
+            }
             List<Long> merchantIds = records.stream().filter(e -> e.getSourceType() == 2).map(TeamDetailsDTO::getInviteUserId).collect(Collectors.toList());
             List<Long> merchantIds = records.stream().filter(e -> e.getSourceType() == 2).map(TeamDetailsDTO::getInviteUserId).collect(Collectors.toList());
             List<MerchantDTO> merchants = this.merchantService.getMerchantByIds(merchantIds);
             List<MerchantDTO> merchants = this.merchantService.getMerchantByIds(merchantIds);
-            map.putAll(merchants.stream().collect(Collectors.toMap(MerchantDTO::getId, MerchantDTO::getName)));
+            if(!CollectionUtils.isEmpty(merchants)){
+                map.putAll(merchants.stream().collect(Collectors.toMap(MerchantDTO::getId, MerchantDTO::getName)));
+            }
         } else if(param.getType() == 1){
         } else if(param.getType() == 1){
             List<Long> ids = records.stream().map(TeamDetailsDTO::getInviteUserId).collect(Collectors.toList());
             List<Long> ids = records.stream().map(TeamDetailsDTO::getInviteUserId).collect(Collectors.toList());
             List<UserDTO> users = this.userService.listUsers(ids);
             List<UserDTO> users = this.userService.listUsers(ids);
-            map = users.stream().collect(Collectors.toMap(UserDTO::getId, UserDTO::getNickname));
+            if(!CollectionUtils.isEmpty(users)){
+                map = users.stream().collect(Collectors.toMap(UserDTO::getId, UserDTO::getNickname));
+            }
         } else if(param.getType() == 2){
         } else if(param.getType() == 2){
             List<Long> ids = records.stream().map(TeamDetailsDTO::getInviteUserId).collect(Collectors.toList());
             List<Long> ids = records.stream().map(TeamDetailsDTO::getInviteUserId).collect(Collectors.toList());
             List<MerchantDTO> merchants = this.merchantService.getMerchantByIds(ids);
             List<MerchantDTO> merchants = this.merchantService.getMerchantByIds(ids);
-            map = merchants.stream().collect(Collectors.toMap(MerchantDTO::getId, MerchantDTO::getName));
+            if(!CollectionUtils.isEmpty(merchants)){
+                map = merchants.stream().collect(Collectors.toMap(MerchantDTO::getId, MerchantDTO::getName));
+            }
         }
         }
         for(TeamDetailsDTO detailsDTO : records){
         for(TeamDetailsDTO detailsDTO : records){
             detailsDTO.setName(map.get(detailsDTO.getInviteUserId()));
             detailsDTO.setName(map.get(detailsDTO.getInviteUserId()));