备份用户部门代码

This commit is contained in:
lulz1 2024-04-04 16:55:43 +08:00
parent 16935ccb5d
commit 276c05ee72
3 changed files with 24 additions and 6 deletions

View File

@ -588,8 +588,14 @@ public class CTripOrderRecordExtensionFactory implements OrderRecordExtensionFac
return orderHotelRecord; return orderHotelRecord;
} }
private String belongDeport(String accountCompanyName, String employeeNo) { private String belongDeport(String employeeNo, String accountCompanyName) {
User user = userRepository.findByUserEmployeeNo(employeeNo); 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()) { if (user.getUserDepartmentInfoList() == null || user.getUserDepartmentInfoList().isEmpty()) {
userHttpRequest.loadUserDeptInfo(user); userHttpRequest.loadUserDeptInfo(user);
} }

View File

@ -68,6 +68,9 @@ public class UserHttpRequestImpl implements UserHttpRequest {
@Override @Override
public User loadUserInfo(User user) { public User loadUserInfo(User user) {
loadSFInfo(user); loadSFInfo(user);
if (user == null) {
return null;
}
return loadRankCode(user); return loadRankCode(user);
} }
@ -104,8 +107,12 @@ public class UserHttpRequestImpl implements UserHttpRequest {
} }
private User loadSFInfo(User user) { private User loadSFInfo(User user) {
List<UserDataDTO> fromJson = userSFRequest List<UserDataDTO> userSFDataFromOpenApi = userSFRequest
.getUserSFDataFromOpenApi(user) .getUserSFDataFromOpenApi(user);
if (userSFDataFromOpenApi == null) {
return null;
}
List<UserDataDTO> fromJson = userSFDataFromOpenApi
.stream() .stream()
.filter(userDataDTO -> userDataDTO.getStatus().equals("A")) .filter(userDataDTO -> userDataDTO.getStatus().equals("A"))
.toList(); .toList();
@ -210,11 +217,13 @@ public class UserHttpRequestImpl implements UserHttpRequest {
public User loadUserDeptInfo(User user) { public User loadUserDeptInfo(User user) {
List<UserDataDTO> userDataDTOList = userSFRequest.getUserSFDataFromOpenApi(user); List<UserDataDTO> 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); addDeptInfo(userDataDTOList.get(0), user, true);
} }
if (userDataDTOList.size() > 1) {
if (userDataDTOList != null && userDataDTOList.size() > 1) {
for (UserDataDTO userDataDTO : userDataDTOList) { for (UserDataDTO userDataDTO : userDataDTOList) {
if (userDataDTO.getPersonIdExternal().equals(userDataDTO.getLoginUsername())) { if (userDataDTO.getPersonIdExternal().equals(userDataDTO.getLoginUsername())) {
addDeptInfo(userDataDTO, user, true); addDeptInfo(userDataDTO, user, true);

View File

@ -69,6 +69,9 @@ public class UserSFRequest {
DataCenterResult result = dataCenterService.post(USER_DATA_PATH, map); DataCenterResult result = dataCenterService.post(USER_DATA_PATH, map);
Type type = new TypeToken<List<UserDataDTO>>() { Type type = new TypeToken<List<UserDataDTO>>() {
}.getType(); }.getType();
if(result.getData() == null){
return null;
}
List<UserDataDTO> userDataDTOs = gson.fromJson(result.getData().toString(), type); List<UserDataDTO> userDataDTOs = gson.fromJson(result.getData().toString(), type);
if (result.getData() != null) { if (result.getData() != null) {
return userDataDTOs; return userDataDTOs;