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.
 
 
 
 
 
 

191 lines
8.0 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.gaotao.modules.productionPicking.dao.ProductionPickingMapper">
<!-- 获取生产出库单列表 -->
<select id="getOutboundList" resultType="java.util.Map">
select
b.site,
b.NotifyNo as outboundNo,
b.bu AS buNo,
'' AS relatedNo,
'' AS relatedLineNo,
0 as totalLabels,
0 as availableLabels,
SUM(CAST(a.QtyToIssue AS float)) as totalQty,
0 as availableQty ,
b.NotifyDate as required_outbound_date,
0 AS pickedLabels,
0 AS pickedQty
from SOIssueNotifyHeader B
INNER JOIN SOIssueNotifyOrderMaterialList a ON A.SITE = B.SITE AND A.NotifyNo = B.NotifyNo
INNER JOIN SOIssueNotifyOrderList D ON A.SITE = D.SITE AND A.NotifyNo = D.NotifyNo AND D.ItemNo = A.ItemNo
where a.site = #{site} and b.bu in (select bu_no from AccessBu where username = #{userName})
AND b.Status = '待出库'
AND a.warehouse_id = #{warehouseId}
<if test="searchCode != null and searchCode != ''">
AND (b.NotifyNo LIKE CONCAT('%', #{searchCode}, '%') or D.SOOrderNo LIKE CONCAT('%', #{searchCode}, '%'))
</if>
<!-- <if test="searchCode == null or searchCode == ''">-->
<!-- AND CONVERT(DATE, b.NotifyDate) = CONVERT(DATE, GETDATE())-->
<!-- </if>-->
GROUP BY
b.site, b.NotifyNo, b.bu ,b.NotifyDate
ORDER BY b.NotifyDate DESC
</select>
<!-- 获取出库单详情 -->
<select id="getOutboundDetails" resultType="java.util.Map">
select
b.site,
b.NotifyNo as outboundNo,
b.bu AS buNo,
#{relatedNo} AS relatedNo,
'' AS relatedLineNo,
0 as totalLabels,
0 as availableLabels,
SUM(CAST(a.QtyToIssue AS float)) as totalQty,
0 as availableQty ,
b.NotifyDate as required_outbound_date,
0 AS pickedLabels,
0 AS pickedQty
from SOIssueNotifyHeader B
INNER JOIN SOIssueNotifyOrderMaterialList a ON A.SITE = B.SITE AND A.NotifyNo = B.NotifyNo
WHERE b.site = #{site}
AND b.bu = #{buNo}
AND b.NotifyNo = #{outboundNo}
AND a.warehouse_id = #{warehouseId}
GROUP BY b.site, b.NotifyNo, b.bu ,b.NotifyDate
</select>
<!-- 验证标签与出库单是否匹配 -->
<select id="validateLabelWithOutbound" resultType="java.util.Map">
select
inv.roll_no AS labelCode,
inv.part_no AS partNo,
inv.qty_on_hand AS quantity,
inv.batch_no AS batchNo,
inv.status AS status,
inv.warehouse_id AS warehouseId,
inv.location_id AS locationId
from inventory_stock inv
inner join (select t.site, ComponentPartNo,sum(QtyToIssue) as QtyToIssue from SOIssueNotifyOrderMaterialList t
inner join SOIssueNotifyOrderList b on t.site = b.site and t.NotifyNo = b.notifyno and t.ItemNo = b.itemno
WHERE t.site = #{site} and t.NotifyNo = #{outboundNo} and b.soorderno = #{relatedNo} group by t.site, ComponentPartNo)
a on A.site = inv.site and A.ComponentPartNo = inv.part_no
WHERE
inv.site = #{site}
AND inv.parent_roll_no =#{labelCode}
AND inv.warehouse_id = #{warehouseId}
AND inv.status = '在库'
AND inv.qty_on_hand > 0
</select>
<!-- 更新出库单状态 -->
<update id="updateOutboundStatus">
UPDATE inventory_stock
SET STATUS = #{status},
status_tb = 'E',
LATEST_OUT_DATE = getDate()
WHERE ROLL_NO IN
<foreach collection="labelCodes" item="labelCode" open="(" separator="," close=")">
#{labelCode}
</foreach>
AND SITE = #{site}
<if test="buNo != null and buNo != ''">
AND BU_NO = #{buNo}
</if>
</update>
<!-- 获取出库单物料清单 -->
<select id="getMaterialList" resultType="java.util.Map">
select
b.site,
b.NotifyNo as outboundNo,
b.bu AS buNo,
a.ComponentPartNo AS partNo,
P.PartDescription AS partDesc,
SUM(CAST(a.QtyToIssue AS float)) as requiredQty,
sum(ISNULL(a.actual_out_qty,0)) as pickedQty ,
SUM(ISNULL(S.RollQty,0)) as scansQty --本次扫描数量
from SOIssueNotifyHeader B
INNER JOIN SOIssueNotifyOrderList C ON B.SITE = C.SITE AND B.NotifyNo = C.NotifyNo
INNER JOIN SOIssueNotifyOrderMaterialList a ON A.SITE = C.SITE AND A.NotifyNo = C.NotifyNo AND C.ItemNo = A.ItemNo
INNER JOIN PART P ON A.SITE = P.SITE AND A.ComponentPartNo = P.PARTNO
LEFT JOIN ScannedRollTempTable S ON A.Site = S.site AND A.ComponentPartNo = S.part_no AND C.SOOrderNo = S.OrderNo
where a.site = #{site}
<if test="buNo != null and buNo != ''">
AND b.bu = #{buNo}
</if>
AND b.Status = '待出库'
AND a.warehouse_id = #{warehouseId}
AND B.NotifyNo = #{outboundNo}
AND C.SOOrderNo = #{relatedNo}
GROUP BY b.site, b.NotifyNo, b.bu , a.ComponentPartNo, P.PartDescription
</select>
<!-- 获取出库单物料明细列表 -->
<select id="getOutboundMaterialDetails" resultType="java.util.Map">
SELECT
A.Site as site,
A.NotifyNo as outboundNo, -- 出库单号
A.SOOrderNo as orderNo, -- 工单号
A.FGPartNo as partNo, -- 物料编码
B.PartDescription as partDescription, -- 物料名称
A.IssureQty as requiredQty, -- 需求数量
b.UMID AS umId, -- 计量单位
SUM (C.QtyToIssue) as pickedQty, --
SUM (ISNULL(D.roll_qty, 0)) as totalQty
FROM SOIssueNotifyOrderList A
INNER JOIN PART B ON A.SITE = B.SITE AND A.FGPartNo = B.PartNo
INNER JOIN SOIssueNotifyOrderMaterialList C ON A.SITE = B.SITE AND A.NotifyNo = C.NotifyNo AND A.ItemNo = C.ItemNo
LEFT JOIN StockTransactionLog D ON C.SITE = D.SITE AND C.NotifyNo = D.document_no AND A.SOOrderNo = D.order_line_no
WHERE A.site = #{site} AND a.NotifyNo = #{outboundNo}
GROUP BY A.Site, A.NotifyNo, A.FGPartNo, B.PartDescription, A.IssureQty, b.UMID, A.SOOrderNo
</select>
<select id="getByRollNo" resultType="com.gaotao.modules.inventoryStock.entity.InventoryStock">
select
inv.roll_no AS labelCode,
inv.part_no AS partNo,
inv.qty_on_hand AS qty_on_hand,
inv.batch_no AS batchNo,
inv.status AS status,
inv.warehouse_id AS warehouseId,
inv.location_id AS locationId
from inventory_stock inv
inner join (select site,ComponentPartNo,sum(QtyToIssue) as QtyToIssue from SOIssueNotifyOrderMaterialList t
WHERE site = #{site} and NotifyNo = #{outboundNo} group by site,ComponentPartNo) a on A.site = inv.site and A.ComponentPartNo = inv.part_no
WHERE
inv.site = #{site}
AND inv.roll_no =#{rollNo}
AND inv.warehouse_id = #{warehouseId}
AND inv.status = '在库'
AND inv.qty_on_hand > 0
</select>
<update id="updateSoBomPickedQty">
UPDATE SOBOM
SET QtyIssue = isnull(QtyIssue, 0) + #{transQty}
WHERE Site = #{site}
AND OrderNo = #{relatedNo}
AND ComponentPartNo = #{partNo}
</update>
<!-- 获取已扫描标签列表(从缓存表) -->
<select id="getScannedLabelList" resultType="java.util.Map">
SELECT
site,
bu_no as buNo,
part_no as partNo,
RollNo as labelCode,
RollQty as quantity
FROM ScannedRollTempTable
WHERE site = #{site}
AND bu_no = #{buNo}
AND NotifyNo = #{outboundNo}
AND OrderNo = #{relatedNo}
ORDER BY RollNo DESC
</select>
</mapper>