Daily Report adds zeros for down days
This commit is contained in:
@ -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<DateTime> dateTimes = new List<DateTime>();
|
||||
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<string> GetDistinctDatesFromReactorScrap(List<ScrapByDay> scraps)
|
||||
{
|
||||
List<string> 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<DateTime> dateTimes = new List<DateTime>();
|
||||
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<ScrapByDay> GetReactorScrapByDay(List<ScrapByDay> scrap)
|
||||
{
|
||||
List<ScrapByDay> sortedScrap = scrap.OrderBy(s => s.StartDate).ToList();
|
||||
|
||||
List<ScrapByDay> scrapByDay = new();
|
||||
|
||||
List<string> 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;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user