From 04ba946e9fe350d3dfdc2ba26d4a05478ddd2e6a Mon Sep 17 00:00:00 2001 From: lulz1 Date: Sat, 20 Apr 2024 20:18:34 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E5=88=86=E9=A1=B5=E6=8E=92=E5=BA=8F?= =?UTF-8?q?=E5=B0=86=E5=B7=B2=E7=BB=93=E6=9D=9F=E7=9A=84=E8=AE=A2=E5=8D=95?= =?UTF-8?q?=E6=94=BE=E5=88=B0=E6=9C=80=E5=90=8E=EF=BC=8C=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E6=9C=AA=E6=8F=90=E4=BA=A4=E5=AE=A1=E6=89=B9=E7=9A=84=E8=AE=A2?= =?UTF-8?q?=E5=8D=95=E6=9F=A5=E8=AF=A2=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../application/queryies/OrderQuery.java | 24 ++++++++++++++----- .../domain/service/OrderDomainService.java | 8 ++++++- .../domain/service/SystemDomainService.java | 1 + .../java/com/chint/RouteApplicationTests.java | 10 ++++++++ 4 files changed, 36 insertions(+), 7 deletions(-) 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); + } }