Files
nanguangszwlback/mhd_wms/src/main/resources/mapper/stockShelfOrder/StockShelfOrderMapper.xml
T
rcx cae62e83a5 fix(oms,wms): 入库反审修复:已反审tab列表查不到数据、未下发单反审补写反审记录
1. W收货单/W上架单【已反审】tab查不到数据:queryList 的 LEFT JOIN stock_in_order 固定带 a/b.DEL_FLAG=1,归档数据(反审后双方均已软删del_flag=2)关联不上b表,仓库/货主等基于b表的过滤条件把行全部过滤掉;改为按是否查反审归档动态切换关联条件(归档按del_flag=2关联,正常列表行为不变)

2. 未下发WMS的执行单反审不产生反审记录:reverseExecutionOrder 幂等跳过分支直接return导致入库异常无留痕;现补写1条反审记录(abnormalType=6,回退库存0,备注未下发WMS),同单号已有有效记录时防重,重试/重复反审幂等

3. OMS反审Feign参数透传组织三字段(organizationId/organizationName/topOrganizationId),供WMS跳过分支写反审记录使用(该场景无W入库单可取组织信息)
2026-09-10 17:25:07 +08:00

221 lines
12 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.wms.domain.stockShelfOrder.repository.mapper.StockShelfOrderMapper">
<resultMap type="com.mhd.wms.domain.stockShelfOrder.repository.po.StockShelfOrderPO" id="StockShelfOrderResult">
<result property="shelfOrderId" column="shelf_order_id" />
<result property="organizationId" column="organization_id" />
<result property="organizationName" column="organization_name" />
<result property="topOrganizationId" column="top_organization_id" />
<result property="inOrderNumber" column="in_order_number" />
<result property="receiptOrderNumber" column="receipt_order_number" />
<result property="receiptTaskNumber" column="receipt_task_number" />
<result property="shelfOrderNumber" column="shelf_order_number" />
<result property="status" column="status" />
<result property="receiptQuantity" column="receipt_quantity" />
<result property="shelvesQuantity" column="shelves_quantity" />
<result property="abnormal" column="abnormal" />
<result property="taskDistribution" column="task_distribution" />
<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="pushStatus" column="push_status" />
<result property="pushTime" column="push_time" />
<result property="pushBy" column="push_by" />
<result property="pushByName" column="push_by_name" />
<result property="goodsType" column="goods_type" />
<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="selectStockShelfOrderPo">
a.shelf_order_id, a.organization_id, a.organization_name, a.top_organization_id,
a.in_order_number, a.receipt_order_number,a.receipt_task_number, a.shelf_order_number,a.status, a.receipt_quantity, a.shelves_quantity, a.material_quantity,
a.shelves_material_quantity, a.abnormal,a.task_distribution, a.task_distribution_time, a.operators_by, 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.push_status,a.push_time,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,
(SELECT m.goods_type FROM shelf_material_detail d
JOIN material_base_info m ON d.material_base_info_id = m.material_base_info_id
WHERE d.shelf_order_number = a.shelf_order_number AND d.level = 1
LIMIT 1) AS goods_type
</sql>
<sql id="selectStockShelfOrderPo1">
<if test="shelfOrderId != null ">
and a.shelf_order_id = #{shelfOrderId}
</if>
<if test="organizationId != null ">
and a.organization_id = #{organizationId}
</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="inOrderNumber != null ">
and a.in_order_number = #{inOrderNumber}
</if>
<if test="receiptOrderNumber != null and receiptOrderNumber != ''">
and a.receipt_order_number like concat('%', #{receiptOrderNumber}, '%')
</if>
<if test="receiptTaskNumber != null and receiptTaskNumber != ''">
and a.receipt_task_number = #{receiptTaskNumber}
</if>
<if test="shelfOrderNumber != null and shelfOrderNumber != ''">
and a.shelf_order_number like concat('%', #{shelfOrderNumber}, '%')
</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="shelvesQuantity != null ">
and a.shelves_quantity = #{shelvesQuantity}
</if>
<if test="abnormal != null ">
and a.abnormal = #{abnormal}
</if>
<if test="taskDistribution != null ">
and a.task_distribution = #{taskDistribution}
</if>
<if test="operatorsBy != null and operatorsBy != ''">
and a.operators_by = #{operatorsBy}
</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="shelfOrderIds != null and shelfOrderIds.size > 0 ">
and a.shelf_order_id in
<foreach collection="shelfOrderIds" item="item" index="index" open="(" close=")" separator=",">
#{item}
</foreach>
</if>
<if test="createTimeStart != null and createTimeStart != ''">
and date_format(a.create_time,'%Y-%m-%d') &gt;= #{createTimeStart}
</if>
<if test="createTimeEnd != null and createTimeEnd != ''">
and date_format(a.create_time,'%Y-%m-%d') &lt;= #{createTimeEnd}
</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="pushTimeFrom != null">
and a.PUSH_TIME <![CDATA[>=]]> #{pushTimeFrom}
</if>
<if test="pushTimeTo != null">
and a.PUSH_TIME <![CDATA[<=]]> #{pushTimeTo}
</if>
<if test="pushStatus != null">
and a.PUSH_STATUS = #{pushStatus}
</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>
<sql id="joinStockReceiptOrderWhere">
<if test="receiptOrderNumber != null and receiptOrderNumber != ''">
and c.receipt_order_number like concat('%', #{receiptOrderNumber}, '%')
</if>
</sql>
<select id="queryList" parameterType="com.mhd.wms.domain.stockShelfOrder.repository.todo.StockShelfOrderDO" resultMap="StockShelfOrderResult">
select
<include refid="selectStockShelfOrderPo"/>
<include refid="com.mhd.wms.domain.stockInOrder.repository.mapper.StockInOrderMapper.joinStockInOrderPo"/>
from stock_shelf_order a
<!-- 已反审tab查归档数据: a/b 均已软删(del_flag=2), 仍按 del_flag=1 关联会导致 b 全为 NULL,
基于 b 的过滤条件(仓库/货主等)随之失效为 false, 列表恒为空; 故按是否查反审归档切换关联条件 -->
LEFT JOIN stock_in_order b ON a.in_order_number = b.in_order_number
<choose>
<when test="reverseAuditStatus != null">
and a.DEL_FLAG = 2 and b.DEL_FLAG = 2
</when>
<otherwise>
and a.DEL_FLAG = 1 and b.DEL_FLAG = 1
</otherwise>
</choose>
<where>
<include refid="selectStockShelfOrderPo1"/>
<include refid="com.mhd.wms.domain.stockInOrder.repository.mapper.StockInOrderMapper.joinStockInOrderPoWhere"/>
</where>
ORDER BY a.create_time DESC
</select>
<select id="getExecutionCount" resultType="java.lang.Integer" parameterType="java.lang.String">
select count(0) from "NGWL_TEST_OMS".EXECUTION_STOCK_IN_ORDER where BUSINESS_IN_ORDER_NUMBER = #{orderNumber} and ISSUE_STATUS != 4 and DEL_FLAG = 1
</select>
<select id="getBusinessOrderNumber" resultType="java.lang.String" parameterType="java.lang.String">
select BUSINESS_IN_ORDER_NUMBER from "NGWL_TEST_OMS".EXECUTION_STOCK_IN_ORDER where IN_ORDER_NUMBER = #{orderNumber} and ISSUE_STATUS != 4 and DEL_FLAG = 1
</select>
<update id="updateOmsOrder">
update "NGWL_TEST_OMS".RESERVATION_STOCK_IN_ORDER set ISSUE_STATUS = #{status},in_quantity = #{shelvesQuantity},STORAGE_TIME = CURRENT_TIMESTAMP where IN_ORDER_NUMBER = #{orderNumber} and DEL_FLAG = 1
</update>
<update id="updateOmsExecutionOrder">
update "NGWL_TEST_OMS".EXECUTION_STOCK_IN_ORDER set ISSUE_STATUS = #{status},in_quantity = #{shelvesQuantity},STORAGE_TIME = CURRENT_TIMESTAMP where IN_ORDER_NUMBER = #{orderNumber} and DEL_FLAG = 1
</update>
<update id="updateOmsReserveOrder">
update "NGWL_TEST_OMS".RESERVE_STOCK_IN_ORDER set in_quantity = #{shelvesQuantity},STORAGE_TIME = CURRENT_TIMESTAMP where IN_ORDER_NUMBER = #{orderNumber} and DEL_FLAG = 1
</update>
<update id="updateOmsDocument">
update "NGWL_TEST_OMS".RESERVATION_IN_MATERIAL_DETAIL set INBOUND_ITEMS = #{shelvesQuantity}, TOTAL_NET_WEIGHT= #{totalNetWeight},STORAGE_TIME = CURRENT_TIMESTAMP where MATERIAL_DETAIL_ID = #{omsInMaterialDetail} and DEL_FLAG = 1
</update>
<update id="updateOmsHandover">
update "NGWL_TEST_OMS".RESERVATION_OUT_MATERIAL_DETAIL set INBOUND_ITEMS = #{checkQuantity},
TOTAL_NET_WEIGHT= #{totalNetWeight}
,STORAGE_TIME = CURRENT_TIMESTAMP
where OUT_ORDER_NUMBER = #{outOrderNumber} and UNIQUE_ID = #{uniqueId} and DEL_FLAG = 1
</update>
<update id="updateOmsDocumentLot">
update "NGWL_TEST_OMS".RESERVATION_IN_MATERIAL_DETAIL set INBOUND_ITEMS = #{shelvesQuantity}, TOTAL_NET_WEIGHT= #{totalNetWeight},STORAGE_TIME = CURRENT_TIMESTAMP
where LOT_NO = #{lotNumber} and DEL_FLAG = 1
</update>
<update id="updateOmsInventoryQuantity">
update "NGWL_TEST_OMS".RESERVATION_MATERIAL_INVENTORY set INVENTORY_QUANTITY = #{quantity},
ALLOCATION_QUANTITY= #{quantity}
where IN_ORDER_NUMBER = #{inOrderNumber} and LOT_NUMBER = #{lotNumber} and DEL_FLAG = 1
</update>
<update id="updateOmsInventorySynchronization">
update "NGWL_TEST_OMS".RESERVATION_MATERIAL_INVENTORY set INVENTORY_QUANTITY = INVENTORY_QUANTITY - #{checkQuantity},
ALLOCATION_QUANTITY= ALLOCATION_QUANTITY - #{checkQuantity}
where IN_ORDER_NUMBER = #{inOrderNumber} and LOT_NUMBER = #{lotNo} and DEL_FLAG = 1
</update>
<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>
</mapper>