Files
nanguangszwlback/mhd_wms/src/main/resources/mapper/pickingOrder/PickingOrderMapper.xml
T
rcx 715883f1d4 feat(oms,wms): 出库业务单反审——已出库/已审核单据回退已创建
- 新增 POST /reservationStockOutOrderApi/reverseAudit,按issueStatus(2-已审核/4-已出库)判断可反审
- 主单回退已创建并打reverseStatus标记,进【已反审】tab(list status=-2),重新审核通过自动复位
- 执行单/明细软删+reverseFlag=1,预约库存调整记录软删
- WMS新增/stockOutOrderApi/omsReverseExecutionOrder:已出库还原实物库存+推OMS,未出库仅还原分配占用,WMS无数据幂等成功
- W出库/拣货/复核/交接单软删+reverseFlag=1,列表支持delFlag=2&reverseFlag=1【已反审】tab
- 四页面新增归档详情接口getReverseInfo*
- 生成出库异常记录【反审记录】(abnormalType=3,前缀FSYC)
- 需先执行SQL: 20260908两个反审脚本(OMS库+WMS库)
2026-09-09 15:20:13 +08:00

227 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.pickingOrder.repository.mapper.PickingOrderMapper">
<resultMap type="com.mhd.wms.domain.pickingOrder.repository.po.PickingOrderPO" id="PickingOrderResult">
<result property="pickingOrderId" column="picking_order_id" />
<result property="organizationId" column="organization_id" />
<result property="organizationName" column="organization_name" />
<result property="topOrganizationId" column="top_organization_id" />
<result property="orderNumber" column="order_number" />
<result property="pickingOrderNumber" column="picking_order_number" />
<result property="status" column="status" />
<result property="type" column="type" />
<result property="quantity" column="quantity" />
<result property="materialQuantity" column="material_quantity" />
<result property="pickingQuantity" column="picking_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="reverseFlag" column="reverse_flag" />
<result property="outOrderNumber" column="out_order_number" />
<result property="businessOrderNo" column="business_order_no" />
<result property="orderTypeCode" column="order_type_code" />
<result property="orderTypeName" column="order_type_name" />
<result property="priorityLevelCode" column="priority_level_code" />
<result property="priorityLevelName" column="priority_level_name" />
<result property="needDeclareFlag" column="need_declare_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="outOrderId" column="out_order_id" />
</resultMap>
<sql id="selectPickingOrderPo">
a.picking_order_id, a.organization_id, a.organization_name, a.top_organization_id, a.order_number, a.picking_order_number,
a.status, a.type, a.warehouse_id, a.warehouse_code, a.warehouse_name, a.shipper_id, a.shipper_name, a.quantity, a.weight_limit, a.volume_limit, a.material_quantity,
IFNULL((SELECT SUM(b.picking_quantity) FROM picking_material_detail b WHERE b.picking_order_number = a.picking_order_number AND b.del_flag = 1), 0) AS picking_quantity,
a.picking_material_quantity, a.abnormal, a.task_distribution, a.remark, a.create_time, a.create_by, a.create_by_name, a.update_time,b.out_order_id,
a.update_by, a.update_by_name, a.del_flag, a.reverse_flag, a.out_order_number, a.business_order_no, a.order_type_code, a.order_type_name, a.priority_level_code, a.priority_level_name
,a.push_status,a.push_time,a.push_by,a.push_by_name,
(SELECT m.goods_type FROM PICKING_MATERIAL_DETAIL d
JOIN material_base_info m ON d.material_base_info_id = m.material_base_info_id
WHERE d.PICKING_ORDER_NUMBER = a.PICKING_ORDER_NUMBER and d.del_flag = 1
LIMIT 1) AS goods_type
</sql>
<sql id="selectPickingOrderPo1">
<if test="pickingOrderId != null ">
and a.picking_order_id = #{pickingOrderId}
</if>
<if test="shipperId != null ">
and a.shipper_id = #{shipperId}
</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="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="orderNumber != null and orderNumber != '' ">
and a.order_number like concat('%', #{orderNumber}, '%')
</if>
<if test="pickingOrderNumber != null and pickingOrderNumber != ''">
and a.picking_order_number like concat('%', #{pickingOrderNumber}, '%')
</if>
<if test="status != null ">
and a.status = #{status}
</if>
<if test="type != null ">
and a.type = #{type}
</if>
<if test="quantity != null ">
and a.quantity = #{quantity}
</if>
<if test="pickingQuantity != null ">
and a.picking_quantity = #{pickingQuantity}
</if>
<if test="abnormal != null ">
and a.abnormal = #{abnormal}
</if>
<if test="taskDistribution != null ">
and a.task_distribution = #{taskDistribution}
</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="pickingOrderIdList != null and pickingOrderIdList.size > 0 ">
and a.picking_order_id in
<foreach collection="pickingOrderIdList" item="item" index="index" open="(" close=")" separator=",">
#{item}
</foreach>
</if>
<choose>
<when test="delFlag != null"> and a.del_flag = #{delFlag} </when>
<otherwise> and a.del_flag = 1 </otherwise>
</choose>
<!-- 反审标记查询: 【已反审】tab 前端传 delFlag=2 + reverseFlag=1 -->
<if test="reverseFlag != null"> and a.reverse_flag = #{reverseFlag} </if>
<if test="needDeclareFlag != null and needDeclareFlag != ''">
and b.need_declare_flag = #{needDeclareFlag}
</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>
</sql>
<select id="queryList" parameterType="com.mhd.wms.domain.pickingOrder.repository.todo.PickingOrderDO" resultMap="PickingOrderResult">
select
<include refid="selectPickingOrderPo"/>
,b.need_Declare_Flag
from picking_order a
left join STOCK_OUT_ORDER b ON a.order_number = b.out_order_number and b.del_flag = 1 and a.del_flag = 1
<where>
<include refid="selectPickingOrderPo1"/>
</where>
order by a.create_time desc
</select>
<select id="queryOutOrderById" parameterType="java.lang.Long" resultType="com.mhd.wms.domain.pickingOrder.repository.po.PickingOrderPO">
select
<include refid="selectPickingOrderPo"/>
<include refid="com.mhd.wms.domain.stockOutOrder.repository.mapper.StockOutOrderMapper.joinStockOutOrderPo"/>
from picking_order a
left join stock_out_order b on a.order_number = b.out_order_number and b.del_flag = 1 and a.del_flag = 1
WHERE a.picking_order_id = #{pickingOrderId}
</select>
<select id="queryWaveOrderById" parameterType="java.lang.Long" resultType="com.mhd.wms.domain.pickingOrder.repository.po.PickingOrderPO">
select
<include refid="selectPickingOrderPo"/>
<include refid="com.mhd.wms.domain.waveOrder.repository.mapper.WaveOrderMapper.joinWaveOrderPo"/>
from picking_order a
left join wave_order b on a.order_number = b.wave_order_number and a.del_flag = 1
WHERE a.picking_order_id = #{pickingOrderId}
</select>
<!-- 归档详情(已反审): 反审时拣货单/出库单均已软删, 按 del_flag=2 查归档数据 -->
<select id="queryOutOrderByIdReverse" parameterType="java.lang.Long" resultType="com.mhd.wms.domain.pickingOrder.repository.po.PickingOrderPO">
select
<include refid="selectPickingOrderPo"/>
<include refid="com.mhd.wms.domain.stockOutOrder.repository.mapper.StockOutOrderMapper.joinStockOutOrderPo"/>
from picking_order a
left join stock_out_order b on a.order_number = b.out_order_number and b.del_flag = 2 and a.del_flag = 2
WHERE a.picking_order_id = #{pickingOrderId}
</select>
<select id="queryWaveOrderByIdReverse" parameterType="java.lang.Long" resultType="com.mhd.wms.domain.pickingOrder.repository.po.PickingOrderPO">
select
<include refid="selectPickingOrderPo"/>
<include refid="com.mhd.wms.domain.waveOrder.repository.mapper.WaveOrderMapper.joinWaveOrderPo"/>
from picking_order a
left join wave_order b on a.order_number = b.wave_order_number and a.del_flag = 2
WHERE a.picking_order_id = #{pickingOrderId}
</select>
<select id="queryOutOrderByOrderNumber" parameterType="java.lang.String" resultType="com.mhd.wms.domain.pickingOrder.repository.po.PickingOrderPO">
select
<include refid="selectPickingOrderPo"/>
<include refid="com.mhd.wms.domain.stockOutOrder.repository.mapper.StockOutOrderMapper.joinStockOutOrderPo"/>
from picking_order a
left join stock_out_order b on a.order_number = b.out_order_number and b.del_flag = 1 and a.del_flag = 1
WHERE a.order_number = #{orderNumber}
</select>
<select id="queryWaveOrderByOrderNumber" parameterType="java.lang.String" resultType="com.mhd.wms.domain.pickingOrder.repository.po.PickingOrderPO">
select
<include refid="selectPickingOrderPo"/>
<include refid="com.mhd.wms.domain.waveOrder.repository.mapper.WaveOrderMapper.joinWaveOrderPo"/>
from picking_order a
left join wave_order b on a.order_number = b.wave_order_number and a.del_flag = 1
WHERE a.order_number = #{orderNumber}
</select>
<update id="addQuantity" parameterType="com.mhd.wms.domain.pickingOrder.repository.todo.PickingOrderDO" >
UPDATE picking_order
<set>
picking_quantity = LEAST(picking_quantity + #{pickingQuantity}, quantity),
picking_material_quantity = picking_material_quantity + #{pickingMaterialQuantity},
status = #{status},
update_by = #{updateBy},
update_by_name = #{updateByName},
update_time = #{updateTime}
</set>
WHERE
picking_order_number = #{pickingOrderNumber}
AND del_flag = 1
</update>
</mapper>