|
|
<?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.customer.dao.ShipmentIssueMapper">
<select id="getUserNotifyNo" resultType="SOIssueNotifyHeaderData"> select top 1 a.notify_no,a.site,a.notify_date,a.username,a.entered_date,a.receiver,a.department_id,a.remark,a.credit_flag,a.issue_flag, a.issue_result,a.plan_issue_date,a.real_issue_date,a.status,a.have_issue_record_flag,a.calc_flag,a.need_approve_flag,a.approved_flag, a.approver,a.approve_date,a.warehouse_id,a.record_version,a.out_work_order_flag,a.project_id,a.order_type,a.auth_rule_id,a.handler_username,a.handler_display,a.push_wcs_flag FROM SOIssueNotifyHeader a WITH (NOLOCK) WHERE a.site=#{site} AND a.username=#{username} AND a.status='UNISSUE' AND a.order_type='shipment' ORDER BY a.entered_date DESC </select> <!-- rqrq - 查询发货申请单订单明细(包含运输标志和配送区域) --> <select id="getNotifyNoDetail" resultType="com.gaotao.modules.notify.entity.SOIssueNotifyOrderList"> SELECT a.notify_no, a.site, a.item_no, a.fgpart_no, a.soorder_no, a.ops_item_no, a.seq_no, a.issure_qty, a.out_work_order_flag, a.location_no, a.need_date, a.release_no, a.sequence_no, a.push_wms_flag, a.transport_flag, a.production_area, ar.area_desc AS areaDesc FROM SOIssueNotifyOrderList a WITH (NOLOCK) LEFT JOIN area ar WITH (NOLOCK) ON a.production_area = ar.area_id WHERE a.site=#{site} AND a.notify_no=#{notifyNo} AND a.order_type='shipment' </select> <!-- 注意:不能用NOLOCK,结果用于生成新的item_no插入记录,脏读可能导致主键冲突 - rqrq --> <select id="getNextItemForShipmentOrderList" resultType="java.math.BigDecimal"> SELECT ISNULL(MAX(item_no), 0) + 1 FROM SOIssueNotifyOrderList WHERE site=#{site} AND notify_no=#{notifyNo} AND order_type='shipment' </select>
<insert id="saveIssueNotifyOrderList"> insert into SOIssueNotifyOrderList(notify_no,site,item_no,fgpart_no,soorder_no,issure_qty,out_work_order_flag,need_date,release_no,sequence_no,order_type,production_area,push_wms_flag,transport_flag) values(#{notifyNo},#{site},#{itemNo},#{fgPartNo},#{soorderNo},#{issureQty,jdbcType=DECIMAL},#{outWorkOrderFlag} ,#{needDate},#{releaseNo},#{sequenceNo},#{orderType},#{productionArea},#{pushWmsFlag},#{transportFlag}) </insert>
<!-- rqrq - 关联part_attribute表查询is_in_wh字段(去除order_type限制,支持所有订单类型) --> <select id="selectOrderMaterialList" resultType="com.gaotao.modules.customer.entity.vo.SOIssueNotifyOrderMaterialListShipmentVo"> SELECT a.notify_no ,a.site ,a.item_no ,a.BOM_item_no ,a.component_part_no ,a.qty_to_issue ,a.qty_to_issue_original ,a.issue_type ,a.remark ,a.order_type ,ISNULL(pa.is_in_wh, '未维护') as isInWh FROM SOIssueNotifyOrderMaterialList a LEFT JOIN part_attribute pa ON a.site=pa.site AND a.component_part_no=pa.part_no WHERE a.site = #{data.site} AND a.notify_no = #{data.notifyNo} AND a.item_no = #{data.itemNo} ORDER BY a.bom_item_no ASC; </select> <delete id="deleteNotifyUnissue"> delete from SOIssueNotifyOrderList where site=#{site} and notify_no=#{notifyNo} and item_no=#{itemNo} </delete> <delete id="deleteUnissueNotifyOrderMaterialListData"> delete from SOIssueNotifyOrderMaterialList where site=#{site} and notify_no=#{notifyNo} and item_no=#{itemNo} </delete>
<insert id="batchSaveShipmentMaterialListData"> insert into SOIssueNotifyOrderMaterialList (notify_no,site,item_no,BOM_item_no,component_part_no,qty_to_issue,qty_to_issue_original,issue_type,remark,order_type) values <foreach collection="data" separator="," item="item"> (#{item.notifyNo},#{item.site},#{item.itemNo},#{item.bOMItemNo},#{item.componentPartNo},#{item.qtyToIssue},#{item.qtyToIssueOriginal},#{item.issueType},rtrim(#{item.remark}),#{item.orderType}) </foreach> </insert> <!-- 优化:添加 WITH (ROWLOCK) 避免锁升级导致死锁 - rqrq --> <update id="updateNotifyStatus"> UPDATE SOIssueNotifyHeader WITH (ROWLOCK) SET plan_issue_date = #{planIssueDate}, remark = #{remark}, status = 'ISSUE' WHERE site = #{site} AND notify_no = #{notifyNo} </update>
<delete id="deleteNotifyHeader"> delete from SOIssueNotifyHeader where site=#{site} and notify_no=#{notifyNo} </delete> <delete id="deleteOrderMaterialList"> delete from SOIssueNotifyOrderMaterialList where site=#{site} and notify_no=#{notifyNo} </delete> <delete id="deleteOrderList"> delete from SOIssueNotifyOrderList where site=#{site} and notify_no=#{notifyNo} </delete> <select id="searchNotifyHeader" resultType="com.gaotao.modules.notify.entity.SOIssueNotifyHeader"> select a.notify_no,a.site,a.notify_date,a.username,a.entered_date,a.receiver,a.department_id,a.remark,a.credit_flag,a.issue_flag, a.issue_result,a.plan_issue_date,a.real_issue_date,a.status,a.have_issue_record_flag,a.calc_flag,a.need_approve_flag,a.approved_flag, a.approver,a.approve_date,a.warehouse_id,a.record_version,a.out_work_order_flag,a.project_id,a.order_type,a.auth_rule_id,a.handler_username,a.handler_display,a.push_wcs_flag FROM SOIssueNotifyHeader a WITH (NOLOCK) LEFT JOIN sys_user b WITH (NOLOCK) ON a.username=b.username
<where> and a.order_type='shipment' <if test="data.notifyNo != null and data.notifyNo != ''"> AND a.notify_no LIKE concat('%',#{data.notifyNo},'%') </if> <if test="data.status != null and data.status != ''"> AND a.status = #{data.status} </if> <if test = "data.username != null and data.username != ''"> AND a.username LIKE #{data.username} </if> <if test="data.startDate != null"> AND CONVERT(date, a.notify_date) >= CONVERT(date, #{data.startDate}) </if> <if test="data.endDate != null"> AND CONVERT(date, a.notify_date) < DATEADD(day, 1, CONVERT(date, #{data.endDate})) </if> <if test = "data.orderStatusList != null and data.orderStatusList.size()>0" > AND a.status in <foreach collection="data.orderStatusList" item="status" open="(" close=")" separator=","> #{status} </foreach> </if> <if test="data.pushWcsFlag != null and data.pushWcsFlag != ''"> AND a.push_wcs_flag = #{data.pushWcsFlag} </if> and a.status!='UNISSUE' </where> order by a.notify_no desc </select>
<!-- rqrq - 检查用户是否有未下达的shipment申请单 --> <select id="checkUserHasUnissueShipment" resultType="com.gaotao.modules.notify.entity.SOIssueNotifyHeader"> select top 1 a.notify_no,a.site,a.notify_date,a.username,a.entered_date,a.receiver,a.department_id,a.remark, a.credit_flag,a.issue_flag,a.issue_result,a.plan_issue_date,a.real_issue_date,a.status, a.have_issue_record_flag,a.calc_flag,a.need_approve_flag,a.approved_flag,a.approver,a.approve_date, a.warehouse_id,a.record_version,a.out_work_order_flag,a.project_id,a.order_type,a.auth_rule_id, a.handler_username,a.handler_display,a.push_wcs_flag FROM SOIssueNotifyHeader a WITH (NOLOCK) WHERE a.site=#{site} AND a.username=#{username} AND a.status='UNISSUE' AND a.order_type='shipment' ORDER BY a.entered_date DESC </select>
<!-- rqrq - 取消下达发货申请单(更新status为UNISSUE) --> <!-- 优化:添加 WITH (ROWLOCK) 避免锁升级导致死锁 - rqrq --> <update id="cancelIssueShipment"> UPDATE SOIssueNotifyHeader WITH (ROWLOCK) SET status = 'UNISSUE' WHERE site = #{site} AND notify_no = #{notifyNo} </update>
<!-- rqrq - 检查发货通知单物料库存匹配情况(只考虑立库) --> <select id="checkShipmentInventory" resultType="ShipmentInventoryCheckResult"> EXEC CheckShipmentIssueNotifyInventory #{site}, #{notifyNo} </select>
<delete id="deleteSOIssueNotifyOrderMaterialInList"> DELETE FROM SOIssueNotifyOrderMaterialList WHERE notify_no = #{notifyNo} AND site = #{site} AND item_no IN <foreach collection="items" item="item" separator="," open="(" close=")"> #{item} </foreach> AND order_type = 'shipment' </delete> <insert id="batchSaveSOIssueNotifyOrderMaterialList"> insert into SOIssueNotifyOrderMaterialList (notify_no,site,item_no,BOM_item_no,component_part_no,qty_to_issue,qty_to_issue_original,issue_type,remark,order_type) values <foreach collection="childList" separator="," item="item"> (#{item.notifyNo},#{item.site},#{item.itemNo},#{item.bOMItemNo},#{item.componentPartNo},#{item.qtyToIssue,jdbcType=DECIMAL},#{item.qtyToIssueOriginal,jdbcType=DECIMAL},#{item.issueType},rtrim(#{item.remark}),#{item.orderType}) </foreach> </insert>
</mapper>
|