feat(oms):库存查询/导出按商品到期日分组排序
This commit is contained in:
+3
-9
@@ -84,16 +84,10 @@ public class ReservationMaterialInventoryApi extends BaseController {
|
||||
materialInventoryDO.setExpiryDateEnd(expiryDateEnd);
|
||||
startPage();
|
||||
// 使用带批次属性的查询方法,批次属性值从库存表中获取
|
||||
// 排序由 SQL 统一处理:到期日倒序(日期近的在前、空值最后)、同到期日按更新时间倒序(空值最后),
|
||||
// 查询列表与导出(同一接口)均按到期日分组,相同到期日的数据相邻显示;
|
||||
// 不在内存重排,避免覆盖 SQL 排序导致跨页分组被打散
|
||||
List<ReservationMaterialInventoryPO> 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;
|
||||
}
|
||||
|
||||
+5
-1
@@ -292,7 +292,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<include refid="selectMaterialInventoryPo1"/>
|
||||
<include refid="JoinMaterialBaseInfoPoWhere"/>
|
||||
</where>
|
||||
group by a.MATERIAL_INVENTORY_ID order by a.update_time desc
|
||||
group by a.MATERIAL_INVENTORY_ID
|
||||
<!-- 按到期日分组归类:到期日倒序(日期近的在前)、空值放最后;同到期日按更新时间倒序(空值放最后)。
|
||||
查询列表与导出共用本查询,相同到期日的数据相邻显示;排序放 SQL 层保证跨页/全量导出分组不被打散 -->
|
||||
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
|
||||
</select>
|
||||
|
||||
<select id="queryListByWlKw" parameterType="com.mhd.oms.domain.reservationMaterialInventory.repository.todo.ReservationMaterialInventoryDO" resultMap="MaterialInventoryResult">
|
||||
|
||||
Reference in New Issue
Block a user