Example #1
0
        private void ManufacturingResourcePlanning(Demands dbDemands)
        {
            if (dbDemands == null || dbDemands.Any() == false)
            {
                throw new MrpRunException(
                          "How could it happen, that no dbDemands are given to plan ?");
            }

            // MaterialRequirementsPlanning
            IMrp1 mrp1 = new Mrp1.impl.Mrp1(dbDemands);

            mrp1.StartMrp1();


            // BackwardForwardBackwardScheduling

            OrderOperationGraph orderOperationGraph = new OrderOperationGraph();

            ScheduleBackwardFirst(orderOperationGraph);
            AssertEveryDemandAndProviderIsScheduled();

            ScheduleForward(orderOperationGraph, _simulationInterval);
            ScheduleBackwardSecond(orderOperationGraph);

            // job shop scheduling
            JobShopScheduling(orderOperationGraph);
        }
Example #2
0
        public DueTime GetEarliestPossibleStartTimeOf(
            ProductionOrderOperation productionOrderOperation)
        {
            DueTime   maximumOfEarliestStartTimes = null;
            Providers providers = ZppConfiguration.CacheManager.GetAggregator()
                                  .GetAllChildStockExchangeProvidersOf(productionOrderOperation);

            foreach (var stockExchangeProvider in providers)
            {
                DueTime earliestStartTime = productionOrderOperation.GetStartTimeBackward();
                if (earliestStartTime.IsGreaterThanOrEqualTo(stockExchangeProvider
                                                             .GetStartTimeBackward()))
                {
                    earliestStartTime = stockExchangeProvider.GetStartTimeBackward();
                }
                else
                {
                    throw new MrpRunException(
                              "A provider of a demand cannot have a later dueTime.");
                }

                Demands stockExchangeDemands = ZppConfiguration.CacheManager.GetAggregator()
                                               .GetAllChildDemandsOf(stockExchangeProvider);
                if (stockExchangeDemands.Any() == false)
                // StockExchangeProvider has no childs (stockExchangeDemands),
                // take that from stockExchangeProvider
                {
                    DueTime childDueTime = stockExchangeProvider.GetStartTimeBackward();
                    if (childDueTime.IsGreaterThan(earliestStartTime))
                    {
                        earliestStartTime = childDueTime;
                    }
                }
                else
                // StockExchangeProvider has childs (stockExchangeDemands)
                {
                    foreach (var stockExchangeDemand in stockExchangeDemands)
                    {
                        DueTime stockExchangeDemandDueTime =
                            stockExchangeDemand.GetStartTimeBackward();
                        if (stockExchangeDemandDueTime.IsGreaterThan(earliestStartTime))
                        {
                            earliestStartTime = stockExchangeDemandDueTime;
                        }
                    }
                }

                if (maximumOfEarliestStartTimes == null ||
                    earliestStartTime.IsGreaterThan(maximumOfEarliestStartTimes))
                {
                    maximumOfEarliestStartTimes = earliestStartTime;
                }
            }

            return(maximumOfEarliestStartTimes);
        }
Example #3
0
        public DueTime GetEarliestPossibleStartTimeOf(ProductionOrderBom productionOrderBom)
        {
            DueTime   earliestStartTime = productionOrderBom.GetStartTimeBackward();
            Providers providers         = ZppConfiguration.CacheManager.GetAggregator()
                                          .GetAllChildProvidersOf(productionOrderBom);

            if (providers.Count() > 1)
            {
                throw new MrpRunException("A productionOrderBom can only have one provider !");
            }


            Provider stockExchangeProvider = providers.GetAny();

            if (earliestStartTime.IsGreaterThanOrEqualTo(
                    stockExchangeProvider.GetStartTimeBackward()))
            {
                earliestStartTime = stockExchangeProvider.GetStartTimeBackward();
            }
            else
            {
                throw new MrpRunException("A provider of a demand cannot have a later dueTime.");
            }

            Demands stockExchangeDemands = ZppConfiguration.CacheManager.GetAggregator()
                                           .GetAllChildDemandsOf(stockExchangeProvider);

            if (stockExchangeDemands.Any() == false)
            // StockExchangeProvider has no childs (stockExchangeDemands),
            // take that from stockExchangeProvider
            {
                DueTime childDueTime = stockExchangeProvider.GetStartTimeBackward();
                if (childDueTime.IsGreaterThan(earliestStartTime))
                {
                    earliestStartTime = childDueTime;
                }
            }
            else
            // StockExchangeProvider has childs (stockExchangeDemands)
            {
                foreach (var stockExchangeDemand in stockExchangeDemands)
                {
                    DueTime stockExchangeDemandDueTime = stockExchangeDemand.GetStartTimeBackward();
                    if (stockExchangeDemandDueTime.IsGreaterThan(earliestStartTime))
                    {
                        earliestStartTime = stockExchangeDemandDueTime;
                    }
                }
            }

            return(earliestStartTime);
        }
        private static void ArchiveStockExchangeProvidersWithoutChilds(
            IDbTransactionData dbTransactionData, IAggregator aggregator)
        {
            Providers copyOfStockExchangeProviders = new Providers();

            copyOfStockExchangeProviders.AddAll(dbTransactionData.StockExchangeProvidersGetAll());
            foreach (var stockExchangeProvider in copyOfStockExchangeProviders)
            {
                Demands stockExchangeDemands =
                    aggregator.GetAllChildDemandsOf(stockExchangeProvider);
                if (stockExchangeDemands == null || stockExchangeDemands.Any() == false)
                {
                    ArchiveDemandOrProvider(stockExchangeProvider, dbTransactionData, aggregator,
                                            false);
                }
            }
        }
        public void TestApplyConfirmations(string testConfigurationFileName)
        {
            InitThisTest(testConfigurationFileName);

            IDbTransactionData dbTransactionData =
                ZppConfiguration.CacheManager.GetDbTransactionData();
            IAggregator aggregator = ZppConfiguration.CacheManager.GetAggregator();

            // Ein CustomerOrderParts darf kein Kind haben und darf nicht beendet sein
            Ids customerOrderIds = new Ids();

            foreach (var demand in dbTransactionData.CustomerOrderPartGetAll())
            {
                CustomerOrderPart customerOrderPart = (CustomerOrderPart)demand;
                customerOrderIds.Add(customerOrderPart.GetCustomerOrderId());
                Providers childs = aggregator.GetAllChildProvidersOf(customerOrderPart);
                Assert.False(childs.Any());
                Assert.False(customerOrderPart.IsFinished());
            }

            // Ein PurchaseOrderPart darf kein Elter haben und darf nicht beendet sein.
            Ids purchaseOrderIds = new Ids();

            foreach (var demand in dbTransactionData.PurchaseOrderPartGetAll())
            {
                PurchaseOrderPart purchaseOrderPart = (PurchaseOrderPart)demand;
                purchaseOrderIds.Add(purchaseOrderPart.GetPurchaseOrderId());

                Assert.False(purchaseOrderPart.IsFinished());
                Demands demands = aggregator.GetAllParentDemandsOf(demand);
                Assert.True(demands == null || demands.Any() == false);
            }

            // Für jede CustomerOrder muss es mind. noch ein CustomerOrderPart geben.
            foreach (var customerOrder in dbTransactionData.CustomerOrderGetAll())
            {
                Assert.True(customerOrderIds.Contains(customerOrder.GetId()));
            }

            // Für jede PurchaseOrder muss es mind. noch ein PurchaseOrderPart geben.
            foreach (var purchaseOrder in dbTransactionData.PurchaseOrderGetAll())
            {
                Assert.True(purchaseOrderIds.Contains(purchaseOrder.GetId()));
            }

            // Ein StockExchangeProvider muss mind. ein Kind haben.
            foreach (var stockExchangeProvider in dbTransactionData.StockExchangeProvidersGetAll())
            {
                Demands childs = aggregator.GetAllChildDemandsOf(stockExchangeProvider);
                Assert.True(childs.Any());
            }

            // Ein StockExchangeDemand darf nicht beendet und geschlossen sein.
            foreach (var stockExchangeDemand in dbTransactionData.StockExchangeDemandsGetAll())
            {
                bool isOpen = OpenDemandManager.IsOpen((StockExchangeDemand)stockExchangeDemand);
                Assert.False(stockExchangeDemand.IsFinished() && isOpen == false);
            }

            // Eine ProductionOrder darf nicht beendet sein und für eine ProductionOrder
            // muss es mind. eine  Operation geben.
            Ids productionOrderIds = new Ids();
            Ids operationIds       = new Ids();

            foreach (var operation in dbTransactionData.ProductionOrderOperationGetAll())
            {
                Id productionOrderId = operation.GetProductionOrderId();
                if (productionOrderIds.Contains(productionOrderId) == false)
                {
                    productionOrderIds.Add(productionOrderId);
                }

                operationIds.Add(operation.GetId());
            }
            foreach (var provider in dbTransactionData.ProductionOrderGetAll())
            {
                ProductionOrder productionOrder = (ProductionOrder)provider;
                Assert.False(productionOrder.DetermineProductionOrderState()
                             .Equals(State.Finished));
                Assert.True(productionOrderIds.Contains(productionOrder.GetId()));
            }

            // Für jede ProductionOrderBom muss die dazugehörige Operation da sein.
            foreach (var demand in dbTransactionData.ProductionOrderBomGetAll())
            {
                ProductionOrderBom productionOrderBom = (ProductionOrderBom)demand;
                operationIds.Contains(productionOrderBom.GetProductionOrderOperationId());
            }

            // Für jeden DemandToProvider und ProviderToDemand müssen die dazugehörigen
            // Demands und Provider existieren.
            foreach (var demandToProvider in dbTransactionData.DemandToProviderGetAll())
            {
                Demand   demand   = dbTransactionData.DemandsGetById(demandToProvider.GetDemandId());
                Provider provider =
                    dbTransactionData.ProvidersGetById(demandToProvider.GetProviderId());
                Assert.NotNull(demand);
                Assert.NotNull(provider);
            }

            foreach (var providerToDemand in dbTransactionData.ProviderToDemandGetAll())
            {
                Demand   demand   = dbTransactionData.DemandsGetById(providerToDemand.GetDemandId());
                Provider provider =
                    dbTransactionData.ProvidersGetById(providerToDemand.GetProviderId());
                Assert.NotNull(demand);
                Assert.NotNull(provider);
            }
        }