增加商品库存报表

This commit is contained in:
季圣华
2021-06-20 22:34:04 +08:00
parent f0da067230
commit e5ce3194ee
7 changed files with 221 additions and 0 deletions

View File

@@ -12,6 +12,17 @@
<result column="low_decimal" jdbcType="VARCHAR" property="lowDecimal" />
</resultMap>
<resultMap extends="com.jsh.erp.datasource.mappers.MaterialMapper.BaseResultMap" id="ResultMapListWithStock" type="com.jsh.erp.datasource.entities.MaterialVo4Unit">
<result column="unitName" jdbcType="VARCHAR" property="unitName" />
<result column="categoryName" jdbcType="VARCHAR" property="categoryName" />
<result column="bar_code" jdbcType="VARCHAR" property="mBarCode" />
<result column="commodity_unit" jdbcType="VARCHAR" property="commodityUnit" />
<result column="purchase_decimal" jdbcType="VARCHAR" property="purchaseDecimal" />
<result column="initialStock" jdbcType="DECIMAL" property="initialStock" />
<result column="currentStock" jdbcType="DECIMAL" property="currentStock" />
<result column="currentStockPrice" jdbcType="DECIMAL" property="currentStockPrice" />
</resultMap>
<resultMap extends="com.jsh.erp.datasource.mappers.MaterialMapper.BaseResultMap" id="ResultAndUnitMap" type="com.jsh.erp.datasource.entities.MaterialVo4Unit">
<result column="unit_name" jdbcType="VARCHAR" property="unitName" />
</resultMap>
@@ -306,4 +317,93 @@
and ifnull(delete_flag,'0') !='1'
and id = #{id}
</update>
<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(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})
</if>
<if test="idList.size()>0">
and m.category_id in
<foreach collection="idList" item="item" index="index" separator="," open="(" close=")">
#{item}
</foreach>
</if>
<if test="materialParam != null">
<bind name="bindParam" value="'%'+materialParam+'%'"/>
and (me.bar_code like #{bindParam} or m.name like #{bindParam} or m.standard like #{bindParam} or m.model like #{bindParam})
</if>
and ifnull(m.delete_flag,'0') !='1'
group by m.id
order by m.id desc
<if test="offset != null and rows != null">
limit #{offset},#{rows}
</if>
</select>
<select id="getListWithStockCount" resultType="java.lang.Integer">
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})
</if>
<if test="idList.size()>0">
and m.category_id in
<foreach collection="idList" item="item" index="index" separator="," open="(" close=")">
#{item}
</foreach>
</if>
<if test="materialParam != null">
<bind name="bindParam" value="'%'+materialParam+'%'"/>
and (me.bar_code like #{bindParam} or m.name like #{bindParam} or m.standard like #{bindParam} or m.model like #{bindParam})
</if>
and ifnull(m.delete_flag,'0') !='1'
group by m.id) tb
</select>
<select id="getTotalStockAndPrice" resultType="com.jsh.erp.datasource.entities.MaterialVo4Unit">
select
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})
</if>
<if test="idList.size()>0">
and m.category_id in
<foreach collection="idList" item="item" index="index" separator="," open="(" close=")">
#{item}
</foreach>
</if>
<if test="materialParam != null">
<bind name="bindParam" value="'%'+materialParam+'%'"/>
and (me.bar_code like #{bindParam} or m.name like #{bindParam} or m.standard like #{bindParam} or m.model like #{bindParam})
</if>
and ifnull(m.delete_flag,'0') !='1'
</select>
</mapper>