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

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 String routeOrderNo;
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")
private CTripCarRecordBase cTripCarRecordBase;
@MappedCollection(idColumn = "c_trip_car_record_id")

View File

@ -21,6 +21,11 @@ public class CTripFlightRecord implements Serializable {
public LocalDateTime createTime;
private String routeOrderNo;
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")
private CTripFlightRecordBase cTripFlightRecordBase;
@MappedCollection(idColumn = "c_trip_flight_record_id")

View File

@ -20,6 +20,11 @@ public class CTripHotelRecord implements Serializable {
private String recordId;
private LocalDateTime createTime;
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")
private CTripHotelRecordBase cTripHotelRecordBase;
@MappedCollection(idColumn = "c_trip_hotel_record_id")

View File

@ -20,6 +20,11 @@ public class CTripTrainRecord implements Serializable {
private String recordId;
private LocalDateTime createTime;
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")
private CTripTrainRecordBase cTripTrainRecordBase;
@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);
} else {
//如果已经存在的话 那么这些基础字段就不用重新构建了
return orderDetail.getFlightOrderDetail();
flightOrderDetail = orderDetail.getFlightOrderDetail();
}
if(orderDetail.getOrderEventList() != null){
//如果订单存在直接配置该订单的超标信息和原因
@ -139,7 +139,7 @@ public class OrderDetailFactoryImpl implements OrderDetailFactory {
trainOrderDetail = BeanUtil.copyProperties(buildWithRouteOrder(routeOrder), TrainOrderDetail.class);
} else {
//如果已经存在的话 那么这些基础字段就不用重新构建了
return order.getTrainOrderDetail();
trainOrderDetail = order.getTrainOrderDetail();
}
if(order.getOrderEventList() != null){
//如果订单存在直接配置该订单的超标信息和原因
@ -174,7 +174,7 @@ public class OrderDetailFactoryImpl implements OrderDetailFactory {
hotelOrderDetail = BeanUtil.copyProperties(buildWithRouteOrder(routeOrder), HotelOrderDetail.class);
} else {
//如果已经存在的话 那么这些基础字段就不用重新构建了
return orderDetail.getHotelOrderDetail();
hotelOrderDetail = orderDetail.getHotelOrderDetail();
}
//如果订单存在直接配置该订单的超标信息和原因
@ -207,7 +207,7 @@ public class OrderDetailFactoryImpl implements OrderDetailFactory {
carOrderDetail = BeanUtil.copyProperties(buildWithRouteOrder(routeOrder), CarOrderDetail.class);
} 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.UserRepository;
import com.chint.domain.service.OrderDetailDomainService;
import com.chint.domain.service.RouteRequestDomainService;
import com.chint.infrastructure.repository.jdbc.JdbcCtripHotelOrderDetailRepository;
import com.chint.infrastructure.util.DateTimeUtil;
import com.chint.infrastructure.util.OrderNo;
@ -46,6 +47,9 @@ public class CTripOrderRecordExtensionFactory implements OrderRecordExtensionFac
@Autowired
private UserHttpRequest userHttpRequest;
@Autowired
private RouteRequestDomainService routeRequestDomainService;;
@Autowired
private UserCustomCodeRepository userCustomCodeRepository;
@ -70,20 +74,14 @@ public class CTripOrderRecordExtensionFactory implements OrderRecordExtensionFac
return res;
}
private OrderRecordBasic buildWithRecord(CTripCarRecord cTripCarRecord) {
OrderRecordBasic orderRecordBasic = new OrderRecordBasic();
CTripCarPassengerInfo cTripCarPassengerInfo = cTripCarRecord.getCTripCarPassengerInfo();
String employeeID = cTripCarPassengerInfo.getEmployeeID();
private OrderRecordBasic buildWithRecord(CTripCarRecord record) {
CTripCarPassengerInfo cTripCarPassengerInfo = record.getCTripCarPassengerInfo();
//如果employeeID为空随机生成一个id给该用户名
if (employeeID == null || employeeID.isBlank() || employeeID.isEmpty()) {
employeeID = getCustomCode(cTripCarPassengerInfo.getPassengerName());
}
orderRecordBasic.loadBookingInfo(employeeID,
cTripCarPassengerInfo.getPassengerName(),
"",
cTripCarPassengerInfo.getPassengerName(),
employeeID);
OrderRecordBasic orderRecordBasic = loadBookingInfoAndUserInfo(record.getBookingUserCode(),
record.getBookingUserName(),
record.getBookingUserPhone(),
record.getUserCode(),
record.getUserName());
orderRecordBasic.setTrvaleSysType(TRAVAL_SYS_TYPE_CTRIP);
orderRecordBasic.setAccountCompanyId(cTripCarPassengerInfo.getCostCenter1());
@ -98,7 +96,7 @@ public class CTripOrderRecordExtensionFactory implements OrderRecordExtensionFac
public OrderCarRecord createCarOrderRecord(Object orderCarRecordData) {
CTripCarRecord cTripCarRecord = (CTripCarRecord) orderCarRecordData;
String routeOrderNo = cTripCarRecord.getRouteOrderNo();
Optional<RouteOrder> byOrderNo = Optional.ofNullable(routeRepository.findByOrderNo(routeOrderNo));
Optional<RouteOrder> byOrderNo = Optional.ofNullable(routeRequestDomainService.getRouteOrder(routeOrderNo));
OrderCarRecord orderCarRecord = buildWithRecord(cTripCarRecord)
.carRecord();
CTripCarRecordBase cTripCarRecordBase = cTripCarRecord.getCTripCarRecordBase();
@ -275,20 +273,14 @@ public class CTripOrderRecordExtensionFactory implements OrderRecordExtensionFac
return null;
}
private OrderRecordBasic buildWithRecord(CTripFlightRecord cTripFlightRecord) {
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());
}
private OrderRecordBasic buildWithRecord(CTripFlightRecord record) {
orderRecordBasic.loadBookingInfo(employeeID,
cTripFlightBaseInfo.getName(),
"",
cTripFlightBaseInfo.getName(),
employeeID);
CTripFlightBaseInfo cTripFlightBaseInfo = record.getCTripFlightBaseInfo();
OrderRecordBasic orderRecordBasic = loadBookingInfoAndUserInfo(record.getBookingUserCode(),
record.getBookingUserName(),
record.getBookingUserPhone(),
record.getUserCode(),
record.getUserName());
orderRecordBasic.setTrvaleSysType(TRAVAL_SYS_TYPE_CTRIP);
orderRecordBasic.setAccountCompanyId(cTripFlightBaseInfo.getCostCenter());
@ -305,7 +297,7 @@ public class CTripOrderRecordExtensionFactory implements OrderRecordExtensionFac
CTripFlightBaseInfo cTripFlightBaseInfo = cTripFlightRecord.getCTripFlightBaseInfo();
CTripFlightTripInfo cTripFlightTripInfo = cTripFlightRecord.getCTripFlightTripInfo();
String routeOrderNo = cTripFlightRecord.getRouteOrderNo();
Optional<RouteOrder> byOrderNo = Optional.ofNullable(routeRepository.findByOrderNo(routeOrderNo));
Optional<RouteOrder> byOrderNo = Optional.ofNullable(routeRequestDomainService.getRouteOrder(routeOrderNo));
OrderFlightRecord orderFlightRecord = buildWithRecord(cTripFlightRecord)
.flightRecord();
@ -498,21 +490,13 @@ public class CTripOrderRecordExtensionFactory implements OrderRecordExtensionFac
}
private OrderRecordBasic buildWithRecord(CTripHotelRecord cTripHotelRecord) {
OrderRecordBasic orderRecordBasic = new OrderRecordBasic();
CTripHotelOrderDetail cTripHotelOrderDetail = cTripHotelRecord.getCTripHotelOrderDetail();
String employeeID = cTripHotelOrderDetail.getEmployeeID();
//如果employeeID为空随机生成一个id给该用户名
if (employeeID == null || employeeID.isBlank() || employeeID.isEmpty()) {
employeeID = getCustomCode(cTripHotelOrderDetail.getEmployeeName());
}
orderRecordBasic.loadBookingInfo(employeeID,
cTripHotelOrderDetail.getEmployeeName(),
"",
cTripHotelOrderDetail.getEmployeeName(),
employeeID);
private OrderRecordBasic buildWithRecord(CTripHotelRecord record) {
CTripHotelOrderDetail cTripHotelOrderDetail = record.getCTripHotelOrderDetail();
OrderRecordBasic orderRecordBasic = loadBookingInfoAndUserInfo(record.getBookingUserCode(),
record.getBookingUserName(),
record.getBookingUserPhone(),
record.getUserCode(),
record.getUserName());
orderRecordBasic.setTrvaleSysType(TRAVAL_SYS_TYPE_CTRIP);
orderRecordBasic.setAccountCompanyId(cTripHotelOrderDetail.getCostCenter());
orderRecordBasic.setAccountCompanyName(cTripHotelOrderDetail.getCostCenter2());
@ -527,7 +511,7 @@ public class CTripOrderRecordExtensionFactory implements OrderRecordExtensionFac
CTripHotelRecord cTripHotelRecord = (CTripHotelRecord) orderHotelRecordData;
CTripHotelOrderDetail cTripHotelOrderDetail = cTripHotelRecord.getCTripHotelOrderDetail();
String routeOrderNo = cTripHotelRecord.getRouteOrderNo();
Optional<RouteOrder> byOrderNo = Optional.ofNullable(routeRepository.findByOrderNo(routeOrderNo));
Optional<RouteOrder> byOrderNo = Optional.ofNullable(routeRequestDomainService.getRouteOrder(routeOrderNo));
OrderHotelRecord orderHotelRecord = buildWithRecord(cTripHotelRecord)
.hotelRecord();
@ -771,4 +755,27 @@ public class CTripOrderRecordExtensionFactory implements OrderRecordExtensionFac
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.user.User;
import com.chint.domain.aggregates.user.UserDepartmentInfo;
import com.chint.domain.repository.RouteRepository;
import com.chint.infrastructure.repository.jdbc.*;
import com.chint.infrastructure.util.BeanCopyUtils;
import com.chint.interfaces.rest.bpm.dto.BPMResponse;
@ -43,6 +44,9 @@ public class LyOrderRecordExtensionFactory implements OrderRecordExtensionFactor
@Autowired
private JdbcRouteRepository jdbcRouteRepository;
@Autowired
private RouteRepository routeRepository;
@Autowired
private OrderRecordFactory orderRecordFactory;
@ -554,7 +558,7 @@ public class LyOrderRecordExtensionFactory implements OrderRecordExtensionFactor
return new OrderRecordBasic();
}
Long routeId = orderDetail.getRouteId();
RouteOrder routeOrder = jdbcRouteRepository.findByRouteId(routeId);
RouteOrder routeOrder = routeRepository.queryById(routeId);
consumerRouteOrder.accept(routeOrder == null ? new RouteOrder() : routeOrder);
if (Objects.isNull(routeOrder)) {
return new OrderRecordBasic();

View File

@ -29,4 +29,7 @@ public interface RouteCacheManage {
Long cacheFakeOrderNoAndSysCodeMapRouteId(String approveOrderNo_fakeOrderNo, 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.stereotype.Component;
import java.util.ArrayList;
import java.util.List;
@Slf4j
@ -90,6 +89,20 @@ public class RouteCacheManageImpl implements RouteCacheManage {
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")
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);
if (routeId == null) {
routeCacheManage.invalidateActualOrderNoAndSysCodeMapRouteId(actualOrderNo, sysCode);
return null;
}
RouteOrder routeOrder = jdbcRouteRepository.findByApproveOrderNo_ActualOrderNoAndApproveOrderNo_SysCode(actualOrderNo, sysCode);
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) {
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.PageResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Sort;
@ -63,9 +64,10 @@ public class RouteRepositoryImpl implements RouteRepository {
}
@Override
public RouteOrder findByOrderNo(String orderNo) {
return jdbcRouteRepository.findByRouteOrderNo(orderNo);
return routeCacheService.getRouteByRouteOrderNo(orderNo);
}
@Override

View File

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

View File

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