优化商品库存查询接口

This commit is contained in:
季圣华
2021-11-25 01:14:00 +08:00
parent de53f2eb3a
commit 61b40f4726
4 changed files with 45 additions and 22 deletions

View File

@@ -339,8 +339,11 @@
select m.*, me.commodity_unit unitName, mc.name categoryName, me.bar_code,
ifnull(me.purchase_decimal,0) purchase_decimal,
(select ifnull(sum(mis.number),0) from jsh_material_initial_stock mis where mis.material_id = m.id
<if test="depotId != null">
and mis.depot_id = #{depotId}
<if test="depotList.size()>0">
and mis.depot_id in
<foreach collection="depotList" item="item" index="index" separator="," open="(" close=")">
#{item}
</foreach>
</if>
) initialStock,
ifnull(sum(mcs.current_number),0) currentStock,
@@ -352,8 +355,11 @@
left JOIN jsh_material_category mc on m.category_id = mc.id and ifnull(mc.delete_Flag,'0') !='1'
where 1=1
and me.default_flag=1
<if test="depotId != null">
and mcs.depot_id = #{depotId}
<if test="depotList.size()>0">
and mcs.depot_id in
<foreach collection="depotList" item="item" index="index" separator="," open="(" close=")">
#{item}
</foreach>
</if>
<if test="idList.size()>0">
and m.category_id in
@@ -390,8 +396,11 @@
left JOIN jsh_material_category mc on m.category_id = mc.id and ifnull(mc.delete_Flag,'0') !='1'
where 1=1
and me.default_flag=1
<if test="depotId != null">
and mcs.depot_id = #{depotId}
<if test="depotList.size()>0">
and mcs.depot_id in
<foreach collection="depotList" item="item" index="index" separator="," open="(" close=")">
#{item}
</foreach>
</if>
<if test="idList.size()>0">
and m.category_id in
@@ -422,8 +431,11 @@
left JOIN jsh_material_category mc on m.category_id = mc.id and ifnull(mc.delete_Flag,'0') !='1'
where 1=1
and me.default_flag=1
<if test="depotId != null">
and mcs.depot_id = #{depotId}
<if test="depotList.size()>0">
and mcs.depot_id in
<foreach collection="depotList" item="item" index="index" separator="," open="(" close=")">
#{item}
</foreach>
</if>
<if test="idList.size()>0">
and m.category_id in