Files
smart_management_dev/src/main/resources/mybatis/wisdom/RkInfoMapper.xml

623 lines
24 KiB
XML
Raw Normal View History

2025-05-30 16:13:27 +08:00
<?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">
2026-01-21 19:21:07 +08:00
2025-05-30 16:13:27 +08:00
<mapper namespace="com.zg.project.wisdom.mapper.RkInfoMapper">
2025-07-10 08:40:36 +08:00
<!-- ========================= resultMap ========================= -->
2025-05-30 16:13:27 +08:00
<resultMap type="RkInfo" id="RkInfoResult">
<result property="id" column="id"/>
<result property="operationType" column="operation_type"/>
2026-01-21 19:21:07 +08:00
<result property="operationTypeName" column="operation_type_name"/>
<result property="bizType" column="biz_type"/>
<result property="wlType" column="wl_type"/>
2026-01-21 19:21:07 +08:00
<result property="wlTypeName" column="wl_type_name"/>
<result property="cangku" column="cangku"/>
2026-01-21 19:21:07 +08:00
<result property="warehouseName" column="warehouse_name"/>
<result property="parentWarehouseCode" column="parent_warehouse_code"/>
<result property="parentWarehouseName" column="parent_warehouse_name"/>
<result property="operationTime" column="operation_time"/>
2026-01-21 19:21:07 +08:00
<result property="stockAge" column="stock_age"/>
<result property="operator" column="operator"/>
2026-01-21 19:21:07 +08:00
<result property="operatorName" column="operator_name"/>
<result property="isChuku" column="is_chuku"/>
<result property="status" column="status"/>
<result property="execStatus" column="exec_status"/>
<result property="remark" column="remark"/>
<result property="billNo" column="bill_no"/>
<result property="xj" column="xj"/>
<result property="xmNo" column="xm_no"/>
<result property="xmMs" column="xm_ms"/>
<result property="xmNoCk" column="xm_no_ck"/>
<result property="xmMsCk" column="xm_ms_ck"/>
<result property="wlNo" column="wl_no"/>
<result property="wlMs" column="wl_ms"/>
<result property="gysNo" column="gys_no"/>
<result property="gysMc" column="gys_mc"/>
<result property="jhAmt" column="jh_amt"/>
<result property="htDj" column="ht_dj"/>
<result property="sapNo" column="sap_no"/>
<result property="xh" column="xh"/>
<result property="jhQty" column="jh_qty"/>
<result property="htQty" column="ht_qty"/>
<result property="dw" column="dw"/>
<result property="realQty" column="real_qty"/>
<result property="totalAmount" column="total_amount"/>
<result property="pcode" column="pcode"/>
<result property="pcodeId" column="pcode_id"/>
<result property="trayCode" column="tray_code"/>
<result property="entityId" column="entity_id"/>
<result property="teamCode" column="team_code"/>
<result property="borrowTime" column="borrow_time"/>
<result property="returnTime" column="return_time"/>
<result property="hasMoved" column="has_moved"/>
<result property="isBorrowed" column="is_borrowed"/>
<result property="createBy" column="create_by"/>
<result property="createTime" column="create_time"/>
<result property="updateBy" column="update_by"/>
<result property="updateTime" column="update_time"/>
<result property="isDelete" column="is_delete"/>
<result property="gysJhId" column="gys_jh_id"/>
<result property="rdid" column="rdid"/>
<result property="rdidCk" column="rdid_ck"/>
<result property="sid" column="sid"/>
<result property="isDelivery" column="is_delivery"/>
<result property="fycde1" column="fycde_1"/>
<result property="fycde2" column="fycde_2"/>
<result property="isUpdate" column="is_update"/>
2025-05-30 16:13:27 +08:00
</resultMap>
2026-01-21 19:21:07 +08:00
<!-- ========================= 公共查询 SQL联表完整版 ========================= -->
2025-05-30 16:13:27 +08:00
<sql id="selectRkInfoVo">
2026-01-21 19:21:07 +08:00
SELECT
ri.*,
/* ===== 新增:计算总金额 ===== */
ri.real_qty * ri.ht_dj AS total_amount,
2025-05-30 16:13:27 +08:00
COALESCE(sit.type_name, sot.type_name) AS operation_type_name,
2026-01-21 19:21:07 +08:00
mt.type_name AS wl_type_name,
wh.warehouse_name,
wh.parent_warehouse_code,
wh.parent_warehouse_name,
su.nick_name AS operator_name,
DATEDIFF(CURRENT_DATE, ri.operation_time) AS stock_age
2025-06-17 08:39:05 +08:00
2026-01-21 19:21:07 +08:00
FROM rk_info ri
LEFT JOIN stock_in_type sit ON ri.operation_type = sit.type_code
LEFT JOIN stock_out_type sot ON ri.operation_type = sot.type_code
LEFT JOIN material_type mt ON ri.wl_type = mt.type_code
LEFT JOIN warehouse_info wh ON ri.cangku = wh.warehouse_code
LEFT JOIN sys_user su ON ri.operator = su.user_id
</sql>
<!-- ========================= 查询列表 ========================= -->
2025-05-30 16:13:27 +08:00
<select id="selectRkInfoList" parameterType="RkInfo" resultMap="RkInfoResult">
<include refid="selectRkInfoVo"/>
<where>
2026-01-21 19:21:07 +08:00
ri.exec_status = 1
2026-01-22 19:59:49 +08:00
AND ri.is_chuku = 0
AND ri.is_delete = 0
2026-02-13 09:47:05 +08:00
<if test="operationType != null and operationType != ''">
2026-01-21 19:21:07 +08:00
AND ri.operation_type LIKE CONCAT('%', #{operationType}, '%')
</if>
2026-02-13 09:47:05 +08:00
2026-01-21 19:21:07 +08:00
<if test="sapNo != null and sapNo != ''">
AND ri.sap_no LIKE CONCAT('%', #{sapNo}, '%')
</if>
2026-02-13 09:47:05 +08:00
2026-01-21 19:21:07 +08:00
<if test="xmNo != null and xmNo != ''">
AND ri.xm_no LIKE CONCAT('%', #{xmNo}, '%')
</if>
2026-02-13 09:47:05 +08:00
2026-01-21 19:21:07 +08:00
<if test="xmMs != null and xmMs != ''">
AND ri.xm_ms LIKE CONCAT('%', #{xmMs}, '%')
</if>
2026-02-13 09:47:05 +08:00
2026-01-21 19:21:07 +08:00
<if test="wlNo != null and wlNo != ''">
AND ri.wl_no LIKE CONCAT('%', #{wlNo}, '%')
</if>
2026-02-13 09:47:05 +08:00
2026-01-21 19:21:07 +08:00
<if test="wlMs != null and wlMs != ''">
AND ri.wl_ms LIKE CONCAT('%', #{wlMs}, '%')
</if>
2026-02-13 09:47:05 +08:00
2026-01-21 19:21:07 +08:00
<if test="gysMc != null and gysMc != ''">
AND ri.gys_mc LIKE CONCAT('%', #{gysMc}, '%')
</if>
2026-02-13 09:47:05 +08:00
2026-01-21 19:21:07 +08:00
<if test="pcode != null and pcode != ''">
AND ri.pcode LIKE CONCAT('%', #{pcode}, '%')
2025-06-05 09:05:08 +08:00
</if>
2026-02-13 09:47:05 +08:00
<if test="bizType != null and bizType != ''">
2026-01-21 19:21:07 +08:00
AND ri.biz_type LIKE CONCAT('%', #{bizType}, '%')
2025-07-25 17:04:11 +08:00
</if>
2026-02-13 09:47:05 +08:00
2025-07-25 17:04:11 +08:00
<if test="wlType != null and wlType != ''">
2026-01-21 19:21:07 +08:00
AND ri.wl_type LIKE CONCAT('%', #{wlType}, '%')
2025-07-25 17:04:11 +08:00
</if>
2026-02-13 09:47:05 +08:00
2025-07-25 17:04:11 +08:00
<if test="cangku != null and cangku != ''">
2026-01-21 19:21:07 +08:00
AND ri.cangku LIKE CONCAT('%', #{cangku}, '%')
2025-07-25 17:04:11 +08:00
</if>
2026-02-13 09:47:05 +08:00
2025-07-25 17:04:11 +08:00
<if test="billNo != null and billNo != ''">
2026-01-21 19:21:07 +08:00
AND ri.bill_no LIKE CONCAT('%', #{billNo}, '%')
2025-07-25 17:04:11 +08:00
</if>
2026-02-13 09:47:05 +08:00
<!-- ★★★ 新增:按备注模糊搜索 ★★★ -->
<if test="remark != null and remark != ''">
AND ri.remark LIKE CONCAT('%', #{remark}, '%')
</if>
<if test="isDelete != null and isDelete != ''">
2026-01-21 19:21:07 +08:00
AND ri.is_delete = #{isDelete}
</if>
2026-02-13 09:47:05 +08:00
2026-01-21 19:21:07 +08:00
<if test="startDate != null">
AND ri.operation_time &gt;= #{startDate}
</if>
2026-02-13 09:47:05 +08:00
2026-01-21 19:21:07 +08:00
<if test="endDate != null">
AND ri.operation_time &lt;= #{endDate}
2025-07-25 17:04:11 +08:00
</if>
2025-05-30 16:13:27 +08:00
</where>
2026-02-13 09:47:05 +08:00
2026-01-21 19:21:07 +08:00
ORDER BY ri.operation_time DESC
2025-05-30 16:13:27 +08:00
</select>
2025-06-04 11:34:07 +08:00
<!-- ========================= 按 ID 查询 ========================= -->
2025-05-30 16:13:27 +08:00
<select id="selectRkInfoById" parameterType="Long" resultMap="RkInfoResult">
<include refid="selectRkInfoVo"/>
2026-01-21 19:21:07 +08:00
WHERE ri.id = #{id}
2025-07-10 08:40:36 +08:00
</select>
2026-01-22 19:59:49 +08:00
<select id="countByBillNo" resultType="int">
SELECT COUNT(1)
FROM rk_info
WHERE bill_no = #{billNo}
</select>
<select id="countNotPreByIds" resultType="int">
SELECT COUNT(1)
FROM rk_info
WHERE id IN
<foreach collection="rkInfoIds" item="id" open="(" separator="," close=")">
#{id}
</foreach>
AND exec_status != '0'
</select>
<select id="selectRkInfoByIds"
parameterType="java.util.List"
resultMap="RkInfoResult">
SELECT
ri.*,
ri.real_qty * ri.ht_dj AS total_amount
2026-01-22 19:59:49 +08:00
FROM rk_info ri
WHERE ri.id IN
<foreach collection="rkInfoIds" item="id" open="(" separator="," close=")">
#{id}
</foreach>
</select>
2026-01-23 17:15:20 +08:00
<select id="selectStockStatisticByCondition"
parameterType="com.zg.project.wisdom.domain.RkInfo"
resultType="com.zg.project.wisdom.domain.vo.StockStatisticVO">
SELECT
2026-01-30 10:20:32 +08:00
IFNULL(SUM(ri.real_qty * ri.ht_dj), 0) AS totalAmount,
COUNT(DISTINCT ri.pcode) AS locationCount,
IFNULL(SUM(ri.real_qty), 0) AS totalQuantity
2026-01-23 17:15:20 +08:00
FROM rk_info ri
<where>
ri.exec_status = 1
AND ri.is_chuku = 0
AND ri.is_delete = 0
<if test="operationType != null and operationType != ''">
AND ri.operation_type LIKE CONCAT('%', #{operationType}, '%')
</if>
<if test="sapNo != null and sapNo != ''">
AND ri.sap_no LIKE CONCAT('%', #{sapNo}, '%')
</if>
<if test="xmNo != null and xmNo != ''">
AND ri.xm_no LIKE CONCAT('%', #{xmNo}, '%')
</if>
<if test="xmMs != null and xmMs != ''">
AND ri.xm_ms LIKE CONCAT('%', #{xmMs}, '%')
</if>
<if test="wlNo != null and wlNo != ''">
AND ri.wl_no LIKE CONCAT('%', #{wlNo}, '%')
</if>
<if test="wlMs != null and wlMs != ''">
AND ri.wl_ms LIKE CONCAT('%', #{wlMs}, '%')
</if>
<if test="gysMc != null and gysMc != ''">
AND ri.gys_mc LIKE CONCAT('%', #{gysMc}, '%')
</if>
<if test="pcode != null and pcode != ''">
AND ri.pcode LIKE CONCAT('%', #{pcode}, '%')
</if>
<if test="bizType != null and bizType != ''">
AND ri.biz_type LIKE CONCAT('%', #{bizType}, '%')
</if>
<if test="wlType != null and wlType != ''">
AND ri.wl_type LIKE CONCAT('%', #{wlType}, '%')
</if>
<if test="cangku != null and cangku != ''">
AND ri.cangku LIKE CONCAT('%', #{cangku}, '%')
</if>
<if test="billNo != null and billNo != ''">
AND ri.bill_no LIKE CONCAT('%', #{billNo}, '%')
</if>
<if test="startDate != null">
AND ri.operation_time &gt;= #{startDate}
</if>
<if test="endDate != null">
AND ri.operation_time &lt;= #{endDate}
</if>
</where>
</select>
2026-01-21 19:21:07 +08:00
<!-- ========================= 删除 ========================= -->
<delete id="deleteRkInfoById" parameterType="Long">
DELETE FROM rk_info WHERE id = #{id}
</delete>
2025-12-12 14:52:48 +08:00
2026-01-22 19:59:49 +08:00
<delete id="deleteRkInfoByIds">
2026-01-21 19:21:07 +08:00
DELETE FROM rk_info
WHERE id IN
2026-01-22 19:59:49 +08:00
<foreach collection="ids" item="id" open="(" separator="," close=")">
#{id}
2026-01-21 19:21:07 +08:00
</foreach>
</delete>
<!-- ========================= 插入 ========================= -->
<insert id="insertRkInfo" parameterType="RkInfo" useGeneratedKeys="true" keyProperty="id">
2026-01-21 19:21:07 +08:00
INSERT INTO rk_info (
operation_type, biz_type, wl_type, cangku, operation_time, operator,
is_chuku, status, exec_status, remark, bill_no,
xj, xm_no, xm_ms, xm_no_ck, xm_ms_ck,
wl_no, wl_ms,
gys_no, gys_mc,
jh_amt, ht_dj, sap_no, xh,
jh_qty, ht_qty, dw, real_qty,
pcode, pcode_id, tray_code, entity_id,
team_code, borrow_time, return_time,
has_moved, is_borrowed,
gys_jh_id,
rdid, rdid_ck, sid,
is_delivery,
fycde_1, fycde_2,
is_update,
create_by, create_time, is_delete
2025-07-21 11:17:44 +08:00
)
2026-01-21 19:21:07 +08:00
VALUES (
#{operationType}, #{bizType}, #{wlType}, #{cangku}, #{operationTime}, #{operator},
#{isChuku}, #{status}, #{execStatus}, #{remark}, #{billNo},
#{xj}, #{xmNo}, #{xmMs}, #{xmNoCk}, #{xmMsCk},
#{wlNo}, #{wlMs},
#{gysNo}, #{gysMc},
#{jhAmt}, #{htDj}, #{sapNo}, #{xh},
#{jhQty}, #{htQty}, #{dw}, #{realQty},
#{pcode}, #{pcodeId}, #{trayCode}, #{entityId},
#{teamCode}, #{borrowTime}, #{returnTime},
#{hasMoved}, #{isBorrowed},
#{gysJhId},
#{rdid}, #{rdidCk}, #{sid},
#{isDelivery},
#{fycde1}, #{fycde2},
#{isUpdate},
#{createBy}, #{createTime}, #{isDelete}
)
</insert>
2026-01-21 19:21:07 +08:00
<!-- ========================= 更新 ========================= -->
2025-05-30 16:13:27 +08:00
<update id="updateRkInfo" parameterType="RkInfo">
2026-01-21 19:21:07 +08:00
UPDATE rk_info
2026-01-06 14:19:58 +08:00
<trim prefix="SET" suffixOverrides=",">
<if test="operationType != null">operation_type = #{operationType},</if>
<if test="bizType != null">biz_type = #{bizType},</if>
2026-01-06 14:19:58 +08:00
<if test="wlType != null">wl_type = #{wlType},</if>
<if test="cangku != null">cangku = #{cangku},</if>
2026-01-21 19:21:07 +08:00
<if test="operationTime != null">operation_time = #{operationTime},</if>
<if test="operator != null">operator = #{operator},</if>
<if test="isChuku != null">is_chuku = #{isChuku},</if>
<if test="status != null">status = #{status},</if>
<if test="execStatus != null">exec_status = #{execStatus},</if>
2026-01-21 19:21:07 +08:00
<if test="remark != null">remark = #{remark},</if>
<if test="billNo != null">bill_no = #{billNo},</if>
<if test="xj != null">xj = #{xj},</if>
<if test="xmNo != null">xm_no = #{xmNo},</if>
<if test="xmMs != null">xm_ms = #{xmMs},</if>
<if test="xmNoCk != null">xm_no_ck = #{xmNoCk},</if>
<if test="xmMsCk != null">xm_ms_ck = #{xmMsCk},</if>
<if test="wlNo != null">wl_no = #{wlNo},</if>
<if test="wlMs != null">wl_ms = #{wlMs},</if>
<if test="gysNo != null">gys_no = #{gysNo},</if>
<if test="gysMc != null">gys_mc = #{gysMc},</if>
<if test="jhAmt != null">jh_amt = #{jhAmt},</if>
<if test="htDj != null">ht_dj = #{htDj},</if>
<if test="sapNo != null">sap_no = #{sapNo},</if>
<if test="xh != null">xh = #{xh},</if>
<if test="jhQty != null">jh_qty = #{jhQty},</if>
<if test="htQty != null">ht_qty = #{htQty},</if>
<if test="dw != null">dw = #{dw},</if>
<if test="realQty != null">real_qty = #{realQty},</if>
<if test="pcode != null">pcode = #{pcode},</if>
<if test="pcodeId != null">pcode_id = #{pcodeId},</if>
<if test="trayCode != null">tray_code = #{trayCode},</if>
<if test="entityId != null">entity_id = #{entityId},</if>
<if test="teamCode != null">team_code = #{teamCode},</if>
<if test="borrowTime != null">borrow_time = #{borrowTime},</if>
<if test="returnTime != null">return_time = #{returnTime},</if>
<if test="hasMoved != null">has_moved = #{hasMoved},</if>
<if test="isBorrowed != null">is_borrowed = #{isBorrowed},</if>
<if test="gysJhId != null">gys_jh_id = #{gysJhId},</if>
<if test="rdid != null">rdid = #{rdid},</if>
<if test="rdidCk != null">rdid_ck = #{rdidCk},</if>
<if test="sid != null">sid = #{sid},</if>
<if test="isDelivery != null">is_delivery = #{isDelivery},</if>
<if test="fycde1 != null">fycde_1 = #{fycde1},</if>
<if test="fycde2 != null">fycde_2 = #{fycde2},</if>
<if test="isUpdate != null">is_update = #{isUpdate},</if>
2026-01-06 14:19:58 +08:00
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
2026-01-21 19:21:07 +08:00
<if test="isDelete != null">is_delete = #{isDelete},</if>
2026-01-06 14:19:58 +08:00
</trim>
2026-01-21 19:21:07 +08:00
WHERE id = #{id}
2025-05-30 16:13:27 +08:00
</update>
2026-01-21 19:21:07 +08:00
<update id="updateExecStatusByIds">
UPDATE rk_info
SET exec_status = #{execStatus}
WHERE id IN
<foreach collection="ids" item="id" open="(" separator="," close=")">
#{id}
</foreach>
</update>
2026-01-22 19:59:49 +08:00
<update id="updateRealQtyById">
update rk_info
set real_qty = #{realQty},
update_time = now()
where id = #{id}
</update>
<update id="updateIsChukuById">
update rk_info
set is_chuku = #{isChuku},
update_time = now()
where id = #{id}
</update>
<update id="updateBorrowReturn">
UPDATE rk_info
SET is_borrowed = #{isBorrowed},
return_time = #{returnTime},
update_time = NOW()
WHERE id = #{id}
2026-01-23 17:15:20 +08:00
AND is_delete = '0'
2026-01-22 19:59:49 +08:00
</update>
<!-- ========================= 1⃣ 正常匹配 ========================= -->
<select id="getByPcodeIdList" resultMap="RkInfoResult">
SELECT
ri.*
FROM rk_info ri
JOIN pcde_detail pd ON ri.pcode_id = pd.encoded_id
WHERE ri.is_delete = '0'
AND ri.is_chuku = '0'
AND pd.is_delete = '0'
AND pd.scene = #{sceneId}
AND ri.pcode_id IN
<foreach collection="pcdeIds" item="id" open="(" separator="," close=")">
#{id}
</foreach>
</select>
<!-- ========================= 2⃣ 未盘点 ========================= -->
<select id="getMissedPcodeIds" resultMap="RkInfoResult">
SELECT
ri.*
FROM rk_info ri
JOIN pcde_detail pd ON ri.pcode_id = pd.encoded_id
WHERE ri.is_delete = '0'
AND ri.is_chuku = '0'
AND pd.is_delete = '0'
AND pd.scene = #{sceneId}
<if test="pcdeIds != null and pcdeIds.size() > 0">
AND ri.pcode_id NOT IN
<foreach collection="pcdeIds" item="id" open="(" separator="," close=")">
#{id}
</foreach>
</if>
</select>
<!-- ========================= 3⃣ 异常(不存在) ========================= -->
<select id="getNotExistsPcodeIds" resultType="java.lang.String">
SELECT t.pcode_id
FROM (
<foreach collection="pcdeIds" item="id" separator="UNION ALL">
SELECT #{id} AS pcode_id
</foreach>
) t
LEFT JOIN (
SELECT ri.pcode_id
FROM rk_info ri
JOIN pcde_detail pd ON ri.pcode_id = pd.encoded_id
WHERE ri.is_delete = '0'
AND ri.is_chuku = '0'
AND pd.is_delete = '0'
AND pd.scene = #{sceneId}
) s ON t.pcode_id = s.pcode_id
WHERE s.pcode_id IS NULL
</select>
<select id="selectPcdeCntFromRkInfo" resultType="com.zg.project.inventory.domain.vo.PcdeCntVO">
SELECT pcode AS pcde,
COUNT(*) AS cnt
FROM rk_info
WHERE pcode_id IN
<foreach collection="ids" item="id" open="(" separator="," close=")">
#{id}
</foreach>
GROUP BY pcode
</select>
<select id="getUnscannedPcodeByScene"
resultType="com.zg.project.inventory.domain.vo.RkInfoMatchVO">
SELECT
r.pcode AS rkPcode,
COALESCE(SUM(r.real_qty), 0) AS realQty
FROM pcde_detail d
JOIN rk_info r ON r.pcode = d.pcode
LEFT JOIN (
SELECT DISTINCT pcode
FROM inventory_match_scan
WHERE task_id = #{taskId}
AND status = '0'
) s ON s.pcode = r.pcode
WHERE (d.is_delete IS NULL OR d.is_delete = '0')
AND d.scene = #{sceneId}
AND r.is_chuku = '0'
AND s.pcode IS NULL
GROUP BY r.pcode
ORDER BY MAX(r.create_time) DESC
</select>
<select id="countGetByWh" resultType="java.lang.Integer" parameterType="java.lang.String">
SELECT COUNT(1) FROM rk_info
WHERE is_delete = '0'
AND cangku = #{warehouse}
AND is_chuku = '0'
</select>
<select id="listRkInfoByPcode"
parameterType="string"
resultMap="RkInfoResult">
SELECT
t.*,
wh.warehouse_name AS cangku_name,
wh.parent_warehouse_code AS parent_warehouse_code,
wh.parent_warehouse_name AS parent_warehouse_name,
wh.warehouse_code AS warehouse_code,
wh.warehouse_name AS warehouse_name
FROM rk_info t
LEFT JOIN warehouse_info wh
ON wh.warehouse_code = t.cangku
WHERE t.is_delete = 0
AND t.is_chuku = 0
AND t.pcode = #{pcode}
ORDER BY t.operation_time DESC, t.id DESC
</select>
2026-01-22 19:59:49 +08:00
<!-- ========================= 按单据号排序查询列表 ========================= -->
<select id="selectRkInfoListOrderByBillNo" parameterType="RkInfo" resultMap="RkInfoResult">
<include refid="selectRkInfoVo"/>
<where>
ri.exec_status = 1
AND ri.is_chuku = 0
AND ri.is_delete = 0
<if test="operationType != null and operationType != ''">
AND ri.operation_type LIKE CONCAT('%', #{operationType}, '%')
</if>
<if test="sapNo != null and sapNo != ''">
AND ri.sap_no LIKE CONCAT('%', #{sapNo}, '%')
</if>
<if test="xmNo != null and xmNo != ''">
AND ri.xm_no LIKE CONCAT('%', #{xmNo}, '%')
</if>
<if test="xmMs != null and xmMs != ''">
AND ri.xm_ms LIKE CONCAT('%', #{xmMs}, '%')
</if>
<if test="wlNo != null and wlNo != ''">
AND ri.wl_no LIKE CONCAT('%', #{wlNo}, '%')
</if>
<if test="wlMs != null and wlMs != ''">
AND ri.wl_ms LIKE CONCAT('%', #{wlMs}, '%')
</if>
<if test="gysMc != null and gysMc != ''">
AND ri.gys_mc LIKE CONCAT('%', #{gysMc}, '%')
</if>
<if test="pcode != null and pcode != ''">
AND ri.pcode LIKE CONCAT('%', #{pcode}, '%')
</if>
<if test="bizType != null and bizType != ''">
AND ri.biz_type LIKE CONCAT('%', #{bizType}, '%')
</if>
<if test="wlType != null and wlType != ''">
AND ri.wl_type LIKE CONCAT('%', #{wlType}, '%')
</if>
<if test="cangku != null and cangku != ''">
AND ri.cangku LIKE CONCAT('%', #{cangku}, '%')
</if>
<if test="billNo != null and billNo != ''">
AND ri.bill_no LIKE CONCAT('%', #{billNo}, '%')
</if>
<if test="isDelete != null and isDelete != ''">
AND ri.is_delete = #{isDelete}
</if>
<!-- 出入库时间范围 -->
<if test="startDate != null">
AND ri.operation_time &gt;= #{startDate}
</if>
<if test="endDate != null">
AND ri.operation_time &lt;= #{endDate}
</if>
</where>
ORDER BY
/* 1. 纯数字优先 */
(ri.sap_no REGEXP '^[0-9]+$') DESC,
/* 2. 纯数字按【从小到大】 */
CASE
WHEN ri.sap_no REGEXP '^[0-9]+$'
THEN CAST(ri.sap_no AS UNSIGNED)
ELSE 999999999999
END ASC,
/* 3. 字母混合按字符串 */
ri.sap_no ASC
</select>
2026-02-13 09:47:05 +08:00
<select id="getByWarehouseAndScene" resultMap="RkInfoResult">
SELECT
ri.*
FROM rk_info ri
JOIN pcde_detail pd
ON pd.pcode = ri.pcode
WHERE ri.exec_status = 1
AND ri.is_delete = '0'
AND ri.is_chuku = '0'
AND ri.cangku = #{warehouseCode}
AND pd.scene = #{sceneId}
</select>
<select id="listRkInfoByPcodes"
resultMap="RkInfoResult"
parameterType="java.util.ArrayList">
SELECT *
FROM rk_info
WHERE is_delete = 0
AND is_chuku = 0
AND pcode IN
<foreach collection="list" item="p" open="(" separator="," close=")">
#{p}
</foreach>
</select>
</mapper>