示例#1
0
        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()));
        }