完成高德差旅申请单同步和取消功能

This commit is contained in:
lulz1 2024-04-30 16:50:50 +08:00
parent 0c6fefa68f
commit 21e73315f3
13 changed files with 160 additions and 63 deletions

View File

@ -21,6 +21,11 @@ public class CTripCarRecord implements Serializable {
private LocalDateTime createTime; private LocalDateTime createTime;
private String routeOrderNo; private String routeOrderNo;
private String orderDate; private String orderDate;
private String bookingUserName;
private String bookingUserCode;
private String bookingUserPhone;
private String userName;
private String userCode;
@MappedCollection(idColumn = "c_trip_car_record_id") @MappedCollection(idColumn = "c_trip_car_record_id")
private CTripCarRecordBase cTripCarRecordBase; private CTripCarRecordBase cTripCarRecordBase;
@MappedCollection(idColumn = "c_trip_car_record_id") @MappedCollection(idColumn = "c_trip_car_record_id")

View File

@ -21,6 +21,11 @@ public class CTripFlightRecord implements Serializable {
public LocalDateTime createTime; public LocalDateTime createTime;
private String routeOrderNo; private String routeOrderNo;
private String ticketNo; private String ticketNo;
private String bookingUserName;
private String bookingUserCode;
private String bookingUserPhone;
private String userName;
private String userCode;
@MappedCollection(idColumn = "c_trip_flight_record_id") @MappedCollection(idColumn = "c_trip_flight_record_id")
private CTripFlightRecordBase cTripFlightRecordBase; private CTripFlightRecordBase cTripFlightRecordBase;
@MappedCollection(idColumn = "c_trip_flight_record_id") @MappedCollection(idColumn = "c_trip_flight_record_id")

View File

@ -20,6 +20,11 @@ public class CTripHotelRecord implements Serializable {
private String recordId; private String recordId;
private LocalDateTime createTime; private LocalDateTime createTime;
private String routeOrderNo; private String routeOrderNo;
private String bookingUserName;
private String bookingUserCode;
private String bookingUserPhone;
private String userName;
private String userCode;
@MappedCollection(idColumn = "c_trip_hotel_record_id") @MappedCollection(idColumn = "c_trip_hotel_record_id")
private CTripHotelRecordBase cTripHotelRecordBase; private CTripHotelRecordBase cTripHotelRecordBase;
@MappedCollection(idColumn = "c_trip_hotel_record_id") @MappedCollection(idColumn = "c_trip_hotel_record_id")

View File

@ -20,6 +20,11 @@ public class CTripTrainRecord implements Serializable {
private String recordId; private String recordId;
private LocalDateTime createTime; private LocalDateTime createTime;
private String routeOrderNo; private String routeOrderNo;
private String bookingUserName;
private String bookingUserCode;
private String bookingUserPhone;
private String userName;
private String userCode;
@MappedCollection(idColumn = "c_trip_train_record_id") @MappedCollection(idColumn = "c_trip_train_record_id")
private CTripTrainRecordBase cTripTrainRecordBase; private CTripTrainRecordBase cTripTrainRecordBase;
@MappedCollection(idColumn = "c_trip_train_record_id") @MappedCollection(idColumn = "c_trip_train_record_id")

View File

@ -108,7 +108,7 @@ public class OrderDetailFactoryImpl implements OrderDetailFactory {
flightOrderDetail = BeanUtil.copyProperties(buildWithRouteOrder(routeOrder), FlightOrderDetail.class); flightOrderDetail = BeanUtil.copyProperties(buildWithRouteOrder(routeOrder), FlightOrderDetail.class);
} else { } else {
//如果已经存在的话 那么这些基础字段就不用重新构建了 //如果已经存在的话 那么这些基础字段就不用重新构建了
return orderDetail.getFlightOrderDetail(); flightOrderDetail = orderDetail.getFlightOrderDetail();
} }
if(orderDetail.getOrderEventList() != null){ if(orderDetail.getOrderEventList() != null){
//如果订单存在直接配置该订单的超标信息和原因 //如果订单存在直接配置该订单的超标信息和原因
@ -139,7 +139,7 @@ public class OrderDetailFactoryImpl implements OrderDetailFactory {
trainOrderDetail = BeanUtil.copyProperties(buildWithRouteOrder(routeOrder), TrainOrderDetail.class); trainOrderDetail = BeanUtil.copyProperties(buildWithRouteOrder(routeOrder), TrainOrderDetail.class);
} else { } else {
//如果已经存在的话 那么这些基础字段就不用重新构建了 //如果已经存在的话 那么这些基础字段就不用重新构建了
return order.getTrainOrderDetail(); trainOrderDetail = order.getTrainOrderDetail();
} }
if(order.getOrderEventList() != null){ if(order.getOrderEventList() != null){
//如果订单存在直接配置该订单的超标信息和原因 //如果订单存在直接配置该订单的超标信息和原因
@ -174,7 +174,7 @@ public class OrderDetailFactoryImpl implements OrderDetailFactory {
hotelOrderDetail = BeanUtil.copyProperties(buildWithRouteOrder(routeOrder), HotelOrderDetail.class); hotelOrderDetail = BeanUtil.copyProperties(buildWithRouteOrder(routeOrder), HotelOrderDetail.class);
} else { } else {
//如果已经存在的话 那么这些基础字段就不用重新构建了 //如果已经存在的话 那么这些基础字段就不用重新构建了
return orderDetail.getHotelOrderDetail(); hotelOrderDetail = orderDetail.getHotelOrderDetail();
} }
//如果订单存在直接配置该订单的超标信息和原因 //如果订单存在直接配置该订单的超标信息和原因
@ -207,7 +207,7 @@ public class OrderDetailFactoryImpl implements OrderDetailFactory {
carOrderDetail = BeanUtil.copyProperties(buildWithRouteOrder(routeOrder), CarOrderDetail.class); carOrderDetail = BeanUtil.copyProperties(buildWithRouteOrder(routeOrder), CarOrderDetail.class);
} else { } else {
//如果已经存在的话 那么这些基础字段就不用重新构建了 //如果已经存在的话 那么这些基础字段就不用重新构建了
return orderDetail.getCarOrderDetail(); carOrderDetail = orderDetail.getCarOrderDetail();
} }
//如果订单存在直接配置该订单的超标信息和原因 //如果订单存在直接配置该订单的超标信息和原因

View File

@ -13,6 +13,7 @@ import com.chint.domain.repository.RouteRepository;
import com.chint.domain.repository.UserCustomCodeRepository; import com.chint.domain.repository.UserCustomCodeRepository;
import com.chint.domain.repository.UserRepository; import com.chint.domain.repository.UserRepository;
import com.chint.domain.service.OrderDetailDomainService; import com.chint.domain.service.OrderDetailDomainService;
import com.chint.domain.service.RouteRequestDomainService;
import com.chint.infrastructure.repository.jdbc.JdbcCtripHotelOrderDetailRepository; import com.chint.infrastructure.repository.jdbc.JdbcCtripHotelOrderDetailRepository;
import com.chint.infrastructure.util.DateTimeUtil; import com.chint.infrastructure.util.DateTimeUtil;
import com.chint.infrastructure.util.OrderNo; import com.chint.infrastructure.util.OrderNo;
@ -46,6 +47,9 @@ public class CTripOrderRecordExtensionFactory implements OrderRecordExtensionFac
@Autowired @Autowired
private UserHttpRequest userHttpRequest; private UserHttpRequest userHttpRequest;
@Autowired
private RouteRequestDomainService routeRequestDomainService;;
@Autowired @Autowired
private UserCustomCodeRepository userCustomCodeRepository; private UserCustomCodeRepository userCustomCodeRepository;
@ -70,20 +74,14 @@ public class CTripOrderRecordExtensionFactory implements OrderRecordExtensionFac
return res; return res;
} }
private OrderRecordBasic buildWithRecord(CTripCarRecord cTripCarRecord) { private OrderRecordBasic buildWithRecord(CTripCarRecord record) {
OrderRecordBasic orderRecordBasic = new OrderRecordBasic(); CTripCarPassengerInfo cTripCarPassengerInfo = record.getCTripCarPassengerInfo();
CTripCarPassengerInfo cTripCarPassengerInfo = cTripCarRecord.getCTripCarPassengerInfo();
String employeeID = cTripCarPassengerInfo.getEmployeeID();
//如果employeeID为空随机生成一个id给该用户名 OrderRecordBasic orderRecordBasic = loadBookingInfoAndUserInfo(record.getBookingUserCode(),
if (employeeID == null || employeeID.isBlank() || employeeID.isEmpty()) { record.getBookingUserName(),
employeeID = getCustomCode(cTripCarPassengerInfo.getPassengerName()); record.getBookingUserPhone(),
} record.getUserCode(),
orderRecordBasic.loadBookingInfo(employeeID, record.getUserName());
cTripCarPassengerInfo.getPassengerName(),
"",
cTripCarPassengerInfo.getPassengerName(),
employeeID);
orderRecordBasic.setTrvaleSysType(TRAVAL_SYS_TYPE_CTRIP); orderRecordBasic.setTrvaleSysType(TRAVAL_SYS_TYPE_CTRIP);
orderRecordBasic.setAccountCompanyId(cTripCarPassengerInfo.getCostCenter1()); orderRecordBasic.setAccountCompanyId(cTripCarPassengerInfo.getCostCenter1());
@ -98,7 +96,7 @@ public class CTripOrderRecordExtensionFactory implements OrderRecordExtensionFac
public OrderCarRecord createCarOrderRecord(Object orderCarRecordData) { public OrderCarRecord createCarOrderRecord(Object orderCarRecordData) {
CTripCarRecord cTripCarRecord = (CTripCarRecord) orderCarRecordData; CTripCarRecord cTripCarRecord = (CTripCarRecord) orderCarRecordData;
String routeOrderNo = cTripCarRecord.getRouteOrderNo(); String routeOrderNo = cTripCarRecord.getRouteOrderNo();
Optional<RouteOrder> byOrderNo = Optional.ofNullable(routeRepository.findByOrderNo(routeOrderNo)); Optional<RouteOrder> byOrderNo = Optional.ofNullable(routeRequestDomainService.getRouteOrder(routeOrderNo));
OrderCarRecord orderCarRecord = buildWithRecord(cTripCarRecord) OrderCarRecord orderCarRecord = buildWithRecord(cTripCarRecord)
.carRecord(); .carRecord();
CTripCarRecordBase cTripCarRecordBase = cTripCarRecord.getCTripCarRecordBase(); CTripCarRecordBase cTripCarRecordBase = cTripCarRecord.getCTripCarRecordBase();
@ -275,20 +273,14 @@ public class CTripOrderRecordExtensionFactory implements OrderRecordExtensionFac
return null; return null;
} }
private OrderRecordBasic buildWithRecord(CTripFlightRecord cTripFlightRecord) { private OrderRecordBasic buildWithRecord(CTripFlightRecord record) {
OrderRecordBasic orderRecordBasic = new OrderRecordBasic();
CTripFlightBaseInfo cTripFlightBaseInfo = cTripFlightRecord.getCTripFlightBaseInfo();
String employeeID = cTripFlightBaseInfo.getEmployeeID();
//如果employeeID为空随机生成一个id给该用户名
if (employeeID == null || employeeID.isBlank() || employeeID.isEmpty()) {
employeeID = getCustomCode(cTripFlightBaseInfo.getName());
}
orderRecordBasic.loadBookingInfo(employeeID, CTripFlightBaseInfo cTripFlightBaseInfo = record.getCTripFlightBaseInfo();
cTripFlightBaseInfo.getName(), OrderRecordBasic orderRecordBasic = loadBookingInfoAndUserInfo(record.getBookingUserCode(),
"", record.getBookingUserName(),
cTripFlightBaseInfo.getName(), record.getBookingUserPhone(),
employeeID); record.getUserCode(),
record.getUserName());
orderRecordBasic.setTrvaleSysType(TRAVAL_SYS_TYPE_CTRIP); orderRecordBasic.setTrvaleSysType(TRAVAL_SYS_TYPE_CTRIP);
orderRecordBasic.setAccountCompanyId(cTripFlightBaseInfo.getCostCenter()); orderRecordBasic.setAccountCompanyId(cTripFlightBaseInfo.getCostCenter());
@ -305,7 +297,7 @@ public class CTripOrderRecordExtensionFactory implements OrderRecordExtensionFac
CTripFlightBaseInfo cTripFlightBaseInfo = cTripFlightRecord.getCTripFlightBaseInfo(); CTripFlightBaseInfo cTripFlightBaseInfo = cTripFlightRecord.getCTripFlightBaseInfo();
CTripFlightTripInfo cTripFlightTripInfo = cTripFlightRecord.getCTripFlightTripInfo(); CTripFlightTripInfo cTripFlightTripInfo = cTripFlightRecord.getCTripFlightTripInfo();
String routeOrderNo = cTripFlightRecord.getRouteOrderNo(); String routeOrderNo = cTripFlightRecord.getRouteOrderNo();
Optional<RouteOrder> byOrderNo = Optional.ofNullable(routeRepository.findByOrderNo(routeOrderNo)); Optional<RouteOrder> byOrderNo = Optional.ofNullable(routeRequestDomainService.getRouteOrder(routeOrderNo));
OrderFlightRecord orderFlightRecord = buildWithRecord(cTripFlightRecord) OrderFlightRecord orderFlightRecord = buildWithRecord(cTripFlightRecord)
.flightRecord(); .flightRecord();
@ -498,21 +490,13 @@ public class CTripOrderRecordExtensionFactory implements OrderRecordExtensionFac
} }
private OrderRecordBasic buildWithRecord(CTripHotelRecord cTripHotelRecord) { private OrderRecordBasic buildWithRecord(CTripHotelRecord record) {
OrderRecordBasic orderRecordBasic = new OrderRecordBasic(); CTripHotelOrderDetail cTripHotelOrderDetail = record.getCTripHotelOrderDetail();
CTripHotelOrderDetail cTripHotelOrderDetail = cTripHotelRecord.getCTripHotelOrderDetail(); OrderRecordBasic orderRecordBasic = loadBookingInfoAndUserInfo(record.getBookingUserCode(),
record.getBookingUserName(),
String employeeID = cTripHotelOrderDetail.getEmployeeID(); record.getBookingUserPhone(),
//如果employeeID为空随机生成一个id给该用户名 record.getUserCode(),
if (employeeID == null || employeeID.isBlank() || employeeID.isEmpty()) { record.getUserName());
employeeID = getCustomCode(cTripHotelOrderDetail.getEmployeeName());
}
orderRecordBasic.loadBookingInfo(employeeID,
cTripHotelOrderDetail.getEmployeeName(),
"",
cTripHotelOrderDetail.getEmployeeName(),
employeeID);
orderRecordBasic.setTrvaleSysType(TRAVAL_SYS_TYPE_CTRIP); orderRecordBasic.setTrvaleSysType(TRAVAL_SYS_TYPE_CTRIP);
orderRecordBasic.setAccountCompanyId(cTripHotelOrderDetail.getCostCenter()); orderRecordBasic.setAccountCompanyId(cTripHotelOrderDetail.getCostCenter());
orderRecordBasic.setAccountCompanyName(cTripHotelOrderDetail.getCostCenter2()); orderRecordBasic.setAccountCompanyName(cTripHotelOrderDetail.getCostCenter2());
@ -527,7 +511,7 @@ public class CTripOrderRecordExtensionFactory implements OrderRecordExtensionFac
CTripHotelRecord cTripHotelRecord = (CTripHotelRecord) orderHotelRecordData; CTripHotelRecord cTripHotelRecord = (CTripHotelRecord) orderHotelRecordData;
CTripHotelOrderDetail cTripHotelOrderDetail = cTripHotelRecord.getCTripHotelOrderDetail(); CTripHotelOrderDetail cTripHotelOrderDetail = cTripHotelRecord.getCTripHotelOrderDetail();
String routeOrderNo = cTripHotelRecord.getRouteOrderNo(); String routeOrderNo = cTripHotelRecord.getRouteOrderNo();
Optional<RouteOrder> byOrderNo = Optional.ofNullable(routeRepository.findByOrderNo(routeOrderNo)); Optional<RouteOrder> byOrderNo = Optional.ofNullable(routeRequestDomainService.getRouteOrder(routeOrderNo));
OrderHotelRecord orderHotelRecord = buildWithRecord(cTripHotelRecord) OrderHotelRecord orderHotelRecord = buildWithRecord(cTripHotelRecord)
.hotelRecord(); .hotelRecord();
@ -771,4 +755,27 @@ public class CTripOrderRecordExtensionFactory implements OrderRecordExtensionFac
default -> "0"; default -> "0";
}; };
} }
private String checkAndGenerateEmployeeId(String employeeId, String employeeName) {
//如果employeeID为空随机生成一个id给该用户名
if (employeeId == null || employeeId.isBlank() || employeeId.isEmpty()) {
employeeId = getCustomCode(employeeName);
}
return employeeId;
}
private OrderRecordBasic loadBookingInfoAndUserInfo(String bookingUserCode,
String bookingUserName,
String bookingUserPhone,
String userCode,
String userName) {
bookingUserCode = checkAndGenerateEmployeeId(bookingUserCode, bookingUserName);
userCode = checkAndGenerateEmployeeId(userCode, userName);
OrderRecordBasic orderRecordBasic = new OrderRecordBasic();
return orderRecordBasic.loadBookingInfo(bookingUserCode,
bookingUserName,
bookingUserPhone,
userName,
userCode);
}
} }

View File

@ -8,6 +8,7 @@ import com.chint.domain.aggregates.order.order_record.OrderTrainRecord;
import com.chint.domain.aggregates.order.order_record.ly_order_record.*; import com.chint.domain.aggregates.order.order_record.ly_order_record.*;
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.repository.RouteRepository;
import com.chint.infrastructure.repository.jdbc.*; import com.chint.infrastructure.repository.jdbc.*;
import com.chint.infrastructure.util.BeanCopyUtils; import com.chint.infrastructure.util.BeanCopyUtils;
import com.chint.interfaces.rest.bpm.dto.BPMResponse; import com.chint.interfaces.rest.bpm.dto.BPMResponse;
@ -43,6 +44,9 @@ public class LyOrderRecordExtensionFactory implements OrderRecordExtensionFactor
@Autowired @Autowired
private JdbcRouteRepository jdbcRouteRepository; private JdbcRouteRepository jdbcRouteRepository;
@Autowired
private RouteRepository routeRepository;
@Autowired @Autowired
private OrderRecordFactory orderRecordFactory; private OrderRecordFactory orderRecordFactory;
@ -554,7 +558,7 @@ public class LyOrderRecordExtensionFactory implements OrderRecordExtensionFactor
return new OrderRecordBasic(); return new OrderRecordBasic();
} }
Long routeId = orderDetail.getRouteId(); Long routeId = orderDetail.getRouteId();
RouteOrder routeOrder = jdbcRouteRepository.findByRouteId(routeId); RouteOrder routeOrder = routeRepository.queryById(routeId);
consumerRouteOrder.accept(routeOrder == null ? new RouteOrder() : routeOrder); consumerRouteOrder.accept(routeOrder == null ? new RouteOrder() : routeOrder);
if (Objects.isNull(routeOrder)) { if (Objects.isNull(routeOrder)) {
return new OrderRecordBasic(); return new OrderRecordBasic();

View File

@ -29,4 +29,7 @@ public interface RouteCacheManage {
Long cacheFakeOrderNoAndSysCodeMapRouteId(String approveOrderNo_fakeOrderNo, String approveOrderNo_sysCode, RouteOrder routeOrder); Long cacheFakeOrderNoAndSysCodeMapRouteId(String approveOrderNo_fakeOrderNo, String approveOrderNo_sysCode, RouteOrder routeOrder);
Long cacheActualOrderNoAndSysCodeMapRouteId(String approveOrderNo_actualOrderNo, String approveOrderNo_sysCode, RouteOrder routeOrder); Long cacheActualOrderNoAndSysCodeMapRouteId(String approveOrderNo_actualOrderNo, String approveOrderNo_sysCode, RouteOrder routeOrder);
Long cacheRouteOrderNoMapRouteId(String routeOrderNo, RouteOrder routeOrder);
void invalidateRouteOrderNoMapRouteId(String routeOrderNo);
} }

View File

@ -9,7 +9,6 @@ import org.springframework.cache.annotation.Cacheable;
import org.springframework.data.redis.core.RedisTemplate; import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.List; import java.util.List;
@Slf4j @Slf4j
@ -20,7 +19,7 @@ public class RouteCacheManageImpl implements RouteCacheManage {
private JdbcRouteRepository jdbcRouteRepository; private JdbcRouteRepository jdbcRouteRepository;
@Autowired @Autowired
private RedisTemplate<String,RouteOrder> redisTemplate; private RedisTemplate<String, RouteOrder> redisTemplate;
@Override @Override
@Cacheable(value = "userRouteLists", key = "#employeeNo") @Cacheable(value = "userRouteLists", key = "#employeeNo")
@ -90,6 +89,20 @@ public class RouteCacheManageImpl implements RouteCacheManage {
return routeOrder.getRouteId(); return routeOrder.getRouteId();
} }
@Cacheable(value = "RouteOrderNo", key = "#routeOrderNo")
public Long cacheRouteOrderNoMapRouteId(String routeOrderNo, RouteOrder routeOrder) {
if (routeOrder == null) {
return null;
}
return routeOrder.getRouteId();
}
@CacheEvict(value = "RouteOrderNo", key = "#routeOrderNo")
@Override
public void invalidateRouteOrderNoMapRouteId(String routeOrderNo) {
}
@CacheEvict(value = "FakeOrderNoAndSysCodeMapRouteId", key = "#approveOrderNo_fakeOrderNo+'-'+ #approveOrderNo_sysCode") @CacheEvict(value = "FakeOrderNoAndSysCodeMapRouteId", key = "#approveOrderNo_fakeOrderNo+'-'+ #approveOrderNo_sysCode")
public void invalidateFakeOrderNoAndSysCodeMapRouteId(String approveOrderNo_fakeOrderNo, String approveOrderNo_sysCode) { public void invalidateFakeOrderNoAndSysCodeMapRouteId(String approveOrderNo_fakeOrderNo, String approveOrderNo_sysCode) {

View File

@ -117,7 +117,6 @@ public class RouteCacheService {
Long routeId = routeCacheManage.cacheActualOrderNoAndSysCodeMapRouteId(actualOrderNo, sysCode, null); Long routeId = routeCacheManage.cacheActualOrderNoAndSysCodeMapRouteId(actualOrderNo, sysCode, null);
if (routeId == null) { if (routeId == null) {
routeCacheManage.invalidateActualOrderNoAndSysCodeMapRouteId(actualOrderNo, sysCode); routeCacheManage.invalidateActualOrderNoAndSysCodeMapRouteId(actualOrderNo, sysCode);
return null;
} }
RouteOrder routeOrder = jdbcRouteRepository.findByApproveOrderNo_ActualOrderNoAndApproveOrderNo_SysCode(actualOrderNo, sysCode); RouteOrder routeOrder = jdbcRouteRepository.findByApproveOrderNo_ActualOrderNoAndApproveOrderNo_SysCode(actualOrderNo, sysCode);
if (routeOrder == null) { if (routeOrder == null) {
@ -130,6 +129,20 @@ public class RouteCacheService {
} }
} }
public RouteOrder getRouteByRouteOrderNo(String routeOrderNo){
Long routeId = routeCacheManage.cacheRouteOrderNoMapRouteId(routeOrderNo, null);
if (routeId == null) {
routeCacheManage.invalidateRouteOrderNoMapRouteId(routeOrderNo);
} else {
return getFromCacheOrSaveToCache(routeId);
}
RouteOrder routeOrder = jdbcRouteRepository.findByRouteOrderNo(routeOrderNo);
if(routeOrder != null) {
routeCacheManage.cacheRouteOrderNoMapRouteId(routeOrderNo, routeOrder.reloadStatus());
}
return routeOrder;
}
public void invalidateRouteCache(Long routeId) { public void invalidateRouteCache(Long routeId) {
routeCacheManage.invalidateRouteCache(routeId); routeCacheManage.invalidateRouteCache(routeId);

View File

@ -8,6 +8,7 @@ import com.chint.infrastructure.repository.jdbc.JdbcRouteRepository;
import com.chint.infrastructure.util.BaseContext; import com.chint.infrastructure.util.BaseContext;
import com.chint.infrastructure.util.PageResult; import com.chint.infrastructure.util.PageResult;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.data.domain.Page; import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Sort; import org.springframework.data.domain.Sort;
@ -63,9 +64,10 @@ public class RouteRepositoryImpl implements RouteRepository {
} }
@Override @Override
public RouteOrder findByOrderNo(String orderNo) { public RouteOrder findByOrderNo(String orderNo) {
return jdbcRouteRepository.findByRouteOrderNo(orderNo); return routeCacheService.getRouteByRouteOrderNo(orderNo);
} }
@Override @Override

View File

@ -4,6 +4,7 @@ import com.chint.domain.aggregates.order.RouteRequest;
import com.chint.domain.repository.RouteRequestRepository; import com.chint.domain.repository.RouteRequestRepository;
import com.chint.infrastructure.repository.jdbc.JdbcRouteRequestRepository; import com.chint.infrastructure.repository.jdbc.JdbcRouteRequestRepository;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
@Repository @Repository
@ -12,6 +13,7 @@ public class RouteRequestRepositoryImpl implements RouteRequestRepository {
@Autowired @Autowired
private JdbcRouteRequestRepository jdbcRouteRequestRepository; private JdbcRouteRequestRepository jdbcRouteRequestRepository;
@Cacheable(value = "RouteRequestNo" , key = "#routeRequestNo")
@Override @Override
public RouteRequest findByRouteRequestNo(String routeRequestNo) { public RouteRequest findByRouteRequestNo(String routeRequestNo) {
return jdbcRouteRequestRepository.findByRouteRequestNo(routeRequestNo); return jdbcRouteRequestRepository.findByRouteRequestNo(routeRequestNo);

View File

@ -82,9 +82,18 @@ public class CTripOrderRecordAutoSave {
OrderFlightResponse.FlightOrderBaseInfo orderBaseInfo = it.getOrderBaseInfo(); OrderFlightResponse.FlightOrderBaseInfo orderBaseInfo = it.getOrderBaseInfo();
record.setRouteOrderNo(orderBaseInfo.getJourneyID()); record.setRouteOrderNo(orderBaseInfo.getJourneyID());
OrderFlightResponse.FlightOrderPassenger orderPassengerInfo = it.getOrderPassengerInfo(); OrderFlightResponse.FlightOrderPassenger orderPassengerInfo = it.getOrderPassengerInfo();
if (orderPassengerInfo != null) { if (orderPassengerInfo != null) {
record.setTicketNo(orderPassengerInfo.getTicketNo()); record.setTicketNo(orderPassengerInfo.getTicketNo());
record.setUserCode(orderPassengerInfo.getEmployeeID());
record.setUserName(orderPassengerInfo.getPassengerName());
} else {
record.setUserCode(orderBaseInfo.getEmployeeID());
record.setUserName(orderBaseInfo.getName());
} }
record.setBookingUserCode(orderBaseInfo.getPreEmployeeID());
record.setBookingUserName(orderBaseInfo.getName());
record.setBookingUserPhone("");
return record; return record;
}).toList(); }).toList();
cTripOrderDetailRepository.saveAllCTripFlightRecord(cTripFlightRecords); cTripOrderDetailRepository.saveAllCTripFlightRecord(cTripFlightRecords);
@ -106,20 +115,30 @@ public class CTripOrderRecordAutoSave {
OrderHotelResponse.SettlementDetail settlementDetail = it.getSettlementDetail(); OrderHotelResponse.SettlementDetail settlementDetail = it.getSettlementDetail();
CTripHotelRecord record = cTripOrderDetailRepository.findHotelRecordByRecordId( CTripHotelRecord record = cTripOrderDetailRepository.findHotelRecordByRecordId(
String.valueOf(settlementDetail.getRecordId())); String.valueOf(settlementDetail.getRecordId()));
OrderHotelResponse.SettlementOrderDetail settlementOrderDetail = it.getOrderDetail();
if (record == null) { if (record == null) {
record = CTripHotelRecord.of(CTripHotelRecordBase.changeInfo(settlementDetail), record = CTripHotelRecord.of(CTripHotelRecordBase.changeInfo(settlementDetail),
CTripHotelInfo.of(it.getHotelDetail()), CTripHotelInfo.of(it.getHotelDetail()),
CTripHotelOrderDetail.of(it.getOrderDetail())); CTripHotelOrderDetail.of(settlementOrderDetail));
} else { } else {
Long originId = record.getId(); Long originId = record.getId();
record = CTripHotelRecord.of(CTripHotelRecordBase.changeInfo(settlementDetail), record = CTripHotelRecord.of(CTripHotelRecordBase.changeInfo(settlementDetail),
CTripHotelInfo.of(it.getHotelDetail()), CTripHotelInfo.of(it.getHotelDetail()),
CTripHotelOrderDetail.of(it.getOrderDetail())); CTripHotelOrderDetail.of(settlementOrderDetail));
record.setId(originId); record.setId(originId);
} }
//补充额外的字段 //补充额外的字段
OrderHotelResponse.SettlementOrderDetail orderDetail = it.getOrderDetail();
record.setRouteOrderNo(orderDetail.getHotelRelatedJourneyNo()); record.setRouteOrderNo(settlementOrderDetail.getHotelRelatedJourneyNo());
List<OrderHotelResponse.SettlementClientDetail> clientDetailList = settlementOrderDetail.getClientDetailList();
if (clientDetailList != null && !clientDetailList.isEmpty()) {
OrderHotelResponse.SettlementClientDetail settlementClientDetail = clientDetailList.get(0);
record.setUserCode(settlementClientDetail.getEmployeeID());
record.setUserName(settlementOrderDetail.getClientName());
}
record.setBookingUserCode(settlementOrderDetail.getEmployeeID());
record.setBookingUserName(settlementOrderDetail.getEmployeeName());
record.setBookingUserPhone("");
return record; return record;
}).toList(); }).toList();
Map<Boolean, List<CTripHotelRecord>> collect = list.stream() Map<Boolean, List<CTripHotelRecord>> collect = list.stream()
@ -170,29 +189,43 @@ public class CTripOrderRecordAutoSave {
List<CTripCarRecord> list = settlementList.stream() List<CTripCarRecord> list = settlementList.stream()
.flatMap(it -> it.getCarSettlementDetailList().stream()) .flatMap(it -> it.getCarSettlementDetailList().stream())
.map(it -> { .map(it -> {
OrderCarResponse.CarOrderDetail orderDetail = it.getOrderDetail();
OrderCarResponse.CarOrderSettlementBaseInfo settlementBaseInfo = it.getSettlementBaseInfo(); OrderCarResponse.CarOrderSettlementBaseInfo settlementBaseInfo = it.getSettlementBaseInfo();
CTripCarRecord record = cTripOrderDetailRepository.findCarRecordByRecordId( CTripCarRecord record = cTripOrderDetailRepository.findCarRecordByRecordId(
String.valueOf(settlementBaseInfo.getRecordId())); String.valueOf(settlementBaseInfo.getRecordId()));
List<OrderCarResponse.CarOrderPassengerInfo> passengerInfoList = orderDetail.getPassengerInfoList();
OrderCarResponse.CarOrderPassengerInfo carOrderPassengerInfo = passengerInfoList.get(0);
if (record == null) { if (record == null) {
record = CTripCarRecord.of( record = CTripCarRecord.of(
CTripCarRecordBase.changeInfo(settlementBaseInfo), CTripCarRecordBase.changeInfo(settlementBaseInfo),
CTripCarQuickInfo.of(it.getOrderDetail().getQuickProductInfo()), CTripCarQuickInfo.of(orderDetail.getQuickProductInfo()),
CTripCarPassengerInfo.of(it.getOrderDetail().getPassengerInfoList().get(0)) CTripCarPassengerInfo.of(carOrderPassengerInfo)
); );
} else { } else {
Long originId = record.getId(); Long originId = record.getId();
record = CTripCarRecord.of( record = CTripCarRecord.of(
CTripCarRecordBase.changeInfo(settlementBaseInfo), CTripCarRecordBase.changeInfo(settlementBaseInfo),
CTripCarQuickInfo.of(it.getOrderDetail().getQuickProductInfo()), CTripCarQuickInfo.of(orderDetail.getQuickProductInfo()),
CTripCarPassengerInfo.of(it.getOrderDetail().getPassengerInfoList().get(0)) CTripCarPassengerInfo.of(carOrderPassengerInfo)
); );
record.setId(originId); record.setId(originId);
} }
//补充额外的字段 //补充额外的字段
OrderCarResponse.CarOrderCorpInfo corpInfo = it.getOrderDetail().getCorpInfo(); OrderCarResponse.CarOrderCorpInfo corpInfo = orderDetail.getCorpInfo();
record.setRouteOrderNo(corpInfo.getJouneryId()); record.setRouteOrderNo(corpInfo.getJouneryId());
String orderDate = it.getOrderDetail().getOrderBaseInfo().getOrderDate(); OrderCarResponse.CarOrderBaseInfo orderBaseInfo = orderDetail.getOrderBaseInfo();
String orderDate = orderBaseInfo.getOrderDate();
record.setOrderDate(DateTimeUtil.timeToStrCommon(DateTimeUtil.strToTime(orderDate))); record.setOrderDate(DateTimeUtil.timeToStrCommon(DateTimeUtil.strToTime(orderDate)));
record.setUserCode(carOrderPassengerInfo.getEmployeeID());
record.setUserName(carOrderPassengerInfo.getPassengerName());
record.setBookingUserCode(orderBaseInfo.getPreEmployeeID());
record.setBookingUserName(orderBaseInfo.getUserName());
record.setBookingUserPhone(orderBaseInfo.getContactMobile());
return record; return record;
}).toList(); }).toList();
cTripOrderDetailRepository.saveAllCTripCarRecord(list); cTripOrderDetailRepository.saveAllCTripCarRecord(list);