功能重构开发
This commit is contained in:
@@ -311,4 +311,11 @@
|
||||
WHERE id = #{gysJhId}
|
||||
</update>
|
||||
|
||||
<update id="decreaseRealQtyById">
|
||||
UPDATE gys_jh
|
||||
SET real_qty = IFNULL(real_qty, 0) - #{rollbackQty}
|
||||
WHERE id = #{gysJhId}
|
||||
AND IFNULL(real_qty, 0) >= #{rollbackQty}
|
||||
</update>
|
||||
|
||||
</mapper>
|
||||
|
||||
@@ -5,20 +5,18 @@
|
||||
<mapper namespace="com.zg.project.wisdom.mapper.RkRecordMapper">
|
||||
|
||||
<!-- ===================== resultMap ===================== -->
|
||||
<resultMap type="RkRecord" id="RkRecordResult">
|
||||
<resultMap id="RkRecordResult" type="com.zg.project.wisdom.domain.RkRecord">
|
||||
<result property="id" column="id"/>
|
||||
|
||||
<!-- ✅ 新增:关联 rk_info 主键 -->
|
||||
<result property="rkInfoId" column="rk_info_id"/>
|
||||
|
||||
<result property="bizType" column="biz_type"/>
|
||||
<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"/>
|
||||
@@ -60,6 +58,7 @@
|
||||
<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="teamName" column="team_name"/>
|
||||
|
||||
@@ -85,52 +84,58 @@
|
||||
<result property="isDelete" column="is_delete"/>
|
||||
</resultMap>
|
||||
|
||||
<!-- ===================== 查询字段(连表补齐) ===================== -->
|
||||
<!-- ===================== 查询字段(统一视图) ===================== -->
|
||||
<sql id="selectRkRecordVo">
|
||||
SELECT
|
||||
rr.*,
|
||||
|
||||
/* 理货员姓名 */
|
||||
su.nick_name AS operator_name,
|
||||
|
||||
/* 物资类型名称 */
|
||||
mt.type_name AS wl_type_name,
|
||||
|
||||
/* 出入库类型名称:入库 / 出库 二选一 */
|
||||
COALESCE(sit.type_name, sot.type_name) AS operation_type_name,
|
||||
|
||||
/* 仓库信息:小仓/大仓 */
|
||||
wh.warehouse_name,
|
||||
wh.parent_warehouse_code,
|
||||
wh.parent_warehouse_name,
|
||||
-- 小仓
|
||||
wh.warehouse_name AS warehouse_name,
|
||||
|
||||
-- 大仓
|
||||
pwh.warehouse_code AS parent_warehouse_code,
|
||||
pwh.warehouse_name AS parent_warehouse_name,
|
||||
|
||||
ct.team_name AS team_name
|
||||
|
||||
FROM rk_record rr
|
||||
LEFT JOIN sys_user su
|
||||
ON rr.operator = su.user_id
|
||||
LEFT JOIN material_type mt
|
||||
ON rr.wl_type = mt.type_code
|
||||
LEFT JOIN stock_in_type sit
|
||||
ON rr.operation_type = sit.type_code
|
||||
LEFT JOIN stock_out_type sot
|
||||
ON rr.operation_type = sot.type_code
|
||||
LEFT JOIN warehouse_info wh
|
||||
ON rr.cangku = wh.warehouse_code
|
||||
LEFT JOIN sys_user su ON rr.operator = su.user_id
|
||||
LEFT JOIN material_type mt ON rr.wl_type = mt.type_code
|
||||
LEFT JOIN stock_in_type sit ON rr.operation_type = sit.type_code
|
||||
LEFT JOIN stock_out_type sot ON rr.operation_type = sot.type_code
|
||||
|
||||
-- 小仓
|
||||
LEFT JOIN warehouse_info wh ON rr.cangku = wh.warehouse_code
|
||||
|
||||
-- 大仓
|
||||
LEFT JOIN warehouse_info pwh ON wh.parent_warehouse_code = pwh.warehouse_code
|
||||
|
||||
LEFT JOIN construction_team ct
|
||||
ON rr.team_code = ct.team_code
|
||||
AND ct.is_delete = '0'
|
||||
</sql>
|
||||
|
||||
<!-- ===================== 查询列表 ===================== -->
|
||||
<select id="selectRkRecordList" parameterType="RkRecord" resultMap="RkRecordResult">
|
||||
<select id="selectRkRecordList"
|
||||
parameterType="RkRecord"
|
||||
resultMap="RkRecordResult">
|
||||
|
||||
<include refid="selectRkRecordVo"/>
|
||||
|
||||
<where>
|
||||
AND rr.exec_status = '1'
|
||||
|
||||
<if test="operationType != null and operationType != ''">
|
||||
AND rr.operation_type = #{operationType}
|
||||
</if>
|
||||
|
||||
<!-- 多 bizType -->
|
||||
<if test="bizTypeList != null and bizTypeList.size > 0">
|
||||
AND rb.biz_type IN
|
||||
AND rr.biz_type IN
|
||||
<foreach collection="bizTypeList"
|
||||
item="bt"
|
||||
open="("
|
||||
@@ -139,37 +144,48 @@
|
||||
#{bt}
|
||||
</foreach>
|
||||
</if>
|
||||
|
||||
<if test="bizType != null and bizType != ''">
|
||||
AND rr.biz_type = #{bizType}
|
||||
</if>
|
||||
|
||||
<if test="pcode != null and pcode != ''">
|
||||
AND rr.pcode = #{pcode}
|
||||
</if>
|
||||
|
||||
<if test="wlType != null and wlType != ''">
|
||||
AND rr.wl_type = #{wlType}
|
||||
</if>
|
||||
|
||||
<if test="cangku != null and cangku != ''">
|
||||
AND rr.cangku = #{cangku}
|
||||
</if>
|
||||
|
||||
<if test="operator != null and operator != ''">
|
||||
AND rr.operator = #{operator}
|
||||
</if>
|
||||
|
||||
<if test="isChuku != null and isChuku != ''">
|
||||
AND rr.is_chuku = #{isChuku}
|
||||
</if>
|
||||
|
||||
<if test="status != null and status != ''">
|
||||
AND rr.status = #{status}
|
||||
</if>
|
||||
|
||||
<if test="execStatus != null and execStatus != ''">
|
||||
AND rr.exec_status = #{execStatus}
|
||||
</if>
|
||||
|
||||
<if test="billNo != null and billNo != ''">
|
||||
AND rr.bill_no = #{billNo}
|
||||
</if>
|
||||
|
||||
<if test="isDelivery != null and isDelivery != ''">
|
||||
AND rr.is_delivery = #{isDelivery}
|
||||
</if>
|
||||
<!-- 项目号 -->
|
||||
|
||||
<!-- 项目 -->
|
||||
<if test="xmNo != null and xmNo != ''">
|
||||
AND rr.xm_no LIKE concat('%', #{xmNo}, '%')
|
||||
</if>
|
||||
@@ -177,50 +193,81 @@
|
||||
AND rr.xm_ms LIKE concat('%', #{xmMs}, '%')
|
||||
</if>
|
||||
|
||||
<!-- 订单编号 -->
|
||||
<!-- 订单 -->
|
||||
<if test="sapNo != null and sapNo != ''">
|
||||
AND rr.sap_no LIKE concat('%', #{sapNo}, '%')
|
||||
</if>
|
||||
|
||||
<!-- 供应商名称 -->
|
||||
<!-- 供应商 -->
|
||||
<if test="gysMc != null and gysMc != ''">
|
||||
AND rr.gys_mc LIKE concat('%', #{gysMc}, '%')
|
||||
</if>
|
||||
|
||||
<!-- 所属小仓(warehouseCode 实际就是 cangku) -->
|
||||
<if test="cangku != null and cangku != ''">
|
||||
AND rr.cangku = #{cangku}
|
||||
</if>
|
||||
<if test="wlNo != null and wlNo != ''">
|
||||
AND rr.wl_no LIKE concat('%', #{wlNo}, '%')
|
||||
</if>
|
||||
<!-- 物料描述 -->
|
||||
|
||||
<if test="wlMs != null and wlMs != ''">
|
||||
AND rr.wl_ms LIKE concat('%', #{wlMs}, '%')
|
||||
</if>
|
||||
|
||||
<!-- 是否借料 -->
|
||||
<if test="isBorrowed != null and isBorrowed != ''">
|
||||
AND rr.is_borrowed = #{isBorrowed}
|
||||
</if>
|
||||
<!-- 默认不查删除 -->
|
||||
|
||||
<!-- 删除标识 -->
|
||||
<if test="isDelete == null">
|
||||
AND (rr.is_delete = '0' OR rr.is_delete = 0 OR rr.is_delete IS NULL)
|
||||
</if>
|
||||
<!-- 如果前端明确传 isDelete,则按传入的精确过滤 -->
|
||||
<if test="isDelete != null and isDelete != ''">
|
||||
AND rr.is_delete = #{isDelete}
|
||||
</if>
|
||||
<!-- 出入库时间范围 -->
|
||||
<if test="startDate != null">
|
||||
AND rr.operation_time >= #{startDate}
|
||||
</if>
|
||||
<if test="endDate != null">
|
||||
AND rr.operation_time <= #{endDate}
|
||||
|
||||
<!-- ================= 时间条件(最终正确版) ================= -->
|
||||
<if test="startDate != null or endDate != null">
|
||||
AND (
|
||||
<!-- 普通入库 / 出库:精确到时分秒 -->
|
||||
(
|
||||
rr.biz_type IN ('0','1')
|
||||
<if test="startDate != null">
|
||||
AND rr.operation_time >= #{startDate}
|
||||
</if>
|
||||
<if test="endDate != null">
|
||||
AND rr.operation_time <= #{endDate}
|
||||
</if>
|
||||
)
|
||||
OR
|
||||
<!-- 借料出库:按 borrow_time(按天) -->
|
||||
(
|
||||
rr.biz_type = '2'
|
||||
<if test="startDate != null">
|
||||
AND rr.borrow_time >= DATE(#{startDate})
|
||||
</if>
|
||||
<if test="endDate != null">
|
||||
AND rr.borrow_time < DATE_ADD(DATE(#{endDate}), INTERVAL 1 DAY)
|
||||
</if>
|
||||
)
|
||||
OR
|
||||
<!-- 还料入库:按 return_time(按天) -->
|
||||
(
|
||||
rr.biz_type = '3'
|
||||
<if test="startDate != null">
|
||||
AND rr.return_time >= DATE(#{startDate})
|
||||
</if>
|
||||
<if test="endDate != null">
|
||||
AND rr.return_time < DATE_ADD(DATE(#{endDate}), INTERVAL 1 DAY)
|
||||
</if>
|
||||
)
|
||||
)
|
||||
</if>
|
||||
</where>
|
||||
ORDER BY rr.exec_status = '0' DESC, rr.operation_time DESC
|
||||
|
||||
ORDER BY rr.exec_status = '0' DESC,
|
||||
rr.operation_time DESC
|
||||
</select>
|
||||
|
||||
|
||||
<!-- ===================== 按 ID 查询 ===================== -->
|
||||
<select id="selectRkRecordById" parameterType="Long" resultMap="RkRecordResult">
|
||||
<include refid="selectRkRecordVo"/>
|
||||
@@ -626,9 +673,10 @@
|
||||
<update id="updateBorrowReturnRecordById">
|
||||
UPDATE rk_record
|
||||
SET
|
||||
biz_type = '3',
|
||||
is_borrowed = #{isBorrowed},
|
||||
return_time = #{returnTime},
|
||||
update_by = #{updateBy},
|
||||
update_by = #{updateBy},
|
||||
update_time = #{updateTime}
|
||||
WHERE id = #{id}
|
||||
AND is_delete = '0'
|
||||
|
||||
Reference in New Issue
Block a user