コード例 #1
0
ファイル: ProcessMrp.cs プロジェクト: langzimu/ng-erp-4.0
        public void ExecutePlanning(IDemandToProvider demand, MrpTask task, int simulationId)
        {
            //creates Provider for the needs
            var productionOrders = _demandForecast.NetRequirement(demand, task, simulationId);

            if (demand.State != State.Finished)
            {
                demand.State = State.ProviderExist;
            }

            var articleBoms = _context.ArticleBoms
                              .Include(a => a.ArticleChild)
                              .ThenInclude(a => a.ArticleBoms)
                              .ToList();

            //If there was enough in stock this does not have to be produced
            if (!productionOrders.Any())
            {
                return;
            }
            foreach (var productionOrder in productionOrders)
            {
                //if the ProductionOrder was just created, initialize concrete WorkSchedules for the ProductionOrders
                if (productionOrder.ProductionOrderWorkSchedule == null ||
                    !productionOrder.ProductionOrderWorkSchedule.Any())
                {
                    _context.CreateProductionOrderWorkSchedules(productionOrder);
                }

                var children = articleBoms.Where(a => a.ArticleParentId == productionOrder.ArticleId)
                               .ToList();

                if (!children.Any())
                {
                    return;
                }
                foreach (var child in children)
                {
                    //create Requester
                    var dpob = _context.CreateDemandProductionOrderBom(child.ArticleChildId, productionOrder.Quantity * (int)child.Quantity);
                    //create Production-BOM
                    _context.TryCreateProductionOrderBoms(dpob, productionOrder, simulationId);
                    //call this method recursively for a depth-first search
                    ExecutePlanning(dpob, task, simulationId);
                }
            }
        }
コード例 #2
0
ファイル: RebuildNets.cs プロジェクト: langzimu/ng-erp-4.0
        private void CallChildrenSatisfyRequest(ProductionOrder po, int simulationId, ProductionDomainContext evaluationContext)
        {
            if (po.ProductionOrderBoms != null && po.ProductionOrderBoms.Any())
            {
                return;
            }
            //call method for each child
            var childrenArticleBoms = _context.ArticleBoms.Include(a => a.ArticleChild).Where(a => a.ArticleParentId == po.ArticleId).ToList();

            foreach (var childBom in childrenArticleBoms)
            {
                var neededAmount = childBom.Quantity * po.Quantity;
                var demandBom    = _context.CreateDemandProductionOrderBom(childBom.ArticleChildId, neededAmount);
                _context.TryCreateProductionOrderBoms(demandBom, po, simulationId);
                SatisfyRequest(demandBom, simulationId, evaluationContext);
            }
        }