feat(oms,wms):库存导出按到期日分组排序并合并同物料同到期日库存(仅wlExpiry查询生效)
需求:库存查询导出按商品到期日分组归类、相同到期日相邻显示,相同物料相同 到期日合并库存。仅在 queryRule=wlExpiry(物料+到期日汇总查询)导出时生效, 列表显示不变;同时回退8fedb6d6对列表默认排序的改动。 一、列表默认查询还原(回退8fedb6d6):OMS queryList 恢复 order by a.update_time desc, Api 恢复 update_time 内存重排(空值最后),两侧列表排序与改动前一致。 二、导出排序(OMS/WMS queryListByWlExpiry):/list 新增可选参数 orderByExpiryDate, 仅 queryRule=wlExpiry 时生效: 1. wlExpiry + orderByExpiryDate=true(导出):到期日倒序(日期近的在前)、空值最后、 0库存靠后、同到期日按更新时间倒序;排序在SQL层,跨页/全量导出分组不被打散; OMS Api 传参时跳过 update_time 内存重排,避免覆盖SQL排序 2. 仅 wlExpiry 不带参数:排序保持原样(sort_order+更新时间倒序) 3. 其他查询方式:不受影响,参数被忽略 三、合并:wlExpiry 查询 GROUP BY 物料+到期日+货主(货主隔离),相同物料相同到期日 合并一行,库存/可用/冻结数量及净重/毛重/体积/面积 SUM 汇总(复用现成查询,未改) 四、前端导出:/list + queryRule=wlExpiry + orderByExpiryDate=true + 当前查询条件(不分页)
This commit is contained in:
+13
-6
@@ -292,11 +292,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<include refid="selectMaterialInventoryPo1"/>
|
||||
<include refid="JoinMaterialBaseInfoPoWhere"/>
|
||||
</where>
|
||||
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
|
||||
group by a.MATERIAL_INVENTORY_ID order by a.update_time desc
|
||||
</select>
|
||||
|
||||
<select id="queryListByWlKw" parameterType="com.mhd.oms.domain.reservationMaterialInventory.repository.todo.ReservationMaterialInventoryDO" resultMap="MaterialInventoryResult">
|
||||
@@ -373,7 +369,18 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
GROUP BY a.MATERIAL_BASE_INFO_ID, a.EXPIRY_DATE, a.shipper_id, a.shipper_code, a.shipper_name,
|
||||
a.organization_id, a.organization_name, a.top_organization_id,
|
||||
b.material_code, b.material_name
|
||||
order by sort_order, MAX(a.update_time) desc
|
||||
<!-- 导出(queryRule=wlExpiry + orderByExpiryDate=true)按到期日分组归类:到期日倒序(日期近的在前)、
|
||||
空值放最后、0库存靠后、同到期日按更新时间倒序;相同物料+相同到期日合并为一行,数量类字段SUM汇总。
|
||||
不传 orderByExpiryDate 保持原有排序 -->
|
||||
<choose>
|
||||
<when test="orderByExpiryDate != null and orderByExpiryDate == true">
|
||||
order by CASE WHEN a.expiry_date IS NULL THEN 1 ELSE 0 END ASC, a.expiry_date DESC,
|
||||
sort_order, MAX(a.update_time) DESC
|
||||
</when>
|
||||
<otherwise>
|
||||
order by sort_order, MAX(a.update_time) desc
|
||||
</otherwise>
|
||||
</choose>
|
||||
</select>
|
||||
|
||||
<select id="queryListByHz" parameterType="com.mhd.oms.domain.reservationMaterialInventory.repository.todo.ReservationMaterialInventoryDO" resultMap="MaterialInventoryResult">
|
||||
|
||||
Reference in New Issue
Block a user