internal void AddToStock(T_StockExchange stockExchange) { _providerQueue.Enqueue(new StockItem { QuantityLeft = new Quantity(stockExchange.Quantity) , StockExchange = stockExchange }); }
public static Demand CreateStockExchangeProductionOrderDemand(M_ArticleBom articleBom, DueTime dueTime) { IDbMasterDataCache dbMasterDataCache = ZppConfiguration.CacheManager.GetMasterDataCache(); T_StockExchange stockExchange = new T_StockExchange(); stockExchange.StockExchangeType = StockExchangeType.Demand; stockExchange.Quantity = articleBom.Quantity; stockExchange.State = State.Created; M_Stock stock = dbMasterDataCache.M_StockGetByArticleId(new Id(articleBom.ArticleChildId)); stockExchange.Stock = stock; stockExchange.StockId = stock.Id; stockExchange.RequiredOnTime = dueTime.GetValue(); stockExchange.ExchangeType = ExchangeType.Withdrawal; StockExchangeDemand stockExchangeDemand = new StockExchangeDemand(stockExchange); return(stockExchangeDemand); }
public StockManager(M_Stock stockElement) { var initalStock = new T_StockExchange { StockId = stockElement.Id, ExchangeType = ExchangeType.Insert, Quantity = stockElement.StartValue, State = State.Finished, RequiredOnTime = 0, Time = 0 }; Stock = stockElement; _providerQueue = new Queue <StockItem>(); StockExchanges = new List <T_StockExchange> { initalStock }; if (stockElement.StartValue > 0) { AddToStock(initalStock); } }
/** * returns a provider, which can be a stockExchangeProvider, if article can be fulfilled by stock, else * a productionOrder/purchaseOrderPart */ private Provider CreateStockExchangeProvider(M_Article article, DueTime dueTime, Quantity demandedQuantity) { if (demandedQuantity == null || demandedQuantity.GetValue() == 0) { throw new MrpRunException("Quantity is not set."); } M_Stock stock = _dbMasterDataCache.M_StockGetByArticleId(article.GetId()); T_StockExchange stockExchange = new T_StockExchange(); stockExchange.StockExchangeType = StockExchangeType.Provider; stockExchange.Quantity = demandedQuantity.GetValue(); // TODO: PASCAL .GetValueOrDefault(); stockExchange.State = State.Created; stockExchange.Stock = stock; stockExchange.StockId = stock.Id; stockExchange.RequiredOnTime = dueTime.GetValue(); stockExchange.ExchangeType = ExchangeType.Withdrawal; StockExchangeProvider stockExchangeProvider = new StockExchangeProvider(stockExchange); return(stockExchangeProvider); }
private void ResponseFromProduction(FProductionResult productionResult) { Agent.DebugMessage(msg: $"{productionResult.Amount} {_stockElement.Article.Name} was send from {Agent.Sender.Path.Name}"); // Add the Produced item to Stock _stockElement.Current += productionResult.Amount; LogValueChange(article: _stockElement.Article, value: Convert.ToDouble(value: _stockElement.Current) * Convert.ToDouble(value: _stockElement.Article.Price)); var stockExchange = new T_StockExchange { StockId = _stockElement.Id, ExchangeType = ExchangeType.Insert, Quantity = productionResult.Amount, State = State.Finished, RequiredOnTime = (int)Agent.CurrentTime, Time = (int)Agent.CurrentTime, ProductionArticleKey = productionResult.Key }; _stockElement.StockExchanges.Add(item: stockExchange); _providerList.Add(item: stockExchange); // Check if the most Important Request can be provided. var mostUrgentRequest = _requestedArticles.First(predicate: x => x.DueTime == _requestedArticles.Min(selector: r => r.DueTime)); //TODO: might be a problem if (mostUrgentRequest.IsHeadDemand && mostUrgentRequest.DueTime > Agent.CurrentTime) { Agent.DebugMessage(msg: $"{_stockElement.Article.Name} {mostUrgentRequest.Key} finished before due. CostumerOrder {mostUrgentRequest.CustomerOrderId} will ask at {mostUrgentRequest.DueTime} for article."); return; } // else if if (mostUrgentRequest.Quantity <= _stockElement.Current) { Agent.DebugMessage(msg: $"{_stockElement.Article.Name} {mostUrgentRequest.Key} is providable {mostUrgentRequest.Quantity} does match current Stock amount of {_stockElement.Current}."); ProvideArticle(articleKey: mostUrgentRequest.Key); } }
internal long CreatePurchase(M_Stock stockElement) { var time = stockElement.Article .ArticleToBusinessPartners .Single(predicate: x => x.BusinessPartner.Kreditor) .TimeToDelivery; var stockExchange = new T_StockExchange { StockId = stockElement.Id, ExchangeType = ExchangeType.Insert, State = State.Created, Time = (int)(Agent.CurrentTime), Quantity = stockElement.Article.Stock.Max - stockElement.Article.Stock.Min, RequiredOnTime = (int)(Agent.CurrentTime) + time, TrackingGuid = Guid.NewGuid() }; _stockManager.StockExchanges.Add(item: stockExchange); // TODO Needs logic if more Kreditors are Added. // TODO start CreatePurchase later if materials are needed later Agent.Send(instruction: Storage.Instruction.StockRefill.Create(message: stockExchange.TrackingGuid, target: Agent.Context.Self), waitFor: time); return(time); }
public static Demand CreateStockExchangeStockDemand(Id articleId, DueTime dueTime, Quantity quantity) { if (quantity == null || quantity.GetValue() == null) { throw new MrpRunException("Quantity is not set."); } IDbMasterDataCache dbMasterDataCache = ZppConfiguration.CacheManager.GetMasterDataCache(); T_StockExchange stockExchange = new T_StockExchange(); stockExchange.StockExchangeType = StockExchangeType.Demand; stockExchange.Quantity = quantity.GetValue().GetValueOrDefault(); stockExchange.State = State.Created; M_Stock stock = dbMasterDataCache.M_StockGetByArticleId(articleId); stockExchange.Stock = stock; stockExchange.StockId = stock.Id; stockExchange.RequiredOnTime = dueTime.GetValue(); stockExchange.ExchangeType = ExchangeType.Insert; StockExchangeDemand stockExchangeDemand = new StockExchangeDemand(stockExchange); return(stockExchangeDemand); }
public StockExchangeProvider(IProvider provider) : base(provider) { _stockExchangeProvider = (T_StockExchange)provider; }
public StockExchangeDemand(IDemand demand) : base(demand) { _tStockExchangeDemand = (T_StockExchange)demand; }