From ec9a797ad250f04d988ad59582c4e14f2f74ce99 Mon Sep 17 00:00:00 2001 From: lulz1 Date: Fri, 23 Feb 2024 09:04:18 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AE=A2=E5=8D=95=E5=88=86=E9=A1=B5=E6=9F=A5?= =?UTF-8?q?=E8=AF=A2=E5=A2=9E=E5=8A=A0=E6=96=B0=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../application/queryies/OrderQuery.java | 27 +++++++++++++++---- .../domain/repository/RouteRepository.java | 3 +++ .../domain/value_object/OrderQueryData.java | 1 + .../repository/RouteRepositoryImpl.java | 9 +++++++ .../repository/jdbc/JdbcRouteRepository.java | 2 ++ 5 files changed, 37 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/chint/application/queryies/OrderQuery.java b/src/main/java/com/chint/application/queryies/OrderQuery.java index ea82618b..8720d361 100644 --- a/src/main/java/com/chint/application/queryies/OrderQuery.java +++ b/src/main/java/com/chint/application/queryies/OrderQuery.java @@ -58,16 +58,17 @@ public class OrderQuery { //执行筛选分页查询 List approvalStatusCodes = queryData.getApprovalStatusCodes(); List legTypes = queryData.getLegTypes(); - if (!approvalStatusCodes.isEmpty() || !legTypes.isEmpty()) { + if ((approvalStatusCodes != null && !approvalStatusCodes.isEmpty()) || (legTypes != null && !legTypes.isEmpty())) { Integer pageNum = queryData.getPageNum(); Integer pageSize = queryData.getPageSize(); List routeOrders = routeRepository.findByActualOrderNoNotNull(); - if (!approvalStatusCodes.isEmpty()) { + routeOrders.forEach(RouteOrder::reloadStatus); + if (approvalStatusCodes != null && !approvalStatusCodes.isEmpty()) { routeOrders = routeOrders.stream() .filter(routeOrder -> approvalStatusCodes.contains(routeOrder.getApprovalStatusCode())) .toList(); } - if (!legTypes.isEmpty()) { + if (legTypes != null && !legTypes.isEmpty()) { routeOrders = routeOrders.stream() .filter(routeOrder -> { List list = new ArrayList<>(routeOrder.getLegItems().stream().map(Leg::getLegType).toList()); @@ -85,16 +86,32 @@ public class OrderQuery { return new PageResult<>(total, orders); } + //根据订单编号事项进行模糊匹配查询 if (queryData.getOrderNo() != null) { Page byOrderNoFuzzy = routeRepository.findByOrderNoFuzzy(queryData); + List content = byOrderNoFuzzy.getContent(); + content.forEach(RouteOrder::reloadStatus); return new PageResult<>(byOrderNoFuzzy.getTotalElements(), - byOrderNoFuzzy - .getContent() + content .stream() .map(OrderQuery::getRouteOrderPageRes) .toList()); } + //根据出差说明进行模糊匹配查询 + if(queryData.getInstructions() != null){ + Page byInstructions = routeRepository.findByInstructions(queryData); + List content = byInstructions.getContent(); + content.forEach(RouteOrder::reloadStatus); + content.forEach(RouteOrder::reloadStatus); + return new PageResult<>(byInstructions.getTotalElements(), + content + .stream() + .map(OrderQuery::getRouteOrderPageRes) + .toList()); + } + + //执行普通分页查询 PageResult routeOrderPageResult = routeRepository.pageQuery(queryData); diff --git a/src/main/java/com/chint/domain/repository/RouteRepository.java b/src/main/java/com/chint/domain/repository/RouteRepository.java index 83f24a96..58115232 100644 --- a/src/main/java/com/chint/domain/repository/RouteRepository.java +++ b/src/main/java/com/chint/domain/repository/RouteRepository.java @@ -16,9 +16,12 @@ public interface RouteRepository { RouteOrder findByActualOrderNoAndSysCode(String actualOrderNo,String sysCode); + + RouteOrder findByOrderNo(String orderNo); Page findByOrderNoFuzzy(OrderQueryData orderQueryData); + Page findByInstructions(OrderQueryData orderQueryData); RouteOrder save(RouteOrder routeOrder); diff --git a/src/main/java/com/chint/domain/value_object/OrderQueryData.java b/src/main/java/com/chint/domain/value_object/OrderQueryData.java index b4311b16..b9c83034 100644 --- a/src/main/java/com/chint/domain/value_object/OrderQueryData.java +++ b/src/main/java/com/chint/domain/value_object/OrderQueryData.java @@ -15,4 +15,5 @@ public class OrderQueryData extends BaseQuery { private List approvalStatusCodes; private List legTypes; private String orderNo; + private String instructions; } diff --git a/src/main/java/com/chint/infrastructure/repository/RouteRepositoryImpl.java b/src/main/java/com/chint/infrastructure/repository/RouteRepositoryImpl.java index 318e44be..37e68089 100644 --- a/src/main/java/com/chint/infrastructure/repository/RouteRepositoryImpl.java +++ b/src/main/java/com/chint/infrastructure/repository/RouteRepositoryImpl.java @@ -57,6 +57,15 @@ public class RouteRepositoryImpl implements RouteRepository { , orderQueryData.getOrderNo(), sort); } + @Override + public Page findByInstructions(OrderQueryData orderQueryData) { + PageRequest sort = PageRequest + .of(orderQueryData.getPageNum() - 1, orderQueryData.getPageSize(), Sort.by("sort")); + User currentUser = BaseContext.getCurrentUser(); + return jdbcRouteRepository.findByCreateUserAndApproveOrderNo_InstructionsContaining(currentUser.getUserId().toString(), + orderQueryData.getInstructions(),sort); + } + @Override public RouteOrder save(RouteOrder routeOrder) { return jdbcRouteRepository.save(routeOrder); diff --git a/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcRouteRepository.java b/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcRouteRepository.java index e029e386..1031219e 100644 --- a/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcRouteRepository.java +++ b/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcRouteRepository.java @@ -18,6 +18,8 @@ public interface JdbcRouteRepository extends CrudRepository { RouteOrder findByApproveOrderNo_FakeOrderNoAndApproveOrderNo_SysCode(String approveOrderNo_fakeOrderNo, String sysCode); + Page findByCreateUserAndApproveOrderNo_InstructionsContaining(String createUser, String approveOrderNo_instructions, Pageable pageable); + RouteOrder findByApproveOrderNo_ActualOrderNoAndApproveOrderNo_SysCode(String approveOrderNo_actualOrderNo, String approveOrderNo_sysCode); RouteOrder findByRouteOrderNo(String routeOrderNo);