|
|
<?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.autoWareHourceHaian.mapper.HaiAnNewIssureMapper">
<!-- 查询海安已保存BOM明细用于编辑回显,避免覆盖已保存申请结果 - rqrq --> <select id="haiAnGetSOSBOMForIssureNew" resultType="HaiAnSOIssueNotifyOrderMaterialListData"> SELECT a.notify_no AS notifyNo, a.site, a.sub_site AS subSite, 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.remark, a.batch_no AS batchNo FROM haian_SOIssueNotifyOrderMaterialList a WITH (NOLOCK) INNER JOIN haian_SOIssueNotifyOrderList b WITH (NOLOCK) 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 b.soorder_no = #{orderNo} AND b.release_no = #{releaseNo} AND b.sequence_no = #{sequenceNo} AND (a.site = #{site} OR a.sub_site = #{site}) </select>
<!-- 查询海安材料明细,按subsite可选过滤,保证子站点隔离 - rqrq --> <select id="haiAnSearchNotifyMaterialListNew" resultType="HaiAnSOIssueNotifyOrderMaterialListData"> SELECT a.notify_no AS notifyNo, a.site, a.sub_site AS subSite, 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, a.batch_no AS batchNo, ISNULL(pa.is_in_wh, '未维护') AS isInWh, b.push_wms_flag AS pushWmsFlag FROM haian_SOIssueNotifyOrderMaterialList a WITH (NOLOCK) LEFT JOIN haian_SOIssueNotifyOrderList b WITH (NOLOCK) ON a.site = b.site AND a.notify_no = b.notify_no AND a.item_no = b.item_no LEFT JOIN part_attribute pa WITH (NOLOCK) ON a.sub_site = pa.site AND a.component_part_no = pa.part_no WHERE a.notify_no = #{notifyNo} AND a.site = #{site} <if test="subSite != null and subSite != ''"> AND a.sub_site = #{subSite} </if> ORDER BY b.need_date, a.item_no, a.BOM_item_no </select>
<!-- 海安主单分页查询,查询维度与旧search页一致但改走haian主表 - rqrq --> <select id="haiAnSearchNotifyHeaderNew" parameterType="HaiAnSOIssueNotifyHeaderData" resultType="HaiAnSOIssueNotifyHeaderData"> 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 AS confirmStatus, 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 haian_SOIssueNotifyHeader a WITH (NOLOCK) <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 haian_SOIssueNotifyOrderList b WITH (NOLOCK) 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> <if test="query.pushWcsFlag != null and query.pushWcsFlag != ''"> AND a.push_wcs_flag = #{query.pushWcsFlag} </if> AND a.status != 'UNISSUE' </where> ORDER BY a.notify_no DESC </select>
<!-- 海安订单层明细查询,返回subsite与配送区域信息 - rqrq --> <select id="haiAnSearchNotifyOrderListNew" resultType="HaiAnSOIssueNotifyOrderListData"> SELECT a.notify_no AS notifyNo, a.site, a.sub_site AS subSite, 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, a.push_wcs_time AS pushWcsTime, b.area_desc AS areaDesc FROM haian_SOIssueNotifyOrderList a WITH (NOLOCK) <!-- 配送区域按通知单工厂及区域编码关联海安主数据;缺失时保留明细且名称为空,NOLOCK允许展示短暂脏读 - rqrq --> LEFT JOIN haian_area b WITH (NOLOCK) ON a.site = b.site AND a.production_area = b.area_id WHERE a.notify_no = #{notifyNo} AND a.site = #{site} ORDER BY a.item_no </select>
<!-- 海安材料汇总查询,按subsite与物料聚合供汇总页签使用 - rqrq --> <select id="haiAnSearchSumNotifyMaterialListNew" resultType="HaiAnSOIssueNotifyOrderMaterialListData"> SELECT a.sub_site AS subSite, 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 haian_SOIssueNotifyOrderMaterialList a WITH (NOLOCK) LEFT JOIN part_attribute pa WITH (NOLOCK) ON a.sub_site = pa.site AND a.component_part_no = pa.part_no WHERE a.notify_no = #{notifyNo} AND a.site = #{site} GROUP BY a.sub_site, a.component_part_no, a.issue_type ORDER BY a.issue_type </select>
<!-- 海安申请单状态更新,保持关闭链路与原流程一致 - rqrq --> <update id="haiAnUpdateNotifyStatusNew"> UPDATE haian_SOIssueNotifyHeader SET status = #{status}, remark = #{closeRemark} WHERE site = #{site} AND notify_no = #{notifyNo} </update>
<!-- 海安日志查询占位,先保证前端接口兼容后续再补日志表 - rqrq --> <select id="haiAnSearchNotifyLogNew" resultType="java.lang.Object"> SELECT '暂无日志数据' AS message WHERE 1 = 2 </select>
<!-- 海安关闭日志查询占位,先保证前端接口兼容后续再补日志表 - rqrq --> <select id="haiAnSearchNotifyLogCloseNew" resultType="java.lang.Object"> SELECT '暂无关闭日志数据' AS message WHERE 1 = 2 </select>
<!-- 查询海安标签明细清单,返回subsite与追踪字段用于对账 - rqrq --> <select id="haiAnSearchMaterialListDetail" resultType="HaiAnSOIssueNotifyOrderMaterialListDetailData"> SELECT d.site, d.notify_no AS notifyNo, d.item_no AS itemNo, d.BOM_item_no AS bomItemNo, d.serialNo AS serialNo, d.task_ref AS taskRef, d.task_item AS taskItem, d.task_seq AS taskSeq, d.out_wcs_flag AS outWcsFlag, d.out_wcs_time AS outWcsTime, d.issure_flag AS issureFlag, d.order_type AS orderType, d.sub_site AS subSite, d.batch_no AS batchNo, d.alloc_seq AS allocSeq, d.pallet_id AS palletId, m.component_part_no AS componentPartNo FROM haian_SOIssueNotifyOrderMaterialList_detail d <!-- 按site、单号、订单行、BOM行和子site取预定明细对应的物料编码;物料行缺失时保留标签明细。NOLOCK仅供展示,可能短暂脏读 - rqrq --> LEFT JOIN haian_SOIssueNotifyOrderMaterialList m WITH (NOLOCK) ON m.site = d.site AND m.notify_no = d.notify_no AND m.item_no = d.item_no AND m.BOM_item_no = d.BOM_item_no AND ISNULL(m.sub_site, '') = ISNULL(d.sub_site, '') WHERE d.site = #{site} AND d.notify_no = #{notifyNo} <if test="subSite != null and subSite != ''"> AND d.sub_site = #{subSite} </if> ORDER BY d.item_no, d.BOM_item_no, d.alloc_seq, d.task_seq </select>
<!-- rqrq - 海安齐套候选:从物料层关联订单层筛选transport_flag='N'。禁止NOLOCK:本查询后会回写transport_flag,脏读未提交明细会导致提前齐套 --> <select id="haiAnGetPendingTransportOrders" resultType="com.gaotao.modules.autoWareHourceHaian.entity.HaiAnSOIssueNotifyOrderListData"> SELECT DISTINCT o.site, o.notify_no AS notifyNo, o.item_no AS itemNo, o.transport_flag AS transportFlag FROM haian_SOIssueNotifyOrderMaterialList m INNER JOIN haian_SOIssueNotifyOrderList o ON m.site = o.site AND m.notify_no = o.notify_no AND m.item_no = o.item_no WHERE m.site = #{site} AND ISNULL(o.transport_flag, 'N') = 'N' ORDER BY o.notify_no, o.item_no </select>
<!-- rqrq - 统计订单行detail总数:用于齐套判断分母,0时不回写transport_flag。禁止NOLOCK:与已取出计数必须同一已提交快照 --> <select id="haiAnCountMaterialDetailTotal" resultType="java.lang.Integer"> SELECT COUNT(1) FROM haian_SOIssueNotifyOrderMaterialList_detail WHERE site = #{site} AND notify_no = #{notifyNo} AND item_no = #{itemNo} </select>
<!-- rqrq - 统计订单行detail已取出数量:仅计out_wcs_flag='Y'。禁止NOLOCK:脏读会把未提交取出当成已齐套 --> <select id="haiAnCountMaterialDetailOut" resultType="java.lang.Integer"> SELECT COUNT(1) FROM haian_SOIssueNotifyOrderMaterialList_detail WHERE site = #{site} AND notify_no = #{notifyNo} AND item_no = #{itemNo} AND out_wcs_flag = 'Y' </select>
<!-- 齐套收口:仅把transport_flag从N回写为Y,不联动其他字段,满足“只改一个标记”要求 - rqrq --> <update id="haiAnUpdateTransportFlagToY"> UPDATE haian_SOIssueNotifyOrderList SET transport_flag = 'Y' WHERE site = #{site} AND notify_no = #{notifyNo} AND item_no = #{itemNo} AND ISNULL(transport_flag, 'N') = 'N' </update>
</mapper>
|