From 4f2e9f2178864f37580e3b82e0a489e9d74130ca Mon Sep 17 00:00:00 2001
From: pan <antony1029@163.com>
Date: 星期一, 24 十一月 2025 15:10:03 +0800
Subject: [PATCH] 提交

---
 项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService_Inbound.cs |    2 
 项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs         |  124 ++++++++++++++++++++++-------------------
 2 files changed, 68 insertions(+), 58 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 8682865..df616ba 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"
@@ -265,8 +265,8 @@
                                 OperationType = 1,
                                 Operator = inboundOrder.Operator,
                                 OrderNo = inboundOrder.UpperOrderNo,
-                                fromWarehouse = allocate?.FromWarehouse??"",
-                                toWarehouse = allocate?.ToWarehouse??"",
+                                fromWarehouse = allocate?.FromWarehouse ?? "",
+                                toWarehouse = allocate?.ToWarehouse ?? "",
                                 Details = new List<AllocateDtoDetail>()
 
                             };
@@ -457,61 +457,71 @@
         public async Task<WebResponseContent> InPickTaskCompleted(Dt_Task task)
         {
             _logger.LogInformation($"TaskService  InPickTaskCompleted: {task.TaskNum}");
-            //鏌ュ簱瀛�
-            Dt_StockInfo stockInfo = _stockRepository.Db.Queryable<Dt_StockInfo>().Includes(x => x.Details).Where(x => x.PalletCode == task.PalletCode).First();
-            if (stockInfo == null)
+            try
             {
-                return WebResponseContent.Instance.Error($"鏈壘鍒版墭鐩樺搴旂殑缁勭洏淇℃伅");
+                //鏌ュ簱瀛�
+                Dt_StockInfo stockInfo = _stockRepository.Db.Queryable<Dt_StockInfo>().Includes(x => x.Details).Where(x => x.PalletCode == task.PalletCode).First();
+                if (stockInfo == null)
+                {
+                    return WebResponseContent.Instance.Error($"鏈壘鍒版墭鐩樺搴旂殑缁勭洏淇℃伅");
+                }
+                if (stockInfo.Details.Count == 0 && stockInfo.PalletType != PalletTypeEnum.Empty.ObjToInt())
+                {
+                    return WebResponseContent.Instance.Error($"鏈壘鍒拌鎵樼洏搴撳瓨鏄庣粏淇℃伅");
+                }
+                //鏌ヨ揣浣�
+                Dt_LocationInfo locationInfo = _locationInfoService.Repository.QueryFirst(x => x.LocationCode == task.TargetAddress);
+                if (locationInfo == null)
+                {
+                    return WebResponseContent.Instance.Error($"鏈壘鍒板搴旂殑缁堢偣璐т綅淇℃伅");
+                }
+                // 鑾峰彇鎵�鏈夊洖搴撲腑鐨勫嚭搴撻攣瀹氳褰�
+                var returnLocks = _outStockLockInfoService.Db.Queryable<Dt_OutStockLockInfo>()
+                    .Where(it => it.OrderNo == task.OrderNo && it.PalletCode == task.PalletCode && it.Status == (int)OutLockStockStatusEnum.鍥炲簱涓�)
+                    .ToList();
+                // 鏇存柊鍑哄簱閿佸畾璁板綍鐘舵�佷负鍥炲簱瀹屾垚
+                foreach (var lockInfo in returnLocks)
+                {
+                    lockInfo.Status = (int)OutLockStockStatusEnum.宸插洖搴�;
+                }
+                _outStockLockInfoService.Db.Updateable(returnLocks).ExecuteCommand();                             
+
+                stockInfo.LocationCode = task.TargetAddress;
+                stockInfo.StockStatus = StockStatusEmun.鍏ュ簱瀹屾垚.ObjToInt();
+                if (stockInfo.Details != null && stockInfo.Details.Any())
+                {
+                    stockInfo.Details.ForEach(x =>
+                    {
+                        x.Status = StockStatusEmun.鍏ュ簱瀹屾垚.ObjToInt();
+                    });
+                    _stockService.StockInfoDetailService.Repository.UpdateData(stockInfo.Details);
+                }
+
+                _stockService.StockInfoService.Repository.UpdateData(stockInfo);
+            
+                await ProcessStockDetailsForReturn(task, stockInfo.Id);
+
+                await DeleteZeroQuantityStockDetails(stockInfo.Id);
+
+                if (stockInfo.PalletType == PalletTypeEnum.Empty.ObjToInt())
+                {
+                    locationInfo.LocationStatus = LocationStatusEnum.Pallet.ObjToInt();
+                }
+                else
+                {
+                    locationInfo.LocationStatus = LocationStatusEnum.InStock.ObjToInt();
+                }
+                _locationInfoService.Repository.UpdateData(locationInfo);
+
+                task.TaskStatus = TaskStatusEnum.Finish.ObjToInt();
+
+                BaseDal.DeleteAndMoveIntoHty(task, App.User.UserId == 0 ? OperateTypeEnum.鑷姩瀹屾垚 : OperateTypeEnum.浜哄伐瀹屾垚);
+                BaseDal.DeleteData(task);
             }
-            if (stockInfo.Details.Count == 0 && stockInfo.PalletType != PalletTypeEnum.Empty.ObjToInt())
+            catch (Exception ex)
             {
-                return WebResponseContent.Instance.Error($"鏈壘鍒拌鎵樼洏搴撳瓨鏄庣粏淇℃伅");
+                _logger.LogInformation($"TaskService  InPickTaskCompleted: {task.TaskNum} , {ex.Message}");
             }
-            //鏌ヨ揣浣�
-            Dt_LocationInfo locationInfo = _locationInfoService.Repository.QueryFirst(x => x.LocationCode == task.TargetAddress);
-            if (locationInfo == null)
-            {
-                return WebResponseContent.Instance.Error($"鏈壘鍒板搴旂殑缁堢偣璐т綅淇℃伅");
-            }
-            // 鑾峰彇鎵�鏈夊洖搴撲腑鐨勫嚭搴撻攣瀹氳褰�
-            var returnLocks = _outStockLockInfoService.Db.Queryable<Dt_OutStockLockInfo>()
-                .Where(it => it.OrderNo == task.OrderNo && it.PalletCode == task.PalletCode && it.Status == (int)OutLockStockStatusEnum.鍥炲簱涓�)
-                .ToList();
-            // 鏇存柊鍑哄簱閿佸畾璁板綍鐘舵�佷负鍥炲簱瀹屾垚
-            foreach (var lockInfo in returnLocks)
-            {
-                lockInfo.Status = (int)OutLockStockStatusEnum.宸插洖搴�;
-            }
-            _outStockLockInfoService.Db.Updateable(returnLocks).ExecuteCommand();
-
-            await DeleteZeroQuantityStockDetails(stockInfo.Id);
-
-            stockInfo.LocationCode = task.TargetAddress;
-            stockInfo.StockStatus = StockStatusEmun.鍏ュ簱瀹屾垚.ObjToInt();
-            stockInfo.Details.ForEach(x =>
-            {
-                x.Status = StockStatusEmun.鍏ュ簱瀹屾垚.ObjToInt();
-            });
-            _stockService.StockInfoService.Repository.UpdateData(stockInfo);
-            _stockService.StockInfoDetailService.Repository.UpdateData(stockInfo.Details);
-            await ProcessStockDetailsForReturn(task, stockInfo.Id);
-
-    
-
-            if (stockInfo.PalletType == PalletTypeEnum.Empty.ObjToInt())
-            {
-                locationInfo.LocationStatus = LocationStatusEnum.Pallet.ObjToInt();
-            }
-            else
-            {
-                locationInfo.LocationStatus = LocationStatusEnum.InStock.ObjToInt();
-            }
-            _locationInfoService.Repository.UpdateData(locationInfo);
-
-            task.TaskStatus = TaskStatusEnum.Finish.ObjToInt();
-
-            BaseDal.DeleteAndMoveIntoHty(task, App.User.UserId == 0 ? OperateTypeEnum.鑷姩瀹屾垚 : OperateTypeEnum.浜哄伐瀹屾垚);
-
             return WebResponseContent.Instance.OK();
         }
 
@@ -526,7 +536,7 @@
                 var deleteCount = await _stockService.StockInfoDetailService.Db.Deleteable<Dt_StockInfoDetail>()
                     .Where(x => x.StockId == stockId &&
                                x.StockQuantity == 0 &&
-                               (x.Status==StockStatusEmun.鍑哄簱瀹屾垚.ObjToInt()|| x.Status==
+                               (x.Status == StockStatusEmun.鍑哄簱瀹屾垚.ObjToInt() || x.Status ==
                                           StockStatusEmun.鍏ュ簱瀹屾垚.ObjToInt())) // 鍙垹闄ゅ凡瀹屾垚鐘舵�佺殑闆跺簱瀛�
                     .ExecuteCommandAsync();
 
@@ -550,14 +560,14 @@
             var stockDetails = await _stockService.StockInfoDetailService.Db.Queryable<Dt_StockInfoDetail>()
                 .Where(x => x.StockId == stockId &&
                            x.StockQuantity > 0 &&
-                          ( x.Status == StockStatusEmun.鍑哄簱閿佸畾.ObjToInt()|| x.Status==
+                          (x.Status == StockStatusEmun.鍑哄簱閿佸畾.ObjToInt() || x.Status ==
                                       StockStatusEmun.鍏ュ簱纭.ObjToInt()))  // 鍖呮嫭鍑哄簱閿佸畾鍜屽叆搴撶‘璁ょ殑
                 .ToListAsync();
 
             foreach (var detail in stockDetails)
             {
-          
-                detail.Status = StockStatusEmun.鍏ュ簱瀹屾垚.ObjToInt();              
+
+                detail.Status = StockStatusEmun.鍏ュ簱瀹屾垚.ObjToInt();
                 detail.OutboundQuantity = 0;  // 娓呯┖鍑哄簱鏁伴噺       
 
                 _logger.LogInformation($"鏇存柊搴撳瓨鏄庣粏鐘舵�� - 鏉$爜: {detail.Barcode}, 鏁伴噺: {detail.StockQuantity}");
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_Inbound.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_Inbound.cs"
index a7d3558..629e46f 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_Inbound.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_Inbound.cs"
@@ -29,7 +29,7 @@
         {
             try
             {
-                Dt_Task dbtask = Repository.QueryFirst(x => x.PalletCode == palletCode);
+                Dt_Task dbtask = Repository.Db.Queryable<Dt_Task>().Where(x => x.PalletCode == palletCode).OrderByDescending(x=>x.CreateDate).First();
                 if (dbtask != null)
                 {
                     if (dbtask.TaskType == TaskTypeEnum.Outbound.ObjToInt())

--
Gitblit v1.9.3