private void AllotPiece(MoveBillMaster moveBillMaster, IOrderedQueryable <Storage> ss, Cell cell, ref decimal quantity, CancellationToken cancellationToken, ProgressState ps) { foreach (var s in ss.ToArray()) { if (cancellationToken.IsCancellationRequested) { return; } if (quantity > 0) { decimal allotQuantity = s.Quantity - s.OutFrozenQuantity; decimal billQuantity = Math.Floor(quantity / s.Product.Unit.Count) * s.Product.Unit.Count; allotQuantity = allotQuantity < billQuantity ? allotQuantity : billQuantity; if (allotQuantity > 0) { var sourceStorage = Locker.LockNoEmptyStorage(s, s.Product); var targetStorage = Locker.LockStorage(cell); if (sourceStorage != null && targetStorage != null && targetStorage.Quantity == 0 && targetStorage.InFrozenQuantity == 0) { MoveBillCreater.AddToMoveBillDetail(moveBillMaster, sourceStorage, targetStorage, allotQuantity); quantity -= allotQuantity; } else { ps.Errors.Add("可用的移入目标库存记录不足!"); } } //else break; } else { break; } } }
private void AllotBar(MoveBillMaster moveBillMaster, IOrderedQueryable <Storage> ss, Cell cell, ref decimal quantity, CancellationToken cancellationToken) { foreach (var s in ss.ToArray()) { if (cancellationToken.IsCancellationRequested) { return; } if (quantity > 0) { decimal allotQuantity = s.Quantity - s.OutFrozenQuantity; decimal billQuantity = quantity; allotQuantity = allotQuantity < billQuantity ? allotQuantity : billQuantity; if (allotQuantity > 0) { var sourceStorage = Locker.LockNoEmptyStorage(s, s.Product); var targetStorage = Locker.LockStorage(cell); if (sourceStorage != null && targetStorage != null && targetStorage.Quantity == 0 && targetStorage.InFrozenQuantity == 0) { MoveBillCreater.AddToMoveBillDetail(moveBillMaster, sourceStorage, targetStorage, allotQuantity); quantity -= allotQuantity; } } else { break; } } else { break; } } }