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:
rcx
2026-08-21 15:13:28 +08:00
parent 3aec384ba0
commit 22f2b66ffa
6 changed files with 52 additions and 12 deletions
@@ -233,6 +233,9 @@ public class MaterialInventoryDO extends MaterialBaseDO {
//查询规则 hz:货主,hzwl:货主+物料,wl:物料,kw:库位,wlkw:物料库位,all:全部(listAll 传入 hz 时会改为 hzwl
private String queryRule;
@ApiModelProperty("导出按到期日分组排序标识:仅 queryRule=wlExpiry 时生效,true-到期日倒序(日期近的在前、空值最后、0库存靠后);不传-保持原有排序")
private Boolean orderByExpiryDate;
@ApiModelProperty("冻结数量大于0条件")
@Excel(name = "冻结数量大于0条件")
private String greaterThanFreezeQuantity;
@@ -57,7 +57,8 @@ public class MaterialInventoryApi extends BaseController {
@RequestParam(value = "customerName", required = false) String customerName,
@RequestParam(value = "excludeZeroInventoryQuantity", required = false) Boolean excludeZeroInventoryQuantity,
@RequestParam(value = "expiryDateStart", required = false) String expiryDateStart,
@RequestParam(value = "expiryDateEnd", required = false) String expiryDateEnd)
@RequestParam(value = "expiryDateEnd", required = false) String expiryDateEnd,
@RequestParam(value = "orderByExpiryDate", required = false) Boolean orderByExpiryDate)
{
if (Boolean.TRUE.equals(excludeZeroInventoryQuantity)) {
materialInventoryDTO.setExcludeZeroInventoryQuantity(true);
@@ -90,6 +91,8 @@ public class MaterialInventoryApi extends BaseController {
materialInventoryDO.setProductionDateStr(materialInventoryDTO.getProductionDate());
materialInventoryDO.setExpiryDateStart(expiryDateStart);
materialInventoryDO.setExpiryDateEnd(expiryDateEnd);
// 导出场景:queryRule=wlExpiry + orderByExpiryDate=true 时 SQL 按到期日倒序分组(与 OMS 库存查询导出一致)
materialInventoryDO.setOrderByExpiryDate(orderByExpiryDate);
Date updateTime = materialInventoryDTO.getUpdateTime();
if (updateTime != null) {
LocalDateTime localDateTime = updateTime.toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime();