From 34c40ce2e68605729486608e4788c1b63eed1cf4 Mon Sep 17 00:00:00 2001 From: nixj Date: Wed, 26 Jun 2024 10:26:44 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90update=E3=80=91=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E6=9D=83=E9=99=90=E6=9A=82=E6=97=B6=E5=8E=BB=E9=99=A4=EF=BC=8C?= =?UTF-8?q?=E7=AD=89=E5=BE=85=E5=90=8E=E7=BB=AD=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/service/BPMOrderDomainService.java | 4 +- .../jdbc/JdbcOrderDetailRepository.java | 21 ++- .../chint/manage/entity/RouteOrderBasic.java | 92 ++++++++++ .../entity/query/ConsumptionDetailQuery.java | 5 + .../mapper/JdbcCarOrderDetailRepository.java | 6 - .../JdbcFlightOrderDetailRepository.java | 6 - .../JdbcHotelOrderDetailRepository.java | 6 - .../JdbcOrderExceedStandardRepository.java | 6 +- .../mapper/JdbcRouteOrderBasicRepository.java | 20 +++ ...dbcRouteOrderExtensionFieldRepository.java | 6 +- .../JdbcTrainOrderDetailRepository.java | 6 - .../JdbcConsumptionDetailRepositoryImpl.java | 170 +++++++++--------- .../service/impl/ManageServiceImpl.java | 35 ++-- .../java/com/chint/manage/util/BaseUtil.java | 6 +- .../manage/util/DataJdbcCreatorUtil.java | 4 +- 15 files changed, 259 insertions(+), 134 deletions(-) create mode 100644 src/main/java/com/chint/manage/entity/RouteOrderBasic.java create mode 100644 src/main/java/com/chint/manage/mapper/JdbcRouteOrderBasicRepository.java diff --git a/src/main/java/com/chint/domain/service/BPMOrderDomainService.java b/src/main/java/com/chint/domain/service/BPMOrderDomainService.java index aecf4e4a..be80a60b 100644 --- a/src/main/java/com/chint/domain/service/BPMOrderDomainService.java +++ b/src/main/java/com/chint/domain/service/BPMOrderDomainService.java @@ -122,7 +122,7 @@ public class BPMOrderDomainService { //保存超标报表 OrderExceedStandard orderExceedStandard = OrderExceedStandard.builder() .applicant(orderDetail.getSupplierName()) - .companyName(user.getCompanyName()) + .companyName(user.getDepartmentInfo().getCompanyName()) .deptName(user.getDepartmentInfo().getDepartmentNameOne()) .standardType(getProductTypeName(command.getProductType())) .sourceName(anExceedStandardDto.getSourceSystem()) @@ -161,7 +161,7 @@ public class BPMOrderDomainService { //保存超标报表 OrderExceedStandard orderExceedStandard = OrderExceedStandard.builder() .applicant(orderDetail.getSupplierName()) - .companyName(user.getCompanyName()) + .companyName(user.getDepartmentInfo().getCompanyName()) .deptName(user.getDepartmentInfo().getDepartmentNameOne()) .standardType(getProductTypeName(command.getProductType())) .sourceName(exceedStandardDto.getOrderSource()) 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 1889fff8..cb14e6e1 100644 --- a/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcOrderDetailRepository.java +++ b/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcOrderDetailRepository.java @@ -6,6 +6,7 @@ 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.Modifying; import org.springframework.data.jdbc.repository.query.Query; import org.springframework.data.repository.CrudRepository; import org.springframework.data.repository.query.Param; @@ -33,11 +34,24 @@ public interface JdbcOrderDetailRepository extends CrudRepository findByCreateTimeBetweenAndProductTypeAndOrderNoContaining(LocalDateTime createTime, LocalDateTime createTime2, Integer productType, String orderNo); List findByUpdateTimeBetween(LocalDateTime createTime, LocalDateTime createTime2); - List findAllByRouteIdIn(List routeIds); + @Query("SELECT order_no FROM order_detail " + + "WHERE route_id IN (:#{#routeIds})") + List findAllOrderNo(@Param("routeIds") List routeIds); + + @Query("SELECT order_id FROM order_detail " + + "WHERE route_id IN (:#{#routeIds})") + List findAllOrderId(@Param("routeIds") List routeIds); + + @Query("SELECT order_no FROM order_detail " ) + List findAllOrderNo(); + + @Query("SELECT order_id FROM order_detail ") + List findAllOrderId(); @Query("SELECT * FROM order_detail " + - "WHERE route_id IN (:#{#dto.routeIds}) " + +// "WHERE route_id IN (:#{#dto.routeIds}) " + + "WHERE 1=1 " + "AND (:#{#dto.orderNo} ='' OR order_no LIKE :#{#dto.orderNo}) " + "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}) " + @@ -47,7 +61,8 @@ public interface JdbcOrderDetailRepository extends CrudRepository listByCondition(@Param("dto") OrderPageQuery dto, @Param("pageRequest")PageRequest pageRequest); @Query("SELECT COUNT(*) FROM order_detail " + - "WHERE route_id IN (:#{#dto.routeIds}) " + +// "WHERE route_id IN (:#{#dto.routeIds}) " + + "WHERE 1=1 " + "AND (:#{#dto.orderNo} ='' OR order_no LIKE :#{#dto.orderNo}) " + "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}) "+ diff --git a/src/main/java/com/chint/manage/entity/RouteOrderBasic.java b/src/main/java/com/chint/manage/entity/RouteOrderBasic.java new file mode 100644 index 00000000..06b7c382 --- /dev/null +++ b/src/main/java/com/chint/manage/entity/RouteOrderBasic.java @@ -0,0 +1,92 @@ +package com.chint.manage.entity; + +import lombok.Data; +import org.springframework.data.annotation.Id; +import org.springframework.data.relational.core.mapping.Table; +import java.io.Serial; +import java.io.Serializable; + +/** + * + * @author xx RouteOrderBasic.java + * + **/ +@Data +@Table("route_order") +public class RouteOrderBasic implements Serializable { +@Serial +private static final long serialVersionUID = 1L; + @Id + private Long routeId; + + /****/ + private java.util.Date bookingTime; + + /****/ + private String userId; + + /****/ + private java.util.Date createTime; + + /****/ + private String createUser; + + /****/ + private Integer sort; + + /****/ + private Integer status; + + /****/ + private java.util.Date updateTime; + + /****/ + private String updateUser; + + /****/ + private String fakeOrderNo; + + /****/ + private String actualOrderNo; + + /**差旅订单号**/ + private String routeOrderNo; + + /****/ + private String supplierName; + + /****/ + private String accountCompany; + + /****/ + private String sysCode; + + /****/ + private String instructions; + + /****/ + private String standardLevel; + + /****/ + private String creator; + + /****/ + private String accountCompanyName; + + /**入账公司64位编码**/ + private String accountCompanyCode; + + /****/ + private String projectName; + + /****/ + private String costCenter; + + /****/ + private java.util.Date startTime; + + /****/ + private java.util.Date endTime; + + +} 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 0e6f94f0..c57ff26a 100644 --- a/src/main/java/com/chint/manage/entity/query/ConsumptionDetailQuery.java +++ b/src/main/java/com/chint/manage/entity/query/ConsumptionDetailQuery.java @@ -4,6 +4,9 @@ import com.chint.domain.value_object.BaseQuery; import com.chint.manage.util.BaseUtil; import lombok.Data; +import java.util.ArrayList; +import java.util.List; + /** * * @Author:nxj @@ -17,6 +20,8 @@ public class ConsumptionDetailQuery extends BaseQuery{ private Integer productType; private String userName=""; private String actualOrderNo=""; //申请单号 + private List orderIds=new ArrayList<>(); + private List orderNos=new ArrayList<>(); public String getActualOrderNo() { return BaseUtil.extractAfterDash(actualOrderNo); diff --git a/src/main/java/com/chint/manage/mapper/JdbcCarOrderDetailRepository.java b/src/main/java/com/chint/manage/mapper/JdbcCarOrderDetailRepository.java index 9ce9e78e..0674ed1b 100644 --- a/src/main/java/com/chint/manage/mapper/JdbcCarOrderDetailRepository.java +++ b/src/main/java/com/chint/manage/mapper/JdbcCarOrderDetailRepository.java @@ -13,11 +13,5 @@ import java.util.List; @Repository public interface JdbcCarOrderDetailRepository extends CrudRepository { - Page findAllByUserNameContainsAndOrderNoContaining(String userName, String orderNo, Pageable pageable); - - Page findAllByUserNameContainsAndOrderNoInAndOrderIdIn(String userName, List orderNo,List orderIds, Pageable pageable); - - Page findAllByUserNameContainsAndOrderIdIn(String userName,List orderIds, Pageable pageable); - List findAllByOrderIdIn(List orderIds); } diff --git a/src/main/java/com/chint/manage/mapper/JdbcFlightOrderDetailRepository.java b/src/main/java/com/chint/manage/mapper/JdbcFlightOrderDetailRepository.java index b60bd6e6..b34528d2 100644 --- a/src/main/java/com/chint/manage/mapper/JdbcFlightOrderDetailRepository.java +++ b/src/main/java/com/chint/manage/mapper/JdbcFlightOrderDetailRepository.java @@ -12,11 +12,5 @@ import java.util.List; @Repository public interface JdbcFlightOrderDetailRepository extends CrudRepository { - Page findAllByUserNameContainsAndOrderNoContaining(String userName, String orderNo, Pageable pageable); - - Page findAllByUserNameContainsAndOrderNoInAndOrderIdIn(String userName, List orderNo,List orderIds, Pageable pageable); - - Page findAllByUserNameContainsAndOrderIdIn(String userName,List orderIds, Pageable pageable); - List findAllByOrderIdIn(List orderIds); } diff --git a/src/main/java/com/chint/manage/mapper/JdbcHotelOrderDetailRepository.java b/src/main/java/com/chint/manage/mapper/JdbcHotelOrderDetailRepository.java index da1fe8db..7899649c 100644 --- a/src/main/java/com/chint/manage/mapper/JdbcHotelOrderDetailRepository.java +++ b/src/main/java/com/chint/manage/mapper/JdbcHotelOrderDetailRepository.java @@ -14,11 +14,5 @@ import java.util.List; @Repository public interface JdbcHotelOrderDetailRepository extends CrudRepository { - Page findAllByBookingNameContainsAndOrderNoContaining(String userName, String orderNo, Pageable pageable); - - Page findAllByBookingNameContainsAndOrderNoInAndOrderIdIn(String userName, List orderNo,List orderIds, Pageable pageable); - - Page findAllByBookingNameContainsAndOrderIdIn(String userName,List orderIds, Pageable pageable); - List findAllByOrderIdIn(List orderIds); } diff --git a/src/main/java/com/chint/manage/mapper/JdbcOrderExceedStandardRepository.java b/src/main/java/com/chint/manage/mapper/JdbcOrderExceedStandardRepository.java index b7cdff16..8de1f15a 100644 --- a/src/main/java/com/chint/manage/mapper/JdbcOrderExceedStandardRepository.java +++ b/src/main/java/com/chint/manage/mapper/JdbcOrderExceedStandardRepository.java @@ -2,6 +2,7 @@ package com.chint.manage.mapper; import com.chint.manage.entity.OrderExceedStandard; import io.lettuce.core.dynamic.annotation.Param; +import org.jetbrains.annotations.NotNull; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.data.jdbc.repository.query.Modifying; @@ -18,5 +19,8 @@ public interface JdbcOrderExceedStandardRepository extends CrudRepository findAllByApplicantContainsAndCompanyNameContainsAndActualOrderNoContainsAndOrderNoContainsAndOrderNoIn(String applicant, String company, String actualOrderNo, String orderNo, List orderNos, Pageable pageable); + List findAll(); + +// Page findAllByApplicantContainsAndDeptNameContainsAndActualOrderNoContainsAndOrderNoContainsAndOrderNoIn(String applicant, String company, String actualOrderNo, String orderNo, List orderNos, Pageable pageable); +Page findAllByApplicantContainsAndDeptNameContainsAndActualOrderNoContainsAndOrderNoContains(String applicant, String company, String actualOrderNo, String orderNo, Pageable pageable); } diff --git a/src/main/java/com/chint/manage/mapper/JdbcRouteOrderBasicRepository.java b/src/main/java/com/chint/manage/mapper/JdbcRouteOrderBasicRepository.java new file mode 100644 index 00000000..c10a3180 --- /dev/null +++ b/src/main/java/com/chint/manage/mapper/JdbcRouteOrderBasicRepository.java @@ -0,0 +1,20 @@ +package com.chint.manage.mapper; +import com.chint.domain.aggregates.order.RouteOrder; +import com.chint.manage.entity.RouteOrderBasic; +import org.springframework.data.repository.CrudRepository; +import org.springframework.stereotype.Repository; + +import java.util.List; + + +/** + * + * @author xx JdbcRouteOrderBasicRepository数据库操作接口类 + * + **/ +@Repository +public interface JdbcRouteOrderBasicRepository extends CrudRepository { + + List findByRouteIdIn(List routeIds); + +} \ No newline at end of file diff --git a/src/main/java/com/chint/manage/mapper/JdbcRouteOrderExtensionFieldRepository.java b/src/main/java/com/chint/manage/mapper/JdbcRouteOrderExtensionFieldRepository.java index 84d46b78..bf44e6af 100644 --- a/src/main/java/com/chint/manage/mapper/JdbcRouteOrderExtensionFieldRepository.java +++ b/src/main/java/com/chint/manage/mapper/JdbcRouteOrderExtensionFieldRepository.java @@ -1,6 +1,8 @@ package com.chint.manage.mapper; import com.chint.manage.entity.RouteOrderExtensionField; +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.util.List; @@ -14,5 +16,7 @@ import java.util.List; @Repository public interface JdbcRouteOrderExtensionFieldRepository extends CrudRepository { - List findByBelongDeptCodeIn(List belongDeptCode); + @Query("SELECT * FROM route_order_extension_field " + + "WHERE belong_dept_code IN (:#{#belongDeptCode})") + List findByCondition(@Param("belongDeptCode") List belongDeptCode); } \ No newline at end of file diff --git a/src/main/java/com/chint/manage/mapper/JdbcTrainOrderDetailRepository.java b/src/main/java/com/chint/manage/mapper/JdbcTrainOrderDetailRepository.java index befad4b5..db696b2e 100644 --- a/src/main/java/com/chint/manage/mapper/JdbcTrainOrderDetailRepository.java +++ b/src/main/java/com/chint/manage/mapper/JdbcTrainOrderDetailRepository.java @@ -11,11 +11,5 @@ import java.util.List; @Repository public interface JdbcTrainOrderDetailRepository extends CrudRepository { - Page findAllByUserNameContainsAndOrderNoContaining(String userName, String orderNo, Pageable pageable); - - Page findAllByUserNameContainsAndOrderNoInAndOrderIdIn(String userName, List orderNo,List orderIds ,Pageable pageable); - - Page findAllByUserNameContainsAndOrderIdIn(String userName,List orderIds, Pageable pageable); - List findAllByOrderIdIn(List orderIds); } 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 9fc13b84..a9556787 100644 --- a/src/main/java/com/chint/manage/mapper/impl/JdbcConsumptionDetailRepositoryImpl.java +++ b/src/main/java/com/chint/manage/mapper/impl/JdbcConsumptionDetailRepositoryImpl.java @@ -35,15 +35,6 @@ public class JdbcConsumptionDetailRepositoryImpl implements JdbcConsumptionDetai @Autowired private NamedParameterJdbcTemplate jdbcTemplate; - - @Autowired - private JdbcTrainOrderDetailRepository jdbcTrainOrderDetailRepository; - @Autowired - private JdbcCarOrderDetailRepository jdbcCarOrderDetailRepository; - @Autowired - private JdbcHotelOrderDetailRepository jdbcHotelOrderDetailRepository; - @Autowired - private JdbcFlightOrderDetailRepository jdbcFlightOrderDetailRepository; @Autowired private JdbcRouteRepository jdbcRouteRepository; @Autowired @@ -56,23 +47,22 @@ public class JdbcConsumptionDetailRepositoryImpl implements JdbcConsumptionDetai public Page itineraryPageQueryByDto(ItineraryPageQuery dto) { String query = "SELECT * FROM route_order " + "WHERE route_id IN (:routeIds) " - + "AND (:actualOrderNo IS NULL OR actual_order_no = :actualOrderNo ) " + "AND actual_order_no IS NOT NULL "; if (!dto.getUserIds().isEmpty()) { - query+="AND user_id IN (:userIds)"; + query+="AND user_id IN (:userIds) "; + } + + if (!dto.getActualOrderNo().isEmpty()) { + query+="AND actual_order_no = :actualOrderNo "; } Map params = new HashMap<>(); - //设置null - if (dto.getActualOrderNo().isEmpty()){ - dto.setActualOrderNo(null); - } + PageRequest pageRequest = PageRequest + .of(dto.getPageNum() - 1, dto.getPageSize(), Sort.by("create_time").descending()); params.put("actualOrderNo", dto.getActualOrderNo()); params.put("userIds", dto.getUserIds()); params.put("routeIds", dto.getRouteIds()); - PageRequest pageRequest = PageRequest - .of(dto.getPageNum() - 1, dto.getPageSize(), Sort.by("route_id").descending()); params.put("offset", pageRequest.getOffset()); params.put("limit", pageRequest.getPageSize()); @@ -87,13 +77,12 @@ public class JdbcConsumptionDetailRepositoryImpl implements JdbcConsumptionDetai @Override public PageResult pageConsumptionDetail(ConsumptionDetailQuery dto) { //数据权限 - List orderIds=baseUtil.getOrderIds(); - if (orderIds==null||orderIds.isEmpty()) { - return PageResult.totalPageNum(0, new ArrayList<>()); - } +// List orderIds=baseUtil.getOrderIds(); +// if (orderIds==null||orderIds.isEmpty()) { +// return PageResult.totalPageNum(0, new ArrayList<>()); +// } - PageRequest pageRequest = PageRequest - .of(dto.getPageNum() - 1, dto.getPageSize(), Sort.by("id").descending()); + List orderIds=jdbcOrderDetailRepository.findAllOrderId(); Page data=new PageImpl<>(Collections.emptyList()); //申请单查询 if (!dto.getActualOrderNo().isEmpty()){ @@ -101,79 +90,100 @@ public class JdbcConsumptionDetailRepositoryImpl implements JdbcConsumptionDetai if (orderNos.isEmpty()){ return new PageResult(0,new ArrayList<>()); } - switch (dto.getProductType()) { - case LEG_TYPE_TRAIN -> data=getOrderTrainRecord(jdbcTrainOrderDetailRepository.findAllByUserNameContainsAndOrderNoInAndOrderIdIn(dto.getUserName(),orderNos,orderIds,pageRequest)); - case LEG_TYPE_AIRPLANE -> data=getOrderFlightRecord(jdbcFlightOrderDetailRepository.findAllByUserNameContainsAndOrderNoInAndOrderIdIn(dto.getUserName(),orderNos,orderIds,pageRequest)); - case LEG_TYPE_HOTEL -> data=getOrderHotelRecord(jdbcHotelOrderDetailRepository.findAllByBookingNameContainsAndOrderNoInAndOrderIdIn(dto.getUserName(),orderNos,orderIds,pageRequest)); - case LEG_TYPE_TAXI -> data=getOrderCarRecord(jdbcCarOrderDetailRepository.findAllByUserNameContainsAndOrderNoInAndOrderIdIn(dto.getUserName(),orderNos,orderIds,pageRequest)); - } - return PageResult.totalPageNum(data.getTotalElements(), data.getContent()); + dto.setOrderNos(orderNos); } switch (dto.getProductType()) { - case LEG_TYPE_TRAIN -> data=getOrderTrainRecord(jdbcTrainOrderDetailRepository.findAllByUserNameContainsAndOrderIdIn(dto.getUserName(),orderIds,pageRequest)); - case LEG_TYPE_AIRPLANE -> data=getOrderFlightRecord(jdbcFlightOrderDetailRepository.findAllByUserNameContainsAndOrderIdIn(dto.getUserName(),orderIds,pageRequest)); - case LEG_TYPE_HOTEL -> data=getOrderHotelRecord(jdbcHotelOrderDetailRepository.findAllByBookingNameContainsAndOrderIdIn(dto.getUserName(),orderIds,pageRequest)); - case LEG_TYPE_TAXI -> data=getOrderCarRecord(jdbcCarOrderDetailRepository.findAllByUserNameContainsAndOrderIdIn(dto.getUserName(),orderIds,pageRequest)); + case LEG_TYPE_TRAIN -> data=trainPageConsumptionDetail(dto); + case LEG_TYPE_AIRPLANE -> data=flightPageConsumptionDetail(dto); + case LEG_TYPE_HOTEL -> data=hotelPageConsumptionDetail(dto); + case LEG_TYPE_TAXI -> data=carPageConsumptionDetail(dto); } return PageResult.totalPageNum(data.getTotalElements(), data.getContent()); } - public Page getOrderTrainRecord(Page page) { - List orderRecords = page.getContent(); - List trainOrderDetailExcels = new ArrayList<>(); - // 遍历 OrderBaseRecord,将其转换为 ConsumptionDetailExcel - for (TrainOrderDetail orderRecord : orderRecords) { - TrainOrderDetailExcel trainOrderDetailExcel = new TrainOrderDetailExcel(); - BeanUtils.copyProperties(orderRecord, trainOrderDetailExcel); - trainOrderDetailExcels.add(trainOrderDetailExcel); - } - // 构建一个新的 Page 对象并返回 - return new PageImpl<>(trainOrderDetailExcels, page.getPageable(), page.getTotalElements()); + + private Page trainPageConsumptionDetail(ConsumptionDetailQuery dto){ + String query = "SELECT * FROM train_order_detail " + + "WHERE 1=1 "; + + Map params = new HashMap<>(); + PageRequest pageRequest = PageRequest + .of(dto.getPageNum() - 1, dto.getPageSize(), Sort.by("create_time").descending()); + query = getString(dto, query, params, pageRequest); + + String pagedQuery = query + " LIMIT :limit OFFSET :offset"; + long count = jdbcTemplate.queryForObject("SELECT COUNT(*) FROM (" + query + ") AS count", params, Long.class); + List results = jdbcTemplate.query(pagedQuery, params, BeanPropertyRowMapper.newInstance(TrainOrderDetailExcel.class)); + return new PageImpl<>(results, pageRequest, count); } - public Page getOrderFlightRecord(Page page) { - List orderRecords = page.getContent(); - List trainOrderDetailExcels = new ArrayList<>(); - for (FlightOrderDetail orderRecord : orderRecords) { - FlightOrderDetailExcel flightOrderDetailExcel = new FlightOrderDetailExcel(); - BeanUtils.copyProperties(orderRecord, flightOrderDetailExcel); - trainOrderDetailExcels.add(flightOrderDetailExcel); - } - // 构建一个新的 Page 对象并返回 - return new PageImpl<>(trainOrderDetailExcels, page.getPageable(), page.getTotalElements()); + private Page flightPageConsumptionDetail(ConsumptionDetailQuery dto){ + String query = "SELECT * FROM flight_order_detail " + + "WHERE 1=1 "; + + Map params = new HashMap<>(); + PageRequest pageRequest = PageRequest + .of(dto.getPageNum() - 1, dto.getPageSize(), Sort.by("create_time").descending()); + query = getString(dto, query, params, pageRequest); + + String pagedQuery = query + " LIMIT :limit OFFSET :offset"; + long count = jdbcTemplate.queryForObject("SELECT COUNT(*) FROM (" + query + ") AS count", params, Long.class); + List results = jdbcTemplate.query(pagedQuery, params, BeanPropertyRowMapper.newInstance(FlightOrderDetailExcel.class)); + return new PageImpl<>(results, pageRequest, count); } - public Page getOrderHotelRecord(Page page) { - List orderRecords = page.getContent(); - List trainOrderDetailExcels = new ArrayList<>(); + private Page hotelPageConsumptionDetail(ConsumptionDetailQuery dto){ + String query = "SELECT * FROM hotel_order_detail " + + "WHERE 1=1 "; - for (HotelOrderDetail orderRecord : orderRecords) { - HotelOrderDetailExcel hotelOrderDetailExcel = new HotelOrderDetailExcel(); - BeanUtils.copyProperties(orderRecord, hotelOrderDetailExcel); - List customers=orderRecord.getCustomers(); - String userNames = customers.stream() - .map(HotelOrderDetailCustomer::getUserName) // 获取用户名 - .collect(Collectors.joining(",")); // 用逗号分隔拼接 - hotelOrderDetailExcel.setUserName(userNames); - trainOrderDetailExcels.add(hotelOrderDetailExcel); - } - // 构建一个新的 Page 对象并返回 - return new PageImpl<>(trainOrderDetailExcels, page.getPageable(), page.getTotalElements()); + Map params = new HashMap<>(); + PageRequest pageRequest = PageRequest + .of(dto.getPageNum() - 1, dto.getPageSize(), Sort.by("create_time").descending()); + query = getString(dto, query, params, pageRequest); + + String pagedQuery = query + " LIMIT :limit OFFSET :offset"; + long count = jdbcTemplate.queryForObject("SELECT COUNT(*) FROM (" + query + ") AS count", params, Long.class); + List results = jdbcTemplate.query(pagedQuery, params, BeanPropertyRowMapper.newInstance(HotelOrderDetailExcel.class)); + return new PageImpl<>(results, pageRequest, count); } - public Page getOrderCarRecord(Page page) { - List orderRecords = page.getContent(); - List trainOrderDetailExcels = new ArrayList<>(); + private Page carPageConsumptionDetail(ConsumptionDetailQuery dto){ + String query = "SELECT * FROM car_order_detail " + + "WHERE 1=1 "; - // 遍历 OrderBaseRecord,将其转换为 ConsumptionDetailExcel - for (CarOrderDetail orderRecord : orderRecords) { - CarOrderDetailExcel carOrderDetailExcel = new CarOrderDetailExcel(); - BeanUtils.copyProperties(orderRecord, carOrderDetailExcel); - trainOrderDetailExcels.add(carOrderDetailExcel); + Map params = new HashMap<>(); + PageRequest pageRequest = PageRequest + .of(dto.getPageNum() - 1, dto.getPageSize(), Sort.by("create_time").descending()); + + query = getString(dto, query, params, pageRequest); + + String pagedQuery = query + " LIMIT :limit OFFSET :offset"; + long count = jdbcTemplate.queryForObject("SELECT COUNT(*) FROM (" + query + ") AS count", params, Long.class); + List results = jdbcTemplate.query(pagedQuery, params, BeanPropertyRowMapper.newInstance(CarOrderDetailExcel.class)); + return new PageImpl<>(results, pageRequest, count); + } + + private static String getString(ConsumptionDetailQuery dto, String query, Map params, PageRequest pageRequest) { + if (!dto.getUserName().isEmpty()) { + dto.setUserName("%"+ dto.getUserName()+"%"); + query +="AND user_name LIKE (:userName)"; } - // 构建一个新的 Page 对象并返回 - return new PageImpl<>(trainOrderDetailExcels, page.getPageable(), page.getTotalElements()); + if (!dto.getOrderIds().isEmpty()) { + query +="AND order_id IN (:orderIds)"; + } + + if (!dto.getOrderNos().isEmpty()) { + query +="AND order_no IN (:orderNos)"; + } + + params.put("userName", dto.getUserName()); + params.put("orderNos", dto.getOrderNos()); + params.put("orderIds", dto.getOrderIds()); + + params.put("offset", pageRequest.getOffset()); + params.put("limit", pageRequest.getPageSize()); + return query; } } 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 a8571bf4..66bc7108 100644 --- a/src/main/java/com/chint/manage/service/impl/ManageServiceImpl.java +++ b/src/main/java/com/chint/manage/service/impl/ManageServiceImpl.java @@ -98,20 +98,19 @@ public class ManageServiceImpl implements ManageService { @Override public PageResult standardQuery(StandardQuery dto) { //数据权限 - List orderNos=baseUtil.getOrderNos(); - if (orderNos==null||orderNos.isEmpty()) { - return PageResult.totalPageNum(0, new ArrayList<>()); - } +// List orderNos=baseUtil.getOrderNos(); +// if (orderNos==null||orderNos.isEmpty()) { +// return PageResult.totalPageNum(0, new ArrayList<>()); +// } PageRequest pageRequest = PageRequest .of(dto.getPageNum() - 1, dto.getPageSize(), Sort.by("id").descending()); - Page page=jdbcOrderExceedStandardRepository.findAllByApplicantContainsAndCompanyNameContainsAndActualOrderNoContainsAndOrderNoContainsAndOrderNoIn(dto.getApplicant(), + Page page=jdbcOrderExceedStandardRepository.findAllByApplicantContainsAndDeptNameContainsAndActualOrderNoContainsAndOrderNoContains(dto.getApplicant(), dto.getCompanyName(), dto.getActualOrderNo(), dto.getOrderNo(), - orderNos, +// orderNos, pageRequest); - List excelList = getOrderExceedStandardExcels(page); return PageResult.totalPageNum(page.getTotalElements(), excelList); } @@ -128,10 +127,11 @@ public class ManageServiceImpl implements ManageService { @Override public PageResult itineraryPageQuery(ItineraryPageQuery dto) { //数据权限 - List routeIds=baseUtil.getRouteIds(); - if (routeIds==null||routeIds.isEmpty()) { - return PageResult.totalPageNum(0, new ArrayList<>()); - } +// List routeIds=baseUtil.getRouteIds(); +// if (routeIds==null||routeIds.isEmpty()) { +// return PageResult.totalPageNum(0, new ArrayList<>()); +// } +// dto.setRouteIds(routeIds); List users=new ArrayList<>(); if (!dto.getApplicant().isEmpty()){ @@ -140,7 +140,6 @@ public class ManageServiceImpl implements ManageService { return PageResult.totalPageNum(0, new ArrayList<>()); } } - dto.setRouteIds(routeIds); dto.setUserIds(users.stream().map(User::getEmployeeNo).toList()); Page page= jdbcConsumptionDetailRepository.itineraryPageQueryByDto(dto); //处理信息 @@ -180,11 +179,11 @@ public class ManageServiceImpl implements ManageService { @Override public PageResult orderPageQuery(OrderPageQuery dto) { //数据权限 - List dataRouteIds=baseUtil.getRouteIds(); - if (dataRouteIds==null||dataRouteIds.isEmpty()) { - return PageResult.totalPageNum(0, new ArrayList<>()); - } - dto.setRouteIds(dataRouteIds); +// List dataRouteIds=baseUtil.getRouteIds(); +// if (dataRouteIds==null||dataRouteIds.isEmpty()) { +// return PageResult.totalPageNum(0, new ArrayList<>()); +// } +// dto.setRouteIds(dataRouteIds); //预订人 if (!dto.getApplicant().equals("")){ @@ -212,7 +211,7 @@ public class ManageServiceImpl implements ManageService { } //部门 if (dto.getBelongDeptCode() != null && !dto.getBelongDeptCode().isEmpty()) { - List routeOrderExtensionFields = jdbcRouteOrderExtensionFieldRepository.findByBelongDeptCodeIn(dto.getBelongDeptCode()); + List routeOrderExtensionFields = jdbcRouteOrderExtensionFieldRepository.findByCondition(dto.getBelongDeptCode()); if (routeOrderExtensionFields == null || routeOrderExtensionFields.isEmpty()) { return PageResult.totalPageNum(0, new ArrayList<>()); } diff --git a/src/main/java/com/chint/manage/util/BaseUtil.java b/src/main/java/com/chint/manage/util/BaseUtil.java index 2bf5dffb..78c8160f 100644 --- a/src/main/java/com/chint/manage/util/BaseUtil.java +++ b/src/main/java/com/chint/manage/util/BaseUtil.java @@ -31,18 +31,18 @@ public class BaseUtil { public List getRouteIds(){ List list = BaseContext.getCurrentUser().loadRoleOrg().getRoleOrgList() .stream().filter(s->s.getOrgShortCode()!=null).map(SystemOrganizationVO::getOrgShortCode).toList(); - List result=jdbcRouteOrderExtensionFieldRepository.findByBelongDeptCodeIn(list); + List result=jdbcRouteOrderExtensionFieldRepository.findByCondition(list); return result.stream().map(RouteOrderExtensionField::getRouteId).toList(); } public List getOrderIds(){ List routeIds = getRouteIds(); - return jdbcOrderDetailRepository.findAllByRouteIdIn(routeIds).stream().map(OrderDetail::getOrderId).toList(); + return jdbcOrderDetailRepository.findAllOrderId(routeIds); } public List getOrderNos(){ List routeIds = getRouteIds(); - return jdbcOrderDetailRepository.findAllByRouteIdIn(routeIds).stream().map(OrderDetail::getOrderNo).toList(); + return jdbcOrderDetailRepository.findAllOrderNo(routeIds); } /** diff --git a/src/main/java/com/chint/manage/util/DataJdbcCreatorUtil.java b/src/main/java/com/chint/manage/util/DataJdbcCreatorUtil.java index 9c762592..558b52cf 100644 --- a/src/main/java/com/chint/manage/util/DataJdbcCreatorUtil.java +++ b/src/main/java/com/chint/manage/util/DataJdbcCreatorUtil.java @@ -39,7 +39,7 @@ public class DataJdbcCreatorUtil { */ private List getTables() throws SQLException { List tables = new ArrayList(); - tables.add("route_order_extension_field"); + tables.add("route_order"); return tables; } @@ -149,7 +149,7 @@ public class DataJdbcCreatorUtil { temp = tables[i].trim(); sb.append(temp.substring(0, 1).toUpperCase()).append(temp.substring(1)); } - beanName = sb.toString(); + beanName = sb.toString()+"Basic"; mapperName = "Jdbc"+beanName + "Repository"; _mapperName = shotFirst(mapperName); serviceName = beanName + "Service";