From 276c05ee72aae59121e06beaedf2c1a05f8d658d Mon Sep 17 00:00:00 2001 From: lulz1 Date: Thu, 4 Apr 2024 16:55:43 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A4=87=E4=BB=BD=E7=94=A8=E6=88=B7=E9=83=A8?= =?UTF-8?q?=E9=97=A8=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../CTripOrderRecordExtensionFactory.java | 8 +++++++- .../rest/user/UserHttpRequestImpl.java | 19 ++++++++++++++----- .../interfaces/rest/user/UserSFRequest.java | 3 +++ 3 files changed, 24 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/chint/domain/factoriy/order_record/CTripOrderRecordExtensionFactory.java b/src/main/java/com/chint/domain/factoriy/order_record/CTripOrderRecordExtensionFactory.java index 4f3c246e..48ef9945 100644 --- a/src/main/java/com/chint/domain/factoriy/order_record/CTripOrderRecordExtensionFactory.java +++ b/src/main/java/com/chint/domain/factoriy/order_record/CTripOrderRecordExtensionFactory.java @@ -588,8 +588,14 @@ public class CTripOrderRecordExtensionFactory implements OrderRecordExtensionFac return orderHotelRecord; } - private String belongDeport(String accountCompanyName, String employeeNo) { + private String belongDeport(String employeeNo, String accountCompanyName) { User user = userRepository.findByUserEmployeeNo(employeeNo); + if (user == null) { + user = userHttpRequest.loadUserInfo(User.withEmployeeNo(employeeNo)); + if (user == null) { + return null; + } + } if (user.getUserDepartmentInfoList() == null || user.getUserDepartmentInfoList().isEmpty()) { userHttpRequest.loadUserDeptInfo(user); } 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 fd72becd..407f7828 100644 --- a/src/main/java/com/chint/interfaces/rest/user/UserHttpRequestImpl.java +++ b/src/main/java/com/chint/interfaces/rest/user/UserHttpRequestImpl.java @@ -68,6 +68,9 @@ public class UserHttpRequestImpl implements UserHttpRequest { @Override public User loadUserInfo(User user) { loadSFInfo(user); + if (user == null) { + return null; + } return loadRankCode(user); } @@ -104,8 +107,12 @@ public class UserHttpRequestImpl implements UserHttpRequest { } private User loadSFInfo(User user) { - List fromJson = userSFRequest - .getUserSFDataFromOpenApi(user) + List userSFDataFromOpenApi = userSFRequest + .getUserSFDataFromOpenApi(user); + if (userSFDataFromOpenApi == null) { + return null; + } + List fromJson = userSFDataFromOpenApi .stream() .filter(userDataDTO -> userDataDTO.getStatus().equals("A")) .toList(); @@ -210,11 +217,13 @@ public class UserHttpRequestImpl implements UserHttpRequest { public User loadUserDeptInfo(User user) { List userDataDTOList = userSFRequest.getUserSFDataFromOpenApi(user); - if (userDataDTOList != null && userDataDTOList.size() == 1) { + if (userDataDTOList == null) { + return null; + } + if (userDataDTOList.size() == 1) { addDeptInfo(userDataDTOList.get(0), user, true); } - - if (userDataDTOList != null && userDataDTOList.size() > 1) { + if (userDataDTOList.size() > 1) { for (UserDataDTO userDataDTO : userDataDTOList) { if (userDataDTO.getPersonIdExternal().equals(userDataDTO.getLoginUsername())) { addDeptInfo(userDataDTO, user, true); diff --git a/src/main/java/com/chint/interfaces/rest/user/UserSFRequest.java b/src/main/java/com/chint/interfaces/rest/user/UserSFRequest.java index 6745b4d9..5faacc02 100644 --- a/src/main/java/com/chint/interfaces/rest/user/UserSFRequest.java +++ b/src/main/java/com/chint/interfaces/rest/user/UserSFRequest.java @@ -69,6 +69,9 @@ public class UserSFRequest { DataCenterResult result = dataCenterService.post(USER_DATA_PATH, map); Type type = new TypeToken>() { }.getType(); + if(result.getData() == null){ + return null; + } List userDataDTOs = gson.fromJson(result.getData().toString(), type); if (result.getData() != null) { return userDataDTOs;