From 8fedb6d6edc7639240dfc6a57e83530b70c52d19 Mon Sep 17 00:00:00 2001 From: rcx <3084692334@qq.com> Date: Thu, 20 Aug 2026 17:54:23 +0800 Subject: [PATCH] =?UTF-8?q?feat(oms):=E5=BA=93=E5=AD=98=E6=9F=A5=E8=AF=A2/?= =?UTF-8?q?=E5=AF=BC=E5=87=BA=E6=8C=89=E5=95=86=E5=93=81=E5=88=B0=E6=9C=9F?= =?UTF-8?q?=E6=97=A5=E5=88=86=E7=BB=84=E6=8E=92=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ReservationMaterialInventoryApi.java | 12 +++--------- .../MaterialInventoryMapper.xml | 6 +++++- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/mhd_oms/src/main/java/com/mhd/oms/interfaces/facade/reservationMaterialInventory/ReservationMaterialInventoryApi.java b/mhd_oms/src/main/java/com/mhd/oms/interfaces/facade/reservationMaterialInventory/ReservationMaterialInventoryApi.java index f21b4f593..80282b72b 100644 --- a/mhd_oms/src/main/java/com/mhd/oms/interfaces/facade/reservationMaterialInventory/ReservationMaterialInventoryApi.java +++ b/mhd_oms/src/main/java/com/mhd/oms/interfaces/facade/reservationMaterialInventory/ReservationMaterialInventoryApi.java @@ -84,16 +84,10 @@ public class ReservationMaterialInventoryApi extends BaseController { materialInventoryDO.setExpiryDateEnd(expiryDateEnd); startPage(); // 使用带批次属性的查询方法,批次属性值从库存表中获取 + // 排序由 SQL 统一处理:到期日倒序(日期近的在前、空值最后)、同到期日按更新时间倒序(空值最后), + // 查询列表与导出(同一接口)均按到期日分组,相同到期日的数据相邻显示; + // 不在内存重排,避免覆盖 SQL 排序导致跨页分组被打散 List list = materialInventoryApplicationService.queryListWithBatchAttributes(materialInventoryDO); - // 按更新时间倒序排序;update_time 为空的数据放最后 - list.sort((o1, o2) -> { - Date t1 = o1.getUpdateTime(); - Date t2 = o2.getUpdateTime(); - if (t1 == null && t2 == null) return 0; - if (t1 == null) return 1; - if (t2 == null) return -1; - return t2.compareTo(t1); // desc - }); TableDataInfo tableDataInfo = getDataTable(list); return tableDataInfo; } diff --git a/mhd_oms/src/main/resources/mapper/reservationMaterialInventory/MaterialInventoryMapper.xml b/mhd_oms/src/main/resources/mapper/reservationMaterialInventory/MaterialInventoryMapper.xml index 8e11d236b..ce58f8970 100644 --- a/mhd_oms/src/main/resources/mapper/reservationMaterialInventory/MaterialInventoryMapper.xml +++ b/mhd_oms/src/main/resources/mapper/reservationMaterialInventory/MaterialInventoryMapper.xml @@ -292,7 +292,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - group by a.MATERIAL_INVENTORY_ID order by a.update_time desc + group by a.MATERIAL_INVENTORY_ID + + order by CASE WHEN a.expiry_date IS NULL THEN 1 ELSE 0 END ASC, a.expiry_date DESC, + CASE WHEN a.update_time IS NULL THEN 1 ELSE 0 END ASC, a.update_time DESC