diff --git a/ReportingServices.Shared/ViewModels/ProductionReport/YieldStatistics.cs b/ReportingServices.Shared/ViewModels/ProductionReport/YieldStatistics.cs index a554c52..e491be3 100644 --- a/ReportingServices.Shared/ViewModels/ProductionReport/YieldStatistics.cs +++ b/ReportingServices.Shared/ViewModels/ProductionReport/YieldStatistics.cs @@ -21,7 +21,7 @@ public class YieldStatistics public void SetYieldInformation(YieldInformation yieldInformation, QuarterlyTargets targets, DateTime qtrStartDate, int yieldedOuts) { OutsByDay = GetReactorOutsByDay(yieldInformation.Outs); - ScrapByDay = yieldInformation.Scrap; + ScrapByDay = GetReactorScrapByDay(yieldInformation.Scrap); DailyPlanWafers = targets.Yield_Outs / targets.PlanWorkingDays; int daysRemainingInQtr = (int)(qtrStartDate.AddDays(targets.PlanWorkingDays) - StartDate).TotalDays; @@ -42,6 +42,28 @@ public class YieldStatistics dates.Add(DateTime.Parse(rout.EndProcessTime).Date.ToString()); } + List dateTimes = new List(); + foreach (string date in dates) + { + dateTimes.Add(DateTime.Parse(date)); + } + + dateTimes.Sort(); + dates.Sort(); + + DateTime currentDateTime = dateTimes.ElementAt(0); + for (int i = 1; i < dateTimes.Count; i++) + { + DateTime nextDateTime = dateTimes[i]; + int dayDiff = (nextDateTime - currentDateTime).Days; + if (dayDiff > 1) + { + dateTimes.Insert(i, currentDateTime.AddDays(1)); + dates.Insert(i, dateTimes.ElementAt(i).ToString("MM/dd/yyyy hh:mm:ss tt")); + } + currentDateTime = dateTimes[i]; + } + return dates; } @@ -66,4 +88,66 @@ public class YieldStatistics return outsByDay; } + + public static List GetDistinctDatesFromReactorScrap(List scraps) + { + List dates = new(); + + foreach (ScrapByDay scrap in scraps) + { + if (!dates.Contains(DateTime.Parse(scrap.StartDate).Date.ToString())) + dates.Add(DateTime.Parse(scrap.StartDate).Date.ToString()); + } + + List dateTimes = new List(); + foreach (string date in dates) + { + dateTimes.Add(DateTime.Parse(date)); + } + + dateTimes.Sort(); + dates.Sort(); + + DateTime currentDateTime = dateTimes.ElementAt(0); + for (int i = 1; i < dateTimes.Count; i++) + { + DateTime nextDateTime = dateTimes[i]; + int dayDiff = (nextDateTime - currentDateTime).Days; + if (dayDiff > 1) + { + dateTimes.Insert(i, currentDateTime.AddDays(1)); + dates.Insert(i, dateTimes.ElementAt(i).ToString("MM/dd/yyyy hh:mm:ss tt")); + } + currentDateTime = dateTimes[i]; + } + + return dates; + } + + public static List GetReactorScrapByDay(List scrap) + { + List sortedScrap = scrap.OrderBy(s => s.StartDate).ToList(); + + List scrapByDay = new(); + + List dates = GetDistinctDatesFromReactorScrap(scrap); + + int scrapIdx = 0; + for (int i = 0; i < dates.Count; i++) + { + ScrapByDay currentScrap = sortedScrap.ElementAtOrDefault(scrapIdx); + string currentDate = dates[i]; + if (currentScrap != null && currentScrap.StartDate == currentDate) + { + scrapByDay.Add(currentScrap); + scrapIdx++; + } + else + { + scrapByDay.Add(new ScrapByDay() { StartDate = dates[i] }); + } + } + + return scrapByDay; + } } \ No newline at end of file diff --git a/ReportingServices.UI/Views/Shared/_DailyReportPartial.cshtml b/ReportingServices.UI/Views/Shared/_DailyReportPartial.cshtml index 124692b..58dc75d 100644 --- a/ReportingServices.UI/Views/Shared/_DailyReportPartial.cshtml +++ b/ReportingServices.UI/Views/Shared/_DailyReportPartial.cshtml @@ -183,7 +183,12 @@ { if (i < numberOfDaysInWeek) { - float yield = ((float)Model.OutsByDay[i].TotalWafers - (float)Model.ScrapByDay[i].TOT_REJ_MANU) / (float)Model.OutsByDay[i].TotalWafers; + int yieldLessScrap = Model.OutsByDay[i].TotalWafers - Model.ScrapByDay[i].TOT_REJ_MANU; + float yield = 0; + if (yieldLessScrap != 0) + { + yield = ((float)Model.OutsByDay[i].TotalWafers - (float)Model.ScrapByDay[i].TOT_REJ_MANU) / (float)Model.OutsByDay[i].TotalWafers; + } @(string.Format("{0:P2}", yield)) diff --git a/ReportingServices.UI/wwwroot/Assets/SLLTools.json b/ReportingServices.UI/wwwroot/Assets/SLLTools.json index 7874230..b051be7 100644 --- a/ReportingServices.UI/wwwroot/Assets/SLLTools.json +++ b/ReportingServices.UI/wwwroot/Assets/SLLTools.json @@ -1 +1 @@ -[{"Date":"2023-01-23T00:00:00-07:00","ASM":7,"HTR":16},{"Date":"2023-01-24T00:00:00-07:00","ASM":7,"HTR":15},{"Date":"2023-01-26T00:00:00-07:00","ASM":7,"HTR":14},{"Date":"2023-02-20T00:00:00-07:00","ASM":3,"HTR":8},{"Date":"2023-03-01T00:00:00-07:00","ASM":3,"HTR":8},{"Date":"2023-03-03T00:00:00-07:00","ASM":3,"HTR":8},{"Date":"2023-04-03T00:00:00-07:00","ASM":2,"HTR":6},{"Date":"2023-05-25T00:00:00-07:00","ASM":2,"HTR":8},{"Date":"2023-06-12T00:00:00-07:00","ASM":2,"HTR":7},{"Date":"2023-07-05T00:00:00-07:00","ASM":0,"HTR":8},{"Date":"2023-10-12T00:00:00-07:00","ASM":2,"HTR":7},{"Date":"2023-10-13T00:00:00-07:00","ASM":4,"HTR":8}] \ No newline at end of file +[{"Date":"2023-01-22T23:00:00-08:00","ASM":7,"HTR":16},{"Date":"2023-01-23T23:00:00-08:00","ASM":7,"HTR":15},{"Date":"2023-01-25T23:00:00-08:00","ASM":7,"HTR":14},{"Date":"2023-02-19T23:00:00-08:00","ASM":3,"HTR":8},{"Date":"2023-02-28T23:00:00-08:00","ASM":3,"HTR":8},{"Date":"2023-03-02T23:00:00-08:00","ASM":3,"HTR":8},{"Date":"2023-04-03T00:00:00-07:00","ASM":2,"HTR":6},{"Date":"2023-05-25T00:00:00-07:00","ASM":2,"HTR":8},{"Date":"2023-06-12T00:00:00-07:00","ASM":2,"HTR":7},{"Date":"2023-07-05T00:00:00-07:00","ASM":0,"HTR":8},{"Date":"2023-10-12T00:00:00-07:00","ASM":2,"HTR":7},{"Date":"2023-10-13T00:00:00-07:00","ASM":4,"HTR":8},{"Date":"2023-10-27T00:00:00-07:00","ASM":3,"HTR":7}] \ No newline at end of file