private void JobShopScheduling(OrderOperationGraph orderOperationGraph) { IDbTransactionData dbTransactionData = ZppConfiguration.CacheManager.GetDbTransactionData(); IAggregator aggregator = ZppConfiguration.CacheManager.GetAggregator(); // some validations if (dbTransactionData.ProductionOrderGetAll().Any() == false) { // no JobShopScheduling needed, all Demands were satisfied without the need for a productionOrder return; } foreach (var productionOrder in dbTransactionData.ProductionOrderGetAll()) { List <ProductionOrderOperation> operations = aggregator.GetProductionOrderOperationsOfProductionOrder( (ProductionOrder)productionOrder); if (operations == null || operations.Any() == false) { throw new MrpRunException( "How could it happen, that a productionOrder without operations exists ?"); } } // start ! IDirectedGraph <INode> operationGraph = new OperationGraph(orderOperationGraph); _jobShopScheduler.ScheduleWithGifflerThompsonAsZaepfel( new PriorityRule(operationGraph), operationGraph); }
private static void HandleProductionOrderIsInStateCreated(ProductionOrder productionOrder, IAggregator aggregator, IDbTransactionData dbTransactionData) { // delete all operations List <ProductionOrderOperation> operations = aggregator.GetProductionOrderOperationsOfProductionOrder(productionOrder); dbTransactionData.ProductionOrderOperationDeleteAll(operations); // collect entities and demandToProviders/providerToDemands to delete List <IDemandOrProvider> demandOrProvidersToDelete = CreateProductionOrderSubGraph(true, productionOrder, aggregator); // delete all collected entities IOpenDemandManager openDemandManager = ZppConfiguration.CacheManager.GetOpenDemandManager(); foreach (var demandOrProvider in demandOrProvidersToDelete) { // don't forget to delete it from openDemands if (demandOrProvider.GetType() == typeof(StockExchangeDemand)) { if (openDemandManager.Contains((Demand)demandOrProvider)) { openDemandManager.RemoveDemand((Demand)demandOrProvider); } } List <ILinkDemandAndProvider> demandAndProviderLinks = aggregator.GetArrowsToAndFrom(demandOrProvider); dbTransactionData.DeleteAllFrom(demandAndProviderLinks); dbTransactionData.DeleteA(demandOrProvider); } }
private static void ArchiveOperations(IDbTransactionData dbTransactionData, IDbTransactionData dbTransactionDataArchive, IAggregator aggregator, ProductionOrder productionOrder) { List <ProductionOrderOperation> operations = aggregator.GetProductionOrderOperationsOfProductionOrder(productionOrder); dbTransactionDataArchive.ProductionOrderOperationAddAll(operations); dbTransactionData.ProductionOrderOperationDeleteAll(operations); }
private Priority GetPriorityOfProductionOrderOperation(DueTime now, ProductionOrderOperation givenProductionOrderOperation, DueTime minStartNextOfParentProvider) { IAggregator aggregator = ZppConfiguration.CacheManager.GetAggregator(); Dictionary <HierarchyNumber, DueTime> alreadySummedHierarchyNumbers = new Dictionary <HierarchyNumber, DueTime>(); DueTime sumDurationsOfOperations = DueTime.Zero(); // O(1) List <ProductionOrderOperation> productionOrderOperations = aggregator.GetProductionOrderOperationsOfProductionOrder(givenProductionOrderOperation .GetProductionOrderId()); foreach (var productionOrderOperation in productionOrderOperations) { // only later operations, which have a smaller hierarchyNumber, have to be considered if (productionOrderOperation.GetHierarchyNumber() .IsSmallerThan(givenProductionOrderOperation.GetHierarchyNumber())) { continue; } if (alreadySummedHierarchyNumbers.ContainsKey(productionOrderOperation .GetHierarchyNumber())) { DueTime alreadySummedHierarchyNumber = alreadySummedHierarchyNumbers[ productionOrderOperation.GetHierarchyNumber()]; if (productionOrderOperation.GetDuration().ToDueTime() .IsGreaterThan(alreadySummedHierarchyNumber)) { sumDurationsOfOperations.IncrementBy(productionOrderOperation.GetDuration() .ToDueTime().Minus(alreadySummedHierarchyNumber)); } } else { alreadySummedHierarchyNumbers.Add(productionOrderOperation.GetHierarchyNumber(), productionOrderOperation.GetDuration().ToDueTime()); } } return(new Priority(minStartNextOfParentProvider.Minus(now) .Minus(sumDurationsOfOperations).GetValue())); }
/** * determines state from all operations */ public State DetermineProductionOrderState() { IAggregator aggregator = ZppConfiguration.CacheManager.GetAggregator(); bool atLeastOneIsInProgress = false; bool atLeastOneIsFinished = false; bool atLeastOneIsInStateCreated = false; var productionOrderOperations = aggregator.GetProductionOrderOperationsOfProductionOrder(this); foreach (var productionOrderOperation in productionOrderOperations) { if (productionOrderOperation.IsInProgress()) { atLeastOneIsInProgress = true; break; } else if (productionOrderOperation.IsFinished()) { atLeastOneIsFinished = true; } else { atLeastOneIsInStateCreated = true; } } if (atLeastOneIsInProgress || atLeastOneIsInStateCreated && atLeastOneIsFinished) { return(State.InProgress); } else if (atLeastOneIsInStateCreated && !atLeastOneIsInProgress && !atLeastOneIsFinished) { return(State.Created); } else if (atLeastOneIsFinished && !atLeastOneIsInProgress && !atLeastOneIsInStateCreated) { return(State.Finished); } else { throw new MrpRunException("This state is not expected."); } }