Пример #1
0
        public List <PcsReworkTotals> CheckForReworkCompliance(List <BatchReport> reports)
        {
            List <PcsReworkTotals> reworkTotals = new List <PcsReworkTotals>();

            foreach (var recipe in Parameters.Select(x => x.RecipeName))
            {
                reworkTotals.Add(new PcsReworkTotals {
                    RecipeName = recipe
                });
            }

            foreach (var report in reports)
            {
                if (CurrentReportShouldHaveRework(report))
                {
                    PcsReworkTotals currentTotal = new PcsReworkTotals();
                    Material        rework       = _helperMethods.FindReworkInBatch(report);

                    if (rework != null)
                    {
                        currentTotal.ActualReworkAmount   = Convert.ToDecimal(rework.ActualWeight);
                        currentTotal.BatchesMade          = 1;
                        currentTotal.ExpectedReworkAmount = GetExpectedReworkAmount(report.Recipe);
                        currentTotal.BatchesWithRework    = 1;
                        currentTotal.RecipeName           = report.Recipe;
                    }
                    else
                    {
                        currentTotal.ActualReworkAmount   = 0;
                        currentTotal.BatchesMade          = 1;
                        currentTotal.ExpectedReworkAmount = GetExpectedReworkAmount(report.Recipe);
                        currentTotal.BatchesWithRework    = 0;
                        currentTotal.RecipeName           = report.Recipe;
                    }

                    AddToReworkTotals(reworkTotals, currentTotal);
                }
            }
            return(reworkTotals);
        }
Пример #2
0
 private void AddToReworkTotals(List <PcsReworkTotals> reworkTotals, PcsReworkTotals currentTotal)
 {
     if (reworkTotals.Exists(x => x.RecipeName == currentTotal.RecipeName))
     {
         PcsReworkTotals temp = reworkTotals.Find(x => x.RecipeName == currentTotal.RecipeName);
         temp.ActualReworkAmount   += currentTotal.ActualReworkAmount;
         temp.BatchesMade          += currentTotal.BatchesMade;
         temp.BatchesWithRework    += currentTotal.BatchesWithRework;
         temp.ExpectedReworkAmount += currentTotal.ExpectedReworkAmount;
     }
     else
     {
         reworkTotals.Add(new PcsReworkTotals
         {
             RecipeName           = currentTotal.RecipeName,
             ActualReworkAmount   = currentTotal.ActualReworkAmount,
             BatchesMade          = currentTotal.BatchesMade,
             BatchesWithRework    = currentTotal.BatchesWithRework,
             ExpectedReworkAmount = currentTotal.ExpectedReworkAmount
         });
     }
 }