修改登录的用户信息同步逻辑 , 修改取消差旅申请单缺失行程的问题
This commit is contained in:
parent
74f2e31f85
commit
bfa2e83a6d
|
@ -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 UserLoginCommand extends Command {
|
||||||
|
private User user;
|
||||||
|
|
||||||
|
public UserLoginCommand user(User user) {
|
||||||
|
this.user = user;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,29 +1,19 @@
|
||||||
package com.chint.application.in;
|
package com.chint.application.in;
|
||||||
|
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSON;
|
|
||||||
import com.chint.application.commands.LYOrderRecordGenerateCommand;
|
import com.chint.application.commands.LYOrderRecordGenerateCommand;
|
||||||
import com.chint.application.dtos.AuthenticationSignDto;
|
|
||||||
import com.chint.application.dtos.CTripRecordMonthSaveDTO;
|
import com.chint.application.dtos.CTripRecordMonthSaveDTO;
|
||||||
import com.chint.domain.aggregates.order.OrderDetail;
|
|
||||||
import com.chint.domain.aggregates.order.RouteOrder;
|
import com.chint.domain.aggregates.order.RouteOrder;
|
||||||
import com.chint.domain.factoriy.order_record.LyStatementOrder;
|
import com.chint.domain.factoriy.order_record.LyStatementOrder;
|
||||||
import com.chint.infrastructure.config.LogConfig.Dto.LogPageDto;
|
|
||||||
import com.chint.infrastructure.config.LogConfig.SystemLog;
|
|
||||||
import com.chint.infrastructure.constant.CommonMessageConstant;
|
|
||||||
import com.chint.infrastructure.echo_framework.command.Command;
|
import com.chint.infrastructure.echo_framework.command.Command;
|
||||||
import com.chint.application.commands.OrderRecordGenerateCommand;
|
import com.chint.application.commands.OrderRecordGenerateCommand;
|
||||||
import com.chint.domain.factoriy.order_record.LyStatementOrder;
|
|
||||||
import com.chint.infrastructure.echo_framework.command.Command;
|
|
||||||
import com.chint.infrastructure.repository.jdbc.JdbcRouteRepository;
|
import com.chint.infrastructure.repository.jdbc.JdbcRouteRepository;
|
||||||
import com.chint.infrastructure.util.BeanCopyUtils;
|
|
||||||
import com.chint.infrastructure.util.DateTimeUtil;
|
import com.chint.infrastructure.util.DateTimeUtil;
|
||||||
import com.chint.infrastructure.util.PageResult;
|
import com.chint.infrastructure.util.PageResult;
|
||||||
import com.chint.infrastructure.util.Result;
|
import com.chint.infrastructure.util.Result;
|
||||||
import com.chint.interfaces.rest.ctrip.order.CTripOrderRecordAutoSave;
|
import com.chint.interfaces.rest.ctrip.order.CTripOrderRecordAutoSave;
|
||||||
import com.chint.interfaces.rest.ly.reconciliation.dto.PageInfo;
|
import com.chint.interfaces.rest.ly.reconciliation.dto.PageInfo;
|
||||||
import com.google.gson.Gson;
|
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
import org.springframework.data.domain.PageRequest;
|
import org.springframework.data.domain.PageRequest;
|
||||||
|
@ -32,15 +22,11 @@ import org.springframework.web.bind.annotation.PostMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
import com.chint.application.commands.OrderRecordGenerateCommand;
|
|
||||||
|
|
||||||
import java.time.LocalDate;
|
|
||||||
import java.time.format.DateTimeFormatter;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import static com.chint.infrastructure.constant.CommonMessageConstant.SUCCESS;
|
import static com.chint.infrastructure.constant.CommonMessageConstant.SUCCESS;
|
||||||
|
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/public")
|
@RequestMapping("/public")
|
||||||
public class AutoWorkController {
|
public class AutoWorkController {
|
||||||
|
@ -52,7 +38,6 @@ public class AutoWorkController {
|
||||||
@Autowired
|
@Autowired
|
||||||
private LyStatementOrder lyStatementOrder;
|
private LyStatementOrder lyStatementOrder;
|
||||||
|
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
@ApiOperation("自动拉取昨天的流水号,每天晚上8点执行")
|
@ApiOperation("自动拉取昨天的流水号,每天晚上8点执行")
|
||||||
@PostMapping("/cTrip/record/save")
|
@PostMapping("/cTrip/record/save")
|
||||||
|
@ -104,5 +89,4 @@ public class AutoWorkController {
|
||||||
PageResult<RouteOrder> routeOrderPageResult = PageResult.totalPageNum(res.getTotalElements(), res.toList());
|
PageResult<RouteOrder> routeOrderPageResult = PageResult.totalPageNum(res.getTotalElements(), res.toList());
|
||||||
return Result.Success(SUCCESS, routeOrderPageResult);
|
return Result.Success(SUCCESS, routeOrderPageResult);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@ package com.chint.application.out;
|
||||||
|
|
||||||
|
|
||||||
import com.chint.application.commands.OrderCreateCommand;
|
import com.chint.application.commands.OrderCreateCommand;
|
||||||
|
import com.chint.application.commands.UserLoginCommand;
|
||||||
import com.chint.application.services.login.strategy.ANFeiShuLoginStrategy;
|
import com.chint.application.services.login.strategy.ANFeiShuLoginStrategy;
|
||||||
import com.chint.application.services.login.strategy.FeishuLoginStrategy;
|
import com.chint.application.services.login.strategy.FeishuLoginStrategy;
|
||||||
import com.chint.application.services.login.strategy.PailaLoginStrategy;
|
import com.chint.application.services.login.strategy.PailaLoginStrategy;
|
||||||
|
@ -27,7 +28,6 @@ import io.swagger.annotations.ApiOperation;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
|
@ -104,12 +104,10 @@ public class LoginController {
|
||||||
//发送创建行程订单命令
|
//发送创建行程订单命令
|
||||||
Command.of(OrderCreateCommand.class).of(currentUser).sendToQueue();
|
Command.of(OrderCreateCommand.class).of(currentUser).sendToQueue();
|
||||||
}
|
}
|
||||||
syncUserInfoToSupplier(currentUser);
|
loginEventBoarder(currentUser);
|
||||||
//清除职级信息
|
//清除职级信息
|
||||||
userLoginResult.getUser().setProfLevel(null);
|
userLoginResult.getUser().setProfLevel(null);
|
||||||
userLoginResult.getUser().setManaLevel(null);
|
userLoginResult.getUser().setManaLevel(null);
|
||||||
//登录成功之后对该用户的行程规划单进行缓存
|
|
||||||
cacheUserRouteOrder(currentUser.getEmployeeNo());
|
|
||||||
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);
|
||||||
|
@ -128,13 +126,11 @@ public class LoginController {
|
||||||
|
|
||||||
//异步执行更新用户信息到同程
|
//异步执行更新用户信息到同程
|
||||||
User currentUser = userLoginResult.getUser();
|
User currentUser = userLoginResult.getUser();
|
||||||
syncUserInfoToSupplier(currentUser);
|
loginEventBoarder(currentUser);
|
||||||
//清除职级信息
|
//清除职级信息
|
||||||
userLoginResult.getUser().setProfLevel(null);
|
userLoginResult.getUser().setProfLevel(null);
|
||||||
userLoginResult.getUser().setManaLevel(null);
|
userLoginResult.getUser().setManaLevel(null);
|
||||||
|
|
||||||
//登录成功之后对该用户的行程规划单进行缓存
|
|
||||||
cacheUserRouteOrder(currentUser.getEmployeeNo());
|
|
||||||
return Result.Success(CommonMessageConstant.SUCCESS, userLoginResult);
|
return Result.Success(CommonMessageConstant.SUCCESS, userLoginResult);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -150,14 +146,12 @@ public class LoginController {
|
||||||
|
|
||||||
//异步执行更新用户信息到同程
|
//异步执行更新用户信息到同程
|
||||||
User currentUser = userLoginResult.getUser();
|
User currentUser = userLoginResult.getUser();
|
||||||
syncUserInfoToSupplier(currentUser);
|
loginEventBoarder(currentUser);
|
||||||
|
|
||||||
//清除职级信息
|
//清除职级信息
|
||||||
userLoginResult.getUser().setProfLevel(null);
|
userLoginResult.getUser().setProfLevel(null);
|
||||||
userLoginResult.getUser().setManaLevel(null);
|
userLoginResult.getUser().setManaLevel(null);
|
||||||
|
|
||||||
//登录成功之后对该用户的行程规划单进行缓存
|
|
||||||
cacheUserRouteOrder(currentUser.getEmployeeNo());
|
|
||||||
return Result.Success(CommonMessageConstant.SUCCESS, userLoginResult);
|
return Result.Success(CommonMessageConstant.SUCCESS, userLoginResult);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -172,50 +166,19 @@ public class LoginController {
|
||||||
|
|
||||||
//异步执行更新用户信息到同程
|
//异步执行更新用户信息到同程
|
||||||
User currentUser = userLoginResult.getUser();
|
User currentUser = userLoginResult.getUser();
|
||||||
syncUserInfoToSupplier(currentUser);
|
loginEventBoarder(currentUser);
|
||||||
|
|
||||||
//清除职级信息
|
//清除职级信息
|
||||||
userLoginResult.getUser().setProfLevel(null);
|
userLoginResult.getUser().setProfLevel(null);
|
||||||
userLoginResult.getUser().setManaLevel(null);
|
userLoginResult.getUser().setManaLevel(null);
|
||||||
|
|
||||||
//登录成功之后对该用户的行程规划单进行缓存
|
|
||||||
cacheUserRouteOrder(currentUser.getEmployeeNo());
|
|
||||||
return Result.Success(CommonMessageConstant.SUCCESS, userLoginResult);
|
return Result.Success(CommonMessageConstant.SUCCESS, userLoginResult);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void syncUserInfoToSupplier(User user) {
|
private void loginEventBoarder(User user) {
|
||||||
// 给定的 LocalDateTime 实例,示例中为2024年3月1日15:00
|
Command.of(UserLoginCommand.class).user(user).sendToQueue();
|
||||||
if (user.checkSyncTime()) {
|
|
||||||
asyncUser(user);
|
|
||||||
} else {
|
|
||||||
log.info("未超过一天,不执行同步。");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void asyncUser(User user) {
|
|
||||||
// 如果超过一天,执行同步代码
|
|
||||||
CompletableFuture.runAsync(() -> {
|
|
||||||
BaseContext.setCurrentUser(user);
|
|
||||||
lyUserRequest.saveCurrentUser();
|
|
||||||
BaseContext.removeCurrentUser();
|
|
||||||
});
|
|
||||||
//异步执行更新用户信息到携程
|
|
||||||
CompletableFuture.runAsync(() -> {
|
|
||||||
BaseContext.setCurrentUser(user);
|
|
||||||
cTripUserSaveRequest.saveUserToCTrip();
|
|
||||||
BaseContext.removeCurrentUser();
|
|
||||||
});
|
|
||||||
// 发送保存用户同步时间
|
|
||||||
user.setSyncTime(LocalDateTime.now());
|
user.setSyncTime(LocalDateTime.now());
|
||||||
userRepository.save(user);
|
userRepository.save(user);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void cacheUserRouteOrder(String employeeNo) {
|
|
||||||
//登录成功之后对该用户的行程规划单进行缓存
|
|
||||||
CompletableFuture.runAsync(() -> {
|
|
||||||
log.info("开始缓存" + employeeNo + "用户的行程规划单");
|
|
||||||
routeCacheService.preloadUserRoutes(employeeNo);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,6 +47,12 @@ public class User implements Serializable {
|
||||||
private String phoneNumber;
|
private String phoneNumber;
|
||||||
private String password;
|
private String password;
|
||||||
private LocalDateTime syncTime;
|
private LocalDateTime syncTime;
|
||||||
|
@Transient
|
||||||
|
private String manaLevel;
|
||||||
|
@Transient
|
||||||
|
private String profLevel;
|
||||||
|
@Transient
|
||||||
|
private String qualityLevel;
|
||||||
@MappedCollection(idColumn = "user_id", keyColumn = "user_key")
|
@MappedCollection(idColumn = "user_id", keyColumn = "user_key")
|
||||||
private List<UserDepartmentInfo> userDepartmentInfoList;
|
private List<UserDepartmentInfo> userDepartmentInfoList;
|
||||||
@Transient
|
@Transient
|
||||||
|
@ -60,12 +66,6 @@ public class User implements Serializable {
|
||||||
@Transient
|
@Transient
|
||||||
private String workStatus;
|
private String workStatus;
|
||||||
@Transient
|
@Transient
|
||||||
private String manaLevel;
|
|
||||||
@Transient
|
|
||||||
private String profLevel;
|
|
||||||
@Transient
|
|
||||||
private String qualityLevel;
|
|
||||||
@Transient
|
|
||||||
private UserLoginParam userLoginParam;
|
private UserLoginParam userLoginParam;
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,6 @@ import com.chint.domain.service.LegDomainService;
|
||||||
import com.chint.domain.service.OrderDomainService;
|
import com.chint.domain.service.OrderDomainService;
|
||||||
import com.chint.domain.service.RouteRequestDomainService;
|
import com.chint.domain.service.RouteRequestDomainService;
|
||||||
import com.chint.domain.service.order_sync.SyncAdapter;
|
import com.chint.domain.service.order_sync.SyncAdapter;
|
||||||
import com.chint.domain.value_object.ApprovalSimpleData;
|
|
||||||
import com.chint.domain.value_object.ApproveRouteData;
|
import com.chint.domain.value_object.ApproveRouteData;
|
||||||
import com.chint.domain.value_object.OrderLegData;
|
import com.chint.domain.value_object.OrderLegData;
|
||||||
import com.chint.domain.value_object.SyncLegData;
|
import com.chint.domain.value_object.SyncLegData;
|
||||||
|
@ -35,13 +34,13 @@ import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import java.time.LocalDate;
|
|
||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
import static com.chint.infrastructure.constant.BPMConstant.*;
|
import static com.chint.infrastructure.constant.BPMConstant.*;
|
||||||
import static com.chint.infrastructure.constant.CommonMessageConstant.LEG_CHANGE_MAX_ERROR;
|
import static com.chint.infrastructure.constant.CommonMessageConstant.LEG_CHANGE_MAX_ERROR;
|
||||||
|
import static com.chint.infrastructure.constant.CommonMessageConstant.NOT_FOUND;
|
||||||
import static com.chint.infrastructure.constant.DataMessageConstant.DATA_NOT_FOUND;
|
import static com.chint.infrastructure.constant.DataMessageConstant.DATA_NOT_FOUND;
|
||||||
import static com.chint.infrastructure.constant.LegConstant.*;
|
import static com.chint.infrastructure.constant.LegConstant.*;
|
||||||
import static com.chint.infrastructure.constant.OrderConstant.*;
|
import static com.chint.infrastructure.constant.OrderConstant.*;
|
||||||
|
@ -207,6 +206,9 @@ public class LegEventHandler implements LegEventService {
|
||||||
String orderNo = data.getSelfOrderNo();
|
String orderNo = data.getSelfOrderNo();
|
||||||
RouteOrder routeOrder = routeRequestDomainService.getRouteOrder(orderNo);
|
RouteOrder routeOrder = routeRequestDomainService.getRouteOrder(orderNo);
|
||||||
//获取行程规划单创建者作为该订单
|
//获取行程规划单创建者作为该订单
|
||||||
|
if (routeOrder == null) {
|
||||||
|
throw new OrderException(NOT_FOUND + "单号为" + orderNo);
|
||||||
|
}
|
||||||
String employeeNo = routeOrder.getUserId();
|
String employeeNo = routeOrder.getUserId();
|
||||||
User byUserEmployeeNo = userRepository.findByUserEmployeeNo(employeeNo);
|
User byUserEmployeeNo = userRepository.findByUserEmployeeNo(employeeNo);
|
||||||
BaseContext.setCurrentUser(byUserEmployeeNo);
|
BaseContext.setCurrentUser(byUserEmployeeNo);
|
||||||
|
@ -307,8 +309,15 @@ public class LegEventHandler implements LegEventService {
|
||||||
|
|
||||||
List<RouteRequest> routeRequestList = routeOrder.getRouteRequestList();
|
List<RouteRequest> routeRequestList = routeOrder.getRouteRequestList();
|
||||||
|
|
||||||
if(routeRequestList != null && !routeRequestList.isEmpty()) {
|
if (routeRequestList != null && !routeRequestList.isEmpty()) {
|
||||||
routeRequestList.forEach(it->syncAdapter.of(it.getSupplier()).cancelRouteRequest(it));
|
routeRequestList.forEach(it -> {
|
||||||
|
List<Long> legIds = it.getRouteRequestLegList().stream().map(RouteRequestLeg::getLegId).toList();
|
||||||
|
it.reloadGenerateRequestLegs(routeOrder.getLegItems()
|
||||||
|
.stream()
|
||||||
|
.filter(leg -> legIds.contains(leg.getLegId()))
|
||||||
|
.toList());
|
||||||
|
syncAdapter.of(it.getSupplier()).cancelRouteRequest(it);
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
if (!list.isEmpty() && !syncAdapter.of(routeOrder.getSupplierName()).cancelSyncSupplierOrder(routeOrder)) {
|
if (!list.isEmpty() && !syncAdapter.of(routeOrder.getSupplierName()).cancelSyncSupplierOrder(routeOrder)) {
|
||||||
throw new CommandException("订单取消失败");
|
throw new CommandException("订单取消失败");
|
||||||
|
@ -389,7 +398,7 @@ public class LegEventHandler implements LegEventService {
|
||||||
}
|
}
|
||||||
case ANYS_BPM -> {
|
case ANYS_BPM -> {
|
||||||
JTH3ChangeDto jth3ChangeDto = new JTH3ChangeDto();
|
JTH3ChangeDto jth3ChangeDto = new JTH3ChangeDto();
|
||||||
bpmRequest.change(jth3ChangeDto,AN_FSSC,userId,accountCompany);
|
bpmRequest.change(jth3ChangeDto, AN_FSSC, userId, accountCompany);
|
||||||
}
|
}
|
||||||
default -> throw new NotFoundException(DATA_NOT_FOUND);
|
default -> throw new NotFoundException(DATA_NOT_FOUND);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,17 +1,23 @@
|
||||||
package com.chint.infrastructure.cache;
|
package com.chint.infrastructure.cache;
|
||||||
|
|
||||||
|
import com.chint.application.commands.UserLoginCommand;
|
||||||
import com.chint.domain.aggregates.order.ApproveOrderNo;
|
import com.chint.domain.aggregates.order.ApproveOrderNo;
|
||||||
import com.chint.domain.aggregates.order.RouteOrder;
|
import com.chint.domain.aggregates.order.RouteOrder;
|
||||||
import com.chint.domain.aggregates.user.User;
|
import com.chint.domain.aggregates.user.User;
|
||||||
|
import com.chint.infrastructure.echo_framework.annotation.ListenTo;
|
||||||
import com.chint.infrastructure.repository.jdbc.JdbcRouteRepository;
|
import com.chint.infrastructure.repository.jdbc.JdbcRouteRepository;
|
||||||
import com.chint.infrastructure.util.BaseContext;
|
import com.chint.infrastructure.util.BaseContext;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
import java.util.Optional;
|
||||||
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
@Service
|
@Service
|
||||||
public class RouteCacheService {
|
public class RouteCacheService {
|
||||||
@Autowired
|
@Autowired
|
||||||
|
@ -21,7 +27,16 @@ public class RouteCacheService {
|
||||||
private JdbcRouteRepository jdbcRouteRepository;
|
private JdbcRouteRepository jdbcRouteRepository;
|
||||||
|
|
||||||
|
|
||||||
|
@ListenTo(command = "UserLoginCommand", order = 9)
|
||||||
|
public void loginAndPreloadUserRoutes(UserLoginCommand command) {
|
||||||
|
Optional.ofNullable(command.getUser())
|
||||||
|
.flatMap(it -> Optional.ofNullable(it.getEmployeeNo()))
|
||||||
|
.ifPresent(it -> CompletableFuture.runAsync(() -> preloadUserRoutes(it)));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public List<RouteOrder> preloadUserRoutes(String employeeNo) {
|
public List<RouteOrder> preloadUserRoutes(String employeeNo) {
|
||||||
|
log.info("开始缓存用户行程规划单");
|
||||||
List<RouteOrder> routeOrders = jdbcRouteRepository.findByUserIdOrApproveOrderNo_Creator(employeeNo, employeeNo);
|
List<RouteOrder> routeOrders = jdbcRouteRepository.findByUserIdOrApproveOrderNo_Creator(employeeNo, employeeNo);
|
||||||
for (RouteOrder routeOrder : routeOrders) {
|
for (RouteOrder routeOrder : routeOrders) {
|
||||||
routeCacheManage.cacheRouteOrder(routeOrder);
|
routeCacheManage.cacheRouteOrder(routeOrder);
|
||||||
|
|
|
@ -35,9 +35,9 @@ public class OrderDetailExportFactory {
|
||||||
orderDetailExport.setProjectCode(it.getProjectOrderNo());
|
orderDetailExport.setProjectCode(it.getProjectOrderNo());
|
||||||
orderDetailExport.setSupplierName(translateSupplierName(it.getTrvaleSysType()));
|
orderDetailExport.setSupplierName(translateSupplierName(it.getTrvaleSysType()));
|
||||||
User byUserEmployeeNo = null;
|
User byUserEmployeeNo = null;
|
||||||
if (it.getUserCode() != null) {
|
if (it.getUserCode() != null && !it.getUserCode().isEmpty()) {
|
||||||
byUserEmployeeNo = userRepository.findByUserEmployeeNo(it.getUserCode());
|
byUserEmployeeNo = userRepository.findByUserEmployeeNo(it.getUserCode());
|
||||||
} else if (it.getBookingUserCode() != null) {
|
} else if (it.getBookingUserCode() != null && !it.getBookingUserCode().isEmpty()) {
|
||||||
byUserEmployeeNo = userRepository.findByUserEmployeeNo(it.getBookingUserCode());
|
byUserEmployeeNo = userRepository.findByUserEmployeeNo(it.getBookingUserCode());
|
||||||
}
|
}
|
||||||
if (byUserEmployeeNo != null) {
|
if (byUserEmployeeNo != null) {
|
||||||
|
@ -74,7 +74,7 @@ public class OrderDetailExportFactory {
|
||||||
orderDetailExport.setProjectCode(it.getProjectOrderNo());
|
orderDetailExport.setProjectCode(it.getProjectOrderNo());
|
||||||
orderDetailExport.setSupplierName(translateSupplierName(it.getTrvaleSysType()));
|
orderDetailExport.setSupplierName(translateSupplierName(it.getTrvaleSysType()));
|
||||||
User byUserEmployeeNo = null;
|
User byUserEmployeeNo = null;
|
||||||
if (it.getBookingUserCode() != null) {
|
if (it.getBookingUserCode() != null && !it.getBookingUserCode().isEmpty()) {
|
||||||
byUserEmployeeNo = userRepository.findByUserEmployeeNo(it.getBookingUserCode());
|
byUserEmployeeNo = userRepository.findByUserEmployeeNo(it.getBookingUserCode());
|
||||||
}
|
}
|
||||||
if (byUserEmployeeNo != null) {
|
if (byUserEmployeeNo != null) {
|
||||||
|
@ -111,9 +111,9 @@ public class OrderDetailExportFactory {
|
||||||
orderDetailExport.setProjectCode(it.getProjectOrderNo());
|
orderDetailExport.setProjectCode(it.getProjectOrderNo());
|
||||||
orderDetailExport.setSupplierName(translateSupplierName(it.getTrvaleSysType()));
|
orderDetailExport.setSupplierName(translateSupplierName(it.getTrvaleSysType()));
|
||||||
User byUserEmployeeNo = null;
|
User byUserEmployeeNo = null;
|
||||||
if (it.getUserCode() != null) {
|
if (it.getUserCode() != null && !it.getUserCode().isEmpty()) {
|
||||||
byUserEmployeeNo = userRepository.findByUserEmployeeNo(it.getUserCode());
|
byUserEmployeeNo = userRepository.findByUserEmployeeNo(it.getUserCode());
|
||||||
} else if (it.getBookingUserCode() != null) {
|
} else if (it.getBookingUserCode() != null && !it.getBookingUserCode().isEmpty()) {
|
||||||
byUserEmployeeNo = userRepository.findByUserEmployeeNo(it.getBookingUserCode());
|
byUserEmployeeNo = userRepository.findByUserEmployeeNo(it.getBookingUserCode());
|
||||||
}
|
}
|
||||||
if (byUserEmployeeNo != null) {
|
if (byUserEmployeeNo != null) {
|
||||||
|
@ -150,9 +150,9 @@ public class OrderDetailExportFactory {
|
||||||
orderDetailExport.setProjectCode(it.getProjectOrderNo());
|
orderDetailExport.setProjectCode(it.getProjectOrderNo());
|
||||||
orderDetailExport.setSupplierName(translateSupplierName(it.getTrvaleSysType()));
|
orderDetailExport.setSupplierName(translateSupplierName(it.getTrvaleSysType()));
|
||||||
User byUserEmployeeNo = null;
|
User byUserEmployeeNo = null;
|
||||||
if (it.getUserCode() != null) {
|
if (it.getUserCode() != null && !it.getUserCode().isEmpty()) {
|
||||||
byUserEmployeeNo = userRepository.findByUserEmployeeNo(it.getUserCode());
|
byUserEmployeeNo = userRepository.findByUserEmployeeNo(it.getUserCode());
|
||||||
} else if (it.getBookingUserCode() != null) {
|
} else if (it.getBookingUserCode() != null && !it.getBookingUserCode().isEmpty()) {
|
||||||
byUserEmployeeNo = userRepository.findByUserEmployeeNo(it.getBookingUserCode());
|
byUserEmployeeNo = userRepository.findByUserEmployeeNo(it.getBookingUserCode());
|
||||||
}
|
}
|
||||||
if (byUserEmployeeNo != null) {
|
if (byUserEmployeeNo != null) {
|
||||||
|
@ -191,6 +191,7 @@ public class OrderDetailExportFactory {
|
||||||
return "未知";
|
return "未知";
|
||||||
}
|
}
|
||||||
return switch (orderStatus) {
|
return switch (orderStatus) {
|
||||||
|
case "0" -> "已取消";
|
||||||
case "1" -> "预定成功";
|
case "1" -> "预定成功";
|
||||||
case "2" -> "改签成功";
|
case "2" -> "改签成功";
|
||||||
case "3" -> "退费成功";
|
case "3" -> "退费成功";
|
||||||
|
|
|
@ -9,7 +9,7 @@ public class SystemUtil {
|
||||||
case BELONG_SYS_TYPE_FSSC -> BELONG_SYS_CODE_FSSC;
|
case BELONG_SYS_TYPE_FSSC -> BELONG_SYS_CODE_FSSC;
|
||||||
case BELONG_SYS_TYPE_H3BPM -> BELONG_SYS_CODE_H3BPM;
|
case BELONG_SYS_TYPE_H3BPM -> BELONG_SYS_CODE_H3BPM;
|
||||||
case BELONG_SYS_TYPE_XNFSSC -> BELONG_SYS_CODE_XNFSSC;
|
case BELONG_SYS_TYPE_XNFSSC -> BELONG_SYS_CODE_XNFSSC;
|
||||||
case BELONG_SYS_TYPE_ANFSSC -> BELONG_SYS_CODE_XNFSSC;
|
case BELONG_SYS_TYPE_ANFSSC -> BELONG_SYS_CODE_ANFSSC;
|
||||||
default -> BELONG_SYS_TYPE_NOT;
|
default -> BELONG_SYS_TYPE_NOT;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
package com.chint.interfaces.rest.ctrip;
|
package com.chint.interfaces.rest.ctrip;
|
||||||
|
|
||||||
|
import com.chint.application.commands.UserLoginCommand;
|
||||||
import com.chint.domain.aggregates.user.User;
|
import com.chint.domain.aggregates.user.User;
|
||||||
import com.chint.domain.repository.UserNameRepository;
|
import com.chint.domain.repository.UserNameRepository;
|
||||||
import com.chint.infrastructure.constant.CTripConstant;
|
import com.chint.infrastructure.constant.CTripConstant;
|
||||||
|
import com.chint.infrastructure.echo_framework.annotation.ListenTo;
|
||||||
import com.chint.infrastructure.util.BaseContext;
|
import com.chint.infrastructure.util.BaseContext;
|
||||||
import com.chint.interfaces.rest.base.PostRequest;
|
import com.chint.interfaces.rest.base.PostRequest;
|
||||||
import com.chint.interfaces.rest.ctrip.dto.AuthenticationResponseList;
|
import com.chint.interfaces.rest.ctrip.dto.AuthenticationResponseList;
|
||||||
|
@ -10,15 +12,19 @@ import com.chint.interfaces.rest.ctrip.dto.user.AuthenticationEntity;
|
||||||
import com.chint.interfaces.rest.ctrip.dto.user.AuthenticationInfo;
|
import com.chint.interfaces.rest.ctrip.dto.user.AuthenticationInfo;
|
||||||
import com.chint.interfaces.rest.ctrip.dto.user.AuthenticationListRequest;
|
import com.chint.interfaces.rest.ctrip.dto.user.AuthenticationListRequest;
|
||||||
import com.chint.interfaces.rest.user.UserHttpRequest;
|
import com.chint.interfaces.rest.user.UserHttpRequest;
|
||||||
|
import com.chint.interfaces.rest.user.UserSync;
|
||||||
import jakarta.annotation.PostConstruct;
|
import jakarta.annotation.PostConstruct;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
@Service
|
@Service
|
||||||
public class CTripUserSaveRequest {
|
public class CTripUserSaveRequest implements UserSync {
|
||||||
@Autowired
|
@Autowired
|
||||||
private PostRequest postRequest;
|
private PostRequest postRequest;
|
||||||
|
|
||||||
|
@ -103,4 +109,17 @@ public class CTripUserSaveRequest {
|
||||||
authenticationEntity.setSubAccountName(subAccountName);
|
authenticationEntity.setSubAccountName(subAccountName);
|
||||||
return authenticationEntity;
|
return authenticationEntity;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ListenTo(command = "UserLoginCommand",order = 1)
|
||||||
|
@Override
|
||||||
|
public User syncUserInfoToSupplier(UserLoginCommand command) {
|
||||||
|
User user = command.getUser();
|
||||||
|
// 如果超过一天,执行同步代码
|
||||||
|
if (user.checkSyncTime()) {
|
||||||
|
CompletableFuture.runAsync(() -> saveUserToCTrip(user));
|
||||||
|
} else {
|
||||||
|
log.info("未超过一天,不执行携程同步");
|
||||||
|
}
|
||||||
|
return user;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,23 +1,28 @@
|
||||||
package com.chint.interfaces.rest.ly;
|
package com.chint.interfaces.rest.ly;
|
||||||
|
|
||||||
|
import com.chint.application.commands.UserLoginCommand;
|
||||||
import com.chint.domain.aggregates.user.User;
|
import com.chint.domain.aggregates.user.User;
|
||||||
import com.chint.domain.repository.UserNameRepository;
|
import com.chint.domain.repository.UserNameRepository;
|
||||||
|
import com.chint.infrastructure.echo_framework.annotation.ListenTo;
|
||||||
import com.chint.infrastructure.util.BaseContext;
|
import com.chint.infrastructure.util.BaseContext;
|
||||||
import com.chint.interfaces.rest.ly.dto.user.EmployeeEntity;
|
import com.chint.interfaces.rest.ly.dto.user.EmployeeEntity;
|
||||||
import com.chint.interfaces.rest.ly.dto.user.EmployeeRequest;
|
import com.chint.interfaces.rest.ly.dto.user.EmployeeRequest;
|
||||||
import com.chint.interfaces.rest.ly.dto.user.UserResponse;
|
import com.chint.interfaces.rest.ly.dto.user.UserResponse;
|
||||||
import com.chint.interfaces.rest.user.UserHttpRequest;
|
import com.chint.interfaces.rest.user.UserHttpRequest;
|
||||||
|
import com.chint.interfaces.rest.user.UserSync;
|
||||||
import jakarta.annotation.PostConstruct;
|
import jakarta.annotation.PostConstruct;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
import static com.chint.infrastructure.constant.LYConstant.L_Y_USER_PATH;
|
import static com.chint.infrastructure.constant.LYConstant.L_Y_USER_PATH;
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@Service
|
@Service
|
||||||
public class LYUserRequest {
|
public class LYUserRequest implements UserSync {
|
||||||
|
|
||||||
|
|
||||||
@Value("${ly.baseUrl}")
|
@Value("${ly.baseUrl}")
|
||||||
|
@ -95,4 +100,17 @@ public class LYUserRequest {
|
||||||
employeeEntity.setPositionLevelName(standardLevel);
|
employeeEntity.setPositionLevelName(standardLevel);
|
||||||
return employeeEntity;
|
return employeeEntity;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ListenTo(command = "UserLoginCommand",order = 0)
|
||||||
|
@Override
|
||||||
|
public User syncUserInfoToSupplier(UserLoginCommand command) {
|
||||||
|
User user = command.getUser();
|
||||||
|
// 如果超过一天,执行同步代码
|
||||||
|
if (user.checkSyncTime()) {
|
||||||
|
CompletableFuture.runAsync(() -> saveCurrentUser(user));
|
||||||
|
} else {
|
||||||
|
log.info("未超过一天,不执行同程同步");
|
||||||
|
}
|
||||||
|
return user;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -202,7 +202,6 @@ public class PushUser {
|
||||||
if (list == null) {
|
if (list == null) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return list.isEmpty();
|
return list.isEmpty();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,10 @@
|
||||||
|
package com.chint.interfaces.rest.user;
|
||||||
|
|
||||||
|
import com.chint.application.commands.UserLoginCommand;
|
||||||
|
import com.chint.domain.aggregates.user.User;
|
||||||
|
|
||||||
|
import java.lang.reflect.Modifier;
|
||||||
|
|
||||||
|
public interface UserSync {
|
||||||
|
User syncUserInfoToSupplier(UserLoginCommand command);
|
||||||
|
}
|
|
@ -8,7 +8,7 @@ spring:
|
||||||
password: ${chint.datasource.password}
|
password: ${chint.datasource.password}
|
||||||
hikari:
|
hikari:
|
||||||
minimum-idle: 20
|
minimum-idle: 20
|
||||||
maximum-pool-size: 50 # 连接池最大连接数
|
maximum-pool-size: 60 # 连接池最大连接数
|
||||||
idle-timeout: 300000 # 空闲连接超时时间(毫秒)
|
idle-timeout: 300000 # 空闲连接超时时间(毫秒)
|
||||||
max-lifetime: 1800000 # 连接的最长生命周期(毫秒)
|
max-lifetime: 1800000 # 连接的最长生命周期(毫秒)
|
||||||
connection-timeout: 60000 # 连接超时时间(毫秒)
|
connection-timeout: 60000 # 连接超时时间(毫秒)
|
||||||
|
|
|
@ -286,7 +286,7 @@ class RouteApplicationTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void loginSignProd() {
|
void loginSignProd() {
|
||||||
String sfno = "220607056";
|
String sfno = "240305077";
|
||||||
String syscode = "FSSC";
|
String syscode = "FSSC";
|
||||||
String billcode = "CLSQ240225000099";
|
String billcode = "CLSQ240225000099";
|
||||||
String companycode = "正泰集团股份有限公司";
|
String companycode = "正泰集团股份有限公司";
|
||||||
|
@ -1294,4 +1294,6 @@ class RouteApplicationTests {
|
||||||
}
|
}
|
||||||
System.out.println(rankName);
|
System.out.println(rankName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue