You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
165 lines
7.5 KiB
165 lines
7.5 KiB
|
1 year ago
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||
|
|
<!DOCTYPE mapper
|
||
|
|
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||
|
|
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||
|
|
<mapper namespace="com.shkj.wms.mapper.SysStockMapper">
|
||
|
|
|
||
|
|
<resultMap type="com.shkj.wms.domain.SysStock" id="SysStockResult">
|
||
|
|
<result property="id" column="id"/>
|
||
|
|
<result property="consignorId" column="consignor_id"/>
|
||
|
|
<result property="branchId" column="branch_id"/>
|
||
|
|
<result property="storageId" column="storage_id"/>
|
||
|
|
<result property="areaId" column="area_id"/>
|
||
|
|
<result property="tunnel" column="tunnel"/>
|
||
|
|
<result property="goodsNo" column="goods_no"/>
|
||
|
|
<result property="qty" column="qty"/>
|
||
|
|
<result property="inQty" column="in_qty"/>
|
||
|
|
<result property="outQty" column="out_qty"/>
|
||
|
|
<result property="stockStatus" column="stock_status"/>
|
||
|
|
<result property="createTime" column="create_time"/>
|
||
|
|
<result property="updateTime" column="update_time"/>
|
||
|
|
<result property="createBy" column="create_by"/>
|
||
|
|
<result property="updateBy" column="update_by"/>
|
||
|
|
</resultMap>
|
||
|
|
|
||
|
|
<update id="updateSysStock" parameterType="com.shkj.wms.bo.SysStockReduceBo">
|
||
|
|
|
||
|
|
update sys_stock set qty =qty -1
|
||
|
|
<where>
|
||
|
|
<if test="branchId != null and branchId !='' ">
|
||
|
|
branch_id = #{branchId}
|
||
|
|
</if>
|
||
|
|
<if test="storageId != null and storageId !='' ">and storage_id = #{storageId}</if>
|
||
|
|
<if test="areaId != null and areaId !='' ">and area_id = #{areaId}</if>
|
||
|
|
</where>
|
||
|
|
</update>
|
||
|
|
|
||
|
|
<select id="queryStockList" resultType="com.shkj.wms.vo.SysStockNumVo" parameterType="com.shkj.wms.bo.SysReportStockQueryBo">
|
||
|
|
select ptPart,ptPartName, ptBreakCat,inNum,outNum, IFNULL(invqty,0)+IFNULL(inNum,0)-IFNULL(outNum,0) as invQty,stockNum
|
||
|
|
from (
|
||
|
|
SELECT
|
||
|
|
a.ptPart,
|
||
|
|
a.ptPartName,
|
||
|
|
a.ptBreakCat,
|
||
|
|
sum( CASE WHEN a.temp = 'in' THEN a.num END ) AS inNum,
|
||
|
|
sum( CASE WHEN a.temp = 'out' THEN a.num END ) AS outNum,
|
||
|
|
sum( CASE WHEN a.temp = 'stock' THEN a.num END ) AS stockNum
|
||
|
|
FROM
|
||
|
|
(
|
||
|
|
SELECT
|
||
|
|
'in' AS temp,
|
||
|
|
bid.pt_part AS ptPart,
|
||
|
|
bid.pt_name AS ptPartName,
|
||
|
|
bid.pt_break_cat as ptBreakCat,
|
||
|
|
ifnull( bii.tt_qty_rct, '' ) AS num,
|
||
|
|
bii.in_date AS date
|
||
|
|
FROM
|
||
|
|
base_item_data bid
|
||
|
|
INNER JOIN busin_item_in bii ON bid.pt_part = bii.tt_part
|
||
|
|
where bii.in_status = 3 and bii.in_type in(1,0)
|
||
|
|
|
||
|
|
<if test="invTimeStart != null and invTimeStart != ''">
|
||
|
|
and bii.create_time > #{invTimeStart}
|
||
|
|
</if>
|
||
|
|
|
||
|
|
<if test="startTime != null and startTime != ''">
|
||
|
|
and bii.create_time < #{startTime}
|
||
|
|
</if>
|
||
|
|
|
||
|
|
UNION ALL
|
||
|
|
|
||
|
|
SELECT
|
||
|
|
'out' AS temp,
|
||
|
|
bid.pt_part AS ptPart,
|
||
|
|
bid.pt_name AS ptPartName,
|
||
|
|
bid.pt_break_cat as ptBreakCat,
|
||
|
|
ifnull( bio.tt_qty_iss, '' ) AS num,
|
||
|
|
DATE_FORMAT( bio.create_time, '%Y-%m-%d' ) AS date
|
||
|
|
FROM
|
||
|
|
base_item_data bid
|
||
|
|
INNER JOIN busin_item_out bio ON bid.pt_part = bio.tt_part
|
||
|
|
where bio.out_type in(1,0)
|
||
|
|
and bio.out_status = 3
|
||
|
|
<if test="invTimeStart != null and invTimeStart != ''">
|
||
|
|
and bio.create_time > #{invTimeStart}
|
||
|
|
</if>
|
||
|
|
|
||
|
|
<if test="startTime != null and startTime != ''">
|
||
|
|
and bio.create_time < #{startTime}
|
||
|
|
</if>
|
||
|
|
|
||
|
|
UNION ALL
|
||
|
|
|
||
|
|
SELECT
|
||
|
|
'stock' AS temp,
|
||
|
|
bid.pt_part AS ptPart,
|
||
|
|
bid.pt_name AS ptPartName,
|
||
|
|
bid.pt_break_cat as ptBreakCat,
|
||
|
|
ifnull(ssd.qty,0) AS num,
|
||
|
|
batch AS date
|
||
|
|
FROM
|
||
|
|
base_item_data bid
|
||
|
|
INNER JOIN sys_stock_detail ssd ON bid.pt_part = ssd.pt_part
|
||
|
|
where ifnull(ssd.qty,0) > 0
|
||
|
|
) a
|
||
|
|
|
||
|
|
<where>
|
||
|
|
<if test="ptPart != null and ptPart != ''">
|
||
|
|
and a.ptPart like UPPER(concat('%', #{ptPart}, '%'))
|
||
|
|
</if>
|
||
|
|
|
||
|
|
<if test="ptBreakCat != null and ptBreakCat != ''">
|
||
|
|
and a.ptBreakCat like UPPER(concat('%', #{ptBreakCat}, '%'))
|
||
|
|
</if>
|
||
|
|
</where>
|
||
|
|
GROUP BY a.ptPart,a.ptPartName,a.ptBreakCat
|
||
|
|
order by ptBreakCat
|
||
|
|
)
|
||
|
|
as result
|
||
|
|
LEFT JOIN (
|
||
|
|
SELECT sum( tt_qty_rct ) AS invqty, tt_part FROM busin_item_in itemin WHERE in_status = '99' GROUP BY tt_part
|
||
|
|
) invStock ON result.ptPart = invStock.tt_part
|
||
|
|
</select>
|
||
|
|
|
||
|
|
<select id="vehicheColorList" resultType="com.shkj.wms.vo.SysStockVehicheColorVo" parameterType="com.shkj.wms.bo.SysReportStockQueryBo">
|
||
|
|
select sum(qty) qty,g.color, dict.dict_value as colorId, g.vehiche_model
|
||
|
|
from sys_dict_data dict
|
||
|
|
INNER JOIN base_goods_data g on dict.dict_label=g.color
|
||
|
|
left join sys_stock_detail d on g.goods_no=d.goods_no
|
||
|
|
where IFNULL(qty,0)>0
|
||
|
|
GROUP BY g.color, g.vehiche_model,dict.dict_value;
|
||
|
|
</select>
|
||
|
|
|
||
|
|
<select id="vehicheColorLocationList" resultType="com.shkj.wms.vo.SysStockVCLocationVo" parameterType="com.shkj.wms.bo.SysReportStockQueryBo">
|
||
|
|
|
||
|
|
select count(distinct loc.id) as locQty,sum(distinct alltmp.stockqty) stockqty,
|
||
|
|
g.color, IFNULL(g.vehiche_model,'empty') as vehiche_model
|
||
|
|
,loc.tunnel ,sum(distinct emptyLoc.emptyLocQty) emptyLocQty
|
||
|
|
from base_location loc
|
||
|
|
left join(
|
||
|
|
select count(distinct location_id) stockqty,goods_no,locGoods.tunnel from
|
||
|
|
sys_stock_detail stock
|
||
|
|
INNER JOIN base_location locGoods on locGoods.id =stock.location_id
|
||
|
|
where stock.qty>0
|
||
|
|
group by goods_no,locGoods.tunnel
|
||
|
|
) alltmp on alltmp.tunnel=loc.tunnel
|
||
|
|
left join base_goods_data g on g.goods_no=alltmp.goods_no
|
||
|
|
left join (
|
||
|
|
select count(id) emptyLocQty,tunnel from base_location
|
||
|
|
where location_status=0
|
||
|
|
group by tunnel
|
||
|
|
) emptyLoc on emptyLoc.tunnel =loc.tunnel
|
||
|
|
GROUP BY g.color, g.vehiche_model,loc.tunnel
|
||
|
|
|
||
|
|
</select>
|
||
|
|
|
||
|
|
<select id="getVehicheStockList" resultType="com.shkj.wms.vo.SysStockVehicheVo">
|
||
|
|
|
||
|
|
select count(*) qty,color,vehiche_model,location,is_punching,LEFT(qr_code,4) as vehiche from sys_stock_detail stock
|
||
|
|
inner join base_goods_data goods on stock.goods_no=goods.goods_no
|
||
|
|
GROUP BY color,vehiche_model,location,is_punching,vehiche
|
||
|
|
|
||
|
|
</select>
|
||
|
|
|
||
|
|
</mapper>
|