feat(wms): 库存列表接口新增隐藏可用数量为0的参数

/materialInventoryApi/list 新增可选参数 excludeZeroAllocationQuantity,为 true 时排除可用数量=0 的库存行;与已有 excludeZeroInventoryQuantity 组成两个独立开关,不传时保持原有行为。配合盘点-库存选择页隐藏数量为0物料及出库选库存隐藏0库存需求。
This commit is contained in:
rcx
2026-09-02 14:04:15 +08:00
parent f5a7c8c1f3
commit 72cb1d8c07
4 changed files with 25 additions and 3 deletions
@@ -256,6 +256,8 @@ public class MaterialInventoryDO extends MaterialBaseDO {
/** 为 true 时 SQL 排除库存数量为 0(含 null 视为 0) */
private Boolean excludeZeroInventoryQuantity;
/** 为 true 时 SQL 排除可用数量为 0(含 null 视为 0),出库选库存可用 */
private Boolean excludeZeroAllocationQuantity;
private String expiryDateStr;
private String productionDateStr;
private String updateTimeStr;
@@ -188,6 +188,9 @@ public class MaterialInventoryDTO extends MaterialBaseDTO {
/** 为 true 时排除库存数量为 0 的行(出库分配选库存用);库存查询页不传或 false */
@ApiModelProperty(value = "是否排除库存数量为0", example = "false")
private Boolean excludeZeroInventoryQuantity;
/** 为 true 时排除可用数量为 0 的行(库存数量>0 但可用数量=0 表示已被冻结/占用完,无法出库);不传或 false 不过滤 */
@ApiModelProperty(value = "是否排除可用数量为0", example = "false")
private Boolean excludeZeroAllocationQuantity;
private String expiryDate;
private String productionDate;
/** 进货日期(yyyy-MM-dd,单日精确查询) */
@@ -53,11 +53,17 @@ public class MaterialInventoryApi extends BaseController {
/**
* 分页查询物料库存列表
*/
@ApiOperation(value = "查询物料库存列表", notes = "库存查询页不传 excludeZeroInventoryQuantity 可查出数量为0;出库分配页传 excludeZeroInventoryQuantity=true 排除库存数量为0;导出复用本接口:传 isExport=true 标识导出请求(导出显示:商品饮用有效期expiryDate/物料分类materialClassifyName/进货日期purchaseDate,所有查询维度均返回)")
@ApiOperation(value = "查询物料库存列表", notes = "两个隐藏0库存开关(均不传或 false 不过滤,保持原行为):"
+ "excludeZeroInventoryQuantity=true 排除库存数量为0(盘点-库存选择页\"隐藏数量为0的物料\");"
+ "excludeZeroAllocationQuantity=true 排除可用数量为0(出库选库存,可用数量=0 表示已被冻结/占用完无法出库);"
+ "物料编号筛选传 materialCode(精确匹配),仓库筛选传 warehouseId(下拉);"
+ "库存查询页不传开关可查出数量为0;导出复用本接口:传 isExport=true 标识导出请求"
+ "(导出显示:商品饮用有效期expiryDate/物料分类materialClassifyName/进货日期purchaseDate,所有查询维度均返回)")
@GetMapping("/list")
public TableDataInfo list(MaterialInventoryDTO materialInventoryDTO,
@RequestParam(value = "customerName", required = false) String customerName,
@RequestParam(value = "excludeZeroInventoryQuantity", required = false) Boolean excludeZeroInventoryQuantity,
@RequestParam(value = "excludeZeroAllocationQuantity", required = false) Boolean excludeZeroAllocationQuantity,
@RequestParam(value = "expiryDateStart", required = false) String expiryDateStart,
@RequestParam(value = "expiryDateEnd", required = false) String expiryDateEnd,
@RequestParam(value = "purchaseDateStart", required = false) String purchaseDateStart,
@@ -69,6 +75,9 @@ public class MaterialInventoryApi extends BaseController {
if (Boolean.TRUE.equals(excludeZeroInventoryQuantity)) {
materialInventoryDTO.setExcludeZeroInventoryQuantity(true);
}
if (Boolean.TRUE.equals(excludeZeroAllocationQuantity)) {
materialInventoryDTO.setExcludeZeroAllocationQuantity(true);
}
// 出库分配前端传的是客户名称 customerName,这里通过名称查询货主ID,使用精确匹配(不模糊匹配)
String shipperName = null; // 保存查询到的货主名称
if (StringUtils.isNotBlank(customerName) && materialInventoryDTO.getShipperId() == null) {
@@ -176,8 +185,10 @@ public class MaterialInventoryApi extends BaseController {
// materialDetailId 是新接口专用参数(出库单明细ID),库存 DTO 的同名字段语义是「上架单明细ID」,
// 泄入原查询会生成错误的 a.material_detail_id 条件导致查空,进原查询前显式清除
materialInventoryDTO.setMaterialDetailId(null);
// assignableList 非导出场景,isExport 传 null
return list(materialInventoryDTO, customerName, excludeZeroInventoryQuantity, expiryDateStart, expiryDateEnd, null, null, orderByExpiryDate, null);
// assignableList 非导出场景,isExport 传 nullexcludeZeroAllocationQuantity 已随 DTO 绑定,透传保持开关生效
return list(materialInventoryDTO, customerName, excludeZeroInventoryQuantity,
materialInventoryDTO.getExcludeZeroAllocationQuantity(),
expiryDateStart, expiryDateEnd, null, null, orderByExpiryDate, null);
}
@ApiOperation("查询物料库存列表不分页;queryRule=hz 时按货主+物料分组(同一物料在不同货主各占一行)")
@@ -217,6 +217,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="excludeZeroInventoryQuantity != null and excludeZeroInventoryQuantity == true">
and COALESCE(a.inventory_quantity, 0) &gt; 0
</if>
<if test="excludeZeroAllocationQuantity != null and excludeZeroAllocationQuantity == true">
and COALESCE(a.allocation_quantity, 0) &gt; 0
</if>
<if test="createByName != null and createByName != ''">
and a.create_by_name like concat('%', #{createByName}, '%')
@@ -378,6 +381,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="excludeZeroInventoryQuantity != null and excludeZeroInventoryQuantity == true">
and COALESCE(mi.inventory_quantity, 0) &gt; 0
</if>
<if test="excludeZeroAllocationQuantity != null and excludeZeroAllocationQuantity == true">
and COALESCE(mi.allocation_quantity, 0) &gt; 0
</if>
<if test="createByName != null and createByName != ''">
and mi.create_by_name like concat('%', #{createByName}, '%')