Commit 05f2d2c5 by liuyang

2024-06-26 获取登录用户所有角色的公司列表去重复

parent 3bc38b2d
......@@ -22,6 +22,7 @@ import java.util.List;
import java.util.Optional;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import java.util.function.Function;
import java.util.stream.Collectors;
/**
......@@ -157,7 +158,11 @@ public class UserSessionUtils extends UserSession {
Optional.ofNullable(companyCodes).orElse(new ArrayList<>()).stream().forEach( code -> {
orgs.addAll(HGXSTools.XsOrg.queryByParent(code,OrgTypeEnum.COMPANY.getCode()));
});
return orgs.stream().filter(o->StringUtils.equals(o.getOrgType(),OrgTypeEnum.COMPANY.getCode())).map(item -> new Company(item.getOrgId(), item.getOrgCname())).collect(Collectors.toList());
return orgs.stream().filter(o->StringUtils.equals(o.getOrgType(),OrgTypeEnum.COMPANY.getCode())).map(item -> new Company(item.getOrgId(), item.getOrgCname())).collect(Collectors.collectingAndThen(
Collectors.toMap(Company::getCompanyCode, Function.identity(), (oldValue, newValue) -> oldValue),
// 将Map转回List
m -> new ArrayList<>(m.values())
));
}
/**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment