feat:新增可用库存查询Mapper接口及SQL

This commit is contained in:
zhouz
2026-07-22 09:43:09 +08:00
parent 4d8110fa26
commit 6c8020d1c3
2 changed files with 50 additions and 0 deletions

View File

@@ -5,8 +5,10 @@ import java.util.*;
import cn.code.nl.framework.common.pojo.PageResult;
import cn.code.nl.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.code.nl.framework.mybatis.core.mapper.BaseMapperX;
import cn.code.nl.module.wms.controller.admin.iostorinv.vo.AvailableInventoryVO;
import cn.code.nl.module.wms.dal.dataobject.iostorinvdtl.IostorinvDtlDO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import cn.code.nl.module.wms.controller.admin.iostorinvdtl.vo.*;
/**
@@ -41,4 +43,18 @@ public interface IostorinvDtlMapper extends BaseMapperX<IostorinvDtlDO> {
.orderByDesc(IostorinvDtlDO::getIostorinvdtlId));
}
/**
* 查询可用库存wms_group_plate 关联 wms_structattr
*
* @param storId 仓库标识(必传)
* @param materialCode 物料编码(可选)
* @param pcsn 批次(可选)
* @param vehicleCode 载具编码(可选)
* @return 可用库存列表
*/
List<AvailableInventoryVO> selectAvailableInventory(
@Param("storId") String storId,
@Param("materialCode") String materialCode,
@Param("pcsn") String pcsn,
@Param("vehicleCode") String vehicleCode);
}

View File

@@ -9,4 +9,38 @@
文档可见https://www.iocoder.cn/MyBatis/x-plugins/
-->
<select id="selectAvailableInventory"
resultType="cn.code.nl.module.wms.controller.admin.iostorinv.vo.AvailableInventoryVO">
SELECT
gp.vehicle_code AS vehicleCode,
gp.pcsn AS pcsn,
gp.material_code AS materialCode,
gp.material_id AS materialId,
gp.qty AS qty,
gp.frozen_qty AS frozenQty,
(gp.qty - gp.frozen_qty) AS availableQty,
gp.qty_unit_id AS qtyUnitId,
gp.qty_unit_name AS qtyUnitName,
gp.ext_code AS extCode,
gp.ext_type AS extType,
gp.ext_dtl_code AS extDtlCode,
sa.stor_id AS storId,
sa.stor_code AS storCode,
sa.stor_name AS storName
FROM wms_group_plate gp
INNER JOIN wms_structattr sa
ON gp.vehicle_code = sa.storagevehicle_code
WHERE sa.stor_id = #{storId}
AND gp.status = '可用'
AND (gp.qty - gp.frozen_qty) > 0
<if test="materialCode != null and materialCode != ''">
AND gp.material_code = #{materialCode}
</if>
<if test="pcsn != null and pcsn != ''">
AND gp.pcsn = #{pcsn}
</if>
<if test="vehicleCode != null and vehicleCode != ''">
AND gp.vehicle_code = #{vehicleCode}
</if>
</select>
</mapper>