|
|
|
|
<?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.hw.wms.mapper.WmsRawStockMapper">
|
|
|
|
|
|
|
|
|
|
<resultMap type="WmsRawStock" id="WmsRawStockResult">
|
|
|
|
|
<result property="rawStockId" column="raw_stock_id"/>
|
|
|
|
|
<result property="warehouseId" column="warehouse_id"/>
|
|
|
|
|
<result property="warehouseFloor" column="warehouse_floor"/>
|
|
|
|
|
<result property="locationCode" column="location_code"/>
|
|
|
|
|
<result property="stockType" column="stock_type"/>
|
|
|
|
|
<result property="materialId" column="material_id"/>
|
|
|
|
|
<result property="instockBatch" column="instock_batch"/>
|
|
|
|
|
<result property="palletInfoCode" column="pallet_info_code"/>
|
|
|
|
|
<result property="instockDate" column="instock_date"/>
|
|
|
|
|
<result property="lastOutstockTime" column="last_outstock_time"/>
|
|
|
|
|
<result property="qualityStatus" column="quality_status"/>
|
|
|
|
|
<result property="completeFlag" column="complete_flag"/>
|
|
|
|
|
<result property="totalAmount" column="total_amount"/>
|
|
|
|
|
<result property="frozenAmount" column="frozen_amount"/>
|
|
|
|
|
<result property="occupyAmount" column="occupy_amount"/>
|
|
|
|
|
<result property="supplierId" column="supplier_id"/>
|
|
|
|
|
<result property="createBy" column="create_by"/>
|
|
|
|
|
<result property="createDate" column="create_date"/>
|
|
|
|
|
<result property="updateBy" column="update_by"/>
|
|
|
|
|
<result property="updateDate" column="update_date"/>
|
|
|
|
|
<result property="activeFlag" column="active_flag"/>
|
|
|
|
|
<result property="materialCode" column="material_code"/>
|
|
|
|
|
<result property="materialName" column="material_name"/>
|
|
|
|
|
<result property="warehouseName" column="warehouse_name"/>
|
|
|
|
|
</resultMap>
|
|
|
|
|
|
|
|
|
|
<sql id="selectWmsRawStockVo">
|
|
|
|
|
select wrs.raw_stock_id,
|
|
|
|
|
wrs.warehouse_id,
|
|
|
|
|
wbw.warehouse_name,
|
|
|
|
|
wbw.warehouse_floor,
|
|
|
|
|
wrs.location_code,
|
|
|
|
|
wrs.stock_type,
|
|
|
|
|
wrs.material_id,
|
|
|
|
|
mbmi.material_code,
|
|
|
|
|
mbmi.material_name,
|
|
|
|
|
wrs.instock_batch,
|
|
|
|
|
wrs.pallet_info_code,
|
|
|
|
|
wrs.instock_date,
|
|
|
|
|
wrs.last_outstock_time,
|
|
|
|
|
wrs.quality_status,
|
|
|
|
|
wrs.complete_flag,
|
|
|
|
|
wrs.total_amount,
|
|
|
|
|
wrs.frozen_amount,
|
|
|
|
|
wrs.occupy_amount,
|
|
|
|
|
wrs.supplier_id,
|
|
|
|
|
wrs.create_by,
|
|
|
|
|
wrs.create_date,
|
|
|
|
|
wrs.update_by,
|
|
|
|
|
wrs.update_date,
|
|
|
|
|
wrs.active_flag
|
|
|
|
|
from wms_raw_stock wrs
|
|
|
|
|
left join wms_base_warehouse wbw on wbw.warehouse_id = wrs.warehouse_id
|
|
|
|
|
left join mes_base_material_info mbmi on mbmi.material_id = wrs.material_id
|
|
|
|
|
</sql>
|
|
|
|
|
|
|
|
|
|
<select id="selectWmsRawStockList" parameterType="WmsRawStock" resultMap="WmsRawStockResult">
|
|
|
|
|
<include refid="selectWmsRawStockVo"/>
|
|
|
|
|
<where>
|
|
|
|
|
<if test="warehouseId != null ">and wrs.warehouse_id = #{warehouseId}</if>
|
|
|
|
|
<if test="locationCode != null and locationCode != ''">and wrs.location_code = #{locationCode}</if>
|
|
|
|
|
<if test="stockType != null and stockType != ''">and wrs.stock_type = #{stockType}</if>
|
|
|
|
|
<if test="materialId != null ">and wrs.material_id = #{materialId}</if>
|
|
|
|
|
<if test="instockBatch != null and instockBatch != ''">and wrs.instock_batch = #{instockBatch}</if>
|
|
|
|
|
<if test="instockDate != null ">and wrs.instock_date = #{instockDate}</if>
|
|
|
|
|
<if test="lastOutstockTime != null ">and wrs.last_outstock_time = #{lastOutstockTime}</if>
|
|
|
|
|
<if test="qualityStatus != null and qualityStatus != ''">and wrs.quality_status = #{qualityStatus}</if>
|
|
|
|
|
<if test="totalAmount != null ">and wrs.total_amount = #{totalAmount}</if>
|
|
|
|
|
<if test="frozenAmount != null ">and wrs.frozen_amount = #{frozenAmount}</if>
|
|
|
|
|
<if test="occupyAmount != null ">and wrs.occupy_amount = #{occupyAmount}</if>
|
|
|
|
|
<if test="supplierId != null ">and wrs.supplier_id = #{supplierId}</if>
|
|
|
|
|
<if test="updateDate != null ">and wrs.update_date = #{updateDate}</if>
|
|
|
|
|
<if test="activeFlag != null and activeFlag != ''">and wrs.active_flag = #{activeFlag}</if>
|
|
|
|
|
<if test="params.beginCreateDate != null and params.beginCreateDate != '' and params.endCreateDate != null and params.endCreateDate != ''">
|
|
|
|
|
and wrs.create_date between #{params.beginCreateDate} and #{params.endCreateDate}
|
|
|
|
|
</if>
|
|
|
|
|
</where>
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
<select id="selectWmsRawStockByRawStockId" parameterType="Long" resultMap="WmsRawStockResult">
|
|
|
|
|
<include refid="selectWmsRawStockVo"/>
|
|
|
|
|
where wrs.raw_stock_id = #{rawStockId}
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
<insert id="insertWmsRawStock" parameterType="WmsRawStock" useGeneratedKeys="true" keyProperty="rawStockId">
|
|
|
|
|
insert into wms_raw_stock
|
|
|
|
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
|
|
|
|
<if test="warehouseId != null">warehouse_id,</if>
|
|
|
|
|
<if test="warehouseFloor != null">warehouse_floor,</if>
|
|
|
|
|
<if test="locationCode != null and locationCode != ''">location_code,</if>
|
|
|
|
|
<if test="stockType != null and stockType != ''">stock_type,</if>
|
|
|
|
|
<if test="materialId != null">material_id,</if>
|
|
|
|
|
<if test="instockBatch != null and instockBatch != ''">instock_batch,</if>
|
|
|
|
|
<if test="saleOrderId != null">sale_order_id,</if>
|
|
|
|
|
<if test="safeFlag != null and safeFlag != ''">safe_flag,</if>
|
|
|
|
|
<if test="instockDate != null">instock_date,</if>
|
|
|
|
|
<if test="lastOutstockTime != null">last_outstock_time,</if>
|
|
|
|
|
<if test="qualityStatus != null and qualityStatus != ''">quality_status,</if>
|
|
|
|
|
<if test="completeFlag != null and completeFlag != ''">complete_flag,</if>
|
|
|
|
|
<if test="totalAmount != null">total_amount,</if>
|
|
|
|
|
<if test="frozenAmount != null">frozen_amount,</if>
|
|
|
|
|
<if test="occupyAmount != null">occupy_amount,</if>
|
|
|
|
|
<if test="supplierId != null">supplier_id,</if>
|
|
|
|
|
<if test="createBy != null">create_by,</if>
|
|
|
|
|
<if test="createDate != null">create_date,</if>
|
|
|
|
|
<if test="updateBy != null">update_by,</if>
|
|
|
|
|
<if test="updateDate != null">update_date,</if>
|
|
|
|
|
<if test="activeFlag != null">active_flag,</if>
|
|
|
|
|
</trim>
|
|
|
|
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
|
|
|
|
<if test="warehouseId != null">#{warehouseId},</if>
|
|
|
|
|
<if test="warehouseFloor != null">#{warehouseFloor},</if>
|
|
|
|
|
<if test="locationCode != null and locationCode != ''">#{locationCode},</if>
|
|
|
|
|
<if test="stockType != null and stockType != ''">#{stockType},</if>
|
|
|
|
|
<if test="materialId != null">#{materialId},</if>
|
|
|
|
|
<if test="instockBatch != null and instockBatch != ''">#{instockBatch},</if>
|
|
|
|
|
<if test="saleOrderId != null">#{saleOrderId},</if>
|
|
|
|
|
<if test="safeFlag != null and safeFlag != ''">#{safeFlag},</if>
|
|
|
|
|
<if test="instockDate != null">#{instockDate},</if>
|
|
|
|
|
<if test="lastOutstockTime != null">#{lastOutstockTime},</if>
|
|
|
|
|
<if test="qualityStatus != null and qualityStatus != ''">#{qualityStatus},</if>
|
|
|
|
|
<if test="completeFlag != null and completeFlag != ''">#{completeFlag},</if>
|
|
|
|
|
<if test="totalAmount != null">#{totalAmount},</if>
|
|
|
|
|
<if test="frozenAmount != null">#{frozenAmount},</if>
|
|
|
|
|
<if test="occupyAmount != null">#{occupyAmount},</if>
|
|
|
|
|
<if test="supplierId != null">#{supplierId},</if>
|
|
|
|
|
<if test="createBy != null">#{createBy},</if>
|
|
|
|
|
<if test="createDate != null">#{createDate},</if>
|
|
|
|
|
<if test="updateBy != null">#{updateBy},</if>
|
|
|
|
|
<if test="updateDate != null">#{updateDate},</if>
|
|
|
|
|
<if test="activeFlag != null">#{activeFlag},</if>
|
|
|
|
|
</trim>
|
|
|
|
|
</insert>
|
|
|
|
|
|
|
|
|
|
<update id="updateWmsRawStock" parameterType="WmsRawStock">
|
|
|
|
|
update wms_raw_stock
|
|
|
|
|
<trim prefix="SET" suffixOverrides=",">
|
|
|
|
|
<if test="warehouseId != null">warehouse_id = #{warehouseId},</if>
|
|
|
|
|
<if test="locationCode != null and locationCode != ''">location_code = #{locationCode},</if>
|
|
|
|
|
<if test="stockType != null and stockType != ''">stock_type = #{stockType},</if>
|
|
|
|
|
<if test="materialId != null">material_id = #{materialId},</if>
|
|
|
|
|
<if test="instockBatch != null and instockBatch != ''">instock_batch = #{instockBatch},</if>
|
|
|
|
|
<if test="instockDate != null">instock_date = #{instockDate},</if>
|
|
|
|
|
<if test="lastOutstockTime != null">last_outstock_time = #{lastOutstockTime},</if>
|
|
|
|
|
<if test="qualityStatus != null and qualityStatus != ''">quality_status = #{qualityStatus},</if>
|
|
|
|
|
<if test="completeFlag != null and completeFlag != ''">complete_flag = #{completeFlag},</if>
|
|
|
|
|
<if test="totalAmount != null">total_amount = #{totalAmount},</if>
|
|
|
|
|
<if test="frozenAmount != null">frozen_amount = #{frozenAmount},</if>
|
|
|
|
|
<if test="occupyAmount != null">occupy_amount = #{occupyAmount},</if>
|
|
|
|
|
<if test="supplierId != null">supplier_id = #{supplierId},</if>
|
|
|
|
|
<if test="createBy != null">create_by = #{createBy},</if>
|
|
|
|
|
<if test="createDate != null">create_date = #{createDate},</if>
|
|
|
|
|
<if test="updateBy != null">update_by = #{updateBy},</if>
|
|
|
|
|
<if test="updateDate != null">update_date = #{updateDate},</if>
|
|
|
|
|
<if test="activeFlag != null">active_flag = #{activeFlag},</if>
|
|
|
|
|
</trim>
|
|
|
|
|
where raw_stock_id = #{rawStockId}
|
|
|
|
|
</update>
|
|
|
|
|
|
|
|
|
|
<delete id="deleteWmsRawStockByRawStockId" parameterType="Long">
|
|
|
|
|
delete
|
|
|
|
|
from wms_raw_stock
|
|
|
|
|
where raw_stock_id = #{rawStockId}
|
|
|
|
|
</delete>
|
|
|
|
|
|
|
|
|
|
<delete id="deleteWmsRawStockByRawStockIds" parameterType="String">
|
|
|
|
|
delete from wms_raw_stock where raw_stock_id in
|
|
|
|
|
<foreach item="rawStockId" collection="array" open="(" separator="," close=")">
|
|
|
|
|
#{rawStockId}
|
|
|
|
|
</foreach>
|
|
|
|
|
</delete>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<select id="selectRawStockByBarcode" resultMap="WmsRawStockResult">
|
|
|
|
|
<include refid="selectWmsRawStockVo"/>
|
|
|
|
|
where instock_batch = #{instockBatch}
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
<select id="getRawStockTotalAmount" resultType="BigDecimal" parameterType="WmsRawStock">
|
|
|
|
|
select sum(total_amount) from wms_raw_stock
|
|
|
|
|
<where>
|
|
|
|
|
<if test="locationCode != null and locationCode != ''">and location_code = #{locationCode}</if>
|
|
|
|
|
and total_amount > 0
|
|
|
|
|
</where>
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<select id="selectWmsRawStocks4Apply" parameterType="WmsRawStock" resultMap="WmsRawStockResult">
|
|
|
|
|
<include refid="selectWmsRawStockVo"/>
|
|
|
|
|
<where>
|
|
|
|
|
<if test="warehouseId != null ">and warehouse_id = #{warehouseId}</if>
|
|
|
|
|
<if test="materialId != null ">and material_id = #{materialId}</if>
|
|
|
|
|
<if test="qualityStatus != null and qualityStatus != ''">and quality_status = #{qualityStatus}</if>
|
|
|
|
|
</where>
|
|
|
|
|
order by instock_date asc
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<select id="selectWmsRawStockInList" parameterType="WmsRawStock" resultMap="WmsRawStockResult">
|
|
|
|
|
<include refid="selectWmsRawStockVo"/>
|
|
|
|
|
<where>
|
|
|
|
|
|
|
|
|
|
<if test="warehouseId != null ">and warehouse_id = #{warehouseId}</if>
|
|
|
|
|
<if test="locationCode != null and locationCode != ''">and location_code = #{locationCode}</if>
|
|
|
|
|
<if test="stockType != null and stockType != ''">and stock_type = #{stockType}</if>
|
|
|
|
|
<if test="materialId != null ">and material_id = #{materialId}</if>
|
|
|
|
|
<if test="instockBatch != null and instockBatch != ''">and instock_batch = #{instockBatch}</if>
|
|
|
|
|
<if test="instockDate != null ">and instock_date = #{instockDate}</if>
|
|
|
|
|
<if test="lastOutstockTime != null ">and last_outstock_time = #{lastOutstockTime}</if>
|
|
|
|
|
<if test="qualityStatus != null and qualityStatus != ''">and quality_status = #{qualityStatus}</if>
|
|
|
|
|
<if test="completeFlag != null and completeFlag != ''">and complete_flag = #{completeFlag}</if>
|
|
|
|
|
<if test="frozenAmount != null ">and frozen_amount = #{frozenAmount}</if>
|
|
|
|
|
<if test="occupyAmount != null ">and occupy_amount = #{occupyAmount}</if>
|
|
|
|
|
<if test="supplierId != null ">and supplier_id = #{supplierId}</if>
|
|
|
|
|
<if test="createDate != null ">and create_date = #{createDate}</if>
|
|
|
|
|
<if test="updateDate != null ">and update_date = #{updateDate}</if>
|
|
|
|
|
<if test="activeFlag != null and activeFlag != ''">and active_flag = #{activeFlag}</if>
|
|
|
|
|
|
|
|
|
|
and total_amount > 0
|
|
|
|
|
</where>
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</mapper>
|