From 7d3d385f0bdcf40b0c42d14ab526df318e04a433 Mon Sep 17 00:00:00 2001
From: pan <antony1029@163.com>
Date: 星期三, 10 十二月 2025 13:15:29 +0800
Subject: [PATCH] 提交

---
 项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs |  152 ++++++++++++++++++++++++++++++--------------------
 1 files changed, 91 insertions(+), 61 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 464a681..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"
@@ -297,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)
                 {
@@ -568,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)
                 {
@@ -683,16 +696,23 @@
                 {
                     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 () =>
@@ -737,60 +757,62 @@
         {
             try
             {
+              
+           
                 // 鑾峰彇鍙楀奖鍝嶇殑璁㈠崟鏄庣粏ID锛堝幓閲嶏級
-                var affectedDetailIds = returnLocks
-                    .Select(x => x.OrderDetailId)
-                    .Distinct()
-                    .ToList();
+                //var affectedDetailIds = returnLocks
+                //    .Select(x => x.OrderDetailId)
+                //    .Distinct()
+                //    .ToList();
 
-                if (!affectedDetailIds.Any())
-                {
-                    _logger.LogInformation($"娌℃湁鍙楀奖鍝嶇殑璁㈠崟鏄庣粏 - OrderNo: {orderNo}");
-                    return;
-                }
+                //if (!affectedDetailIds.Any())
+                //{
+                //    _logger.LogInformation($"娌℃湁鍙楀奖鍝嶇殑璁㈠崟鏄庣粏 - OrderNo: {orderNo}");
+                //    return;
+                //}
 
-                _logger.LogInformation($"鏇存柊{affectedDetailIds.Count}涓彈褰卞搷鐨勮鍗曟槑缁� - OrderNo: {orderNo}");
+                //_logger.LogInformation($"鏇存柊{affectedDetailIds.Count}涓彈褰卞搷鐨勮鍗曟槑缁� - OrderNo: {orderNo}");
 
-                foreach (var detailId in affectedDetailIds)
-                {
-                    // 閲嶆柊璁$畻璇ヨ鍗曟槑缁嗙殑閿佸畾鏁伴噺
-                    decimal currentLockQty = await CalculateOrderDetailLockQuantity(detailId);
+                //foreach (var detailId in affectedDetailIds)
+                //{
+                //    // 閲嶆柊璁$畻璇ヨ鍗曟槑缁嗙殑閿佸畾鏁伴噺
+                //    decimal currentLockQty = await CalculateOrderDetailLockQuantity(detailId);
 
-                    // 妫�鏌ユ暟鎹竴鑷存��
-                    if (currentLockQty < 0)
-                    {
-                        _logger.LogWarning($"閿佸畾鏁伴噺璁$畻涓鸿礋鍊� - OrderDetailId: {detailId}, 褰撳墠鍊�: {currentLockQty}锛岄噸缃负0");
-                        currentLockQty = 0;
-                    }
+                //    // 妫�鏌ユ暟鎹竴鑷存��
+                //    if (currentLockQty < 0)
+                //    {
+                //        _logger.LogWarning($"閿佸畾鏁伴噺璁$畻涓鸿礋鍊� - OrderDetailId: {detailId}, 褰撳墠鍊�: {currentLockQty}锛岄噸缃负0");
+                //        currentLockQty = 0;
+                //    }
 
-                    // 鑾峰彇璁㈠崟鏄庣粏
-                    var orderDetail = await _outboundOrderDetailService.Db.Queryable<Dt_OutboundOrderDetail>()
-                        .FirstAsync(x => x.Id == detailId);
+                //    // 鑾峰彇璁㈠崟鏄庣粏
+                //    var orderDetail = await _outboundOrderDetailService.Db.Queryable<Dt_OutboundOrderDetail>()
+                //        .FirstAsync(x => x.Id == detailId);
 
-                    if (orderDetail == null)
-                    {
-                        _logger.LogWarning($"鏈壘鍒拌鍗曟槑缁� - OrderDetailId: {detailId}");
-                        continue;
-                    }
+                //    if (orderDetail == null)
+                //    {
+                //        _logger.LogWarning($"鏈壘鍒拌鍗曟槑缁� - OrderDetailId: {detailId}");
+                //        continue;
+                //    }
 
-                    // 鏇存柊閿佸畾鏁伴噺
-                    if (orderDetail.LockQuantity != currentLockQty)
-                    {
-                        await _outboundOrderDetailService.Db.Updateable<Dt_OutboundOrderDetail>()
-                            .SetColumns(it => new Dt_OutboundOrderDetail
-                            {
-                                LockQuantity = currentLockQty,
-                            })
-                            .Where(it => it.Id == detailId)
-                            .ExecuteCommandAsync();
+                //    // 鏇存柊閿佸畾鏁伴噺
+                //    if (orderDetail.LockQuantity != currentLockQty)
+                //    {
+                //        await _outboundOrderDetailService.Db.Updateable<Dt_OutboundOrderDetail>()
+                //            .SetColumns(it => new Dt_OutboundOrderDetail
+                //            {
+                //                LockQuantity = currentLockQty,
+                //            })
+                //            .Where(it => it.Id == detailId)
+                //            .ExecuteCommandAsync();
 
-                        _logger.LogInformation($"鏇存柊璁㈠崟鏄庣粏閿佸畾鏁伴噺 - OrderDetailId: {detailId}, " +
-                                              $"鏃у��: {orderDetail.LockQuantity}, 鏂板��: {currentLockQty}");
-                    }
+                //        _logger.LogInformation($"鏇存柊璁㈠崟鏄庣粏閿佸畾鏁伴噺 - OrderDetailId: {detailId}, " +
+                //                              $"鏃у��: {orderDetail.LockQuantity}, 鏂板��: {currentLockQty}");
+                //    }
 
-                    // 鏇存柊璁㈠崟鏄庣粏鐘舵��
-                    await UpdateOrderDetailStatus(orderDetail);
-                }
+                //    // 鏇存柊璁㈠崟鏄庣粏鐘舵��
+                //    await UpdateOrderDetailStatus(orderDetail);
+                //}
             }
             catch (Exception ex)
             {
@@ -939,6 +961,7 @@
                     {
                         hasInProgress = true;
                     }
+                    await UpdateOrderDetailStatus(detail);
                 }
 
                 var outboundOrder = await _outboundOrderService.Db.Queryable<Dt_OutboundOrder>()
@@ -976,6 +999,7 @@
 
                     _logger.LogInformation($"鏇存柊璁㈠崟鐘舵�� - OrderNo: {orderNo}, 鏃х姸鎬�: {outboundOrder.OrderStatus}, 鏂扮姸鎬�: {newStatus}");
                 }
+               
             }
             catch (Exception ex)
             {
@@ -1045,7 +1069,7 @@
                 if (allCompleted && newStatus == (int)OutOrderStatusEnum.鍑哄簱瀹屾垚)
                 {
 
-                    if (outboundOrder.OrderType == OutOrderTypeEnum.Allocate.ObjToInt())
+                    if (outboundOrder.OrderType == OutOrderTypeEnum.Allocate.ObjToInt() || outboundOrder.OrderType == OutOrderTypeEnum.InternalAllocat.ObjToInt())
                     {
                         var allocate = _allocateService.Repository.QueryData(x => x.UpperOrderNo == outboundOrder.UpperOrderNo).First();
                         var allocatefeedmodel = new AllocateDto
@@ -1280,8 +1304,14 @@
                     _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