diff --git a/src/main/java/com/chint/interfaces/rest/user/UserHttpRequestImpl.java b/src/main/java/com/chint/interfaces/rest/user/UserHttpRequestImpl.java index 407f7828..1a61eaf9 100644 --- a/src/main/java/com/chint/interfaces/rest/user/UserHttpRequestImpl.java +++ b/src/main/java/com/chint/interfaces/rest/user/UserHttpRequestImpl.java @@ -139,7 +139,22 @@ public class UserHttpRequestImpl implements UserHttpRequest { private User loadBatchSF(List 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 = userDataDTOS + .stream() + .filter(it -> it.getPersonIdExternal().equals(it.getLoginUsername())) + .findFirst(); + return userDataDTO.map(UserDataDTO::getCompany).orElse(null); + } + }); // 根据公司代码获取对应的UserDataDTO Predicate matchCompanyCode = StringCheck.isFirstCharacterChinese(companyCode) ?