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/DeliveryOrderServicesLK.cs | 21 +++++++++++++++------
1 files changed, 15 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..f96c94d 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"
@@ -28,6 +28,7 @@
List<Dt_MaterielInfo> materielInfos = _materielInfoService.Repository.QueryData(x => deliveryOrder.Details.Select(x => x.Goods_no).ToList().Contains(x.MaterielCode));
List<Dt_InventoryInfo> inventoryInfos = _inventoryInfoService.Repository.QueryData(x => deliveryOrder.Warehouse_no == x.WarehouseCode && deliveryOrder.Details.Select(x => x.Goods_no).ToList().Contains(x.MaterielCode));
List<Dt_Inventory_Batch> inventory_Batches = _inventory_BatchServices.Repository.QueryData(x => deliveryOrder.Details.Select(x => x.Goods_no).ToList().Contains(x.MaterielCode));
+ List<Dt_MaterielInfo> MaterieInfoBusiness =new List<Dt_MaterielInfo>();
#region 鐩樹簭鍑哄簱鍗�
if (deliveryOrder.Out_type == "6")
{
@@ -39,22 +40,28 @@
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)}銆�");
+ //娣诲姞鐗╂枡淇℃伅涓殑绔嬪簱涓氬姟搴撳瓨淇℃伅
+ 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.OotDetailStatus = "宸插畬鎴�";
cabinOrderDetailsUp.Add(orderDetail);
- #region 娣诲姞鐩樼泩鍏ュ簱浠诲姟
+ #region 娣诲姞鐩樹簭鍑哄簱浠诲姟
Dt_SupplyTask_Hty supplyTask_Hty = new Dt_SupplyTask_Hty()
{
WarehouseCode = inventoryInfo.WarehouseCode,
@@ -86,6 +93,8 @@
_inventory_BatchServices.UpdateData(batchesUp);
_deliveryOrderDetailServices.UpdateData(cabinOrderDetailsUp);
BaseDal.UpdateData(deliveryOrder);
+ //娣诲姞鐗╂枡淇℃伅涓殑绔嬪簱涓氬姟搴撳瓨淇℃伅
+ _materielInfoService.UpdateData(MaterieInfoBusiness);
_unitOfWorkManage.CommitTran();
}
catch (Exception ex)
--
Gitblit v1.9.3