|
|
<?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.notify.mapper.NewIssureMapper">
<insert id="saveSOIssueNotifyOrderListForExcel"> 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) values(#{notifyNo},#{site},#{itemNo},#{fgPartNo},#{soorderNo},#{issureQty,jdbcType=DECIMAL},#{outWorkOrderFlag} ,#{needDate},#{releaseNo},#{sequenceNo},#{orderType}) </insert>
<delete id="deleteSOIssueNotifyOrderMaterialListDataForExcel"> delete from SOIssueNotifyOrderMaterialList where site=#{site} and notify_no=#{notifyNo} and item_no=#{itemNo} </delete>
<insert id="batchSaveSOIssueNotifyOrderMaterialListDataForExcel"> 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,jdbcType=DECIMAL},#{item.qtyToIssueOriginal,jdbcType=DECIMAL},#{item.issueType},rtrim(#{item.remark}),#{item.orderType}) </foreach> </insert>
<select id="getSOSBOMForIssureNew" resultType="SOIssueNotifyOrderMaterialListData"> select a.notify_no,a.site,a.item_no,a.BOM_item_no as BOMItemNo,a.component_part_no as ComponentPartNo, a.qty_to_issue as QtyToIssue,a.qty_to_issue_original as QtyToIssueOriginal,a.remark from SOIssueNotifyOrderMaterialList a inner join SOIssueNotifyOrderList b on a.site=b.site and a.notify_no=b.notify_no and a.item_no=b.item_no where a.notify_no=#{notifyNo} and a.site=#{site} and b.soorder_no=#{orderNo} and b.release_no=#{releaseNo} and b.sequence_no=#{sequenceNo} </select>
<!-- AI制作 - 查询申请单主表 --> <select id="searchNotifyHeaderNew" parameterType="SOIssueNotifyHeaderData" resultType="SOIssueNotifyHeaderData"> select a.notify_no as notifyNo,a.site,a.notify_date as notifyDate,a.username,a.entered_date as enteredDate,a.receiver,a.department_id as departmentId,a.remark,a.credit_flag as creditFlag,a.issue_flag as issueFlag, a.issue_result as issueResult,a.plan_issue_date as planIssueDate,a.real_issue_date as realIssueDate,a.status,a.have_issue_record_flag as haveIssueRecordFlag,a.calc_flag as calcFlag,a.need_approve_flag as needApproveFlag,a.approved_flag as approvedFlag, a.approver,a.approve_date as approveDate,a.warehouse_id as warehouseId,a.record_version as recordVersion,a.out_work_order_flag as outWorkOrderFlag,a.project_id as projectId,a.order_type as orderType,a.auth_rule_id as authRuleId, a.confirm_status , a.confirm_user_id as confirmUserId,a.confirm_username as confirmUsername,a.confirm_user_display as confirmUserDisplay,a.confirm_date as confirmDate,a.handler_username as handlerUsername,a.handler_display as handlerDisplay,a.push_wcs_flag as pushWcsFlag from SOIssueNotifyHeader a <where> <if test="query.notifyNo != null and query.notifyNo != ''"> AND a.notify_no = #{query.notifyNo} </if> <if test="query.username != null and query.username != ''"> AND a.username LIKE '%' + #{query.username} + '%' </if> <if test="query.orderType != null and query.orderType != ''"> AND a.order_type = #{query.orderType} </if> <if test="query.status != null and query.status != ''"> AND a.status = #{query.status} </if> <if test="query.orderNo != null and query.orderNo != ''"> AND EXISTS ( SELECT 1 FROM SOIssueNotifyOrderList b WHERE b.site = a.site AND b.notify_no = a.notify_no AND b.soorder_no = #{query.orderNo} ) </if> <if test="query.startDate != null"> AND CONVERT(date, a.notify_date) >= CONVERT(date, #{query.startDate}) </if> <if test="query.endDate != null"> AND CONVERT(date, a.notify_date) < DATEADD(day, 1, CONVERT(date, #{query.endDate})) </if> <if test="query.site != null and query.site != ''"> AND a.site = #{query.site} </if> and a.status!='UNISSUE' </where> order by a.notify_no desc </select>
<!-- rqrq - 查询申请单明细,关联area表获取配送区域描述 --> <select id="searchNotifyOrderListNew" resultType="SOIssueNotifyOrderListData"> select a.notify_no as notifyNo,a.site,a.item_no as itemNo,a.fgpart_no as fgPartNo,a.soorder_no as soorderNo,a.ops_item_no as opsItemNo,a.seq_no as seqNo, a.issure_qty as issureQty,a.location_no as locationNo,a.need_date as needDate,a.out_work_order_flag as outWorkOrderFlag,a.release_no as releaseNo,a.sequence_no as sequenceNo, a.push_wms_flag as pushWmsFlag,a.transport_flag as transportFlag,a.production_area as productionArea, b.area_desc as areaDesc from SOIssueNotifyOrderList a left join area b on a.production_area = b.area_id where a.notify_no=#{notifyNo} and a.site=#{site} order by a.item_no </select>
<!-- AI制作 - 查询材料明细 --> <!-- rqrq - 关联part_attribute表查询is_in_wh字段 --> <select id="searchNotifyMaterialListNew" resultType="SOIssueNotifyOrderMaterialListData"> select a.notify_no as notifyNo,a.site,a.item_no as itemNo,a.BOM_item_no as bOMItemNo,a.component_part_no as componentPartNo,a.qty_to_issue as qtyToIssue,a.qty_to_issue_original as qtyToIssueOriginal, b.fgpart_no as fgpartNo,b.ops_item_no as opsItemNo,b.soorder_no as soorderNo,b.seq_no as seqNo, b.location_no as locationNo,a.issue_type as issueType,b.need_date as needDate,a.remark, ISNULL(pa.is_in_wh, '未维护') as isInWh from SOIssueNotifyOrderMaterialList a left join SOIssueNotifyOrderList b on a.site=b.site and a.notify_no=b.notify_no and a.item_no=b.item_no left join part_attribute pa on a.site=pa.site and a.component_part_no=pa.part_no where a.notify_no=#{notifyNo} and a.site=#{site} order by b.need_date,a.item_no </select>
<!-- AI制作 - 查询材料汇总 --> <!-- rqrq - 关联part_attribute表查询is_in_wh字段 --> <select id="searchSumNotifyMaterialListNew" resultType="SOIssueNotifyOrderMaterialListData"> select a.component_part_no as componentPartNo,sum(a.qty_to_issue) as qtyToIssue,sum(isnull(a.qty_to_issue_original,0)) as qtyToIssueOriginal, a.issue_type as issueType, ISNULL(MAX(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.notify_no=#{notifyNo} and a.site=#{site} group by a.site,a.component_part_no,a.issue_type order by a.issue_type </select>
<!-- AI制作 - 更新申请单状态为关闭 --> <update id="updateNotifyStatusNew"> update SOIssueNotifyHeader set status=#{status}, remark=#{closeRemark} where site=#{site} and notify_no=#{notifyNo} </update>
<!-- AI制作 - 查询申请单日志 --> <select id="searchNotifyLogNew" resultType="java.lang.Object"> select '暂无日志数据' as message where 1=2 </select>
<!-- AI制作 - 查询申请单关闭日志 --> <select id="searchNotifyLogCloseNew" resultType="java.lang.Object"> select '暂无关闭日志数据' as message where 1=2 </select>
<!-- AI制作 - 根据site和notify_no查询申请单明细 --> <select id="getOrderListForWcs" resultType="SOIssueNotifyOrderListData"> select a.notify_no as notifyNo,a.site,a.item_no as itemNo,a.fgpart_no as fgPartNo,a.soorder_no as soorderNo,a.ops_item_no as opsItemNo,a.seq_no as seqNo, a.issure_qty as issureQty,a.location_no as locationNo,a.need_date as needDate,a.out_work_order_flag as outWorkOrderFlag,a.release_no as releaseNo,a.sequence_no as sequenceNo from SOIssueNotifyOrderList a where a.notify_no=#{notifyNo} and a.site=#{site} order by a.item_no </select>
<!-- AI制作 - 根据site、notify_no和item_no查询材料明细 --> <select id="getMaterialListForWcs" resultType="SOIssueNotifyOrderMaterialListData"> select a.notify_no as notifyNo,a.site,a.item_no as itemNo,a.BOM_item_no as bomItemNo,a.component_part_no as componentPartNo,a.qty_to_issue as qtyToIssue,a.qty_to_issue_original as qtyToIssueOriginal, a.issue_type as issueType,a.remark from SOIssueNotifyOrderMaterialList a where a.notify_no=#{notifyNo} and a.site=#{site} and a.item_no=#{itemNo} order by a.BOM_item_no </select>
<!-- AI制作 - 根据site和part_no列表查询物料属性 --> <select id="getPartAttributeListForWcs" resultType="com.gaotao.modules.factory.entity.PartAttribute"> select site, part_no as partNo, is_in_wh as isInWh, is_robot_pick as isRobotPick, weight, length, width, height, diameter from part_attribute where site = #{site} <if test="partNos != null and partNos.size() > 0"> and part_no in <foreach collection="partNos" item="partNo" open="(" separator="," close=")"> #{partNo} </foreach> </if> </select>
<!-- AI制作 - 更新申请单推送WCS状态 --> <update id="updatePushWcsFlag"> update SOIssueNotifyHeader set push_wcs_flag='已完成' where site=#{site} and notify_no=#{notifyNo} </update>
<!-- ==================== 新增推送WCS相关SQL - rqrq ==================== --> <!-- rqrq - 根据条码列表查询handling_unit的reserve_flag --> <select id="checkReserveFlagBySerialNos" resultType="java.lang.String"> SELECT reserve_flag FROM handling_unit WHERE site = #{site} AND unit_id IN <foreach collection="serialNos" item="serialNo" open="(" separator="," close=")"> #{serialNo} </foreach> AND (reserve_flag ='Y') </select> <!-- rqrq - 根据条码列表查询所有栈板ID --> <select id="getPalletIdsBySerialNos" resultType="java.lang.String"> SELECT DISTINCT pd.pallet_id FROM pallet_detail pd WHERE pd.site = #{site} AND pd.serial_no IN <foreach collection="serialNos" item="serialNo" open="(" separator="," close=")"> #{serialNo} </foreach> </select> <!-- rqrq - 检查栈板的calling_flag --> <select id="checkCallingFlagByPalletIds" resultType="java.lang.String"> SELECT pallet_id FROM pallet WHERE site = #{site} AND pallet_id IN <foreach collection="palletIds" item="palletId" open="(" separator="," close=")"> #{palletId} </foreach> AND calling_flag ='Y' </select> <!-- rqrq - 根据notifyNo和productionOrderNo查询itemNo --> <select id="getItemNoByNotifyNoAndOrderNo" resultType="java.math.BigDecimal"> SELECT top 1 item_no FROM SOIssueNotifyOrderList <where> and site = #{site} AND notify_no = #{notifyNo} <if test="productionOrderNo != null and productionOrderNo != ''"> AND soorder_no = #{productionOrderNo} </if> </where> </select> <select id="getFgPartNoWithNotifyNo" resultType="String"> SELECT top 1 fgpart_no FROM SOIssueNotifyOrderList <where> and site = #{site} AND notify_no = #{notifyNo} <if test="productionOrderNo != null and productionOrderNo != ''"> AND soorder_no = #{productionOrderNo} </if> </where> </select>
<select id="getFgPartNoWithNotifyNoItemNo" resultType="String"> SELECT top 1 fgpart_no FROM SOIssueNotifyOrderList WHERE site = #{site} AND notify_no = #{notifyNo} AND item_no = #{itemNo,jdbcType=DECIMAL} </select>
<!-- rqrq - 根据site+notifyNo+itemNo查询生产区域 --> <select id="getProductionAreaByNotifyNoAndItemNo" resultType="String"> SELECT production_area FROM SOIssueNotifyOrderList WITH (NOLOCK) WHERE site = #{site} AND notify_no = #{notifyNo} AND item_no = #{itemNo,jdbcType=DECIMAL} </select>
<!-- rqrq - 根据site+notifyNo+itemNo查询订单类型 --> <select id="getOrderTypeByNotifyNoAndItemNo" resultType="String"> SELECT order_type FROM SOIssueNotifyOrderList WITH (NOLOCK) WHERE site = #{site} AND notify_no = #{notifyNo} AND item_no = #{itemNo,jdbcType=DECIMAL} </select>
<!-- rqrq - 根据site+notifyNo+itemNo查询订单行完整信息(一次性获取所有需要的字段)--> <select id="getOrderListByNotifyNoAndItemNo" resultType="SOIssueNotifyOrderList"> SELECT notify_no AS notifyNo, site, item_no AS itemNo, fgpart_no AS fgPartNo, soorder_no AS soorderNo, ops_item_no AS opsItemNo, seq_no AS seqNo, issure_qty AS issureQty, out_work_order_flag AS outWorkOrderFlag, need_date AS needDate, location_no AS locationNo, release_no AS releaseNo, sequence_no AS sequenceNo, push_wms_flag AS pushWmsFlag, production_area AS productionArea, transport_flag AS transportFlag, order_type AS orderType FROM SOIssueNotifyOrderList WITH (NOLOCK) WHERE site = #{site} AND notify_no = #{notifyNo} AND item_no = #{itemNo,jdbcType=DECIMAL} </select> <!-- rqrq - 更新handling_unit的reserve标志 --> <update id="updateHandlingUnitReserveFlag"> UPDATE handling_unit SET reserve_flag = 'Y', reserve_order_ref1 = #{notifyNo}, reserve_order_ref2 = CAST(#{itemNo} AS VARCHAR(50)), reserve_order_ref3 = #{productionOrderNo} WHERE site = #{site} AND unit_id IN <foreach collection="serialNos" item="serialNo" open="(" separator="," close=")"> #{serialNo} </foreach> </update> <!-- rqrq - 更新栈板的calling_flag --> <update id="updatePalletCallingFlag"> UPDATE pallet SET calling_flag = 'Y', updated_by = 'WMS_SYSTEM', updated_time = GETDATE() WHERE site = #{site} AND pallet_id IN <foreach collection="palletIds" item="palletId" open="(" separator="," close=")"> #{palletId} </foreach> </update> <!-- rqrq - 批量插入SOIssueNotifyOrderMaterialList_detail记录 --> <!-- rqrq - 批量插入SOIssueNotifyOrderMaterialList_detail,固定order_type为shoporder --> <insert id="batchInsertMaterialListDetail"> INSERT INTO SOIssueNotifyOrderMaterialList_detail (site, notify_no, item_no, BOM_item_no, serialNo, task_ref, task_item, task_seq, out_wcs_flag, issure_flag, order_type) VALUES <foreach collection="list" item="item" separator=","> (#{item.site}, #{item.notifyNo}, #{item.itemNo}, #{item.bomItemNo}, #{item.serialNo}, #{item.taskRef}, #{item.taskItem}, #{item.taskSeq}, #{item.outWcsFlag}, #{item.issureFlag}, #{item.orderType}) </foreach> </insert> <!-- rqrq - 更新SOIssueNotifyOrderList的push_wms_flag --> <update id="updateOrderListPushWmsFlag"> UPDATE SOIssueNotifyOrderList SET push_wms_flag = 'Y' WHERE site = #{site} AND notify_no = #{notifyNo} AND item_no = #{itemNo} </update> <!-- rqrq - 更新SOIssueNotifyHeader的push_wcs_flag --> <update id="updateNotifyHeaderPushWcsFlag"> UPDATE SOIssueNotifyHeader SET push_wcs_flag = #{pushWcsFlag} WHERE site = #{site} AND notify_no = #{notifyNo} </update> <!-- rqrq - 根据栈板ID和序列号列表查询栈板明细信息 --> <select id="getPalletDetailsByPalletAndSerials" resultType="com.gaotao.modules.automatedWarehouse.entity.PalletDetail"> SELECT position, layer, serial_no as serialNo FROM pallet_detail WHERE site = #{site} AND pallet_id = #{palletId} AND serial_no IN <foreach collection="serialNos" item="serialNo" open="(" separator="," close=")"> #{serialNo} </foreach> ORDER BY position, layer </select> <!-- rqrq - 查询序列号在handling_unit中的location_id(无锁查询)--> <select id="getSerialNoLocationId" resultType="java.lang.String"> SELECT location_id FROM handling_unit WITH (NOLOCK) WHERE site = #{site} AND unit_id = #{serialNo} </select> <!-- rqrq - 查询预留标签清单(适用于所有订单类型:shoporder/shipment/noorder) --> <select id="searchMaterialListDetail" resultType="com.gaotao.modules.notify.entity.SOIssueNotifyOrderMaterialListDetail"> SELECT site, notify_no AS notifyNo, item_no AS itemNo, BOM_item_no AS bomItemNo, serialNo, task_ref AS taskRef, task_item AS taskItem, task_seq AS taskSeq, out_wcs_flag AS outWcsFlag, issure_flag AS issureFlag, order_type AS orderType FROM SOIssueNotifyOrderMaterialList_detail WITH (NOLOCK) WHERE site = #{site} AND notify_no = #{notifyNo} ORDER BY item_no, BOM_item_no, task_seq </select>
</mapper>
|