bug优化1209

This commit is contained in:
2025-12-09 15:54:39 +08:00
parent 2c21c1560e
commit b7434d71df
11 changed files with 117 additions and 38 deletions

View File

@@ -62,7 +62,7 @@
<result property="isDelivery" column="is_delivery"/>
</resultMap>
<!-- 明细查询SQL包含多表JOIN用于普通明细/分页等) -->
<!-- 明细查询SQL包含多表JOIN用于普通明<EFBFBD>?分页等) -->
<sql id="selectRkInfoVo">
SELECT
ri.id,
@@ -203,6 +203,7 @@
<select id="selectRkInfoList" parameterType="RkInfo" resultMap="RkInfoResult">
<include refid="selectRkInfoVo"/>
<where>
<!-- is_chuku 多状态 / 单状态 -->
<choose>
<when test="isChukuList != null and isChukuList.size > 0">
AND ri.is_chuku IN
@@ -215,6 +216,7 @@
</when>
</choose>
<!-- 关键字搜索 -->
<if test="keyword != null and keyword != ''">
AND (
ri.xm_no like concat('%', #{keyword}, '%')
@@ -248,6 +250,7 @@
<if test="fycde2 != null and fycde2 != ''">
AND ri.fycde_2 like concat('%', #{fycde2}, '%')
</if>
<if test="ids != null and ids.size > 0">
AND ri.id IN
<foreach collection="ids" item="id" open="(" separator="," close=")">
@@ -255,13 +258,55 @@
</foreach>
</if>
<if test="startTime != null">
<![CDATA[ AND ri.rk_time >= #{startTime} ]]>
</if>
<if test="endTime != null">
<![CDATA[ AND ri.rk_time <= #{endTime} ]]>
<!-- ★★ 先按是否借料过滤行0 否1 借料中2 已归还 ★★ -->
<if test="isBorrowed != null and isBorrowed != ''">
AND ri.is_borrowed = #{isBorrowed}
</if>
<!-- ★★ 时间范围逻辑 ★★ -->
<!-- 1普通库存isBorrowed 为空):按入库时间 rk_time -->
<if test="(isBorrowed == null or isBorrowed == '')">
<if test="startTime != null">
<![CDATA[
AND ri.rk_time >= #{startTime}
]]>
</if>
<if test="endTime != null">
<![CDATA[
AND ri.rk_time < DATE_ADD(#{endTime}, INTERVAL 1 DAY)
]]>
</if>
</if>
<!-- 2借料中按借用时间 borrow_time -->
<if test="isBorrowed == '1'">
<if test="startTime != null">
<![CDATA[
AND ri.borrow_time >= #{startTime}
]]>
</if>
<if test="endTime != null">
<![CDATA[
AND ri.borrow_time < DATE_ADD(#{endTime}, INTERVAL 1 DAY)
]]>
</if>
</if>
<!-- 3已归还按归还时间 return_time -->
<if test="isBorrowed == '2'">
<if test="startTime != null">
<![CDATA[
AND ri.return_time >= #{startTime}
]]>
</if>
<if test="endTime != null">
<![CDATA[
AND ri.return_time < DATE_ADD(#{endTime}, INTERVAL 1 DAY)
]]>
</if>
</if>
<!-- 领用时间范围(原有逻辑,保留) -->
<if test="lyStartTime != null">
<![CDATA[ AND ri.ly_time >= #{lyStartTime} ]]>
</if>
@@ -354,11 +399,11 @@
</otherwise>
</choose>
</where>
ORDER BY ri.rk_time DESC
</select>
<!-- ================== 这里是已优化的按单据分组查询(替换旧版本) ================== -->
<!-- ================== 这里是已优化的按单据分组查询替换旧版本<E78988>?================== -->
<select id="selectGroupedByBill" resultMap="RkInfoResult" parameterType="map">
SELECT
a.id,
@@ -508,12 +553,13 @@
<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 非空 -->
<!-- 出库才要<EFBFBD>?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
@@ -543,7 +589,7 @@
ORDER BY a.rk_time DESC
</select>
<!-- ================== /按单据分组查================== -->
<!-- ================== /按单据分组查<EFBFBD>?================== -->
<select id="selectRkInfoById" parameterType="Long" resultMap="RkInfoResult">
<include refid="selectRkInfoVo"/>
@@ -590,7 +636,7 @@
WHERE bill_no = #{billNo} AND sap_no IS NOT NULL
</select>
<!-- 正常数据:扫描到的库位(限定场景 -->
<!-- 正常数据:扫描到的库位(限定场景<EFBFBD>?-->
<select id="getByPcodeIdList" parameterType="map" resultMap="RkInfoResult">
SELECT
ri.id, ri.rk_type, ri.wl_type, ri.cangku, ri.rk_time, ri.lihuo_y,
@@ -613,7 +659,7 @@
</foreach>
</select>
<!-- 未扫描到的数据(限定场景 -->
<!-- 未扫描到的数据(限定场景<EFBFBD>?-->
<select id="getMissedPcodeIds" parameterType="map" resultMap="RkInfoResult">
SELECT
ri.id, ri.rk_type, ri.wl_type, ri.cangku, ri.rk_time, ri.lihuo_y,
@@ -918,7 +964,6 @@
ORDER BY t.rk_time DESC, t.id DESC
</select>
<!-- 分页查询 rk_info 全量明细(支持 keyword 模糊过滤) -->
<select id="selectAllRkInfo"
parameterType="com.zg.project.wisdom.domain.RkInfo"
resultMap="RkInfoResult">
@@ -940,7 +985,18 @@
<if test="endTime != null">
AND ri.rk_time <![CDATA[ <= ]]> #{endTime}
</if>
<if test="statDate != null">
AND ri.return_time <![CDATA[ >= ]]> #{statDate}
</if>
<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 ri.ly_time <![CDATA[ >= ]]> #{lyStartTime}
</if>
@@ -992,7 +1048,7 @@
</select>
<select id="selectStatistics" resultType="java.lang.Long" parameterType="java.lang.Object" >
SELECT sum(ri.ht_dj*ri.real_qty)
SELECT sum(ri.ht_dj * ri.real_qty)
FROM rk_info ri
<where>
(ri.is_delete = '0' OR ri.is_delete = 0 OR ri.is_delete IS NULL)
@@ -1004,7 +1060,9 @@
<if test="cangku != null and cangku != ''">
AND ri.cangku = #{cangku}
</if>
<if test="rkType != null and rkType != ''">
AND ri.rk_type = #{rkType}
</if>
<if test="startTime != null">
AND ri.rk_time <![CDATA[ >= ]]> #{startTime}
</if>