Exemplo n.º 1
0
        private EntityCollector MaterialRequirementsPlanningForOneDemand(Demand demand,
                                                                         IProviderManager providerManager)
        {
            EntityCollector entityCollector = new EntityCollector();

            EntityCollector response = providerManager.Satisfy(demand, demand.GetQuantity());

            entityCollector.AddAll(response);
            response = providerManager.CreateDependingDemands(entityCollector.GetProviders());
            entityCollector.AddAll(response);

            if (entityCollector.IsSatisfied(demand) == false)
            {
                throw new MrpRunException($"'{demand}' was NOT satisfied: remaining is " +
                                          $"{entityCollector.GetRemainingQuantity(demand)}");
            }

            return(entityCollector);
        }
Exemplo n.º 2
0
        public EntityCollector CreateDependingDemands(Providers providers)
        {
            EntityCollector entityCollector = new EntityCollector();

            foreach (var provider in providers)
            {
                EntityCollector response;
                if (provider.GetType() == typeof(ProductionOrder))
                {
                    response = _productionManager.CreateDependingDemands(provider);
                    entityCollector.AddAll(response);
                }
                else if (provider.GetType() == typeof(StockExchangeProvider))
                {
                    response = _stockManager.CreateDependingDemands(provider);
                    entityCollector.AddAll(response);
                }
            }

            return(entityCollector);
        }
        public EntityCollector CreateDependingDemands(Provider provider)
        {
            EntityCollector entityCollector  = new EntityCollector();
            Demands         dependingDemands = CreateProductionOrderBoms(provider.GetArticle(), provider,
                                                                         provider.GetQuantity());

            entityCollector.AddAll(dependingDemands);
            foreach (var dependingDemand in dependingDemands)
            {
                T_ProviderToDemand providerToDemand = new T_ProviderToDemand(provider.GetId(),
                                                                             dependingDemand.GetId(), dependingDemand.GetQuantity());
                entityCollector.Add(providerToDemand);
            }

            return(entityCollector);
        }
Exemplo n.º 4
0
        public void StartMrp1()
        {
            // init
            int MAX_DEMANDS_IN_QUEUE = 100000;

            FastPriorityQueue <DemandQueueNode> demandQueue =
                new FastPriorityQueue <DemandQueueNode>(MAX_DEMANDS_IN_QUEUE);

            IProviderManager providerManager = new ProviderManager();

            foreach (var demand in dbDemands)
            {
                demandQueue.Enqueue(new DemandQueueNode(demand), demand.GetStartTimeBackward().GetValue());
            }

            EntityCollector allCreatedEntities = new EntityCollector();

            while (demandQueue.Count != 0)
            {
                DemandQueueNode firstDemandInQueue = demandQueue.Dequeue();

                EntityCollector response =
                    MaterialRequirementsPlanningForOneDemand(firstDemandInQueue.GetDemand(), providerManager);
                allCreatedEntities.AddAll(response);

                foreach (var demand in response.GetDemands())
                {
                    demandQueue.Enqueue(new DemandQueueNode(demand),
                                        demand.GetStartTimeBackward().GetValue());
                }
            }

            // write data to _dbTransactionData
            IDbTransactionData dbTransactionData =
                ZppConfiguration.CacheManager.GetDbTransactionData();

            dbTransactionData.AddAllFrom(allCreatedEntities);
            // End of MaterialRequirementsPlanning
        }