【fix】订单分页查询行程号、预订人问题修复

This commit is contained in:
nixj 2024-06-18 16:53:16 +08:00
parent 6592f244ef
commit 832144c773
5 changed files with 54 additions and 31 deletions

View File

@ -37,9 +37,8 @@ public interface JdbcOrderDetailRepository extends CrudRepository<OrderDetail, L
@Query("SELECT * 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}) " +
@ -48,9 +47,8 @@ public interface JdbcOrderDetailRepository extends CrudRepository<OrderDetail, L
List<OrderDetail> 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}) "+

View File

@ -19,4 +19,6 @@ public interface JdbcUserRepository extends CrudRepository<User, Long> {
List<User> findAllByNameContains(String name);
Page<User> findAllByNameContainsAndEmployeeNoContains(String name, String employeeNo, Pageable pageable);
List<User> findAllByEmployeeNoIn(List<String> employeeNos);
}

View File

@ -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("订单类型")

View File

@ -29,12 +29,4 @@ public class OrderPageQuery extends BaseQuery {
private List<String> employeeNos=null;
private List<Long> routeIds=null;
public String getOrderNo() {
return "%" +orderNo+"%";
}
public String getApplicant(){
return "%" +applicant+"%";
}
}

View File

@ -176,18 +176,30 @@ public class ManageServiceImpl implements ManageService {
return PageResult.totalPageNum(0, new ArrayList<>());
}
dto.setRouteIds(dataRouteIds);
//预订人 todo 预订人查询还有点问题
if (!dto.getApplicant().equals("")){
List<User> 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<RouteOrder> 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<Long> AnB = dto.getRouteIds().stream().filter(routeOrders.stream().map(RouteOrder::getRouteId).toList()::contains).collect(Collectors.toList());
dto.setRouteIds(AnB);
List<Long> routeOrderIds = routeOrders.stream().map(RouteOrder::getRouteId).collect(Collectors.toList());
List<Long> updatedRouteIds = dto.getRouteIds() == null
? routeOrderIds
: dto.getRouteIds().stream().filter(routeOrderIds::contains).collect(Collectors.toList());
if (updatedRouteIds.isEmpty()) {
return PageResult.totalPageNum(0, new ArrayList<>());
}
dto.setRouteIds(updatedRouteIds);
}
//部门
if (dto.getBelongDeptCode() != null && !dto.getBelongDeptCode().isEmpty()) {
@ -195,12 +207,23 @@ public class ManageServiceImpl implements ManageService {
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<Long> routeOrderExtensionFieldIds = routeOrderExtensionFields.stream()
.map(RouteOrderExtensionField::getRouteId)
.collect(Collectors.toList());
List<Long> 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<OrderDetail> 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<RouteOrder> routeOrders=jdbcRouteRepository.findByRouteIdIn(routeIds);
List<User> users=jdbcUserRepository.findAllByEmployeeNoIn(list.stream().map(OrderDetail::getEmployeeNo).collect(Collectors.toList()));
List<OrderPageExcel> result = list.stream().map(temp -> {
OrderPageExcel obj = orderPageDtoMap.get(temp.getOrderId());
if (obj==null){
@ -237,12 +262,16 @@ public class ManageServiceImpl implements ManageService {
List<Location> origin=locations.stream().filter(s->s.getLocationId().equals(finalObj.getOriginId())).toList();
List<Location> destination=locations.stream().filter(s->s.getLocationId().equals(finalObj.getDestinationId())).toList();
List<User> 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<RouteOrder> orders=routeOrders.stream().filter(s->s.getRouteId().equals(finalObj.getRouteId())).toList();
if (!orders.isEmpty()) {
finalObj.setRouteOrderNo(orders.get(0).getRouteOrderNo());