【add】订单分页查询功能实现

This commit is contained in:
nixj 2024-06-13 13:52:43 +08:00
parent 925e4c5954
commit 7f0acc3b3f
12 changed files with 254 additions and 65 deletions

View File

@ -40,8 +40,10 @@ public interface JdbcOrderDetailRepository extends CrudRepository<OrderDetail, L
"WHERE 1=1 " + "WHERE 1=1 " +
"AND (:#{#dto.orderNo} ='' OR order_no LIKE :#{#dto.orderNo}) " + "AND (:#{#dto.orderNo} ='' OR order_no LIKE :#{#dto.orderNo}) " +
"AND (:#{#dto.applicant} ='' OR supplier_name LIKE :#{#dto.applicant}) " + "AND (:#{#dto.applicant} ='' OR supplier_name LIKE :#{#dto.applicant}) " +
"AND (:#{#dto.startTime} IS NULL OR :#{#dto.endTime} IS NULL OR order_date BETWEEN :#{#dto.startTime} AND :#{#dto.endTime} ) " + "AND (:#{#dto.startTime} IS NULL OR :#{#dto.endTime} IS NULL OR order_date BETWEEN :#{#dto.startTime} AND :#{#dto.endTime}) " +
"AND (:#{#dto.productType} ='' OR product_type = :#{#dto.productType}) "+ "AND (:#{#dto.productType} ='' OR product_type = :#{#dto.productType}) " +
"AND (:#{#dto.employeeNo} ='' OR employee_no = :#{#dto.employeeNo}) " +
"AND (:#{#dto.employeeNos} IS NULL OR employee_no IN (:#{#dto.employeeNos})) " +
"LIMIT :#{#pageRequest.pageSize} OFFSET :#{#pageRequest.pageNumber}") "LIMIT :#{#pageRequest.pageSize} OFFSET :#{#pageRequest.pageNumber}")
List<OrderDetail> listByCondition(@Param("dto") OrderPageQuery dto, @Param("pageRequest")PageRequest pageRequest); List<OrderDetail> listByCondition(@Param("dto") OrderPageQuery dto, @Param("pageRequest")PageRequest pageRequest);
@ -50,6 +52,8 @@ public interface JdbcOrderDetailRepository extends CrudRepository<OrderDetail, L
"AND (:#{#dto.orderNo} ='' OR order_no LIKE :#{#dto.orderNo}) " + "AND (:#{#dto.orderNo} ='' OR order_no LIKE :#{#dto.orderNo}) " +
"AND (:#{#dto.applicant} ='' OR supplier_name LIKE :#{#dto.applicant}) " + "AND (:#{#dto.applicant} ='' OR supplier_name LIKE :#{#dto.applicant}) " +
"AND (:#{#dto.startTime} IS NULL OR :#{#dto.endTime} IS NULL OR order_date BETWEEN :#{#dto.startTime} AND :#{#dto.endTime} ) " + "AND (:#{#dto.startTime} IS NULL OR :#{#dto.endTime} IS NULL OR order_date BETWEEN :#{#dto.startTime} AND :#{#dto.endTime} ) " +
"AND (:#{#dto.productType} ='' OR product_type = :#{#dto.productType}) ") "AND (:#{#dto.productType} ='' OR product_type = :#{#dto.productType}) "+
"AND (:#{#dto.employeeNo} ='' OR employee_no = :#{#dto.employeeNo}) "+
"AND (:#{#dto.employeeNos} IS NULL OR employee_no IN (:#{#dto.employeeNos})) ")
Integer countByCondition(@Param("dto") OrderPageQuery dto); Integer countByCondition(@Param("dto") OrderPageQuery dto);
} }

View File

@ -59,4 +59,6 @@ select * from route_order r1 left join route_custom_extension_field r2 on r1.rou
@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") @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<String> findByActualOrderNo(@Param("actualOrderNo") String actualOrderNo); List<String> findByActualOrderNo(@Param("actualOrderNo") String actualOrderNo);
List<RouteOrder> findAllByRouteOrderNoContains(String routeOrderNo);
} }

View File

@ -1,33 +0,0 @@
package com.chint.manage.entity.dto;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import java.time.LocalDateTime;
import java.util.List;
@Data
public class OrderPageDto {
private Long routeId;
private String orderNo;
private String supplierName;
private Integer productType;
private String price; // 价格
private String employeeNo;
//出发
private Long originId;
private String originName;
//目的地
private Long destinationId;
private String destinationName;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private LocalDateTime orderDate;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private LocalDateTime startTime;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private LocalDateTime endTime;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private LocalDateTime createTime;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private LocalDateTime updateTime;
}

View File

@ -0,0 +1,93 @@
package com.chint.manage.entity.excel;
import com.alibaba.excel.annotation.ExcelIgnore;
import com.alibaba.excel.annotation.ExcelProperty;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import java.time.LocalDateTime;
import static com.chint.infrastructure.constant.LegConstant.*;
@Data
public class OrderPageExcel extends BaseExcel {
@ExcelIgnore
private Long routeId;
@ExcelProperty("订单号")
private String orderNo;
@ExcelProperty("行程号")
private String routeOrderNo;
@ExcelProperty("出行人")
private String travelers;
@ExcelIgnore
private String status;
@ExcelProperty("订单状态")
private String statusName;
@ExcelProperty("预订人")
private String supplierName;
@ExcelIgnore
private Integer productType;
@ExcelProperty("订单类型")
private String productTypeName;
@ExcelProperty("价格")
private String price; // 价格
@ExcelProperty
private String employeeNo;
@ExcelIgnore
private Long originId;
@ExcelProperty("出发地")
private String originName;
@ExcelIgnore
private Long destinationId;
@ExcelProperty("目的地")
private String destinationName;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
@ExcelProperty("订单创建时间")
private LocalDateTime orderDate;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
@ExcelProperty("订单开始时间")
private LocalDateTime startTime;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
@ExcelProperty("订单结束时间")
private LocalDateTime endTime;
public String getProductTypeName(){
switch (productType){
case LEG_TYPE_AIRPLANE: productTypeName="飞机";break;
case LEG_TYPE_TAXI: productTypeName="打车";break;
case LEG_TYPE_TRAIN: productTypeName="火车";break;
case LEG_TYPE_HOTEL: productTypeName="酒店";break;
}
return productTypeName;
}
public String getStatusName(){
if (status==null){
return status;
}
if(productType.equals(LEG_TYPE_HOTEL)){
switch (status){
// 订单状态1-预订成功3-全部退订成功4-部分退订成功
case "1": statusName="预订成功";
break;
case "3": statusName="全部退订成功";
break;
case "4": statusName="部分退订成功";
break;
}
}else {
// 订单状态0-取消 1-出票成功2-改签成功3-退票成功
switch (status){
case "1": statusName="出票成功";
break;
case "2": statusName="改签成功";
break;
case "3": statusName="退票成功";
break;
case "0": statusName="取消";
break;
}
}
return statusName;
}
}

View File

@ -10,10 +10,8 @@ import java.util.List;
public class OrderPageQuery extends BaseQuery { public class OrderPageQuery extends BaseQuery {
//订单号 //订单号
private String orderNo=""; private String orderNo="";
//申请单号 //行程号
private String actualOrderNo=""; private String routeOrderNo="";
//出行人
private String travelers="";
//预订人 //预订人
private String applicant=""; private String applicant="";
//开始日期 //开始日期
@ -25,8 +23,12 @@ public class OrderPageQuery extends BaseQuery {
*/ */
private String productType=""; private String productType="";
//部门名称 //部门名称
private String deptName=""; private List<String> belongDeptCode=null;
private List<String> userIds=new ArrayList<>(); private String employeeNo="";
private List<String> employeeNos=null;
private List<Long> routeIds=null;
public String getOrderNo() { public String getOrderNo() {
return "%" +orderNo+"%"; return "%" +orderNo+"%";

View File

@ -2,6 +2,7 @@ package com.chint.manage.mapper;
import com.chint.domain.aggregates.order.CarOrderDetail; import com.chint.domain.aggregates.order.CarOrderDetail;
import com.chint.domain.aggregates.order.HotelOrderDetail; import com.chint.domain.aggregates.order.HotelOrderDetail;
import com.chint.domain.aggregates.order.TrainOrderDetail;
import org.springframework.data.domain.Page; import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
import org.springframework.data.repository.CrudRepository; import org.springframework.data.repository.CrudRepository;
@ -17,4 +18,6 @@ public interface JdbcCarOrderDetailRepository extends CrudRepository<CarOrderDet
Page<CarOrderDetail> findAllByUserNameContainsAndOrderNoInAndOrderIdIn(String userName, List<String> orderNo,List<Long> orderIds, Pageable pageable); Page<CarOrderDetail> findAllByUserNameContainsAndOrderNoInAndOrderIdIn(String userName, List<String> orderNo,List<Long> orderIds, Pageable pageable);
Page<CarOrderDetail> findAllByUserNameContainsAndOrderIdIn(String userName,List<Long> orderIds, Pageable pageable); Page<CarOrderDetail> findAllByUserNameContainsAndOrderIdIn(String userName,List<Long> orderIds, Pageable pageable);
List<CarOrderDetail> findAllByOrderIdIn(List<Long> orderIds);
} }

View File

@ -17,4 +17,6 @@ public interface JdbcFlightOrderDetailRepository extends CrudRepository<FlightOr
Page<FlightOrderDetail> findAllByUserNameContainsAndOrderNoInAndOrderIdIn(String userName, List<String> orderNo,List<Long> orderIds, Pageable pageable); Page<FlightOrderDetail> findAllByUserNameContainsAndOrderNoInAndOrderIdIn(String userName, List<String> orderNo,List<Long> orderIds, Pageable pageable);
Page<FlightOrderDetail> findAllByUserNameContainsAndOrderIdIn(String userName,List<Long> orderIds, Pageable pageable); Page<FlightOrderDetail> findAllByUserNameContainsAndOrderIdIn(String userName,List<Long> orderIds, Pageable pageable);
List<FlightOrderDetail> findAllByOrderIdIn(List<Long> orderIds);
} }

View File

@ -2,6 +2,7 @@ package com.chint.manage.mapper;
import com.chint.domain.aggregates.order.FlightOrderDetail; import com.chint.domain.aggregates.order.FlightOrderDetail;
import com.chint.domain.aggregates.order.HotelOrderDetail; import com.chint.domain.aggregates.order.HotelOrderDetail;
import com.chint.domain.aggregates.order.TrainOrderDetail;
import com.chint.domain.aggregates.order.order_record.OrderHotelRecord; import com.chint.domain.aggregates.order.order_record.OrderHotelRecord;
import org.springframework.data.domain.Page; import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
@ -18,4 +19,6 @@ public interface JdbcHotelOrderDetailRepository extends CrudRepository<HotelOrde
Page<HotelOrderDetail> findAllByBookingNameContainsAndOrderNoInAndOrderIdIn(String userName, List<String> orderNo,List<Long> orderIds, Pageable pageable); Page<HotelOrderDetail> findAllByBookingNameContainsAndOrderNoInAndOrderIdIn(String userName, List<String> orderNo,List<Long> orderIds, Pageable pageable);
Page<HotelOrderDetail> findAllByBookingNameContainsAndOrderIdIn(String userName,List<Long> orderIds, Pageable pageable); Page<HotelOrderDetail> findAllByBookingNameContainsAndOrderIdIn(String userName,List<Long> orderIds, Pageable pageable);
List<HotelOrderDetail> findAllByOrderIdIn(List<Long> orderIds);
} }

View File

@ -16,4 +16,6 @@ public interface JdbcTrainOrderDetailRepository extends CrudRepository<TrainOrde
Page<TrainOrderDetail> findAllByUserNameContainsAndOrderNoInAndOrderIdIn(String userName, List<String> orderNo,List<Long> orderIds ,Pageable pageable); Page<TrainOrderDetail> findAllByUserNameContainsAndOrderNoInAndOrderIdIn(String userName, List<String> orderNo,List<Long> orderIds ,Pageable pageable);
Page<TrainOrderDetail> findAllByUserNameContainsAndOrderIdIn(String userName,List<Long> orderIds, Pageable pageable); Page<TrainOrderDetail> findAllByUserNameContainsAndOrderIdIn(String userName,List<Long> orderIds, Pageable pageable);
List<TrainOrderDetail> findAllByOrderIdIn(List<Long> orderIds);
} }

View File

@ -3,14 +3,13 @@ package com.chint.manage.service;
import com.chint.infrastructure.util.PageResult; import com.chint.infrastructure.util.PageResult;
import com.chint.manage.entity.OrderDownloadRecord; import com.chint.manage.entity.OrderDownloadRecord;
import com.chint.manage.entity.dto.ItineraryPageDto; import com.chint.manage.entity.dto.ItineraryPageDto;
import com.chint.manage.entity.dto.OrderPageDto; import com.chint.manage.entity.excel.OrderPageExcel;
import com.chint.manage.entity.query.ConsumptionDetailQuery; import com.chint.manage.entity.query.ConsumptionDetailQuery;
import com.chint.manage.entity.query.ItineraryPageQuery; import com.chint.manage.entity.query.ItineraryPageQuery;
import com.chint.manage.entity.query.OrderPageQuery; import com.chint.manage.entity.query.OrderPageQuery;
import com.chint.manage.entity.query.StandardQuery; import com.chint.manage.entity.query.StandardQuery;
import com.chint.manage.entity.excel.BaseExcel; import com.chint.manage.entity.excel.BaseExcel;
import com.chint.manage.entity.excel.OrderExceedStandardExcel; import com.chint.manage.entity.excel.OrderExceedStandardExcel;
import org.springframework.web.bind.annotation.RequestBody;
import java.io.File; import java.io.File;
import java.util.List; import java.util.List;
@ -36,5 +35,5 @@ public interface ManageService {
List<OrderDownloadRecord> orderDownloadRecordQuery(); List<OrderDownloadRecord> orderDownloadRecordQuery();
PageResult<OrderPageDto> orderPageQuery(OrderPageQuery dto); PageResult<OrderPageExcel> orderPageQuery(OrderPageQuery dto);
} }

View File

@ -1,10 +1,7 @@
package com.chint.manage.service.impl; package com.chint.manage.service.impl;
import com.chint.application.dtos.response.LocationRes; import com.chint.application.dtos.response.LocationRes;
import com.chint.domain.aggregates.order.Leg; import com.chint.domain.aggregates.order.*;
import com.chint.domain.aggregates.order.Location;
import com.chint.domain.aggregates.order.OrderDetail;
import com.chint.domain.aggregates.order.RouteOrder;
import com.chint.domain.aggregates.user.User; import com.chint.domain.aggregates.user.User;
import com.chint.domain.repository.UserRepository; import com.chint.domain.repository.UserRepository;
import com.chint.domain.service.LegDomainService; import com.chint.domain.service.LegDomainService;
@ -16,16 +13,16 @@ import com.chint.infrastructure.util.BaseContext;
import com.chint.infrastructure.util.PageResult; import com.chint.infrastructure.util.PageResult;
import com.chint.manage.entity.OrderDownloadRecord; import com.chint.manage.entity.OrderDownloadRecord;
import com.chint.manage.entity.OrderExceedStandard; import com.chint.manage.entity.OrderExceedStandard;
import com.chint.manage.entity.RouteOrderExtensionField;
import com.chint.manage.entity.dto.ItineraryPageDto; import com.chint.manage.entity.dto.ItineraryPageDto;
import com.chint.manage.entity.dto.OrderPageDto; import com.chint.manage.entity.excel.OrderPageExcel;
import com.chint.manage.entity.excel.BaseExcel; import com.chint.manage.entity.excel.BaseExcel;
import com.chint.manage.entity.excel.OrderExceedStandardExcel; import com.chint.manage.entity.excel.OrderExceedStandardExcel;
import com.chint.manage.entity.query.ConsumptionDetailQuery; import com.chint.manage.entity.query.ConsumptionDetailQuery;
import com.chint.manage.entity.query.ItineraryPageQuery; import com.chint.manage.entity.query.ItineraryPageQuery;
import com.chint.manage.entity.query.OrderPageQuery; import com.chint.manage.entity.query.OrderPageQuery;
import com.chint.manage.entity.query.StandardQuery; import com.chint.manage.entity.query.StandardQuery;
import com.chint.manage.mapper.JdbcOrderDownloadRecordRepository; import com.chint.manage.mapper.*;
import com.chint.manage.mapper.JdbcOrderExceedStandardRepository;
import com.chint.manage.mapper.impl.JdbcConsumptionDetailRepositoryImpl; import com.chint.manage.mapper.impl.JdbcConsumptionDetailRepositoryImpl;
import com.chint.manage.service.ManageService; import com.chint.manage.service.ManageService;
import com.chint.manage.util.BaseUtil; import com.chint.manage.util.BaseUtil;
@ -38,12 +35,13 @@ import org.springframework.data.domain.Sort;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.io.File; import java.io.File;
import java.util.ArrayList; import java.util.*;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.util.stream.Stream; import java.util.stream.Stream;
import static com.chint.infrastructure.constant.LegConstant.*;
import static com.chint.infrastructure.constant.LegConstant.LEG_TYPE_TAXI;
/** /**
* *
* @Authornxj * @Authornxj
@ -71,6 +69,16 @@ public class ManageServiceImpl implements ManageService {
private JdbcOrderDetailRepository jdbcOrderDetailRepository; private JdbcOrderDetailRepository jdbcOrderDetailRepository;
@Autowired @Autowired
private JdbcLocationRepository locationRepository; private JdbcLocationRepository locationRepository;
@Autowired
private JdbcRouteOrderExtensionFieldRepository jdbcRouteOrderExtensionFieldRepository;
@Autowired
private JdbcTrainOrderDetailRepository jdbcTrainOrderDetailRepository;
@Autowired
private JdbcFlightOrderDetailRepository jdbcFlightOrderDetailRepository;
@Autowired
private JdbcHotelOrderDetailRepository jdbcHotelOrderDetailRepository;
@Autowired
private JdbcCarOrderDetailRepository jdbcCarOrderDetailRepository;
@Override @Override
public PageResult<? extends BaseExcel> pageConsumptionDetail(ConsumptionDetailQuery dto) { public PageResult<? extends BaseExcel> pageConsumptionDetail(ConsumptionDetailQuery dto) {
@ -161,30 +169,134 @@ public class ManageServiceImpl implements ManageService {
} }
@Override @Override
public PageResult<OrderPageDto> orderPageQuery(OrderPageQuery dto) { public PageResult<OrderPageExcel> orderPageQuery(OrderPageQuery dto) {
// //数据权限
// List<Long> routeIds=baseUtil.getRouteIds();
// if (routeIds==null||routeIds.isEmpty()) {
// return PageResult.totalPageNum(0, new ArrayList<>());
// }
//行程号
if (!dto.getRouteOrderNo().isEmpty()){
List<RouteOrder> routeOrders=jdbcRouteRepository.findAllByRouteOrderNoContains(dto.getRouteOrderNo());
if (dto.getRouteIds()==null){
dto.setRouteIds(routeOrders.stream().map(RouteOrder::getRouteId).toList());
}else {
List<Long> AnB = dto.getRouteIds().stream().filter(routeOrders.stream().map(RouteOrder::getRouteId).toList()::contains).collect(Collectors.toList());
dto.setRouteIds(AnB);
}
}
//部门
if (dto.getBelongDeptCode()!=null&&!dto.getBelongDeptCode().isEmpty()) {
List<RouteOrderExtensionField> routeOrderExtensionFields=jdbcRouteOrderExtensionFieldRepository.findByBelongDeptCodeIn(dto.getBelongDeptCode());
if (routeOrderExtensionFields==null||routeOrderExtensionFields.isEmpty()) {
return PageResult.totalPageNum(0, new ArrayList<>());
}
if (dto.getRouteIds()==null){
dto.setRouteIds(routeOrderExtensionFields.stream().map(RouteOrderExtensionField::getRouteId).toList());
}else {
List<Long> AnB = dto.getRouteIds().stream().filter(routeOrderExtensionFields.stream().map(RouteOrderExtensionField::getRouteId).toList()::contains).collect(Collectors.toList());
dto.setRouteIds(AnB);
}
}
List<OrderDetail> list=jdbcOrderDetailRepository.listByCondition(dto,dto.getPageResult()); List<OrderDetail> list=jdbcOrderDetailRepository.listByCondition(dto,dto.getPageResult());
//处理地点信息 //处理地点信息
List<Long> locationIds = new ArrayList<>(list.stream().map(OrderDetail::getOriginId).toList()); List<Long> locationIds = new ArrayList<>(list.stream().map(OrderDetail::getOriginId).toList());
locationIds.addAll(list.stream().map(OrderDetail::getDestinationId).toList()); locationIds.addAll(list.stream().map(OrderDetail::getDestinationId).toList());
List<Location> locations=locationRepository.findByLocationIdIn(locationIds); List<Location> locations=locationRepository.findByLocationIdIn(locationIds);
//根据类型处理出行订单信息
Map<Long, OrderPageExcel> orderPageDtoMap=new HashMap<>();
Map<Integer, List<OrderDetail>> collect = list.stream().collect(Collectors.groupingBy(OrderDetail::getProductType));
for (Map.Entry<Integer, List<OrderDetail>> entry : collect.entrySet()) {
int type = entry.getKey();
List<OrderDetail> details = entry.getValue();
switch (type) {
case LEG_TYPE_TRAIN -> dealOrderTrainRecord(details,orderPageDtoMap);
case LEG_TYPE_AIRPLANE -> dealOrderFlightRecord(details,orderPageDtoMap);
case LEG_TYPE_HOTEL -> dealOrderHotelRecord(details,orderPageDtoMap);
case LEG_TYPE_TAXI -> dealOrderCarRecord(details,orderPageDtoMap);
}
}
//处理行程单信息
List<Long> routeIds=list.stream().map(OrderDetail::getRouteId).toList();
List<RouteOrder> routeOrders=jdbcRouteRepository.findByRouteIdIn(routeIds);
List<OrderPageDto> result = list.stream().map(temp -> { List<OrderPageExcel> result = list.stream().map(temp -> {
OrderPageDto obj = new OrderPageDto(); OrderPageExcel obj = orderPageDtoMap.get(temp.getOrderId());
if (obj==null){
obj=new OrderPageExcel();
}
BeanUtils.copyProperties(temp, obj); BeanUtils.copyProperties(temp, obj);
Location origin=locations.stream().filter(s->s.getLocationId().equals(obj.getOriginId())).toList().get(0); OrderPageExcel finalObj = obj;
Location destination=locations.stream().filter(s->s.getLocationId().equals(obj.getDestinationId())).toList().get(0); Location origin=locations.stream().filter(s->s.getLocationId().equals(finalObj.getOriginId())).toList().get(0);
Location destination=locations.stream().filter(s->s.getLocationId().equals(finalObj.getDestinationId())).toList().get(0);
if (origin!=null){ if (origin!=null){
obj.setOriginName(origin.getLocationName()); finalObj.setOriginName(origin.getLocationName());
} }
if (destination!=null){ if (destination!=null){
obj.setDestinationName(destination.getLocationName()); finalObj.setDestinationName(destination.getLocationName());
} }
return obj; List<RouteOrder> orders=routeOrders.stream().filter(s->s.getRouteId().equals(finalObj.getRouteId())).toList();
if (!orders.isEmpty()) {
finalObj.setRouteOrderNo(orders.get(0).getRouteOrderNo());
}
return finalObj;
}).toList(); }).toList();
Integer count=jdbcOrderDetailRepository.countByCondition(dto); Integer count=jdbcOrderDetailRepository.countByCondition(dto);
return PageResult.totalPageNum(count, result); return PageResult.totalPageNum(count, result);
} }
private void dealOrderTrainRecord(List<OrderDetail> entry,Map<Long, OrderPageExcel> orderPageDtoMap){
if (entry!=null&&!entry.isEmpty()){
List<TrainOrderDetail> trainOrderDetails=jdbcTrainOrderDetailRepository.findAllByOrderIdIn(entry.stream().map(OrderDetail::getOrderId).toList());
for (TrainOrderDetail trainOrderDetail : trainOrderDetails) {
OrderPageExcel orderPageDto=new OrderPageExcel();
orderPageDto.setStatus(trainOrderDetail.getOrderStatus());
orderPageDto.setTravelers(trainOrderDetail.getUserName());
orderPageDtoMap.put(trainOrderDetail.getOrderId(),orderPageDto);
}
}
}
private void dealOrderFlightRecord(List<OrderDetail> entry,Map<Long, OrderPageExcel> orderPageDtoMap){
if (entry!=null&&!entry.isEmpty()){
List<FlightOrderDetail> flightOrderDetails=jdbcFlightOrderDetailRepository.findAllByOrderIdIn(entry.stream().map(OrderDetail::getOrderId).toList());
for (FlightOrderDetail flightOrderDetail : flightOrderDetails) {
OrderPageExcel orderPageDto=new OrderPageExcel();
orderPageDto.setStatus(flightOrderDetail.getOrderStatus());
orderPageDto.setTravelers(flightOrderDetail.getUserName());
orderPageDtoMap.put(flightOrderDetail.getOrderId(),orderPageDto);
}
}
}
private void dealOrderHotelRecord(List<OrderDetail> entry,Map<Long, OrderPageExcel> orderPageDtoMap){
if (entry!=null&&!entry.isEmpty()){
List<HotelOrderDetail> hotelOrderDetails=jdbcHotelOrderDetailRepository.findAllByOrderIdIn(entry.stream().map(OrderDetail::getOrderId).toList());
for (HotelOrderDetail hotelOrderDetail : hotelOrderDetails) {
OrderPageExcel orderPageDto=new OrderPageExcel();
orderPageDto.setStatus(hotelOrderDetail.getOrderStatus());
String userNames = hotelOrderDetail.getCustomers().stream()
.map(HotelOrderDetailCustomer::getUserName) // 获取用户名
.collect(Collectors.joining(",")); // 用逗号分隔拼接
orderPageDto.setTravelers(userNames);
orderPageDtoMap.put(hotelOrderDetail.getOrderId(),orderPageDto);
}
}
}
private void dealOrderCarRecord(List<OrderDetail> entry,Map<Long, OrderPageExcel> orderPageDtoMap){
if (entry!=null&&!entry.isEmpty()){
List<CarOrderDetail> carOrderDetails=jdbcCarOrderDetailRepository.findAllByOrderIdIn(entry.stream().map(OrderDetail::getOrderId).toList());
for (CarOrderDetail carOrderDetail : carOrderDetails) {
OrderPageExcel orderPageDto=new OrderPageExcel();
orderPageDto.setStatus(carOrderDetail.getOrderStatus());
orderPageDto.setTravelers(carOrderDetail.getUserName());
orderPageDtoMap.put(carOrderDetail.getOrderId(),orderPageDto);
}
}
}
private static List<OrderExceedStandardExcel> getOrderExceedStandardExcels(Page<OrderExceedStandard> page) { private static List<OrderExceedStandardExcel> getOrderExceedStandardExcels(Page<OrderExceedStandard> page) {
List<OrderExceedStandard> orderList = page.getContent(); List<OrderExceedStandard> orderList = page.getContent();
List<OrderExceedStandardExcel> excelList = new ArrayList<>(); List<OrderExceedStandardExcel> excelList = new ArrayList<>();

View File

@ -52,7 +52,7 @@ public class ManageTest {
@Test @Test
void recordAdd(){ void recordAdd(){
OrderPageQuery dto=new OrderPageQuery(); OrderPageQuery dto=new OrderPageQuery();
dto.setOderNo("123"); dto.setOrderNo("123");
OrderDownloadRecord downloadRecord=OrderDownloadRecord.builder() OrderDownloadRecord downloadRecord=OrderDownloadRecord.builder()
.fileUrl("url") .fileUrl("url")
.status("已完成") .status("已完成")