From 196f5b07f70e1091ad55cc8882d2c6decd288024 Mon Sep 17 00:00:00 2001 From: lulz1 Date: Wed, 29 May 2024 16:14:43 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E4=BF=AE=E5=A4=8D=E9=83=A8=E9=97=A8?= =?UTF-8?q?=E9=97=AE=E9=A2=98=E5=AF=BC=E8=87=B4=E9=AB=98=E5=BE=B7=E6=B6=88?= =?UTF-8?q?=E8=B4=B9=E6=98=8E=E7=BB=86=E6=8E=A8=E9=80=81=E5=A4=B1=E8=B4=A5?= =?UTF-8?q?=E7=9A=84bug=EF=BC=8C=E5=AE=8C=E5=96=84=E6=9F=A5=E8=AF=A2?= =?UTF-8?q?=E6=9C=AA=E6=8F=90=E4=BB=B7=E8=AE=A2=E5=8D=95=E7=9A=84=E5=8A=9F?= =?UTF-8?q?=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../application/queryies/OrderQuery.java | 23 ++++++++++++++++--- .../aggregates/supplier/SupplierProduct.java | 4 ++++ .../aggregates/user/UserDepartmentInfo.java | 16 ++++++------- 3 files changed, 32 insertions(+), 11 deletions(-) diff --git a/src/main/java/com/chint/application/queryies/OrderQuery.java b/src/main/java/com/chint/application/queryies/OrderQuery.java index d1d27528..99e9ef14 100644 --- a/src/main/java/com/chint/application/queryies/OrderQuery.java +++ b/src/main/java/com/chint/application/queryies/OrderQuery.java @@ -2,14 +2,16 @@ package com.chint.application.queryies; import cn.hutool.core.bean.BeanUtil; import com.chint.application.dtos.RoutOrderFieldParam; +import com.chint.application.dtos.mapper.RouteOrderMapper; import com.chint.application.dtos.response.*; import com.chint.application.dtos.trip.*; -import com.chint.application.dtos.mapper.RouteOrderMapper; import com.chint.application.queryies.estimate.EstimatePrice; import com.chint.domain.aggregates.location.basedata.CountryLevelInfoEntity; import com.chint.domain.aggregates.location.basedata.DistrictPOIInfoEntity; import com.chint.domain.aggregates.location.basedata.PrefectureLevelCityInfoEntity; import com.chint.domain.aggregates.order.*; +import com.chint.domain.aggregates.supplier.Supplier; +import com.chint.domain.aggregates.supplier.SupplierProduct; import com.chint.domain.aggregates.user.User; import com.chint.domain.exceptions.NotFoundException; import com.chint.domain.repository.*; @@ -89,6 +91,9 @@ public class OrderQuery { @Autowired private LocationRepository locationRepository; + @Autowired + private SupplierRepository supplierRepository; + public RouteOrder queryByOrderId(OrderQueryData queryData) { return routeRepository.queryById(queryData.getRouteId()).reloadStatus(); } @@ -511,6 +516,7 @@ public class OrderQuery { } public List queryNotSubmit(OrderQueryData queryData) { + String supplierName = queryData.getSupplierName(); User currentUser = BaseContext.getCurrentUser(); List routeOrders = routeRepository.findAllByEmployeeNo(currentUser.getEmployeeNo()); routeOrders = routeOrders.stream().filter(it -> it.getUserId().equals(currentUser.getEmployeeNo())).toList(); @@ -519,13 +525,23 @@ public class OrderQuery { orderDomainService.checkRouteOrderStatus(route); }); Stream stream = routeOrders.stream(); - if (queryData.getSupplierName() != null) { + if (supplierName != null) { stream = stream .filter(it -> it.getRouteRequestList() == null || it.getRouteRequestList().isEmpty() || it.getRouteRequestList() .stream() - .noneMatch(routeRequest -> routeRequest.getSupplier().equals(queryData.getSupplierName()))); + .noneMatch(routeRequest -> routeRequest.getSupplier().equals(supplierName))); } + Optional supplierOptional = supplierRepository.findBySupplierName(supplierName); + if (supplierOptional.isEmpty()) { + throw new NotFoundException("错误的供应商,请联系管理员"); + } + Supplier supplier = supplierOptional.get(); + List allowSupplierProductList = supplier.getSupplierProductList() + .stream() + .filter(SupplierProduct::ifCanOrder) + .map(SupplierProduct::getProductType) + .toList(); return stream .filter(order -> order.getApprovalStatus() != null) .filter(order -> !order.getOrderStatus().equals(ORDER_STATUS_FINISH) && @@ -535,6 +551,7 @@ public class OrderQuery { !order.getLegItems().isEmpty() && order.getLegItems().stream().anyMatch(leg -> !leg.getLegType().equals(LEG_TYPE_OTHER))) .filter(order -> order.getSupplierName() == null) + .filter(order -> order.getLegItems().stream().map(Leg::getLegType).anyMatch(allowSupplierProductList::contains)) //判断有无允许预订的商品 .sorted(Comparator.comparing(RouteOrder::getUpdateTime).reversed()) .map(order -> { User user = userRepository.findByUserEmployeeNo(order.getUserId()); diff --git a/src/main/java/com/chint/domain/aggregates/supplier/SupplierProduct.java b/src/main/java/com/chint/domain/aggregates/supplier/SupplierProduct.java index 65d13b63..0babe7ad 100644 --- a/src/main/java/com/chint/domain/aggregates/supplier/SupplierProduct.java +++ b/src/main/java/com/chint/domain/aggregates/supplier/SupplierProduct.java @@ -24,4 +24,8 @@ public class SupplierProduct implements Serializable { private String ifCanCancelRule; @MappedCollection(idColumn = "supplier_product_id", keyColumn = "supplier_product_key") private List supplierProductStandardLevelList; + + public boolean ifCanOrder() { + return ifCanOrder == 1; + } } diff --git a/src/main/java/com/chint/domain/aggregates/user/UserDepartmentInfo.java b/src/main/java/com/chint/domain/aggregates/user/UserDepartmentInfo.java index 9621142f..326be616 100644 --- a/src/main/java/com/chint/domain/aggregates/user/UserDepartmentInfo.java +++ b/src/main/java/com/chint/domain/aggregates/user/UserDepartmentInfo.java @@ -255,13 +255,13 @@ public class UserDepartmentInfo implements Serializable { } public boolean checkIfIn(String orgShortCode) { - return this.companyCode.contains(orgShortCode) || - this.departmentCodeOne.contains(orgShortCode) || - this.departmentCodeTwo.contains(orgShortCode) || - this.departmentCodeThree.contains(orgShortCode) || - this.departmentCodeFour.contains(orgShortCode) || - this.departmentCodeFive.contains(orgShortCode) || - this.departmentCodeSix.contains(orgShortCode) || - this.departmentCodeSeven.contains(orgShortCode); + return (this.companyCode != null && this.companyCode.contains(orgShortCode)) || + (this.departmentCodeOne != null && this.departmentCodeOne.contains(orgShortCode)) || + (this.departmentCodeTwo != null && this.departmentCodeTwo.contains(orgShortCode)) || + (this.departmentCodeThree != null && this.departmentCodeThree.contains(orgShortCode)) || + (this.departmentCodeFour != null && this.departmentCodeFour.contains(orgShortCode)) || + (this.departmentCodeFive != null && this.departmentCodeFive.contains(orgShortCode)) || + (this.departmentCodeSix != null && this.departmentCodeSix.contains(orgShortCode)) || + (this.departmentCodeSeven != null && this.departmentCodeSeven.contains(orgShortCode)); } }