From b8de8918c118acd2100e83bd16c2e58cb9d99810 Mon Sep 17 00:00:00 2001 From: "han\\hanst" Date: Tue, 16 Dec 2025 14:35:05 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../warehouse/dao/InventoryStockMapper.java | 39 ++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/gaotao/modules/warehouse/dao/InventoryStockMapper.java b/src/main/java/com/gaotao/modules/warehouse/dao/InventoryStockMapper.java index e550169..c7784df 100644 --- a/src/main/java/com/gaotao/modules/warehouse/dao/InventoryStockMapper.java +++ b/src/main/java/com/gaotao/modules/warehouse/dao/InventoryStockMapper.java @@ -11,7 +11,44 @@ import java.math.BigDecimal; @Mapper public interface InventoryStockMapper extends BaseMapper { - @Select("SELECT * FROM inventory_stock WITH (UPDLOCK, ROWLOCK) WHERE site = #{site} AND warehouse_id = #{warehouseId} AND part_no = #{partNo} AND batch_no = #{batchNo} AND location_id = #{locationId} and wdr=#{wdr} and eng_chg_level=#{engChgLevel}") + /** + * 查询库存记录并加行锁(用于更新操作) + * + *

性能优化说明:

+ * + * + *

必需索引:

+ *
+     * CREATE NONCLUSTERED INDEX IDX_INVENTORY_STOCK_QUERY ON inventory_stock
+     * (site, warehouse_id, part_no, batch_no, location_id, wdr, eng_chg_level)
+     * INCLUDE (in_qty, out_qty, qty_on_hand, qty_reserved, in_standard_value, 
+     *          in_actual_value, out_standard_value, out_actual_value, 
+     *          handling_unit_qty, first_in_date, latest_in_date, latest_out_date, 
+     *          active_date, manufacture_date, expired_date, latest_count_date,
+     *          freeze_flag, qty_tmp, qty_to_issue, partner_id, partner_type, 
+     *          description, material, length, width, um_id);
+     * 
+ */ + @Select("SELECT site, warehouse_id, part_no, batch_no, location_id, wdr, eng_chg_level, " + + "in_qty, out_qty, qty_on_hand, qty_reserved, " + + "in_standard_value, in_actual_value, out_standard_value, out_actual_value, " + + "handling_unit_qty, first_in_date, latest_in_date, latest_out_date, active_date, " + + "manufacture_date, expired_date, latest_count_date, freeze_flag, " + + "qty_tmp, qty_to_issue, partner_id, partner_type, " + + "description, material, length, width, um_id " + + "FROM inventory_stock WITH (ROWLOCK, UPDLOCK) " + + "WHERE site = #{site} " + + "AND warehouse_id = #{warehouseId} " + + "AND part_no = #{partNo} " + + "AND batch_no = #{batchNo} " + + "AND location_id = #{locationId} " + + "AND wdr = #{wdr} " + + "AND eng_chg_level = #{engChgLevel}") InventoryStock selectForUpdate(@Param("site") String site, @Param("warehouseId") String warehouseId, @Param("partNo") String partNo,