List<BspGroupDepartment> groupsByDeparIds =
groupService.getGroupsByDeparIds(departParentIds); //負責父級部門的賬戶組id集合
List<String> parentGroupIds = groupsByDeparIds.stream().map(one->one.getGroupId()).collect(Collectors.toList());
// logger.info("負責父級部門的賬戶組id集合Id=" +JSON.toJSONString(parentGroupIds));
List<BspPerson> persons = bspPersonService.getByGroupIds(parentGroupIds);
//根據personId去重
uniquePersons = persons.stream().collect(
Collectors.collectingAndThen(
Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(BspPerson::getPersonId))), ArrayList::new)
);
//抽取對象集合中對象的id成id集合(List<String>)
List<BspGroupDepartment> groupsByDeparIds = New ArrayList<BspGroupDepartment>();
List<String> parentGroupIds = groupsByDeparIds.stream().map(one->one.getGroupId()).collect(Collectors.toList());
//根據一個屬性去重(personId)
List<BspPerson> uniquePersons = persons.stream().collect(
Collectors.collectingAndThen(
Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(BspPerson::getPersonId))), ArrayList::new)
//根據多個屬性去重
List<ClassEntity> distinctClass = classEntities.stream().collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(o -> o.getProfessionId() + ";" + o.getGrade()))), ArrayList::new));