Used queries to get data from scrape database instead of FabTime to use a single data source.
This commit is contained in:
@ -1,6 +1,5 @@
|
||||
using ReportingServices.Shared.HelperClasses;
|
||||
using ReportingServices.Shared.Models.ProductionReport;
|
||||
using ReportingServices.Shared.ViewModels.ProductionReport;
|
||||
|
||||
namespace ReportingServices.Shared.ViewModels.ProductionReport
|
||||
{
|
||||
@ -9,8 +8,11 @@ namespace ReportingServices.Shared.ViewModels.ProductionReport
|
||||
public DateTime StartDate { get; set; }
|
||||
public YieldStatistics CurrentWeek { get; set; }
|
||||
public YieldStatistics PreviousWeek { get; set; }
|
||||
public List<ToolEventView> ToolEvents { get; set; }
|
||||
public Dictionary<string, List<EquipmentStateByDay>> ToolAvailibilityByType { get; set; }
|
||||
public Dictionary<string, ToolStateByType> ToolStateByType { get; set; }
|
||||
public List<ToolEvent> CleanEvents { get; set; }
|
||||
public List<ToolEvent> MetrologyEvents { get; set; }
|
||||
public Dictionary<string, List<string>> ToolStatesByOwner { get; set; }
|
||||
public Dictionary<string, List<int>> DualLayerReactors { get; set; }
|
||||
public ManualReportEntries ManualReportEntries { get; set; }
|
||||
@ -26,8 +28,11 @@ namespace ReportingServices.Shared.ViewModels.ProductionReport
|
||||
{
|
||||
ToolAvailibilityByType = new();
|
||||
ToolStateByType = new();
|
||||
CleanEvents = new();
|
||||
MetrologyEvents = new();
|
||||
DualLayerReactors = new();
|
||||
UnloadTempsByDay = new();
|
||||
ToolEvents = new();
|
||||
StartDate = DateTime.Parse(APIHelperFunctions.GetBeginningOfWeekAsAPIString());
|
||||
CurrentWeek = new(StartDate, true);
|
||||
PreviousWeek = new(StartDate.AddDays(-7), false);
|
||||
|
@ -0,0 +1,187 @@
|
||||
using ReportingServices.Shared.Models.ProductionReport;
|
||||
using System.Data;
|
||||
|
||||
namespace ReportingServices.Shared.ViewModels.ProductionReport
|
||||
{
|
||||
public class ToolEventView
|
||||
{
|
||||
public string Reactor { get; set; }
|
||||
public string Type { get; set; }
|
||||
public bool DownMoreThanTwelveHours { get; set; }
|
||||
public string StartDate { get; set; }
|
||||
public string EndDate { get; set; }
|
||||
public bool IsInProduction { get; set; }
|
||||
public List<ReactorEvent> Events { get; set; }
|
||||
public ReactorEvent MostRecentEvent { get; set; }
|
||||
public List<ToolUptimeData> Uptime { get; set; }
|
||||
|
||||
public ToolEventView(List<ReactorEvent> events, string startDate, string endDate, string reactor, string type)
|
||||
{
|
||||
Events = events;
|
||||
StartDate = startDate;
|
||||
EndDate = endDate;
|
||||
Reactor = reactor;
|
||||
Type = type;
|
||||
MostRecentEvent = events[events.Count - 1];
|
||||
IsInProduction = EventIsProduction(MostRecentEvent.REACT_MODE);
|
||||
DownMoreThanTwelveHours = DetermineIfExtendedDowntime();
|
||||
Uptime = DetermineToolUptimeData();
|
||||
}
|
||||
|
||||
private bool DetermineIfExtendedDowntime()
|
||||
{
|
||||
double numberOfHours = 0;
|
||||
|
||||
for (int i = Events.Count - 1; i >= 0; i--)
|
||||
{
|
||||
if (EventIsProduction(Events[i].REACT_MODE))
|
||||
return false;
|
||||
|
||||
if (i == Events.Count - 1)
|
||||
numberOfHours = (DateTime.Now - DateTime.Parse(Events[i].EVENT_DTM)).TotalHours;
|
||||
else
|
||||
numberOfHours += (DateTime.Parse(Events[i + 1].EVENT_DTM) - DateTime.Parse(Events[i].EVENT_DTM)).TotalHours;
|
||||
|
||||
if (numberOfHours > 12)
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public List<ToolUptimeData> DetermineToolUptimeData()
|
||||
{
|
||||
List<ToolUptimeData> data = new();
|
||||
|
||||
bool currentModeIsUp;
|
||||
double uptime = 0;
|
||||
DateTime compareDate = DateTime.Parse(StartDate).Date;
|
||||
DateTime previousTransaction = DateTime.Parse(StartDate).Date;
|
||||
|
||||
currentModeIsUp = EventIsProduction(Events[0].REACT_MODE);
|
||||
|
||||
if (Events.Count == 1)
|
||||
data = LoadUptimeData(currentModeIsUp);
|
||||
|
||||
for (int i = 1; i < Events.Count; i++)
|
||||
{
|
||||
DateTime currentTransaction = DateTime.Parse(Events[i].EVENT_DTM);
|
||||
|
||||
if (currentTransaction.Date == compareDate)
|
||||
{
|
||||
if (currentModeIsUp)
|
||||
uptime += (DateTime.Parse(Events[i].EVENT_DTM) - previousTransaction).TotalMinutes;
|
||||
|
||||
currentModeIsUp = EventIsProduction(Events[i].REACT_MODE);
|
||||
previousTransaction = DateTime.Parse(Events[i].EVENT_DTM);
|
||||
}
|
||||
|
||||
if ((currentTransaction.Date - compareDate).TotalHours == 24)
|
||||
{
|
||||
if (currentModeIsUp)
|
||||
uptime += (currentTransaction.Date - previousTransaction).TotalMinutes;
|
||||
|
||||
data.Add(new ToolUptimeData
|
||||
{
|
||||
Date = compareDate.ToString(),
|
||||
UptimePercentage = uptime / 1440
|
||||
});
|
||||
|
||||
if (currentModeIsUp)
|
||||
uptime = (currentTransaction - currentTransaction.Date).TotalMinutes;
|
||||
else
|
||||
uptime = 0;
|
||||
|
||||
compareDate = compareDate.AddDays(1);
|
||||
currentModeIsUp = EventIsProduction(Events[i].REACT_MODE);
|
||||
previousTransaction = DateTime.Parse(Events[i].EVENT_DTM);
|
||||
}
|
||||
|
||||
if ((currentTransaction.Date - compareDate).TotalHours > 24)
|
||||
{
|
||||
while (currentTransaction.Date != compareDate)
|
||||
{
|
||||
if (currentModeIsUp)
|
||||
uptime += (compareDate.AddDays(1) - previousTransaction).TotalMinutes;
|
||||
|
||||
data.Add(new ToolUptimeData
|
||||
{
|
||||
Date = compareDate.ToString(),
|
||||
UptimePercentage = uptime / 1440
|
||||
});
|
||||
|
||||
uptime = 0;
|
||||
|
||||
compareDate = compareDate.AddDays(1);
|
||||
previousTransaction = compareDate;
|
||||
}
|
||||
}
|
||||
|
||||
if (i == Events.Count - 1)
|
||||
{
|
||||
if ((DateTime.Parse(EndDate).Date != compareDate))
|
||||
{
|
||||
while (DateTime.Parse(EndDate).Date != compareDate)
|
||||
{
|
||||
if (currentModeIsUp)
|
||||
uptime += (compareDate.AddDays(1) - previousTransaction).TotalMinutes;
|
||||
|
||||
data.Add(new ToolUptimeData
|
||||
{
|
||||
Date = compareDate.ToString(),
|
||||
UptimePercentage = uptime / 1440
|
||||
});
|
||||
|
||||
uptime = 0;
|
||||
|
||||
compareDate = compareDate.AddDays(1);
|
||||
previousTransaction = compareDate;
|
||||
}
|
||||
}
|
||||
|
||||
if (currentModeIsUp)
|
||||
uptime += (DateTime.Parse(EndDate) - previousTransaction).TotalMinutes;
|
||||
|
||||
data.Add(new ToolUptimeData
|
||||
{
|
||||
Date = DateTime.Now.Date.ToString(),
|
||||
UptimePercentage = uptime / (DateTime.Parse(EndDate) - DateTime.Parse(EndDate).Date).TotalMinutes
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
private List<ToolUptimeData> LoadUptimeData(bool currentModeIsUp)
|
||||
{
|
||||
List<ToolUptimeData> data = new();
|
||||
|
||||
double days = (DateTime.Parse(EndDate) - DateTime.Parse(StartDate)).TotalDays;
|
||||
|
||||
for (int i = 0; i < days; i++)
|
||||
{
|
||||
data.Add(new ToolUptimeData
|
||||
{
|
||||
Date = DateTime.Parse(StartDate).Date.AddDays(i).ToString(),
|
||||
UptimePercentage = currentModeIsUp ? 1 : 0
|
||||
});
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
private bool EventIsProduction(string evnt)
|
||||
{
|
||||
if (evnt.ToUpper() == "UP")
|
||||
return true;
|
||||
|
||||
if (evnt.ToUpper() == "UP_WITH_INCREASED_SAMPLING")
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user