From 1a465495340bfea81b1e4d1db130399ccdf58fb4 Mon Sep 17 00:00:00 2001
From: pan <antony1029@163.com>
Date: 星期三, 03 十二月 2025 08:35:51 +0800
Subject: [PATCH] 提交

---
 项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_Model/Models/Outbound/Dt_PickingRecord.cs                          |    2 
 项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_OutboundService/OutboundPickingService.cs                          |   18 +-
 项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_WMSServer/Controllers/Outbound/PickingReturnController.cs          |    2 
 项目代码/WMS无仓储版/WIDESEA_WMSServer/.vs/WIDESEA_WMSServer/CopilotIndices/17.14.878.3237/CodeChunks.db-shm      |    0 
 项目代码/WMS无仓储版/WIDESEA_WMSServer/.vs/WIDESEA_WMSServer/CopilotIndices/17.14.878.3237/SemanticSymbols.db-shm |    0 
 项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs                                     |  134 ++++++----------
 项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_BasicService/InvokeMESService.cs                                   |  281 +++++++++++++++++++++++-----------
 7 files changed, 253 insertions(+), 184 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/.vs/WIDESEA_WMSServer/CopilotIndices/17.14.878.3237/CodeChunks.db-shm" "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/.vs/WIDESEA_WMSServer/CopilotIndices/17.14.878.3237/CodeChunks.db-shm"
new file mode 100644
index 0000000..fae3bf5
--- /dev/null
+++ "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/.vs/WIDESEA_WMSServer/CopilotIndices/17.14.878.3237/CodeChunks.db-shm"
Binary files differ
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/.vs/WIDESEA_WMSServer/CopilotIndices/17.14.878.3237/SemanticSymbols.db-shm" "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/.vs/WIDESEA_WMSServer/CopilotIndices/17.14.878.3237/SemanticSymbols.db-shm"
new file mode 100644
index 0000000..332c120
--- /dev/null
+++ "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/.vs/WIDESEA_WMSServer/CopilotIndices/17.14.878.3237/SemanticSymbols.db-shm"
Binary files differ
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_BasicService/InvokeMESService.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_BasicService/InvokeMESService.cs"
index 59d58ee..d085b30 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_BasicService/InvokeMESService.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_BasicService/InvokeMESService.cs"
@@ -1,4 +1,5 @@
 锘縰sing Dm.filter;
+using MailKit.Search;
 using Microsoft.Extensions.Logging;
 using Newtonsoft.Json;
 using Org.BouncyCastle.Asn1.Ocsp;
@@ -8,6 +9,7 @@
 using System.Linq;
 using System.Net;
 using System.Net.Http;
+using System.Reflection.Metadata;
 using System.Security.Policy;
 using System.Text;
 using System.Threading.Tasks;
@@ -26,6 +28,30 @@
 
 namespace WIDESEA_BasicService
 {
+    public class TransferDataDto
+    {
+        public DateTime TransferTime { get; set; }
+        public List<TransferItemDto> Items { get; set; }
+    }
+
+    public class TransferItemDto
+    {
+        public string MaterialCode { get; set; }
+        public decimal TotalQuantity { get; set; }
+        public List<LocationInfoDto> Locations { get; set; }
+    }
+    public class LocationInfoDto
+    {
+        public string LocationCode { get; set; }
+        public decimal Quantity { get; set; }
+        public List<BarcodeInfoDto> Barcodes { get; set; }
+    }
+
+    public class BarcodeInfoDto
+    {
+        public string Barcode { get; set; }
+        public decimal Quantity { get; set; }
+    }
     public class InvokeMESService : IInvokeMESService
     {
         private readonly IHttpClientFactory _httpClientFactory;
@@ -37,11 +63,12 @@
         private readonly IRepository<Dt_StockInfoDetail> _stockInfoDetailRepository;
         private readonly IRepository<Dt_StockInfo> _stockInfoRepository;
         private readonly IRepository<Dt_InboundOrder> _inboundOrderRepository;
+        private readonly IRepository<Dt_PickingRecord> _pickingRecoreRepository;
         private readonly IMaterialUnitService _materialUnitService;
         private readonly IOutboundOrderService _outboundOrderService;
         private readonly IOutboundOrderDetailService _outboundOrderDetailService;
         private readonly IOutStockLockInfoService _outStockLockInfoService;
-        public InvokeMESService(IHttpClientFactory httpClientFactory, ILogger<InvokeMESService> logger, IRepository<Dt_FeedbackToMes> feedbacktomesRepository, IRepository<Dt_StockInfoDetail> stockInfoDetailRepository, IRepository<Dt_StockInfo> stockInfoRepository, IRepository<Dt_InboundOrder> inboundOrderRepository, IOutboundOrderService outboundOrderService, IOutboundOrderDetailService outboundOrderDetailService, IOutStockLockInfoService outStockLockInfoService, IMaterialUnitService materialUnitService)
+        public InvokeMESService(IHttpClientFactory httpClientFactory, ILogger<InvokeMESService> logger, IRepository<Dt_FeedbackToMes> feedbacktomesRepository, IRepository<Dt_StockInfoDetail> stockInfoDetailRepository, IRepository<Dt_StockInfo> stockInfoRepository, IRepository<Dt_InboundOrder> inboundOrderRepository, IOutboundOrderService outboundOrderService, IOutboundOrderDetailService outboundOrderDetailService, IOutStockLockInfoService outStockLockInfoService, IMaterialUnitService materialUnitService, IRepository<Dt_PickingRecord> pickingRecoreRepository)
         {
             _httpClientFactory = httpClientFactory;
             _logger = logger;
@@ -53,6 +80,7 @@
             _outboundOrderDetailService = outboundOrderDetailService;
             _outStockLockInfoService = outStockLockInfoService;
             _materialUnitService = materialUnitService;
+            _pickingRecoreRepository = pickingRecoreRepository;
         }
 
         /// <summary>
@@ -221,6 +249,58 @@
         }
 
         /// <summary>
+        /// 鍑嗗鍥炰紶鏁版嵁
+        /// </summary>
+        private TransferDataDto PrepareTransferData(List<Dt_PickingRecord> pickingRecords)
+        {
+            var transferData = new TransferDataDto
+            {
+                TransferTime = DateTime.Now,
+                Items = new List<TransferItemDto>()
+            };
+
+            // 鎸夌墿鏂欏垎缁�
+            var materialGroups = pickingRecords
+                .GroupBy(x => x.MaterielCode)
+                .ToList();
+
+            foreach (var group in materialGroups)
+            {
+                var item = new TransferItemDto
+                {
+                    MaterialCode = group.Key,
+                    TotalQuantity = group.Sum(x => x.PickQuantity),
+                    Locations = new List<LocationInfoDto>()
+                };
+
+                // 鎸夎揣浣嶅垎缁�
+                var locationGroups = group
+                    .GroupBy(x => x.LocationCode)
+                    .ToList();
+
+                foreach (var locationGroup in locationGroups)
+                {
+                    var location = new LocationInfoDto
+                    {
+                        LocationCode = locationGroup.Key,
+                        Quantity = locationGroup.Sum(x => x.PickQuantity),
+                        Barcodes = locationGroup.Select(x => new BarcodeInfoDto
+                        {
+                            Barcode = x.Barcode,
+                            Quantity = x.PickQuantity
+                        }).ToList()
+                    };
+
+                    item.Locations.Add(location);
+                }
+
+                transferData.Items.Add(item);
+            }
+
+            return transferData;
+        }
+
+        /// <summary>
         /// 
         /// </summary>
         /// <param name="orderNos"></param>
@@ -275,7 +355,7 @@
                                                MaterialCode = group.Key.MaterielCode,
                                                LineNo = group.Key.InboundOrderRowNo,
                                                WarehouseCode = group.Key.WarehouseCode,
-                                               Qty = group.Sum(x => x.BarcodeQty),                           
+                                               Qty = group.Sum(x => x.BarcodeQty),
                                                Unit = group.Key.BarcodeUnit,
                                                Barcodes = group.Select(row => new BarcodeInfo
                                                {
@@ -366,11 +446,12 @@
             }
             return WebResponseContent.Instance.OK();
         }
+      
         private async Task<WebResponseContent> HandleOutboundOrderBatchToMESCompletion(Dt_OutboundOrder outboundOrder, string orderNo)
         {
             // 瀹氫箟榛樿杩斿洖锛堟垚鍔熸�侊級
             WebResponseContent response = WebResponseContent.Instance.OK("鍥炰紶MES澶勭悊瀹屾垚");
-
+            //0 = 鏈洖浼狅紝1 = 宸插洖浼犳垚鍔燂紝2 = 鍥炰紶澶辫触 
             try
             {
                 // 鏍¢獙锛氬凡鍥炰紶鐩存帴杩斿洖閿欒
@@ -391,8 +472,86 @@
                     return WebResponseContent.Instance.Error("鏆傛棤闇�瑕佸鐞嗙殑璁㈠崟鏄庣粏");
                 }
 
-                //  绛涢�夊凡瀹屾垚鍑哄簱鐨勬槑缁咺D
+
+                var pickingRecords = await _pickingRecoreRepository.Db.Queryable<Dt_PickingRecord>().Where(x => x.OrderNo == orderNo && x.ReturnToMESStatus != 1 && !x.IsCancelled).ToListAsync();
+
+                if (!pickingRecords.Any())
+                    return WebResponseContent.Instance.Error("娌℃湁闇�瑕佸洖浼犵殑鍒嗘嫞璁板綍");
+
+
+                var documentNo = UniqueValueGenerator.Generate();
+
+
+                var feedModel = new FeedbackOutboundRequestModel
+                {
+                    reqCode = Guid.NewGuid().ToString(),
+                    reqTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
+                    business_type = outboundOrder.BusinessType,
+                    factoryArea = outboundOrder.FactoryArea,
+                    operationType = 1,
+                    Operator = outboundOrder.Operator,
+                    orderNo = outboundOrder.UpperOrderNo,
+                    documentsNO = documentNo,
+                    status = outboundOrder.OrderStatus,
+                    details = new List<FeedbackOutboundDetailsModel>()
+                };
                 var detailIds = new List<int>();
+                // 濉厖鏄庣粏鍜屾潯鐮佷俊鎭�
+                foreach (var detail in orderDetails)
+                {
+                    // 鏌ヨ璇ユ槑缁嗗搴旂殑閿佸畾鏉$爜璁板綍
+                    var detailPicks = pickingRecords.Where(x => x.OrderNo == orderNo
+                                   && detail.Id == x.OrderDetailId).ToList();
+                    if (!detailPicks.Any())
+                    {
+                        continue;
+                    }
+                    var detailModel = new FeedbackOutboundDetailsModel
+                    {
+                        materialCode = detail.MaterielCode,
+                        lineNo = detail.lineNo,
+                        warehouseCode = detail.WarehouseCode,
+                        qty = 0,
+                        currentDeliveryQty = 0,
+                        unit = detail.BarcodeUnit,
+                        barcodes = new List<WIDESEA_DTO.Outbound.BarcodesModel>()
+                    };
+
+                    // 濉厖鏉$爜淇℃伅锛堝惈鍗曚綅杞崲锛�
+                    foreach (var item in detailPicks)
+                    {
+                        if (item.PickQuantity <= 0)
+                        {
+                            continue;
+                        }
+                        var barModel = new WIDESEA_DTO.Outbound.BarcodesModel
+                        {
+                            barcode = item.Barcode,
+                            supplyCode = item.SupplyCode,
+                            batchNo = item.BatchNo,
+                            unit = item.BarcodeUnit,
+                            qty = item.PickQuantity
+                        };
+
+                        // 鍗曚綅涓嶄竴鑷存椂杞崲
+                        if (detail.BarcodeUnit != detail.Unit)
+                        {
+                            var convertResult = await _materialUnitService.ConvertAsync(
+                                item.MaterielCode, item.PickQuantity, detail.Unit, detail.BarcodeUnit);
+                            barModel.unit = convertResult.Unit;
+                            barModel.qty = convertResult.Quantity;
+                        }
+                        else
+                        {
+                            barModel.qty = item.PickQuantity;
+                        }
+                        detailModel.qty += barModel.qty;
+                        detailModel.currentDeliveryQty += barModel.qty;
+                        detailModel.barcodes.Add(barModel);
+                    }
+                    detailIds.Add(detail.Id);
+                    feedModel.details.Add(detailModel);
+                }
                 var allCompleted = true;
 
                 // 绛涢�夊緟鍥炰紶鐨勬槑缁嗭紙ReturnToMESStatus=0锛�
@@ -415,7 +574,7 @@
                 int newStatus = allCompleted ? (int)OutOrderStatusEnum.鍑哄簱瀹屾垚 : (int)OutOrderStatusEnum.鍑哄簱涓�;
                 if (outboundOrder.OrderStatus != newStatus)
                 {
-                    // 淇鍘熸湁璇硶閿欒锛歋etColumns 鏄祴鍊硷紙=锛夎�岄潪鍒ゆ柇锛�==锛�
+
                     int updateCount = await _outboundOrderService.Db.Updateable<Dt_OutboundOrder>()
                         .SetColumns(x => x.OrderStatus == newStatus)
                         .Where(x => x.OrderNo == orderNo)
@@ -424,85 +583,16 @@
                     if (updateCount <= 0)
                     {
                         _logger.LogWarning($"鏇存柊鍑哄簱鍗曠姸鎬佸け璐� - OrderNo: {orderNo}, 鐩爣鐘舵��: {newStatus}");
-                        // 鐘舵�佹洿鏂板け璐ヤ笉涓柇娴佺▼锛屼絾璁板綍璀﹀憡
+
                     }
                 }
 
-                // 鏋勫缓鍥炰紶MES鐨勬ā鍨�
-                var documentNo = UniqueValueGenerator.Generate();
-                var feedModel = new FeedbackOutboundRequestModel
-                {
-                    reqCode = Guid.NewGuid().ToString(),
-                    reqTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
-                    business_type = outboundOrder.BusinessType,
-                    factoryArea = outboundOrder.FactoryArea,
-                    operationType = 1,
-                    Operator = outboundOrder.Operator,
-                    orderNo = outboundOrder.UpperOrderNo,
-                    documentsNO = documentNo,
-                    status = outboundOrder.OrderStatus,
-                    details = new List<FeedbackOutboundDetailsModel>()
-                };
-
-                // 濉厖鏄庣粏鍜屾潯鐮佷俊鎭�
-                foreach (var detail in orderDetails )
-                {
-                    // 鏌ヨ璇ユ槑缁嗗搴旂殑閿佸畾鏉$爜璁板綍
-                    var detailLocks = await _outStockLockInfoService.Db.Queryable<Dt_OutStockLockInfo>()
-                        .Where(x => x.OrderNo == orderNo
-                                   && detail.Id == x.OrderDetailId
-                                   && (x.Status == (int)OutLockStockStatusEnum.鎷i�夊畬鎴�
-                                       || x.Status == (int)OutLockStockStatusEnum.宸插洖搴�))
-                        .ToListAsync();
-
-                    var detailModel = new FeedbackOutboundDetailsModel
-                    {
-                        materialCode = detail.MaterielCode,
-                        lineNo = detail.lineNo,
-                        warehouseCode = detail.WarehouseCode,
-                        qty =0,
-                        currentDeliveryQty = 0,
-                        unit = detail.BarcodeUnit,
-                        barcodes = new List<WIDESEA_DTO.Outbound.BarcodesModel>()
-                    };
-
-                    // 濉厖鏉$爜淇℃伅锛堝惈鍗曚綅杞崲锛�
-                    foreach (var item in detailLocks)
-                    {
-                        if (item.PickedQty > 0)
-                        {
-                            var barModel = new WIDESEA_DTO.Outbound.BarcodesModel
-                            {
-                                barcode = item.CurrentBarcode,
-                                supplyCode = item.SupplyCode,
-                                batchNo = item.BatchNo,
-                                unit = item.BarcodeUnit,
-                                qty = item.BarcodeQty
-                            };
-
-                            // 鍗曚綅涓嶄竴鑷存椂杞崲
-                            if (item.BarcodeUnit != item.Unit)
-                            {
-                                var convertResult = await _materialUnitService.ConvertAsync(
-                                    item.MaterielCode, item.BarcodeQty, item.Unit, item.BarcodeUnit);
-                                barModel.unit = convertResult.Unit;
-                                barModel.qty = convertResult.Quantity;
-                            }
-
-                            detailModel.qty += barModel.qty;
-                            detailModel.currentDeliveryQty += barModel.qty;
-                            detailModel.barcodes.Add(barModel);
-                        }
-                    }
-
-                    feedModel.details.Add(detailModel);
-                }
 
                 // 璋冪敤MES鍥炰紶鎺ュ彛
                 var mesResult = await FeedbackOutbound(feedModel);
                 if (mesResult == null || mesResult.code != 200)
                 {
-                
+
                     // 鏇存柊鏄庣粏涓哄洖浼犲け璐ワ紙ReturnToMESStatus=2锛�
                     await _outboundOrderDetailService.Db.Updateable<Dt_OutboundOrderDetail>()
                         .SetColumns(it => new Dt_OutboundOrderDetail
@@ -515,17 +605,28 @@
 
                     return WebResponseContent.Instance.Error($"鍥炰紶MES澶辫触");
                 }
-
-                //MES鍥炰紶鎴愬姛锛氭洿鏂版槑缁嗕负鍥炰紶鎴愬姛鐘舵��
-                await _outboundOrderDetailService.Db.Updateable<Dt_OutboundOrderDetail>()
-                    .SetColumns(it => new Dt_OutboundOrderDetail
-                    {
-                        ReturnToMESStatus = 1,
-                        documentsNO = documentNo,
-                    })
-                    .Where(x => detailIds.Contains(x.Id))
-                    .ExecuteCommandAsync();
-
+                foreach (var record in pickingRecords.Where(x => detailIds.Contains(x.OrderDetailId)).ToList())
+                {
+                    record.ReturnToMESStatus = 1;
+                }
+                var updates = pickingRecords.Where(x => detailIds.Contains(x.OrderDetailId)).ToList();
+                updates.ForEach(x =>
+                {
+                    x.ReturnToMESStatus = 1;
+                });
+                await _pickingRecoreRepository.Db.Updateable(updates).ExecuteCommandAsync();
+                if (allCompleted)
+                {
+                    //MES鍥炰紶鎴愬姛锛氭洿鏂版槑缁嗕负鍥炰紶鎴愬姛鐘舵��
+                    await _outboundOrderDetailService.Db.Updateable<Dt_OutboundOrderDetail>()
+                        .SetColumns(it => new Dt_OutboundOrderDetail
+                        {
+                            ReturnToMESStatus = 1,
+                            documentsNO = documentNo,
+                        })
+                        .Where(x => detailIds.Contains(x.Id))
+                        .ExecuteCommandAsync();
+                }
                 // 鏍¢獙鏄惁鎵�鏈夋槑缁嗛兘瀹屾垚锛屾洿鏂拌鍗曟渶缁堢姸鎬�
                 if (allCompleted && newStatus == (int)OutOrderStatusEnum.鍑哄簱瀹屾垚)
                 {
@@ -673,8 +774,8 @@
                                 materialCode = group.Key.MaterielCode,
                                 lineNo = group.Key.lineNo,
                                 warehouseCode = group.Key.WarehouseCode,
-                                qty = group.Sum(x => x.BarcodeQty),
-                                currentDeliveryQty = group.Sum(x => x.BarcodeQty),
+                                qty = group.Sum(x => x.PickedQty),
+                                currentDeliveryQty = group.Sum(x => x.PickedQty),
                                 unit = group.Key.BarcodeUnit,
                                 barcodes = group.Select(lockInfo => new WIDESEA_DTO.Outbound.BarcodesModel
                                 {
@@ -682,7 +783,7 @@
                                     supplyCode = lockInfo.SupplyCode,
                                     batchNo = lockInfo.BatchNo,
                                     unit = lockInfo.BarcodeUnit,
-                                    qty = lockInfo.BarcodeQty
+                                    qty = lockInfo.PickedQty
                                 }).ToList()
                             }).ToList();
 
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_Model/Models/Outbound/Dt_PickingRecord.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_Model/Models/Outbound/Dt_PickingRecord.cs"
index e0015f7..d642e34 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_Model/Models/Outbound/Dt_PickingRecord.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_Model/Models/Outbound/Dt_PickingRecord.cs"
@@ -91,6 +91,8 @@
         ///</summary>
         [SugarColumn(ColumnName = "barcodemoveQty", ColumnDescription = "鏁伴噺")]
         public decimal BarcodeMoveQty { get; set; }
+
+        public int ReturnToMESStatus { get; set; }
     }
 
 
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/OutboundPickingService.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/OutboundPickingService.cs"
index fd76615..62d9963 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/OutboundPickingService.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/OutboundPickingService.cs"
@@ -1966,7 +1966,7 @@
                     .Where(x => x.OrderNo == orderNo && x.Status == (int)OutLockStockStatusEnum.鎷i�夊畬鎴�)
                     .ToListAsync();
 
-                var groupedData = lists.GroupBy(item => new { item.MaterielCode, item.lineNo, item.Unit, item.WarehouseCode })
+                var groupedData = lists.GroupBy(item => new { item.MaterielCode, item.lineNo, item.BarcodeUnit, item.WarehouseCode })
                    .Select(group => new AllocateDtoDetail
                    {
                        MaterialCode = group.Key.MaterielCode,
@@ -1974,13 +1974,13 @@
                        WarehouseCode = group.Key.WarehouseCode,
                        Qty = group.Sum(x => x.PickedQty),
 
-                       Unit = group.Key.Unit,
+                       Unit = group.Key.BarcodeUnit,
                        Barcodes = group.Select(row => new BarcodeInfo
                        {
                            Barcode = row.CurrentBarcode,
                            SupplyCode = row.SupplyCode,
                            BatchNo = row.BatchNo,
-                           Unit = row.Unit,
+                           Unit = row.BarcodeUnit,
                            Qty = row.PickedQty
                        }).ToList()
 
@@ -2036,8 +2036,8 @@
                            materialCode = group.Key.MaterielCode,
                            lineNo = group.Key.lineNo,
                            warehouseCode = group.Key.WarehouseCode,
-                           qty = group.Sum(x => x.BarcodeQty),
-                           currentDeliveryQty = group.Sum(x => x.BarcodeQty),
+                           qty = group.Sum(x => x.PickedQty),
+                           currentDeliveryQty = group.Sum(x => x.PickedQty),
                            unit = group.Key.BarcodeUnit,
                            barcodes = group.Select(row => new WIDESEA_DTO.Outbound.BarcodesModel
                            {
@@ -2045,7 +2045,7 @@
                                supplyCode = row.SupplyCode,
                                batchNo = row.BatchNo,
                                unit = row.BarcodeUnit,
-                               qty = row.BarcodeQty
+                               qty = row.PickedQty
                            }).ToList()
                        }).ToList();
 
@@ -2844,8 +2844,8 @@
                                   materialCode = group.Key.MaterielCode,
                                   lineNo = group.Key.lineNo,
                                   warehouseCode = group.Key.WarehouseCode,
-                                  qty = group.Sum(x => x.BarcodeQty),
-                                  currentDeliveryQty = group.Sum(x => x.BarcodeQty),
+                                  qty = group.Sum(x => x.PickedQty),
+                                  currentDeliveryQty = group.Sum(x => x.PickedQty),
                                   unit = group.Key.BarcodeUnit,
                                   barcodes = group.Select(lockInfo => new WIDESEA_DTO.Outbound.BarcodesModel
                                   {
@@ -2853,7 +2853,7 @@
                                       supplyCode = lockInfo.SupplyCode,
                                       batchNo = lockInfo.BatchNo,
                                       unit = lockInfo.BarcodeUnit,
-                                      qty = lockInfo.BarcodeQty
+                                      qty = lockInfo.PickedQty
                                   }).ToList()
                               }).ToList();
                         feedmodel.details.AddRange(groupdata);
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 05dfb19..9cc3fde 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"
@@ -645,7 +645,7 @@
                     locationInfo.LocationStatus = LocationStatusEnum.InStock.ObjToInt();
                 }
 
-                _locationInfoService.Repository.UpdateData(locationInfo);                       
+                _locationInfoService.Repository.UpdateData(locationInfo);
 
                 task.TaskStatus = TaskStatusEnum.Finish.ObjToInt();
 
@@ -749,7 +749,7 @@
                         await _outboundOrderDetailService.Db.Updateable<Dt_OutboundOrderDetail>()
                             .SetColumns(it => new Dt_OutboundOrderDetail
                             {
-                                LockQuantity = currentLockQty, 
+                                LockQuantity = currentLockQty,
                             })
                             .Where(it => it.Id == detailId)
                             .ExecuteCommandAsync();
@@ -853,7 +853,7 @@
                     await _outboundOrderDetailService.Db.Updateable<Dt_OutboundOrderDetail>()
                         .SetColumns(it => new Dt_OutboundOrderDetail
                         {
-                            OrderDetailStatus = newStatus, 
+                            OrderDetailStatus = newStatus,
                         })
                         .Where(it => it.Id == orderDetail.Id)
                         .ExecuteCommandAsync();
@@ -940,7 +940,7 @@
                         .SetColumns(x => new Dt_OutboundOrder
                         {
                             OrderStatus = newStatus,
-                            Operator = App.User.UserName, 
+                            Operator = App.User.UserName,
                         })
                         .Where(x => x.OrderNo == orderNo)
                         .ExecuteCommandAsync();
@@ -1049,7 +1049,7 @@
                                 MaterialCode = detail.MaterielCode,
                                 LineNo = detail.lineNo,
                                 WarehouseCode = detail.WarehouseCode,
-                                Qty =0,
+                                Qty = 0,
                                 Unit = detail.BarcodeUnit,
                                 Barcodes = new List<BarcodeInfo>()
                             };
@@ -1057,44 +1057,47 @@
                             {
                                 if (item.PickedQty > 0)
                                 {
-                                    Barcode = item.CurrentBarcode,
-                                    SupplyCode = item.SupplyCode,
-                                    BatchNo = item.BatchNo,
-                                    Unit = detail.BarcodeUnit,
-                                    Qty = 0
-                                };
-                                // 鍗曚綅涓嶄竴鑷存椂杞崲
-                                if (detail.BarcodeUnit != detail.Unit)
-                                {
-                                    var convertResult = await _materialUnitService.ConvertAsync(item.MaterielCode, item.PickedQty, detail.Unit, detail.BarcodeUnit);
-                                    barModel.Unit = convertResult.Unit;
-                                    barModel.Qty = convertResult.Quantity;
+                                    var barModel = new BarcodeInfo
+                                    {
+                                        Barcode = item.CurrentBarcode,
+                                        SupplyCode = item.SupplyCode,
+                                        BatchNo = item.BatchNo,
+                                        Unit = detail.BarcodeUnit,
+                                        Qty = 0
+                                    };
+                                    // 鍗曚綅涓嶄竴鑷存椂杞崲
+                                    if (detail.BarcodeUnit != detail.Unit)
+                                    {
+                                        var convertResult = await _materialUnitService.ConvertAsync(item.MaterielCode, item.PickedQty, detail.Unit, detail.BarcodeUnit);
+                                        barModel.Unit = convertResult.Unit;
+                                        barModel.Qty = convertResult.Quantity;
+                                    }
+                                    else
+                                    {
+                                        barModel.Qty = item.PickedQty;
+                                    }
+                                    detailModel.Qty += barModel.Qty;
+                                    detailModel.Barcodes.Add(barModel);
                                 }
-                                else
-                                {
-                                    barModel.Qty = item.PickedQty;
-                                }
-                                detailModel.Qty += barModel.Qty;
-                                detailModel.Barcodes.Add(barModel);
+
+
+                                allocatefeedmodel.Details.Add(detailModel);
                             }
 
+                            var result = await _invokeMESService.FeedbackAllocate(allocatefeedmodel);
+                            if (result != null && result.code == 200)
+                            {
+                                await _outboundOrderDetailService.Db.Updateable<Dt_OutboundOrderDetail>()
+                                       .SetColumns(x => x.ReturnToMESStatus == 1)
+                                       .Where(x => x.OrderId == outboundOrder.Id).ExecuteCommandAsync();
 
-                            allocatefeedmodel.Details.Add(detailModel);
-                        }
-
-                        var result = await _invokeMESService.FeedbackAllocate(allocatefeedmodel);
-                        if (result != null && result.code == 200)
-                        {
-                            await _outboundOrderDetailService.Db.Updateable<Dt_OutboundOrderDetail>()
-                                   .SetColumns(x => x.ReturnToMESStatus == 1)
-                                   .Where(x => x.OrderId == outboundOrder.Id).ExecuteCommandAsync();
-
-                            await _outboundOrderService.Db.Updateable<Dt_OutboundOrder>()
-                                  .SetColumns(x => new Dt_OutboundOrder
-                                  {
-                                      ReturnToMESStatus = 1,
-                                      Operator = App.User.UserName,
-                                  }).Where(x => x.OrderNo == orderNo).ExecuteCommandAsync();
+                                await _outboundOrderService.Db.Updateable<Dt_OutboundOrder>()
+                                      .SetColumns(x => new Dt_OutboundOrder
+                                      {
+                                          ReturnToMESStatus = 1,
+                                          Operator = App.User.UserName,
+                                      }).Where(x => x.OrderNo == orderNo).ExecuteCommandAsync();
+                            }
                         }
                     }
                     else if (outboundOrder.OrderType == OutOrderTypeEnum.ReCheck.ObjToInt())
@@ -1133,7 +1136,7 @@
                                 lineNo = detail.lineNo, // 娉ㄦ剰锛氳繖閲屽彲鑳介渶瑕佽皟鏁村瓧娈靛悕
                                 warehouseCode = detail.WarehouseCode,
                                 qty = 0,
-                                currentDeliveryQty =0,
+                                currentDeliveryQty = 0,
                                 unit = detail.Unit,
                                 barcodes = new List<WIDESEA_DTO.Outbound.BarcodesModel>()
                             };
@@ -1141,7 +1144,6 @@
                             {
                                 if (item.PickedQty > 0)
                                 {
-<<<<<<< .mine
                                     var barModel = new WIDESEA_DTO.Outbound.BarcodesModel
                                     {
                                         barcode = item.CurrentBarcode,
@@ -1151,60 +1153,24 @@
                                         qty = item.PickedQty
                                     };
                                     // 鍗曚綅涓嶄竴鑷存椂杞崲
-                                    if (item.BarcodeUnit != item.Unit)
+                                    if (detail.BarcodeUnit != detail.Unit)
                                     {
-                                        var convertResult = await _materialUnitService.ConvertAsync(item.MaterielCode, item.PickedQty, item.Unit, item.BarcodeUnit);
+                                        var convertResult = await _materialUnitService.ConvertAsync(item.MaterielCode, item.PickedQty, detail.Unit, detail.BarcodeUnit);
                                         barModel.unit = convertResult.Unit;
                                         barModel.qty = convertResult.Quantity;
                                     }
-
+                                    else
+                                    {
+                                        barModel.qty = item.PickedQty;
+                                    }
                                     detailModel.qty += barModel.qty;
                                     detailModel.currentDeliveryQty += barModel.qty;
                                     detailModel.barcodes.Add(barModel);
-=======
-                                    barcode = item.CurrentBarcode,
-                                    supplyCode = item.SupplyCode,
-                                    batchNo = item.BatchNo,
-                                    unit = detail.BarcodeUnit,
-                                    qty = item.PickedQty
-                                };
-                                // 鍗曚綅涓嶄竴鑷存椂杞崲
-                                if (detail.BarcodeUnit != detail.Unit)
-                                {
-                                    var convertResult = await _materialUnitService.ConvertAsync(item.MaterielCode, item.PickedQty, detail.Unit, detail.BarcodeUnit);
-                                    barModel.unit = convertResult.Unit;
-                                    barModel.qty = convertResult.Quantity;
-
-
-
-
-
-
-
->>>>>>> .theirs
                                 }
-<<<<<<< .mine
-
-
-
-
-
-
-
-
-=======
-                                else
-                                {
-                                    barModel.qty = item.PickedQty;
-                                }
-
-                                    detailModel.qty += barModel.qty;
-                                detailModel.currentDeliveryQty += barModel.qty;
-                                detailModel.barcodes.Add(barModel);
->>>>>>> .theirs
                             }
                             feedmodel.details.Add(detailModel);
                         }
+
                         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/Outbound/PickingReturnController.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/Outbound/PickingReturnController.cs"
index 45460a8..e048964 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/Outbound/PickingReturnController.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/Outbound/PickingReturnController.cs"
@@ -26,7 +26,7 @@
         }
 
         /// <summary>
-        /// 
+        /// 閲嶆缁勭洏鍏ュ簱
         /// </summary>
         /// <param name="materielGroupDTO"></param>
         /// <returns></returns>

--
Gitblit v1.9.3