订单分页查询增加新参数

This commit is contained in:
lulz1 2024-02-23 09:04:18 +08:00
parent 44c7cb1845
commit ec9a797ad2
5 changed files with 37 additions and 5 deletions

View File

@ -58,16 +58,17 @@ public class OrderQuery {
//执行筛选分页查询
List<Integer> approvalStatusCodes = queryData.getApprovalStatusCodes();
List<Integer> 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<RouteOrder> 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<Integer> 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<RouteOrder> byOrderNoFuzzy = routeRepository.findByOrderNoFuzzy(queryData);
List<RouteOrder> 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<RouteOrder> byInstructions = routeRepository.findByInstructions(queryData);
List<RouteOrder> content = byInstructions.getContent();
content.forEach(RouteOrder::reloadStatus);
content.forEach(RouteOrder::reloadStatus);
return new PageResult<>(byInstructions.getTotalElements(),
content
.stream()
.map(OrderQuery::getRouteOrderPageRes)
.toList());
}
//执行普通分页查询
PageResult<RouteOrder> routeOrderPageResult = routeRepository.pageQuery(queryData);

View File

@ -16,9 +16,12 @@ public interface RouteRepository {
RouteOrder findByActualOrderNoAndSysCode(String actualOrderNo,String sysCode);
RouteOrder findByOrderNo(String orderNo);
Page<RouteOrder> findByOrderNoFuzzy(OrderQueryData orderQueryData);
Page<RouteOrder> findByInstructions(OrderQueryData orderQueryData);
RouteOrder save(RouteOrder routeOrder);

View File

@ -15,4 +15,5 @@ public class OrderQueryData extends BaseQuery {
private List<Integer> approvalStatusCodes;
private List<Integer> legTypes;
private String orderNo;
private String instructions;
}

View File

@ -57,6 +57,15 @@ public class RouteRepositoryImpl implements RouteRepository {
, orderQueryData.getOrderNo(), sort);
}
@Override
public Page<RouteOrder> 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);

View File

@ -18,6 +18,8 @@ public interface JdbcRouteRepository extends CrudRepository<RouteOrder, Long> {
RouteOrder findByApproveOrderNo_FakeOrderNoAndApproveOrderNo_SysCode(String approveOrderNo_fakeOrderNo, String sysCode);
Page<RouteOrder> findByCreateUserAndApproveOrderNo_InstructionsContaining(String createUser, String approveOrderNo_instructions, Pageable pageable);
RouteOrder findByApproveOrderNo_ActualOrderNoAndApproveOrderNo_SysCode(String approveOrderNo_actualOrderNo, String approveOrderNo_sysCode);
RouteOrder findByRouteOrderNo(String routeOrderNo);