From 6b6c66cd99a4e73eea9bc68c8d7c63fd08180fb9 Mon Sep 17 00:00:00 2001
From: pan <antony1029@163.com>
Date: 星期二, 18 十一月 2025 16:12:46 +0800
Subject: [PATCH] 提交

---
 项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs |  107 +++++++++++++++++++++++++++++++++++++++++++++++++----
 1 files changed, 98 insertions(+), 9 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 8113068..c8152ac 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"
@@ -16,6 +16,7 @@
 #endregion << 鐗� 鏈� 娉� 閲� >>
 
 using AutoMapper;
+using Dm.filter;
 using MailKit.Search;
 using Microsoft.Extensions.Logging;
 using Newtonsoft.Json;
@@ -108,6 +109,7 @@
             _outStockLockInfoService = outStockLockInfoService;
         }
 
+
         /// <summary>
         /// 
         /// </summary>
@@ -118,6 +120,7 @@
             try
             {
                 Dt_Task task;
+
                 if (int.TryParse(taskNum, out var newTaskNum))
                 {
                     task = BaseDal.QueryFirst(x => x.TaskNum == newTaskNum);
@@ -130,6 +133,7 @@
                 {
                     return WebResponseContent.Instance.Error("鏈壘鍒颁换鍔′俊鎭�");
                 }
+                _logger.LogInformation($"TaskService TaskCompleted: {JsonConvert.SerializeObject(task)} , {task.TaskType} ");
 
                 MethodInfo? methodInfo = GetType().GetMethod(((TaskTypeEnum)task.TaskType) + "TaskCompleted");
                 if (methodInfo != null)
@@ -144,6 +148,7 @@
             }
             catch (Exception ex)
             {
+                _logger.LogError($"TaskService TaskCompleted:  {ex.Message} ");
                 return WebResponseContent.Instance.Error(ex.Message);
             }
         }
@@ -259,15 +264,16 @@
 
                         };
 
-                        var groupedData = inboundOrder.Details.GroupBy(item => new { item.MaterielCode, item.SupplyCode, item.BatchNo, item.lineNo, item.BarcodeUnit, item.WarehouseCode})
+                        var groupedData = inboundOrder.Details.GroupBy(item => new { item.MaterielCode, item.SupplyCode, item.BatchNo, item.lineNo, item.BarcodeUnit, item.WarehouseCode })
                            .Select(group => new FeedbackInboundDetailsModel
                            {
                                materialCode = group.Key.MaterielCode,
                                supplyCode = group.Key.SupplyCode,
                                batchNo = group.Key.BatchNo,
                                lineNo = group.Key.lineNo,
-                               warehouseCode = group.Key.WarehouseCode ,
-                              // warehouseCode= "1072",
+                               warehouseCode = group.Key.WarehouseCode,
+                               qty=group.Sum(x=>x.BarcodeQty),
+                               // warehouseCode= "1072",
                                unit = group.Key.BarcodeUnit,
                                barcodes = group.Select(row => new FeedbackBarcodesModel
                                {
@@ -276,20 +282,58 @@
                                }).ToList()
                            }).ToList();
                         feedmodel.details = groupedData;
-                        
+
                         _invokeMESService.FeedbackInbound(feedmodel);
                     }
 
                 }
             }
-            catch (Exception ex) {
+            catch (Exception ex)
+            {
                 _logger.LogInformation("InboundTaskCompleted 鍥炲啓MES澶辫触:  " + ex.Message);
             }
 
             return WebResponseContent.Instance.OK();
         }
 
+        public WebResponseContent OutboundTaskCompleted(Dt_Task task)
+        {
+            _logger.LogInformation($"TaskService  OutboundTaskCompleted: {task.TaskNum}");
+            //鏌ヨ揣浣�
+            Dt_LocationInfo locationInfo = _locationInfoService.Repository.QueryFirst(x => x.LocationCode == task.SourceAddress);
+            if (locationInfo == null)
+            {
+                return WebResponseContent.Instance.Error($"鏈壘鍒板搴旂殑缁堢偣璐т綅淇℃伅");
+            }
+            locationInfo.LocationStatus = LocationStatusEnum.Free.ObjToInt();
+            _locationInfoService.Repository.UpdateData(locationInfo);
 
+            var outloks = _outStockLockInfoService.Db.Queryable<Dt_OutStockLockInfo>().Where(x => x.TaskNum == task.TaskNum).ToList();
+
+            var stockids = outloks.Select(x => x.StockId).ToList();
+            
+            _stockService.StockInfoService.Db.Updateable<Dt_StockInfo>()
+                                  .SetColumns(it => new Dt_StockInfo
+                                  {
+                                      StockStatus = StockStatusEmun.鍑哄簱閿佸畾.ObjToInt()
+                                  })
+                                  .Where(it => stockids.Contains(it.Id))
+                                  .ExecuteCommand();
+
+            _stockService.StockInfoDetailService.Db.Updateable<Dt_StockInfoDetail>()
+                                  .SetColumns(it => new Dt_StockInfoDetail
+                                  {
+                                      Status = StockStatusEmun.鍑哄簱閿佸畾.ObjToInt()
+                                  })
+                                  .Where(it => stockids.Contains( it.StockId))
+                                  .ExecuteCommand();
+ 
+
+
+            return WebResponseContent.Instance.OK();
+
+
+        }
         public async Task<WebResponseContent> InEmptyTaskCompleted(Dt_Task task)
         {
 
@@ -343,14 +387,58 @@
             }
         }
 
+        public 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)
+            {
+                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($"鏈壘鍒板搴旂殑缁堢偣璐т綅淇℃伅");
+            }
+            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);
+
+            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();
+        }
 
         public async Task<WebResponseContent> OutEmptyTaskCompleted(Dt_Task task)
         {
             WebResponseContent content = new WebResponseContent();
             try
             {
-                Dt_StockInfo stockInfo = _stockRepository.Db.Queryable<Dt_StockInfo>().Where(x => x.PalletCode == task.PalletCode  ).First();
+                Dt_StockInfo stockInfo = _stockRepository.Db.Queryable<Dt_StockInfo>().Where(x => x.PalletCode == task.PalletCode).First();
                 if (stockInfo == null)
                 {
                     return WebResponseContent.Instance.Error($"鏈壘鍒版墭鐩樺搴旂殑搴撳瓨淇℃伅");
@@ -362,7 +450,7 @@
                     return content.Error($"鏈壘鍒板搴旂殑缁堢偣璐т綅淇℃伅");
                 }
 
-               
+
                 int beforeStatus = locationInfo.LocationStatus;
 
                 locationInfo.LocationStatus = LocationStatusEnum.Free.ObjToInt();
@@ -382,13 +470,14 @@
             }
             catch (Exception ex)
             {
+                _logger.LogError($"TaskService OutEmptyTaskCompleted:  {ex.Message} ");
                 return await Task.FromResult(WebResponseContent.Instance.Error(ex.Message));
             }
         }
 
 
 
-      
+
         /// <summary>
         /// 鍥炲簱瀹屾垚鍥炶皟 
         public async Task<WebResponseContent> BackToStockComplete(Dt_Task task)
@@ -470,7 +559,7 @@
 
                 //  鏇存柊浠诲姟鐘舵�佷负宸插畬鎴�
                 task.TaskStatus = (int)TaskStatusEnum.Finish;
-             
+
                 await Db.Updateable(task).ExecuteCommandAsync();
 
                 _unitOfWorkManage.CommitTran();

--
Gitblit v1.9.3