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.
 
 
 
 
 
 

202 lines
8.4 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.outboundNotification.dao.OutboundNotificationDetailMapper">
<!-- 查询拣货出库单明细 -->
<select id="getOutboundDetail" resultType="com.gaotao.modules.outboundNotification.entity.vo.OutboundNotificationDetailVo" parameterType="com.gaotao.modules.outboundNotification.entity.vo.OutboundNotificationDetailVo">
SELECT
a.site,
a.bu_no,
a.order_no,
a.part_no,
a.part_desc,
a.unit,
c.umName,
a.required_qty,
a.out_warehouse,
b.WareHouseName as outWarehouseName,
a.out_batch_no,
a.created_by,
a.created_date,
a.updated_by,
a.updated_date,
a.order_qty,
a.related_order_no,
a.related_order_line_no,
a.actual_out_qty as actualStockOutQty
FROM outbound_notification_detail as a
left join WareHouse as b on a.site = b.site and a.bu_no = b.bu_no and a.out_warehouse = b.WareHouseID
left join um as c on a.site = c.site and a.unit = c.UMID
<where>
a.site = #{site} and a.bu_no = #{buNo} and a.order_no = #{orderNo}
<if test = "partNo != null and partNo != ''">
AND a.part_no = #{partNo}
</if>
</where>
</select>
<select id="getOutboundDetailWithRoll" resultType="com.gaotao.modules.outboundNotification.entity.vo.OutboundNotificationDetailVo" parameterType="com.gaotao.modules.outboundNotification.entity.vo.OutboundNotificationDetailVo">
SELECT
a.site,
a.bu_no,
a.order_no,
a.part_no,
a.part_desc,
a.unit,
a.required_qty,
a.out_warehouse,
a.out_batch_no,
a.created_by,
a.created_date,
a.updated_by,
a.updated_date,
a.order_qty,
a.related_order_no,
a.related_order_line_no,
isnull(sum(c.roll_qty),0) as rollQty,
case when a.required_qty-isnull(sum(c.roll_qty),0)>0 then Round( a.required_qty-isnull(sum(c.roll_qty),0),3)
else 0 end as unScanQty
FROM outbound_notification_detail as a
left join so_receive_boxes b on a.site=b.site and a.bu_no=b.bu_no and a.order_no=b.order_no
left join so_receive_box_rolls c on a.site=c.site and a.bu_no=c.bu_no and b.box_no=c.box_no and a.part_no=c.part_no
<where>
a.site = #{site} and a.bu_no = #{buNo} and a.order_no = #{orderNo}
<if test = "partNo != null and partNo != ''">
AND a.part_no = #{partNo}
</if>
</where>
GROUP BY
a.site,
a.bu_no,
a.order_no,
a.part_no,
a.part_desc,
a.unit,
a.required_qty,
a.out_warehouse,
a.out_batch_no,
a.created_by,
a.created_date,
a.updated_by,
a.updated_date,
a.order_qty,
a.related_order_no, a.related_order_line_no
</select>
<!-- 删除拣货出库单明细 -->
<delete id="deleteOutboundDetail" parameterType="com.gaotao.modules.outboundNotification.entity.vo.OutboundNotificationDetailVo">
DELETE FROM outbound_notification_detail
WHERE site = #{site} and bu_no = #{buNo} and order_no = #{orderNo} and part_no = #{partNo}
</delete>
<insert id="saveOutboundDetails">
INSERT INTO outbound_notification_detail
(site, bu_no, order_no, part_no, part_desc, unit, required_qty, out_warehouse,
out_batch_no, created_by, created_date, order_qty, related_order_no, related_order_line_no)
VALUES
<foreach collection="list" item="detail" separator=",">
(#{detail.site}, #{detail.buNo}, #{detail.orderNo}, #{detail.partNo}, #{detail.partDesc},
#{detail.unit}, #{detail.requiredQty,jdbcType=FLOAT}, #{detail.outWarehouse},
#{detail.outBatchNo}, #{detail.createdBy}, GETDATE(), #{detail.orderQty,jdbcType=FLOAT},
#{detail.relatedOrderNo}, #{detail.relatedOrderLineNo})
</foreach>
</insert>
<select id="getOutboundPartList" resultType="com.gaotao.modules.pms.entity.vo.PartInformationVo">
SELECT
a.site,
a.bu_no,
a.PartNo,
a.PartDescription as partDesc,
a.UMID as unit,
um.umName,
a.outbound_warehouse_id as outboundWarehouseId
FROM part as a
left join outbound_notification_detail as b on a.site = b.site and a.bu_no = b.bu_no and a.partNo = b.part_no and b.order_no = #{query.orderNo}
left join um as um on a.site = um.site and a.UMID = um.UMID
where a.site = #{query.site} and a.bu_no = #{query.buNo} and b.site is null
and a.PartNo not in
<foreach collection="query.arr" close=")" open="(" item="item" separator=",">
#{item}
</foreach>
<if test = "query.partNo != null and query.partNo != ''">
AND a.partNo like '%' + #{query.partNo} + '%'
</if>
<if test = "query.partDesc != null and query.partDesc != ''">
AND a.PartDescription like '%' + #{query.partDesc} + '%'
</if>
</select>
<delete id="deleteOutboundDetailByHead">
DELETE FROM outbound_notification_detail
WHERE site = #{site} AND bu_no = #{buNo} AND order_no = #{orderNo}
</delete>
<update id="updateOutboundDetails" parameterType="java.util.List">
UPDATE outbound_notification_detail
SET
required_qty = CASE
<foreach item="item" index="index" collection="list" open="" close="" separator=" ">
WHEN part_no = #{item.partNo} THEN #{item.requiredQty,jdbcType=DOUBLE}
</foreach>
ELSE required_qty
END,
out_warehouse = CASE
<foreach item="item" index="index" collection="list" open="" close="" separator=" ">
WHEN part_no = #{item.partNo} THEN #{item.outWarehouse}
</foreach>
ELSE out_warehouse
END
WHERE part_no IN
<foreach item="item" index="index" collection="list" open="(" separator="," close=")">
#{item.partNo}
</foreach>
AND site = #{list[0].site} and bu_no = #{list[0].buNo} and order_no = #{list[0].orderNo}
</update>
<select id="getOutboundDetail2" resultType="com.gaotao.modules.trans.entity.TransDetailSub" statementType="CALLABLE">
{call GetWarehouseEntryAndExitDetails(
#{site, mode=IN, jdbcType=VARCHAR},
#{buNo, mode=IN, jdbcType=VARCHAR},
#{orderNo, mode=IN, jdbcType=VARCHAR},
#{orderType, mode=IN, jdbcType=VARCHAR},
#{relatedOrderNo, mode=IN, jdbcType=VARCHAR},
#{relatedOrderLineNo, mode=IN, jdbcType=VARCHAR},
#{partNo, mode=IN, jdbcType=VARCHAR}
)}
</select>
<select id="getOutboundShopOrderList" resultType="com.gaotao.modules.outboundNotification.entity.vo.OutboundNotificationDetailVo">
SELECT
a.Site,
a.bu_no,
a.Order_No as related_order_no,
a.item_no as related_order_line_no,
a.Part_No,
a.part_desc as partDesc,
a.order_qty,
b.umid as unit,
um.umName,
SUM(a.roll_qty) AS requiredQty -- 可出库数量
FROM po_order_roll_no a
INNER JOIN part b WITH (NOLOCK) ON a.site = b.site AND a.part_no = b.partno
LEFT JOIN inventory_stock c WITH (NOLOCK) ON a.site = c.site AND a.roll_no = c.roll_no AND (c.status IN ('在库', '冻结') OR A.hardtag_in_flag ='未入库')
left join um as um on a.site = um.site and b.umid = um.umid
where a.site = #{query.site} and a.bu_no = #{query.buNo}
and a.Part_No not in
<foreach collection="query.arr" close=")" open="(" item="item" separator=",">
#{item}
</foreach>
<if test = "query.relatedOrderNo != null and query.relatedOrderNo != ''">
AND a.Order_No like '%' + #{query.relatedOrderNo} + '%'
</if>
<if test = "query.partNo != null and query.partNo != ''">
AND a.Part_No like '%' + #{query.partNo} + '%'
</if>
<if test = "query.partDesc != null and query.partDesc != ''">
AND a.part_desc like '%' + #{query.partDesc} + '%'
</if>
GROUP BY a.Site, a.bu_no, a.Order_No, a.item_no, a.Part_No, a.part_desc, a.order_qty, b.umid, um.umName
</select>
</mapper>