|
|
|
@ -102,6 +102,12 @@ |
|
|
|
<if test="query.safetyStock == '安全'"> |
|
|
|
and A.qty_on_hand <![CDATA[>]]> B.min_stock |
|
|
|
</if> |
|
|
|
<if test="query.safetyStock == '不安全' and (query.securityMethod == '库存' or query.securityMethod == '' or query.securityMethod == null )"> |
|
|
|
and A.qty_on_hand <![CDATA[<=]]> B.min_stock |
|
|
|
</if> |
|
|
|
<if test="query.safetyStock == '不安全' and query.securityMethod == '库存和在途'"> |
|
|
|
and A.qty_on_hand + isnull(A.qty_of_po,0.0) <![CDATA[<=]]> B.min_stock |
|
|
|
</if> |
|
|
|
</where> |
|
|
|
GROUP BY |
|
|
|
<if test="query.groupType == 0"> |
|
|
|
@ -110,12 +116,6 @@ |
|
|
|
<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> |
|
|
|
|
|
|
|
<update id="updateQtyOfPoByIdOfAdd"> |
|
|
|
@ -129,4 +129,87 @@ |
|
|
|
<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 |
|
|
|
left join accessBu D on A.site=D.site and A.citem_code=d.bu_no and D.username=#{query.username} |
|
|
|
<where> |
|
|
|
A.site = #{query.site} and D.username is not null |
|
|
|
and A.batch_no is not null and b.part_no is not null |
|
|
|
<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> |