From 0bf83c362c7f20c4181eb35af014fe9a152a2150 Mon Sep 17 00:00:00 2001 From: nixj Date: Mon, 27 May 2024 14:47:22 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90update=E3=80=91=E6=B6=88=E8=B4=B9?= =?UTF-8?q?=E6=98=8E=E7=BB=86=E6=9F=A5=E8=AF=A2=E6=9D=A1=E4=BB=B6=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../jdbc/JdbcOrderDetailRepository.java | 2 ++ .../repository/jdbc/JdbcRouteRepository.java | 7 +++++ .../entity/query/ConsumptionDetailQuery.java | 2 +- .../mapper/JdbcCarOrderDetailRepository.java | 7 +++++ .../JdbcFlightOrderDetailRepository.java | 7 +++++ .../JdbcHotelOrderDetailRepository.java | 7 +++++ .../JdbcTrainOrderDetailRepository.java | 6 ++++ .../JdbcConsumptionDetailRepositoryImpl.java | 29 ++++++++++++++++--- 8 files changed, 62 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcOrderDetailRepository.java b/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcOrderDetailRepository.java index 9ac69782..b8002582 100644 --- a/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcOrderDetailRepository.java +++ b/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcOrderDetailRepository.java @@ -28,4 +28,6 @@ public interface JdbcOrderDetailRepository extends CrudRepository findByCreateTimeBetweenAndProductType(LocalDateTime createTime, LocalDateTime createTime2, Integer productType); List findByCreateTimeBetweenAndProductTypeAndOrderNoContaining(LocalDateTime createTime, LocalDateTime createTime2, Integer productType, String orderNo); List findByUpdateTimeBetween(LocalDateTime createTime, LocalDateTime createTime2); + + List findAllByRouteIdIn(Collection routeIds); } diff --git a/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcRouteRepository.java b/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcRouteRepository.java index e10381d1..a4b68834 100644 --- a/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcRouteRepository.java +++ b/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcRouteRepository.java @@ -6,6 +6,7 @@ import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.Pageable; import org.springframework.data.jdbc.repository.query.Query; import org.springframework.data.repository.CrudRepository; +import org.springframework.data.repository.query.Param; import org.springframework.stereotype.Repository; import java.time.LocalDateTime; @@ -52,4 +53,10 @@ select * from route_order r1 left join route_custom_extension_field r2 on r1.rou List findByField(); List findByRouteOrderNoIn(Collection routeOrderNo); + + List findAllByApproveOrderNo_ActualOrderNoContaining(String approveOrderNo_actualOrderNo); + + @Query("select od.order_no from route_order ro,order_detail od where ro.route_id=od.route_id and ro.actual_order_no like :actualOrderNo") + List findByActualOrderNo(@Param("actualOrderNo") String actualOrderNo); + } diff --git a/src/main/java/com/chint/manage/entity/query/ConsumptionDetailQuery.java b/src/main/java/com/chint/manage/entity/query/ConsumptionDetailQuery.java index 9c5300e6..41407ec8 100644 --- a/src/main/java/com/chint/manage/entity/query/ConsumptionDetailQuery.java +++ b/src/main/java/com/chint/manage/entity/query/ConsumptionDetailQuery.java @@ -15,5 +15,5 @@ public class ConsumptionDetailQuery extends BaseQuery{ */ private Integer productType; private String userName=""; - private String orderNo=""; + private String actualOrderNo=""; //申请单号 } diff --git a/src/main/java/com/chint/manage/mapper/JdbcCarOrderDetailRepository.java b/src/main/java/com/chint/manage/mapper/JdbcCarOrderDetailRepository.java index e618902d..e3c7238c 100644 --- a/src/main/java/com/chint/manage/mapper/JdbcCarOrderDetailRepository.java +++ b/src/main/java/com/chint/manage/mapper/JdbcCarOrderDetailRepository.java @@ -1,13 +1,20 @@ package com.chint.manage.mapper; import com.chint.domain.aggregates.order.CarOrderDetail; +import com.chint.domain.aggregates.order.HotelOrderDetail; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.data.repository.CrudRepository; import org.springframework.stereotype.Repository; +import java.util.List; + @Repository public interface JdbcCarOrderDetailRepository extends CrudRepository { Page findAllByUserNameContainsAndOrderNoContaining(String userName, String orderNo, Pageable pageable); + + Page findAllByUserNameContainsAndOrderNoIn(String userName, List orderNo, Pageable pageable); + + Page findAllByUserNameContains(String userName, Pageable pageable); } diff --git a/src/main/java/com/chint/manage/mapper/JdbcFlightOrderDetailRepository.java b/src/main/java/com/chint/manage/mapper/JdbcFlightOrderDetailRepository.java index e8d30c7c..2dc921c5 100644 --- a/src/main/java/com/chint/manage/mapper/JdbcFlightOrderDetailRepository.java +++ b/src/main/java/com/chint/manage/mapper/JdbcFlightOrderDetailRepository.java @@ -1,13 +1,20 @@ package com.chint.manage.mapper; import com.chint.domain.aggregates.order.FlightOrderDetail; +import com.chint.domain.aggregates.order.TrainOrderDetail; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.data.repository.CrudRepository; import org.springframework.stereotype.Repository; +import java.util.List; + @Repository public interface JdbcFlightOrderDetailRepository extends CrudRepository { Page findAllByUserNameContainsAndOrderNoContaining(String userName, String orderNo, Pageable pageable); + + Page findAllByUserNameContainsAndOrderNoIn(String userName, List orderNo, Pageable pageable); + + Page findAllByUserNameContains(String userName, Pageable pageable); } diff --git a/src/main/java/com/chint/manage/mapper/JdbcHotelOrderDetailRepository.java b/src/main/java/com/chint/manage/mapper/JdbcHotelOrderDetailRepository.java index 4fcda59e..1d73e0c2 100644 --- a/src/main/java/com/chint/manage/mapper/JdbcHotelOrderDetailRepository.java +++ b/src/main/java/com/chint/manage/mapper/JdbcHotelOrderDetailRepository.java @@ -1,5 +1,6 @@ package com.chint.manage.mapper; +import com.chint.domain.aggregates.order.FlightOrderDetail; import com.chint.domain.aggregates.order.HotelOrderDetail; import com.chint.domain.aggregates.order.order_record.OrderHotelRecord; import org.springframework.data.domain.Page; @@ -7,8 +8,14 @@ import org.springframework.data.domain.Pageable; import org.springframework.data.repository.CrudRepository; import org.springframework.stereotype.Repository; +import java.util.List; + @Repository public interface JdbcHotelOrderDetailRepository extends CrudRepository { Page findAllByBookingNameContainsAndOrderNoContaining(String userName, String orderNo, Pageable pageable); + + Page findAllByBookingNameContainsAndOrderNoIn(String userName, List orderNo, Pageable pageable); + + Page findAllByBookingNameContains(String userName, Pageable pageable); } diff --git a/src/main/java/com/chint/manage/mapper/JdbcTrainOrderDetailRepository.java b/src/main/java/com/chint/manage/mapper/JdbcTrainOrderDetailRepository.java index ca270676..24bacd8a 100644 --- a/src/main/java/com/chint/manage/mapper/JdbcTrainOrderDetailRepository.java +++ b/src/main/java/com/chint/manage/mapper/JdbcTrainOrderDetailRepository.java @@ -6,8 +6,14 @@ import org.springframework.data.domain.Pageable; import org.springframework.data.repository.CrudRepository; import org.springframework.stereotype.Repository; +import java.util.List; + @Repository public interface JdbcTrainOrderDetailRepository extends CrudRepository { Page findAllByUserNameContainsAndOrderNoContaining(String userName, String orderNo, Pageable pageable); + + Page findAllByUserNameContainsAndOrderNoIn(String userName, List orderNo, Pageable pageable); + + Page findAllByUserNameContains(String userName, Pageable pageable); } diff --git a/src/main/java/com/chint/manage/mapper/impl/JdbcConsumptionDetailRepositoryImpl.java b/src/main/java/com/chint/manage/mapper/impl/JdbcConsumptionDetailRepositoryImpl.java index 934198de..e51ba020 100644 --- a/src/main/java/com/chint/manage/mapper/impl/JdbcConsumptionDetailRepositoryImpl.java +++ b/src/main/java/com/chint/manage/mapper/impl/JdbcConsumptionDetailRepositoryImpl.java @@ -1,6 +1,8 @@ package com.chint.manage.mapper.impl; import com.chint.domain.aggregates.order.*; +import com.chint.infrastructure.repository.jdbc.JdbcOrderDetailRepository; +import com.chint.infrastructure.repository.jdbc.JdbcRouteRepository; import com.chint.infrastructure.util.PageResult; import com.chint.manage.entity.dto.ItineraryPageDto; import com.chint.manage.entity.query.ConsumptionDetailQuery; @@ -41,6 +43,10 @@ public class JdbcConsumptionDetailRepositoryImpl implements JdbcConsumptionDetai private JdbcHotelOrderDetailRepository jdbcHotelOrderDetailRepository; @Autowired private JdbcFlightOrderDetailRepository jdbcFlightOrderDetailRepository; + @Autowired + private JdbcRouteRepository jdbcRouteRepository; + @Autowired + private JdbcOrderDetailRepository jdbcOrderDetailRepository; @Override @@ -78,11 +84,26 @@ public class JdbcConsumptionDetailRepositoryImpl implements JdbcConsumptionDetai PageRequest pageRequest = PageRequest .of(dto.getPageNum() - 1, dto.getPageSize(), Sort.by("id").descending()); Page data=new PageImpl<>(Collections.emptyList()); + //申请单查询 + if (!dto.getActualOrderNo().isEmpty()){ + List orderNos=jdbcRouteRepository.findByActualOrderNo("%" + dto.getActualOrderNo() + "%"); + if (orderNos.isEmpty()){ + return new PageResult(0,new ArrayList<>()); + } + switch (dto.getProductType()) { + case LEG_TYPE_TRAIN -> data=getOrderTrainRecord(jdbcTrainOrderDetailRepository.findAllByUserNameContainsAndOrderNoIn(dto.getUserName(),orderNos,pageRequest)); + case LEG_TYPE_AIRPLANE -> data=getOrderFlightRecord(jdbcFlightOrderDetailRepository.findAllByUserNameContainsAndOrderNoIn(dto.getUserName(),orderNos,pageRequest)); + case LEG_TYPE_HOTEL -> data=getOrderHotelRecord(jdbcHotelOrderDetailRepository.findAllByBookingNameContainsAndOrderNoIn(dto.getUserName(),orderNos,pageRequest)); + case LEG_TYPE_TAXI -> data=getOrderCarRecord(jdbcCarOrderDetailRepository.findAllByUserNameContainsAndOrderNoIn(dto.getUserName(),orderNos,pageRequest)); + } + return PageResult.totalPageNum(data.getTotalElements(), data.getContent()); + } + switch (dto.getProductType()) { - case LEG_TYPE_TRAIN -> data=getOrderTrainRecord(jdbcTrainOrderDetailRepository.findAllByUserNameContainsAndOrderNoContaining(dto.getUserName(),dto.getOrderNo(),pageRequest)); - case LEG_TYPE_AIRPLANE -> data=getOrderFlightRecord(jdbcFlightOrderDetailRepository.findAllByUserNameContainsAndOrderNoContaining(dto.getUserName(),dto.getOrderNo(),pageRequest)); - case LEG_TYPE_HOTEL -> data=getOrderHotelRecord(jdbcHotelOrderDetailRepository.findAllByBookingNameContainsAndOrderNoContaining(dto.getUserName(),dto.getOrderNo(),pageRequest)); - case LEG_TYPE_TAXI -> data=getOrderCarRecord(jdbcCarOrderDetailRepository.findAllByUserNameContainsAndOrderNoContaining(dto.getUserName(),dto.getOrderNo(),pageRequest)); + case LEG_TYPE_TRAIN -> data=getOrderTrainRecord(jdbcTrainOrderDetailRepository.findAllByUserNameContains(dto.getUserName(),pageRequest)); + case LEG_TYPE_AIRPLANE -> data=getOrderFlightRecord(jdbcFlightOrderDetailRepository.findAllByUserNameContains(dto.getUserName(),pageRequest)); + case LEG_TYPE_HOTEL -> data=getOrderHotelRecord(jdbcHotelOrderDetailRepository.findAllByBookingNameContains(dto.getUserName(),pageRequest)); + case LEG_TYPE_TAXI -> data=getOrderCarRecord(jdbcCarOrderDetailRepository.findAllByUserNameContains(dto.getUserName(),pageRequest)); } return PageResult.totalPageNum(data.getTotalElements(), data.getContent()); }