Updated daily report to show correct information when two work weeks split quarters.

Also current changes to project with Blazor implementation is implemented here as well.
This commit is contained in:
Daniel Wathen
2023-04-03 09:58:28 -07:00
parent f77d723576
commit 72e7a55ab4
305 changed files with 148901 additions and 4 deletions

View File

@ -0,0 +1,157 @@
using Microsoft.AspNetCore.Components;
using ReportingServices.Blazor.Services;
using ReportingServices.Shared.Blazor.Models.ProductionReport;
namespace ReportingServices.Blazor.Components.DailyReport;
public partial class TargetsSummary
{
[Inject]
public AppData AppData { get; set; }
[Inject]
public ScrapeDBService Db { get; set; }
[Parameter]
public DateTime StartDate { get; set; }
[Parameter]
public DateTime EndDate { get; set; }
[Parameter]
public DateTime QuarterStartDate { get; set; }
[Parameter]
public QuarterlyTargets Targets { get; set; }
[Parameter]
public OutsAndScrapTotal QTDOutsAndScrap { get; set; }
private List<ReactorOutsByDay> OutsByDay { get; set; }
private List<ScrapByDay> ScrapByDay { get; set; }
private int DailyPlanWafers { get; set; }
private int DailyWafersForQTR { get; set; }
private YieldInformation YieldInformation { get; set; }
private OutsAndScrapTotal OutsAndScrap { get; set; }
private bool IsCurrentWeek { get; set; }
private DateTime[] Dates { get; set; }
private int AddExtraDay { get; set; }
private Dictionary<DateTime, int> WeeklyOuts { get; set; }
private Dictionary<DateTime, YieldStatistics> WeeklyYieldStatistics { get; set; }
private int NumberCompletedDaysInWeek { get; set; }
private int TotalWafersForPartialDay { get; set; }
private int YieldedWafersPerDay { get; set; }
private int TotalWafersOut { get; set; }
private int TotalCustomerScrap { get; set; }
private int TotalManufacturingScrap { get; set; }
private int TotalProdScrap { get; set; }
private int TotalYieldedWafersOut { get; set; }
private int DeltaToCommit { get; set; }
private int DeltaToPlan { get; set; }
private int TotalYield { get; set; }
protected async override Task OnInitializedAsync()
{
await base.OnInitializedAsync();
WeeklyYieldStatistics = new();
DailyPlanWafers = (int)Math.Floor((double)(Targets.Yield_Outs / Targets.PlanWorkingDays));
IsCurrentWeek = (EndDate - StartDate).Days != 7;
AddExtraDay = IsCurrentWeek ? 1 : 0;
YieldInformation = await Db.GetReactorAndScrapOutsAsync(StartDate, EndDate);
OutsAndScrap = await Db.GetOutsAndScrapAsync(QuarterStartDate, StartDate);
Dates = new DateTime[] { StartDate, StartDate.AddDays(1), StartDate.AddDays(2),
StartDate.AddDays(3), StartDate.AddDays(4), StartDate.AddDays(5), StartDate.AddDays(6) };
}
protected override bool ShouldRender()
{
if (YieldInformation != null && OutsAndScrap != null)
{
GetReactorOutsByDay(YieldInformation.Outs);
GetWeeklyTotals();
GetYieldStatistics();
NumberCompletedDaysInWeek = IsCurrentWeek ? YieldInformation.Scrap.Count - 1 : 7;
TotalWafersForPartialDay = NumberCompletedDaysInWeek == 7 ? 0 : WeeklyYieldStatistics[DateTime.Now.Date].YieldedOuts;
int daysRemainingInQtr = (int)(QuarterStartDate.AddDays(Targets.PlanWorkingDays) - StartDate).TotalDays;
int yieldedOuts = OutsAndScrap.Outs - OutsAndScrap.CustomerScrap - OutsAndScrap.ManufacturingScrap - OutsAndScrap.ProductionScrap;
if (daysRemainingInQtr == Targets.PlanWorkingDays)
DailyWafersForQTR = DailyPlanWafers;
else
DailyWafersForQTR = (int)Math.Round((double)((Targets.Yield_Outs - yieldedOuts) / daysRemainingInQtr));
YieldedWafersPerDay = (int)((double)(TotalYieldedWafersOut - TotalWafersForPartialDay) / NumberCompletedDaysInWeek);
return true;
}
return false;
}
public void GetReactorOutsByDay(List<ReactorOutsByRDS> outs)
{
WeeklyOuts = outs.GroupBy(x => x.EndProcessTime, (key, values) =>
new { Date = key, Outs = values.Sum(x => int.Parse(x.Units))}).ToDictionary(x => DateTime.Parse(x.Date), x => x.Outs);
}
private void GetYieldStatistics()
{
Dictionary<DateTime, ScrapByDay> scrapInfo = new();
foreach (ScrapByDay scrap in YieldInformation.Scrap)
scrapInfo.Add(DateTime.Parse(scrap.StartDate), scrap);
foreach (DateTime date in Dates)
{
int outs = 0, yieldedOuts = 0, customerScrap = 0, manufacturingScrap = 0, productionScrap = 0;
double yieldPercentage = 0;
if (scrapInfo.ContainsKey(date))
{
outs = WeeklyOuts[date];
customerScrap = scrapInfo[date].TOT_REJ_CUST;
manufacturingScrap = scrapInfo[date].TOT_REJ_MANU;
productionScrap = scrapInfo[date].TW_PROD;
yieldedOuts = outs - customerScrap - manufacturingScrap - productionScrap;
yieldPercentage = (double)(outs - manufacturingScrap) / outs;
}
YieldStatistics yieldStatistics = new()
{
Outs = outs,
CustomerScrap = customerScrap,
ManufacturingScrap = manufacturingScrap,
ProductionScrap = productionScrap,
YieldedOuts = yieldedOuts,
YieldPercent = yieldPercentage
};
WeeklyYieldStatistics.Add(date, yieldStatistics);
}
}
private void GetWeeklyTotals()
{
TotalWafersOut = GetTotalOuts();
TotalCustomerScrap = YieldInformation.Scrap.Sum(x => x.TOT_REJ_CUST);
TotalManufacturingScrap = YieldInformation.Scrap.Sum(x => x.TOT_REJ_MANU);
TotalProdScrap = YieldInformation.Scrap.Sum(x => x.TW_PROD);
TotalYieldedWafersOut = TotalWafersOut - TotalManufacturingScrap - TotalProdScrap - TotalCustomerScrap;
}
private int GetTotalOuts()
{
int result = 0;
foreach (KeyValuePair<DateTime, int> pair in WeeklyOuts)
result += pair.Value;
return result;
}
}