查询逻辑 联查name和code

This commit is contained in:
2025-07-19 17:53:28 +08:00
parent e05a0476b2
commit dca61b7ae1
4 changed files with 40 additions and 3 deletions

View File

@@ -25,5 +25,24 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
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.*,
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
${ew.customSqlSegment}
</select>
</mapper>