Map<Long,User> userMap = users.stream()
.collect(Collectors.toMap(User::getPersonId, user -> user));
List<Long> inventoryPersonIds = users.stream().map(User::getPersonId)
.collect(Collectors.toList());
List<Person> inventoryPersons = personClient.findAllStateByIds(inventoryPersonIds);
Map<Long, Person> personMap = ListUtil.getIdMap(inventoryPersons,Person::getId);
//构建userId到person的map映射
Map<Long, Person> userPersonMap = new HashMap<>(users.size());
for (Map.Entry<Long, User> user : userMap.entrySet()){
userPersonMap.put(user.getValue().getId(), personMap.get(user.getKey()));
}
构建userId到person的map映射
最新推荐文章于 2024-09-08 11:09:43 发布