This commit is contained in:
2025-10-28 12:20:20 +08:00
parent 0b9f7bc7e9
commit 10d6cc1144
18 changed files with 5032 additions and 47 deletions

View File

@@ -9,8 +9,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<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"/>
@@ -39,7 +37,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
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
END AS itemCode,
(SELECT COUNT(*)
FROM wms_material_coil mc
WHERE mc.item_type = s.item_type
AND mc.item_id = s.item_id
AND mc.del_flag = 0) AS totalQuantity
FROM wms_stock s
LEFT JOIN wms_product p ON s.item_type = 'product' AND s.item_id = p.product_id and p.del_flag = 0
LEFT JOIN wms_raw_material r ON s.item_type = 'raw_material' AND s.item_id = r.raw_material_id and r.del_flag = 0
@@ -47,4 +50,22 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
${ew.customSqlSegment}
</select>
<!-- 按仓库统计库存分布 -->
<select id="selectStockDistribution" resultType="com.klp.domain.vo.WmsStockVo">
SELECT
mc.warehouse_id AS warehouseId,
w.warehouse_name AS warehouseName,
COUNT(*) AS totalQuantity,
mc.item_type AS itemType,
mc.item_id AS itemId
FROM wms_material_coil mc
INNER JOIN wms_warehouse w ON mc.warehouse_id = w.warehouse_id AND w.del_flag = 0
WHERE mc.item_type = #{itemType}
AND mc.item_id = #{itemId}
AND mc.del_flag = 0
AND mc.data_type = 1
GROUP BY mc.warehouse_id, w.warehouse_name, mc.item_type, mc.item_id
ORDER BY totalQuantity DESC
</select>
</mapper>