From 988085fd00217ec0e9b8f8b0bb21b172ee9f9938 Mon Sep 17 00:00:00 2001
From: huangxiaoqiang <huangxiaoqiang@hnkhzn.com>
Date: 星期四, 11 十二月 2025 15:11:35 +0800
Subject: [PATCH] Merge branch 'master' of http://115.159.85.185:8098/r/ZhongRui/ALDbanyunxiangmu

---
 项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_OutboundService/OutboundBatchPickingService.cs          |   22 +++--------
 项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_WMSServer/Controllers/Inbound/InboundOrderController.cs |    5 +-
 项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs                          |   68 +++++++++++++++++++++++++++++----
 3 files changed, 67 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_OutboundService/OutboundBatchPickingService.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_OutboundService/OutboundBatchPickingService.cs"
index 0eeaef1..a1e6320 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_OutboundService/OutboundBatchPickingService.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_OutboundService/OutboundBatchPickingService.cs"
@@ -943,7 +943,7 @@
 
 
         /// <summary>
-        /// 鎵ц鎵嬪姩鎷嗗寘閫昏緫 - 淇鐗堟湰
+        /// 鎵ц鎵嬪姩鎷嗗寘閫昏緫 
         /// </summary>
         private async Task<List<SplitResult>> ExecuteManualSplitLogic(Dt_OutStockLockInfo lockInfo, Dt_StockInfoDetail stockDetail,
             decimal splitQuantity, string palletCode)
@@ -1001,8 +1001,8 @@
                     MaterielCode = stockDetail.MaterielCode,
                     OrderNo = stockDetail.OrderNo,
                     BatchNo = stockDetail.BatchNo,
-                    StockQuantity = newStockQuantity,  // 淇锛氫娇鐢ㄦ纭殑鎷嗗寘鏁伴噺
-                    OutboundQuantity = 0,  // 鏂版潯鐮佸垵濮嬪嚭搴撴暟閲忎负0
+                    StockQuantity = newStockQuantity,   
+                    OutboundQuantity = 0,   
                     Barcode = newBarcode,
                     Status = (int)StockStatusEmun.鍑哄簱閿佸畾,
                     SupplyCode = stockDetail.SupplyCode,
@@ -3158,17 +3158,7 @@
             _logger.LogInformation($"闇�瑕佽嚜鍔ㄦ媶鍖� - 搴撳瓨: {stockDetail.StockQuantity}, 鍒嗛厤: {lockInfo.AssignQuantity}, 鎷嗗寘鏁伴噺: {splitQuantity}");
 
             // 鎵ц鑷姩鎷嗗寘
-            var splitResult = await ExecuteAutoSplitLogic(lockInfo, stockDetail, splitQuantity, palletCode);
-
-            // 灏嗘媶鍖呮暟閲忎紶閫掔粰璋冪敤鏂癸紝鐢ㄤ簬楠岃瘉
-            if (splitResult != null && splitResult.Any())
-            {
-                // 鍦ㄨ繑鍥炵粨鏋滀腑鎼哄甫鎷嗗寘鏁伴噺淇℃伅
-                foreach (var result in splitResult)
-                {
-                    result.quantityTotal = splitQuantity.ToString("F2");
-                }
-            }
+            var splitResult = await ExecuteAutoSplitLogic(lockInfo, stockDetail, splitQuantity,  palletCode);
 
             return splitResult;
         }
@@ -3178,7 +3168,7 @@
         /// 鍘熷垯锛氬彧鍒嗙鐗╃悊搴撳瓨锛屼笉鏀瑰彉鍘熻鍗曠殑浠讳綍鍒嗛厤鍜屽嚭搴撴暟閲�
         /// </summary>
         private async Task<List<SplitResult>> ExecuteAutoSplitLogic(Dt_OutStockLockInfo lockInfo, Dt_StockInfoDetail stockDetail,
-            decimal splitQuantity, string palletCode)
+            decimal splitQuantity,string palletCode)
         {
             _logger.LogInformation($"寮�濮嬫墽琛岃嚜鍔ㄦ媶鍖呴�昏緫 - 鍘熸潯鐮�: {stockDetail.Barcode}, 鎷嗗寘鏁伴噺: {splitQuantity}");
 
@@ -3269,7 +3259,7 @@
                 await RecordSplitHistory(lockInfo, stockDetail, splitQuantity, newBarcode, true, originalStockQty);
 
                 // 鍒涘缓鎷嗗寘缁撴灉鍒楄〃
-                var splitResults = CreateSplitResults(lockInfo, splitQuantity, lockInfo.AssignQuantity, newBarcode, stockDetail.Barcode);
+                var splitResults = CreateSplitResults(lockInfo, splitQuantity, stockDetail.StockQuantity, newBarcode, stockDetail.Barcode);
 
                 _logger.LogInformation($"鑷姩鎷嗗寘閫昏緫鎵ц瀹屾垚 - 鍒涘缓浜嗘湭鍒嗛厤鐨勫簱瀛樺拰閿佸畾璁板綍");
 
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 03574dc..b65d4c3 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"
@@ -303,11 +303,11 @@
 
                 _recordService.StockQuantityChangeRecordService.AddStockChangeRecord(stockInfo, stockInfo.Details, beforeQuantity, stockInfo.Details.Sum(x => x.StockQuantity) + beforeQuantity, WIDESEA_Common.StockEnum.StockChangeType.MaterielGroup);
             }
-            catch(Exception ex)
+            catch (Exception ex)
             {
-                _logger.LogInformation($"InboundTaskCompleted AddLocationStatusChangeRecord : {ex.Message} " );
+                _logger.LogInformation($"InboundTaskCompleted AddLocationStatusChangeRecord : {ex.Message} ");
             }
-                try
+            try
             {
                 foreach (var inboundOrder in inboundOrders)
                 {
@@ -579,7 +579,7 @@
                 {
                     _locationStatusChangeRecordService.AddLocationStatusChangeRecord(locationInfo, beforelocationStatus, StockChangeType.Inbound.ObjToInt(), "", task.TaskNum);
                 }
-                catch(Exception ex)
+                catch (Exception ex)
                 {
                     _logger.LogInformation($"InEmptyTaskCompleted AddLocationStatusChangeRecord : {ex.Message} ");
                 }
@@ -696,7 +696,7 @@
                 {
                     await Db.Deleteable(task).ExecuteCommandAsync();
                 }
-             
+
                 await RecalculateOrderStatus(task.OrderNo);
                 try
                 {
@@ -757,8 +757,8 @@
         {
             try
             {
-              
-           
+
+
                 // 鑾峰彇鍙楀奖鍝嶇殑璁㈠崟鏄庣粏ID锛堝幓閲嶏級
                 //var affectedDetailIds = returnLocks
                 //    .Select(x => x.OrderDetailId)
@@ -999,7 +999,7 @@
 
                     _logger.LogInformation($"鏇存柊璁㈠崟鐘舵�� - OrderNo: {orderNo}, 鏃х姸鎬�: {outboundOrder.OrderStatus}, 鏂扮姸鎬�: {newStatus}");
                 }
-               
+
             }
             catch (Exception ex)
             {
@@ -1136,8 +1136,33 @@
 
                                 allocatefeedmodel.Details.Add(detailModel);
                             }
+                            var groupedResult = allocatefeedmodel.Details.GroupBy(item => new
+                            {
+                                item.WarehouseCode,
+                                item.MaterialCode,
+                                item.Unit,
+                                item.LineNo
+                            }).Select(group => new AllocateDtoDetail
+                            {
+                                 WarehouseCode = group.Key.WarehouseCode,
+                                 MaterialCode = group.Key.MaterialCode,
+                                 LineNo = group.Key.LineNo,                              
+                                 Qty = group.Sum(x => x.Qty),  
+                                 Unit = group.Key.Unit, 
+                                 Barcodes = group.SelectMany(x => x.Barcodes) 
+                                                       .GroupBy(b => b.Barcode) 
+                                                       .Select(b => new BarcodeInfo
+                                                       {
+                                                           Barcode = b.Key,
+                                                           BatchNo = b.First().BatchNo,
+                                                           SupplyCode = b.First().SupplyCode,
+                                                           Qty = b.Max(x => x.Qty), 
+                                                           Unit = b.First().Unit
+                                                       }) .ToList()
+                             }) .ToList();
+                            allocatefeedmodel.Details = groupedResult;
 
-                            var result = await _invokeMESService.FeedbackAllocate(allocatefeedmodel);
+                          var result = await _invokeMESService.FeedbackAllocate(allocatefeedmodel);
                             if (result != null && result.code == 200)
                             {
                                 await _outboundOrderDetailService.Db.Updateable<Dt_OutboundOrderDetail>()
@@ -1222,6 +1247,31 @@
                                 }
                                 feedmodel.details.Add(detailModel);
                             }
+                            var groupedResult = feedmodel.details.GroupBy(item => new
+                            {
+                                item.warehouseCode,
+                                item.materialCode,
+                                item.unit,
+                                item.lineNo
+                            }).Select(group => new FeedbackOutboundDetailsModel
+                            {
+                                warehouseCode = group.Key.warehouseCode,
+                                materialCode = group.Key.materialCode,
+                                lineNo = group.Key.lineNo,
+                                qty = group.Sum(x => x.qty),
+                                unit = group.Key.unit,
+                                barcodes = group.SelectMany(x => x.barcodes)
+                                                       .GroupBy(b => b.barcode)
+                                                       .Select(b => new WIDESEA_DTO.Outbound.BarcodesModel
+                                                       {
+                                                           barcode = b.Key,
+                                                           batchNo = b.First().batchNo,
+                                                           supplyCode = b.First().supplyCode,
+                                                           qty = b.Max(x => x.qty),
+                                                           unit = b.First().unit
+                                                       }).ToList()
+                            }).ToList();
+                            feedmodel.details = groupedResult;
 
                             var result = await _invokeMESService.FeedbackOutbound(feedmodel);
                             if (result != null && result.code == 200)
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_WMSServer/Controllers/Inbound/InboundOrderController.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_WMSServer/Controllers/Inbound/InboundOrderController.cs"
index c91eb7f..34a6a2f 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_WMSServer/Controllers/Inbound/InboundOrderController.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_WMSServer/Controllers/Inbound/InboundOrderController.cs"
@@ -66,8 +66,7 @@
 
         [HttpPost, Route("Test"), AllowAnonymous, MethodParamsValidate]
         public async Task<WebResponseContent> Test()
-        {
-
+        {       
             //var originalTask = _taskRepository.Db.Queryable<Dt_Task>().First();
 
             //var result = _task_HtyService.DeleteAndMoveIntoHty(originalTask, OperateTypeEnum.浜哄伐鍒犻櫎);
@@ -91,7 +90,7 @@
             //var  ddddssss = "WSLOT" + DateTime.Now.ToString("yyyyMMddHHmmss") + ssss.ToString().PadLeft(5, '0');
             //erpApiService.GetSuppliersAsync();
 
-            erpApiService.GetMaterialUnitAsync();
+           // erpApiService.GetMaterialUnitAsync();
 
             //var sss = await _invokeMESService.NewMaterielToMes(new WIDESEA_DTO.Basic.MaterielToMesDTO
             //{

--
Gitblit v1.9.3