添加高德同步代码

This commit is contained in:
lulz1 2024-04-26 16:04:15 +08:00
parent 3b0bbc9b6b
commit 850e55ff52
14 changed files with 316 additions and 130 deletions

View File

@ -0,0 +1,15 @@
package com.chint.application.commands;
import com.chint.domain.aggregates.user.User;
import com.chint.infrastructure.echo_framework.command.Command;
import lombok.Data;
@Data
public class UserSFCommand extends Command {
private User user;
public UserSFCommand user(User user) {
this.user = user;
return this;
}
}

View File

@ -95,7 +95,7 @@ public class LoginController {
.authenticateEmployeeNo(userLoginParam); .authenticateEmployeeNo(userLoginParam);
//异步执行更新用户信息到同程 //异步执行更新用户信息到同程
User currentUser = userLoginResult.getUser(); User currentUser = BaseContext.getCurrentUser();
if (billcode != null) { if (billcode != null) {
if (companycode == null) { if (companycode == null) {
@ -105,9 +105,6 @@ public class LoginController {
Command.of(OrderCreateCommand.class).of(currentUser).sendToQueue(); Command.of(OrderCreateCommand.class).of(currentUser).sendToQueue();
} }
loginEventBoarder(currentUser); loginEventBoarder(currentUser);
//清除职级信息
userLoginResult.getUser().setProfLevel(null);
userLoginResult.getUser().setManaLevel(null);
return Result.Success(CommonMessageConstant.SUCCESS, userLoginResult); return Result.Success(CommonMessageConstant.SUCCESS, userLoginResult);
} else { } else {
return Result.error(AuthMessageConstant.SIGN_ERROR); return Result.error(AuthMessageConstant.SIGN_ERROR);
@ -125,11 +122,8 @@ public class LoginController {
.authenticateEmployeeNo(userLoginParam); .authenticateEmployeeNo(userLoginParam);
//异步执行更新用户信息到同程 //异步执行更新用户信息到同程
User currentUser = userLoginResult.getUser(); User currentUser = BaseContext.getCurrentUser();
loginEventBoarder(currentUser); loginEventBoarder(currentUser);
//清除职级信息
userLoginResult.getUser().setProfLevel(null);
userLoginResult.getUser().setManaLevel(null);
return Result.Success(CommonMessageConstant.SUCCESS, userLoginResult); return Result.Success(CommonMessageConstant.SUCCESS, userLoginResult);
} }
@ -145,13 +139,9 @@ public class LoginController {
.authenticateEmployeeNo(userLoginParam); .authenticateEmployeeNo(userLoginParam);
//异步执行更新用户信息到同程 //异步执行更新用户信息到同程
User currentUser = userLoginResult.getUser(); User currentUser = BaseContext.getCurrentUser();
loginEventBoarder(currentUser); loginEventBoarder(currentUser);
//清除职级信息
userLoginResult.getUser().setProfLevel(null);
userLoginResult.getUser().setManaLevel(null);
return Result.Success(CommonMessageConstant.SUCCESS, userLoginResult); return Result.Success(CommonMessageConstant.SUCCESS, userLoginResult);
} }
@ -165,13 +155,8 @@ public class LoginController {
.authenticateEmployeeNo(userLoginParam); .authenticateEmployeeNo(userLoginParam);
//异步执行更新用户信息到同程 //异步执行更新用户信息到同程
User currentUser = userLoginResult.getUser(); User currentUser = BaseContext.getCurrentUser();
loginEventBoarder(currentUser); loginEventBoarder(currentUser);
//清除职级信息
userLoginResult.getUser().setProfLevel(null);
userLoginResult.getUser().setManaLevel(null);
return Result.Success(CommonMessageConstant.SUCCESS, userLoginResult); return Result.Success(CommonMessageConstant.SUCCESS, userLoginResult);
} }

View File

@ -60,13 +60,17 @@ public class CTripFlightTripInfo implements Serializable {
private String AirlineName; private String AirlineName;
public static CTripFlightTripInfo of(OrderFlightResponse.FlightTripRecordInfo flightTripRecordInfo) { public static CTripFlightTripInfo of(OrderFlightResponse.FlightTripRecordInfo flightTripRecordInfo) {
CTripFlightTripInfo cTripFlightTripInfo = BeanUtil.copyProperties(flightTripRecordInfo, CTripFlightTripInfo.class); if(flightTripRecordInfo == null) {
cTripFlightTripInfo.setValidFlag(flightTripRecordInfo.isValidFlag() ? 1 : 0); return null;
cTripFlightTripInfo.setOpenTranFlag(flightTripRecordInfo.isOpenTranFlag() ? 1 : 0); } else {
cTripFlightTripInfo.setSharedFlag(flightTripRecordInfo.isSharedFlag() ? 1 : 0); CTripFlightTripInfo cTripFlightTripInfo = BeanUtil.copyProperties(flightTripRecordInfo, CTripFlightTripInfo.class);
cTripFlightTripInfo.setSurfaceFlag(flightTripRecordInfo.isSurfaceFlag() ? 1 : 0); cTripFlightTripInfo.setValidFlag(flightTripRecordInfo.isValidFlag() ? 1 : 0);
cTripFlightTripInfo.setTicketNoStatusName(translateTicketStatus(flightTripRecordInfo.getTicketNoStatus())); cTripFlightTripInfo.setOpenTranFlag(flightTripRecordInfo.isOpenTranFlag() ? 1 : 0);
return cTripFlightTripInfo; cTripFlightTripInfo.setSharedFlag(flightTripRecordInfo.isSharedFlag() ? 1 : 0);
cTripFlightTripInfo.setSurfaceFlag(flightTripRecordInfo.isSurfaceFlag() ? 1 : 0);
cTripFlightTripInfo.setTicketNoStatusName(translateTicketStatus(flightTripRecordInfo.getTicketNoStatus()));
return cTripFlightTripInfo;
}
} }
private static String translateTicketStatus(Integer ticketNoStatus) { private static String translateTicketStatus(Integer ticketNoStatus) {

View File

@ -1,11 +1,19 @@
package com.chint.domain.aggregates.user; package com.chint.domain.aggregates.user;
import cn.hutool.core.bean.BeanUtil;
import com.auth0.jwt.interfaces.Claim; import com.auth0.jwt.interfaces.Claim;
import com.auth0.jwt.interfaces.DecodedJWT; import com.auth0.jwt.interfaces.DecodedJWT;
import com.chint.application.commands.UserSFCommand;
import com.chint.domain.aggregates.system.FsscSystem; import com.chint.domain.aggregates.system.FsscSystem;
import com.chint.domain.exceptions.NotFoundException;
import com.chint.domain.value_object.UserLoginParam; import com.chint.domain.value_object.UserLoginParam;
import com.chint.domain.value_object.UserVO;
import com.chint.infrastructure.constant.AuthMessageConstant; import com.chint.infrastructure.constant.AuthMessageConstant;
import com.chint.infrastructure.echo_framework.command.Command;
import com.chint.infrastructure.util.BaseContext;
import com.chint.infrastructure.util.StringCheck;
import com.chint.interfaces.rest.base.PostRequest; import com.chint.interfaces.rest.base.PostRequest;
import com.chint.interfaces.rest.user.dto.UserDataDTO;
import com.google.gson.Gson; import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken; import com.google.gson.reflect.TypeToken;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
@ -25,7 +33,9 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Optional; import java.util.Optional;
import java.util.function.Predicate;
import static com.chint.infrastructure.constant.AuthMessageConstant.SF_DATA_NOT_EXIST;
import static com.chint.infrastructure.constant.AuthMessageConstant.USER_FSSC_SYSTEM_LIST; import static com.chint.infrastructure.constant.AuthMessageConstant.USER_FSSC_SYSTEM_LIST;
import static com.chint.infrastructure.constant.BPMConstant.*; import static com.chint.infrastructure.constant.BPMConstant.*;
import static com.chint.infrastructure.constant.FSSCConstant.*; import static com.chint.infrastructure.constant.FSSCConstant.*;
@ -68,13 +78,82 @@ public class User implements Serializable {
@Transient @Transient
private UserLoginParam userLoginParam; private UserLoginParam userLoginParam;
public User loadInfoFromDept() {
if (this.userDepartmentInfoList == null || this.userDepartmentInfoList.isEmpty()) {
//如果发现 用户的 部门信息为空 那么直接调用 sf查询
Command.of(UserSFCommand.class).user(this).sendToQueue();
}
if (userDepartmentInfoList == null) {
throw new NotFoundException(SF_DATA_NOT_EXIST);
} else if (userDepartmentInfoList.size() > 1) {
// 获取公司代码优先从用户获取若为空则从登录参数中获取
String companyCode = Optional.ofNullable(this.getCompanyCode())
.orElseGet(() -> {
User currentUser = BaseContext.getCurrentUser();
if (currentUser != null && currentUser.getUserLoginParam() != null) {
return currentUser.getUserLoginParam().getCompanyCode();
}
return null;
});
// 确保在没有有效的公司代码时使用安全默认值
if (companyCode == null) {
companyCode = ""; // 使用空字符串或其他逻辑确定的默认值
}
// 根据公司代码获取对应的UserDataDTO
String finalCompanyCode = companyCode;
Predicate<UserDepartmentInfo> matchCompanyCode = StringCheck.isFirstCharacterChinese(companyCode) ?
departmentInfo -> departmentInfo.getCompanyName().equals(finalCompanyCode) :
departmentInfo -> departmentInfo.getCompanyCode().equals(finalCompanyCode);
UserDepartmentInfo userDepartmentInfo = userDepartmentInfoList.stream()
.filter(matchCompanyCode)
.findFirst()
.orElseGet(this::getFallbackDeptInfo);
loadInfoFromDeptInfo(userDepartmentInfo);
} else {
UserDepartmentInfo fallbackDeptInfo = getFallbackDeptInfo();
loadInfoFromDeptInfo(fallbackDeptInfo);
}
return this;
}
public UserVO mapToVO() {
return BeanUtil.copyProperties(this, UserVO.class);
}
private UserDepartmentInfo getFallbackDeptInfo() {
return userDepartmentInfoList.stream()
.filter(UserDepartmentInfo::ifPrimary)
.findFirst()
.orElseGet(() -> userDepartmentInfoList.get(0));
}
private User loadInfoFromDeptInfo(UserDepartmentInfo userDepartmentInfo) {
this.setCompanyCode(userDepartmentInfo.getCompanyCode());
this.setWorkStatus(userDepartmentInfo.getStatus());
this.setGender(userDepartmentInfo.getGender());
this.setName(userDepartmentInfo.getUname());
this.setPhoneNumber(userDepartmentInfo.getMobilePhone());
this.setCompanyName(userDepartmentInfo.getCompanyName());
if (userDepartmentInfo.getCustManaLevel() != null) {
this.setManaLevel(userDepartmentInfo.getCustManaLevel());
} else {
this.setManaLevel(userDepartmentInfo.getCustManaLevelF());
}
this.setProfLevel(userDepartmentInfo.getCustProfLevel());
this.setQualityLevel(userDepartmentInfo.getCustQualityLevel());
return this;
}
public User(String employeeNo) { public User(String employeeNo) {
this.employeeNo = employeeNo; this.employeeNo = employeeNo;
} }
public UserDepartmentInfo.Builder addDeptInfo() { public UserDepartmentInfo.Builder addDeptInfo() {
return new UserDepartmentInfo.Builder(this); return new UserDepartmentInfo.Builder();
} }
public UserDepartmentInfo getDepartmentInfo() { public UserDepartmentInfo getDepartmentInfo() {
@ -273,8 +352,45 @@ public class User implements Serializable {
return XN_FSSC_REDIRECT_PATH_APPROVAL_ONE + employeeNo + FSSC_REDIRECT_PATH_APPROVAL_TWO; return XN_FSSC_REDIRECT_PATH_APPROVAL_ONE + employeeNo + FSSC_REDIRECT_PATH_APPROVAL_TWO;
} }
// public User startAddDept(){ public User addDeptInfo(UserDataDTO userData) {
// UserDepartmentInfo.Builder builder = this.addDeptInfo()
// .companyInfo(userData.getCompany(), userData.getCompany_cn())
// } .deptOne(userData.getUnit1(), userData.getUnit1_cn())
.deptTwo(userData.getUnit2(), userData.getUnit2_cn())
.deptThree(userData.getUnit3(), userData.getUnit3_cn())
.deptFour(userData.getUnit4(), userData.getUnit4_cn())
.deptFive(userData.getUnit5(), userData.getUnit5_cn())
.deptSix(null, null)
.deptSeven(null, null)
.loadWorkInfo(userData.getCust_manaLevel(),
userData.getCust_manaLevelF(),
userData.getCust_profLevel(),
userData.getCust_techLevel(),
userData.getCust_qualityLevel())
.userInfo(userData.getMobilePhone(),
userData.getUname(),
userData.getGender(),
userData.getStatus());
UserDepartmentInfo userDepartmentInfo = builder.finish();
if (userData.getPersonIdExternal().equals(userData.getLoginUsername())) {
userDepartmentInfo.setIfPrimary(1);
} else {
userDepartmentInfo.setIfPrimary(0);
}
List<UserDepartmentInfo> userDepartmentInfoList = this.getUserDepartmentInfoList();
List<UserDepartmentInfo> result = new ArrayList<>();
if (userDepartmentInfoList != null && !userDepartmentInfoList.isEmpty()) {
if (userDepartmentInfoList.contains(userDepartmentInfo)) {
return this;
}
List<UserDepartmentInfo> list = userDepartmentInfoList.stream().distinct().toList();
if (userDepartmentInfo.ifPrimary()) {
list.forEach(it -> it.setIfPrimary(0));
}
result.addAll(list);
}
result.add(userDepartmentInfo);
this.setUserDepartmentInfoList(result);
return this;
}
} }

View File

@ -41,8 +41,22 @@ public class UserDepartmentInfo implements Serializable {
private String departmentNameSeven; private String departmentNameSeven;
private Integer ifPrimary; private Integer ifPrimary;
public String getDeptInfo(){ private String mobilePhone;
return departmentNameOne + "-" + departmentNameTwo + private String uname;
private String gender;
private String custManaLevel;
private String custManaLevelF;
private String custProfLevel;
private String custTechLevel;
private String custQualityLevel;
private String status;
public boolean ifPrimary(){
return ifPrimary == 1;
}
public String getDeptInfo() {
return departmentNameOne + "-" + departmentNameTwo +
"-" + departmentNameThree + "-" + departmentNameFour + "-" + departmentNameThree + "-" + departmentNameFour +
"-" + departmentNameFive + "-" + departmentNameSix + "-" + departmentNameSeven; "-" + departmentNameFive + "-" + departmentNameSix + "-" + departmentNameSeven;
} }
@ -74,19 +88,14 @@ public class UserDepartmentInfo implements Serializable {
@Override @Override
public int hashCode() { public int hashCode() {
return Objects.hash(companyCode, companyName, departmentCodeOne, departmentNameOne, departmentCodeTwo, departmentNameTwo, departmentCodeThree, departmentNameThree, departmentCodeFour, departmentNameFour, departmentCodeFive, departmentNameFive, departmentCodeSix, departmentNameSix, departmentCodeSeven, departmentNameSeven,ifPrimary); return Objects.hash(companyCode, companyName, departmentCodeOne, departmentNameOne, departmentCodeTwo, departmentNameTwo, departmentCodeThree, departmentNameThree, departmentCodeFour, departmentNameFour, departmentCodeFive, departmentNameFive, departmentCodeSix, departmentNameSix, departmentCodeSeven, departmentNameSeven, ifPrimary);
} }
public Builder start(User user) { public Builder start() {
return new Builder(user); return new Builder();
} }
public UserDepartmentInfo(String companyCode, String companyName, String departmentCodeOne, public UserDepartmentInfo(String companyCode, String companyName, String departmentCodeOne, String departmentNameOne, String departmentCodeTwo, String departmentNameTwo, String departmentCodeThree, String departmentNameThree, String departmentCodeFour, String departmentNameFour, String departmentCodeFive, String departmentNameFive, String departmentCodeSix, String departmentNameSix, String departmentCodeSeven, String departmentNameSeven, Integer ifPrimary, String mobilePhone, String uname, String gender, String custManaLevel, String custManaLevelF, String custProfLevel, String custTechLevel, String custQualityLevel, String status) {
String departmentNameOne, String departmentCodeTwo, String departmentNameTwo,
String departmentCodeThree, String departmentNameThree, String departmentCodeFour,
String departmentNameFour, String departmentCodeFive, String departmentNameFive,
String departmentCodeSix, String departmentNameSix, String departmentCodeSeven,
String departmentNameSeven, Integer ifPrimary) {
this.companyCode = companyCode; this.companyCode = companyCode;
this.companyName = companyName; this.companyName = companyName;
this.departmentCodeOne = departmentCodeOne; this.departmentCodeOne = departmentCodeOne;
@ -104,11 +113,18 @@ public class UserDepartmentInfo implements Serializable {
this.departmentCodeSeven = departmentCodeSeven; this.departmentCodeSeven = departmentCodeSeven;
this.departmentNameSeven = departmentNameSeven; this.departmentNameSeven = departmentNameSeven;
this.ifPrimary = ifPrimary; this.ifPrimary = ifPrimary;
this.mobilePhone = mobilePhone;
this.uname = uname;
this.gender = gender;
this.custManaLevel = custManaLevel;
this.custManaLevelF = custManaLevelF;
this.custProfLevel = custProfLevel;
this.custTechLevel = custTechLevel;
this.custQualityLevel = custQualityLevel;
this.status = status;
} }
public static class Builder { public static class Builder {
private User user;
private String companyCode; private String companyCode;
private String companyName; private String companyName;
private String departmentCodeOne; private String departmentCodeOne;
@ -126,10 +142,15 @@ public class UserDepartmentInfo implements Serializable {
private String departmentCodeSeven; private String departmentCodeSeven;
private String departmentNameSeven; private String departmentNameSeven;
private Integer ifPrimary; private Integer ifPrimary;
private String mobilePhone;
public Builder(User user) { private String uname;
this.user = user; private String gender;
} private String custManaLevel;
private String custManaLevelF;
private String custProfLevel;
private String custTechLevel;
private String custQualityLevel;
private String status;
public Builder companyInfo(String companyCode, String companyName) { public Builder companyInfo(String companyCode, String companyName) {
this.companyCode = companyCode; this.companyCode = companyCode;
@ -184,7 +205,28 @@ public class UserDepartmentInfo implements Serializable {
return this; return this;
} }
public UserDepartmentInfo addToUser() { public Builder loadWorkInfo(String custManaLevel,
String custManaLevelF,
String custProfLevel,
String custTechLevel,
String custQualityLevel) {
this.custManaLevel = custManaLevel;
this.custManaLevelF = custManaLevelF;
this.custProfLevel = custProfLevel;
this.custTechLevel = custTechLevel;
this.custQualityLevel = custQualityLevel;
return this;
}
public Builder userInfo(String mobilePhone, String uname, String gender, String status) {
this.mobilePhone = mobilePhone;
this.uname = uname;
this.gender = gender;
this.status = status;
return this;
}
public UserDepartmentInfo finish() {
UserDepartmentInfo userDepartmentInfo = new UserDepartmentInfo(companyCode, UserDepartmentInfo userDepartmentInfo = new UserDepartmentInfo(companyCode,
companyName, companyName,
departmentCodeOne, departmentCodeOne,
@ -201,22 +243,16 @@ public class UserDepartmentInfo implements Serializable {
departmentNameSix, departmentNameSix,
departmentCodeSeven, departmentCodeSeven,
departmentNameSeven, departmentNameSeven,
ifPrimary); ifPrimary,
if (userDepartmentInfo.getIfPrimary() == null || userDepartmentInfo.getIfPrimary() != 1) { mobilePhone,
userDepartmentInfo.setIfPrimary(0); uname,
} gender,
List<UserDepartmentInfo> userDepartmentInfoList = user.getUserDepartmentInfoList(); custManaLevel,
List<UserDepartmentInfo> result = new ArrayList<>(); custManaLevelF,
if(userDepartmentInfoList != null && !userDepartmentInfoList.isEmpty()) { custProfLevel,
List<UserDepartmentInfo> list = userDepartmentInfoList.stream().distinct().toList(); custTechLevel,
user.setUserDepartmentInfoList(list); custQualityLevel,
if(userDepartmentInfoList.contains(userDepartmentInfo)){ status);
return userDepartmentInfo;
}
result.addAll(userDepartmentInfoList);
}
result.add(userDepartmentInfo);
user.setUserDepartmentInfoList(result);
return userDepartmentInfo; return userDepartmentInfo;
} }
} }

View File

@ -240,6 +240,15 @@ public class CTripOrderRecordExtensionFactory implements OrderRecordExtensionFac
} }
}, () -> orderCarRecord.setOrderStatus("0")); }, () -> orderCarRecord.setOrderStatus("0"));
//修正携程成中心错误的问题
if (byOrderNo.isPresent()) {
RouteOrder routeOrder = byOrderNo.get();
ApproveOrderNo approveOrderNo = routeOrder.getApproveOrderNo();
if (approveOrderNo != null) {
orderCarRecord.setOfflineCcomyCode(approveOrderNo.getCostCenter());
}
}
return orderCarRecord; return orderCarRecord;
} }
@ -476,6 +485,14 @@ public class CTripOrderRecordExtensionFactory implements OrderRecordExtensionFac
} }
}, () -> orderFlightRecord.setOrderStatus("0")); }, () -> orderFlightRecord.setOrderStatus("0"));
//修正携程成中心错误的问题
if (byOrderNo.isPresent()) {
RouteOrder routeOrder = byOrderNo.get();
ApproveOrderNo approveOrderNo = routeOrder.getApproveOrderNo();
if (approveOrderNo != null) {
orderFlightRecord.setOfflineCcomyCode(approveOrderNo.getCostCenter());
}
}
return orderFlightRecord; return orderFlightRecord;
} }
@ -701,6 +718,18 @@ public class CTripOrderRecordExtensionFactory implements OrderRecordExtensionFac
orderHotelRecord.setOrderStatus("0"); orderHotelRecord.setOrderStatus("0");
} }
}, () -> orderHotelRecord.setOrderStatus("0")); }, () -> orderHotelRecord.setOrderStatus("0"));
//修正携程成中心错误的问题
if (byOrderNo.isPresent()) {
RouteOrder routeOrder = byOrderNo.get();
ApproveOrderNo approveOrderNo = routeOrder.getApproveOrderNo();
if (approveOrderNo != null) {
orderHotelRecord.setOfflineCcomyCode(approveOrderNo.getCostCenter());
}
}
return orderHotelRecord; return orderHotelRecord;
} }

View File

@ -59,7 +59,6 @@ public class AuthenticateServiceImpl implements AuthenticateService {
if (user != null) { if (user != null) {
// 部分数据需要通过查询外部的http来获取 // 部分数据需要通过查询外部的http来获取
user.setUserLoginParam(userLoginParam); user.setUserLoginParam(userLoginParam);
BaseContext.setCurrentUser(user);
return getUserLoginResult(user); return getUserLoginResult(user);
} else { } else {
User newUser = userFactory.create(userLoginParam.getSfno()); User newUser = userFactory.create(userLoginParam.getSfno());
@ -68,14 +67,12 @@ public class AuthenticateServiceImpl implements AuthenticateService {
httpRequest.loadUserInfo(newUser); httpRequest.loadUserInfo(newUser);
userRepository.save(newUser); userRepository.save(newUser);
newUser.setUserLoginParam(userLoginParam); newUser.setUserLoginParam(userLoginParam);
BaseContext.setCurrentUser(newUser);
return getUserLoginResult(newUser); return getUserLoginResult(newUser);
} }
} }
private UserLoginResult getUserLoginResult(User user) { private UserLoginResult getUserLoginResult(User user) {
UserLoginParam userLoginParam = user.getUserLoginParam(); UserLoginParam userLoginParam = user.getUserLoginParam();
BaseContext.setCurrentUser(user);
user.setCompanyCode(userLoginParam.getCompanyCode()); user.setCompanyCode(userLoginParam.getCompanyCode());
user.setUserLoginParam(userLoginParam); user.setUserLoginParam(userLoginParam);
httpRequest.loadUserInfo(user); httpRequest.loadUserInfo(user);
@ -93,7 +90,6 @@ public class AuthenticateServiceImpl implements AuthenticateService {
claims.put(USER_FSSC_SYSTEM_LIST, json.gson().toJson(fsscSystemList)); claims.put(USER_FSSC_SYSTEM_LIST, json.gson().toJson(fsscSystemList));
claims.put(USER_STANDARD_LEVEL, user.getStandardLevel()); claims.put(USER_STANDARD_LEVEL, user.getStandardLevel());
String jwt = JWTUtil.createJWT(claims); String jwt = JWTUtil.createJWT(claims);
//这里已经是完成的用户信息里 因此将用户信息保存到threadLocal当中 //这里已经是完成的用户信息里 因此将用户信息保存到threadLocal当中
BaseContext.setCurrentUser(user); BaseContext.setCurrentUser(user);
return UserLoginResult.buildWithUser(user).loadToken(Token.of(jwt)); return UserLoginResult.buildWithUser(user).loadToken(Token.of(jwt));

View File

@ -6,31 +6,24 @@ import lombok.Data;
@Data @Data
public class UserLoginResult { public class UserLoginResult {
private User user; private UserVO user;
private Token token; private Token token;
// private String redirectUrl; // private String redirectUrl;
public UserLoginResult(User user) { public UserLoginResult(User user) {
this.user = user; this.user = user.mapToVO();
this.token = null; this.token = null;
} }
public User getUser() { public UserVO getUser() {
return user; return user;
} }
public void setUser(User user) {
this.user = user;
}
public Token getToken() { public Token getToken() {
return token; return token;
} }
public void setToken(Token token) {
this.token = token;
}
public static UserLoginResult buildWithUser(User user) { public static UserLoginResult buildWithUser(User user) {
return new UserLoginResult(user); return new UserLoginResult(user);
} }

View File

@ -0,0 +1,25 @@
package com.chint.domain.value_object;
import com.chint.domain.aggregates.system.FsscSystem;
import lombok.Data;
import org.springframework.data.annotation.Transient;
import java.time.LocalDateTime;
import java.util.List;
@Data
public class UserVO {
private Long userId;
private String employeeNo;
private Integer employeeLevel;
private String name;
private String email;
private String gender;
private String phoneNumber;
private String password;
private LocalDateTime syncTime;
private List<FsscSystem> fsscSystemList;
private String standardLevel;
private String companyCode;
private String companyName;
}

View File

@ -8,6 +8,7 @@ public class AuthMessageConstant {
public static final String JWT_EXPIRED = "登录信息已过期"; public static final String JWT_EXPIRED = "登录信息已过期";
public static final String JWT_REQUIRED = "需要 JWT 令牌"; public static final String JWT_REQUIRED = "需要 JWT 令牌";
public static final String JWT_ACCESS_DENIED = "JWT 令牌不足以访问此资源"; public static final String JWT_ACCESS_DENIED = "JWT 令牌不足以访问此资源";
public static final String SF_DATA_NOT_EXIST = "sf信息不存在请联系管理员";
// 用户认证消息 // 用户认证消息
public static final String AUTHENTICATION_FAILED = "认证失败"; public static final String AUTHENTICATION_FAILED = "认证失败";
public static final String LOGIN_SUCCESS = "登录成功"; public static final String LOGIN_SUCCESS = "登录成功";

View File

@ -7,6 +7,7 @@ public class CommonMessageConstant {
public static final String SYNC_FAILURE_TRAIN = "携程暂不支持火车票预订"; public static final String SYNC_FAILURE_TRAIN = "携程暂不支持火车票预订";
public static final String DUPLICATE_ERROR = "数据重复"; public static final String DUPLICATE_ERROR = "数据重复";
public static final String NOT_FOUND = "未找到相关数据"; public static final String NOT_FOUND = "未找到相关数据";
public static final String EMPLOYEE_NO_NOT_EXIST = "未找到相关数据";
public static final String INVALID_REQUEST = "无效的请求"; public static final String INVALID_REQUEST = "无效的请求";
public static final String ACCESS_DENIED = "访问被拒绝"; public static final String ACCESS_DENIED = "访问被拒绝";
public static final String SERVER_ERROR = "服务器错误"; public static final String SERVER_ERROR = "服务器错误";

View File

@ -27,7 +27,7 @@ public class AmapLocationRequest {
return amapRequest.post(BaseUrl + AMAP_LOCATION_PATH, param, LocationResponse.class); return amapRequest.post(BaseUrl + AMAP_LOCATION_PATH, param, LocationResponse.class);
} }
@Cacheable(value = "AmapLocationACode" , key = "#locationName")
public String getACodeByLocationName(String locationName) { public String getACodeByLocationName(String locationName) {
LocationResponse locationQuery = locationQuery(locationName); LocationResponse locationQuery = locationQuery(locationName);
Optional<LocationResponse.AmapCityInfo> amapCityInfo = Optional.ofNullable(locationQuery.getData()) Optional<LocationResponse.AmapCityInfo> amapCityInfo = Optional.ofNullable(locationQuery.getData())

View File

@ -1,16 +1,20 @@
package com.chint.interfaces.rest.user; package com.chint.interfaces.rest.user;
import com.chint.application.commands.UserSFCommand;
import com.chint.domain.aggregates.standards.Ranks; import com.chint.domain.aggregates.standards.Ranks;
import com.chint.domain.aggregates.standards.StaffRank; import com.chint.domain.aggregates.standards.StaffRank;
import com.chint.domain.aggregates.system.JTCompany;
import com.chint.domain.aggregates.user.User; import com.chint.domain.aggregates.user.User;
import com.chint.domain.aggregates.user.UserDepartmentInfo; import com.chint.domain.aggregates.user.UserDepartmentInfo;
import com.chint.domain.exceptions.NotFoundException;
import com.chint.domain.repository.JTCompanyRepository; import com.chint.domain.repository.JTCompanyRepository;
import com.chint.domain.repository.StaffRankRepository; import com.chint.domain.repository.StaffRankRepository;
import com.chint.domain.repository.UserRepository; import com.chint.domain.repository.UserRepository;
import com.chint.domain.service.JTCompanyDomainService; import com.chint.domain.service.JTCompanyDomainService;
import com.chint.domain.service.RankDomainService; import com.chint.domain.service.RankDomainService;
import com.chint.infrastructure.constant.SFConstant; import com.chint.infrastructure.constant.SFConstant;
import com.chint.infrastructure.echo_framework.annotation.ListenTo;
import com.chint.infrastructure.util.BaseContext; import com.chint.infrastructure.util.BaseContext;
import com.chint.infrastructure.util.StringCheck; import com.chint.infrastructure.util.StringCheck;
import com.chint.interfaces.rest.base.PostRequest; import com.chint.interfaces.rest.base.PostRequest;
@ -24,6 +28,7 @@ import java.util.List;
import java.util.Optional; import java.util.Optional;
import java.util.function.Predicate; import java.util.function.Predicate;
import static com.chint.infrastructure.constant.CommonMessageConstant.EMPLOYEE_NO_NOT_EXIST;
import static com.chint.infrastructure.constant.RankConstant.DEFAULT_RANK_NAME; import static com.chint.infrastructure.constant.RankConstant.DEFAULT_RANK_NAME;
import static com.chint.infrastructure.constant.RankConstant.JT_COMPANY_CODE; import static com.chint.infrastructure.constant.RankConstant.JT_COMPANY_CODE;
@ -65,12 +70,19 @@ public class UserHttpRequestImpl implements UserHttpRequest {
@Autowired @Autowired
private UserRepository userRepository; private UserRepository userRepository;
@Override @Override
public User loadUserInfo(User user) { public User loadUserInfo(User user) {
//这个方法 逻辑进行修改 首先通过查询 表的方式 如果部分数据为空 那么就要查询 sf信息获取 //这个方法 逻辑进行修改 首先通过查询 表的方式 如果部分数据为空 那么就要查询 sf信息获取
user = loadSFInfo(user); user.loadInfoFromDept();
if (user == null) { //根据员工的登录信息来创建fssc基础跳转信息
return null; List<UserDepartmentInfo> userDepartmentInfoList = user.getUserDepartmentInfoList()
.stream()
.filter(it -> jtCompanyDomainService.ifCompanyInJT(null, it.getCompanyCode()))
.toList();
for (UserDepartmentInfo userDepartmentInfo : userDepartmentInfoList) {
String sysCode = jtCompanyDomainService.findSystemCodeByCompanyCode(userDepartmentInfo.getCompanyCode());
user.addFssc(userDepartmentInfo.getCompanyName(), sysCode);
} }
return loadRankCode(user); return loadRankCode(user);
} }
@ -107,7 +119,13 @@ public class UserHttpRequestImpl implements UserHttpRequest {
return user; return user;
} }
private User loadSFInfo(User user) {
@ListenTo(command = "UserSFCommand", order = 0)
public User loadSFInfo(UserSFCommand command) {
User user = command.getUser();
if (user == null || user.getEmployeeNo() == null) {
throw new NotFoundException(EMPLOYEE_NO_NOT_EXIST);
}
List<UserDataDTO> userSFDataFromOpenApi = userSFRequest List<UserDataDTO> userSFDataFromOpenApi = userSFRequest
.getUserSFDataFromOpenApi(user); .getUserSFDataFromOpenApi(user);
if (userSFDataFromOpenApi == null) { if (userSFDataFromOpenApi == null) {
@ -117,11 +135,9 @@ public class UserHttpRequestImpl implements UserHttpRequest {
.stream() .stream()
.filter(userDataDTO -> userDataDTO.getStatus().equals("A")) .filter(userDataDTO -> userDataDTO.getStatus().equals("A"))
.toList(); .toList();
if (fromJson.size() == 1) {
UserDataDTO userData = fromJson.get(0); for (UserDataDTO userDataDTO : fromJson) {
loadSingleSF(userData, user); user.addDeptInfo(userDataDTO);
} else {
loadBatchSF(fromJson, user);
} }
return user; return user;
} }
@ -132,7 +148,7 @@ public class UserHttpRequestImpl implements UserHttpRequest {
user.addFssc(userData.getCompany_cn(), sysCode); user.addFssc(userData.getCompany_cn(), sysCode);
//根据同步时间来决定是否要同步部门信息 //根据同步时间来决定是否要同步部门信息
if (user.checkSyncTime()) { if (user.checkSyncTime()) {
addDeptInfo(userData, user, true); user.addDeptInfo(userData);
} }
return user; return user;
} }
@ -174,11 +190,7 @@ public class UserHttpRequestImpl implements UserHttpRequest {
processSpecialCompanies(userDataDTOS, user); processSpecialCompanies(userDataDTOS, user);
for (UserDataDTO userDataDTO : userDataDTOS) { for (UserDataDTO userDataDTO : userDataDTOS) {
if (userDataDTO.getPersonIdExternal().equals(userDataDTO.getLoginUsername())) { user.addDeptInfo(userDataDTO);
addDeptInfo(userDataDTO, user, true);
} else {
addDeptInfo(userDataDTO, user, false);
}
} }
return user; return user;
} }
@ -206,24 +218,6 @@ public class UserHttpRequestImpl implements UserHttpRequest {
return user; return user;
} }
private User addDeptInfo(UserDataDTO userData, User user, Boolean ifPrimary) {
UserDepartmentInfo.Builder builder = user.addDeptInfo()
.companyInfo(userData.getCompany(), userData.getCompany_cn())
.deptOne(userData.getUnit1(), userData.getUnit1_cn())
.deptTwo(userData.getUnit2(), userData.getUnit2_cn())
.deptThree(userData.getUnit3(), userData.getUnit3_cn())
.deptFour(userData.getUnit4(), userData.getUnit4_cn())
.deptFive(userData.getUnit5(), userData.getUnit5_cn())
.deptSix(null, null)
.deptSeven(null, null);
if (ifPrimary) {
builder.primary();
}
builder.addToUser();
return user;
}
private UserDataDTO getFallbackUserData(List<UserDataDTO> userDataDTOS) { private UserDataDTO getFallbackUserData(List<UserDataDTO> userDataDTOS) {
// 若无匹配则优先使用主岗数据否则使用列表中的第一个 // 若无匹配则优先使用主岗数据否则使用列表中的第一个
return userDataDTOS.stream() return userDataDTOS.stream()
@ -263,20 +257,11 @@ public class UserHttpRequestImpl implements UserHttpRequest {
if (userDataDTOList == null) { if (userDataDTOList == null) {
return null; return null;
} }
if (userDataDTOList.size() == 1) {
addDeptInfo(userDataDTOList.get(0), user, true); userDataDTOList.forEach(user::addDeptInfo);
}
if (userDataDTOList.size() > 1) { if (user.getName() == null || user.getName().isEmpty() || user.getName().isBlank()) {
for (UserDataDTO userDataDTO : userDataDTOList) { getDataFromUserSFData(user, userDataDTOList.get(0));
if (userDataDTO.getPersonIdExternal().equals(userDataDTO.getLoginUsername())) {
addDeptInfo(userDataDTO, user, true);
} else {
addDeptInfo(userDataDTO, user, false);
}
}
}
if(user.getName() == null || user.getName().isEmpty() || user.getName().isBlank()){
getDataFromUserSFData(user,userDataDTOList.get(0));
} }
return userRepository.save(user); return userRepository.save(user);
@ -299,9 +284,9 @@ public class UserHttpRequestImpl implements UserHttpRequest {
} }
//这里执行去重逻辑 因出现部分员工的部分信息重复的问题 //这里执行去重逻辑 因出现部分员工的部分信息重复的问题
if(userDepartmentInfoList != null && userDepartmentInfoList.size() > 1){ if (userDepartmentInfoList != null && userDepartmentInfoList.size() > 1) {
List<UserDepartmentInfo> userDepartmentInfos = userDepartmentInfoList.stream().distinct().toList(); List<UserDepartmentInfo> userDepartmentInfos = userDepartmentInfoList.stream().distinct().toList();
if(userDepartmentInfos.size() < userDepartmentInfoList.size()){ if (userDepartmentInfos.size() < userDepartmentInfoList.size()) {
user.setUserDepartmentInfoList(userDepartmentInfos); user.setUserDepartmentInfoList(userDepartmentInfos);
userRepository.save(user); userRepository.save(user);
} }

View File

@ -832,7 +832,7 @@ public class LYTest {
@Test @Test
void searchHotel() { void searchHotel() {
HotelDetailResponse hotelOrderDetail = lySearchRequest.getHotelOrderDetail("HO20240401145300516689"); HotelDetailResponse hotelOrderDetail = lySearchRequest.getHotelOrderDetail("HO20240410160000601814");
Gson gson = new Gson(); Gson gson = new Gson();
String json = gson.toJson(hotelOrderDetail); String json = gson.toJson(hotelOrderDetail);
System.out.println(json); System.out.println(json);