diff --git a/src/main/java/com/chint/application/queryies/OrderQuery.java b/src/main/java/com/chint/application/queryies/OrderQuery.java index 8cfc907b..d58a294a 100644 --- a/src/main/java/com/chint/application/queryies/OrderQuery.java +++ b/src/main/java/com/chint/application/queryies/OrderQuery.java @@ -35,7 +35,8 @@ import java.util.stream.Collectors; import java.util.stream.Stream; import static com.chint.infrastructure.constant.FSSCConstant.*; -import static com.chint.infrastructure.constant.LegConstant.*; +import static com.chint.infrastructure.constant.LegConstant.LEG_TYPE_HOTEL; +import static com.chint.infrastructure.constant.LegConstant.LEG_TYPE_OTHER; import static com.chint.infrastructure.constant.LocationConstant.LOCATION_LEVEL_CITY; import static com.chint.infrastructure.constant.LocationConstant.LOCATION_LEVEL_COUNTY; import static com.chint.infrastructure.constant.OrderConstant.ORDER_EVENT_CANCEL_NAME; @@ -138,11 +139,16 @@ public class OrderQuery { //根据系统标识进行筛选 routeOrders = sysCodeFilter(routeOrders, queryData.getSysCode()); + //将已结束的行程放到最后 + Comparator statusComparator = Comparator.comparing( + (RouteOrder order) -> order.getOrderStatus().equals(ORDER_STATUS_FINISH), + Comparator.reverseOrder() + ); int total = routeOrders.size(); List orders = routeOrders .stream() - .sorted(Comparator.comparing(RouteOrder::getUpdateTime).reversed()) + .sorted(statusComparator.thenComparing(RouteOrder::getUpdateTime).reversed()) .skip((long) (pageNum - 1) * pageSize) .limit(pageSize) .map(routeOrder -> { @@ -539,18 +545,24 @@ public class OrderQuery { public List queryNotSubmit(OrderQueryData queryData) { User currentUser = BaseContext.getCurrentUser(); - List routeOrders = routeRepository.findByActualOrderNoNotNull(queryData); + List routeOrders = routeRepository.findAllByEmployeeNo(currentUser.getEmployeeNo()); routeOrders = routeOrders.stream().filter(it -> it.getUserId().equals(currentUser.getEmployeeNo())).toList(); - routeOrders.forEach(route -> orderDomainService.queryLocation(route.getLegItems())); + routeOrders.forEach(route -> { + orderDomainService.queryLocation(route.getLegItems()); + orderDomainService.checkRouteOrderStatus(route); + }); Stream stream = routeOrders.stream(); if (queryData.getSupplierName() != null) { stream = stream - .filter(it-> it.getRouteRequestList() + .filter(it -> it.getRouteRequestList() == null || it.getRouteRequestList().isEmpty() || + it.getRouteRequestList() .stream() .anyMatch(routeRequest -> !routeRequest.getSupplier().equals(queryData.getSupplierName()))); } return stream - .filter(order -> order.reloadStatus().getOrderStatus().equals(ORDER_STATUS_APPROVAL)) + .filter(order -> order.getApproveOrderNo() != null && order.getApproveOrderNo().getActualOrderNo() != null) + .filter(order -> order.getOrderStatus().equals(ORDER_STATUS_APPROVAL)) + .sorted(Comparator.comparing(RouteOrder::getUpdateTime).reversed()) .map(order -> { User user = userRepository.findByUserEmployeeNo(order.getUserId()); return getRouteOrderPageRes(order, user); diff --git a/src/main/java/com/chint/domain/service/OrderDomainService.java b/src/main/java/com/chint/domain/service/OrderDomainService.java index beb7f3e3..47b4633d 100644 --- a/src/main/java/com/chint/domain/service/OrderDomainService.java +++ b/src/main/java/com/chint/domain/service/OrderDomainService.java @@ -149,7 +149,6 @@ public class OrderDomainService { if (leg.getDestinationId() != null) { leg.setDestinationLocation(locationRepository.findByLocationId(leg.getDestinationId())); } - }); return list; } @@ -450,4 +449,11 @@ public class OrderDomainService { } } + public RouteOrder checkRouteOrderStatus(RouteOrder routeOrder) { + if(routeOrder.getOrderStatus() == null ) { + routeOrder.reloadStatus(); + routeRepository.save(routeOrder); + } + return routeOrder; + } } diff --git a/src/main/java/com/chint/domain/service/SystemDomainService.java b/src/main/java/com/chint/domain/service/SystemDomainService.java index b4b5ef2b..7d525c36 100644 --- a/src/main/java/com/chint/domain/service/SystemDomainService.java +++ b/src/main/java/com/chint/domain/service/SystemDomainService.java @@ -46,4 +46,5 @@ public class SystemDomainService { .map(AccountCompany::getCompanyName) .findFirst(); } + } diff --git a/src/test/java/com/chint/RouteApplicationTests.java b/src/test/java/com/chint/RouteApplicationTests.java index 4c83f326..96d12a29 100644 --- a/src/test/java/com/chint/RouteApplicationTests.java +++ b/src/test/java/com/chint/RouteApplicationTests.java @@ -16,6 +16,7 @@ import com.chint.domain.aggregates.user.User; import com.chint.domain.repository.*; import com.chint.domain.service.JTCompanyDomainService; import com.chint.domain.service.OrderDomainService; +import com.chint.domain.service.SystemDomainService; import com.chint.domain.service.order_sync.LYOrderSyncAdapter; import com.chint.domain.value_object.RanksData; import com.chint.infrastructure.repository.CTripOrderDetailImpl; @@ -149,6 +150,10 @@ class RouteApplicationTests { @Autowired private OrderDomainService orderDomainService; + @Autowired + private SystemDomainService systemDomainService; + + void test3() { FlyOkDTO freightDTO = new FlyOkDTO(); ParamFly param = new ParamFly(); @@ -1271,4 +1276,9 @@ class RouteApplicationTests { } System.out.println(receiptsNum); } + @Test + void testS(){ + Optional s = systemDomainService.companyNameByAccountId(null); + s.ifPresent(System.out::println); + } }