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.
214 lines
10 KiB
214 lines
10 KiB
<?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.xujie.sys.modules.pms.mapper.InventoryStockMapper">
|
|
|
|
<!-- 可根据自己的需求,是否要使用 -->
|
|
<resultMap type="com.xujie.sys.modules.pms.entity.InventoryStockEntity" id="inventoryStockMap">
|
|
<result property="site" column="site"/>
|
|
<result property="warehouseId" column="warehouse_id"/>
|
|
<result property="partNo" column="part_no"/>
|
|
<result property="batchNo" column="batch_no"/>
|
|
<result property="locationId" column="location_id"/>
|
|
<result property="firstInDate" column="first_in_date"/>
|
|
<result property="latestOutDate" column="latest_out_date"/>
|
|
<result property="latestInDate" column="latest_in_date"/>
|
|
<result property="activeDate" column="active_date"/>
|
|
<result property="inQty" column="in_qty"/>
|
|
<result property="outQty" column="out_qty"/>
|
|
<result property="qtyOnHand" column="qty_on_hand"/>
|
|
<result property="qtyReserved" column="qty_reserved"/>
|
|
<result property="inStandardValue" column="in_standard_value"/>
|
|
<result property="inActualValue" column="in_actual_value"/>
|
|
<result property="outStandardValue" column="out_standard_value"/>
|
|
<result property="outActualValue" column="out_actual_value"/>
|
|
<result property="partnerId" column="partner_id"/>
|
|
<result property="partnerType" column="partner_type"/>
|
|
<result property="latestCountDate" column="latest_count_date"/>
|
|
<result property="freezeFlag" column="freeze_flag"/>
|
|
<result property="qtyTmp" column="qty_tmp"/>
|
|
<result property="manuFactureDate" column="manu_facture_date"/>
|
|
<result property="expiredDate" column="expired_date"/>
|
|
<result property="qtyToIssue" column="qty_to_issue"/>
|
|
<result property="id" column="id"/>
|
|
<result property="citemCode" column="citem_code"/>
|
|
<result property="qtyOfPo" column="qty_of_po"/>
|
|
</resultMap>
|
|
|
|
<select id="queryPage" resultType="com.xujie.sys.modules.pms.entity.InventoryStockVoData">
|
|
SELECT
|
|
a.citem_code,
|
|
min(A.id) id,
|
|
A.site,
|
|
min(A.warehouse_id) AS warehouse_id,
|
|
A.part_no,min(A.batch_no) as batch_no,
|
|
min(A.location_id) AS location_id,
|
|
sum(isnull(A.in_qty, 0)) AS inQty,
|
|
sum(isnull(A.out_qty, 0)) AS outQty,
|
|
sum(isnull(A.qty_on_hand, 0)) AS qtyOnHand,
|
|
B.part_description,
|
|
min(B.spec) AS spec,
|
|
B.min_stock,
|
|
B.max_stock,
|
|
min(A.partner_id) AS partner_id,
|
|
min(A.first_in_date) AS first_in_date,
|
|
B.average_price,
|
|
B.umid,
|
|
(sum(isnull(A.qty_on_hand, 0)) * B.average_price) as totalCost,
|
|
dbo.get_bu_desc(A.site, A.citem_code) buDesc
|
|
from inventory_stock A
|
|
left join part_spare B on A.site = B.site and A.part_no = B.part_no and a.citem_code = b.bu_no
|
|
<where>
|
|
A.site in (select site from eam_access_site where username = #{query.username})
|
|
and (A.site + '-' + A.citem_code) in (select * from dbo.query_bu(#{query.username}))
|
|
and A.batch_no is not null and b.part_no is not null
|
|
<if test="query.buDesc != null and query.buDesc != ''">
|
|
AND dbo.get_bu_desc (a.site, a.citem_code) = #{query.buDesc}
|
|
</if>
|
|
<if test="query.active != null and query.active != ''">
|
|
and B.active = #{query.active}
|
|
</if>
|
|
<if test="query.batchNo != null and query.batchNo != ''">
|
|
and A.batch_no like '%'+#{query.batchNo}+'%'
|
|
</if>
|
|
<if test="query.warehouseId != null and query.warehouseId != ''">
|
|
and A.warehouse_id like '%'+#{query.warehouseId}+'%'
|
|
</if>
|
|
<if test="query.locationId != null and query.locationId != ''">
|
|
and A.location_id like '%'+#{query.locationId}+'%'
|
|
</if>
|
|
<if test="query.partNo != null and query.partNo != ''">
|
|
and A.part_no like '%'+#{query.partNo}+'%'
|
|
</if>
|
|
<if test="query.partDescription != null and query.partDescription != ''">
|
|
and B.part_description like '%'+#{query.partDescription}+'%'
|
|
</if>
|
|
<if test="query.spec != null and query.spec != '' ">
|
|
and B.spec like '%'+#{query.spec}+'%'
|
|
</if>
|
|
<if test="query.startFirstInDate != null and query.startFirstInDate != ''">
|
|
and A.first_in_date >= #{query.startFirstInDate}
|
|
</if>
|
|
<if test="query.endFirstInDate != null and query.endFirstInDate != ''">
|
|
and A.first_in_date <![CDATA[<=]]> #{query.endFirstInDate}
|
|
</if>
|
|
<if test="query.startQtyOnHand != null ">
|
|
and A.qty_on_hand >= #{query.startQtyOnHand}
|
|
</if>
|
|
<if test="query.endQtyOnHand !=null ">
|
|
and A.qty_on_hand <![CDATA[<=]]> #{query.endQtyOnHand}
|
|
</if>
|
|
<if test="query.safetyStock == '安全'">
|
|
and A.qty_on_hand <![CDATA[>]]> B.min_stock
|
|
</if>
|
|
<if test="query.safetyStock == '不安全'">
|
|
and A.qty_on_hand <![CDATA[<=]]> B.min_stock
|
|
</if>
|
|
</where>
|
|
GROUP BY
|
|
<if test="query.groupType == 0">
|
|
A.site, A.part_no, B.part_description, A.batch_no, b.min_stock, b.max_stock, B.average_price, B.umid, a.citem_code
|
|
</if>
|
|
<if test="query.groupType == 1">
|
|
A.site, A.part_no, B.part_description, b.min_stock, b.max_stock, B.average_price, B.umid, a.citem_code
|
|
</if>
|
|
</select>
|
|
|
|
<update id="updateQtyOfPoByIdOfAdd">
|
|
update inventory_stock set qty_of_po = isnull(qty_of_po,0) + #{qtyOfPo} where id = #{id}
|
|
</update>
|
|
|
|
<update id="updateQtyOnHandByIdOfAdd">
|
|
update inventory_stock set qty_on_hand = isnull(qty_on_hand,0) + #{qtyOfPo}, qty_of_po = isnull(qty_of_po,0) - #{qtyOfPo} where id = #{id}
|
|
</update>
|
|
|
|
<update id="updateQtyOfPoByIdOfSub">
|
|
update inventory_stock set qty_of_po = isnull(qty_of_po,0) - #{qtyOfPo} where id = #{id}
|
|
</update>
|
|
|
|
<select id="queryPageByPo" resultType="com.xujie.sys.modules.pms.entity.InventoryStockVoData">
|
|
SELECT
|
|
A.citem_code,
|
|
min(A.id) as id,
|
|
A.site,
|
|
min(A.warehouse_id) AS warehouse_id,
|
|
A.part_no,min(A.batch_no) as batch_no,
|
|
min(A.location_id) AS location_id,
|
|
sum(isnull( A.in_qty , 0 )) AS inQty,
|
|
sum(isnull( A.out_qty , 0 )) AS outQty,
|
|
sum(isnull( A.qty_on_hand , 0 )) AS qtyOnHand,
|
|
B.part_description,
|
|
min(B.spec) AS spec,
|
|
B.min_stock,
|
|
B.max_stock,
|
|
min(A.partner_id) AS partner_id,
|
|
min(A.first_in_date) AS first_in_date,
|
|
B.average_price,
|
|
B.umid,
|
|
sum(isnull(A.qty_of_po,0)) as qty_of_po,
|
|
(sum(isnull( A.qty_on_hand , 0 )) * B.average_price) as totalCost,
|
|
dbo.get_bu_desc( A.site,A.citem_code) buDesc
|
|
from inventory_stock A
|
|
left join part_spare B on A.site = B.site and A.part_no = B.part_no and a.citem_code = b.bu_no
|
|
<where>
|
|
A.site in (select site from eam_access_site where username = #{query.username})
|
|
and (A.site + '-' + A.citem_code) in (select * from dbo.query_bu(#{query.username}))
|
|
and A.batch_no is not null and b.part_no is not null
|
|
<if test="query.buDesc != null and query.buDesc != ''">
|
|
AND dbo.get_bu_desc (a.site, a.citem_code) = #{query.buDesc}
|
|
</if>
|
|
<if test="query.active != null and query.active != ''">
|
|
and B.active = #{query.active}
|
|
</if>
|
|
<if test="query.buNo != null and query.buNo != ''">
|
|
and a.citem_code = #{query.buNo}
|
|
</if>
|
|
<if test="query.batchNo != null and query.batchNo != ''">
|
|
and A.batch_no like '%'+#{query.batchNo}+'%'
|
|
</if>
|
|
<if test="query.warehouseId != null and query.warehouseId != ''">
|
|
and A.warehouse_id like '%'+#{query.warehouseId}+'%'
|
|
</if>
|
|
<if test="query.locationId != null and query.locationId != ''">
|
|
and A.location_id like '%'+#{query.locationId}+'%'
|
|
</if>
|
|
<if test="query.partNo != null and query.partNo != ''">
|
|
and A.part_no like '%'+#{query.partNo}+'%'
|
|
</if>
|
|
<if test="query.partDescription != null and query.partDescription != ''">
|
|
and B.part_description like '%'+#{query.partDescription}+'%'
|
|
</if>
|
|
<if test="query.spec != null and query.spec != '' ">
|
|
and B.spec like '%'+#{query.spec}+'%'
|
|
</if>
|
|
<if test="query.startFirstInDate != null and query.startFirstInDate != ''">
|
|
and A.first_in_date >= #{query.startFirstInDate}
|
|
</if>
|
|
<if test="query.endFirstInDate != null and query.endFirstInDate != ''">
|
|
and A.first_in_date <![CDATA[<=]]> #{query.endFirstInDate}
|
|
</if>
|
|
<if test="query.startQtyOnHand != null ">
|
|
and A.qty_on_hand >= #{query.startQtyOnHand}
|
|
</if>
|
|
<if test="query.endQtyOnHand !=null ">
|
|
and A.qty_on_hand <![CDATA[<=]]> #{query.endQtyOnHand}
|
|
</if>
|
|
<if test="query.safetyStock == '安全'">
|
|
and A.qty_on_hand <![CDATA[>]]> B.min_stock
|
|
</if>
|
|
</where>
|
|
GROUP BY
|
|
<if test="query.groupType == 0">
|
|
A.site, A.part_no, B.part_description, A.batch_no, b.min_stock, b.max_stock, B.average_price, B.umid,a.citem_code
|
|
</if>
|
|
<if test="query.groupType == 1">
|
|
A.site, A.part_no, B.part_description, b.min_stock, b.max_stock, B.average_price, B.umid,a.citem_code
|
|
</if>
|
|
<if test="query.safetyStock == '不安全' and (query.securityMethod == '库存' or query.securityMethod == '' or query.securityMethod == null )">
|
|
having sum(A.qty_on_hand) <![CDATA[<]]> B.min_stock
|
|
</if>
|
|
<if test="query.safetyStock == '不安全' and query.securityMethod == '库存和在途'">
|
|
having sum(A.qty_on_hand) + sum(isnull(A.qty_of_po,0.0)) <![CDATA[<]]> B.min_stock
|
|
</if>
|
|
</select>
|
|
</mapper>
|