From 61654768aa92e6c3fd288344c0c895ba4d19d127 Mon Sep 17 00:00:00 2001
From: 647556386 <647556386@qq.com>
Date: 星期二, 06 一月 2026 19:14:18 +0800
Subject: [PATCH] Merge branch 'htq20251215' of http://115.159.85.185:8098/r/ZhongRui/ALDbanyunxiangmu into htq20251215

---
 项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_OutboundService/OutboundPickingService.cs |   46 ++++++++++++++++++++++++++++++++--------------
 1 files changed, 32 insertions(+), 14 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/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 d796d5b..fa4c44d 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"
@@ -2365,7 +2365,7 @@
                         foreach (var detail in inboundOrder.Details)
                         {
                             if (detail.OrderDetailStatus != OrderDetailStatusEnum.Over.ObjToInt() &&
-                                !string.IsNullOrEmpty(detail.Barcode))
+                                !string.IsNullOrEmpty(detail.Barcode)&& detail.OutBoxbarcodes == noStockOut.barCode)
                             {
                                 detailLists.Add(detail);
                             }
@@ -2386,11 +2386,18 @@
                 {
                     item.NoStockOutQty = 0;
 
-                    var matchedCode = outboundOrder.Details.FirstOrDefault(detail => detail.MaterielCode == item.MaterielCode && detail.OrderDetailStatus != OrderDetailStatusEnum.Over.ObjToInt() && (detail.OrderQuantity-detail.LockQuantity-detail.MoveQty-detail.NoStockOutQty)>0);
+                    var matchedCode = outboundOrder.Details.FirstOrDefault(detail => detail.MaterielCode == item.MaterielCode && detail.OrderDetailStatus != OrderDetailStatusEnum.Over.ObjToInt()&& detail.OrderQuantity - detail.LockQuantity - detail.MoveQty - detail.NoStockOutQty > 0);
 
-                    if (matchedCode == null)
+                    if (matchedCode != null)
                     {
-                        return WebResponseContent.Instance.Error($"鍦ㄥ嚭搴撳崟鐨勭墿鏂欑紪鐮佷腑鏈壘鍒颁笌閲囪喘鍗曚腑鐨剓item.MaterielCode} 瀵瑰簲鐨勭墿鏂欍��");
+                        if(matchedCode.OrderQuantity - matchedCode.LockQuantity - matchedCode.MoveQty - matchedCode.NoStockOutQty < 0)
+                        {
+                            return WebResponseContent.Instance.Error($"鐗╂枡{item.MaterielCode}鍙嚭鏁伴噺婧㈠嚭{(matchedCode.LockQuantity + matchedCode.MoveQty + matchedCode.NoStockOutQty) - matchedCode.OrderQuantity}");
+                        }
+                    }
+                    else
+                    {
+                        return WebResponseContent.Instance.Error($"鍦ㄥ嚭搴撳崟鐨勭墿鏂欑紪鐮佷腑鏈壘鍒颁笌閲囪喘鍗曚腑鐨剓item.MaterielCode} 瀵瑰簲鐨勭墿鏂�");
                     }
                     if (!matchedCode.BatchNo.IsNullOrEmpty() && matchedCode.BatchNo != "")
                     {
@@ -2415,12 +2422,15 @@
                             return WebResponseContent.Instance.Error($"璇ユ潯鐮亄item.Barcode}瀵瑰簲鐨勫崟鎹巶鍖轰笌鍑哄簱鍗曟嵁涓嶄竴鑷达紒涓嶅厑璁稿嚭搴撱��");
                         }
                     }
-                    if (!matchedCode.WarehouseCode.IsNullOrEmpty() && matchedCode.WarehouseCode != "")
+                    if(inboundOrder.BusinessType != "11")
                     {
-                        var matcheBatch = outboundOrder.Details.FirstOrDefault(detail => detail.WarehouseCode == item.WarehouseCode);
-                        if (matcheBatch == null)
+                        if (!matchedCode.WarehouseCode.IsNullOrEmpty() && matchedCode.WarehouseCode != "")
                         {
-                            return WebResponseContent.Instance.Error($"浠撳簱涓嶄竴鑷达紒鍦ㄥ嚭搴撳崟鐨勭墿鏂欑紪鐮佷腑鏈壘鍒颁笌閲囪喘鍗曚粨搴撲腑鐨剓item.WarehouseCode} 瀵瑰簲鐨勭墿鏂欍��");
+                            var matcheBatch = outboundOrder.Details.FirstOrDefault(detail => detail.WarehouseCode == item.WarehouseCode);
+                            if (matcheBatch == null)
+                            {
+                                return WebResponseContent.Instance.Error($"浠撳簱涓嶄竴鑷达紒鍦ㄥ嚭搴撳崟鐨勭墿鏂欑紪鐮佷腑鏈壘鍒颁笌閲囪喘鍗曚粨搴撲腑鐨剓item.WarehouseCode} 瀵瑰簲鐨勭墿鏂欍��");
+                            }
                         }
                     }
 
@@ -2680,6 +2690,7 @@
                 {
                     item.LockQuantity = item.NoStockOutQty;
                     item.OverOutQuantity = item.NoStockOutQty;
+                    item.CurrentDeliveryQty = item.OverOutQuantity;
                     //娣诲姞鍥炰紶MES鍙傛暟
                     List<Barcodes> barcodesList = new List<Barcodes>();
                     List<Barcodes> documentsNOList = new List<Barcodes>();
@@ -2771,7 +2782,7 @@
                         BusinessType = "3",
                         FactoryArea = inboundOrder.FactoryArea,
                         OperationType = 1,
-                        Operator = inboundOrder.Operator,
+                        Operator = App.User.UserName,
                         OrderNo = inboundOrder.UpperOrderNo,
                         fromWarehouse = allocate?.FromWarehouse ?? "",
                         toWarehouse = allocate?.ToWarehouse ?? "",
@@ -2787,11 +2798,13 @@
 
                     if (response != null && response.IsSuccess)
                     {
-                        _inboundOrderRepository.Db.Updateable<Dt_InboundOrderDetail>().SetColumns(it => new Dt_InboundOrderDetail { ReturnToMESStatus = 1 });
+                        _inboundOrderRepository.Db.Updateable<Dt_InboundOrderDetail>().SetColumns(it => new Dt_InboundOrderDetail { ReturnToMESStatus = 1 })
+                            .Where(it => it.OrderId == inboundOrder.Id).ExecuteCommand();
                     }
                     else
                     {
-                        _inboundOrderRepository.Db.Updateable<Dt_InboundOrderDetail>().SetColumns(it => new Dt_InboundOrderDetail { ReturnToMESStatus = 2 });
+                        _inboundOrderRepository.Db.Updateable<Dt_InboundOrderDetail>().SetColumns(it => new Dt_InboundOrderDetail { ReturnToMESStatus = 2 })
+                            .Where(it => it.OrderId == inboundOrder.Id).ExecuteCommand();
                         return content.Error("鍥炰紶MES澶辫触");
                     }
                 }
@@ -2804,7 +2817,7 @@
                         business_type = inboundOrder.BusinessType,
                         factoryArea = inboundOrder.FactoryArea,
                         operationType = 1,
-                        Operator = inboundOrder.Operator,
+                        Operator = App.User.UserName,
                         orderNo = inboundOrder.UpperOrderNo,
                         status = inboundOrder.OrderStatus,
                         details = NoStockOutFeedbackInboundDetailsModelDto(detail)
@@ -2818,11 +2831,16 @@
 
                     if (response != null && response.IsSuccess)
                     {
-                        _inboundOrderRepository.Db.Updateable<Dt_InboundOrderDetail>().SetColumns(it => new Dt_InboundOrderDetail { ReturnToMESStatus = 1 });
+                        _inboundOrderRepository.Db.Updateable<Dt_InboundOrderDetail>().SetColumns(it => new Dt_InboundOrderDetail { ReturnToMESStatus = 1 })
+                            .Where(it => it.OrderId == inboundOrder.Id).ExecuteCommand();
+                        _inboundOrderRepository.Db.Updateable<Dt_InboundOrder>().SetColumns(it => new Dt_InboundOrder { ReturnToMESStatus = 1 })
+                            .Where(it => it.Id == inboundOrder.Id).ExecuteCommand();
                     }
                     else
                     {
-                        _inboundOrderRepository.Db.Updateable<Dt_InboundOrderDetail>().SetColumns(it => new Dt_InboundOrderDetail { ReturnToMESStatus = 2 });
+                        _inboundOrderRepository.Db.Updateable<Dt_InboundOrderDetail>().SetColumns(it => new Dt_InboundOrderDetail { ReturnToMESStatus = 2 }).Where(it => it.OrderId == inboundOrder.Id).ExecuteCommand();
+                        _inboundOrderRepository.Db.Updateable<Dt_InboundOrder>().SetColumns(it => new Dt_InboundOrder { ReturnToMESStatus = 2 })
+                            .Where(it => it.Id == inboundOrder.Id).ExecuteCommand();
                         return content.Error("鍥炰紶MES澶辫触");
                     }
                 }

--
Gitblit v1.9.3