From 293a090d8b5c1a532f2d8aee0cec027d46e8cc80 Mon Sep 17 00:00:00 2001 From: Superdandan <1033719135@qq.com> Date: Thu, 4 Apr 2024 17:06:12 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E5=96=84=E7=94=A8=E6=88=B7=E8=8E=B7?= =?UTF-8?q?=E5=8F=96=E9=83=A8=E9=97=A8=E4=BF=A1=E6=81=AF=E7=9A=84=E9=80=BB?= =?UTF-8?q?=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../rest/user/UserHttpRequestImpl.java | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) 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) ?