From 844c7c3ce2c39139490a6ecb0f35170f6cade290 Mon Sep 17 00:00:00 2001
From: wankeda <Administrator@DESKTOP-HAU3ST3>
Date: 星期二, 28 四月 2026 16:31:54 +0800
Subject: [PATCH] 1

---
 WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs |  173 +++++++++++++++++++++++++++++++++++++++++++--------------
 1 files changed, 129 insertions(+), 44 deletions(-)

diff --git a/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs b/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs
index b1d8887..b0eb149 100644
--- a/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs
+++ b/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs
@@ -132,9 +132,11 @@
         private readonly IInboundRepository _inboundRepository;
         private readonly ITakeStockOrderCPRepository _takeStockOrderCPRepository;
         private readonly ITakeStockOrderDetailCPRepository _takeStockOrderDetailCPRepository;
+        private readonly IHubContext<WMSNoticeHub> _hubContext;
         public ITaskRepository Repository => BaseDal;
 
-        public TaskService(ITaskRepository BaseDal, IMapper mapper, IUnitOfWorkManage unitOfWorkManage, IMaterielInfoService materielInfoService, IInboundOrderDetail_HtyService inboundOrderDetail_HtyService, IOutboundOrder_HtyService outboundOrder_HtyService, IOutboundOrderDetail_HtyService outboundOrderDetail_HtyService, IInboundOrder_HtyService inboundOrder_HtyService, IStockRepository stockRepository, IInboundOrderDetailService inboundOrderDetailService, IBasicService basicService, IOutboundService outboundService, IInboundService inboundService, IRecordService recordService, IStockService stockService, ITask_HtyService taskHtyService, ILocationInfoService locationInfoService, IOutboundOrderDetailRepository outboundOrderDetailRepository, IBasicRepository basicRepository, IStockInfoDetailRepository stockInfoDetailRepository, IPalletTypeInfoRepository palletTypeInfoRepository, IReturnOrderRepository returnOrderRepository, IProductionRepository productionRepository, IInboundRepository inboundRepository, INewOutboundOrderDetailRepository newOutboundOrderDetailRepository, ITakeStockOrderCPRepository takeStockOrderCPRepository, ITakeStockOrderDetailCPRepository takeStockOrderDetailCPRepository, IStockInfoDetailCPRepository stockInfoDetailCPRepository) : base(BaseDal)
+        public TaskService(ITaskRepository BaseDal, IMapper mapper, IUnitOfWorkManage unitOfWorkManage, IMaterielInfoService materielInfoService, IInboundOrderDetail_HtyService inboundOrderDetail_HtyService, IOutboundOrder_HtyService outboundOrder_HtyService, IOutboundOrderDetail_HtyService outboundOrderDetail_HtyService, IInboundOrder_HtyService inboundOrder_HtyService, IStockRepository stockRepository, IInboundOrderDetailService inboundOrderDetailService, IBasicService basicService, IOutboundService outboundService, IInboundService inboundService, IRecordService recordService, IStockService stockService, ITask_HtyService taskHtyService, ILocationInfoService locationInfoService, IOutboundOrderDetailRepository outboundOrderDetailRepository, IBasicRepository basicRepository, IStockInfoDetailRepository stockInfoDetailRepository, IPalletTypeInfoRepository palletTypeInfoRepository, IReturnOrderRepository returnOrderRepository, IProductionRepository productionRepository, IInboundRepository inboundRepository, INewOutboundOrderDetailRepository newOutboundOrderDetailRepository, ITakeStockOrderCPRepository takeStockOrderCPRepository, ITakeStockOrderDetailCPRepository takeStockOrderDetailCPRepository, IStockInfoDetailCPRepository stockInfoDetailCPRepository,
+          IHubContext<WMSNoticeHub> hubContext) : base(BaseDal)
         {
             _mapper = mapper;
             _stockRepository = stockRepository;
@@ -163,6 +165,7 @@
             _takeStockOrderCPRepository = takeStockOrderCPRepository;
             _takeStockOrderDetailCPRepository = takeStockOrderDetailCPRepository;
             _stockInfoDetailCPRepository = stockInfoDetailCPRepository;
+            _hubContext = hubContext;
         }
 
         public string ReceiveWMSTaskin = WIDESEA_Core.Helper.AppSettings.Configuration["ReceiveWMSTaskin"];
@@ -810,7 +813,14 @@
                                         // 鍒ゆ柇Success鐨勫��
                                         if (!response.Success)
                                         {
+                                            WriteLog.Write_Log("API", "鍏ュ簱鈥斿洖璋僑MOM(澶辫触)", "璇锋眰澶辫触", new { 璇锋眰鎶ユ枃 = houseInboundPassBack, 鎺ユ敹鎶ユ枃 = response });
+
                                             throw new Exception($"鎿嶄綔澶辫触: {response.Message ?? "鏈彁渚涢敊璇俊鎭�"}");
+                                        }
+                                        else
+                                        {
+                                            WriteLog.Write_Log("API", "鍏ュ簱鈥斿洖璋僑MOM(鎴愬姛)", "璇锋眰鎴愬姛", new { 璇锋眰鎶ユ枃 = houseInboundPassBack, 鎺ユ敹鎶ユ枃 = response });
+
                                         }
 
                                     }
@@ -888,7 +898,14 @@
                                         var response = HttpHelper.Post<MomRequestContent>(ReceiveWMSTaskAllocatein, inventoryAllocate, "璋冩嫧鍏ュ簱鏁伴噺鍥炰紶WMS");
                                         if (!response.Success)
                                         {
+                                            WriteLog.Write_Log("API", "鍏ュ簱鈥斿洖璋僑MOM(澶辫触)", "璇锋眰澶辫触", new { 璇锋眰鎶ユ枃 = inventoryAllocate, 鎺ユ敹鎶ユ枃 = response });
+
                                             throw new Exception($"鎿嶄綔澶辫触锛歿response.Message ?? "鏈彁渚涢敊璇俊鎭�"}");
+                                        }
+                                        else
+                                        {
+                                            WriteLog.Write_Log("API", "鍏ュ簱鈥斿洖璋僑MOM(鎴愬姛)", "璇锋眰鎴愬姛", new { 璇锋眰鎶ユ枃 = inventoryAllocate, 鎺ユ敹鎶ユ枃 = response });
+
                                         }
                                     }
                                 }
@@ -950,16 +967,23 @@
                                     if (authResult.IsSuccess)
                                     {
                                         houseSyncretism.Context = new Dictionary<string, string>
-                                            {
-                                                { "Ticket", authResult.Ticket },
-                                                { "InvOrgId", authResult.InvOrgId }
+                                        {
+                                            { "Ticket", authResult.Ticket },
+                                            { "InvOrgId", authResult.InvOrgId }
 
-                                            };
+                                        };
 
                                         var response = HttpHelper.Post<MomRequestContent>(ReceiveWMSTaskin, houseSyncretism, "绔嬪簱鍏ュ簱鏁伴噺鍥炰紶WMS");
                                         if (!response.Success)
                                         {
+                                            WriteLog.Write_Log("API", "鍏ュ簱鈥斿洖璋僑MOM(澶辫触)", "璇锋眰澶辫触", new { 璇锋眰鎶ユ枃 = houseSyncretism, 鎺ユ敹鎶ユ枃 = response });
+
                                             throw new Exception($"鎿嶄綔澶辫触: {response.Message ?? "鏈彁渚涢敊璇俊鎭�"}");
+                                        }
+                                        else
+                                        {
+                                            WriteLog.Write_Log("API", "鍏ュ簱鈥斿洖璋僑MOM(鎴愬姛)", "璇锋眰鎴愬姛", new { 璇锋眰鎶ユ枃 = houseSyncretism, 鎺ユ敹鎶ユ枃 = response });
+
                                         }
 
                                     }
@@ -1499,20 +1523,24 @@
             if (authResult.IsSuccess)
             {
                 houseInboundPassBack.Context = new Dictionary<string, string>
-            {
-                { "Ticket", authResult.Ticket },
-                { "InvOrgId", authResult.InvOrgId }
-            };
+                {
+                    { "Ticket", authResult.Ticket },
+                    { "InvOrgId", authResult.InvOrgId }
+                };
 
                 var response = HttpHelper.Post<MomRequestContent>(ReceiveWMSTaskin, houseInboundPassBack, "绔嬪簱鍏ュ簱鏁伴噺鍥炰紶WMS");
                 // 鍒ゆ柇Success鐨勫��
                 if (response.Success)
                 {
+                    WriteLog.Write_Log("API", "鍏ュ簱鈥斿洖璋僑MOM(鎴愬姛)", "璇锋眰鎴愬姛", new { 璇锋眰鎶ユ枃 = houseInboundPassBack, 鎺ユ敹鎶ユ枃 = response });
+
                     // 濡傛灉Success涓簍rue锛岃繑鍥為渶瑕佺殑鍊硷紙杩欓噷浠ヨ繑鍥炴暣涓搷搴斿璞′负渚嬶級
                     return WebResponseContent.Instance.OK();
                 }
                 else
                 {
+                    WriteLog.Write_Log("API", "鍏ュ簱鈥斿洖璋僑MOM(澶辫触)", "璇锋眰澶辫触", new { 璇锋眰鎶ユ枃 = houseInboundPassBack, 鎺ユ敹鎶ユ枃 = response });
+
                     // 濡傛灉Success涓篺alse锛屾姏鍑哄紓甯稿苟鍖呭惈閿欒淇℃伅
                     throw new Exception($"鎿嶄綔澶辫触: {response.Message ?? "鏈彁渚涢敊璇俊鎭�"}");
                 }
@@ -1559,19 +1587,23 @@
             if (authResult.IsSuccess)
             {
                 houseReturnOrders.Context = new Dictionary<string, string>
-            {
-                { "Ticket", authResult.Ticket },
-                { "InvOrgId", authResult.InvOrgId }
-            };
+                {
+                    { "Ticket", authResult.Ticket },
+                    { "InvOrgId", authResult.InvOrgId }
+                };
                 var response = HttpHelper.Post<MomRequestContent>(ReceiveWMSTaskreturn, houseReturnOrders, "鍙栨秷鍙戣揣鍚庣珛搴撳弽鎷e叆搴撳洖浼燱MS");
                 // 鍒ゆ柇Success鐨勫��
                 if (response.Success)
                 {
+                    WriteLog.Write_Log("API", "鍏ュ簱鈥斿洖璋僑MOM(鎴愬姛)", "璇锋眰鎴愬姛", new { 璇锋眰鎶ユ枃 = houseReturnOrders, 鎺ユ敹鎶ユ枃 = response });
+
                     // 濡傛灉Success涓簍rue锛岃繑鍥為渶瑕佺殑鍊硷紙杩欓噷浠ヨ繑鍥炴暣涓搷搴斿璞′负渚嬶級
                     return WebResponseContent.Instance.OK();
                 }
                 else
                 {
+                    WriteLog.Write_Log("API", "鍏ュ簱鈥斿洖璋僑MOM(澶辫触)", "璇锋眰澶辫触", new { 璇锋眰鎶ユ枃 = houseReturnOrders, 鎺ユ敹鎶ユ枃 = response });
+
                     // 濡傛灉Success涓篺alse锛屾姏鍑哄紓甯稿苟鍖呭惈閿欒淇℃伅
                     throw new Exception($"鎿嶄綔澶辫触: {response.Message ?? "鏈彁渚涢敊璇俊鎭�"}");
                 }
@@ -1636,45 +1668,54 @@
                 ApiType = "InventoryAllocateController",
                 Method = "AsrsFinishedStockCount",
                 Parameters = new List<InventoryAllocate.Allocate>
-        {
-             new InventoryAllocate.Allocate
-            {
-                Value = new List<Allocate.data1>
                 {
-                new Allocate.data1
-                {
-                    No = inboundOrder.OrderNo,
-                    //InWarehouse = task.Roadway,
-                    TransactionCode = inboundOrder.TransactionCode,
-                    InoutType = inboundOrder.OrderType,
-                    OrderType = inboundOrder.InoutType,
-                    // 閬嶅巻鎵�鏈夊簱瀛樻槑缁嗭紝娣诲姞鍒� DetailList
-                    DetailList = StockInfos.Select(d => new Allocate.data1.Inventory
-                    {
-                        LinId = d.Details.FirstOrDefault()?.LinId?? "",
-                        MaterielCode = d.Details.FirstOrDefault()?.MaterielCode?? "",
-                        OrderQuantity = d.Details.FirstOrDefault().StockQuantity,
-                        BatchNo = d.BatchNo,
-                        LPNNo = d.PalletCode,
-                        FinishQty = d.Details.FirstOrDefault().StockQuantity,
-                        LocationName = d.LocationCode
-                    }).ToList()
+                     new InventoryAllocate.Allocate
+                     {
+                        Value = new List<Allocate.data1>
+                        {
+                            new Allocate.data1
+                            {
+                                No = inboundOrder.OrderNo,
+                                //InWarehouse = task.Roadway,
+                                TransactionCode = inboundOrder.TransactionCode,
+                                InoutType = inboundOrder.OrderType,
+                                OrderType = inboundOrder.InoutType,
+                                // 閬嶅巻鎵�鏈夊簱瀛樻槑缁嗭紝娣诲姞鍒� DetailList
+                                DetailList = StockInfos.Select(d => new Allocate.data1.Inventory
+                                {
+                                    LinId = d.Details.FirstOrDefault()?.LinId?? "",
+                                    MaterielCode = d.Details.FirstOrDefault()?.MaterielCode?? "",
+                                    OrderQuantity = d.Details.FirstOrDefault().StockQuantity,
+                                    BatchNo = d.BatchNo,
+                                    LPNNo = d.PalletCode,
+                                    FinishQty = d.Details.FirstOrDefault().StockQuantity,
+                                    LocationName = d.LocationCode
+                                }).ToList()
+                            }
+                        }
+                     }
                 }
-                }
-            }
-        }
             };
 
             var authResult = AuthenticateWithWMS();
             if (authResult.IsSuccess)
             {
                 inventoryAllocate.Context = new Dictionary<string, string>
-        {
-            { "Ticket", authResult.Ticket },
-            { "InvOrgId", authResult.InvOrgId }
-        };
+                {
+                    { "Ticket", authResult.Ticket },
+                    { "InvOrgId", authResult.InvOrgId }
+                };
 
-                HttpHelper.Post<WebResponseContent>(ReceiveWMSTaskAllocatein, inventoryAllocate, "璋冩嫧鍏ュ簱鏁伴噺鍥炰紶WMS");
+                var response = HttpHelper.Post<WebResponseContent>(ReceiveWMSTaskAllocatein, inventoryAllocate, "璋冩嫧鍏ュ簱鏁伴噺鍥炰紶WMS");
+                if (!response.Status)
+                {
+                    WriteLog.Write_Log("API", "鍏ュ簱鈥斿洖璋僑MOM(澶辫触)", "璇锋眰澶辫触", new { 璇锋眰鎶ユ枃 = inventoryAllocate, 鎺ユ敹鎶ユ枃 = response });
+                }
+                else
+                {
+                    WriteLog.Write_Log("API", "鍏ュ簱鈥斿洖璋僑MOM(鎴愬姛)", "璇锋眰鎴愬姛", new { 璇锋眰鎶ユ枃 = inventoryAllocate, 鎺ユ敹鎶ユ枃 = response });
+
+                }
             }
         }
 
@@ -1948,8 +1989,14 @@
                                                 var response = HttpHelper.Post<MomRequestContent>(ReceiveWMSTaskout, passBack, "绔嬪簱鍑哄簱鏁伴噺鍥炰紶WMS");
                                                 if (!response.Success)
                                                 {
+                                                    WriteLog.Write_Log("API", "鍑哄簱鈥斿洖璋僑MOM(澶辫触)", "璇锋眰澶辫触", new { 璇锋眰鎶ユ枃 = passBack, 鎺ユ敹鎶ユ枃 = response });
+
                                                     throw new Exception($"鎿嶄綔澶辫触: {response.Message ?? "鏈彁渚涢敊璇俊鎭�"}");
                                                 }
+                                                else
+                                                {
+                                                    WriteLog.Write_Log("API", "鍑哄簱鈥斿洖璋僑MOM(鎴愬姛)", "璇锋眰鎴愬姛", new { 璇锋眰鎶ユ枃 = passBack, 鎺ユ敹鎶ユ枃 = response });
+                                                }                                                 
                                             }
                                         }
 
@@ -2005,8 +2052,14 @@
                                                 var response = HttpHelper.Post<MomRequestContent>(ReceiveWMSTaskin, allocate, "绔嬪簱鍏ュ簱鏁伴噺鍥炰紶WMS");
                                                 if (!response.Success)
                                                 {
+                                                    WriteLog.Write_Log("API", "鍑哄簱鈥斿洖璋僑MOM(澶辫触)", "璇锋眰澶辫触", new { 璇锋眰鎶ユ枃 = allocate, 鎺ユ敹鎶ユ枃 = response });
+
                                                     throw new Exception($"鎿嶄綔澶辫触: {response.Message ?? "鏈彁渚涢敊璇俊鎭�"}");
                                                 }
+                                                else
+                                                {
+                                                    WriteLog.Write_Log("API", "鍑哄簱鈥斿洖璋僑MOM(鎴愬姛)", "璇锋眰鎴愬姛", new { 璇锋眰鎶ユ枃 = allocate, 鎺ユ敹鎶ユ枃 = response });
+                                                }                                                   
                                             }
                                         }
                                     }
@@ -2180,7 +2233,14 @@
                                                 var response = HttpHelper.Post<MomRequestContent>(ReceiveWMSTaskout, passBack, "绔嬪簱鍑哄簱鏁伴噺鍥炰紶WMS");
                                                 if (!response.Success)
                                                 {
+                                                    WriteLog.Write_Log("API", "鍑哄簱鈥斿洖璋僑MOM(澶辫触)", "璇锋眰澶辫触", new { 璇锋眰鎶ユ枃 = passBack, 鎺ユ敹鎶ユ枃 = response });
+
                                                     throw new Exception($"鎿嶄綔澶辫触: {response.Message ?? "鏈彁渚涢敊璇俊鎭�"}");
+                                                }
+                                                else
+                                                {
+                                                    WriteLog.Write_Log("API", "鍑哄簱鈥斿洖璋僑MOM(鎴愬姛)", "璇锋眰鎴愬姛", new { 璇锋眰鎶ユ枃 = passBack, 鎺ユ敹鎶ユ枃 = response });
+
                                                 }
                                             }
                                         }
@@ -2237,7 +2297,14 @@
                                                 var response = HttpHelper.Post<MomRequestContent>(ReceiveWMSTaskin, allocate, "绔嬪簱鍏ュ簱鏁伴噺鍥炰紶WMS");
                                                 if (!response.Success)
                                                 {
+                                                    WriteLog.Write_Log("API", "鍑哄簱鈥斿洖璋僑MOM(澶辫触)", "璇锋眰澶辫触", new { 璇锋眰鎶ユ枃 = allocate, 鎺ユ敹鎶ユ枃 = response });
+
                                                     throw new Exception($"鎿嶄綔澶辫触: {response.Message ?? "鏈彁渚涢敊璇俊鎭�"}");
+                                                }
+                                                else
+                                                {
+                                                    WriteLog.Write_Log("API", "鍑哄簱鈥斿洖璋僑MOM(鎴愬姛)", "璇锋眰鎴愬姛", new { 璇锋眰鎶ユ枃 = allocate, 鎺ユ敹鎶ユ枃 = response });
+
                                                 }
                                             }
                                         }
@@ -2853,7 +2920,16 @@
             { "InvOrgId", authResult.InvOrgId }
         };
 
-                HttpHelper.Post<WebResponseContent>(ReceiveWMSTaskin, allocate, "绔嬪簱鍏ュ簱鏁伴噺鍥炰紶WMS");
+                var response =  HttpHelper.Post<WebResponseContent>(ReceiveWMSTaskin, allocate, "绔嬪簱鍏ュ簱鏁伴噺鍥炰紶WMS");
+                if (!response.Status)
+                {
+                    WriteLog.Write_Log("API", "鍑哄簱鈥斿洖璋僑MOM(澶辫触)", "璇锋眰澶辫触", new { 璇锋眰鎶ユ枃 = allocate, 鎺ユ敹鎶ユ枃 = response });
+
+                }
+                else
+                {
+                    WriteLog.Write_Log("API", "鍑哄簱鈥斿洖璋僑MOM(鎴愬姛)", "璇锋眰鎴愬姛", new { 璇锋眰鎶ユ枃 = allocate, 鎺ユ敹鎶ユ枃 = response });
+                }
             }
         }
 
@@ -3351,17 +3427,22 @@
                     result = response.Content.ReadAsStringAsync()
                         .ConfigureAwait(false).GetAwaiter().GetResult();
                 }
+                WriteLog.Write_Log("API", "鍑哄簱鈥斿洖璋僂RP(鎴愬姛)", "璇锋眰鎴愬姛", new { 璇锋眰鎶ユ枃 = postContent, 鎺ユ敹鎶ユ枃 = result });
 
                 // 鍋囪ERP杩斿洖鎴愬姛鏃惰繑鍥炴垚鍔熷搷搴�
                 return WebResponseContent.Instance.OK(result);
             }
             catch (HttpRequestException ex)
             {
+                WriteLog.Write_Log("API", "鍑哄簱鈥斿洖璋僂RP(澶辫触)", "璇锋眰澶辫触", new { 璇锋眰鎶ユ枃 = postContent, 鎺ユ敹鎶ユ枃 = ex.Message });
+
                 // 澶勭悊HTTP璇锋眰鐩稿叧寮傚父
                 return WebResponseContent.Instance.Error($"HTTP璇锋眰閿欒: {ex.Message}");
             }
             catch (Exception ex)
             {
+                WriteLog.Write_Log("API", "鍑哄簱鈥斿洖璋僂RP(澶辫触)", "璇锋眰澶辫触", new { 璇锋眰鎶ユ枃 = postContent, 鎺ユ敹鎶ユ枃 = ex.Message });
+
                 // 澶勭悊鍏朵粬寮傚父
                 return WebResponseContent.Instance.Error($"澶勭悊澶辫触: {ex.Message}");
             }
@@ -3389,11 +3470,15 @@
             // 鍒ゆ柇Success鐨勫��
             if (response.Code == 0)
             {
+                WriteLog.Write_Log("API", "鍏ュ簱鈥斿洖璋僂RP(鎴愬姛)", "璇锋眰鎴愬姛", new { 璇锋眰鎶ユ枃 = feedbackInboundOrderERPs, 鎺ユ敹鎶ユ枃 = response });
+
                 // 濡傛灉Success涓簍rue锛岃繑鍥為渶瑕佺殑鍊硷紙杩欓噷浠ヨ繑鍥炴暣涓搷搴斿璞′负渚嬶級
                 return WebResponseContent.Instance.OK();
             }
             else
             {
+                WriteLog.Write_Log("API", "鍏ュ簱鈥斿洖璋僂RP(澶辫触)", "璇锋眰澶辫触", new { 璇锋眰鎶ユ枃 = feedbackInboundOrderERPs, 鎺ユ敹鎶ユ枃 = response });
+
                 // 濡傛灉Success涓篺alse锛屾姏鍑哄紓甯稿苟鍖呭惈閿欒淇℃伅
                 throw new Exception($"鎿嶄綔澶辫触: {response.Message ?? "鏈彁渚涢敊璇俊鎭�"}");
             }

--
Gitblit v1.9.3