From 7278264f027d62664a0209699d0f66a22fd06a8e Mon Sep 17 00:00:00 2001
From: wanshenmean <cathay_xy@163.com>
Date: 星期一, 13 四月 2026 10:24:04 +0800
Subject: [PATCH] feat: 更新依赖版本并优化MES接口调用

---
 Code/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/Controllers/Stock/StockInfoDetailController.cs |   66 +++++++++++----------------------
 1 files changed, 22 insertions(+), 44 deletions(-)

diff --git a/Code/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/Controllers/Stock/StockInfoDetailController.cs b/Code/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/Controllers/Stock/StockInfoDetailController.cs
index 1c4242a..eca38b2 100644
--- a/Code/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/Controllers/Stock/StockInfoDetailController.cs
+++ b/Code/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/Controllers/Stock/StockInfoDetailController.cs
@@ -22,16 +22,19 @@
         private readonly IMesLogService _mesLogService;
         private readonly IMesService _mesService;
         private readonly ISys_DictionaryService _sysDictionaryService;
+        private readonly IStockInfoService _stockInfoService;
 
         public StockInfoDetailController(
             IStockInfoDetailService service,
             IMesLogService mesLogService,
             IMesService mesService,
-            ISys_DictionaryService sysDictionaryService) : base(service)
+            ISys_DictionaryService sysDictionaryService,
+            IStockInfoService stockInfoService) : base(service)
         {
             _mesLogService = mesLogService;
             _mesService = mesService;
             _sysDictionaryService = sysDictionaryService;
+            _stockInfoService = stockInfoService;
         }
 
         /// <summary>
@@ -48,36 +51,26 @@
             try
             {
                 // 1. 鍙傛暟楠岃瘉
-                if (string.IsNullOrWhiteSpace(dto.PalletCode))
-                {
-                    return response.Error("鎵樼洏缂栧彿涓嶈兘涓虹┖");
-                }
-
                 if (dto.SfcList == null || !dto.SfcList.Any())
                 {
                     return response.Error("鐢佃姱鐮佸垪琛ㄤ笉鑳戒负绌�");
                 }
 
                 // 2. 楠岃瘉鐢佃姱鐘舵�侊紙闈�'宸查攣瀹�'鐘舵�佸厑璁哥粦瀹氾級
-                var stockDetails = await Service.Repository.QueryDataAsync(x => dto.SfcList.Contains(x.SerialNumber));
-                if (stockDetails != null && stockDetails.Any(d => d.Status == 99))
+                var stockDetail = await Service.Repository.QueryFirstAsync(x => dto.SfcList.Contains(x.SerialNumber));
+                if (stockDetail != null && stockDetail.Status == 99)
                 {
                     return response.Error("褰撳墠搴撳瓨鏄庣粏鍖呭惈宸查攣瀹氱姸鎬侊紝涓嶅厑璁告墽琛岀粦瀹氭搷浣�");
                 }
-
-                // 3. 鑾峰彇绯荤粺閰嶇疆
-                var configs = _sysDictionaryService.GetVueDictionary(new[] { "MES_EquipmentCode", "MES_ResourceCode" });
-
-                string equipmentCode = GetConfigValue(configs, "MES_EquipmentCode", "WCS_001");
-                string resourceCode = GetConfigValue(configs, "MES_ResourceCode", "RESOURCE_001");
+                var stockInfo = await _stockInfoService.Repository.QueryFirstAsync(x => stockDetail.StockId == x.Id);
 
                 // 3. 鏋勯�燤ES璇锋眰 - 灏嗙數鑺垪琛ㄨ浆鎹负ContainerSfcItem鏍煎紡
                 var mesRequest = new BindContainerRequest
                 {
-                    EquipmentCode = equipmentCode,
-                    ResourceCode = resourceCode,
+                    EquipmentCode = "STK-GROUP-001",
+                    ResourceCode = "STK-GROUP-001",
                     LocalTime = DateTime.Now,
-                    ContainerCode = dto.PalletCode,
+                    ContainerCode = stockInfo.PalletCode,
                     ContainerSfcList = dto.SfcList.Select(sfc => new ContainerSfcItem
                     {
                         Sfc = sfc,
@@ -146,36 +139,26 @@
             try
             {
                 // 1. 鍙傛暟楠岃瘉
-                if (string.IsNullOrWhiteSpace(dto.PalletCode))
-                {
-                    return response.Error("鎵樼洏缂栧彿涓嶈兘涓虹┖");
-                }
-
                 if (dto.SfcList == null || !dto.SfcList.Any())
                 {
                     return response.Error("鐢佃姱鐮佸垪琛ㄤ笉鑳戒负绌�");
                 }
 
                 // 2. 楠岃瘉鐢佃姱鐘舵�侊紙闈�'宸查攣瀹�'鐘舵�佸厑璁歌В缁戯級
-                var stockDetails = await Service.Repository.QueryDataAsync(x => dto.SfcList.Contains(x.SerialNumber));
-                if (stockDetails != null && stockDetails.Any(d => d.Status == 99))
+                var stockDetail = await Service.Repository.QueryFirstAsync(x => dto.SfcList.Contains(x.SerialNumber));
+                if (stockDetail != null && stockDetail.Status == 99)
                 {
                     return response.Error("褰撳墠搴撳瓨鏄庣粏鍖呭惈宸查攣瀹氱姸鎬侊紝涓嶅厑璁告墽琛岃В缁戞搷浣�");
                 }
-
-                // 3. 鑾峰彇绯荤粺閰嶇疆
-                var configs = _sysDictionaryService.GetVueDictionary(new[] { "MES_EquipmentCode", "MES_ResourceCode" });
-
-                string equipmentCode = GetConfigValue(configs, "MES_EquipmentCode", "WCS_001");
-                string resourceCode = GetConfigValue(configs, "MES_ResourceCode", "RESOURCE_001");
+                var stockInfo = await _stockInfoService.Repository.QueryFirstAsync(x => stockDetail.StockId == x.Id);
 
                 // 3. 鏋勯�燤ES璇锋眰
                 var mesRequest = new UnBindContainerRequest
                 {
-                    EquipmentCode = equipmentCode,
-                    ResourceCode = resourceCode,
+                    EquipmentCode = "STK-GROUP-001",
+                    ResourceCode = "STK-GROUP-001",
                     LocalTime = DateTime.Now,
-                    ContainCode = dto.PalletCode,
+                    ContainCode = stockInfo.PalletCode,
                     SfcList = dto.SfcList
                 };
 
@@ -251,25 +234,20 @@
 
                 // 2. 楠岃瘉鐢佃姱鐘舵�侊紙闈�'宸查攣瀹�'鐘舵�佸厑璁窷G涓婃姤锛�
                 var sfcList = dto.NgSfcList.Select(x => x.Sfc).ToList();
-                var stockDetails = await Service.Repository.QueryDataAsync(x => sfcList.Contains(x.SerialNumber));
-                if (stockDetails != null && stockDetails.Any(d => d.Status == 99))
+                var stockDetail = await Service.Repository.QueryFirstAsync(x => sfcList.Contains(x.SerialNumber));
+                if (stockDetail != null && stockDetail.Status == 99)
                 {
                     return response.Error("褰撳墠搴撳瓨鏄庣粏鍖呭惈宸查攣瀹氱姸鎬侊紝涓嶅厑璁告墽琛孨G涓婃姤鎿嶄綔");
                 }
-
-                // 3. 鑾峰彇绯荤粺閰嶇疆
-                var configs = _sysDictionaryService.GetVueDictionary(new[] { "MES_EquipmentCode", "MES_ResourceCode" });
-
-                string equipmentCode = GetConfigValue(configs, "MES_EquipmentCode", "WCS_001");
-                string resourceCode = GetConfigValue(configs, "MES_ResourceCode", "RESOURCE_001");
+                var stockInfo = await _stockInfoService.Repository.QueryFirstAsync(x => stockDetail.StockId == x.Id);
 
                 // 3. 鏋勯�燤ES璇锋眰 - 灏咲TO鏍煎紡杞崲涓篗ES璇锋眰鏍煎紡
                 var mesRequest = new ContainerNgReportRequest
                 {
-                    EquipmentCode = equipmentCode,
-                    ResourceCode = resourceCode,
+                    EquipmentCode = "STK-GROUP-001",
+                    ResourceCode = "RESOURCE-001",
                     LocalTime = DateTime.Now,
-                    ContainerCode = dto.PalletCode,
+                    ContainerCode = stockInfo.PalletCode,
                     NgSfcList = dto.NgSfcList.Select(ng => new NgSfcItem
                     {
                         Sfc = ng.Sfc,

--
Gitblit v1.9.3