|
|
<?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.inboundNotification.dao.InboundNotificationHeadMapper">
<!-- 获取检验合格待入库列表 --> <select id="getQualifiedInboundList" resultType="java.util.Map"> SELECT h.site, h.order_no AS inboundNo, h.bu_no AS buNo, '' AS batchNo, h.required_inbound_date AS inspectionDate, SUM(CASE WHEN pr.hardtag_in_flag = '已入库' THEN 1 ELSE 0 END) AS labelinCount, -- 已入库标签数 COUNT(DISTINCT pr.roll_no) AS totalLabels, -- 需入库标签数 SUM(CASE WHEN pr.hardtag_in_flag = '已入库' THEN ISNULL(pr.roll_qty, 0) ELSE 0 END) AS totalinLabels, -- 已入库物料总数 D.required_qty as labelCount --需入库总数 FROM inbound_notification_head h INNER JOIN inbound_notification_detail d ON h.site = d.site and h.bu_no = d.bu_no and h.order_no = d.order_no LEFT JOIN po_order_roll_no pr ON d.site = pr.site and d.bu_no = pr.bu_no and d.inspection_no = pr.inspection_no AND d.part_no = pr.part_no WHERE h.site = #{site} and h.bu_no in (select bu_no from AccessBu where username = #{userName}) and h.order_type = '采购入库' and h.close_flag = 'N' AND h.order_status = '待入库' and d.in_warehouse = #{warehouseId} <if test="searchCode != null and searchCode != ''"> AND ( h.order_no LIKE CONCAT('%', #{searchCode}, '%') OR d.related_order_no LIKE CONCAT('%', #{searchCode}, '%') ) </if><!-- <if test="searchCode == null or searchCode == ''">--><!-- AND CONVERT(DATE, h.required_inbound_date) = CONVERT(DATE, GETDATE())--><!-- </if>--> GROUP BY h.site,h.bu_no,h.order_no,h.required_inbound_date ,D.required_qty ORDER BY h.required_inbound_date DESC </select>
<!-- 获取入库单详情 --> <select id="getInboundDetails" resultType="java.util.Map"> SELECT h.site, h.order_no as inboundNo, h.site as site, h.bu_no as buNo, '' as batchNo, h.required_inbound_date as inspectionDate, SUM(CASE WHEN hardtag_in_flag = '已入库' then 1 else 0 end) labelinCount, --已入库标签数 COUNT(DISTINCT pr.roll_no) as totalLabels , --需入库标签数 SUM(CASE WHEN hardtag_in_flag = '已入库' then CAST(roll_qty AS float) else 0 end) totalinLabels,--已入库物料总数 D.required_qty as labelCount --需入库总数 FROM inbound_notification_head h INNER JOIN inbound_notification_detail d ON h.site = d.site and h.bu_no = d.bu_no and h.order_no = d.order_no LEFT JOIN po_order_roll_no pr ON d.site = pr.site and d.bu_no = pr.bu_no and d.inspection_no = pr.inspection_no AND d.part_no = pr.part_no WHERE h.site = #{site} AND h.bu_no = #{buNo} AND h.order_no = #{orderNo} GROUP BY h.order_no, h.site, h.bu_no, h.required_inbound_date,D.required_qty </select>
<!-- 更新入库单状态 --> <update id="updateInboundStatus"> UPDATE h SET h.order_status = #{status}, h.updated_date = GETDATE(), h.updated_by = 'SYSTEM' FROM inbound_notification_head h WHERE h.order_no = #{orderNo} AND h.site = #{site} AND h.bu_no = #{buNo} </update>
<!-- 获取物料清单 --> <select id="getMaterialList" resultType="java.util.Map"> SELECT d.site, d.bu_no, d.part_no as partNo, d.part_desc, SUM(CASE WHEN hardtag_in_flag = '已入库' then CAST(roll_qty AS float) else 0 end) totalinLabels,--已入库数 D.required_qty as labelCount --需入库总数 FROM inbound_notification_detail d LEFT JOIN po_order_roll_no pr ON d.site = pr.site and d.bu_no = pr.bu_no and d.inspection_no = pr.inspection_no AND d.part_no = pr.part_no WHERE d.SITE = #{site} AND d.bu_no = #{buNo} AND d.order_no = #{inboundNo} group by d.site, d.bu_no,d.part_no, d.part_desc,D.required_qty </select>
<!-- 验证库位是否存在且可用 --> <select id="validateLocation" resultType="java.util.Map"> SELECT LocationID as locationCode, WareHouseID as warehouseId, LocationName as locationName, Active as status, site FROM Location WHERE LocationID = #{locationCode} AND site = #{site} </select>
<!-- 检查入库单的所有标签是否都已入库 --> <select id="checkAllLabelsInbound" resultType="java.util.Map"> SELECT COUNT(DISTINCT pr.roll_no) as totalLabels, SUM(CASE WHEN pr.hardtag_in_flag = '已入库' THEN 1 ELSE 0 END) as inboundLabels FROM inbound_notification_head h INNER JOIN inbound_notification_detail d ON h.order_no = d.order_no AND h.site = d.site LEFT JOIN po_order_roll_no pr ON d.order_no = pr.inspection_no AND d.part_no = pr.part_no WHERE h.order_no = #{orderNo} AND h.site = #{site} AND h.bu_no = #{buNo} </select>
<!-- 查询收获入库单 --> <select id="searchInboundNotification" parameterType="com.gaotao.modules.inboundNotification.entity.vo.InboundNotificationHeadVo" resultType="com.gaotao.modules.inboundNotification.entity.vo.InboundNotificationHeadVo"> SELECT a.site, a.bu_no, dbo.get_bu_desc(a.site, a.bu_no) as buDesc, a.order_no, a.order_type, a.order_status, a.supplier_id, b.SupplierName, a.related_order_no, a.related_order_line_no, a.required_inbound_date, a.remarks, a.erp_order_no, a.erp_order_line_no, a.erp_order_date, a.created_by, a.created_date, a.updated_by, a.updated_date, a.assigned_by, a.assigned_date, a.closed_by, a.closed_date, a.archived_by, a.archived_date, a.orderref1, a.orderref2, a.orderref3, a.orderref4, a.orderref5, a.order_date, a.close_flag, a.in_warehouse, a.required_qty_count, a.order_qty, a.show_in_query_flag, r.crdname as category, a.department_no, d.department_desc as departmentName FROM inbound_notification_head as a left join Supplier as b on a.site = b.site and a.supplier_id = b.SupplierID left join Rdstyle r on a.category = r.crdcode and r.bRdFlag = '入' left join erp_department d on a.department_no = d.department_no <where> a.site in (select site from AccessSite where userID = #{query.userName}) and a.bu_no in (select bu_no from AccessBu where username = #{query.userName}) <if test="query.orderNo != null and query.orderNo != ''"> AND a.order_no like '%' + #{query.orderNo} + '%' </if> <if test="query.orderType != null and query.orderType != ''"> AND a.order_type = #{query.orderType} </if> <if test="query.orderStatus != null and query.orderStatus != ''"> AND a.order_status in <foreach collection="query.statusArr" close=")" open="(" item="item" separator=","> #{item} </foreach> </if> <if test="query.startDate != null "> AND a.required_inbound_date >= #{query.startDate} </if> <if test="query.endDate != null "> AND #{query.endDate} >= a.required_inbound_date </if> </where> </select>
<insert id="saveInboundNotification" parameterType="com.gaotao.modules.inboundNotification.entity.vo.InboundNotificationHeadVo"> INSERT INTO inbound_notification_head (site, bu_no, order_no, order_type, order_status, supplier_id, related_order_no, related_order_line_no, required_inbound_date, remarks, erp_order_no, erp_order_line_no, erp_order_date, created_by, created_date, category, department_no) VALUES (#{site}, #{buNo}, #{orderNo}, #{orderType}, #{orderStatus}, #{supplierId}, #{relatedOrderNo}, #{relatedOrderLineNo}, #{requiredInboundDate}, #{remarks}, #{erpOrderNo}, #{erpOrderLineNo}, #{erpOrderDate}, #{createdBy}, GETDATE(), #{category}, #{departmentNo}) </insert>
<delete id="deleteInboundNotification"> DELETE FROM inbound_notification_head WHERE site = #{site} AND bu_no = #{buNo} AND order_no = #{orderNo} </delete>
<update id="closeInboundNotification"> UPDATE inbound_notification_head SET order_status = #{orderStatus}, close_flag = 'Y', closed_by = #{closedBy}, closed_date = GETDATE() WHERE site = #{site} AND bu_no = #{buNo} AND order_no = #{orderNo} AND close_flag = 'N' </update>
<update id="issueInboundNotification"> UPDATE inbound_notification_head SET assigned_by = #{assignedBy}, assigned_date = GETDATE() WHERE site = #{site} AND bu_no = #{buNo} AND order_no = #{orderNo} </update>
<update id="updateInboundNotification"> UPDATE inbound_notification_head SET supplier_id = #{supplierId}, remarks = #{remarks}, order_status = #{orderStatus}, category = #{category}, department_no = #{departmentNo}, updated_by = #{updatedBy}, updated_date = GETDATE() WHERE site = #{site} AND bu_no = #{buNo} AND order_no = #{orderNo} </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 = #{inboundNo} ORDER BY RollNo DESC </select>
<!-- 获取物料可用库存(调用存储过程) --> <select id="getInventoryStock" resultType="java.util.Map" statementType="CALLABLE"> {call GetInventoryStock( #{site, mode=IN, jdbcType=VARCHAR}, #{notifyNo, mode=IN, jdbcType=VARCHAR}, #{notifyType, mode=IN, jdbcType=VARCHAR}, #{orderNo, mode=IN, jdbcType=VARCHAR}, #{orderLineNo, mode=IN, jdbcType=VARCHAR}, #{partNo, mode=IN, jdbcType=VARCHAR}, #{warehouseId, mode=IN, jdbcType=VARCHAR} )} </select>
<!-- 查询入库类别列表 --> <select id="getInboundCategoryList" resultType="java.util.Map"> SELECT crdcode, crdname FROM Rdstyle WHERE bRdFlag = '入' </select>
<!-- 查询部门列表 --> <select id="getDepartmentList" resultType="java.util.Map"> SELECT department_no AS departmentNo, department_desc AS departmentDesc FROM erp_department </select>
<!-- 删除标签导入临时表数据 --> <delete id="deleteLabelImportTemp"> DELETE FROM label_import_temp WHERE site = #{site} AND bu_no = #{buNo} AND order_no = #{orderNo} </delete>
<!-- 插入标签导入临时表数据 --> <insert id="insertLabelImportTemp"> INSERT INTO label_import_temp ( site, bu_no, order_no, order_type, related_order_no, related_order_line_no, part_no, roll_no, batch_no, roll_qty ) VALUES ( #{site}, #{buNo}, #{orderNo}, #{orderType}, #{relatedOrderNo}, #{relatedOrderLineNo}, #{partNo}, #{rollNo}, #{batchNo}, #{rollQty} ) </insert>
<!-- 调用存储过程 UspImportRoll --> <select id="callUspImportRoll" statementType="CALLABLE" parameterType="java.util.Map"> {call UspImportRoll( #{site, mode=IN, jdbcType=VARCHAR}, #{buNo, mode=IN, jdbcType=VARCHAR}, #{orderNo, mode=IN, jdbcType=VARCHAR}, #{orderType, mode=IN, jdbcType=VARCHAR}, #{resultCode, mode=OUT, jdbcType=VARCHAR}, #{resultMsg, mode=OUT, jdbcType=VARCHAR} )} </select></mapper>
|