private void VerifyEveryMachineHasOnlyOneOperationAtAnyTime(IAggregator aggregator) { IDbMasterDataCache dbMasterDataCache = ZppConfiguration.CacheManager.GetMasterDataCache(); foreach (var resource in dbMasterDataCache.ResourceGetAll()) { List <ProductionOrderOperation> operations = aggregator.GetAllOperationsOnResource(resource.GetValue()); T_ProductionOrderOperation lastOperation = null; foreach (var operation in operations.OrderBy(x => x.GetValue().Start)) { T_ProductionOrderOperation tOperation = operation.GetValue(); if (lastOperation == null) { lastOperation = operation.GetValue(); } else { Assert.True(lastOperation.End <= tOperation.Start, $"Operations are overlapping: '{lastOperation}' and {tOperation}'."); } } } }
public void TestPurchaseQuantityIsAMultipleOfPackSize() { IZppSimulator zppSimulator = new global::Master40.SimulationMrp.impl.ZppSimulator(); zppSimulator.StartTestCycle(); IDbMasterDataCache dbMasterDataCache = ZppConfiguration.CacheManager.GetMasterDataCache(); IDbTransactionData persistedTransactionData = ZppConfiguration.CacheManager.ReloadTransactionData(); List <T_PurchaseOrderPart> tPurchaseOrderParts = persistedTransactionData .PurchaseOrderPartGetAll().GetAllAs <T_PurchaseOrderPart>(); foreach (var tPurchaseOrderPart in tPurchaseOrderParts) { M_ArticleToBusinessPartner articleToBusinessPartner = dbMasterDataCache.M_ArticleToBusinessPartnerGetAllByArticleId( new Id(tPurchaseOrderPart.ArticleId))[0]; Quantity multiplier = new Quantity(1); while (multiplier.GetValue() * articleToBusinessPartner.PackSize < tPurchaseOrderPart.Quantity) { multiplier.IncrementBy(new Quantity(1)); } Quantity expectedPurchaseQuantity = new Quantity(multiplier.GetValue() * articleToBusinessPartner.PackSize); Assert.True(tPurchaseOrderPart.GetQuantity().Equals(expectedPurchaseQuantity), $"Quantity of PurchaseOrderPart ({tPurchaseOrderPart}) ist not a multiple of packSize."); } }
public void TestALotSize() { IDbMasterDataCache dbMasterDataCache = ZppConfiguration.CacheManager.GetMasterDataCache(); LotSize lotSize = new LotSize(new Quantity(6), dbMasterDataCache.M_ArticleGetAll()[0].GetId()); foreach (var quantity in lotSize.GetLotSizes()) { Assert.True(quantity.GetValue() == TestConfiguration.LotSize, $"Quantity ({quantity}) is not correct."); } }
public static CustomerOrderPart CreateCustomerOrderPartRandomArticleToBuy( int quantity, DueTime dueTime) { IDbMasterDataCache dbMasterDataCache = ZppConfiguration.CacheManager.GetMasterDataCache(); List <M_Article> articlesToBuy = dbMasterDataCache.M_ArticleGetArticlesToBuy(); int randomArticleIndex = random.Next(0, articlesToBuy.Count - 1); CustomerOrderPart customerOrderPart = CreateCustomerOrderPartWithGivenArticle(quantity, articlesToBuy[randomArticleIndex], dueTime); return(customerOrderPart); }
private static T_CustomerOrder CreateCustomerOrder(DueTime dueTime) { IDbMasterDataCache dbMasterDataCache = ZppConfiguration.CacheManager.GetMasterDataCache(); var order = new T_CustomerOrder() { BusinessPartnerId = dbMasterDataCache.M_BusinessPartnerGetAll()[0].Id, DueTime = dueTime.GetValue(),//, CreationTime = 0, Name = $"RandomProductionOrder{random.Next()}", }; return(order); }
public CustomerOrderCreator(Quantity defaultCustomerOrderQuantityPerCycle) { if (defaultCustomerOrderQuantityPerCycle != null && defaultCustomerOrderQuantityPerCycle.IsSmallerThan( _defaultCustomerOrderQuantityPerCycle)) { _defaultCustomerOrderQuantityPerCycle = defaultCustomerOrderQuantityPerCycle; } var orderArrivalRate = new OrderArrivalRate(0.025); IDbMasterDataCache masterDataCache = ZppConfiguration.CacheManager.GetMasterDataCache(); _orderGenerator = TestScenario.GetOrderGenerator(new MinDeliveryTime(200), new MaxDeliveryTime(1430), orderArrivalRate, masterDataCache.M_ArticleGetAll(), masterDataCache.M_BusinessPartnerGetAll()); }
private void EnsureMachineIsLoaded() { if (_productionOrderOperation.Resource == null) { if (_productionOrderOperation.ResourceId == null) { throw new MrpRunException( "Cannot load Machine, if this operation is not yet planned."); } Id resourceId = new Id(_productionOrderOperation.ResourceId.GetValueOrDefault()); IDbMasterDataCache dbMasterDataCache = ZppConfiguration.CacheManager.GetMasterDataCache(); Resource resource = dbMasterDataCache.M_ResourceGetById(resourceId); _productionOrderOperation.Resource = resource.GetValue(); } }
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 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); }