From 85fac67b3bcd53894151a2bce384a945b1b67eb2 Mon Sep 17 00:00:00 2001
From: wanshenmean <cathay_xy@163.com>
Date: 星期一, 30 三月 2026 14:26:02 +0800
Subject: [PATCH] feat(TaskService): OutboundFinishTaskTrayAsync添加任务和库存历史保存

---
 Code/WMS/WIDESEA_WMSServer/WIDESEA_StockService/StockInfoService.cs |   25 ++++++++++++++++++++-----
 1 files changed, 20 insertions(+), 5 deletions(-)

diff --git a/Code/WMS/WIDESEA_WMSServer/WIDESEA_StockService/StockInfoService.cs b/Code/WMS/WIDESEA_WMSServer/WIDESEA_StockService/StockInfoService.cs
index 71f1e9b..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,16 +101,17 @@
         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
+                .Where(s => s.Details != null)
                 .SelectMany(s => s.Details)
                 .Select(d => d.MaterielCode)
                 .Where(c => !string.IsNullOrEmpty(c))
@@ -105,6 +119,7 @@
                 .ToList();
 
             var batchNoList = stockInfos
+                .Where(s => s.Details != null)
                 .SelectMany(s => s.Details)
                 .Select(d => d.BatchNo)
                 .Where(b => !string.IsNullOrEmpty(b))
@@ -130,7 +145,7 @@
                 };
 
                 // 灏濊瘯浠庡簱瀛樺瓧鍏镐腑鑾峰彇搴撳瓨淇℃伅
-                if (stockDict.TryGetValue(loc.Id, out var stockInfo))
+                if (stockDict.TryGetValue(loc.Id, out var stockInfo) && stockInfo.Details != null)
                 {
                     item.PalletCode = stockInfo.PalletCode;
                     item.StockQuantity = stockInfo.Details.Sum(d => d.StockQuantity);

--
Gitblit v1.9.3