From b0ed419ede8bd1829e670891ffe878630ba517e2 Mon Sep 17 00:00:00 2001
From: yanjinhui <3306209981@qq.com>
Date: 星期一, 03 十一月 2025 17:57:32 +0800
Subject: [PATCH] 优化

---
 新建文件夹/WIDESEA_WMSServer/WIDESEA_SquareCabinServices/LKBusiness/CabinOrderServicesLK.cs |   22 +++++++++++++++++-----
 1 files changed, 17 insertions(+), 5 deletions(-)

diff --git "a/\346\226\260\345\273\272\346\226\207\344\273\266\345\244\271/WIDESEA_WMSServer/WIDESEA_SquareCabinServices/LKBusiness/CabinOrderServicesLK.cs" "b/\346\226\260\345\273\272\346\226\207\344\273\266\345\244\271/WIDESEA_WMSServer/WIDESEA_SquareCabinServices/LKBusiness/CabinOrderServicesLK.cs"
index 1392201..55ec36e 100644
--- "a/\346\226\260\345\273\272\346\226\207\344\273\266\345\244\271/WIDESEA_WMSServer/WIDESEA_SquareCabinServices/LKBusiness/CabinOrderServicesLK.cs"
+++ "b/\346\226\260\345\273\272\346\226\207\344\273\266\345\244\271/WIDESEA_WMSServer/WIDESEA_SquareCabinServices/LKBusiness/CabinOrderServicesLK.cs"
@@ -36,6 +36,7 @@
                 List<Dt_MaterielInfo> materielInfos = _materielInfoService.Repository.QueryData(x => cabinOrder.Details.Select(x => x.Goods_no).ToList().Contains(x.MaterielCode));
                 List<Dt_InventoryInfo> inventoryInfos = _inventoryInfoService.Repository.QueryData(x => cabinOrder.Warehouse_no == x.WarehouseCode && cabinOrder.Details.Select(x => x.Goods_no).ToList().Contains(x.MaterielCode));
                 List<Dt_Inventory_Batch> inventory_Batches = _inventory_BatchServices.Repository.QueryData(x => cabinOrder.Details.Select(x => x.Goods_no).ToList().Contains(x.MaterielCode));
+                List<Dt_MaterielInfo> MaterieInfoBusiness = new List<Dt_MaterielInfo>();
                 #region 鐩樼泩鍏ュ簱鍗�
                 if (cabinOrder.Order_type == "5")
                 {
@@ -45,15 +46,24 @@
                         if (orderDetail == null) throw new Exception($"鏈壘鍒扮洏鐐瑰崟銆恵cabinOrder.Order_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 != inventoryInfo.SupplyQuantity)
+                            throw new Exception($"鐩樼泩鍏ュ簱鏁伴噺涓嶄竴鑷�,涓婁紶鏁伴噺銆恵orderQty}銆�,搴撳瓨鐩樼泩鏁伴噺銆恵inventoryInfo.SupplyQuantity}銆�");
+                        var mater = materielInfos.FirstOrDefault(x => x.MaterielCode == detail.productCode);
+                        //娣诲姞鐗╂枡淇℃伅涓殑绔嬪簱涓氬姟搴撳瓨淇℃伅
+                        if (mater != null)
+                        {
+                            mater.Business_qty += inventoryInfo.SupplyQuantity;
+                            MaterieInfoBusiness.Add(mater);
+                        }
+
+                        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.OrderDetailStatus = "宸插畬鎴�";
@@ -90,6 +100,8 @@
                     _inventory_BatchServices.UpdateData(batchesUp);
                     _cabinOrderDetailServices.UpdateData(cabinOrderDetailsUp);
                     BaseDal.UpdateData(cabinOrder);
+                    //娣诲姞鐗╂枡鐨勭珛搴撲笟鍔″熀纭�鏁版嵁
+                    _materielInfoService.UpdateData(MaterieInfoBusiness);
                     _unitOfWorkManage.CommitTran();
                 }
                 #endregion

--
Gitblit v1.9.3