搜索员工列表中,管理者的UID
Set<Long> leaderSet = new HashSet<>();
List<StaffDto> allUserList = staffService.getByDepartId(xxx, true);
leaderSet = allUserList.stream().filter(staffDto -> {
//该语句块中返回true会添加到set集合中,返回false会继续执行下一条记录
try {
if (staffDto == null) {
return false;
}
StaffDto s = staffService.getByUserId(staffDto.getUserId(), "xxx");
if (s != null && s.getRankName() != null && s.getRankName().contains("M")) {
System.out.println(s.getChineseName());
return true;
}
return false;
} catch (Exception e) {
System.out.println("判断是否为管理层异常" + e);
return false;
}
}).map(udt -> udt.getUserId()).collect(Collectors.toSet());