From 1b8daa902b075c7cedee7bbcc13b914b7a5b4ad4 Mon Sep 17 00:00:00 2001
From: dengjunjie <dengjunjie@hnkhzn.com>
Date: 星期一, 03 十一月 2025 11:48:49 +0800
Subject: [PATCH] 优化盘点逻辑

---
 新建文件夹/WIDESEA_WMSServer/WIDESEA_SquareCabinServices/LKBusiness/DeliveryOrderServicesLK.cs |   11 +++++------
 1 files changed, 5 insertions(+), 6 deletions(-)

diff --git "a/\346\226\260\345\273\272\346\226\207\344\273\266\345\244\271/WIDESEA_WMSServer/WIDESEA_SquareCabinServices/LKBusiness/DeliveryOrderServicesLK.cs" "b/\346\226\260\345\273\272\346\226\207\344\273\266\345\244\271/WIDESEA_WMSServer/WIDESEA_SquareCabinServices/LKBusiness/DeliveryOrderServicesLK.cs"
index 3c120d4..84065f4 100644
--- "a/\346\226\260\345\273\272\346\226\207\344\273\266\345\244\271/WIDESEA_WMSServer/WIDESEA_SquareCabinServices/LKBusiness/DeliveryOrderServicesLK.cs"
+++ "b/\346\226\260\345\273\272\346\226\207\344\273\266\345\244\271/WIDESEA_WMSServer/WIDESEA_SquareCabinServices/LKBusiness/DeliveryOrderServicesLK.cs"
@@ -39,22 +39,21 @@
                             if (orderDetail == null) throw new Exception($"鏈壘鍒扮洏鐐瑰崟銆恵deliveryOrder.Out_no}銆戠墿鏂欑紪鍙枫�恵detail.productCode}銆戠墿鏂欐壒娆°�恵detail.batchNo}銆戠殑鏄庣粏淇℃伅");
                             decimal orderQty = detail.orderDetails?.Sum(x => decimal.TryParse(x.quantity, out var q) ? Math.Abs(q) : 0) ?? 0;
                             Dt_InventoryInfo inventoryInfo = inventoryInfos.Where(x => x.MaterielCode == detail.productCode && x.BatchNo == detail.batchNo).First();
-                            var qty = inventoryInfo.SupplyQuantity - inventoryInfo.StockQuantity;
-                            if (orderQty != qty)
-                                throw new Exception($"鐩樹簭鍑哄簱鏁伴噺涓嶄竴鑷�,涓婁紶鏁伴噺銆恵orderQty}銆�,搴撳瓨鐩樹簭鏁伴噺銆恵qty}銆�");
-                            inventoryInfo.StockQuantity = inventoryInfo.SupplyQuantity;
+                            if (orderQty != Math.Abs(inventoryInfo.SupplyQuantity))
+                                throw new Exception($"鐩樹簭鍑哄簱鏁伴噺涓嶄竴鑷�,涓婁紶鏁伴噺銆恵orderQty}銆�,搴撳瓨鐩樹簭鏁伴噺銆恵Math.Abs(inventoryInfo.SupplyQuantity)}銆�");
+                            inventoryInfo.StockQuantity += inventoryInfo.SupplyQuantity;
                             inventoryInfo.AvailableQuantity = inventoryInfo.StockQuantity;
                             inventoryInfo.SupplyQuantity = 0;
                             inventoryInfo.StockStatus = StockStatusEmun.鍏ュ簱瀹屾垚.ObjToInt();
                             infosUp.Add(inventoryInfo);
                             Dt_Inventory_Batch inventory_Batch = inventory_Batches.First(x => x.MaterielCode == inventoryInfo.MaterielCode && x.BatchNo == inventoryInfo.BatchNo);
-                            inventory_Batch.StockQuantity = inventory_Batch.SupplyQuantity;
+                            inventory_Batch.StockQuantity += inventory_Batch.SupplyQuantity;
                             inventory_Batch.AvailableQuantity = inventory_Batch.StockQuantity;
                             inventory_Batch.SupplyQuantity = 0;
                             batchesUp.Add(inventory_Batch);
                             orderDetail.OotDetailStatus = "宸插畬鎴�";
                             cabinOrderDetailsUp.Add(orderDetail);
-                            #region 娣诲姞鐩樼泩鍏ュ簱浠诲姟
+                            #region 娣诲姞鐩樹簭鍑哄簱浠诲姟
                             Dt_SupplyTask_Hty supplyTask_Hty = new Dt_SupplyTask_Hty()
                             {
                                 WarehouseCode = inventoryInfo.WarehouseCode,

--
Gitblit v1.9.3