Пример #1
0
 public RequirementsDay(ProductRequirements parentRequirements, DateTime day)
 {
     ParentRequirements = parentRequirements;
     Day = day;
     foreach (var coatingLine in StaticFactoryValuesManager.CoatingLines)
     {
         hoursAvailable[coatingLine] = ShiftHandler.CoatingInstance.GetHoursOnDay(day, coatingLine);
         hoursUsed[coatingLine]      = 0;
     }
 }
Пример #2
0
        private static void CalculateAllRequirements()
        {
            Queue <ProductRequirements> updateQueue = new Queue <ProductRequirements>(_allRequirements);

            // Update all master requirements
            while (updateQueue.Count > 0)
            {
                ProductRequirements currentRequirement = updateQueue.Dequeue();

                currentRequirement.UpdateInventory(_earliestDay);

                DateTime day = _earliestDay;

                while (day <= _latestDay)
                {
                    var reqDay = currentRequirement.GetRequirementDay(day);
                    if (reqDay.NetRequiredPieces > 0)
                    {
                        double        leadHours = 0;
                        Configuration config    =
                            MachineHandler.Instance.AllConfigurations.FirstOrDefault(
                                c => c.CanMake(currentRequirement.MasterItem));
                        if (config != null)
                        {
                            leadHours = config.HoursToMake(currentRequirement.MasterItem, reqDay.NetRequiredPieces / currentRequirement.MasterItem.PiecesPerUnit);
                        }

                        DateTime POday    = day.AddDays(Math.Ceiling(leadHours / 24 + LeadTimeDays));
                        var      POreqDay = currentRequirement.GetRequirementDay(POday);
                        POreqDay.PurchaseOrderPieces = (reqDay.NetRequiredPieces);
                        // add gross for any dependent items
                        if (currentRequirement.Input != null)
                        {
                            foreach (var configItem in currentRequirement.Input)
                            {
                                var ratio    = configItem.Pieces / currentRequirement.OutPieces;
                                var childReq = GetRequirements(configItem.MasterID);
                                var childDay = childReq.GetRequirementDay(POday);
                                childDay.AddGrossRequirement(ratio * reqDay.NetRequiredPieces);

                                // Add this child item to be updated
                                if (!updateQueue.Contains(childReq))
                                {
                                    updateQueue.Enqueue(childReq);
                                }
                            }
                        }
                    }
                    day = day.AddDays(1);
                }
            }
        }