635 lines
25 KiB
XML
635 lines
25 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.zg.project.wisdom.mapper.RkInfoMapper">
|
||
|
||
<!-- ========================= resultMap ========================= -->
|
||
<resultMap type="RkInfo" id="RkInfoResult">
|
||
<result property="id" column="id"/>
|
||
<result property="operationType" column="operation_type"/>
|
||
<result property="operationTypeName" column="operation_type_name"/>
|
||
<result property="bizType" column="biz_type"/>
|
||
<result property="wlType" column="wl_type"/>
|
||
<result property="wlTypeName" column="wl_type_name"/>
|
||
<result property="cangku" column="cangku"/>
|
||
<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"/>
|
||
<result property="stockAge" column="stock_age"/>
|
||
<result property="operator" column="operator"/>
|
||
<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"/>
|
||
<result property="scene" column="scene"/>
|
||
<result property="sceneName" column="sceneName"/>
|
||
</resultMap>
|
||
|
||
<!-- ========================= 公共查询 SQL(联表完整版) ========================= -->
|
||
<sql id="selectRkInfoVo">
|
||
SELECT
|
||
ri.*,
|
||
CASE
|
||
WHEN ri.scene = 'HJ' THEN '货架'
|
||
WHEN ri.scene = 'DC' THEN '堆场'
|
||
ELSE ri.scene
|
||
END AS sceneName,
|
||
/* ===== 新增:计算总金额 ===== */
|
||
ri.real_qty * ri.ht_dj AS total_amount,
|
||
|
||
COALESCE(sit.type_name, sot.type_name) AS operation_type_name,
|
||
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
|
||
|
||
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>
|
||
<!-- ========================= 查询列表 ========================= -->
|
||
<select id="selectRkInfoList" 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="remark != null and remark != ''">
|
||
AND ri.remark LIKE CONCAT('%', #{remark}, '%')
|
||
</if>
|
||
<if test="scene != null and scene != ''">
|
||
AND ri.scene LIKE CONCAT('%', #{scene}, '%')
|
||
</if>
|
||
<if test="isDelete != null and isDelete != ''">
|
||
AND ri.is_delete = #{isDelete}
|
||
</if>
|
||
|
||
<if test="startDate != null">
|
||
AND ri.operation_time >= #{startDate}
|
||
</if>
|
||
|
||
<if test="endDate != null">
|
||
AND ri.operation_time <= #{endDate}
|
||
</if>
|
||
</where>
|
||
|
||
ORDER BY ri.operation_time DESC
|
||
</select>
|
||
|
||
<!-- ========================= 按 ID 查询 ========================= -->
|
||
<select id="selectRkInfoById" parameterType="Long" resultMap="RkInfoResult">
|
||
<include refid="selectRkInfoVo"/>
|
||
WHERE ri.id = #{id}
|
||
</select>
|
||
|
||
<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
|
||
|
||
FROM rk_info ri
|
||
WHERE ri.id IN
|
||
<foreach collection="rkInfoIds" item="id" open="(" separator="," close=")">
|
||
#{id}
|
||
</foreach>
|
||
</select>
|
||
|
||
<select id="selectStockStatisticByCondition"
|
||
parameterType="com.zg.project.wisdom.domain.RkInfo"
|
||
resultType="com.zg.project.wisdom.domain.vo.StockStatisticVO">
|
||
|
||
SELECT
|
||
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
|
||
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="scene != null and scene != ''">
|
||
AND ri.scene LIKE CONCAT('%', #{scene}, '%')
|
||
</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 >= #{startDate}
|
||
</if>
|
||
<if test="endDate != null">
|
||
AND ri.operation_time <= #{endDate}
|
||
</if>
|
||
</where>
|
||
</select>
|
||
|
||
<!-- ========================= 删除 ========================= -->
|
||
<delete id="deleteRkInfoById" parameterType="Long">
|
||
DELETE FROM rk_info WHERE id = #{id}
|
||
</delete>
|
||
|
||
<delete id="deleteRkInfoByIds">
|
||
DELETE FROM rk_info
|
||
WHERE id IN
|
||
<foreach collection="ids" item="id" open="(" separator="," close=")">
|
||
#{id}
|
||
</foreach>
|
||
</delete>
|
||
|
||
<!-- ========================= 插入 ========================= -->
|
||
<insert id="insertRkInfo" parameterType="RkInfo" useGeneratedKeys="true" keyProperty="id">
|
||
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,scene
|
||
)
|
||
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},#{scene}
|
||
)
|
||
</insert>
|
||
|
||
<!-- ========================= 更新 ========================= -->
|
||
<update id="updateRkInfo" parameterType="RkInfo">
|
||
UPDATE rk_info
|
||
<trim prefix="SET" suffixOverrides=",">
|
||
<if test="operationType != null">operation_type = #{operationType},</if>
|
||
<if test="bizType != null">biz_type = #{bizType},</if>
|
||
<if test="wlType != null">wl_type = #{wlType},</if>
|
||
<if test="cangku != null">cangku = #{cangku},</if>
|
||
<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>
|
||
<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>
|
||
<if test="updateBy != null">update_by = #{updateBy},</if>
|
||
<if test="updateTime != null">update_time = #{updateTime},</if>
|
||
<if test="isDelete != null">is_delete = #{isDelete},</if>
|
||
<if test="scene != null">scene = #{scene}</if>
|
||
</trim>
|
||
WHERE id = #{id}
|
||
</update>
|
||
|
||
<update id="updateExecStatusByIds">
|
||
UPDATE rk_info
|
||
SET exec_status = #{execStatus}
|
||
WHERE id IN
|
||
<foreach collection="ids" item="id" open="(" separator="," close=")">
|
||
#{id}
|
||
</foreach>
|
||
</update>
|
||
|
||
<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}
|
||
AND is_delete = '0'
|
||
</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>
|
||
|
||
<!-- ========================= 按单据号排序查询列表 ========================= -->
|
||
<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 >= #{startDate}
|
||
</if>
|
||
<if test="endDate != null">
|
||
AND ri.operation_time <= #{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>
|
||
|
||
<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>
|