From a2f948006c6c7e918ba4f2e66d477cc2d5017a75 Mon Sep 17 00:00:00 2001
From: heshaofeng <heshaofeng@hnkhzn.com>
Date: 星期三, 10 十二月 2025 21:49:58 +0800
Subject: [PATCH] Merge branch 'master' of http://115.159.85.185:8098/r/ZhongRui/ALDbanyunxiangmu

---
 项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs |  102 +++++++++++++++++++++++++++++++++++++--------------
 1 files changed, 74 insertions(+), 28 deletions(-)

diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs"
index ca42579..03574dc 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs"
@@ -130,17 +130,18 @@
             _task_HtyService = task_HtyService;
         }
 
-        public async Task TaskStatusChange(string taskNum,TaskStatusEnum taskStatusEnum)
+        public async Task TaskStatusChange(string taskNum, TaskStatusEnum taskStatusEnum)
         {
             if (int.TryParse(taskNum, out var newTaskNum))
             {
-                await Db.Updateable<Dt_Task>().SetColumns(it => new Dt_Task {
-                        TaskStatus = taskStatusEnum.ObjToInt()
-                    })
+                await Db.Updateable<Dt_Task>().SetColumns(it => new Dt_Task
+                {
+                    TaskStatus = taskStatusEnum.ObjToInt()
+                })
                     .Where(it => it.TaskNum == newTaskNum)
                     .ExecuteCommandAsync();
             }
-              
+
         }
 
         /// <summary>
@@ -296,10 +297,17 @@
             {
                 await Db.Deleteable(task).ExecuteCommandAsync();
             }
-            _locationStatusChangeRecordService.AddLocationStatusChangeRecord(locationInfo, beforeStatus, StockChangeType.Inbound.ObjToInt(), "", task.TaskNum);
-
-            _recordService.StockQuantityChangeRecordService.AddStockChangeRecord(stockInfo, stockInfo.Details, beforeQuantity, stockInfo.Details.Sum(x => x.StockQuantity) + beforeQuantity, WIDESEA_Common.StockEnum.StockChangeType.MaterielGroup);
             try
+            {
+                _locationStatusChangeRecordService.AddLocationStatusChangeRecord(locationInfo, beforeStatus, StockChangeType.Inbound.ObjToInt(), "", task.TaskNum);
+
+                _recordService.StockQuantityChangeRecordService.AddStockChangeRecord(stockInfo, stockInfo.Details, beforeQuantity, stockInfo.Details.Sum(x => x.StockQuantity) + beforeQuantity, WIDESEA_Common.StockEnum.StockChangeType.MaterielGroup);
+            }
+            catch(Exception ex)
+            {
+                _logger.LogInformation($"InboundTaskCompleted AddLocationStatusChangeRecord : {ex.Message} " );
+            }
+                try
             {
                 foreach (var inboundOrder in inboundOrders)
                 {
@@ -450,10 +458,17 @@
                             var feedbackresult = await _invokeMESService.FeedbackInbound(feedmodel);
                             if (feedbackresult != null && feedbackresult.code == 200)
                             {
-                                _inboundOrderService.Db.Updateable<Dt_InboundOrder>().SetColumns(it => new Dt_InboundOrder { ReturnToMESStatus = 1 })
+                                _inboundOrderService.Db.Updateable<Dt_InboundOrder>().SetColumns(it => new Dt_InboundOrder { ReturnToMESStatus = 1, Remark = "" })
                                 .Where(it => it.Id == inboundOrder.Id).ExecuteCommand();
                                 _inboundOrderDetailService.Db.Updateable<Dt_InboundOrderDetail>().SetColumns(it => new Dt_InboundOrderDetail { ReturnToMESStatus = 1 })
                                 .Where(it => it.OrderId == inboundOrder.Id).ExecuteCommand();
+                            }
+                            else
+                            {
+                                _inboundOrderService.Db.Updateable<Dt_InboundOrder>().SetColumns(it => new Dt_InboundOrder { ReturnToMESStatus = 2, Remark = feedbackresult.message })
+                                .Where(it => it.Id == inboundOrder.Id).ExecuteCommand();
+                                _inboundOrderDetailService.Db.Updateable<Dt_InboundOrderDetail>().SetColumns(it => new Dt_InboundOrderDetail { ReturnToMESStatus = 2 })
+                               .Where(it => it.OrderId == inboundOrder.Id).ExecuteCommand();
                             }
                         }
                     }
@@ -560,8 +575,14 @@
                 {
                     await Db.Deleteable(task).ExecuteCommandAsync();
                 }
-                _locationStatusChangeRecordService.AddLocationStatusChangeRecord(locationInfo, beforelocationStatus, StockChangeType.Inbound.ObjToInt(), "", task.TaskNum);
-
+                try
+                {
+                    _locationStatusChangeRecordService.AddLocationStatusChangeRecord(locationInfo, beforelocationStatus, StockChangeType.Inbound.ObjToInt(), "", task.TaskNum);
+                }
+                catch(Exception ex)
+                {
+                    _logger.LogInformation($"InEmptyTaskCompleted AddLocationStatusChangeRecord : {ex.Message} ");
+                }
 
                 if (outboundOrder != null)
                 {
@@ -586,7 +607,7 @@
             _logger.LogInformation($"TaskService InPickTaskCompleted: {task.TaskNum}");
 
             try
-            {              
+            {
                 // 鏌ュ簱瀛�
                 Dt_StockInfo stockInfo = await _stockRepository.Db.Queryable<Dt_StockInfo>()
                     .Includes(x => x.Details)
@@ -624,7 +645,7 @@
                 // 鏇存柊鍑哄簱閿佸畾璁板綍鐘舵�佷负鍥炲簱瀹屾垚
                 foreach (var lockInfo in returnLocks)
                 {
-                    lockInfo.Status = (int)OutLockStockStatusEnum.宸插洖搴�; 
+                    lockInfo.Status = (int)OutLockStockStatusEnum.宸插洖搴�;
                 }
 
                 if (returnLocks.Any())
@@ -675,17 +696,24 @@
                 {
                     await Db.Deleteable(task).ExecuteCommandAsync();
                 }
-                // 璁板綍璐т綅鐘舵�佸彉鏇�
-                _locationStatusChangeRecordService.AddLocationStatusChangeRecord(
-                    locationInfo,
-                    beforelocationStatus,
-                    StockChangeType.Inbound.ObjToInt(),
-                    "",
-                    task.TaskNum
-                );
+             
                 await RecalculateOrderStatus(task.OrderNo);
+                try
+                {
+                    // 璁板綍璐т綅鐘舵�佸彉鏇�
+                    _locationStatusChangeRecordService.AddLocationStatusChangeRecord(
+                        locationInfo,
+                        beforelocationStatus,
+                        StockChangeType.Inbound.ObjToInt(),
+                        "",
+                        task.TaskNum
+                    );
+                }
+                catch (Exception ex)
+                {
+                    _logger.LogInformation($"InPickTaskCompleted AddLocationStatusChangeRecord : {ex.Message} ");
+                }
 
-      
                 _logger.LogInformation($"鎵樼洏鍥炲簱瀹屾垚澶勭悊鎴愬姛 - 浠诲姟鍙�: {task.TaskNum}, 鎵樼洏: {task.PalletCode}, 璁㈠崟: {task.OrderNo}");
                 _ = Task.Run(async () =>
                 {
@@ -964,7 +992,7 @@
                     await _outboundOrderService.Db.Updateable<Dt_OutboundOrder>()
                         .SetColumns(x => new Dt_OutboundOrder
                         {
-                            OrderStatus = newStatus, 
+                            OrderStatus = newStatus,
                         })
                         .Where(x => x.OrderNo == orderNo)
                         .ExecuteCommandAsync();
@@ -1119,7 +1147,7 @@
                                 await _outboundOrderService.Db.Updateable<Dt_OutboundOrder>()
                                       .SetColumns(x => new Dt_OutboundOrder
                                       {
-                                          ReturnToMESStatus = 1, 
+                                          ReturnToMESStatus = 1,
                                       }).Where(x => x.OrderNo == orderNo).ExecuteCommandAsync();
                             }
                         }
@@ -1204,8 +1232,20 @@
                                     .ExecuteCommandAsync();
 
                                 await _outboundOrderService.Db.Updateable<Dt_OutboundOrder>()
-                                    .SetColumns(x => x.ReturnToMESStatus == 1)
+                                    .SetColumns(it => new Dt_OutboundOrder { ReturnToMESStatus = 2, Remark = "" })
                                     .Where(x => x.OrderNo == orderNo)
+                                    .ExecuteCommandAsync();
+                            }
+                            else
+                            {
+                                await _outboundOrderDetailService.Db.Updateable<Dt_OutboundOrderDetail>()
+                                 .SetColumns(x => x.ReturnToMESStatus == 2)
+                                 .Where(x => x.OrderId == outboundOrder.Id)
+                                 .ExecuteCommandAsync();
+
+                                await _outboundOrderService.Db.Updateable<Dt_OutboundOrder>()
+                                    .SetColumns(it => new Dt_OutboundOrder { ReturnToMESStatus = 2, Remark = result.message })
+                                     .Where(x => x.OrderNo == orderNo)
                                     .ExecuteCommandAsync();
                             }
                         }
@@ -1260,12 +1300,18 @@
 
                 var stockresult = _stockService.StockInfoService.Repository.DeleteAndMoveIntoHty(stockInfo, App.User.UserId == 0 ? OperateTypeEnum.鑷姩瀹屾垚 : OperateTypeEnum.浜哄伐瀹屾垚);
                 if (!stockresult)
-                { 
+                {
                     _stockRepository.Db.Deleteable(stockInfo).ExecuteCommand();
                 }
                 _stockService.StockInfoService.DeleteData(stockInfo);
-                _locationStatusChangeRecordService.AddLocationStatusChangeRecord(locationInfo, beforeStatus, StockChangeType.Outbound.ObjToInt(), stockInfo.Details.FirstOrDefault()?.OrderNo ?? "", task.TaskNum);
-
+                try
+                {
+                    _locationStatusChangeRecordService.AddLocationStatusChangeRecord(locationInfo, beforeStatus, StockChangeType.Outbound.ObjToInt(), stockInfo?.Details.FirstOrDefault()?.OrderNo ?? "", task.TaskNum);
+                }
+                catch (Exception ex)
+                {
+                    _logger.LogError($"TaskService OutEmptyTaskCompleted AddLocationStatusChangeRecord:  {ex.Message} ");
+                }
                 return await Task.FromResult(WebResponseContent.Instance.OK());
 
             }

--
Gitblit v1.9.3