//以userid为主,重复数据不获取,不会抛出异常
Map<Long, UserLoginLog> longDateMap = userLoginLogList.stream()
.collect(Collectors.toMap(UserLoginLog::getUserId, Function.identity(), (key1, key2) -> key1));
//业务逻辑
if(longDateMap.containsKey(listVo.getUserId()))
listVo.setLastActivityTime((Objects.nonNull(longDateMap.get(listVo.getUserId()))) ? null : longDateMap.get(listVo.getUserId()).getCreateTime());
//以下会抛出异常
Map<Long, String> userMap = userInfoList.stream()
.collect(Collectors.toMap(k -> k.getUserId(), k -> k.getNickName()));
Map<Long, CustomerInfo> customerInfoMap = customerInfoList.stream().
collect(Collectors.toMap(k -> k.getUserId(), k -> k));
//业务逻辑
if(userMap.containsKey(listVo.getUserId()))
listVo.setNickName(userMap.get(listVo.getUserId()));
if(customerInfoMap.containsKey(listVo.getUserId())){
listVo.setKycTier(customerInfoMap.get(listVo.getUserId()).getIdentityCheckLevelNumber());
标签:Map,listVo,get,longDateMap,List,getUserId,customerInfoMap From: https://www.cnblogs.com/fengquan-blog/p/18036608