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 368e903e..ea8c593a 100644 --- a/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcOrderDetailRepository.java +++ b/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcOrderDetailRepository.java @@ -37,9 +37,8 @@ public interface JdbcOrderDetailRepository extends CrudRepository listByCondition(@Param("dto") OrderPageQuery dto, @Param("pageRequest")PageRequest pageRequest); @Query("SELECT COUNT(*) FROM order_detail " + - "WHERE 1=1 " + + "WHERE route_id IN (:#{#dto.routeIds}) " + "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}) "+ "AND (:#{#dto.employeeNo} ='' OR employee_no = :#{#dto.employeeNo}) "+ diff --git a/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcUserRepository.java b/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcUserRepository.java index 19b0e397..40a86a59 100644 --- a/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcUserRepository.java +++ b/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcUserRepository.java @@ -19,4 +19,6 @@ public interface JdbcUserRepository extends CrudRepository { List findAllByNameContains(String name); Page findAllByNameContainsAndEmployeeNoContains(String name, String employeeNo, Pageable pageable); + + List findAllByEmployeeNoIn(List employeeNos); } diff --git a/src/main/java/com/chint/manage/entity/excel/OrderPageExcel.java b/src/main/java/com/chint/manage/entity/excel/OrderPageExcel.java index 8c515466..cfe13e9a 100644 --- a/src/main/java/com/chint/manage/entity/excel/OrderPageExcel.java +++ b/src/main/java/com/chint/manage/entity/excel/OrderPageExcel.java @@ -23,8 +23,10 @@ public class OrderPageExcel extends BaseExcel { private String status; @ExcelProperty("订单状态") private String statusName; - @ExcelProperty("预订人") + @ExcelIgnore private String supplierName; + @ExcelProperty("预订人") + private String applicant; @ExcelIgnore private Integer productType; @ExcelProperty("订单类型") 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 b965caca..f65a133b 100644 --- a/src/main/java/com/chint/manage/entity/query/OrderPageQuery.java +++ b/src/main/java/com/chint/manage/entity/query/OrderPageQuery.java @@ -29,12 +29,4 @@ public class OrderPageQuery extends BaseQuery { private List employeeNos=null; private List routeIds=null; - - public String getOrderNo() { - return "%" +orderNo+"%"; - } - - public String getApplicant(){ - return "%" +applicant+"%"; - } } 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 2181ac2f..fa8ea10a 100644 --- a/src/main/java/com/chint/manage/service/impl/ManageServiceImpl.java +++ b/src/main/java/com/chint/manage/service/impl/ManageServiceImpl.java @@ -176,31 +176,54 @@ public class ManageServiceImpl implements ManageService { return PageResult.totalPageNum(0, new ArrayList<>()); } dto.setRouteIds(dataRouteIds); + + //预订人 todo 预订人查询还有点问题 + if (!dto.getApplicant().equals("")){ + List users=jdbcUserRepository.findAllByNameContains(dto.getApplicant()); + if (users==null||users.isEmpty()) { + return PageResult.totalPageNum(0, new ArrayList<>()); + } + dto.setEmployeeNos(users.stream().map(User::getEmployeeNo).toList()); + } + //行程号 - if (!dto.getRouteOrderNo().isEmpty()){ - List routeOrders=jdbcRouteRepository.findAllByRouteOrderNoContains(dto.getRouteOrderNo()); + if (!dto.getRouteOrderNo().isEmpty()) { + List routeOrders = jdbcRouteRepository.findAllByRouteOrderNoContains(dto.getRouteOrderNo()); if (routeOrders == null || routeOrders.isEmpty()) { return PageResult.totalPageNum(0, new ArrayList<>()); } - if (dto.getRouteIds()==null){ - dto.setRouteIds(routeOrders.stream().map(RouteOrder::getRouteId).toList()); - }else { - List 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 routeOrderExtensionFields=jdbcRouteOrderExtensionFieldRepository.findByBelongDeptCodeIn(dto.getBelongDeptCode()); - if (routeOrderExtensionFields==null||routeOrderExtensionFields.isEmpty()) { + List routeOrderIds = routeOrders.stream().map(RouteOrder::getRouteId).collect(Collectors.toList()); + List updatedRouteIds = dto.getRouteIds() == null + ? routeOrderIds + : dto.getRouteIds().stream().filter(routeOrderIds::contains).collect(Collectors.toList()); + if (updatedRouteIds.isEmpty()) { return PageResult.totalPageNum(0, new ArrayList<>()); } - if (dto.getRouteIds()==null){ - dto.setRouteIds(routeOrderExtensionFields.stream().map(RouteOrderExtensionField::getRouteId).toList()); - }else { - List AnB = dto.getRouteIds().stream().filter(routeOrderExtensionFields.stream().map(RouteOrderExtensionField::getRouteId).toList()::contains).collect(Collectors.toList()); - dto.setRouteIds(AnB); + dto.setRouteIds(updatedRouteIds); + } + //部门 + if (dto.getBelongDeptCode() != null && !dto.getBelongDeptCode().isEmpty()) { + List routeOrderExtensionFields = jdbcRouteOrderExtensionFieldRepository.findByBelongDeptCodeIn(dto.getBelongDeptCode()); + if (routeOrderExtensionFields == null || routeOrderExtensionFields.isEmpty()) { + return PageResult.totalPageNum(0, new ArrayList<>()); } + List routeOrderExtensionFieldIds = routeOrderExtensionFields.stream() + .map(RouteOrderExtensionField::getRouteId) + .collect(Collectors.toList()); + List updatedRouteIds = dto.getRouteIds() == null + ? routeOrderExtensionFieldIds + : dto.getRouteIds().stream().filter(routeOrderExtensionFieldIds::contains).collect(Collectors.toList()); + if (updatedRouteIds.isEmpty()) { + return PageResult.totalPageNum(0, new ArrayList<>()); + } + dto.setRouteIds(updatedRouteIds); + } + //设置全模糊 + if (!dto.getOrderNo().equals("")){ + dto.setOrderNo("%"+dto.getOrderNo()+"%"); + } + if (!dto.getApplicant().equals("")){ + dto.setApplicant("%"+dto.getApplicant()+"%"); } List list=jdbcOrderDetailRepository.listByCondition(dto,dto.getPageResult()); @@ -227,6 +250,8 @@ public class ManageServiceImpl implements ManageService { routeIds=routeIds.stream().distinct().filter(Objects::nonNull).collect(Collectors.toList()); List routeOrders=jdbcRouteRepository.findByRouteIdIn(routeIds); + List users=jdbcUserRepository.findAllByEmployeeNoIn(list.stream().map(OrderDetail::getEmployeeNo).collect(Collectors.toList())); + List result = list.stream().map(temp -> { OrderPageExcel obj = orderPageDtoMap.get(temp.getOrderId()); if (obj==null){ @@ -237,12 +262,16 @@ public class ManageServiceImpl implements ManageService { List origin=locations.stream().filter(s->s.getLocationId().equals(finalObj.getOriginId())).toList(); List destination=locations.stream().filter(s->s.getLocationId().equals(finalObj.getDestinationId())).toList(); + List user=users.stream().filter(s->s.getEmployeeNo().equals(finalObj.getEmployeeNo())).toList(); if (!origin.isEmpty()){ finalObj.setOriginName(origin.get(0).getLocationName()); } if (!destination.isEmpty()){ finalObj.setDestinationName(destination.get(0).getLocationName()); } + if (!user.isEmpty()){ + finalObj.setApplicant(user.get(0).getName()); + } List orders=routeOrders.stream().filter(s->s.getRouteId().equals(finalObj.getRouteId())).toList(); if (!orders.isEmpty()) { finalObj.setRouteOrderNo(orders.get(0).getRouteOrderNo());