Files
klp-oa/klp-wms/src/main/resources/mapper/klp/WmsStockMapper.xml
2025-08-01 17:04:32 +08:00

51 lines
2.2 KiB
XML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.klp.mapper.WmsStockMapper">
<resultMap type="com.klp.domain.WmsStock" id="WmsStockResult">
<result property="stockId" column="stock_id"/>
<result property="warehouseId" column="warehouse_id"/>
<result property="itemType" column="item_type"/>
<result property="itemId" column="item_id"/>
<result property="quantity" column="quantity"/>
<result property="unit" column="unit"/>
<result property="batchNo" column="batch_no"/>
<result property="remark" column="remark"/>
<result property="delFlag" column="del_flag"/>
<result property="createTime" column="create_time"/>
<result property="createBy" column="create_by"/>
<result property="updateTime" column="update_time"/>
<result property="updateBy" column="update_by"/>
</resultMap>
<select id="getStockByItemId" resultType="java.math.BigDecimal">
select sum(quantity) as quantity from wms_stock
where item_id = #{rawMaterialId} and item_type = 'raw_material' and del_flag = 0
</select>
<!-- 分页联查物品名称和编码支持Wrapper动态条件返回Page<WmsStockVo> -->
<select id="selectVoPagePlus" resultType="com.klp.domain.vo.WmsStockVo">
SELECT
s.*,
w.warehouse_name,
CASE
WHEN s.item_type = 'product' THEN p.product_name
WHEN s.item_type = 'raw_material' THEN r.raw_material_name
ELSE NULL
END AS itemName,
CASE
WHEN s.item_type = 'product' THEN p.product_code
WHEN s.item_type = 'raw_material' THEN r.raw_material_code
ELSE NULL
END AS itemCode
FROM wms_stock s
LEFT JOIN wms_product p ON s.item_type = 'product' AND s.item_id = p.product_id
LEFT JOIN wms_raw_material r ON s.item_type = 'raw_material' AND s.item_id = r.raw_material_id
left join wms_warehouse w on s.warehouse_id = w.warehouse_id
${ew.customSqlSegment}
</select>
</mapper>