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 9616aa77..943f5d06 100644 --- a/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcOrderDetailRepository.java +++ b/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcOrderDetailRepository.java @@ -2,9 +2,13 @@ package com.chint.infrastructure.repository.jdbc; import com.chint.domain.aggregates.order.OrderDetail; import com.chint.domain.aggregates.order.RouteOrder; +import com.chint.manage.entity.query.OrderPageQuery; import org.springframework.data.domain.Page; +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; @@ -30,4 +34,22 @@ public interface JdbcOrderDetailRepository extends CrudRepository findByUpdateTimeBetween(LocalDateTime createTime, LocalDateTime createTime2); List findAllByRouteIdIn(List routeIds); + + + @Query("SELECT * FROM order_detail " + + "WHERE 1=1 " + + "AND (:#{#dto.orderNo} ='' OR order_no LIKE :#{#dto.orderNo}) " + + "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.productType} ='' OR product_type = :#{#dto.productType}) "+ + "LIMIT :#{#pageRequest.pageSize} OFFSET :#{#pageRequest.pageNumber}") + List listByCondition(@Param("dto") OrderPageQuery dto, @Param("pageRequest")PageRequest pageRequest); + + @Query("SELECT COUNT(*) FROM order_detail " + + "WHERE 1=1 " + + "AND (:#{#dto.orderNo} ='' OR order_no LIKE :#{#dto.orderNo}) " + + "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.productType} ='' OR product_type = :#{#dto.productType}) ") + Integer countByCondition(@Param("dto") OrderPageQuery dto); } diff --git a/src/main/java/com/chint/manage/controller/ManageController.java b/src/main/java/com/chint/manage/controller/ManageController.java index b7ee90ed..955efbc4 100644 --- a/src/main/java/com/chint/manage/controller/ManageController.java +++ b/src/main/java/com/chint/manage/controller/ManageController.java @@ -10,7 +10,6 @@ import com.chint.manage.entity.query.ItineraryPageQuery; import com.chint.manage.entity.query.OrderPageQuery; import com.chint.manage.entity.query.StandardQuery; import com.chint.manage.service.ManageService; -import com.chint.manage.util.BaseUtil; import io.swagger.annotations.ApiOperation; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; @@ -26,7 +25,6 @@ import org.springframework.web.bind.annotation.RestController; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; -import java.util.List; import static com.chint.dama.dc.basic.Result.SUCCESS; @@ -99,7 +97,7 @@ public class ManageController { @PostMapping("/order/pageQuery") public Result orderPageQuery(@RequestBody OrderPageQuery dto){ //订单查询 order_detail 行程号改为申请单号 任务创建创建生成记录 异步生成 完成之后再开发下载 - return null; + return Result.Success(SUCCESS,manageService.orderPageQuery(dto)); } @ApiOperation("订单下载记录查询接口") diff --git a/src/main/java/com/chint/manage/entity/dto/OrderPageDto.java b/src/main/java/com/chint/manage/entity/dto/OrderPageDto.java index 9ed1d93e..9b61616c 100644 --- a/src/main/java/com/chint/manage/entity/dto/OrderPageDto.java +++ b/src/main/java/com/chint/manage/entity/dto/OrderPageDto.java @@ -1,8 +1,10 @@ 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 { @@ -12,9 +14,20 @@ public class OrderPageDto { 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; } diff --git a/src/main/java/com/chint/manage/entity/query/OrderPageQuery.java b/src/main/java/com/chint/manage/entity/query/OrderPageQuery.java index ae52fbbd..c8720cde 100644 --- a/src/main/java/com/chint/manage/entity/query/OrderPageQuery.java +++ b/src/main/java/com/chint/manage/entity/query/OrderPageQuery.java @@ -9,7 +9,7 @@ import java.util.List; @Data public class OrderPageQuery extends BaseQuery { //订单号 - private String oderNo=""; + private String orderNo=""; //申请单号 private String actualOrderNo=""; //出行人 @@ -20,9 +20,19 @@ public class OrderPageQuery extends BaseQuery { private String startTime; //结束日期 private String endTime; - //产品类型 - private String productType; + /** + * 商品类型 0-火车 1飞机 2酒店 3打车 4其他 + */ + private String productType=""; //部门名称 private String deptName=""; private List userIds=new ArrayList<>(); + + public String getOrderNo() { + return "%" +orderNo+"%"; + } + + public String getApplicant(){ + return "%" +applicant+"%"; + } } diff --git a/src/main/java/com/chint/manage/service/ManageService.java b/src/main/java/com/chint/manage/service/ManageService.java index c8609838..ed8ed196 100644 --- a/src/main/java/com/chint/manage/service/ManageService.java +++ b/src/main/java/com/chint/manage/service/ManageService.java @@ -3,11 +3,14 @@ package com.chint.manage.service; import com.chint.infrastructure.util.PageResult; import com.chint.manage.entity.OrderDownloadRecord; import com.chint.manage.entity.dto.ItineraryPageDto; +import com.chint.manage.entity.dto.OrderPageDto; import com.chint.manage.entity.query.ConsumptionDetailQuery; import com.chint.manage.entity.query.ItineraryPageQuery; +import com.chint.manage.entity.query.OrderPageQuery; import com.chint.manage.entity.query.StandardQuery; import com.chint.manage.entity.excel.BaseExcel; import com.chint.manage.entity.excel.OrderExceedStandardExcel; +import org.springframework.web.bind.annotation.RequestBody; import java.io.File; import java.util.List; @@ -32,4 +35,6 @@ public interface ManageService { void addOrderDownloadRecord(OrderDownloadRecord orderDownloadRecord); List orderDownloadRecordQuery(); + + PageResult orderPageQuery(OrderPageQuery dto); } diff --git a/src/main/java/com/chint/manage/service/impl/ManageServiceImpl.java b/src/main/java/com/chint/manage/service/impl/ManageServiceImpl.java index 1692ce8b..8247e479 100644 --- a/src/main/java/com/chint/manage/service/impl/ManageServiceImpl.java +++ b/src/main/java/com/chint/manage/service/impl/ManageServiceImpl.java @@ -2,10 +2,14 @@ package com.chint.manage.service.impl; import com.chint.application.dtos.response.LocationRes; import com.chint.domain.aggregates.order.Leg; +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.repository.UserRepository; import com.chint.domain.service.LegDomainService; +import com.chint.infrastructure.repository.jdbc.JdbcLocationRepository; +import com.chint.infrastructure.repository.jdbc.JdbcOrderDetailRepository; import com.chint.infrastructure.repository.jdbc.JdbcRouteRepository; import com.chint.infrastructure.repository.jdbc.JdbcUserRepository; import com.chint.infrastructure.util.BaseContext; @@ -13,10 +17,12 @@ import com.chint.infrastructure.util.PageResult; import com.chint.manage.entity.OrderDownloadRecord; import com.chint.manage.entity.OrderExceedStandard; import com.chint.manage.entity.dto.ItineraryPageDto; +import com.chint.manage.entity.dto.OrderPageDto; import com.chint.manage.entity.excel.BaseExcel; import com.chint.manage.entity.excel.OrderExceedStandardExcel; import com.chint.manage.entity.query.ConsumptionDetailQuery; import com.chint.manage.entity.query.ItineraryPageQuery; +import com.chint.manage.entity.query.OrderPageQuery; import com.chint.manage.entity.query.StandardQuery; import com.chint.manage.mapper.JdbcOrderDownloadRecordRepository; import com.chint.manage.mapper.JdbcOrderExceedStandardRepository; @@ -35,6 +41,7 @@ import java.io.File; import java.util.ArrayList; import java.util.List; import java.util.Objects; +import java.util.stream.Collectors; import java.util.stream.Stream; /** @@ -60,6 +67,10 @@ public class ManageServiceImpl implements ManageService { private JdbcOrderDownloadRecordRepository jdbcOrderDownloadRecordRepository; @Autowired private BaseUtil baseUtil; + @Autowired + private JdbcOrderDetailRepository jdbcOrderDetailRepository; + @Autowired + private JdbcLocationRepository locationRepository; @Override public PageResult pageConsumptionDetail(ConsumptionDetailQuery dto) { @@ -149,6 +160,31 @@ public class ManageServiceImpl implements ManageService { return jdbcOrderDownloadRecordRepository.findAllByEmployeeNo(user.getEmployeeNo()); } + @Override + public PageResult orderPageQuery(OrderPageQuery dto) { + List list=jdbcOrderDetailRepository.listByCondition(dto,dto.getPageResult()); + //处理地点信息 + List locationIds = new ArrayList<>(list.stream().map(OrderDetail::getOriginId).toList()); + locationIds.addAll(list.stream().map(OrderDetail::getDestinationId).toList()); + List locations=locationRepository.findByLocationIdIn(locationIds); + + List result = list.stream().map(temp -> { + OrderPageDto obj = new OrderPageDto(); + BeanUtils.copyProperties(temp, obj); + Location origin=locations.stream().filter(s->s.getLocationId().equals(obj.getOriginId())).toList().get(0); + Location destination=locations.stream().filter(s->s.getLocationId().equals(obj.getDestinationId())).toList().get(0); + if (origin!=null){ + obj.setOriginName(origin.getLocationName()); + } + if (destination!=null){ + obj.setDestinationName(destination.getLocationName()); + } + return obj; + }).toList(); + Integer count=jdbcOrderDetailRepository.countByCondition(dto); + return PageResult.totalPageNum(count, result); + } + private static List getOrderExceedStandardExcels(Page page) { List orderList = page.getContent(); List excelList = new ArrayList<>();