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);