生成出入库单据逻辑修改

This commit is contained in:
2025-12-25 09:42:51 +08:00
parent 0fe1ee916c
commit b0bbeeec7c
9 changed files with 334 additions and 300 deletions

View File

@@ -282,8 +282,8 @@
</if>
<if test="endTime != null">
<![CDATA[
AND ri.rk_time < DATE_ADD(#{endTime}, INTERVAL 1 DAY)
]]>
AND ri.rk_time <= #{endTime}
]]>
</if>
<if test="lyStartTime != null">
@@ -381,6 +381,7 @@
ORDER BY ri.rk_time DESC
</select>
<!-- 借料 / 还料专用列表查询 -->
<select id="selectBorrowAndReturnList"
parameterType="RkInfo"
resultMap="RkInfoResult">
@@ -389,72 +390,29 @@
<where>
<!-- 只查未删除 -->
<choose>
<when test="isDelete != null and isDelete != ''">
AND ri.is_delete = #{isDelete}
</when>
<otherwise>
AND ri.is_delete = 0
</otherwise>
</choose>
AND ri.is_delete = 0
<!-- 借料/还料状态0 否1 借料中2 已归还 -->
<!-- ✅ 关键:只允许未出库的数据 -->
AND ri.is_chuku = '0'
<!-- 借料状态 -->
<choose>
<when test="isBorrowed != null and isBorrowed != ''">
AND ri.is_borrowed = #{isBorrowed}
</when>
<otherwise>
AND ri.is_borrowed IN ('1','2')
AND (ri.is_borrowed = 0 OR ri.is_borrowed IS NULL)
</otherwise>
</choose>
<!-- 时间范围:根据 isBorrowed 选择 borrow_time / return_time -->
<!-- 先添加通用时间条件如果isBorrowed为1或2时使用对应的时间字段 -->
<if test="startTime != null">
<choose>
<when test="isBorrowed != null and (isBorrowed == '1' or isBorrowed == 1)">
<![CDATA[
AND ri.borrow_time >= #{startTime}
]]>
</when>
<when test="isBorrowed != null and (isBorrowed == '2' or isBorrowed == 2)">
<![CDATA[
AND ri.return_time >= #{startTime}
]]>
</when>
<otherwise>
<![CDATA[
AND ri.rk_time >= #{startTime}
]]>
</otherwise>
</choose>
</if>
<if test="endTime != null">
<choose>
<when test="isBorrowed != null and (isBorrowed == '1' or isBorrowed == 1)">
<![CDATA[
AND ri.borrow_time < DATE_ADD(#{endTime}, INTERVAL 1 DAY)
]]>
</when>
<when test="isBorrowed != null and (isBorrowed == '2' or isBorrowed == 2)">
<![CDATA[
AND ri.return_time < DATE_ADD(#{endTime}, INTERVAL 1 DAY)
]]>
</when>
<otherwise>
<![CDATA[
AND ri.rk_time < DATE_ADD(#{endTime}, INTERVAL 1 DAY)
]]>
</otherwise>
</choose>
</if>
<if test="xmNo != null and xmNo != ''">
AND ri.xm_no LIKE concat('%', #{xmNo}, '%')
</if>
<if test="sapNo != null and sapNo != ''">
AND ri.sap_no LIKE concat('%', #{sapNo}, '%')
</if>
<if test="billNo != null and billNo != ''">
AND ri.bill_no LIKE concat('%', #{billNo}, '%')
</if>
@@ -463,15 +421,18 @@
ORDER BY ri.borrow_time DESC, ri.return_time DESC, ri.id DESC
</select>
<select id="selectGroupedByBill" resultMap="RkInfoResult" parameterType="map">
<select id="selectGroupedByBill"
resultMap="RkInfoResult"
parameterType="map">
SELECT
a.id,
a.bill_no,
a.bill_no_ck,
a.rk_type,
si.type_name AS rk_type_name,
si.type_name AS rk_type_name,
a.wl_type,
mt.type_name AS wl_type_name,
mt.type_name AS wl_type_name,
a.cangku,
a.rk_time,
a.lihuo_y,
@@ -487,37 +448,51 @@
a.gys_no,
a.sap_no,
a.ck_type,
so.type_name AS ck_type_name,
so.type_name AS ck_type_name,
a.ly_time,
a.ck_lihuo_y,
u.user_name AS ck_lihuo_y_name,
ru.user_name AS lihuo_y_name,
a.is_delivery AS is_delivery
u.user_name AS ck_lihuo_y_name,
ru.user_name AS lihuo_y_name,
a.is_delivery AS is_delivery
FROM (
SELECT
MIN(t.id) AS id,
t.bill_no AS bill_no,
MIN(t.bill_no_ck) AS bill_no_ck,
MIN(t.rk_type) AS rk_type,
MIN(t.wl_type) AS wl_type,
MIN(t.cangku) AS cangku,
MIN(t.rk_time) AS rk_time,
MIN(t.lihuo_y) AS lihuo_y,
MAX(t.is_chuku) AS is_chuku,
MIN(t.xj) AS xj,
MIN(t.xm_no) AS xm_no,
MIN(t.xm_ms) AS xm_ms,
MIN(t.xm_no_ck) AS xm_no_ck,
MIN(t.xm_ms_ck) AS xm_ms_ck,
MIN(t.gys_mc) AS gys_mc,
MIN(t.wl_no) AS wl_no,
MIN(t.wl_ms) AS wl_ms,
MIN(t.gys_no) AS gys_no,
MIN(t.sap_no) AS sap_no,
MIN(t.ck_type) AS ck_type,
MAX(t.ly_time) AS ly_time,
MIN(t.ck_lihuo_y) AS ck_lihuo_y,
MIN(t.is_delivery) AS is_delivery
MIN(t.id) AS id,
/* ✅ 单据号:出库/借料出库 -> CK其它 -> RK用于页面展示 */
t.show_bill_no AS bill_no,
/* 保留 bill_no_ck 字段(出库态有值) */
MIN(t.bill_no_ck) AS bill_no_ck,
MIN(t.rk_type) AS rk_type,
MIN(t.wl_type) AS wl_type,
MIN(t.cangku) AS cangku,
/* 时间:你要更合理也可以改成 MAX(COALESCE(ly_time,rk_time)) */
MIN(t.rk_time) AS rk_time,
MIN(t.lihuo_y) AS lihuo_y,
MAX(t.is_chuku) AS is_chuku,
MIN(t.xj) AS xj,
MIN(t.xm_no) AS xm_no,
MIN(t.xm_ms) AS xm_ms,
MIN(t.xm_no_ck) AS xm_no_ck,
MIN(t.xm_ms_ck) AS xm_ms_ck,
MIN(t.gys_mc) AS gys_mc,
MIN(t.wl_no) AS wl_no,
MIN(t.wl_ms) AS wl_ms,
MIN(t.gys_no) AS gys_no,
MIN(t.sap_no) AS sap_no,
MIN(t.ck_type) AS ck_type,
MAX(t.ly_time) AS ly_time,
MIN(t.ck_lihuo_y) AS ck_lihuo_y,
MIN(t.is_delivery) AS is_delivery,
/* ✅ 用于 needAudit 子查询判断:本组是 RK 组还是 CK 组 */
MIN(t.show_bill_type) AS show_bill_type
FROM (
SELECT
ri.id,
@@ -544,11 +519,29 @@
ri.ck_lihuo_y,
ri.pcode,
ri.is_delete,
ri.is_delivery
ri.is_delivery,
CASE
WHEN ri.is_chuku IN ('1','3')
AND ri.bill_no_ck IS NOT NULL
AND ri.bill_no_ck != ''
THEN ri.bill_no_ck
ELSE ri.bill_no
END AS show_bill_no,
CASE
WHEN ri.is_chuku IN ('1','3')
AND ri.bill_no_ck IS NOT NULL
AND ri.bill_no_ck != ''
THEN 'CK'
ELSE 'RK'
END AS show_bill_type
FROM rk_info ri
) t
<where>
<!-- is_delete -->
<!-- 只查未删除 -->
<choose>
<when test="q.isDelete != null and q.isDelete != ''">
AND t.is_delete = #{q.isDelete}
@@ -571,60 +564,102 @@
</when>
</choose>
<!-- keyword -->
<if test="q.keyword != null and q.keyword != ''">
AND (
t.xm_no LIKE concat('%', #{q.keyword}, '%')
OR t.xm_ms LIKE concat('%', #{q.keyword}, '%')
OR t.wl_no LIKE concat('%', #{q.keyword}, '%')
OR t.wl_ms LIKE concat('%', #{q.keyword}, '%')
OR t.gys_no LIKE concat('%', #{q.keyword}, '%')
OR t.gys_mc LIKE concat('%', #{q.keyword}, '%')
OR t.sap_no LIKE concat('%', #{q.keyword}, '%')
OR t.bill_no LIKE concat('%', #{q.keyword}, '%')
OR t.bill_no_ck LIKE concat('%', #{q.keyword}, '%')
OR t.ck_type LIKE concat('%', #{q.keyword}, '%')
OR t.pcode LIKE concat('%', #{q.keyword}, '%')
)
<!-- 时间过滤rk_time -->
<if test="q.startTime != null and q.startTime != ''">
<![CDATA[ AND t.rk_time >= #{q.startTime} ]]>
</if>
<if test="q.endTime != null and q.endTime != ''">
<![CDATA[ AND t.rk_time <= #{q.endTime} ]]>
</if>
<!-- 维度 -->
<if test="q.rkType != null and q.rkType != ''"> AND t.rk_type LIKE concat('%', #{q.rkType}, '%') </if>
<if test="q.wlType != null and q.wlType != ''"> AND t.wl_type LIKE concat('%', #{q.wlType}, '%') </if>
<if test="q.cangku != null and q.cangku != ''"> AND t.cangku LIKE concat('%', #{q.cangku}, '%') </if>
<!-- 时间过滤ly_time -->
<if test="q.lyStartTime != null and q.lyStartTime != ''">
<![CDATA[ AND t.ly_time >= #{q.lyStartTime} ]]>
</if>
<if test="q.lyEndTime != null and q.lyEndTime != ''">
<![CDATA[ AND t.ly_time <= #{q.lyEndTime} ]]>
</if>
<!-- 时间 -->
<if test="q.startTime != null"><![CDATA[ AND t.rk_time >= #{q.startTime} ]]></if>
<if test="q.endTime != null"><![CDATA[ AND t.rk_time <= #{q.endTime} ]]></if>
<if test="q.lyStartTime!= null"><![CDATA[ AND t.ly_time >= #{q.lyStartTime}]]></if>
<if test="q.lyEndTime != null"><![CDATA[ AND t.ly_time <= #{q.lyEndTime} ]]></if>
<!-- 维度条件 -->
<if test="q.rkType != null and q.rkType != ''">
AND t.rk_type LIKE concat('%', #{q.rkType}, '%')
</if>
<if test="q.wlType != null and q.wlType != ''">
AND t.wl_type LIKE concat('%', #{q.wlType}, '%')
</if>
<if test="q.cangku != null and q.cangku != ''">
AND t.cangku LIKE concat('%', #{q.cangku}, '%')
</if>
<!-- 模糊字段 -->
<if test="q.lihuoY != null and q.lihuoY != ''"> AND t.lihuo_y LIKE concat('%', #{q.lihuoY}, '%') </if>
<if test="q.xj != null and q.xj != ''"> AND t.xj LIKE concat('%', #{q.xj}, '%') </if>
<if test="q.billNo != null and q.billNo != ''"> AND t.bill_no LIKE concat('%', #{q.billNo}, '%') </if>
<if test="q.billNoCk != null and q.billNoCk != ''"> AND t.bill_no_ck LIKE concat('%', #{q.billNoCk}, '%') </if>
<if test="q.xmNo != null and q.xmNo != ''"> AND t.xm_no LIKE concat('%', #{q.xmNo}, '%') </if>
<if test="q.xmMs != null and q.xmMs != ''"> AND t.xm_ms LIKE concat('%', #{q.xmMs}, '%') </if>
<if test="q.wlNo != null and q.wlNo != ''"> AND t.wl_no LIKE concat('%', #{q.wlNo}, '%') </if>
<if test="q.wlMs != null and q.wlMs != ''"> AND t.wl_ms LIKE concat('%', #{q.wlMs}, '%') </if>
<if test="q.gysNo != null and q.gysNo != ''"> AND t.gys_no LIKE concat('%', #{q.gysNo}, '%') </if>
<if test="q.gysMc != null and q.gysMc != ''"> AND t.gys_mc LIKE concat('%', #{q.gysMc}, '%') </if>
<if test="q.sapNo != null and q.sapNo != ''"> AND t.sap_no LIKE concat('%', #{q.sapNo}, '%') </if>
<if test="q.pcode != null and q.pcode != ''"> AND t.pcode LIKE concat('%', #{q.pcode}, '%') </if>
<if test="q.ckType != null and q.ckType != ''"> AND t.ck_type LIKE concat('%', #{q.ckType}, '%') </if>
<if test="q.lihuoY != null and q.lihuoY != ''">
AND t.lihuo_y LIKE concat('%', #{q.lihuoY}, '%')
</if>
<if test="q.xj != null and q.xj != ''">
AND t.xj LIKE concat('%', #{q.xj}, '%')
</if>
<!-- 单据号(如果你页面输入框叫 billNo就建议这里也去匹配 show_bill_no -->
<if test="q.billNo != null and q.billNo != ''">
AND t.show_bill_no LIKE concat('%', #{q.billNo}, '%')
</if>
<!-- 如果你还保留 billNoCk 入参,也允许精确筛 CK -->
<if test="q.billNoCk != null and q.billNoCk != ''">
AND t.bill_no_ck LIKE concat('%', #{q.billNoCk}, '%')
</if>
<!-- 其它模糊 -->
<if test="q.xmNo != null and q.xmNo != ''">
AND t.xm_no LIKE concat('%', #{q.xmNo}, '%')
</if>
<if test="q.xmMs != null and q.xmMs != ''">
AND t.xm_ms LIKE concat('%', #{q.xmMs}, '%')
</if>
<if test="q.wlNo != null and q.wlNo != ''">
AND t.wl_no LIKE concat('%', #{q.wlNo}, '%')
</if>
<if test="q.wlMs != null and q.wlMs != ''">
AND t.wl_ms LIKE concat('%', #{q.wlMs}, '%')
</if>
<if test="q.gysNo != null and q.gysNo != ''">
AND t.gys_no LIKE concat('%', #{q.gysNo}, '%')
</if>
<if test="q.gysMc != null and q.gysMc != ''">
AND t.gys_mc LIKE concat('%', #{q.gysMc}, '%')
</if>
<if test="q.sapNo != null and q.sapNo != ''">
AND t.sap_no LIKE concat('%', #{q.sapNo}, '%')
</if>
<if test="q.pcode != null and q.pcode != ''">
AND t.pcode LIKE concat('%', #{q.pcode}, '%')
</if>
<if test="q.ckType != null and q.ckType != ''">
AND t.ck_type LIKE concat('%', #{q.ckType}, '%')
</if>
<if test="q.isDelivery != null and q.isDelivery != ''">
AND t.is_delivery = #{q.isDelivery}
</if>
<!-- 出库才要 bill_no_ck 非空 -->
<if test="(q.isChuku != null and q.isChuku == '1')
or (q.isChukuList != null and q.isChukuList.size > 0 and q.isChukuList.contains('1'))">
AND t.bill_no_ck IS NOT NULL
<!-- keyword建议也命中 show_bill_no解决用户输入 CK/RK 都能搜到) -->
<if test="q.keyword != null and q.keyword != ''">
AND (
t.xm_no LIKE concat('%', #{q.keyword}, '%')
OR t.xm_ms LIKE concat('%', #{q.keyword}, '%')
OR t.wl_no LIKE concat('%', #{q.keyword}, '%')
OR t.wl_ms LIKE concat('%', #{q.keyword}, '%')
OR t.gys_no LIKE concat('%', #{q.keyword}, '%')
OR t.gys_mc LIKE concat('%', #{q.keyword}, '%')
OR t.sap_no LIKE concat('%', #{q.keyword}, '%')
OR t.bill_no LIKE concat('%', #{q.keyword}, '%')
OR t.bill_no_ck LIKE concat('%', #{q.keyword}, '%')
OR t.show_bill_no LIKE concat('%', #{q.keyword}, '%')
OR t.ck_type LIKE concat('%', #{q.keyword}, '%')
OR t.pcode LIKE concat('%', #{q.keyword}, '%')
)
</if>
<!-- 审核 -->
<!-- ✅ 审核过滤:按组类型匹配 RK 或 CK -->
<if test="needAudit != null and needAudit == 1">
AND NOT EXISTS (
SELECT 1
@@ -633,12 +668,19 @@
ON asg.rk_id = r2.id
AND asg.approver_id IS NOT NULL
AND (asg.audit_result IS NOT NULL AND asg.audit_result != '1')
WHERE r2.bill_no = t.bill_no
AND r2.is_delete = 0
WHERE r2.is_delete = 0
AND (
(t.show_bill_type = 'RK' AND r2.bill_no = t.show_bill_no)
OR (t.show_bill_type = 'CK' AND r2.bill_no_ck = t.show_bill_no)
)
)
</if>
</where>
GROUP BY t.bill_no
/* ✅ 关键:按 show_bill_no 分组(出库合并 CK在库保留 RK */
GROUP BY t.show_bill_no
) a
LEFT JOIN stock_in_type si ON a.rk_type = si.type_code
LEFT JOIN stock_out_type so ON a.ck_type = so.type_code
@@ -646,8 +688,10 @@
LEFT JOIN material_type mt ON a.wl_type = mt.type_code
LEFT JOIN sys_user ru ON a.lihuo_y = ru.user_id
ORDER BY a.rk_time DESC
</select>
<!-- ================== /按单据分组查询 ================== -->
<select id="selectRkInfoById" parameterType="Long" resultMap="RkInfoResult">
@@ -863,9 +907,12 @@
<trim prefix="SET" suffixOverrides=",">
<if test="rkType != null">rk_type = #{rkType},</if>
<if test="wlType != null">wl_type = #{wlType},</if>
<if test="warehouseCode != null and warehouseCode != ''">
cangku = #{warehouseCode},
<!-- ✅ 仓库字段统一使用 cangku -->
<if test="cangku != null and cangku != ''">
cangku = #{cangku},
</if>
<if test="rkTime != null">rk_time = #{rkTime},</if>
<if test="lihuoY != null">lihuo_y = #{lihuoY},</if>
<if test="isChuku != null">is_chuku = #{isChuku},</if>
@@ -1055,74 +1102,81 @@
<if test="parentWarehouseCode != null and parentWarehouseCode != ''">
AND wh.parent_warehouse_code = #{parentWarehouseCode}
</if>
<if test="startTime != null and startTime != ''">
<!-- Date 类型:只能判 null别再判 '' -->
<if test="startTime != null">
AND ri.rk_time <![CDATA[ >= ]]> #{startTime}
</if>
<if test="endTime != null and endTime != ''">
<if test="endTime != null">
AND ri.rk_time <![CDATA[ <= ]]> #{endTime}
</if>
<if test="statDate != null and statDate != ''">
<if test="statDate != null">
AND ri.return_time <![CDATA[ >= ]]> #{statDate}
</if>
<if test="endDate != null and endDate != ''">
<if test="endDate != null">
AND ri.return_time <![CDATA[ <= ]]> #{endDate}
</if>
<if test="rkType != null and rkType != ''">
AND ri.rk_type = #{rkType}
</if>
<if test="wlType != null and wlType != ''">
AND ri.wl_type = #{wlType}
</if>
<if test="lyStartTime != null and lyStartTime != ''">
<!-- Date 类型:只能判 null -->
<if test="lyStartTime != null">
AND ri.ly_time <![CDATA[ >= ]]> #{lyStartTime}
</if>
<if test="lyEndTime != null and lyEndTime != ''">
<if test="lyEndTime != null">
AND ri.ly_time <![CDATA[ <= ]]> #{lyEndTime}
</if>
<if test="xmNo != null and xmNo != ''">
AND ri.xm_no LIKE CONCAT('%', #{xmNo}, '%')
AND ri.xm_no LIKE CONCAT('%', #{xmNo}, '%')
</if>
<if test="xmMs != null and xmMs != ''">
AND ri.xm_ms LIKE CONCAT('%', #{xmMs}, '%')
AND ri.xm_ms LIKE CONCAT('%', #{xmMs}, '%')
</if>
<if test="wlNo != null and wlNo != ''">
AND ri.wl_no LIKE CONCAT('%', #{wlNo}, '%')
AND ri.wl_no LIKE CONCAT('%', #{wlNo}, '%')
</if>
<if test="wlMs != null and wlMs != ''">
AND ri.wl_ms LIKE CONCAT('%', #{wlMs}, '%')
AND ri.wl_ms LIKE CONCAT('%', #{wlMs}, '%')
</if>
<if test="gysNo != null and gysNo != ''">
AND ri.gys_no LIKE CONCAT('%', #{gysNo}, '%')
AND ri.gys_no LIKE CONCAT('%', #{gysNo}, '%')
</if>
<if test="gysMc != null and gysMc != ''">
AND ri.gys_mc LIKE CONCAT('%', #{gysMc}, '%')
AND ri.gys_mc LIKE CONCAT('%', #{gysMc}, '%')
</if>
<if test="sapNo != null and sapNo != ''">
AND ri.sap_no LIKE CONCAT('%', #{sapNo}, '%')
AND ri.sap_no LIKE CONCAT('%', #{sapNo}, '%')
</if>
<if test="billNo != null and billNo != ''">
AND ri.bill_no LIKE CONCAT('%', #{billNo}, '%')
AND ri.bill_no LIKE CONCAT('%', #{billNo}, '%')
</if>
<if test="billNoCk != null and billNoCk != ''">
AND ri.bill_no_ck LIKE CONCAT('%', #{billNoCk}, '%')
</if>
<if test="ckType != null and ckType != ''">
AND ri.ck_type LIKE CONCAT('%', #{ckType}, '%')
AND ri.ck_type LIKE CONCAT('%', #{ckType}, '%')
</if>
<if test="pcode != null and pcode != ''">
AND ri.pcode LIKE CONCAT('%', #{pcode}, '%')
AND ri.pcode LIKE CONCAT('%', #{pcode}, '%')
</if>
<if test="fycde1 != null and fycde1 != ''">
AND ri.fycde_1 LIKE CONCAT('%', #{fycde1}, '%')
AND ri.fycde_1 LIKE CONCAT('%', #{fycde1}, '%')
</if>
<if test="fycde2 != null and fycde2 != ''">
AND ri.fycde_2 LIKE CONCAT('%', #{fycde2}, '%')
AND ri.fycde_2 LIKE CONCAT('%', #{fycde2}, '%')
</if>
</where>
ORDER BY ri.create_time DESC, ri.id DESC
</select>
<select id="selectStatistics" resultType="java.lang.Long" parameterType="java.lang.Object" >
SELECT sum(ri.ht_dj * ri.real_qty)
FROM rk_info ri
@@ -1266,80 +1320,24 @@
</select>
<select id="selectDeliveryCkList"
resultType="com.zg.project.wisdom.domain.RkInfo">
parameterType="com.zg.project.wisdom.domain.RkInfo"
resultMap="RkInfoResult">
SELECT
id,
gys_jh_id AS gysJhId,
rk_type AS rkType,
wl_type AS wlType,
cangku,
rk_time AS rkTime,
borrow_time AS borrowTime,
return_time AS returnTime,
lihuo_y AS lihuoY,
is_chuku AS isChuku,
bill_no AS billNo,
bill_no_ck AS billNoCk,
is_delivery AS isDelivery,
remark,
xj,
xm_no AS xmNo,
xm_ms AS xmMs,
xm_no_ck AS xmNoCk,
xm_ms_ck AS xmMsCk,
wl_no AS wlNo,
wl_ms AS wlMs,
gys_no AS gysNo,
gys_mc AS gysMc,
jh_amt AS jhAmt,
ht_dj AS htDj,
sap_no AS sapNo,
xh,
jh_qty AS jhQty,
ht_qty AS htQty,
dw,
real_qty AS realQty,
pcode,
pcode_id AS pcodeId,
tray_code AS trayCode,
entity_id AS entityId,
ck_lihuo_y AS ckLihuoY,
ck_type AS ckType,
team_code AS teamCode,
ck_remark AS ckRemark,
ly_time AS lyTime,
has_moved AS hasMoved,
is_borrowed AS isBorrowed,
fycde_1 AS fycde1,
fycde_2 AS fycde2,
is_delete AS isDelete,
create_by AS createBy,
create_time AS createTime,
update_by AS updateBy,
update_time AS updateTime
FROM rk_info
WHERE is_delete = '0'
AND is_chuku = '1'
AND is_delivery = '1'
<include refid="selectRkInfoVo"/>
<if test="q.xj != null and q.xj != ''">
AND xj = #{q.xj}
</if>
<if test="q.xmNoCk != null and q.xmNoCk != ''">
AND xm_no_ck = #{q.xmNoCk}
</if>
<if test="q.teamCode != null and q.teamCode != ''">
AND team_code = #{q.teamCode}
</if>
<if test="q.lyStartTime != null">
AND ly_time &gt;= #{q.lyStartTime}
</if>
<if test="q.lyEndTime != null">
AND ly_time &lt;= #{q.lyEndTime}
</if>
<where>
AND ri.is_delete = 0
AND ri.is_delivery = '1'
ORDER BY bill_no_ck, ly_time, id
<if test="isChuku != null and isChuku != ''">
AND ri.is_chuku = #{isChuku}
</if>
<if test="billNoCk != null and billNoCk != ''">
AND ri.bill_no_ck LIKE concat('%', #{billNoCk}, '%')
</if>
</where>
ORDER BY ri.rk_time DESC
</select>
<!-- 根据入库单号查询单据头公共信息 -->
@@ -1378,6 +1376,13 @@
LIMIT 1
</select>
<select id="selectMaxBillNo" resultType="java.lang.String">
SELECT MAX(bill_no)
FROM rk_info
WHERE is_delete = 0
AND bill_no LIKE CONCAT(#{prefix}, '%')
</select>
<update id="updateBillInfo" parameterType="com.zg.project.wisdom.domain.RkInfo">
UPDATE rk_info
<set>