fix:修复高压结算查询数据不完全的问题

This commit is contained in:
lulz1 2024-07-16 10:41:17 +08:00
parent 6a76da4f15
commit 4f64d16ca4
18 changed files with 513 additions and 109 deletions

View File

@ -0,0 +1,169 @@
package com.chint.domain.aggregates.approval.platform;
import com.chint.domain.aggregates.order.*;
import com.chint.domain.aggregates.user.User;
import com.chint.domain.repository.LegRepository;
import com.chint.domain.repository.LocationRepository;
import com.chint.domain.repository.UserRepository;
import com.chint.domain.service.supplier.SupplierConstantUtil;
import com.chint.infrastructure.constant.BPMConstant;
import com.chint.infrastructure.util.DaysUtil;
import com.chint.infrastructure.util.Json;
import com.chint.interfaces.rest.base.PostRequest;
import com.chint.interfaces.rest.bpm.dot.BPMBaseResponse;
import com.chint.interfaces.rest.bpm.dto.BPMBaseRequest;
import com.chint.interfaces.rest.bpm.dto.BPMResponse;
import com.chint.interfaces.rest.bpm.dto.ExceedStandardDto;
import com.chint.interfaces.rest.ctrip.CTripEstimateRequest;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.time.LocalDate;
import java.util.Optional;
import java.util.function.Function;
import java.util.function.Supplier;
import static com.chint.infrastructure.constant.LegConstant.LEG_TYPE_HOTEL;
import static com.chint.infrastructure.constant.UtilConstant.KEEP_TWO_DECIMAL_ZERO;
@Slf4j
@Component
public class ApprovalH3BPMMethod {
@Autowired
private PostRequest postRequest;
@Autowired
private LocationRepository locationRepository;
@Autowired
private CTripEstimateRequest cTripEstimateRequest;
@Autowired
private UserRepository userRepository;
@Autowired
private LegRepository legRepository;
/**
* H3BPM
*/
public BPMResponse H3BPMSubmitWorkflow(String url, String workflowCode, Object entityObject, String employeeNo) {
BPMBaseRequest bpmRequest = new BPMBaseRequest();
String entityParamValues = Json.gson().toJson(entityObject);
bpmRequest.setWorkflowCode(workflowCode)
.setUserCode(employeeNo)//sf号
.setFinishStart(true)//true会自动流转到下一审批点false:停在手工填写节点
.setEntityParamValues(entityParamValues);
BPMBaseResponse bpmBaseResponse = postRequest.post(url, bpmRequest, BPMBaseResponse.class);
log.info("response = " + bpmBaseResponse);
return bpmBaseResponse.getD();
}
public ExceedStandardDto creatAuditParamByCar(OrderDetail orderDetail) {
CarOrderDetail carOrderDetail = orderDetail.getCarOrderDetail();
ExceedStandardDto exceedStandardDto = new ExceedStandardDto();
String supplierName = orderDetail.getSupplierName();
exceedStandardDto.setOrderType(BPMConstant.EXCEED_STANDARD_TYPE_CAR)
.setOrderSource(SupplierConstantUtil.etaSupplierName(supplierName))
.setOrderNo(carOrderDetail.getOrderNo())
.setExcessAmount(BigDecimal.valueOf(Double.parseDouble(carOrderDetail.getOrderAmount())))
.setReason(carOrderDetail.getOverStandardReason());
return exceedStandardDto;
}
public ExceedStandardDto creatAuditParamByTrain(OrderDetail orderDetail) {
TrainOrderDetail trainOrderDetail = orderDetail.getTrainOrderDetail();
ExceedStandardDto exceedStandardDto = new ExceedStandardDto();
String supplierName = SupplierConstantUtil.etaSupplierName(orderDetail.getSupplierName());
exceedStandardDto.setOrderType(BPMConstant.EXCEED_STANDARD_TYPE_TRAIN)
.setSeatingStandard(trainOrderDetail.getSeatName())
.setOrderSource(supplierName)
.setOrderNo(trainOrderDetail.getOrderNo())
.setExcessAmount(BigDecimal.valueOf(Double.parseDouble(trainOrderDetail.getOrderAmount())))
.setReason(trainOrderDetail.getOverStandardReason());
return exceedStandardDto;
}
public ExceedStandardDto creatAuditParamByHotel(OrderDetail orderDetail, RouteOrder routeOrder) {
HotelOrderDetail hotelOrderDetail = orderDetail.getHotelOrderDetail();
ExceedStandardDto exceedStandardDto = new ExceedStandardDto();
Long legId = orderDetail.getLegId();
// 差旅标准金额
BigDecimal standardPrice = new BigDecimal("0");
// 定义用于计算标准价格的函数
Function<Leg, BigDecimal> calculateStandardPrice = leg -> {
String standardTotalPrice = leg.getEstimateAmount() == null ? "0" : leg.getEstimateAmount();
BigDecimal bigStandardPrice = new BigDecimal(standardTotalPrice);
int days = DaysUtil.calculateNightsBetweenDates(LocalDate.from(leg.getStartTime()), LocalDate.from(leg.getEndTime()));
return days > 0 ? bigStandardPrice.divide(new BigDecimal(days), 3, RoundingMode.HALF_UP) : bigStandardPrice;
};
// legId null 时的处理逻辑
Supplier<BigDecimal> handleNullLegId = () -> {
Optional<Location> optById = locationRepository.findOptById(orderDetail.getOriginId());
return optById.map(location -> {
Long cityId = location.getCityId();
if (cityId != null) {
String maxPrice = cTripEstimateRequest.hotelMaxPrice(cityId, routeOrder.getUserId(), routeOrder.getStandardLevel());
return maxPrice != null ? new BigDecimal(maxPrice) : new BigDecimal(KEEP_TWO_DECIMAL_ZERO);
} else {
return new BigDecimal(KEEP_TWO_DECIMAL_ZERO);
}
}).orElse(new BigDecimal(KEEP_TWO_DECIMAL_ZERO));
};
BigDecimal standardPriceFromQuery = handleNullLegId.get();
if (orderDetail.getPrice() != null && orderDetail.getProductType().equals(LEG_TYPE_HOTEL)) {
standardPrice = !standardPriceFromQuery.equals(new BigDecimal(KEEP_TWO_DECIMAL_ZERO)) ? standardPriceFromQuery :
calculateStandardPrice.apply(legRepository.findByLegId(legId));
}
// 金额计算
BigDecimal bigTotalPrice = new BigDecimal(orderDetail.getPrice() == null ? "0" : orderDetail.getPrice()); // 获取酒店需要支付的总价格
int actualDays = DaysUtil.calculateNightsBetweenDates(LocalDate.from(orderDetail.getStartTime()), LocalDate.from(orderDetail.getEndTime()));
BigDecimal result = bigTotalPrice.subtract(standardPrice.multiply(BigDecimal.valueOf(actualDays)));
BigDecimal divide = actualDays > 0 ? result.divide(new BigDecimal(actualDays), 3, RoundingMode.HALF_UP) : result;
// 超标总金额
String supplierName = SupplierConstantUtil.etaSupplierName(orderDetail.getSupplierName());
exceedStandardDto.setOrderType(BPMConstant.EXCEED_STANDARD_TYPE_HOTEL)
.setHotelStandard(String.valueOf(standardPrice)) // 差旅标准
.setHouseLayout(hotelOrderDetail.getRoomTypeName())
.setHotelName(hotelOrderDetail.getHotelName())
.setOrderSource(supplierName)
.setOrderNo(hotelOrderDetail.getOrderNo())
.setExcessAmount(result) // 超标金额
.setReason(hotelOrderDetail.getOverStandardReason())
.setOccupant(hotelOrderDetail.getBookingName()) // 入住人
.setDays(Integer.valueOf(hotelOrderDetail.getNightCount())) // 入住天数
.setExcessAmountDay(divide); // 超标金额(/)
if (StringUtils.isBlank(exceedStandardDto.getOccupant())) {
String employeeNo = orderDetail.getEmployeeNo(); // 用户id
User user = userRepository.findByUserEmployeeNo(employeeNo);
if (user != null) {
exceedStandardDto.setOccupant(user.getName()); // 入住人
}
}
return exceedStandardDto;
}
public ExceedStandardDto creatAuditParamByFlight(OrderDetail orderDetail) {
FlightOrderDetail flightOrderDetail = orderDetail.getFlightOrderDetail();
ExceedStandardDto exceedStandardDto = new ExceedStandardDto();
String supplierName = SupplierConstantUtil.etaSupplierName(orderDetail.getSupplierName());
exceedStandardDto.setOrderType(BPMConstant.EXCEED_STANDARD_TYPE_FLIGHT)
.setCabinClass(flightOrderDetail.getSeatPointName())
.setOrderSource(supplierName)
.setOrderNo(flightOrderDetail.getOrderNo())
.setExcessAmount(BigDecimal.valueOf(Double.parseDouble(flightOrderDetail.getOrderAmount())))
.setReason(flightOrderDetail.getOverStandardReason());
return exceedStandardDto;
}
}

View File

@ -10,6 +10,9 @@ import java.io.Serial;
import java.io.Serializable;
import java.util.List;
import java.util.Optional;
import java.util.function.Function;
import static com.chint.domain.aggregates.approval.platform.ApprovalPlatformInfo.ApprovalPlatformPathType.*;
@Data
@Table("approval_platform_info")
@ -26,37 +29,61 @@ public class ApprovalPlatformInfo implements Serializable {
private String platformDescription;
private String platformExtension;
@MappedCollection(idColumn = "approval_platform_info_id", keyColumn = "approval_platform_info_key")
private List<ApprovalPlatformPath> approvalPlatformPathList;
public Optional<String> expenseUrl() {
return getUrlByType("EXPENSE");
return getUrlByType(EXPENSE);
}
public Optional<String> changeUrl() {
return getUrlByType("CHANGE");
return getUrlByType(CHANGE);
}
public Optional<String> addUrl() {
return getUrlByType("ADD");
return getUrlByType(ADD);
}
public Optional<String> refundOrderUrl() {
return getUrlByType("REFUND_ORDER");
return getUrlByType(REFUND_ORDER);
}
public Optional<String> changeOrderUrl() {
return getUrlByType("CHANGE_ORDER");
return getUrlByType(CHANGE_ORDER);
}
public Optional<String> getUrlByType(String type) {
public Optional<String> expenseExtension() {
return getExtensionByType(EXPENSE);
}
public Optional<String> changeExtension() {
return getExtensionByType(CHANGE);
}
public Optional<String> addExtension() {
return getExtensionByType(ADD);
}
public Optional<String> refundOrderExtension() {
return getExtensionByType(REFUND_ORDER);
}
public Optional<String> changeOrderExtension() {
return getExtensionByType(CHANGE_ORDER);
}
private <T> Optional<T> getPropertyByType(ApprovalPlatformPathType type, Function<ApprovalPlatformPath, T> mapper) {
if (approvalPlatformPathList == null || approvalPlatformPathList.isEmpty()) {
return Optional.empty();
}
return approvalPlatformPathList.stream()
.filter(it -> it.getApproval_platform_type().equals(type))
.map(it -> this.platformBaseUrl + it.getApproval_platform_path())
.filter(it -> it.getApproval_platform_type().equals(type.name()))
.map(mapper)
.findFirst();
}
public Optional<String> getUrlByType(ApprovalPlatformPathType type) {
return getPropertyByType(type, it -> this.platformBaseUrl + it.getApproval_platform_path());
}
public Optional<String> getExtensionByType(ApprovalPlatformPathType type) {
return getPropertyByType(type, ApprovalPlatformPath::getExtension);
}
public enum ApprovalPlatformPathType {
EXPENSE, CHANGE, ADD, REFUND_ORDER, CHANGE_ORDER
}
}

View File

@ -0,0 +1,114 @@
package com.chint.domain.aggregates.approval.platform;
import com.chint.domain.aggregates.approval.ApprovalData;
import com.chint.domain.aggregates.approval.ApprovalResultData;
import com.chint.domain.aggregates.order.RouteOrder;
import com.chint.domain.repository.ApprovalPlatformInfoRepository;
import com.chint.domain.repository.SupplierRepository;
import com.chint.infrastructure.util.DelayDispatch;
import com.chint.infrastructure.util.Json;
import com.chint.interfaces.rest.base.PostRequest;
import com.chint.interfaces.rest.bpm.dto.ExceedStandardDto;
import jakarta.annotation.PostConstruct;
import lombok.Data;
import lombok.experimental.Accessors;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.Optional;
@Component
public class ApprovalPlatformJT implements ApprovalPlatform {
@Autowired
private SupplierRepository supplierRepository;
@Autowired
private ApprovalPlatformInfoRepository approvalPlatformInfoRepository;
private ApprovalPlatformInfo approvalPlatformInfo;
@Autowired
private ApprovalH3BPMMethod approvalH3BPMMethod;
@Autowired
private PostRequest postRequest;
public static final String platformMark = "JT";
@PostConstruct
void init() {
approvalPlatformInfoRepository.findByPlatformMark(platformMark)
.ifPresent(approvalPlatformInfo -> this.approvalPlatformInfo = approvalPlatformInfo);
}
@Override
public void submitApproval(ApprovalData approvalData) {
}
@Override
public String getApprovalPlatformName() {
return "";
}
@Override
public void submitLegAddApproval(ApprovalData approvalData) {
}
@Override
public void submitLegChangeApproval(ApprovalData approvalData) {
}
@Override
public void submitOrderExpenseApproval(ApprovalData approvalData) {
Optional<String> expenseUrlOpt = approvalPlatformInfo.expenseUrl();
if (expenseUrlOpt.isEmpty()) {
return;
}
Optional<String> expenseExtensionOpt = approvalPlatformInfo.expenseExtension();
if (expenseExtensionOpt.isEmpty()) {
return;
}
RouteOrder routeOrder = approvalData.getRouteOrder();
ExceedStandardDto exceedStandardDto = approvalH3BPMMethod
.creatAuditParamByHotel(approvalData.getOrderDetail(), routeOrder);
String json = Json.gson().toJson(exceedStandardDto);
String url = expenseUrlOpt.get();
String extension = expenseExtensionOpt.get();
DelayDispatch.attemptToSend(
() -> approvalH3BPMMethod.H3BPMSubmitWorkflow(url, extension, json, routeOrder.getUserId()).getSuccess(), 0
);
}
@Override
public void submitOrderChangeApproval(ApprovalData approvalData) {
}
@Override
public void submitOrderRefundApproval(ApprovalData approvalData) {
}
@Override
public void submitLegAddOrChangeApproval(ApprovalData approvalData) {
}
@Override
public void receiveApprovalResultCustom(ApprovalResultData resultData) {
}
@Data
@Accessors(chain = true)
public static class ExpenseParam {
private String workflowCode;//流程编码
private String userCode;//发起人SF号
private Boolean finishStart;//是否结果填单节点
private String EntityParamValues;//数据
}
}

View File

@ -10,4 +10,5 @@ public class OrderBaseRecord {
private LocalDateTime updateDataTime;
private String ticketClerk; // 票务员
private String belongDepart;
private Long routeId;
}

View File

@ -77,12 +77,14 @@ public class OrderTrainRecord extends OrderBaseRecord{
// private String belongDepart; //归属部门
private String settleOrderFlag;
public OrderTrainRecord loadBelongDeport(String belongDeport
) {
// 行程信息
this.setBelongDepart(belongDeport);
return this;
}
// 加载基础订单信息
public OrderTrainRecord loadBasicOrderInfo(Long id, String orderNo, String orderStatus, String createTime) {
this.setId(id);

View File

@ -177,6 +177,10 @@ public class AmapOrderRecordExtensionFactory implements OrderRecordExtensionFact
orderCarRecord.setRunTime("0");
}
if (routeOrder.isPresent()) {
RouteOrder routeOrderEntity = routeOrder.get();
orderCarRecord.setRouteId(routeOrderEntity.getRouteId());
}
orderDetail.ifPresentOrElse(orderCarRecord::loadComplianceInfo, orderCarRecord::loadComplianceInfoNot);
return orderCarRecord;

View File

@ -871,6 +871,7 @@ public class CTripOrderRecordExtensionFactory implements OrderRecordExtensionFac
if (approveOrderNo != null) {
orderCarRecord.setOfflineCcomyCode(approveOrderNo.getCostCenter());
}
orderCarRecord.setRouteId(routeOrder.getRouteId());
}
return orderCarRecord;
}
@ -1071,8 +1072,8 @@ public class CTripOrderRecordExtensionFactory implements OrderRecordExtensionFac
if (approveOrderNo != null) {
orderFlightRecord.setOfflineCcomyCode(approveOrderNo.getCostCenter());
}
orderFlightRecord.setRouteId(routeOrder.getRouteId());
}
return orderFlightRecord;
}
@ -1280,6 +1281,7 @@ public class CTripOrderRecordExtensionFactory implements OrderRecordExtensionFac
if (approveOrderNo != null) {
orderHotelRecord.setOfflineCcomyCode(approveOrderNo.getCostCenter());
}
orderHotelRecord.setRouteId(routeOrder.getRouteId());
}
return orderHotelRecord;
}

View File

@ -96,6 +96,11 @@ public class LyOrderRecordExtensionFactory implements OrderRecordExtensionFactor
if (orderCarRecordData instanceof LyOrderCarRecord lyOrderCarRecord) {
createCarOrder(orderCarRecord, lyOrderCarRecord, routeOrder);
}
if (routeOrder.isPresent()) {
RouteOrder routeOrderEntity = routeOrder.get();
orderCarRecord.setRouteId(routeOrderEntity.getRouteId());
}
return orderCarRecord;
}
@ -105,6 +110,11 @@ public class LyOrderRecordExtensionFactory implements OrderRecordExtensionFactor
if (orderTrainRecordData instanceof LyOrderTrainRecord lyOrderTrainRecord) {
createTrainOrder(orderTrainRecord, lyOrderTrainRecord, routeOrder);
}
if (routeOrder.isPresent()) {
RouteOrder routeOrderEntity = routeOrder.get();
orderTrainRecord.setRouteId(routeOrderEntity.getRouteId());
}
return orderTrainRecord;
}
@ -114,6 +124,11 @@ public class LyOrderRecordExtensionFactory implements OrderRecordExtensionFactor
if (orderFlightRecordData instanceof LyOrderFlightRecord lyOrderFlightRecord) {
createFlightOrder(orderFlightRecord, lyOrderFlightRecord, routeOrder);
}
if (routeOrder.isPresent()) {
RouteOrder routeOrderEntity = routeOrder.get();
orderFlightRecord.setRouteId(routeOrderEntity.getRouteId());
}
return orderFlightRecord;
}
@ -123,6 +138,11 @@ public class LyOrderRecordExtensionFactory implements OrderRecordExtensionFactor
if (orderHotelRecordData instanceof LyOrderHotelRecord lyOrderHotelRecord) {
createHotelOrder(orderHotelRecord, lyOrderHotelRecord, routeOrder);
}
if (routeOrder.isPresent()) {
RouteOrder routeOrderEntity = routeOrder.get();
orderHotelRecord.setRouteId(routeOrderEntity.getRouteId());
}
return orderHotelRecord;
}

View File

@ -23,6 +23,14 @@ public class SupplierDomainService {
@Autowired
private SupplierCallBackLogRepository supplierCallBackLogRepository;
public String translateSupplierCNName(String supplier) {
return supplierRepository
.findBySupplierName(supplier)
.map(Supplier::getCnName)
.orElse("");
}
public boolean ifCanCancel(Leg leg, String supplierName) {
Optional<Supplier> supplierOptional = supplierRepository.findBySupplierName(supplierName);
if (supplierOptional.isPresent()) {
@ -60,7 +68,6 @@ public class SupplierDomainService {
}
@ListenTo(command = "SupplierCallBackErrorCommand", order = 0)
public void supplierCallBackError(SupplierCallBackErrorCommand command) {
SupplierCallBackLog supplierCallBackLog = SupplierCallBackLog

View File

@ -1,17 +1,43 @@
package com.chint.domain.service.supplier;
import com.chint.infrastructure.constant.SupplierNameConstant;
import com.chint.domain.repository.SupplierRepository;
import com.chint.domain.service.SupplierDomainService;
import jakarta.annotation.PostConstruct;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import static com.chint.infrastructure.constant.SupplierNameConstant.*;
import java.util.HashMap;
import java.util.Map;
@Slf4j
@Component
public class SupplierConstantUtil {
@Autowired
private SupplierRepository supplierRepository;
@Autowired
private SupplierDomainService supplierDomainService;
private static final Map<String, String> supplierCnNameMap = new HashMap<>();
@PostConstruct
public void init() {
supplierRepository.findAll()
.forEach(supplier -> supplierCnNameMap.put(supplier.getName(), supplier.getCnName()));
log.info(supplierCnNameMap.toString());
}
public static String translateOrderSupplierName(String supplier) {
return switch (supplier) {
case SUPPLIER_L_Y -> SUPPLIER_L_Y_CN_NAME;
case SUPPLIER_C_TRIP -> SUPPLIER_C_TRIP_CN_NAME;
case SUPPLIER_AMAP -> SUPPLIER_AMAP_CN_NAME;
default -> "未知供应商";
};
return supplierCnNameMap.getOrDefault(supplier, "");
}
public static String etaSupplierName(String supplier) {
return translateOrderSupplierName(supplier) + "商旅";
}
public static String orderSupplierName(String supplier) {
return translateOrderSupplierName(supplier) + "预定";
}
}

View File

@ -0,0 +1,75 @@
package com.chint.infrastructure.constant;
import org.intellij.lang.annotations.Language;
public class SQLConstant {
@Language("sql")
public static final String OrderFlightRecordExtensionSQL = """
select r1.* from order_flight_record r1
left join route_custom_extension_field r3 on r1.route_id = r3.route_id
where r3.field_name = :fieldName and r3.field_value = :fieldValue and account_period = :accountPeriod
order by r1.create_time desc
limit :offset , :size
""";
@Language("sql")
public static final String OrderFlightRecordExtensionCOUNTSQL = """
select count(*) from order_flight_record r1
left join route_custom_extension_field r3 on r1.route_id = r3.route_id
where r3.field_name = :fieldName and r3.field_value = :fieldValue and account_period = :accountPeriod
order by r1.create_time desc
""";
@Language("sql")
public static final String OrderHotelRecordExtensionSQL = """
select r1.* from order_hotel_record r1
left join route_custom_extension_field r3 on r1.route_id = r3.route_id
where r3.field_name = :fieldName and r3.field_value = :fieldValue and account_period = :accountPeriod
order by r1.create_time desc
limit :offset , :size
""";
@Language("sql")
public static final String OrderHotelRecordExtensionCOUNTSQL = """
select count(*) from order_hotel_record r1
left join route_custom_extension_field r3 on r1.route_id = r3.route_id
where r3.field_name = :fieldName and r3.field_value = :fieldValue and account_period = :accountPeriod
order by r1.create_time desc
""";
@Language("sql")
public static final String OrderTrainRecordExtensionSQL = """
select r1.* from order_train_record r1
left join route_custom_extension_field r3 on r1.route_id = r3.route_id
where r3.field_name = :fieldName and r3.field_value = :fieldValue and account_period = :accountPeriod
order by r1.create_time desc
limit :offset , :size
""";
@Language("sql")
public static final String OrderTrainRecordExtensionCOUNTSQL = """
select count(*) from order_train_record r1
left join route_custom_extension_field r3 on r1.route_id = r3.route_id
where r3.field_name = :fieldName and r3.field_value = :fieldValue and account_period = :accountPeriod
order by r1.create_time desc
""";
@Language("sql")
public static final String OrderCarRecordExtensionSQL = """
select r1.* from order_car_record r1
left join route_custom_extension_field r3 on r1.route_id = r3.route_id
where r3.field_name = :fieldName and r3.field_value = :fieldValue and account_period = :accountPeriod
order by r1.create_time desc
limit :offset , :size
""";
@Language("sql")
public static final String OrderCarRecordExtensionCOUNTSQL = """
select count(*) from order_car_record r1
left join route_custom_extension_field r3 on r1.route_id = r3.route_id
where r3.field_name = :fieldName and r3.field_value = :fieldValue and account_period = :accountPeriod
order by r1.create_time desc
""";
}

View File

@ -15,7 +15,7 @@ public class UserNameRepositoryImpl implements UserNameRepository {
@Autowired
private JdbcUserNameRepository jdbcUserNameRepository;
@Cacheable(value = "user::name", key = "#employeeNo")
@Cacheable(value = "User::name", key = "#employeeNo")
@Override
public Optional<UserName> findByEmployeeNo(String employeeNo) {
return jdbcUserNameRepository.findByEmployeeNo(employeeNo);

View File

@ -12,6 +12,9 @@ import java.util.Collection;
import java.util.List;
import java.util.Optional;
import static com.chint.infrastructure.constant.SQLConstant.OrderCarRecordExtensionCOUNTSQL;
import static com.chint.infrastructure.constant.SQLConstant.OrderCarRecordExtensionSQL;
@Repository
public interface JdbcOrderCarRecordRepository extends CrudRepository<OrderCarRecord, Long> {
@ -32,24 +35,9 @@ public interface JdbcOrderCarRecordRepository extends CrudRepository<OrderCarRec
List<OrderCarRecord> findByAccountPeriod(String accountPeriod);
@Query("""
select r1.* from order_car_record r1
left join order_detail o1 on r1.order_detail_id = o1.order_id
left join route_order r2 on o1.route_id = r2.route_id
left join route_custom_extension_field r3 on r2.route_id = r3.route_id
where r3.field_name = :fieldName and r3.field_value = :fieldValue and account_period = :accountPeriod
order by r1.create_time desc
limit :offset , :size
""")
@Query(OrderCarRecordExtensionSQL)
List<OrderCarRecord> queryRecordByCustomFiled(String fieldName, String fieldValue, String accountPeriod, Integer offset, Integer size);
@Query("""
select count(*) from order_car_record r1
left join order_detail o1 on r1.order_detail_id = o1.order_id
left join route_order r2 on o1.route_id = r2.route_id
left join route_custom_extension_field r3 on r2.route_id = r3.route_id
where r3.field_name = :fieldName and r3.field_value = :fieldValue and account_period = :accountPeriod
order by r1.create_time desc
""")
@Query(OrderCarRecordExtensionCOUNTSQL)
Integer countRecordByCustomFiled(String fieldName, Object fieldValue, String accountPeriod);
}

View File

@ -12,6 +12,8 @@ import java.util.Collection;
import java.util.List;
import java.util.Optional;
import static com.chint.infrastructure.constant.SQLConstant.*;
@Repository
public interface JdbcOrderFlightRecordRepository extends CrudRepository<OrderFlightRecord, Long> {
Optional<OrderFlightRecord> findByDetailId(String detailId);
@ -30,24 +32,9 @@ public interface JdbcOrderFlightRecordRepository extends CrudRepository<OrderFli
List<OrderFlightRecord> findByDetailIdIn(Collection<String> detailId);
List<OrderFlightRecord> findByAccountPeriod(String accountPeriod);
@Query("""
select r1.* from order_flight_record r1
left join order_detail o1 on r1.order_detail_id = o1.order_id
left join route_order r2 on o1.route_id = r2.route_id
left join route_custom_extension_field r3 on r2.route_id = r3.route_id
where r3.field_name = :fieldName and r3.field_value = :fieldValue and account_period = :accountPeriod
order by r1.create_time desc
limit :offset , :size
""")
@Query(OrderFlightRecordExtensionSQL)
List<OrderFlightRecord> queryRecordByCustomFiled(String fieldName, String fieldValue, String accountPeriod, Integer offset, Integer size);
@Query("""
select count(*) from order_flight_record r1
left join order_detail o1 on r1.order_detail_id = o1.order_id
left join route_order r2 on o1.route_id = r2.route_id
left join route_custom_extension_field r3 on r2.route_id = r3.route_id
where r3.field_name = :fieldName and r3.field_value = :fieldValue and account_period = :accountPeriod
order by r1.create_time desc
""")
@Query(OrderFlightRecordExtensionCOUNTSQL)
Integer countRecordByCustomFiled(String fieldName, Object fieldValue, String accountPeriod);
}

View File

@ -12,6 +12,9 @@ import java.util.Collection;
import java.util.List;
import java.util.Optional;
import static com.chint.infrastructure.constant.SQLConstant.OrderHotelRecordExtensionCOUNTSQL;
import static com.chint.infrastructure.constant.SQLConstant.OrderHotelRecordExtensionSQL;
@Repository
public interface JdbcOrderHotelRecordRepository extends CrudRepository<OrderHotelRecord, Long> {
@ -31,25 +34,10 @@ public interface JdbcOrderHotelRecordRepository extends CrudRepository<OrderHote
List<OrderHotelRecord> findByDetailIdIn(Collection<String> detailId);
List<OrderHotelRecord> findByAccountPeriod(String accountPeriod);
@Query("""
select r1.* from order_hotel_record r1
left join order_detail o1 on r1.order_detail_id = o1.order_id
left join route_order r2 on o1.route_id = r2.route_id
left join route_custom_extension_field r3 on r2.route_id = r3.route_id
where r3.field_name = :fieldName and r3.field_value = :fieldValue and account_period = :accountPeriod
order by r1.create_time desc
limit :offset , :size
""")
@Query(OrderHotelRecordExtensionSQL)
List<OrderHotelRecord> queryRecordByCustomFiled(String fieldName, String fieldValue, String accountPeriod, Integer offset, Integer size);
@Query("""
select count(*) from order_hotel_record r1
left join order_detail o1 on r1.order_detail_id = o1.order_id
left join route_order r2 on o1.route_id = r2.route_id
left join route_custom_extension_field r3 on r2.route_id = r3.route_id
where r3.field_name = :fieldName and r3.field_value = :fieldValue and account_period = :accountPeriod
order by r1.create_time desc
""")
@Query(OrderHotelRecordExtensionCOUNTSQL)
Integer countRecordByCustomFiled(String fieldName, Object fieldValue, String accountPeriod);
}

View File

@ -12,6 +12,9 @@ import java.util.Collection;
import java.util.List;
import java.util.Optional;
import static com.chint.infrastructure.constant.SQLConstant.OrderTrainRecordExtensionCOUNTSQL;
import static com.chint.infrastructure.constant.SQLConstant.OrderTrainRecordExtensionSQL;
@Repository
public interface JdbcOrderTrainRecordRepository extends CrudRepository<OrderTrainRecord, Long> {
Optional<OrderTrainRecord> findByDetailId(String detailId);
@ -30,24 +33,9 @@ public interface JdbcOrderTrainRecordRepository extends CrudRepository<OrderTrai
List<OrderTrainRecord> findByDetailIdIn(Collection<String> detailId);
List<OrderTrainRecord> findByAccountPeriod(String accountPeriod);
@Query("""
select r1.* from order_train_record r1
left join order_detail o1 on r1.order_detail_id = o1.order_id
left join route_order r2 on o1.route_id = r2.route_id
left join route_custom_extension_field r3 on r2.route_id = r3.route_id
where r3.field_name = :fieldName and r3.field_value = :fieldValue and account_period = :accountPeriod
order by r1.create_time desc
limit :offset , :size
""")
@Query(OrderTrainRecordExtensionSQL)
List<OrderTrainRecord> queryRecordByCustomFiled(String fieldName, String fieldValue, String accountPeriod, Integer offset, Integer size);
@Query("""
select count(*) from order_train_record r1
left join order_detail o1 on r1.order_detail_id = o1.order_id
left join route_order r2 on o1.route_id = r2.route_id
left join route_custom_extension_field r3 on r2.route_id = r3.route_id
where r3.field_name = :fieldName and r3.field_value = :fieldValue and account_period = :accountPeriod
order by r1.create_time desc
""")
@Query(OrderTrainRecordExtensionCOUNTSQL)
Integer countRecordByCustomFiled(String fieldName, Object fieldValue, String accountPeriod);
}

View File

@ -6,13 +6,15 @@ import com.chint.domain.aggregates.user.User;
import com.chint.domain.repository.UserRepository;
import com.chint.infrastructure.cache.RouteCacheManage;
import com.chint.infrastructure.cache.RouteCacheService;
import com.chint.interfaces.rest.ctrip.CTripLocationHttpRequest;
import com.chint.infrastructure.repository.cache.CacheSystemOrganizationRepository;
import com.google.gson.Gson;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.cache.support.NullValue;
import org.springframework.data.redis.core.RedisTemplate;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
@ -31,8 +33,18 @@ public class CacheTest {
@Autowired
private UserRepository userRepository;
@Autowired
private CacheSystemOrganizationRepository cacheSystemOrganizationRepository;
private Gson gson = new Gson();
@Test
public void nullTest(){
List<Long> list = new ArrayList<>();
list.add((Long) NullValue.INSTANCE);
cacheSystemOrganizationRepository.getFromCacheByIdIn( list );
}
// @Test
public void getAllRouteOrderById(){
List<String> keys = List.of("RouteOrders::900","RouteOrders::918");

View File

@ -314,9 +314,9 @@ class RouteApplicationTests {
@Test
void loginSign() {
String sfno = "220222190";
String sfno = "220506072";
String syscode = "FSSC";
String billcode = "CLSQ240225000101";
String billcode = "CLSQ240225000099";
String companycode = "正泰集团股份有限公司";
String timespan = "1708908662738";
String s = Digest.md5(sfno + syscode + billcode + companycode + LOGIN_SECRET_KEY + timespan);
@ -325,7 +325,7 @@ class RouteApplicationTests {
@Test
void loginSignProd() {
String sfno = "240522018";
String sfno = "240102037";
String syscode = "FSSC";
String billcode = "CLSQ240225000099";
String companycode = "正泰集团股份有限公司";
@ -336,6 +336,8 @@ class RouteApplicationTests {
}
@Test
void deleteRouteOrder2() {
routeRepository.deleteById(50519L);
@ -344,18 +346,10 @@ class RouteApplicationTests {
@Test
void testPushBatch() throws UnsupportedEncodingException {
List<String> billcodeList = List.of("CLS24070100346",
"CLS24070100358",
"CLS24070100472",
"CLS24070100474",
"CLS24063000266");
List<String> billcodeList = List.of("CLS24070300047");
List<String> sfnoList = List.of(
"220524027",
"220506052",
"180605050",
"220621032",
"220630159"
"220208019"
);
System.out.println(billcodeList.size());