仓库信息字段更新1212

This commit is contained in:
2025-12-12 14:52:48 +08:00
parent b7434d71df
commit 8e0d7b463a
67 changed files with 1533 additions and 681 deletions

View File

@@ -18,6 +18,13 @@
<result property="rkTypeName" column="rk_type_name"/>
<result property="wlTypeName" column="wl_type_name"/>
<result property="cangkuName" column="cangku_name"/>
<!-- 新增:大仓/小仓编码和名称 -->
<result property="parentWarehouseCode" column="parent_warehouse_code"/>
<result property="parentWarehouseName" column="parent_warehouse_name"/>
<result property="warehouseCode" column="warehouse_code"/>
<result property="warehouseName" column="warehouse_name"/>
<result property="remark" column="remark" />
<result property="xj" column="xj" />
<result property="xmNo" column="xm_no" />
@@ -62,7 +69,7 @@
<result property="isDelivery" column="is_delivery"/>
</resultMap>
<!-- 明细查询SQL包含多表JOIN用于普通明<EFBFBD>?分页等) -->
<!-- 明细查询SQL包含多表JOIN用于普通明分页等) -->
<sql id="selectRkInfoVo">
SELECT
ri.id,
@@ -70,7 +77,16 @@
ri.bill_no_ck,
ri.rk_type, st.type_name AS rk_type_name,
ri.wl_type, mt.type_name AS wl_type_name,
ri.cangku, wh.warehouse_name AS cangku_name,
ri.cangku,
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,
ri.rk_time, ri.lihuo_y, ri.is_chuku, ri.is_borrowed, ri.is_delivery,ri.remark,
ri.ck_lihuo_y, ri.ck_type, sot.type_name AS ck_type_name,
ri.team_code, ct.team_name,
@@ -148,7 +164,8 @@
#{item.xmNoCk}, #{item.xmMsCk}, #{item.xj}, #{item.sapNo}, #{item.gysNo}, #{item.gysMc},
#{item.jhQty}, #{item.htQty}, #{item.jhAmt}, #{item.htDj}, #{item.dw},
#{item.borrowTime}, #{item.returnTime}, #{item.status},
#{item.pcode}, #{item.pcodeId}, #{item.trayCode}, #{item.realQty}, #{item.entityId}, #{item.fycde1}, #{item.fycde2},
#{item.pcode}, #{item.pcodeId}, #{item.trayCode}, #{item.realQty}, #{item.entityId},
#{item.fycde1}, #{item.fycde2},
#{item.remark}, #{item.isChuku}, #{item.isBorrowed}, #{item.gysJhId},
#{item.isDelete}, #{item.createBy}, #{item.createTime}
)
@@ -219,36 +236,36 @@
<!-- 关键字搜索 -->
<if test="keyword != null and keyword != ''">
AND (
ri.xm_no like concat('%', #{keyword}, '%')
or ri.xm_ms like concat('%', #{keyword}, '%')
or ri.fycde_1 like concat('%', #{keyword}, '%')
or ri.fycde_2 like concat('%', #{keyword}, '%')
or ri.wl_no like concat('%', #{keyword}, '%')
or ri.wl_ms like concat('%', #{keyword}, '%')
or ri.gys_no like concat('%', #{keyword}, '%')
or ri.gys_mc like concat('%', #{keyword}, '%')
or ri.sap_no like concat('%', #{keyword}, '%')
or ri.bill_no like concat('%', #{keyword}, '%')
or ri.bill_no_ck like concat('%', #{keyword}, '%')
or ri.ck_type like concat('%', #{keyword}, '%')
or ri.pcode like concat('%', #{keyword}, '%')
ri.xm_no LIKE concat('%', #{keyword}, '%')
OR ri.xm_ms LIKE concat('%', #{keyword}, '%')
OR ri.fycde_1 LIKE concat('%', #{keyword}, '%')
OR ri.fycde_2 LIKE concat('%', #{keyword}, '%')
OR ri.wl_no LIKE concat('%', #{keyword}, '%')
OR ri.wl_ms LIKE concat('%', #{keyword}, '%')
OR ri.gys_no LIKE concat('%', #{keyword}, '%')
OR ri.gys_mc LIKE concat('%', #{keyword}, '%')
OR ri.sap_no LIKE concat('%', #{keyword}, '%')
OR ri.bill_no LIKE concat('%', #{keyword}, '%')
OR ri.bill_no_ck LIKE concat('%', #{keyword}, '%')
OR ri.ck_type LIKE concat('%', #{keyword}, '%')
OR ri.pcode LIKE concat('%', #{keyword}, '%')
)
</if>
<if test="rkType != null and rkType != ''">
AND ri.rk_type like concat('%', #{rkType}, '%')
AND ri.rk_type LIKE concat('%', #{rkType}, '%')
</if>
<if test="wlType != null and wlType != ''">
AND ri.wl_type like concat('%', #{wlType}, '%')
AND ri.wl_type LIKE concat('%', #{wlType}, '%')
</if>
<if test="cangku != null and cangku != ''">
AND ri.cangku like concat('%', #{cangku}, '%')
AND ri.cangku LIKE concat('%', #{cangku}, '%')
</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>
<if test="ids != null and ids.size > 0">
@@ -258,55 +275,17 @@
</foreach>
</if>
<!-- ★★ 先按是否借料过滤行0 否1 借料中2 已归还 ★★ -->
<if test="isBorrowed != null and isBorrowed != ''">
AND ri.is_borrowed = #{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>
<!-- ★★ 时间范围逻辑 ★★ -->
<!-- 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>
@@ -315,34 +294,34 @@
</if>
<if test="lihuoY != null and lihuoY != ''">
AND ri.lihuo_y like concat('%', #{lihuoY}, '%')
AND ri.lihuo_y LIKE concat('%', #{lihuoY}, '%')
</if>
<if test="xj != null and xj != ''">
AND ri.xj like concat('%', #{xj}, '%')
AND ri.xj LIKE concat('%', #{xj}, '%')
</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}, '%')
AND ri.bill_no_ck LIKE concat('%', #{billNoCk}, '%')
</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="jhAmt != null">
@@ -353,10 +332,10 @@
</if>
<if test="sapNo != null and sapNo != ''">
AND ri.sap_no like concat('%', #{sapNo}, '%')
AND ri.sap_no LIKE concat('%', #{sapNo}, '%')
</if>
<if test="xh != null and xh != ''">
AND ri.xh like concat('%', #{xh}, '%')
AND ri.xh LIKE concat('%', #{xh}, '%')
</if>
<if test="jhQty != null">
AND ri.jh_qty = #{jhQty}
@@ -365,14 +344,14 @@
AND ri.ht_qty = #{htQty}
</if>
<if test="dw != null and dw != ''">
AND ri.dw like concat('%', #{dw}, '%')
AND ri.dw LIKE concat('%', #{dw}, '%')
</if>
<if test="realQty != null">
AND ri.real_qty = #{realQty}
</if>
<if test="pcode != null and pcode != ''">
AND ri.pcode like concat('%', #{pcode}, '%')
AND ri.pcode LIKE concat('%', #{pcode}, '%')
</if>
<if test="lyTime != null">
AND ri.ly_time = #{lyTime}
@@ -381,13 +360,13 @@
AND ri.return_time = #{returnTime}
</if>
<if test="trayCode != null and trayCode != ''">
AND ri.tray_code like concat('%', #{trayCode}, '%')
AND ri.tray_code LIKE concat('%', #{trayCode}, '%')
</if>
<if test="entityId != null and entityId != ''">
AND ri.entity_id like concat('%', #{entityId}, '%')
AND ri.entity_id LIKE concat('%', #{entityId}, '%')
</if>
<if test="ckType != null and ckType != ''">
AND ri.ck_type like concat('%', #{ckType}, '%')
AND ri.ck_type LIKE concat('%', #{ckType}, '%')
</if>
<choose>
@@ -402,8 +381,88 @@
ORDER BY ri.rk_time DESC
</select>
<select id="selectBorrowAndReturnList"
parameterType="RkInfo"
resultMap="RkInfoResult">
<include refid="selectRkInfoVo"/>
<where>
<!-- 只查未删除 -->
<choose>
<when test="isDelete != null and isDelete != ''">
AND ri.is_delete = #{isDelete}
</when>
<otherwise>
AND ri.is_delete = 0
</otherwise>
</choose>
<!-- 借料/还料状态0 否1 借料中2 已归还 -->
<choose>
<when test="isBorrowed != null and isBorrowed != ''">
AND ri.is_borrowed = #{isBorrowed}
</when>
<otherwise>
AND ri.is_borrowed IN ('1','2')
</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>
</where>
ORDER BY ri.borrow_time DESC, ri.return_time DESC, ri.id DESC
</select>
<!-- ================== 这里是已优化的按单据分组查询替换旧版本<E78988>?================== -->
<select id="selectGroupedByBill" resultMap="RkInfoResult" parameterType="map">
SELECT
a.id,
@@ -559,7 +618,7 @@
AND t.is_delivery = #{q.isDelivery}
</if>
<!-- 出库才要<EFBFBD>?bill_no_ck 非空 -->
<!-- 出库才要 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
@@ -589,7 +648,7 @@
ORDER BY a.rk_time DESC
</select>
<!-- ================== /按单据分组查<EFBFBD>?================== -->
<!-- ================== /按单据分组查================== -->
<select id="selectRkInfoById" parameterType="Long" resultMap="RkInfoResult">
<include refid="selectRkInfoVo"/>
@@ -636,7 +695,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,
@@ -659,7 +718,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,
@@ -704,7 +763,7 @@
</select>
<select id="getUnscannedPcodeByScene"
resultType="com.zg.project.Inventory.domain.vo.RkInfoMatchVO">
resultType="com.zg.project.inventory.domain.vo.RkInfoMatchVO">
SELECT
r.pcode AS rkPcode,
COALESCE(SUM(r.real_qty), 0) AS realQty
@@ -724,7 +783,7 @@
ORDER BY MAX(r.create_time) DESC
</select>
<select id="selectPcdeCntFromRkInfo" resultType="com.zg.project.Inventory.domain.vo.PcdeCntVO">
<select id="selectPcdeCntFromRkInfo" resultType="com.zg.project.inventory.domain.vo.PcdeCntVO">
SELECT pcode AS pcde,
COUNT(*) AS cnt
FROM rk_info
@@ -738,18 +797,25 @@
<select id="selectOneForEachBillNo" parameterType="java.util.List" resultType="com.zg.project.wisdom.domain.RkInfo">
SELECT
COALESCE(r.bill_no_ck, r.bill_no) AS billNo,
MAX(r.lihuo_y) AS lihuoY,
MAX(u.user_name) AS lihuoYName,
MAX(rkType.type_name) AS rkTypeName,
MAX(cangku.warehouse_name) AS cangkuName,
MAX(wlType.type_name) AS wlTypeName,
MAX(ckType.type_name) AS ckTypeName,
MAX(team.team_name) AS teamName
MAX(r.lihuo_y) AS lihuoY,
MAX(u.user_name) AS lihuoYName,
MAX(rkType.type_name) AS rkTypeName,
MAX(cangku.warehouse_name) AS cangkuName,
-- 新增:大仓/小仓编码和名称
MAX(cangku.parent_warehouse_code) AS parentWarehouseCode,
MAX(cangku.parent_warehouse_name) AS parentWarehouseName,
MAX(cangku.warehouse_code) AS warehouseCode,
MAX(cangku.warehouse_name) AS warehouseName,
MAX(wlType.type_name) AS wlTypeName,
MAX(ckType.type_name) AS ckTypeName,
MAX(team.team_name) AS teamName
FROM rk_info r
LEFT JOIN stock_in_type rkType ON r.rk_type = rkType.type_code
LEFT JOIN stock_in_type rkType ON r.rk_type = rkType.type_code
LEFT JOIN stock_out_type ckType ON r.ck_type = ckType.type_code
LEFT JOIN warehouse_info cangku ON r.cangku = cangku.warehouse_code
LEFT JOIN material_type wlType ON r.wl_type = wlType.type_code
LEFT JOIN warehouse_info cangku ON r.cangku = cangku.warehouse_code
LEFT JOIN material_type wlType ON r.wl_type = wlType.type_code
LEFT JOIN construction_team team ON r.team_code = team.team_code
LEFT JOIN sys_user u ON r.lihuo_y = u.user_id
WHERE r.is_delete = '0'
@@ -797,7 +863,9 @@
<trim prefix="SET" suffixOverrides=",">
<if test="rkType != null">rk_type = #{rkType},</if>
<if test="wlType != null">wl_type = #{wlType},</if>
<if test="cangku != null">cangku = #{cangku},</if>
<if test="warehouseCode != null and warehouseCode != ''">
cangku = #{warehouseCode},
</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>
@@ -954,7 +1022,13 @@
resultMap="RkInfoResult">
SELECT
t.*,
wh.warehouse_name AS cangku_name
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
@@ -975,20 +1049,20 @@
AND ri.is_chuku = #{isChuku}
</if>
<if test="cangku != null and cangku != ''">
AND ri.cangku = #{cangku}
<if test="warehouseCode != null and warehouseCode != ''">
AND ri.cangku = #{warehouseCode}
</if>
<if test="startTime != null">
<if test="startTime != null and startTime != ''">
AND ri.rk_time <![CDATA[ >= ]]> #{startTime}
</if>
<if test="endTime != null">
<if test="endTime != null and endTime != ''">
AND ri.rk_time <![CDATA[ <= ]]> #{endTime}
</if>
<if test="statDate != null">
<if test="statDate != null and statDate != ''">
AND ri.return_time <![CDATA[ >= ]]> #{statDate}
</if>
<if test="endDate != null">
<if test="endDate != null and endDate != ''">
AND ri.return_time <![CDATA[ <= ]]> #{endDate}
</if>
<if test="rkType != null and rkType != ''">
@@ -997,10 +1071,10 @@
<if test="wlType != null and wlType != ''">
AND ri.wl_type = #{wlType}
</if>
<if test="lyStartTime != null">
<if test="lyStartTime != null and lyStartTime != ''">
AND ri.ly_time <![CDATA[ >= ]]> #{lyStartTime}
</if>
<if test="lyEndTime != null">
<if test="lyEndTime != null and lyEndTime != ''">
AND ri.ly_time <![CDATA[ <= ]]> #{lyEndTime}
</if>
@@ -1070,10 +1144,10 @@
AND ri.rk_time <![CDATA[ <= ]]> #{endTime}
</if>
<if test="lyStartTime != null">
<if test="lyStartTime != null and lyStartTime != ''">
AND ri.ly_time <![CDATA[ >= ]]> #{lyStartTime}
</if>
<if test="lyEndTime != null">
<if test="lyEndTime != null and lyEndTime != ''">
AND ri.ly_time <![CDATA[ <= ]]> #{lyEndTime}
</if>
@@ -1140,10 +1214,10 @@
AND ri.rk_time <![CDATA[ <= ]]> #{endTime}
</if>
<if test="lyStartTime != null">
<if test="lyStartTime != null and lyStartTime != ''">
AND ri.ly_time <![CDATA[ >= ]]> #{lyStartTime}
</if>
<if test="lyEndTime != null">
<if test="lyEndTime != null and lyEndTime != ''">
AND ri.ly_time <![CDATA[ <= ]]> #{lyEndTime}
</if>
@@ -1247,7 +1321,6 @@
AND is_chuku = '1'
AND is_delivery = '1'
<!-- 可选过滤:比如你以后想限定县局、项目等 -->
<if test="q.xj != null and q.xj != ''">
AND xj = #{q.xj}
</if>
@@ -1267,13 +1340,59 @@
ORDER BY bill_no_ck, ly_time, id
</select>
<!-- 根据入库单号查询单据头公共信息 -->
<select id="selectHeaderByBillNo"
parameterType="java.lang.String"
resultMap="RkInfoResult">
SELECT
ri.id,
ri.bill_no,
ri.bill_no_ck,
ri.is_chuku,
ri.rk_type,
st.type_name AS rk_type_name,
ri.wl_type,
mt.type_name AS wl_type_name,
ri.rk_time,
ri.ly_time,
ri.lihuo_y,
u.user_name AS lihuo_y_name,
ri.cangku,
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 ri
LEFT JOIN stock_in_type st ON ri.rk_type = st.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 u ON ri.lihuo_y = u.user_id
WHERE ri.is_delete = '0'
AND ri.bill_no = #{billNo}
ORDER BY ri.rk_time ASC, ri.id ASC
LIMIT 1
</select>
<update id="updateBillInfo" parameterType="com.zg.project.wisdom.domain.RkInfo">
UPDATE rk_info
<set>
<if test="rkType != null">rk_type = #{rkType},</if>
<if test="wlType != null">wl_type = #{wlType},</if>
<if test="cangku != null">cangku = #{cangku},</if>
<if test="rkTime != null">rk_time = #{rkTime},</if>
<if test="rkType != null">
rk_type = #{rkType},
</if>
<if test="wlType != null">
wl_type = #{wlType},
</if>
<if test="warehouseCode != null and warehouseCode != ''">
cangku = #{warehouseCode},
</if>
<if test="rkTime != null">
rk_time = #{rkTime},
</if>
</set>
WHERE bill_no = #{billNo}
</update>