Files
nanguangszwlback/mhd_oms/src/main/resources/mapper/executionStockInOrder/ExecutionStockInOrderMapper.xml
T
rcx b7cacaeb8d feat(oms,wms): 入库业务单反审——业务单改已驳回+已反审tab,执行单/W入库/收货/上架软删打标归档,库存还原扣减,W入库异常反审记录
【需求】已入库/已出库的单子客户通知需要回退的场景,单子回退到最原始状态。反审入口在 OMS-入库业务单页面【反審單據】按钮,一次操作全链路回退。

【反审规则】
1. 按页面状态 issueStatus 判断:进行中(1)/已审核(2)/已入库(4)/部分完成(5) 可反审;已创建(0)无需反审、已驳回(3)可直接编辑;已取消/已关闭(status 6/7)兜底拦截
2. 已推送关务/NC(pushStatus=3)直接拦截,避免关务与仓内数据不一致
3. W入库单有出库记录就不能反审:按入库单号+动作(分配库存/出库)查询库存调整记录>0 即拦截,另校验库存冻结量>0
4. WMS无该单数据时幂等成功(未下发单反审),反审失败可安全重试

【反审动作】
1. 入库业务单:状态改为已驳回(issueStatus=3,与审核不通过同语义,可编辑→重新审核→重新下发),打已反审标记落入【已反审】tab;清空入库数量/入库时间/执行单号,明细 INBOUND_ITEMS/TOTAL_NET_WEIGHT 归零
2. 入库执行单+物料明细:软删(del_flag=2)+打已反审标记,【已反审】tab 按「已软删+已反审」查询归档数据,避免归档单被误审核/下发
3. WMS侧(逐执行单Feign omsReverseInOrder):库存还原扣减(校验库存行合计=已完成上架量后整行对称扣回,GREATEST(x-n,0)兜底)→ W入库单/W收货单/W上架单及明细、收货/上架作业单/任务/质检单整链软删+打已反审标记 → 写1条入库异常【反审记录】(type=3/abnormalType=6,FSYC单号)用于记录跟踪

【接口】
- POST /reservationStockInOrderApi/reverseAudit 反审(inOrderIds + reverseAuditRemark,支持批量)
- 已反审tab:/reservationStockInOrderApi/list?reverseAuditStatus=1(执行单/W入库单/W收货单/W上架单同参数,后端固定限定 del_flag=2+标记=1 归档数据)
- 归档详情:/executionStockInOrderApi、/stockInOrderApi、/stockReceiptOrderApi、/stockShelfOrderApi 各增 getReverseAuditInfo/{id}(原 getInfo 行为不变)
- 反审记录筛选:/inOrderAbnormalApi/list?abnormalType=6

【DDL】sql/20260908_oms_inbound_reverse_audit.sql:RESERVATION_STOCK_IN_ORDER / EXECUTION_STOCK_IN_ORDER / STOCK_IN_ORDER / STOCK_RECEIPT_ORDER / STOCK_SHELF_ORDER 各新增 REVERSE_AUDIT_STATUS/REMARK/BY/BY_NAME/TIME 五列,发服务前先执行

【其他】
- 库存扣减走 batchSubtractInventoryQuantity 并显式传更新人,规避 Feign 链路无登录态时 SecurityUtils 抛异常
- omsReverseInOrder 的 Feign 方法与降级已随出库反审提交(715883f1)入库,本次不再重复提交
- 归档行只读,详情走 getReverseAuditInfo;正常数据与归档数据互不干扰
2026-09-09 15:38:21 +08:00

678 lines
35 KiB
XML

<?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.mhd.oms.domain.executionStockInOrder.repository.mapper.ExecutionStockInOrderMapper">
<resultMap type="com.mhd.oms.domain.executionStockInOrder.repository.po.ExecutionStockInOrderPO" id="StockInOrderResult">
<result property="inOrderId" column="in_order_id" />
<result property="organizationId" column="organization_id" />
<result property="organizationName" column="organization_name" />
<result property="topOrganizationId" column="top_organization_id" />
<result property="noticeNumber" column="notice_number" />
<result property="inOrderNumber" column="in_order_number" />
<result property="status" column="status" />
<result property="auditStatus" column="audit_status" />
<result property="auditRemark" column="audit_remark" />
<result property="auditBy" column="audit_by" />
<result property="auditByName" column="audit_by_name" />
<result property="auditTime" column="audit_time" />
<result property="warehouseId" column="warehouse_id" />
<result property="warehouseCode" column="warehouse_code" />
<result property="warehouseName" column="warehouse_name" />
<result property="shipperId" column="shipper_id" />
<result property="shipperName" column="shipper_name" />
<result property="orderTypeCode" column="order_type_code" />
<result property="orderTypeName" column="order_type_name" />
<result property="supplierId" column="supplier_id" />
<result property="supplierName" column="supplier_name" />
<result property="expectTime" column="expect_time" />
<result property="supplyChainNumber" column="supply_chain_number" />
<result property="priorityLevelCode" column="priority_level_code" />
<result property="priorityLevelName" column="priority_level_name" />
<result property="directWarehouse" column="direct_warehouse" />
<result property="annexUrl" column="annex_url" />
<result property="quantity" column="quantity" />
<result property="planInQuantity" column="plan_in_quantity" />
<result property="receiptQuantity" column="receipt_quantity" />
<result property="shelvesQuantity" column="shelves_quantity" />
<result property="cancelOrder" column="cancel_order" />
<result property="cancelRemark" column="cancel_remark" />
<result property="cancelBy" column="cancel_by" />
<result property="cancelByName" column="cancel_by_name" />
<result property="cancelTime" column="cancel_time" />
<result property="closeOrder" column="close_order" />
<result property="closeRemark" column="close_remark" />
<result property="closeBy" column="close_by" />
<result property="closeByName" column="close_by_name" />
<result property="closeTime" column="close_time" />
<result property="remark" column="remark" />
<result property="createTime" column="create_time" />
<result property="createBy" column="create_by" />
<result property="createByName" column="create_by_name" />
<result property="updateTime" column="update_time" />
<result property="updateBy" column="update_by" />
<result property="updateByName" column="update_by_name" />
<result property="delFlag" column="del_flag" />
<result property="overStockId" column="over_stock_id" />
<result property="overStockStatus" column="over_stock_status" />
<result property="overStockType" column="over_stock_type" />
<result property="to" column="TO" />
<result property="contactPerson" column="CONTACT_PERSON" />
<result property="vehicleInfo" column="VEHICLE_INFO" />
<result property="consignmentNo" column="CONSIGNMENT_NO" />
<result property="tel" column="TEL" />
<result property="driverSignature" column="DRIVER_SIGNATURE" />
<result property="fax" column="FAX" />
<result property="declarationArea" column="DECLARATION_AREA" />
<result property="manufacturer" column="MANUFACTURER" />
<result property="customsBrokerInfo" column="CUSTOMS_BROKER_INFO" />
<result property="deliveryAddress" column="DELIVERY_ADDRESS" />
<result property="entryExitCustoms" column="ENTRY_EXIT_CUSTOMS" />
<result property="originDestinationCountry" column="ORIGIN_DESTINATION_COUNTRY" />
<result property="carrier" column="CARRIER" />
<result property="containerNo" column="CONTAINER_NO" />
<result property="transportMethod" column="TRANSPORT_METHOD" />
<result property="supervisionMethod" column="SUPERVISION_METHOD" />
<result property="customsInspection" column="CUSTOMS_INSPECTION" />
<result property="needCustomsDeclaration" column="NEED_CUSTOMS_DECLARATION" />
<result property="needTransport" column="NEED_TRANSPORT" />
<result property="warehouseDate" column="WAREHOUSE_DATE" />
<result property="completionTime" column="COMPLETION_TIME" />
<result property="orderDate" column="ORDER_DATE" />
<result property="issueStatus" column="issue_status" />
<result property="issueTime" column="issue_time" />
<result property="issueId" column="issue_id" />
<result property="issueName" column="issue_name" />
<result property="reservationAuditId" column="reservation_audit_id" />
<result property="reservationAuditName" column="reservation_audit_name" />
<result property="reservationAuditTime" column="reservation_audit_time" />
<result property="reservationOrderSource" column="RESERVATION_ORDER_SOURCE" />
<result property="directorId" column="DIRECTOR_ID" />
<result property="directorPhone" column="DIRECTOR_PHONE" />
<result property="directorName" column="DIRECTOR_NAME" />
<result property="storageTime" column="STORAGE_TIME" />
<result property="inQuantity" column="IN_QUANTITY" />
<result property="pushTime" column="PUSH_TIME" />
<result property="pushStatus" column="PUSH_STATUS" />
<result property="pushBy" column="PUSH_BY" />
<result property="pushByName" column="PUSH_BY_NAME" />
<result property="tmsOrderNumber" column="TMS_ORDER_NUMBER" />
<result property="pictureUrl" column="PICTURE_URL" />
<result property="amount" column="AMOUNT" />
<result property="businessPriceWay" column="BUSINESS_PRICE_WAY" />
<result property="businessChargeType" column="BUSINESS_CHARGE_TYPE" />
<result property="totalWarehouseRent" column="TOTAL_WAREHOUSE_RENT" />
<result property="manpowerFee" column="MANPOWER_FEE" />
<result property="fireInsureFee" column="FIRE_INSURE_FEE" />
<result property="discount" column="DISCOUNT" />
<result property="isFreeManpowerFee" column="IS_FREE_MANPOWER_FEE" />
<result property="businessInOrderNumber" column="BUSINESS_IN_ORDER_NUMBER" />
<result property="reverseAuditStatus" column="REVERSE_AUDIT_STATUS" />
<result property="reverseAuditRemark" column="REVERSE_AUDIT_REMARK" />
<result property="reverseAuditBy" column="REVERSE_AUDIT_BY" />
<result property="reverseAuditByName" column="REVERSE_AUDIT_BY_NAME" />
<result property="reverseAuditTime" column="REVERSE_AUDIT_TIME" />
</resultMap>
<sql id="selectStockInOrderPo">
a.in_order_id, a.organization_id, a.organization_name, a.top_organization_id, a.notice_number, a.in_order_number, a.status,
a.audit_status, a.audit_remark, a.audit_by, a.audit_by_name, a.audit_time, a.warehouse_id, a.warehouse_code, a.warehouse_name, a.shipper_id, a.shipper_code,
a.shipper_name, a.order_type_code, a.order_type_name, a.supplier_id, a.supplier_code, a.supplier_name, a.expect_time, a.supply_chain_number,
a.priority_level_code, a.priority_level_name, a.direct_warehouse, a.annex_url, a.material_quantity, a.quantity,a.business_order_no,a.amount,
a.business_price_way,a.business_charge_type,a.total_warehouse_rent,a.manpower_fee,a.fire_insure_fee,a.discount,a.is_free_manpower_fee,a.business_number,
-- 计划入库数量:入库明细表 in_material_detail 的 quantity 汇总
<!-- (select ifnull(sum(imd.quantity), 0)-->
<!-- from in_material_detail imd-->
<!-- where imd.in_order_number = a.in_order_number-->
<!-- and imd.del_flag = 1-->
<!-- and (imd.level is null or imd.level = 1)-->
<!-- ) as plan_in_quantity,-->
<!-- &#45;&#45; 收货数量:收货单表 stock_receipt_order 的 receipt_quantity 汇总-->
<!-- (select ifnull(sum(sro.receipt_quantity), 0)-->
<!-- from stock_receipt_order sro-->
<!-- where sro.in_order_number = a.in_order_number-->
<!-- and sro.del_flag = 1-->
<!-- ) as receipt_quantity,-->
<!-- &#45;&#45; 上架数量:上架单表 stock_shelf_order 的 shelves_quantity 汇总-->
<!-- (select ifnull(sum(sso.shelves_quantity), 0)-->
<!-- from stock_shelf_order sso-->
<!-- where sso.in_order_number = a.in_order_number-->
<!-- and sso.del_flag = 1-->
<!-- ) as shelves_quantity,-->
a.weight_limit, a.volume_limit, a.cancel_order, a.cancel_remark, a.cancel_by,a.PICTURE_URL,a.business_in_order_number,
a.cancel_by_name, a.cancel_time, a.close_order, a.close_remark, a.close_by, a.close_by_name, a.close_time, a.remark, a.create_time, a.create_by,
a.create_by_name, a.update_time, a.update_by, a.update_by_name, a.del_flag, a.over_stock_id, a.over_stock_status, a.over_stock_type,
a."TO", a.CONTACT_PERSON, a.VEHICLE_INFO, a.CONSIGNMENT_NO, a.TEL, a.DRIVER_SIGNATURE, a.FAX, a.DECLARATION_AREA, a.MANUFACTURER,
a.CUSTOMS_BROKER_INFO, a.DELIVERY_ADDRESS, a.ENTRY_EXIT_CUSTOMS, a.ORIGIN_DESTINATION_COUNTRY, a.CARRIER, a.CONTAINER_NO,
a.TRANSPORT_METHOD, a.SUPERVISION_METHOD, a.CUSTOMS_INSPECTION, a.NEED_CUSTOMS_DECLARATION, a.NEED_TRANSPORT,
a.WAREHOUSE_DATE, a.COMPLETION_TIME, a.ORDER_DATE,a.reservation_audit_time,a.reservation_audit_name
,a.reservation_audit_id,a.issue_name,a.issue_id,a.issue_time,a.issue_status,a.RESERVATION_ORDER_SOURCE,a.tms_order_number
,a.DIRECTOR_NAME ,a.DIRECTOR_PHONE,a.DIRECTOR_ID,a.STORAGE_TIME,a.in_quantity,
a.PUSH_TIME,a.PUSH_STATUS,a.PUSH_BY,a.PUSH_BY_NAME,
a.REVERSE_AUDIT_STATUS,a.REVERSE_AUDIT_REMARK,a.REVERSE_AUDIT_BY,a.REVERSE_AUDIT_BY_NAME,a.REVERSE_AUDIT_TIME
</sql>
<sql id="joinStockInOrderPo">
,b.notice_number, b.warehouse_id, b.warehouse_code, b.warehouse_name, b.shipper_id, b.shipper_code, b.shipper_name,
b.order_type_code, b.order_type_name, b.supplier_id, b.supplier_code, b.supplier_name, b.expect_time, b.supply_chain_number, b.priority_level_code,
b.priority_level_name, b.direct_warehouse, b.annex_url, b.material_quantity as in_order_material_quantity, b.quantity as in_order_quantity
</sql>
<sql id="joinStockInOrderPoWhere">
<if test="noticeNumber != null and noticeNumber != ''">
and b.notice_number = #{noticeNumber}
</if>
<if test="inOrderNumber != null and inOrderNumber != ''">
and b.in_order_number like concat('%', #{inOrderNumber}, '%')
</if>
<if test="warehouseId != null ">
and b.warehouse_id = #{warehouseId}
</if>
<if test="warehouseCode != null and warehouseCode != ''">
and b.warehouse_code = #{warehouseCode}
</if>
<if test="warehouseName != null and warehouseName != ''">
and b.warehouse_name like concat('%', #{warehouseName}, '%')
</if>
<if test="shipperId != null ">
and b.shipper_id = #{shipperId}
</if>
<if test="shipperName != null and shipperName != ''">
and b.shipper_name like concat('%', #{shipperName}, '%')
</if>
<if test="orderTypeCode != null and orderTypeCode != ''">
and b.order_type_code = #{orderTypeCode}
</if>
<if test="orderTypeName != null and orderTypeName != ''">
and b.order_type_name like concat('%', #{orderTypeName}, '%')
</if>
<if test="supplierId != null ">
and b.supplier_id = #{supplierId}
</if>
<if test="supplierName != null and supplierName != ''">
and b.supplier_name like concat('%', #{supplierName}, '%')
</if>
<if test="expectTime != null ">
and b.expect_time = #{expectTime}
</if>
<if test="supplyChainNumber != null and supplyChainNumber != ''">
and b.supply_chain_number = #{supplyChainNumber}
</if>
<if test="priorityLevelCode != null and priorityLevelCode != ''">
and b.priority_level_code = #{priorityLevelCode}
</if>
<if test="priorityLevelName != null and priorityLevelName != ''">
and b.priority_level_name like concat('%', #{priorityLevelName}, '%')
</if>
<if test="directWarehouse != null ">
and b.direct_warehouse = #{directWarehouse}
</if>
<if test="annexUrl != null and annexUrl != ''">
and b.annex_url = #{annexUrl}
</if>
<if test="quantity != null ">
and b.quantity = #{quantity}
</if>
</sql>
<sql id="selectStockInOrderPo1">
<if test="organizationId != null ">
and a.organization_id = #{organizationId}
</if>
<if test="tmsOrderNumber != null and tmsOrderNumber != ''">
and a.tms_order_number like concat('%', #{tmsOrderNumber}, '%')
</if>
<if test="organizationName != null and organizationName != ''">
and a.organization_name like concat('%', #{organizationName}, '%')
</if>
<if test="topOrganizationId != null ">
and a.top_organization_id = #{topOrganizationId}
</if>
<if test="noticeNumber != null and noticeNumber != ''">
and a.notice_number = #{noticeNumber}
</if>
<if test="inOrderNumber != null and inOrderNumber != ''">
and a.in_order_number like concat('%', #{inOrderNumber}, '%')
</if>
<!-- 业务入库单号:同时模糊匹配业务单号/入库单号,两种单号输混也能搜到 -->
<if test="businessInOrderNumber != null and businessInOrderNumber != ''">
and (a.business_in_order_number like concat('%', #{businessInOrderNumber}, '%')
or a.in_order_number like concat('%', #{businessInOrderNumber}, '%'))
</if>
<if test="status != null ">
and a.status = #{status}
</if>
<if test="ltStatus != null ">
and a.status &lt; #{ltStatus}
</if>
<if test="gtStatus != null ">
and a.status &gt; #{gtStatus}
</if>
<if test="auditStatus != null ">
and a.audit_status = #{auditStatus}
</if>
<if test="ltAuditStatus != null ">
and a.audit_status &lt; #{ltAuditStatus}
</if>
<if test="gtAuditStatus != null ">
and a.audit_status &gt; #{gtAuditStatus}
</if>
<if test="auditRemark != null and auditRemark != ''">
and a.audit_remark = #{auditRemark}
</if>
<if test="auditBy != null ">
and a.audit_by = #{auditBy}
</if>
<if test="auditByName != null and auditByName != ''">
and a.audit_by_name like concat('%', #{auditByName}, '%')
</if>
<if test="auditTime != null ">
and a.audit_time = #{auditTime}
</if>
<if test="issueStatus != null">
and a.issue_status = #{issueStatus}
</if>
<if test="warehouseId != null ">
and a.warehouse_id = #{warehouseId}
</if>
<if test="warehouseCode != null and warehouseCode != ''">
and a.warehouse_code = #{warehouseCode}
</if>
<if test="warehouseName != null and warehouseName != ''">
and a.warehouse_name like concat('%', #{warehouseName}, '%')
</if>
<if test="shipperId != null ">
and a.shipper_id = #{shipperId}
</if>
<if test="shipperName != null and shipperName != ''">
and a.shipper_name like concat('%', #{shipperName}, '%')
</if>
<if test="orderTypeCode != null and orderTypeCode != ''">
and a.order_type_code = #{orderTypeCode}
</if>
<if test="orderTypeName != null and orderTypeName != ''">
and (a.ORDER_TYPE_NAME like concat('%', #{orderTypeName}, '%') or a.BUSINESS_TYPE like concat('%', #{orderTypeName}, '%') or a.ORDER_TYPE_CODE like concat('%', #{orderTypeName}, '%'))
</if>
<if test="supplierId != null ">
and a.supplier_id = #{supplierId}
</if>
<if test="supplierName != null and supplierName != ''">
and a.supplier_name like concat('%', #{supplierName}, '%')
</if>
<if test="expectTime != null ">
and a.expect_time = #{expectTime}
</if>
<if test="supplyChainNumber != null and supplyChainNumber != ''">
and a.supply_chain_number = #{supplyChainNumber}
</if>
<if test="priorityLevelCode != null and priorityLevelCode != ''">
and a.priority_level_code = #{priorityLevelCode}
</if>
<if test="priorityLevelName != null and priorityLevelName != ''">
and a.priority_level_name like concat('%', #{priorityLevelName}, '%')
</if>
<if test="directWarehouse != null ">
and a.direct_warehouse = #{directWarehouse}
</if>
<if test="annexUrl != null and annexUrl != ''">
and a.annex_url = #{annexUrl}
</if>
<if test="quantity != null ">
and a.quantity = #{quantity}
</if>
<if test="cancelOrder != null ">
and a.cancel_order = #{cancelOrder}
</if>
<if test="cancelRemark != null and cancelRemark != ''">
and a.cancel_remark = #{cancelRemark}
</if>
<if test="cancelBy != null ">
and a.cancel_by = #{cancelBy}
</if>
<if test="cancelByName != null and cancelByName != ''">
and a.cancel_by_name like concat('%', #{cancelByName}, '%')
</if>
<if test="cancelTime != null ">
and a.cancel_time = #{cancelTime}
</if>
<if test="closeOrder != null ">
and a.close_order = #{closeOrder}
</if>
<if test="closeRemark != null and closeRemark != ''">
and a.close_remark = #{closeRemark}
</if>
<if test="closeBy != null ">
and a.close_by = #{closeBy}
</if>
<if test="closeByName != null and closeByName != ''">
and a.close_by_name like concat('%', #{closeByName}, '%')
</if>
<if test="closeTime != null ">
and a.close_time = #{closeTime}
</if>
<if test="createByName != null and createByName != ''">
and a.create_by_name like concat('%', #{createByName}, '%')
</if>
<if test="updateByName != null and updateByName != ''">
and a.update_by_name like concat('%', #{updateByName}, '%')
</if>
<if test="inOrderIds != null and inOrderIds.size > 0 ">
and a.in_order_id in
<foreach collection="inOrderIds" item="item" index="index" open="(" close=")" separator=",">
#{item}
</foreach>
</if>
<!-- 报关相关字段查询条件 -->
<if test="to != null and to != ''">
and a."TO" like concat('%', #{to}, '%')
</if>
<if test="contactPerson != null and contactPerson != ''">
and a.CONTACT_PERSON like concat('%', #{contactPerson}, '%')
</if>
<if test="vehicleInfo != null and vehicleInfo != ''">
and a.VEHICLE_INFO like concat('%', #{vehicleInfo}, '%')
</if>
<if test="consignmentNo != null and consignmentNo != ''">
and a.CONSIGNMENT_NO like concat('%', #{consignmentNo}, '%')
</if>
<if test="tel != null and tel != ''">
and a.TEL like concat('%', #{tel}, '%')
</if>
<if test="driverSignature != null and driverSignature != ''">
and a.DRIVER_SIGNATURE like concat('%', #{driverSignature}, '%')
</if>
<if test="fax != null and fax != ''">
and a.FAX like concat('%', #{fax}, '%')
</if>
<if test="declarationArea != null and declarationArea != ''">
and a.DECLARATION_AREA like concat('%', #{declarationArea}, '%')
</if>
<if test="manufacturer != null and manufacturer != ''">
and a.MANUFACTURER like concat('%', #{manufacturer}, '%')
</if>
<if test="customsBrokerInfo != null and customsBrokerInfo != ''">
and a.CUSTOMS_BROKER_INFO like concat('%', #{customsBrokerInfo}, '%')
</if>
<if test="deliveryAddress != null and deliveryAddress != ''">
and a.DELIVERY_ADDRESS like concat('%', #{deliveryAddress}, '%')
</if>
<if test="entryExitCustoms != null and entryExitCustoms != ''">
and a.ENTRY_EXIT_CUSTOMS like concat('%', #{entryExitCustoms}, '%')
</if>
<if test="originDestinationCountry != null and originDestinationCountry != ''">
and a.ORIGIN_DESTINATION_COUNTRY like concat('%', #{originDestinationCountry}, '%')
</if>
<if test="carrier != null and carrier != ''">
and a.CARRIER like concat('%', #{carrier}, '%')
</if>
<if test="containerNo != null and containerNo != ''">
and a.CONTAINER_NO = #{containerNo}
</if>
<if test="transportMethod != null and transportMethod != ''">
and a.TRANSPORT_METHOD = #{transportMethod}
</if>
<if test="supervisionMethod != null and supervisionMethod != ''">
and a.SUPERVISION_METHOD = #{supervisionMethod}
</if>
<if test="customsInspection != null">
and a.CUSTOMS_INSPECTION = #{customsInspection}
</if>
<if test="needCustomsDeclaration != null">
and a.NEED_CUSTOMS_DECLARATION = #{needCustomsDeclaration}
</if>
<if test="needTransport != null">
and a.NEED_TRANSPORT = #{needTransport}
</if>
<if test="warehouseDate != null">
and a.WAREHOUSE_DATE = #{warehouseDate}
</if>
<if test="completionTime != null">
and a.COMPLETION_TIME = #{completionTime}
</if>
<if test="orderDate != null">
and a.ORDER_DATE = #{orderDate}
</if>
<if test="createTimeStart != null and createTimeStart != ''">
and a.create_time >= #{createTimeStart}
</if>
<if test="createTimeEnd != null and createTimeEnd != ''">
and a.create_time <![CDATA[ < ]]> DATEADD(DAY, 1, #{createTimeEnd})
</if>
<if test="pushTimeFrom != null">
and a.PUSH_TIME <![CDATA[>=]]> #{pushTimeFrom}
</if>
<if test="pushTimeTo != null">
and a.PUSH_TIME <![CDATA[<=]]> #{pushTimeTo}
</if>
<if test="createTimeFrom != null">
and a.create_time <![CDATA[>=]]> #{createTimeFrom}
</if>
<if test="createTimeTo != null">
and a.create_time <![CDATA[<=]]> #{createTimeTo}
</if>
<if test="pushStatus != null">
and a.PUSH_STATUS = #{pushStatus}
</if>
<if test="businessType != null and businessType != ''">
and a.BUSINESS_TYPE = #{businessType}
</if>
<if test="reservationOrderSource != null and reservationOrderSource != ''">
and a.RESERVATION_ORDER_SOURCE = #{reservationOrderSource}
</if>
<!-- businessNumber:该列无写入链路(历史数据恒空),原精确等值必查空;改为按业务单号/入库单号模糊互查兜底 -->
<if test="businessNumber != null and businessNumber != ''">
and (a.business_in_order_number like concat('%', #{businessNumber}, '%')
or a.in_order_number like concat('%', #{businessNumber}, '%'))
</if>
<if test="storageTimeStart != null and storageTimeStart != ''">
and a.storage_time >= #{storageTimeStart}
</if>
<if test="storageTimeEnd != null and storageTimeEnd != ''">
and a.storage_time <![CDATA[ < ]]> DATEADD(DAY, 1, #{storageTimeEnd})
</if>
<if test="expectTimeStart != null and expectTimeStart != ''">
and a.expect_time >= #{expectTimeStart}
</if>
<if test="expectTimeEnd != null and expectTimeEnd != ''">
and a.expect_time <![CDATA[ < ]]> DATEADD(DAY, 1, #{expectTimeEnd})
</if>
<if test="xfStatus != null and xfStatus != '' and xfStatus == '已下发'">
and a.issue_time is not null
</if>
<if test="xfStatus != null and xfStatus != '' and xfStatus == '未下发'">
and a.issue_time is null
</if>
<!-- 入库明细:物料名称、物料编码(同一明细行同时满足;与计划数量汇总口径一致)。关联 material_base_info 避免明细冗余名称与主档不一致时筛不到 -->
<if test="(materialName != null and materialName != '') or (materialCode != null and materialCode != '')">
and exists (
select 1 from in_material_detail imd
left join material_base_info mb on imd.material_base_info_id = mb.material_base_info_id and mb.del_flag = 1
where imd.in_order_number = a.in_order_number
and imd.del_flag = 1
and (imd.level is null or imd.level = 1)
<if test="materialName != null and materialName != ''">
and (
imd.material_name like concat('%', #{materialName}, '%')
or mb.material_name like concat('%', #{materialName}, '%')
)
</if>
<if test="materialCode != null and materialCode != ''">
and (
imd.material_code like concat('%', #{materialCode}, '%')
or mb.material_code like concat('%', #{materialCode}, '%')
)
</if>
)
</if>
<!-- 反审状态过滤:入库执行单【已反审】tab 传 reverseAuditStatus=1,查询已软删且打反审标记的归档数据 -->
<choose>
<when test="reverseAuditStatus != null">
and a.REVERSE_AUDIT_STATUS = #{reverseAuditStatus}
and a.del_flag = 2
</when>
<otherwise>
<choose>
<when test="delFlag != null"> and a.del_flag = #{delFlag} </when>
<otherwise> and a.del_flag = 1 </otherwise>
</choose>
</otherwise>
</choose>
</sql>
<select id="queryList" parameterType="com.mhd.oms.domain.executionStockInOrder.repository.todo.ExecutionStockInOrderDO" resultMap="StockInOrderResult">
select
<include refid="selectStockInOrderPo"/>
from execution_stock_in_order a
<where>
<include refid="selectStockInOrderPo1"/>
</where>
ORDER BY a.create_time IS NULL, a.create_time DESC
</select>
<select id="getinfo" parameterType="java.lang.Long" resultType="com.mhd.oms.domain.executionStockInOrder.repository.po.MaterialBaseInfoPO">
select * from "NGWL_TEST_WMS".MATERIAL_BASE_INFO where 1 = 1 and DEL_FLAG = 1 and MATERIAL_BASE_INFO_ID = #{id}
</select>
<select id="getByName" parameterType="java.lang.String" resultType="com.mhd.oms.domain.executionStockInOrder.repository.po.MaterialBaseInfoPO">
select * from "NGWL_TEST_WMS".MATERIAL_BASE_INFO where 1 = 1 and DEL_FLAG = 1 and MATERIAL_NAME = #{name}
</select>
<select id="getByCode" parameterType="java.lang.String" resultType="com.mhd.oms.domain.executionStockInOrder.repository.po.MaterialBaseInfoPO">
select * from "NGWL_TEST_WMS".MATERIAL_BASE_INFO where 1 = 1 and DEL_FLAG = 1 and MATERIAL_CODE = #{code}
</select>
<select id="getMaterialBaseInfoList" parameterType="java.lang.String" resultType="com.mhd.oms.domain.executionStockInOrder.repository.po.MaterialBaseInfoPO">
select * from "NGWL_TEST_WMS".MATERIAL_BASE_INFO where 1 = 1 and DEL_FLAG = 1 and material_code = #{id}
</select>
<select id="getInfoByMaterialBaseInfoIds" parameterType="java.lang.Long" resultType="com.mhd.oms.domain.executionStockInOrder.repository.po.MaterialWarehouseControlPO">
select * from "NGWL_TEST_WMS".MATERIAL_WAREHOUSE_CONTROL where 1 = 1 and DEL_FLAG = 1 and MATERIAL_BASE_INFO_ID = #{id}
</select>
<select id="getGoodsInfoByMaterialBaseInfoIds" parameterType="java.lang.Long" resultType="com.mhd.oms.domain.executionStockInOrder.repository.po.MaterialGoodsRulePO">
select * from "NGWL_TEST_WMS".MATERIAL_GOODS_RULE where 1 = 1 and DEL_FLAG = 1 and MATERIAL_BASE_INFO_ID = #{id}
</select>
<select id="getUserNcCode" parameterType="java.lang.Long" resultType="java.lang.String">
select CUSTOMER_NC_CODE from "NGWL_TEST_USER".USER_SHIPPER where 1 = 1 and DEL_FLAG = 1 and USER_ID = #{id} limit 1
</select>
<!-- 入仓通知单打印-表头查询 -->
<select id="queryNoticePrint" resultMap="StockInOrderResult">
SELECT
a.notice_number,
a.in_order_number,
a.status,
a.warehouse_name,
a.supplier_name,
a.shipper_name,
a.order_type_name,
a.expect_time,
a.material_quantity,
a.manufacturer,
a.contact_person,
a.tel,
a.vehicle_info,
a.delivery_address,
a.warehouse_date,
a.remark,
a.create_time
FROM execution_stock_in_order a
WHERE a.del_flag = 1
AND a.in_order_id = #{inOrderId}
</select>
<!-- 入仓通知单打印-明细查询 -->
<select id="queryNoticePrintDetail" resultMap="ExecutionInMaterialDetailResult">
SELECT
b.material_code,
b.material_name,
b.piece_count,
b.total_net_weight,
b.total_gross_weight,
b.unit_code,
b.pack_name,
b.batch_number,
b.storage_location_name,
b.quantity,
b.inbound_quantity
FROM execution_in_material_detail b
WHERE b.del_flag = 1
AND b.in_order_number = #{inOrderNumber}
ORDER BY b.material_code
</select>
<!-- 明细结果映射 -->
<resultMap type="com.mhd.oms.domain.executionInMaterialDetail.repository.po.ExecutionInMaterialDetailPO" id="ExecutionInMaterialDetailResult">
<result property="materialCode" column="material_code"/>
<result property="materialName" column="material_name"/>
<result property="pieceCount" column="piece_count"/>
<result property="totalNetWeight" column="total_net_weight"/>
<result property="totalGrossWeight" column="total_gross_weight"/>
<result property="unitCode" column="unit_code"/>
<result property="packName" column="pack_name"/>
<result property="batchNumber" column="batch_number"/>
<result property="storageLocationName" column="storage_location_name"/>
<result property="quantity" column="quantity"/>
<result property="inboundQuantity" column="inbound_quantity"/>
</resultMap>
<update id="updateByOrderId" parameterType="java.lang.String">
update "NGWL_TEST_WLHY".tms_order set ORDER_STATUS = 9 where ID = #{orderId}
</update>
<update id="updateByTransportationNumber" parameterType="java.lang.String">
update "NGWL_TEST_WLHY".TMS_TRANSPORT_NOTE set WAYBILL_STATUS =12 where TRANSPORTATION_NUMBER = #{transportationNumber}
</update>
<update id="updateWmsOut">
update "NGWL_TEST_WMS".stock_out_order set return_quantity = #{quantity} where out_order_number = #{orderNumber}
</update>
<select id="getIsCheckCredit" parameterType="java.lang.Long" resultType="java.lang.String">
select IS_CHECK_CREDIT from "NGWL_TEST_USER".USER_SHIPPER where 1 = 1 and DEL_FLAG = 1 and USER_ID = #{id}
</select>
<select id="getCreditAmount" parameterType="java.lang.Long" resultType="java.math.BigDecimal">
select CREDIT_AMOUNT from "NGWL_TEST_USER".USER_SHIPPER where 1 = 1 and DEL_FLAG = 1 and USER_ID = #{id}
</select>
<select id="getCustomerNcCode" parameterType="java.lang.Long" resultType="java.lang.String">
select CUSTOMER_NC_CODE from "NGWL_TEST_USER".USER_SHIPPER where 1 = 1 and DEL_FLAG = 1 and USER_ID = #{id}
</select>
<select id="getNcUrl" resultType="java.lang.String">
SELECT INTERFACE_TYPE_VALUE FROM NGWL_TEST_THIRDPARTY."SYS_DEPART_INTERFACE_INFO"
where DEL_FLAG = '1'
and organization_id = #{organizationId}
and organization_name = #{organizationName}
and interface_type = #{interfaceType} limit 1
</select>
<update id="delWOrder">
update "NGWL_TEST_WMS".stock_in_order set DEL_FLAG = 2 where DEL_FLAG = 1 and in_order_number = #{inOrderNumber}
</update>
<update id="delWOrderDetail">
update "NGWL_TEST_WMS".IN_MATERIAL_DETAIL set DEL_FLAG = 2 where DEL_FLAG = 1 and in_order_number = #{inOrderNumber}
</update>
<update id="delWShOrder">
update "NGWL_TEST_WMS".STOCK_RECEIPT_ORDER set DEL_FLAG = 2 where DEL_FLAG = 1 and in_order_number = #{inOrderNumber}
</update>
<select id="getWShOrder" parameterType="java.lang.String" resultType="java.lang.String">
select RECEIPT_ORDER_NUMBER from "NGWL_TEST_WMS".STOCK_RECEIPT_ORDER where 1 = 1 and DEL_FLAG = 1 and IN_ORDER_NUMBER = #{inOrderNumber}
</select>
<update id="delWShOrderDetail">
update "NGWL_TEST_WMS".RECEIPT_MATERIAL_DETAIL set DEL_FLAG = 2 where DEL_FLAG = 1 and RECEIPT_ORDER_NUMBER = #{receiptOrderNumber}
</update>
<select id="countByOrderNumberPrefix" resultType="java.lang.Integer" parameterType="java.lang.String">
SELECT COUNT(1)
FROM execution_stock_in_order
WHERE in_order_number LIKE concat(#{prefix}, '%')
</select>
</mapper>