From 05a9d230c8f515bc59b491311bd2897b82164fab Mon Sep 17 00:00:00 2001
From: huangxiaoqiang <huangxiaoqiang@hnkhzn.com>
Date: 星期六, 12 七月 2025 18:31:49 +0800
Subject: [PATCH] 增强异常处理错误信息返回在 `TaskService.cs` 文件中,更新了异常处理逻辑,错误信息现在包含异常的堆栈跟踪信息 `ex.StackTrace`,以提供更详细的调试信息。

---
 Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StoragIntegrationServices/MOM/CellState/CellStateService.cs |   55 ++++++++++++++++++++-----------------------------------
 1 files changed, 20 insertions(+), 35 deletions(-)

diff --git a/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StoragIntegrationServices/MOM/CellState/CellStateService.cs b/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StoragIntegrationServices/MOM/CellState/CellStateService.cs
index 2746a02..e61bb34 100644
--- a/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StoragIntegrationServices/MOM/CellState/CellStateService.cs
+++ b/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StoragIntegrationServices/MOM/CellState/CellStateService.cs
@@ -1,4 +1,5 @@
-锘縰sing LogLibrary.Log;
+锘縰sing AngleSharp.Io;
+using LogLibrary.Log;
 using Masuit.Tools;
 using Newtonsoft.Json;
 using WIDESEA_Common;
@@ -6,6 +7,7 @@
 using WIDESEA_Core.Const;
 using WIDESEA_Core.Helper;
 using WIDESEA_DTO;
+using WIDESEA_DTO.MOM;
 using WIDESEA_IRepository;
 using WIDESEA_IServices;
 using WIDESEA_IStorageBasicService;
@@ -40,7 +42,7 @@
             input.SessionId = Guid.NewGuid().ToString();
             input.EmployeeNo = "MITest";
             input.RequestTime = TimeZoneInfo.ConvertTimeToUtc(DateTime.Now).ToString("yyyy-MM-ddTHH:mm:ss.fffZ");
-            var inputJson = input.ToDictionary();
+            var inputJson = Masuit.Tools.ObjectExtensions.ToDictionary(input);
             var configs = _configService.GetConfigsByCategory(CateGoryConst.SYS_MOMIPAddress);
             var wmsBase = configs.FirstOrDefault(x => x.ConfigKey == SysConfigConst.MOMBaseIP)?.ConfigValue;
             var ipAddress = configs.FirstOrDefault(x => x.ConfigKey == SysConfigConst.CellState)?.ConfigValue; 
@@ -51,35 +53,6 @@
             var wmsIpAddress = wmsBase + ipAddress;
 
             var result = HttpsClient.PostAsync(wmsIpAddress, inputJson).Result;
-            //var x = await HttpsClient.PostAsync("http://c24-cellmi3:12020/api/MachineIntegration/CellState", inputJson);
-            #region
-            //if (x != null)
-            //{
-            //    ResultCellState result = JsonConvert.DeserializeObject<ResultCellState>(x);
-            //    DtBoxingInfo boxingInfo = new DtBoxingInfo()
-            //    {
-            //        IsFull = true,
-            //        PalletCode = "",
-            //    };
-            //    var details = new List<DtBoxingInfoDetail>();
-            //    foreach (var item in result.SerialNos)
-            //    {
-            //        DtBoxingInfoDetail detail = new DtBoxingInfoDetail()
-            //        {
-            //            SerialNumber = item.SerialNo,
-            //            OrderNo = item.BindCode,
-            //            Status = item.SerialNoStatus,
-            //        };
-            //        details.Add(detail);
-            //    }
-            //    boxingInfo.BoxingInfoDetails = details;
-            //    var abc = await _boxingInfoService.AddBoxingInfoAsync(boxingInfo);
-            //    if (abc.Status)
-            //        return content.OK("缁勭洏鎴愬姛");
-            //    else
-            //        return content.Error("缁勭洏澶辫触");
-            //}
-            #endregion
 
             LogFactory.GetLog("鍗曠數鑺睘鎬ц幏鍙�").Info(true, $"\r\r--------------------------------------");
             LogFactory.GetLog("鍗曠數鑺睘鎬ц幏鍙�").Info(true, result);
@@ -87,7 +60,7 @@
         }
         catch (Exception err)
         {
-            Console.WriteLine(err.Message.ToString());
+            //Console.WriteLine(err.Message.ToString());
             LogFactory.GetLog("鍗曠數鑺睘鎬ц幏鍙�").Error(true, $"\r\r--------------------------------------");
             LogFactory.GetLog("鍗曠數鑺睘鎬ц幏鍙�").Error(true, $"璇锋眰鍙傛暟: {JsonConvert.SerializeObject(input)}");
             LogFactory.GetLog("鍗曠數鑺睘鎬ц幏鍙�").Error(true, err.Message);
@@ -109,7 +82,7 @@
             input.SessionId = Guid.NewGuid().ToString();
             input.EmployeeNo = "MITest";
             input.RequestTime = TimeZoneInfo.ConvertTimeToUtc(DateTime.Now).ToString("yyyy-MM-ddTHH:mm:ss.fffZ");
-            var inputJson = input.ToDictionary();
+            var inputJson = Masuit.Tools.ObjectExtensions.ToDictionary(input);
             var configs = _configService.GetConfigsByCategory(CateGoryConst.SYS_MOMIPAddress);
             var wmsBase = configs.FirstOrDefault(x => x.ConfigKey == SysConfigConst.MOMBaseIP)?.ConfigValue;
             var ipAddress = configs.FirstOrDefault(x => x.ConfigKey == SysConfigConst.TrayCellsStatus)?.ConfigValue;
@@ -120,7 +93,17 @@
             var wmsIpAddress = wmsBase + ipAddress;
 
             var result = HttpsClient.PostAsync(wmsIpAddress, inputJson).Result;
-            //var x = await HttpsClient.PostAsync("http://c24-cellmi3:12020/api/MachineIntegration/TrayCellsStatus", inputJson);
+
+            var respone = JsonConvert.DeserializeObject<ResultTrayCellsStatus>(result.ToString());
+
+            if (!respone.Success)
+            {
+                MoMErrorMsg.AddMoMErrorMsg(0, input.TrayBarcode, respone.MOMMessage, SysConfigConst.TrayCellsStatus);
+            }
+            else
+            {
+                MoMErrorMsg.DeleteMoMErrorMsg(0, input.TrayBarcode);
+            }
 
             LogFactory.GetLog("鏁寸洏鐢佃姱灞炴�ц幏鍙�").Info(true, $"\r\r--------------------------------------");
             LogFactory.GetLog("鏁寸洏鐢佃姱灞炴�ц幏鍙�").Info(true, result);
@@ -128,7 +111,9 @@
         }
         catch (Exception err)
         {
-            Console.WriteLine(err.Message.ToString());
+            //MoMErrorMsg.AddMoMErrorMsg(0, input.TrayBarcode, err.Message, SysConfigConst.TrayCellsStatus);
+
+            //Console.WriteLine(err.Message.ToString());
             LogFactory.GetLog("鏁寸洏鐢佃姱灞炴�ц幏鍙�").Error(true, $"\r\r--------------------------------------");
             LogFactory.GetLog("鏁寸洏鐢佃姱灞炴�ц幏鍙�").Error(true, $"璇锋眰鍙傛暟: {JsonConvert.SerializeObject(input)}");
             LogFactory.GetLog("鏁寸洏鐢佃姱灞炴�ц幏鍙�").Error(true, err.Message);

--
Gitblit v1.9.3