From 1f15dd43b334e31189c4580b98f57d2cc71935d8 Mon Sep 17 00:00:00 2001
From: wanshenmean <cathay_xy@163.com>
Date: 星期一, 30 三月 2026 14:11:23 +0800
Subject: [PATCH] refactor(StockInfo): 重构 Get3DLayoutAsync 使用依赖注入服务

---
 Code/WMS/WIDESEA_WMSServer/WIDESEA_StockService/StockInfoService.cs                   |   21 +++++++++++++++++----
 Code/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/Controllers/Stock/StockInfoController.cs |    2 +-
 2 files changed, 18 insertions(+), 5 deletions(-)

diff --git a/Code/WMS/WIDESEA_WMSServer/WIDESEA_StockService/StockInfoService.cs b/Code/WMS/WIDESEA_WMSServer/WIDESEA_StockService/StockInfoService.cs
index 842fc27..d992bdf 100644
--- a/Code/WMS/WIDESEA_WMSServer/WIDESEA_StockService/StockInfoService.cs
+++ b/Code/WMS/WIDESEA_WMSServer/WIDESEA_StockService/StockInfoService.cs
@@ -2,6 +2,7 @@
 using WIDESEA_Core.BaseRepository;
 using WIDESEA_Core.BaseServices;
 using WIDESEA_DTO.Stock;
+using WIDESEA_IBasicService;
 using WIDESEA_IStockService;
 using WIDESEA_Model.Models;
 
@@ -18,11 +19,23 @@
         public IRepository<Dt_StockInfo> Repository => BaseDal;
 
         /// <summary>
+        /// 璐т綅淇℃伅鏈嶅姟鎺ュ彛锛堢敤浜庤幏鍙栦粨搴撹揣浣嶄俊鎭級
+        /// </summary>
+        private readonly ILocationInfoService _locationInfoService;
+
+        /// <summary>
+        /// 浠撳簱淇℃伅鏈嶅姟鎺ュ彛锛堢敤浜庤幏鍙栦粨搴撳熀鏈俊鎭級
+        /// </summary>
+        private readonly IWarehouseService _warehouseService;
+
+        /// <summary>
         /// 鏋勯�犲嚱鏁�
         /// </summary>
         /// <param name="baseDal">鍩虹鏁版嵁璁块棶瀵硅薄</param>
-        public StockInfoService(IRepository<Dt_StockInfo> baseDal) : base(baseDal)
+        public StockInfoService(IRepository<Dt_StockInfo> baseDal, ILocationInfoService locationInfoService, IWarehouseService warehouseService) : base(baseDal)
         {
+            _locationInfoService = locationInfoService;
+            _warehouseService = warehouseService;
         }
 
         /// <summary>
@@ -88,13 +101,13 @@
         public async Task<Stock3DLayoutDTO> Get3DLayoutAsync(int warehouseId)
         {
             // 1. 鏌ヨ浠撳簱淇℃伅
-            var warehouse = await Repository.Change<Dt_Warehouse>().GetFirstAsync(x => x.Id == warehouseId);
+            var warehouse = await _warehouseService.Repository.QueryFirstAsync(x => x.WarehouseId == warehouseId);
 
             // 2. 鏌ヨ璇ヤ粨搴撴墍鏈夎揣浣�
-            var locations = await Repository.Change<Dt_LocationInfo>().GetListAsync(x => x.WarehouseId == warehouseId);
+            var locations = await _locationInfoService.Repository.QueryDataAsync(x => x.WarehouseId == warehouseId);
 
             // 3. 鏌ヨ璇ヤ粨搴撴墍鏈夊簱瀛樹俊鎭紙鍖呭惈Details瀵艰埅灞炴�э級
-            var stockInfos = await Repository.Change<Dt_StockInfo>().Includes(x => x.Details).GetListAsync(x => x.WarehouseId == warehouseId);
+            var stockInfos = await Repository.QueryDataNavAsync(x => x.WarehouseId == warehouseId);
 
             // 4. 鎻愬彇鐗╂枡缂栧彿鍜屾壒娆″彿鍒楄〃锛堝幓閲嶏級
             var materielCodeList = stockInfos
diff --git a/Code/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/Controllers/Stock/StockInfoController.cs b/Code/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/Controllers/Stock/StockInfoController.cs
index 62af775..1a7ac90 100644
--- a/Code/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/Controllers/Stock/StockInfoController.cs
+++ b/Code/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/Controllers/Stock/StockInfoController.cs
@@ -29,7 +29,7 @@
         public async Task<WebResponseContent> Get3DLayout(int warehouseId)
         {
             var result = await Service.Get3DLayoutAsync(warehouseId);
-            return WebResponseContent.Instance.OK(result);
+            return WebResponseContent.Instance.OK(data: result);
         }
     }
 }

--
Gitblit v1.9.3