添加高德同步代码
This commit is contained in:
parent
3b0bbc9b6b
commit
850e55ff52
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -95,7 +95,7 @@ public class LoginController {
|
|||
.authenticateEmployeeNo(userLoginParam);
|
||||
|
||||
//异步执行更新用户信息到同程
|
||||
User currentUser = userLoginResult.getUser();
|
||||
User currentUser = BaseContext.getCurrentUser();
|
||||
|
||||
if (billcode != null) {
|
||||
if (companycode == null) {
|
||||
|
@ -105,9 +105,6 @@ public class LoginController {
|
|||
Command.of(OrderCreateCommand.class).of(currentUser).sendToQueue();
|
||||
}
|
||||
loginEventBoarder(currentUser);
|
||||
//清除职级信息
|
||||
userLoginResult.getUser().setProfLevel(null);
|
||||
userLoginResult.getUser().setManaLevel(null);
|
||||
return Result.Success(CommonMessageConstant.SUCCESS, userLoginResult);
|
||||
} else {
|
||||
return Result.error(AuthMessageConstant.SIGN_ERROR);
|
||||
|
@ -125,11 +122,8 @@ public class LoginController {
|
|||
.authenticateEmployeeNo(userLoginParam);
|
||||
|
||||
//异步执行更新用户信息到同程
|
||||
User currentUser = userLoginResult.getUser();
|
||||
User currentUser = BaseContext.getCurrentUser();
|
||||
loginEventBoarder(currentUser);
|
||||
//清除职级信息
|
||||
userLoginResult.getUser().setProfLevel(null);
|
||||
userLoginResult.getUser().setManaLevel(null);
|
||||
|
||||
return Result.Success(CommonMessageConstant.SUCCESS, userLoginResult);
|
||||
}
|
||||
|
@ -145,13 +139,9 @@ public class LoginController {
|
|||
.authenticateEmployeeNo(userLoginParam);
|
||||
|
||||
//异步执行更新用户信息到同程
|
||||
User currentUser = userLoginResult.getUser();
|
||||
User currentUser = BaseContext.getCurrentUser();
|
||||
loginEventBoarder(currentUser);
|
||||
|
||||
//清除职级信息
|
||||
userLoginResult.getUser().setProfLevel(null);
|
||||
userLoginResult.getUser().setManaLevel(null);
|
||||
|
||||
return Result.Success(CommonMessageConstant.SUCCESS, userLoginResult);
|
||||
}
|
||||
|
||||
|
@ -165,13 +155,8 @@ public class LoginController {
|
|||
.authenticateEmployeeNo(userLoginParam);
|
||||
|
||||
//异步执行更新用户信息到同程
|
||||
User currentUser = userLoginResult.getUser();
|
||||
User currentUser = BaseContext.getCurrentUser();
|
||||
loginEventBoarder(currentUser);
|
||||
|
||||
//清除职级信息
|
||||
userLoginResult.getUser().setProfLevel(null);
|
||||
userLoginResult.getUser().setManaLevel(null);
|
||||
|
||||
return Result.Success(CommonMessageConstant.SUCCESS, userLoginResult);
|
||||
}
|
||||
|
||||
|
|
|
@ -60,13 +60,17 @@ public class CTripFlightTripInfo implements Serializable {
|
|||
private String AirlineName;
|
||||
|
||||
public static CTripFlightTripInfo of(OrderFlightResponse.FlightTripRecordInfo flightTripRecordInfo) {
|
||||
CTripFlightTripInfo cTripFlightTripInfo = BeanUtil.copyProperties(flightTripRecordInfo, CTripFlightTripInfo.class);
|
||||
cTripFlightTripInfo.setValidFlag(flightTripRecordInfo.isValidFlag() ? 1 : 0);
|
||||
cTripFlightTripInfo.setOpenTranFlag(flightTripRecordInfo.isOpenTranFlag() ? 1 : 0);
|
||||
cTripFlightTripInfo.setSharedFlag(flightTripRecordInfo.isSharedFlag() ? 1 : 0);
|
||||
cTripFlightTripInfo.setSurfaceFlag(flightTripRecordInfo.isSurfaceFlag() ? 1 : 0);
|
||||
cTripFlightTripInfo.setTicketNoStatusName(translateTicketStatus(flightTripRecordInfo.getTicketNoStatus()));
|
||||
return cTripFlightTripInfo;
|
||||
if(flightTripRecordInfo == null) {
|
||||
return null;
|
||||
} else {
|
||||
CTripFlightTripInfo cTripFlightTripInfo = BeanUtil.copyProperties(flightTripRecordInfo, CTripFlightTripInfo.class);
|
||||
cTripFlightTripInfo.setValidFlag(flightTripRecordInfo.isValidFlag() ? 1 : 0);
|
||||
cTripFlightTripInfo.setOpenTranFlag(flightTripRecordInfo.isOpenTranFlag() ? 1 : 0);
|
||||
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) {
|
||||
|
|
|
@ -1,11 +1,19 @@
|
|||
package com.chint.domain.aggregates.user;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import com.auth0.jwt.interfaces.Claim;
|
||||
import com.auth0.jwt.interfaces.DecodedJWT;
|
||||
import com.chint.application.commands.UserSFCommand;
|
||||
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.UserVO;
|
||||
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.user.dto.UserDataDTO;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import lombok.AllArgsConstructor;
|
||||
|
@ -25,7 +33,9 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
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.BPMConstant.*;
|
||||
import static com.chint.infrastructure.constant.FSSCConstant.*;
|
||||
|
@ -68,13 +78,82 @@ public class User implements Serializable {
|
|||
@Transient
|
||||
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) {
|
||||
this.employeeNo = employeeNo;
|
||||
}
|
||||
|
||||
public UserDepartmentInfo.Builder addDeptInfo() {
|
||||
return new UserDepartmentInfo.Builder(this);
|
||||
return new UserDepartmentInfo.Builder();
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
// 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;
|
||||
}
|
||||
}
|
|
@ -41,8 +41,22 @@ public class UserDepartmentInfo implements Serializable {
|
|||
private String departmentNameSeven;
|
||||
private Integer ifPrimary;
|
||||
|
||||
public String getDeptInfo(){
|
||||
return departmentNameOne + "-" + departmentNameTwo +
|
||||
private String mobilePhone;
|
||||
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 +
|
||||
"-" + departmentNameFive + "-" + departmentNameSix + "-" + departmentNameSeven;
|
||||
}
|
||||
|
@ -74,19 +88,14 @@ public class UserDepartmentInfo implements Serializable {
|
|||
|
||||
@Override
|
||||
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) {
|
||||
return new Builder(user);
|
||||
public Builder start() {
|
||||
return new Builder();
|
||||
}
|
||||
|
||||
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) {
|
||||
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) {
|
||||
this.companyCode = companyCode;
|
||||
this.companyName = companyName;
|
||||
this.departmentCodeOne = departmentCodeOne;
|
||||
|
@ -104,11 +113,18 @@ public class UserDepartmentInfo implements Serializable {
|
|||
this.departmentCodeSeven = departmentCodeSeven;
|
||||
this.departmentNameSeven = departmentNameSeven;
|
||||
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 {
|
||||
private User user;
|
||||
private String companyCode;
|
||||
private String companyName;
|
||||
private String departmentCodeOne;
|
||||
|
@ -126,10 +142,15 @@ public class UserDepartmentInfo implements Serializable {
|
|||
private String departmentCodeSeven;
|
||||
private String departmentNameSeven;
|
||||
private Integer ifPrimary;
|
||||
|
||||
public Builder(User user) {
|
||||
this.user = user;
|
||||
}
|
||||
private String mobilePhone;
|
||||
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 Builder companyInfo(String companyCode, String companyName) {
|
||||
this.companyCode = companyCode;
|
||||
|
@ -184,7 +205,28 @@ public class UserDepartmentInfo implements Serializable {
|
|||
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,
|
||||
companyName,
|
||||
departmentCodeOne,
|
||||
|
@ -201,22 +243,16 @@ public class UserDepartmentInfo implements Serializable {
|
|||
departmentNameSix,
|
||||
departmentCodeSeven,
|
||||
departmentNameSeven,
|
||||
ifPrimary);
|
||||
if (userDepartmentInfo.getIfPrimary() == null || userDepartmentInfo.getIfPrimary() != 1) {
|
||||
userDepartmentInfo.setIfPrimary(0);
|
||||
}
|
||||
List<UserDepartmentInfo> userDepartmentInfoList = user.getUserDepartmentInfoList();
|
||||
List<UserDepartmentInfo> result = new ArrayList<>();
|
||||
if(userDepartmentInfoList != null && !userDepartmentInfoList.isEmpty()) {
|
||||
List<UserDepartmentInfo> list = userDepartmentInfoList.stream().distinct().toList();
|
||||
user.setUserDepartmentInfoList(list);
|
||||
if(userDepartmentInfoList.contains(userDepartmentInfo)){
|
||||
return userDepartmentInfo;
|
||||
}
|
||||
result.addAll(userDepartmentInfoList);
|
||||
}
|
||||
result.add(userDepartmentInfo);
|
||||
user.setUserDepartmentInfoList(result);
|
||||
ifPrimary,
|
||||
mobilePhone,
|
||||
uname,
|
||||
gender,
|
||||
custManaLevel,
|
||||
custManaLevelF,
|
||||
custProfLevel,
|
||||
custTechLevel,
|
||||
custQualityLevel,
|
||||
status);
|
||||
return userDepartmentInfo;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -240,6 +240,15 @@ public class CTripOrderRecordExtensionFactory implements OrderRecordExtensionFac
|
|||
}
|
||||
}, () -> orderCarRecord.setOrderStatus("0"));
|
||||
|
||||
//修正携程成中心错误的问题
|
||||
if (byOrderNo.isPresent()) {
|
||||
RouteOrder routeOrder = byOrderNo.get();
|
||||
ApproveOrderNo approveOrderNo = routeOrder.getApproveOrderNo();
|
||||
if (approveOrderNo != null) {
|
||||
orderCarRecord.setOfflineCcomyCode(approveOrderNo.getCostCenter());
|
||||
}
|
||||
}
|
||||
|
||||
return orderCarRecord;
|
||||
}
|
||||
|
||||
|
@ -476,6 +485,14 @@ public class CTripOrderRecordExtensionFactory implements OrderRecordExtensionFac
|
|||
}
|
||||
}, () -> orderFlightRecord.setOrderStatus("0"));
|
||||
|
||||
//修正携程成中心错误的问题
|
||||
if (byOrderNo.isPresent()) {
|
||||
RouteOrder routeOrder = byOrderNo.get();
|
||||
ApproveOrderNo approveOrderNo = routeOrder.getApproveOrderNo();
|
||||
if (approveOrderNo != null) {
|
||||
orderFlightRecord.setOfflineCcomyCode(approveOrderNo.getCostCenter());
|
||||
}
|
||||
}
|
||||
|
||||
return orderFlightRecord;
|
||||
}
|
||||
|
@ -701,6 +718,18 @@ public class CTripOrderRecordExtensionFactory implements OrderRecordExtensionFac
|
|||
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;
|
||||
}
|
||||
|
||||
|
|
|
@ -59,7 +59,6 @@ public class AuthenticateServiceImpl implements AuthenticateService {
|
|||
if (user != null) {
|
||||
// 部分数据需要通过查询外部的http来获取
|
||||
user.setUserLoginParam(userLoginParam);
|
||||
BaseContext.setCurrentUser(user);
|
||||
return getUserLoginResult(user);
|
||||
} else {
|
||||
User newUser = userFactory.create(userLoginParam.getSfno());
|
||||
|
@ -68,14 +67,12 @@ public class AuthenticateServiceImpl implements AuthenticateService {
|
|||
httpRequest.loadUserInfo(newUser);
|
||||
userRepository.save(newUser);
|
||||
newUser.setUserLoginParam(userLoginParam);
|
||||
BaseContext.setCurrentUser(newUser);
|
||||
return getUserLoginResult(newUser);
|
||||
}
|
||||
}
|
||||
|
||||
private UserLoginResult getUserLoginResult(User user) {
|
||||
UserLoginParam userLoginParam = user.getUserLoginParam();
|
||||
BaseContext.setCurrentUser(user);
|
||||
user.setCompanyCode(userLoginParam.getCompanyCode());
|
||||
user.setUserLoginParam(userLoginParam);
|
||||
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_STANDARD_LEVEL, user.getStandardLevel());
|
||||
String jwt = JWTUtil.createJWT(claims);
|
||||
|
||||
//这里已经是完成的用户信息里, 因此将用户信息保存到threadLocal当中
|
||||
BaseContext.setCurrentUser(user);
|
||||
return UserLoginResult.buildWithUser(user).loadToken(Token.of(jwt));
|
||||
|
|
|
@ -6,31 +6,24 @@ import lombok.Data;
|
|||
|
||||
@Data
|
||||
public class UserLoginResult {
|
||||
private User user;
|
||||
private UserVO user;
|
||||
private Token token;
|
||||
// private String redirectUrl;
|
||||
|
||||
public UserLoginResult(User user) {
|
||||
this.user = user;
|
||||
this.user = user.mapToVO();
|
||||
this.token = null;
|
||||
}
|
||||
|
||||
public User getUser() {
|
||||
public UserVO getUser() {
|
||||
return user;
|
||||
}
|
||||
|
||||
public void setUser(User user) {
|
||||
this.user = user;
|
||||
}
|
||||
|
||||
public Token getToken() {
|
||||
return token;
|
||||
}
|
||||
|
||||
public void setToken(Token token) {
|
||||
this.token = token;
|
||||
}
|
||||
|
||||
public static UserLoginResult buildWithUser(User user) {
|
||||
return new UserLoginResult(user);
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
|
@ -8,6 +8,7 @@ public class AuthMessageConstant {
|
|||
public static final String JWT_EXPIRED = "登录信息已过期";
|
||||
public static final String JWT_REQUIRED = "需要 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 LOGIN_SUCCESS = "登录成功";
|
||||
|
|
|
@ -7,6 +7,7 @@ public class CommonMessageConstant {
|
|||
public static final String SYNC_FAILURE_TRAIN = "携程暂不支持火车票预订";
|
||||
public static final String DUPLICATE_ERROR = "数据重复";
|
||||
public static final String NOT_FOUND = "未找到相关数据";
|
||||
public static final String EMPLOYEE_NO_NOT_EXIST = "未找到相关数据";
|
||||
public static final String INVALID_REQUEST = "无效的请求";
|
||||
public static final String ACCESS_DENIED = "访问被拒绝";
|
||||
public static final String SERVER_ERROR = "服务器错误";
|
||||
|
|
|
@ -27,7 +27,7 @@ public class AmapLocationRequest {
|
|||
return amapRequest.post(BaseUrl + AMAP_LOCATION_PATH, param, LocationResponse.class);
|
||||
}
|
||||
|
||||
|
||||
@Cacheable(value = "AmapLocationACode" , key = "#locationName")
|
||||
public String getACodeByLocationName(String locationName) {
|
||||
LocationResponse locationQuery = locationQuery(locationName);
|
||||
Optional<LocationResponse.AmapCityInfo> amapCityInfo = Optional.ofNullable(locationQuery.getData())
|
||||
|
|
|
@ -1,16 +1,20 @@
|
|||
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.StaffRank;
|
||||
import com.chint.domain.aggregates.system.JTCompany;
|
||||
import com.chint.domain.aggregates.user.User;
|
||||
import com.chint.domain.aggregates.user.UserDepartmentInfo;
|
||||
import com.chint.domain.exceptions.NotFoundException;
|
||||
import com.chint.domain.repository.JTCompanyRepository;
|
||||
import com.chint.domain.repository.StaffRankRepository;
|
||||
import com.chint.domain.repository.UserRepository;
|
||||
import com.chint.domain.service.JTCompanyDomainService;
|
||||
import com.chint.domain.service.RankDomainService;
|
||||
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.StringCheck;
|
||||
import com.chint.interfaces.rest.base.PostRequest;
|
||||
|
@ -24,6 +28,7 @@ import java.util.List;
|
|||
import java.util.Optional;
|
||||
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.JT_COMPANY_CODE;
|
||||
|
||||
|
@ -65,12 +70,19 @@ public class UserHttpRequestImpl implements UserHttpRequest {
|
|||
@Autowired
|
||||
private UserRepository userRepository;
|
||||
|
||||
|
||||
@Override
|
||||
public User loadUserInfo(User user) {
|
||||
//这个方法 逻辑进行修改 , 首先通过查询 表的方式 , 如果部分数据为空 , 那么就要查询 sf信息获取
|
||||
user = loadSFInfo(user);
|
||||
if (user == null) {
|
||||
return null;
|
||||
user.loadInfoFromDept();
|
||||
//根据员工的登录信息,来创建fssc基础跳转信息
|
||||
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);
|
||||
}
|
||||
|
@ -107,7 +119,13 @@ public class UserHttpRequestImpl implements UserHttpRequest {
|
|||
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
|
||||
.getUserSFDataFromOpenApi(user);
|
||||
if (userSFDataFromOpenApi == null) {
|
||||
|
@ -117,11 +135,9 @@ public class UserHttpRequestImpl implements UserHttpRequest {
|
|||
.stream()
|
||||
.filter(userDataDTO -> userDataDTO.getStatus().equals("A"))
|
||||
.toList();
|
||||
if (fromJson.size() == 1) {
|
||||
UserDataDTO userData = fromJson.get(0);
|
||||
loadSingleSF(userData, user);
|
||||
} else {
|
||||
loadBatchSF(fromJson, user);
|
||||
|
||||
for (UserDataDTO userDataDTO : fromJson) {
|
||||
user.addDeptInfo(userDataDTO);
|
||||
}
|
||||
return user;
|
||||
}
|
||||
|
@ -132,7 +148,7 @@ public class UserHttpRequestImpl implements UserHttpRequest {
|
|||
user.addFssc(userData.getCompany_cn(), sysCode);
|
||||
//根据同步时间来决定是否要同步部门信息
|
||||
if (user.checkSyncTime()) {
|
||||
addDeptInfo(userData, user, true);
|
||||
user.addDeptInfo(userData);
|
||||
}
|
||||
return user;
|
||||
}
|
||||
|
@ -174,11 +190,7 @@ public class UserHttpRequestImpl implements UserHttpRequest {
|
|||
processSpecialCompanies(userDataDTOS, user);
|
||||
|
||||
for (UserDataDTO userDataDTO : userDataDTOS) {
|
||||
if (userDataDTO.getPersonIdExternal().equals(userDataDTO.getLoginUsername())) {
|
||||
addDeptInfo(userDataDTO, user, true);
|
||||
} else {
|
||||
addDeptInfo(userDataDTO, user, false);
|
||||
}
|
||||
user.addDeptInfo(userDataDTO);
|
||||
}
|
||||
return user;
|
||||
}
|
||||
|
@ -206,24 +218,6 @@ public class UserHttpRequestImpl implements UserHttpRequest {
|
|||
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) {
|
||||
// 若无匹配,则优先使用主岗数据,否则使用列表中的第一个
|
||||
return userDataDTOS.stream()
|
||||
|
@ -263,20 +257,11 @@ public class UserHttpRequestImpl implements UserHttpRequest {
|
|||
if (userDataDTOList == null) {
|
||||
return null;
|
||||
}
|
||||
if (userDataDTOList.size() == 1) {
|
||||
addDeptInfo(userDataDTOList.get(0), user, true);
|
||||
}
|
||||
if (userDataDTOList.size() > 1) {
|
||||
for (UserDataDTO userDataDTO : userDataDTOList) {
|
||||
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));
|
||||
|
||||
userDataDTOList.forEach(user::addDeptInfo);
|
||||
|
||||
if (user.getName() == null || user.getName().isEmpty() || user.getName().isBlank()) {
|
||||
getDataFromUserSFData(user, userDataDTOList.get(0));
|
||||
}
|
||||
|
||||
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();
|
||||
if(userDepartmentInfos.size() < userDepartmentInfoList.size()){
|
||||
if (userDepartmentInfos.size() < userDepartmentInfoList.size()) {
|
||||
user.setUserDepartmentInfoList(userDepartmentInfos);
|
||||
userRepository.save(user);
|
||||
}
|
||||
|
|
|
@ -832,7 +832,7 @@ public class LYTest {
|
|||
|
||||
@Test
|
||||
void searchHotel() {
|
||||
HotelDetailResponse hotelOrderDetail = lySearchRequest.getHotelOrderDetail("HO20240401145300516689");
|
||||
HotelDetailResponse hotelOrderDetail = lySearchRequest.getHotelOrderDetail("HO20240410160000601814");
|
||||
Gson gson = new Gson();
|
||||
String json = gson.toJson(hotelOrderDetail);
|
||||
System.out.println(json);
|
||||
|
|
Loading…
Reference in New Issue