From cdf2005b0dcb458b747958ebe808931914815541 Mon Sep 17 00:00:00 2001
From: liyong <18434998025@163.com>
Date: 星期二, 27 一月 2026 16:41:16 +0800
Subject: [PATCH] fix(enum): 代码迁移
---
src/main/resources/mapper/stock/StockInventoryMapper.xml | 163 +++++++++++++++++++++++++++++++++++++++++++++++++-----
1 files changed, 147 insertions(+), 16 deletions(-)
diff --git a/src/main/resources/mapper/stock/StockInventoryMapper.xml b/src/main/resources/mapper/stock/StockInventoryMapper.xml
index 705eea3..224eb5a 100644
--- a/src/main/resources/mapper/stock/StockInventoryMapper.xml
+++ b/src/main/resources/mapper/stock/StockInventoryMapper.xml
@@ -4,14 +4,14 @@
<!-- 閫氱敤鏌ヨ鏄犲皠缁撴灉 -->
<resultMap id="BaseResultMap" type="com.ruoyi.stock.pojo.StockInventory">
- <result column="id" property="id" />
- <result column="product_model_id" property="productModelId" />
- <result column="qualitity" property="qualitity" />
- <result column="create_time" property="createTime" />
- <result column="update_time" property="updateTime" />
- <result column="version" property="version" />
- <result column="locked_quantity" property="lockedQuantity" />
- <result column="warn_num" property="warnNum" />
+ <result column="id" property="id"/>
+ <result column="product_model_id" property="productModelId"/>
+ <result column="qualitity" property="qualitity"/>
+ <result column="create_time" property="createTime"/>
+ <result column="update_time" property="updateTime"/>
+ <result column="version" property="version"/>
+ <result column="locked_quantity" property="lockedQuantity"/>
+ <result column="warn_num" property="warnNum"/>
</resultMap>
<update id="updateAddStockInventory">
update stock_inventory
@@ -19,8 +19,17 @@
<if test="ew.qualitity != null">
qualitity = qualitity + #{ew.qualitity},
</if>
- <if test="ew.version != null">
- version = version + 1,
+ <if test="ew.version != null">
+ version = version + 1,
+ </if>
+ <if test="ew.remark != null and ew.remark !=''">
+ remark = #{ew.remark},
+ </if>
+ <if test="ew.warnNum != null and ew.warnNum !=''">
+ warn_num = #{ew.warnNum},
+ </if>
+ <if test="ew.lockedQuantity != null and ew.lockedQuantity !=''">
+ locked_quantity = locked_quantity + #{ew.lockedQuantity},
</if>
update_time = now()
</set>
@@ -35,22 +44,144 @@
<if test="ew.version != null">
version = version + 1,
</if>
+ <if test="ew.remark != null and ew.remark !=''">
+ remark = #{ew.remark},
+ </if>
update_time = now()
</set>
where product_model_id = #{ew.productModelId} and qualitity >= #{ew.qualitity}
</update>
<select id="pagestockInventory" resultType="com.ruoyi.stock.dto.StockInventoryDto">
- select si.*,
- pm.model,
- pm.unit,
- p.product_name
+ select si.id,
+ si.qualitity,
+ COALESCE(si.locked_quantity, 0) as locked_quantity,
+ si.product_model_id,
+ si.create_time,
+ si.update_time,
+ COALESCE(si.warn_num, 0) as warn_num,
+ si.version,
+ (si.qualitity - COALESCE(si.locked_quantity, 0)) as un_locked_quantity,
+ pm.model,
+ pm.unit,
+ p.product_name
from stock_inventory si
- left join product_model pm on si.product_model_id = pm.id
- left join product p on pm.product_id = p.id
+ left join product_model pm on si.product_model_id = pm.id
+ left join product p on pm.product_id = p.id
where 1 = 1
<if test="ew.productName != null and ew.productName !=''">
and p.product_name like concat('%',#{ew.productName},'%')
</if>
</select>
+ <select id="listStockInventoryExportData" resultType="com.ruoyi.stock.execl.StockInventoryExportData">
+ select si.qualitity,
+ pm.model,
+ pm.unit,
+ p.product_name,
+ si.warn_num,
+ si.locked_quantity,
+ si.remark,
+ si.update_time
+ from stock_inventory si
+ left join product_model pm on si.product_model_id = pm.id
+ left join product p on pm.product_id = p.id
+ where 1 = 1
+ <if test="ew.productName != null and ew.productName !=''">
+ and p.product_name like concat('%',#{ew.productName},'%')
+ </if>
+ </select>
+ <select id="stockInventoryPage" resultType="com.ruoyi.stock.dto.StockInRecordDto">
+ select sir.*,si.qualitity,
+ pm.model,
+ pm.unit,
+ p.product_name
+ from
+ stock_in_record sir
+ left join stock_inventory si on sir.product_model_id = si.product_model_id
+ left join product_model pm on sir.product_model_id = pm.id
+ left join product p on pm.product_id = p.id
+ <where>
+ <if test="ew.reportDate != null">
+ and sir.create_time >= #{ew.reportDate}
+ and sir.create_time < DATE_ADD(#{ew.reportDate}, INTERVAL 1 DAY)
+ </if>
+ <if test="ew.startMonth != null">
+ and sir.create_time >= #{ew.startMonth}
+ </if>
+ <if test="ew.endMonth != null">
+ and sir.create_time <= #{ew.endMonth}
+ </if>
+ </where>
+ </select>
+
+ <select id="stockInAndOutRecord" resultType="com.ruoyi.stock.dto.StockInventoryDto">
+ SELECT
+ pm.model,
+ pm.unit,
+ p.product_name,
+ MAX(current_inventory) as current_stock,
+ SUM(CASE WHEN record_type = 'in' THEN amount ELSE 0 END) as total_stock_in,
+ SUM(CASE WHEN record_type = 'out' THEN amount ELSE 0 END) as total_stock_out
+ FROM (
+ SELECT
+ product_model_id,
+ SUM(qualitity) as current_inventory,
+ 0 as amount,
+ '' as record_type
+ FROM stock_inventory
+ GROUP BY product_model_id
+
+ UNION ALL
+
+ SELECT
+ product_model_id,
+ 0 as current_inventory,
+ SUM(stock_in_num) as amount,
+ 'in' as record_type
+ FROM stock_in_record
+ <where>
+ type = 0
+ <if test="ew.startMonth != null">
+ and stock_in_record.create_time >= #{ew.startMonth}
+ </if>
+ <if test="ew.endMonth != null">
+ and stock_in_record.create_time <= #{ew.endMonth}
+ </if>
+ </where>
+ GROUP BY product_model_id
+
+ UNION ALL
+
+ SELECT
+ product_model_id,
+ 0 as current_inventory,
+ SUM(stock_out_num) as amount,
+ 'out' as record_type
+ FROM stock_out_record
+ <where>
+ type = 0
+ <if test="ew.startMonth != null">
+ and stock_out_record.create_time >= #{ew.startMonth}
+ </if>
+ <if test="ew.endMonth != null">
+ and stock_out_record.create_time <= #{ew.endMonth}
+ </if>
+ </where>
+ GROUP BY product_model_id
+ ) combined_data
+ LEFT JOIN product_model pm ON pm.id = combined_data.product_model_id
+ LEFT JOIN product p ON p.id = pm.product_id
+ <where>
+ <if test="ew.productName != null and ew.productName !=''">
+ and p.product_name like concat('%',#{ew.productName},'%')
+ </if>
+ <if test="ew.model != null and ew.model !=''">
+ and pm.model like concat('%',#{ew.model},'%')
+ </if>
+ </where>
+ GROUP BY
+ pm.model,
+ pm.unit,
+ p.product_name
+ </select>
</mapper>
--
Gitblit v1.9.3