From 8482760e3db0581ee34d79424e73fed69e7948d9 Mon Sep 17 00:00:00 2001
From: wanshenmean <cathay_xy@163.com>
Date: 星期一, 30 三月 2026 18:10:20 +0800
Subject: [PATCH] feat(stockChat): 库存3D查看器完整实现

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

diff --git a/Code/WMS/WIDESEA_WMSServer/WIDESEA_StockService/StockInfoService.cs b/Code/WMS/WIDESEA_WMSServer/WIDESEA_StockService/StockInfoService.cs
index d992bdf..81f3390 100644
--- a/Code/WMS/WIDESEA_WMSServer/WIDESEA_StockService/StockInfoService.cs
+++ b/Code/WMS/WIDESEA_WMSServer/WIDESEA_StockService/StockInfoService.cs
@@ -107,7 +107,7 @@
             var locations = await _locationInfoService.Repository.QueryDataAsync(x => x.WarehouseId == warehouseId);
 
             // 3. 鏌ヨ璇ヤ粨搴撴墍鏈夊簱瀛樹俊鎭紙鍖呭惈Details瀵艰埅灞炴�э級
-            var stockInfos = await Repository.QueryDataNavAsync(x => x.WarehouseId == warehouseId);
+            var stockInfos = await Repository.QueryDataNavAsync(x => x.WarehouseId == warehouseId && x.LocationId != 0);
 
             // 4. 鎻愬彇鐗╂枡缂栧彿鍜屾壒娆″彿鍒楄〃锛堝幓閲嶏級
             var materielCodeList = stockInfos
@@ -145,34 +145,52 @@
                 };
 
                 // 灏濊瘯浠庡簱瀛樺瓧鍏镐腑鑾峰彇搴撳瓨淇℃伅
-                if (stockDict.TryGetValue(loc.Id, out var stockInfo) && stockInfo.Details != null)
+                if (stockDict.TryGetValue(loc.Id, out var stockInfo))
                 {
+                    // 绌烘墭鐩樹篃鏈夊簱瀛樿褰曪紝鍙槸涓嶅寘鍚槑缁�
                     item.PalletCode = stockInfo.PalletCode;
-                    item.StockQuantity = stockInfo.Details.Sum(d => d.StockQuantity);
+                    item.StockStatus = stockInfo.StockStatus; // 鐩存帴浣跨敤鍚庣搴撳瓨鐘舵��
 
-                    // 鑾峰彇绗竴涓槑缁嗙殑鐗╂枡淇℃伅锛堝鏋滃瓨鍦級
-                    var firstDetail = stockInfo.Details.FirstOrDefault();
-                    if (firstDetail != null)
+                    // 鍙湁褰揇etails涓嶄负null涓旀湁鏁版嵁鏃舵墠澶勭悊搴撳瓨鏄庣粏
+                    if (stockInfo.Details != null && stockInfo.Details.Any())
                     {
-                        item.MaterielCode = firstDetail.MaterielCode;
-                        item.MaterielName = firstDetail.MaterielName;
-                        item.BatchNo = firstDetail.BatchNo;
-                    }
+                        item.StockQuantity = stockInfo.Details.Sum(d => d.StockQuantity);
 
-                    // 璁$畻搴撳瓨鐘舵��
-                    var ratio = item.MaxCapacity > 0 ? item.StockQuantity / item.MaxCapacity : 0;
-                    if (ratio >= 0.9f)
-                        item.StockStatus = 3; // 宸叉弧 (FULL)
-                    else if (ratio >= 0.1f)
-                        item.StockStatus = 1; // 鏈夎揣 (HAS_STOCK)
-                    else if (ratio > 0)
-                        item.StockStatus = 2; // 搴撳瓨绱у紶 (LOW_STOCK)
+                        // 鑾峰彇绗竴涓槑缁嗙殑鐗╂枡淇℃伅锛堝鏋滃瓨鍦級
+                        var firstDetail = stockInfo.Details.FirstOrDefault();
+                        if (firstDetail != null)
+                        {
+                            item.MaterielCode = firstDetail.MaterielCode;
+                            item.MaterielName = firstDetail.MaterielName;
+                            item.BatchNo = firstDetail.BatchNo;
+                        }
+
+                        // 濉厖搴撳瓨鏄庣粏鍒楄〃
+                        item.Details = stockInfo.Details.Select(d => new StockDetailItemDTO
+                        {
+                            Id = d.Id,
+                            MaterielCode = d.MaterielCode,
+                            MaterielName = d.MaterielName,
+                            BatchNo = d.BatchNo,
+                            StockQuantity = d.StockQuantity,
+                            Unit = d.Unit,
+                            ProductionDate = d.ProductionDate,
+                            EffectiveDate = d.EffectiveDate,
+                            OrderNo = d.OrderNo,
+                            Status = d.Status
+                        }).ToList();
+                    }
                     else
-                        item.StockStatus = 0; // 鏃犺揣 (EMPTY)
+                    {
+                        // 绌烘墭鐩橈紙鏃犳槑缁嗭級
+                        item.StockQuantity = 0;
+                        item.Details = new List<StockDetailItemDTO>(); // 纭繚鏄┖鍒楄〃鑰岄潪null
+                    }
                 }
                 else
                 {
-                    item.StockStatus = 0; // 鏃犺揣 (EMPTY)
+                    // 鏃犲簱瀛樿褰曪紝璐т綅涓虹┖
+                    item.StockStatus = 0; // 绌洪棽
                     item.StockQuantity = 0;
                 }
 

--
Gitblit v1.9.3