@ -34,37 +34,66 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</resultMap>
<sql id= "selectWmsProductStockVo" >
select product_stock_id, warehouse_id, location_code, stock_type, product_batch, quality_status, product_id, plan_code, plan_detail_code,sale_order_id,saleorder_code, total_amount, frozen_amount, occupy_amount, create_by, create_date, update_by, update_date, active_flag, instock_date from wms_product_stock
select wps.product_stock_id,
wps.warehouse_id,
wbw.warehouse_name,
wbw.warehouse_floor,
wps.location_code,
wps.stock_type,
wps.product_batch,
wps.quality_status,
wps.product_id,
mbmi.material_code,
mbmi.material_name,
wps.plan_code,
wps.plan_detail_code,
wps.sale_order_id,
wps.saleorder_code,
wps.total_amount,
wps.frozen_amount,
wps.occupy_amount,
wps.create_by,
wps.create_date,
wps.update_by,
wps.update_date,
wps.active_flag,
wps.instock_date
from wms_product_stock wps
left join wms_base_warehouse wbw on wbw.warehouse_id = wps.warehouse_id
left join mes_base_material_info mbmi on mbmi.material_id = wps.product_id
</sql>
<select id= "selectWmsProductStockList" parameterType= "WmsProductStock" resultMap= "WmsProductStockResult" >
<include refid= "selectWmsProductStockVo" />
<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= "productBatch != null and productBatch != ''" > and product_batch = #{productBatch}</if>
<if test= "qualityStatus != null and qualityStatus != ''" > and quality_status = #{qualityStatus}</if>
<if test= "productId != null " > and product_id = #{productId}</if>
<if test= "planCode != null " > and plan_code = #{planCode}</if>
<if test= "planDetailCode != null " > and plan_detail_code = #{planDetailCode}</if>
<if test= "saleorderCode != null " > and saleorder_code = #{saleorderCode}</if>
<if test= "totalAmount != null " > and total_amount = #{totalAmount}</if>
<if test= "frozenAmount != null " > and frozen_amount = #{frozenAmount}</if>
<if test= "occupyAmount != null " > and occupy_amount = #{occupyAmount}</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>
<if test= "instockDate != null " > and instock_date = #{instockDate}</if>
<if test= "warehouseId != null " > and wps.warehouse_id = #{warehouseId}</if>
<if test= "locationCode != null and locationCode != ''" > and wps.location_code = #{locationCode}</if>
<if test= "stockType != null and stockType != ''" > and wps.stock_type = #{stockType}</if>
<if test= "productBatch != null and productBatch != ''" > and wps.product_batch = #{productBatch}</if>
<if test= "qualityStatus != null and qualityStatus != ''" > and wps.quality_status = #{qualityStatus}</if>
<if test= "productId != null " > and wps.product_id = #{productId}</if>
<if test= "planCode != null " > and wps.plan_code = #{planCode}</if>
<if test= "planDetailCode != null " > and wps.plan_detail_code = #{planDetailCode}</if>
<if test= "saleorderCode != null " > and wps.saleorder_code = #{saleorderCode}</if>
<if test= "totalAmount != null " > and wps.total_amount = #{totalAmount}</if>
<if test= "frozenAmount != null " > and wps.frozen_amount = #{frozenAmount}</if>
<if test= "occupyAmount != null " > and wps.occupy_amount = #{occupyAmount}</if>
<if test= "updateDate != null " > and wps.update_date = #{updateDate}</if>
<if test= "activeFlag != null and activeFlag != ''" > and wps.active_flag = #{activeFlag}</if>
<if test= "instockDate != null " > and wps.instock_date = #{instockDate}</if>
<if test= "params.beginCreateDate != null and params.beginCreateDate != '' and params.endCreateDate != null and params.endCreateDate != ''" >
and wps.create_date between #{params.beginCreateDate} and #{params.endCreateDate}
</if>
</where>
</select>
<select id= "selectWmsProductStockByProductStockId" parameterType= "Long" resultMap= "WmsProductStockResult" >
<include refid= "selectWmsProductStockVo" />
where product_stock_id = #{productStockId}
where wps. product_stock_id = #{productStockId}
</select>
<insert id= "insertWmsProductStock" parameterType= "WmsProductStock" useGeneratedKeys= "true" keyProperty= "productStockId" >
<insert id= "insertWmsProductStock" parameterType= "WmsProductStock" useGeneratedKeys= "true"
keyProperty="productStockId">
insert into wms_product_stock
<trim prefix= "(" suffix= ")" suffixOverrides= "," >
<if test= "warehouseId != null" > warehouse_id,</if>
@ -136,7 +165,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</update>
<delete id= "deleteWmsProductStockByProductStockId" parameterType= "Long" >
delete from wms_product_stock where product_stock_id = #{productStockId}
delete
from wms_product_stock
where product_stock_id = #{productStockId}
</delete>
<delete id= "deleteWmsProductStockByProductStockIds" parameterType= "String" >
@ -147,13 +178,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</delete>
<select id= "getProductStockTotalAmount" resultType= "BigDecimal" parameterType= "WmsProductStock" >
select sum(total_amount) from wms_product_stock
<where >
@ -169,12 +193,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id= "selectProductStockByLocationAndBatchAndSaleOrderId" resultMap= "WmsProductStockResult" >
<include refid= "selectWmsProductStockVo" />
where location_code = #{locationCode} and product_batch = #{productBatch} and sale_order_id=#{saleOrderId} and stock_type = #{stockType}
where location_code = #{locationCode} and product_batch = #{productBatch} and sale_order_id=#{saleOrderId} and
stock_type = #{stockType}
</select>
<select id= "selectWmsProductStockInList" parameterType= "WmsProductStock" resultMap= "WmsProductStockResult" >
<include refid= "selectWmsProductStockVo" />
<where >
@ -197,10 +220,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</select>
<select id= "selectWmsProductStockJoinList" parameterType= "WmsProductStock" resultMap= "WmsProductStockResult" >
select wps.product_stock_id, wps.warehouse_id, wps.location_code, wps.stock_type, wps.product_batch, wps.quality_status, wps.product_id,
wps.plan_code, wps.plan_detail_code, wps.total_amount, wps.frozen_amount, wps.occupy_amount, wps.active_flag, wps.instock_date,
select wps.product_stock_id, wps.warehouse_id, wps.location_code, wps.stock_type, wps.product_batch,
wps.quality_status, wps.product_id,
wps.plan_code, wps.plan_detail_code, wps.total_amount, wps.frozen_amount, wps.occupy_amount, wps.active_flag,
wps.instock_date,
mai.material_code,mai.material_name
from wms_product_stock wps left join mes_base_material_info mai on wps.product_id = mai.material_id
@ -225,10 +249,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</select>
<select id= "selectWmsProductStocksBySaleorder" parameterType= "WmsProductStock" resultMap= "WmsProductStockResult" >
select wps.warehouse_id,wps.sale_order_id,wps.product_id,sum(total_amount) total_amount,sum(frozen_amount) frozen_amount,sum(occupy_amount) occupy_amount,
select wps.warehouse_id,wps.sale_order_id,wps.product_id,sum(total_amount) total_amount,sum(frozen_amount)
frozen_amount,sum(occupy_amount) occupy_amount,
mbmi.material_code,mbmi.material_name,
wbw.warehouse_name,mso.order_amount,mso.saleorder_code,
(select sum(wpo.apply_qty) from wms_product_outstock wpo where wpo.sale_order_id=wps.sale_order_id and wpo.warehouse_id=wps.warehouse_id and wpo.product_id=wps.product_id and (wpo.execute_status='0' or wpo.execute_status='1')) apply_amount
(select sum(wpo.apply_qty) from wms_product_outstock wpo where wpo.sale_order_id=wps.sale_order_id and
wpo.warehouse_id=wps.warehouse_id and wpo.product_id=wps.product_id and (wpo.execute_status='0' or
wpo.execute_status='1')) apply_amount
from wms_product_stock wps
left join mes_base_material_info mbmi on wps.product_id=mbmi.material_id
left join wms_base_warehouse wbw on wps.warehouse_id=wbw.warehouse_id
@ -243,7 +270,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</select>
<!-- select id="selectWmsProductStocksBySaleorder" parameterType="WmsProductStock" resultMap="WmsProductStockResult">
select wgb.warehouse_id,wgb.saleorder_code,wgb.product_id,mso.order_amount,wgb.total_amount,wgb.frozen_amount,wgb.occupy_amount,wbw.warehouse_name,mbmi.material_code,mbmi.material_name from mes_sale_order mso left join
(select wps.warehouse_id,wps.saleorder_code,wps.product_id,sum(total_amount) total_amount,sum(frozen_amount) frozen_amount,sum(occupy_amount) occupy_amount from wms_product_stock wps where wps.total_amount>0 and wps.stock_type='3'