完善用户获取部门信息的逻辑

This commit is contained in:
Superdandan 2024-04-04 17:06:12 +08:00
parent 276c05ee72
commit 293a090d8b
1 changed files with 16 additions and 1 deletions

View File

@ -139,7 +139,22 @@ public class UserHttpRequestImpl implements UserHttpRequest {
private User loadBatchSF(List<UserDataDTO> userDataDTOS, User user) {
// 获取公司代码优先从用户获取若为空则从登录参数中获取
String companyCode = Optional.ofNullable(user.getCompanyCode())
.orElseGet(() -> BaseContext.getCurrentUser().getUserLoginParam().getCompanyCode());
.orElseGet(() ->
{
User currentUser = BaseContext.getCurrentUser();
if (currentUser != null &&
currentUser.getUserLoginParam() != null &&
currentUser.getUserLoginParam().getCompanyCode() != null) {
return currentUser.getUserLoginParam().getCompanyCode();
} else {
//如果不存在登录信息那么获取用户的主岗信息
Optional<UserDataDTO> userDataDTO = userDataDTOS
.stream()
.filter(it -> it.getPersonIdExternal().equals(it.getLoginUsername()))
.findFirst();
return userDataDTO.map(UserDataDTO::getCompany).orElse(null);
}
});
// 根据公司代码获取对应的UserDataDTO
Predicate<UserDataDTO> matchCompanyCode = StringCheck.isFirstCharacterChinese(companyCode) ?