优化商品库存报表

This commit is contained in:
季圣华
2021-06-21 01:12:54 +08:00
parent 523a7d287b
commit 6eb7d965a7
3 changed files with 42 additions and 15 deletions

View File

@@ -320,19 +320,23 @@
<select id="getListWithStock" resultMap="ResultMapListWithStock">
select m.*, me.commodity_unit unitName, mc.name categoryName, me.bar_code,
ifnull(me.purchase_decimal,0) purchase_decimal, ifnull(sum(mis.number),0) initialStock,
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>
) initialStock,
ifnull(sum(mcs.current_number),0) currentStock,
sum(ifnull(me.purchase_decimal, 0) * ifnull(mcs.current_number, 0)) currentStockPrice
FROM jsh_material m
left JOIN jsh_material_extend me on m.id = me.material_id and ifnull(me.delete_Flag,'0') !='1'
left join jsh_material_initial_stock mis on m.id = mis.material_id and ifnull(mis.delete_flag,'0') !='1'
left join jsh_material_current_stock mcs on m.id = mcs.material_id and ifnull(mcs.delete_flag,'0') !='1'
left JOIN jsh_unit u on m.unit_id = u.id and ifnull(u.delete_Flag,'0') !='1'
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 (mis.depot_id = #{depotId} or mcs.depot_id = #{depotId})
and mcs.depot_id = #{depotId}
</if>
<if test="idList.size()>0">
and m.category_id in
@@ -356,14 +360,13 @@
select count(tb.id) from
(select m.id from jsh_material m
left JOIN jsh_material_extend me on m.id = me.material_id and ifnull(me.delete_Flag,'0') !='1'
left join jsh_material_initial_stock mis on m.id = mis.material_id and ifnull(mis.delete_flag,'0') !='1'
left join jsh_material_current_stock mcs on m.id = mcs.material_id and ifnull(mcs.delete_flag,'0') !='1'
left JOIN jsh_unit u on m.unit_id = u.id and ifnull(u.delete_Flag,'0') !='1'
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 (mis.depot_id = #{depotId} or mcs.depot_id = #{depotId})
and mcs.depot_id = #{depotId}
</if>
<if test="idList.size()>0">
and m.category_id in
@@ -385,14 +388,13 @@
sum(ifnull(me.purchase_decimal,0)*ifnull(mcs.current_number,0)) currentStockPrice
from jsh_material m
left JOIN jsh_material_extend me on m.id = me.material_id and ifnull(me.delete_Flag,'0') !='1'
left join jsh_material_initial_stock mis on m.id = mis.material_id and ifnull(mis.delete_flag,'0') !='1'
left join jsh_material_current_stock mcs on m.id = mcs.material_id and ifnull(mcs.delete_flag,'0') !='1'
left JOIN jsh_unit u on m.unit_id = u.id and ifnull(u.delete_Flag,'0') !='1'
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 (mis.depot_id = #{depotId} or mcs.depot_id = #{depotId})
and mcs.depot_id = #{depotId}
</if>
<if test="idList.size()>0">
and m.category_id in