优化商品库存报表
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user