Merge remote-tracking branch 'origin/dev' into dev
This commit is contained in:
commit
d2e8ba5558
|
@ -56,6 +56,14 @@ public class OrderController {
|
|||
return Result.Success(SUCCESS);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
@ApiOperation("取消已同步的行程规划单")
|
||||
@PostMapping("/sync/cancel")
|
||||
public Result<String> syncOrderCancel(@RequestBody SyncLegData syncLegData) {
|
||||
orderApplicationService.syncCancel(syncLegData);
|
||||
return Result.Success(SUCCESS);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
@ApiOperation("批量同步行程规划单到供应商")
|
||||
@PostMapping("/sync/batch")
|
||||
|
|
|
@ -15,6 +15,7 @@ import com.chint.domain.repository.LegRepository;
|
|||
import com.chint.domain.repository.RouteRepository;
|
||||
import com.chint.domain.service.LegDomainService;
|
||||
import com.chint.domain.service.OrderDomainService;
|
||||
import com.chint.domain.service.order_sync.SyncAdapter;
|
||||
import com.chint.domain.value_object.*;
|
||||
import com.chint.domain.value_object.enums.CurrencyType;
|
||||
import com.chint.infrastructure.constant.CommonMessageConstant;
|
||||
|
@ -59,6 +60,9 @@ public class OrderApplicationService {
|
|||
@Autowired
|
||||
private LegDomainService legDomainService;
|
||||
|
||||
@Autowired
|
||||
private SyncAdapter syncAdapter;
|
||||
|
||||
private final DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd hh:mm:ss");
|
||||
|
||||
|
||||
|
@ -206,6 +210,19 @@ public class OrderApplicationService {
|
|||
Command.of(LegSyncCommand.class).data(syncLegData).sendToQueue();
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void syncCancel(SyncLegData syncLegData) {
|
||||
Long routeId = syncLegData.getRouteId();
|
||||
if(routeId != null){
|
||||
RouteOrder routeOrder = routeRepository.queryById(routeId);
|
||||
String supplierName = routeOrder.getSupplierName();
|
||||
if(supplierName != null){
|
||||
syncAdapter.of(supplierName).cancelSyncSupplierOrder(routeOrder);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Transactional
|
||||
public void ordered(OrderLegData data) {
|
||||
Command.of(RouteUpdateOrderCommand.class).data(data).sendToQueue();
|
||||
|
|
|
@ -55,28 +55,8 @@ public class AuthenticateServiceImpl implements AuthenticateService {
|
|||
User user = userRepository.findByUserEmployeeNo(userLoginParam.getSfno());
|
||||
if (user != null) {
|
||||
// 部分数据需要通过查询外部的http来获取
|
||||
BaseContext.setCurrentUser(user);
|
||||
user.setCompanyCode(userLoginParam.getCompanyCode());
|
||||
user.setUserLoginParam(userLoginParam);
|
||||
httpRequest.loadUserInfo(user);
|
||||
List<FsscSystem> fsscSystemList = user.getFsscSystemList();
|
||||
Map<String, Object> claims = new HashMap<>();
|
||||
claims.put(USER_ID, user.getUserId());
|
||||
claims.put(USER_PHONE, user.getPhoneNumber());
|
||||
claims.put(USER_EMAIL, user.getEmail());
|
||||
claims.put(USER_EMPLOYEE_NO, user.getEmployeeNo());
|
||||
claims.put(USER_NAME, user.getName());
|
||||
claims.put(USER_EMPLOYEE_LEVEL, user.getEmployeeLevel());
|
||||
claims.put(USER_RANK_CODE, user.getStandardLevel());
|
||||
claims.put(USER_COMPANY_CODE, user.getCompanyCode());
|
||||
claims.put(USER_LOGIN_PARAM, json.gson().toJson(userLoginParam));
|
||||
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));
|
||||
return getUserLoginResult(user);
|
||||
|
||||
} else {
|
||||
User newUser = userFactory.create(userLoginParam.getSfno());
|
||||
|
@ -84,10 +64,37 @@ public class AuthenticateServiceImpl implements AuthenticateService {
|
|||
newUser.setCompanyCode(userLoginParam.getCompanyCode());
|
||||
httpRequest.loadUserInfo(newUser);
|
||||
userRepository.save(newUser);
|
||||
return authenticateEmployeeNo(userLoginParam);
|
||||
newUser.setUserLoginParam(userLoginParam);
|
||||
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);
|
||||
List<FsscSystem> fsscSystemList = user.getFsscSystemList();
|
||||
Map<String, Object> claims = new HashMap<>();
|
||||
claims.put(USER_ID, user.getUserId());
|
||||
claims.put(USER_PHONE, user.getPhoneNumber());
|
||||
claims.put(USER_EMAIL, user.getEmail());
|
||||
claims.put(USER_EMPLOYEE_NO, user.getEmployeeNo());
|
||||
claims.put(USER_NAME, user.getName());
|
||||
claims.put(USER_EMPLOYEE_LEVEL, user.getEmployeeLevel());
|
||||
claims.put(USER_RANK_CODE, user.getStandardLevel());
|
||||
claims.put(USER_COMPANY_CODE, user.getCompanyCode());
|
||||
claims.put(USER_LOGIN_PARAM, json.gson().toJson(userLoginParam));
|
||||
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));
|
||||
}
|
||||
|
||||
@Override
|
||||
public OrderSearchResult authenticateClient(AuthenticationDto authenticationDto) throws Exception {
|
||||
|
||||
|
|
|
@ -49,7 +49,7 @@ public class LYOrderSyncAdapter implements SupplierOrderSync {
|
|||
public boolean syncSupplierOrder(RouteOrder order) {
|
||||
log.info("开始同步同程订单");
|
||||
Boolean flag = synchronization(order, "1");
|
||||
System.out.println("flag = " + flag);
|
||||
log.info("flag = " + flag);
|
||||
return flag;
|
||||
}
|
||||
|
||||
|
@ -59,7 +59,7 @@ public class LYOrderSyncAdapter implements SupplierOrderSync {
|
|||
order.setStatus(2);
|
||||
log.info("开始取消同程订单");
|
||||
Boolean flag = synchronization(order, "2");
|
||||
System.out.println("flag = " + flag);
|
||||
log.info("flag = " + flag);
|
||||
return flag;
|
||||
}
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@ public class UserRepositoryImpl implements UserRepository {
|
|||
return null;
|
||||
}
|
||||
|
||||
@Cacheable(value = "UserByEmployeeNo", key = "#employeeNo")
|
||||
|
||||
@Override
|
||||
public User findByUserEmployeeNo(String employeeNo) {
|
||||
return jdbcUserRepository.findByEmployeeNo(employeeNo);
|
||||
|
|
|
@ -19,6 +19,9 @@ import org.springframework.stereotype.Service;
|
|||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static com.chint.infrastructure.constant.RankConstant.*;
|
||||
|
||||
|
@ -94,7 +97,11 @@ public class UserHttpRequestImpl implements UserHttpRequest {
|
|||
}
|
||||
|
||||
private User loadSFInfo(User user) {
|
||||
List<UserDataDTO> fromJson = userSFRequest.getUserSFDataFromOpenApi(user);
|
||||
List<UserDataDTO> fromJson = userSFRequest
|
||||
.getUserSFDataFromOpenApi(user)
|
||||
.stream()
|
||||
.filter(userDataDTO -> userDataDTO.getStatus().equals("A"))
|
||||
.toList();
|
||||
if (fromJson.size() == 1) {
|
||||
UserDataDTO userData = fromJson.get(0);
|
||||
loadSingleSF(userData, user);
|
||||
|
@ -115,62 +122,58 @@ public class UserHttpRequestImpl implements UserHttpRequest {
|
|||
if (jtCompanyDomainService.ifCompanyInJT(null, userData.getCompany())) {
|
||||
user.addJTFssc(FSSC_LOAD_URL, postRequest);
|
||||
}
|
||||
if (user.getEmployeeNo().equals("200226032")) {
|
||||
user.addXNFssc(FSSC_LOAD_URL, postRequest);
|
||||
}
|
||||
|
||||
return user;
|
||||
}
|
||||
|
||||
private User loadBatchSF(List<UserDataDTO> userDataDTOS, User user) {
|
||||
//从用户身上获取companyCode ,
|
||||
String companyCode = user.getCompanyCode();
|
||||
if (companyCode == null) {
|
||||
//如果为null,说明用户是登录操作 ,那么从登录参数中获取 companyCode
|
||||
companyCode = BaseContext.getCurrentUser().getUserLoginParam().getCompanyCode();
|
||||
}
|
||||
String newCompanyCode = companyCode;
|
||||
List<String> companyCodeList = userDataDTOS.stream().map(UserDataDTO::getCompany).toList();
|
||||
Optional<UserDataDTO> first;
|
||||
if (StringCheck.isFirstCharacterChinese(newCompanyCode)) {
|
||||
first = userDataDTOS.stream()
|
||||
.filter(userData -> userData.getCompany_cn().equals(newCompanyCode))
|
||||
.findFirst();
|
||||
// 获取公司代码,优先从用户获取,若为空则从登录参数中获取
|
||||
String companyCode = Optional.ofNullable(user.getCompanyCode())
|
||||
.orElseGet(() -> BaseContext.getCurrentUser().getUserLoginParam().getCompanyCode());
|
||||
|
||||
} else {
|
||||
first = userDataDTOS.stream()
|
||||
.filter(userData -> userData.getCompany().equals(newCompanyCode))
|
||||
.findFirst();
|
||||
}
|
||||
// 根据公司代码获取对应的UserDataDTO
|
||||
Predicate<UserDataDTO> matchCompanyCode = StringCheck.isFirstCharacterChinese(companyCode) ?
|
||||
userData -> userData.getCompany_cn().equals(companyCode) :
|
||||
userData -> userData.getCompany().equals(companyCode);
|
||||
|
||||
UserDataDTO userData = userDataDTOS.stream()
|
||||
.filter(matchCompanyCode)
|
||||
.findFirst()
|
||||
.orElseGet(() -> getFallbackUserData(userDataDTOS));
|
||||
|
||||
first.ifPresent(
|
||||
userData -> {
|
||||
getDataFromUserSFData(user, userData);
|
||||
}
|
||||
);
|
||||
// 使用获取到的UserDataDTO更新用户信息
|
||||
getDataFromUserSFData(user, userData);
|
||||
|
||||
if (first.isEmpty()) {
|
||||
//如果不存在的话 ,复制主岗数据
|
||||
Optional<UserDataDTO> dataDTO = userDataDTOS.stream()
|
||||
.filter(userData -> userData.getUserId().equals(userData.getPersonIdExternal()))
|
||||
.findFirst();
|
||||
if (dataDTO.isPresent()) {
|
||||
getDataFromUserSFData(user, dataDTO.get());
|
||||
} else {
|
||||
getDataFromUserSFData(user, userDataDTOS.get(0));
|
||||
}
|
||||
}
|
||||
//如果用户的公司编码属于集团 ,那么加入集团财务共享跳转地址
|
||||
if (jtCompanyDomainService.ifCompanyInJT(null, user.getCompanyCode())) {
|
||||
user.addJTFssc(FSSC_LOAD_URL, postRequest);
|
||||
}
|
||||
if (companyCodeList.contains(XN_COMPANY_CODE)) {
|
||||
user.addXNFssc(FSSC_LOAD_URL, postRequest);
|
||||
}
|
||||
// 检查并处理JT公司和XN公司的特殊情况
|
||||
processSpecialCompanies(userDataDTOS, user);
|
||||
|
||||
return user;
|
||||
}
|
||||
|
||||
private UserDataDTO getFallbackUserData(List<UserDataDTO> userDataDTOS) {
|
||||
// 若无匹配,则优先使用主岗数据,否则使用列表中的第一个
|
||||
return userDataDTOS.stream()
|
||||
.filter(userData -> userData.getUserId().equals(userData.getPersonIdExternal()))
|
||||
.findFirst()
|
||||
.orElse(userDataDTOS.get(0));
|
||||
}
|
||||
|
||||
private void processSpecialCompanies(List<UserDataDTO> userDataDTOS, User user) {
|
||||
Set<String> companyCodes = userDataDTOS.stream()
|
||||
.map(UserDataDTO::getCompany)
|
||||
.collect(Collectors.toSet());
|
||||
|
||||
boolean isInJTCompany = companyCodes.stream()
|
||||
.anyMatch(code -> jtCompanyDomainService.ifCompanyInJT(null, code));
|
||||
|
||||
if (isInJTCompany) {
|
||||
user.addJTFssc(FSSC_LOAD_URL, postRequest);
|
||||
}
|
||||
if (companyCodes.contains(XN_COMPANY_CODE)) {
|
||||
user.addXNFssc(FSSC_LOAD_URL, postRequest);
|
||||
}
|
||||
}
|
||||
|
||||
private User getDataFromUserSFData(User user, UserDataDTO userData) {
|
||||
user.setCompanyCode(userData.getCompany());
|
||||
user.setWorkStatus(userData.getStatus());
|
||||
|
|
|
@ -76,7 +76,4 @@ public class UserSFRequest {
|
|||
throw new NotFoundException(NOT_FOUND);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -20,8 +20,8 @@ chint:
|
|||
|
||||
logging:
|
||||
level:
|
||||
org.springframework.jdbc.core.JdbcTemplate: info
|
||||
org.springframework.jdbc.core.StatementCreatorUtils: info
|
||||
org.springframework.jdbc.core.JdbcTemplate: trace
|
||||
org.springframework.jdbc.core.StatementCreatorUtils: trace
|
||||
root: info
|
||||
org.springframework.cache: info
|
||||
|
||||
|
|
|
@ -32,8 +32,8 @@ chint:
|
|||
|
||||
logging:
|
||||
level:
|
||||
org.springframework.jdbc.core.JdbcTemplate: info
|
||||
org.springframework.jdbc.core.StatementCreatorUtils: info
|
||||
org.springframework.jdbc.core.JdbcTemplate: trace
|
||||
org.springframework.jdbc.core.StatementCreatorUtils: trace
|
||||
root: info
|
||||
org.springframework.cache: info
|
||||
|
||||
|
|
Loading…
Reference in New Issue