| | |
| | | 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") |
| | | { |
| | |
| | | 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, |
| | |
| | | _inventory_BatchServices.UpdateData(batchesUp); |
| | | _deliveryOrderDetailServices.UpdateData(cabinOrderDetailsUp); |
| | | BaseDal.UpdateData(deliveryOrder); |
| | | //æ·»å ç©æä¿¡æ¯ä¸çç«åºä¸å¡åºåä¿¡æ¯ |
| | | _materielInfoService.UpdateData(MaterieInfoBusiness); |
| | | _unitOfWorkManage.CommitTran(); |
| | | } |
| | | catch (Exception ex) |