Ran formatting through code
This commit is contained in:
@ -1,56 +1,53 @@
|
||||
using System.Web;
|
||||
namespace ReportingServices.Shared.HelperClasses;
|
||||
|
||||
namespace ReportingServices.Shared.HelperClasses
|
||||
public static class APIHelperFunctions
|
||||
{
|
||||
public static class APIHelperFunctions
|
||||
public static string GetBeginningOfWeekAsAPIString()
|
||||
{
|
||||
public static string GetBeginningOfWeekAsAPIString()
|
||||
DateTime date = DateTime.Now;
|
||||
|
||||
int dayOfWeek = (int)date.DayOfWeek;
|
||||
|
||||
date = dayOfWeek switch
|
||||
{
|
||||
DateTime date = DateTime.Now;
|
||||
0 => date.AddDays(-6),
|
||||
1 => date,
|
||||
_ => date.AddDays(1 - dayOfWeek)
|
||||
};
|
||||
|
||||
int dayOfWeek = (int)date.DayOfWeek;
|
||||
|
||||
date = dayOfWeek switch
|
||||
{
|
||||
0 => date.AddDays(-6),
|
||||
1 => date,
|
||||
_ => date.AddDays(1 - dayOfWeek)
|
||||
};
|
||||
|
||||
return GetDateTimeAsAPIString(date.ToString(), false);
|
||||
}
|
||||
|
||||
public static string GetDateWithOffsetAsAPIString(string dateString, float offset)
|
||||
{
|
||||
DateTime date = DateTime.Parse(dateString);
|
||||
|
||||
date = date.AddHours(offset);
|
||||
|
||||
return GetDateTimeAsAPIString(date.ToString(), true);
|
||||
}
|
||||
|
||||
public static string GetDateTimeAsAPIString(string dateString, bool fullDateTime)
|
||||
{
|
||||
DateTime date = DateTime.Parse(dateString);
|
||||
|
||||
if (fullDateTime)
|
||||
dateString = date.ToString("yyyy-M-d HH:mm:ss");
|
||||
else
|
||||
dateString = date.Year + "-" + date.Month + "-" + date.Day + " 0:0:0";
|
||||
|
||||
return dateString;
|
||||
}
|
||||
|
||||
public static List<T> ReverseList<T>(List<T> inputList)
|
||||
{
|
||||
List<T> temp = new();
|
||||
|
||||
for (int i = inputList.Count - 1; i >= 0; i--)
|
||||
{
|
||||
temp.Add(inputList[i]);
|
||||
}
|
||||
|
||||
return temp;
|
||||
}
|
||||
return GetDateTimeAsAPIString(date.ToString(), false);
|
||||
}
|
||||
}
|
||||
|
||||
public static string GetDateWithOffsetAsAPIString(string dateString, float offset)
|
||||
{
|
||||
DateTime date = DateTime.Parse(dateString);
|
||||
|
||||
date = date.AddHours(offset);
|
||||
|
||||
return GetDateTimeAsAPIString(date.ToString(), true);
|
||||
}
|
||||
|
||||
public static string GetDateTimeAsAPIString(string dateString, bool fullDateTime)
|
||||
{
|
||||
DateTime date = DateTime.Parse(dateString);
|
||||
|
||||
if (fullDateTime)
|
||||
dateString = date.ToString("yyyy-M-d HH:mm:ss");
|
||||
else
|
||||
dateString = date.Year + "-" + date.Month + "-" + date.Day + " 0:0:0";
|
||||
|
||||
return dateString;
|
||||
}
|
||||
|
||||
public static List<T> ReverseList<T>(List<T> inputList)
|
||||
{
|
||||
List<T> temp = new();
|
||||
|
||||
for (int i = inputList.Count - 1; i >= 0; i--)
|
||||
{
|
||||
temp.Add(inputList[i]);
|
||||
}
|
||||
|
||||
return temp;
|
||||
}
|
||||
}
|
@ -1,22 +1,19 @@
|
||||
using ReportingServices.Shared.Models.ProductionReport;
|
||||
using System.Net.Http.Json;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json;
|
||||
|
||||
namespace ReportingServices.Shared.HelperClasses
|
||||
namespace ReportingServices.Shared.HelperClasses;
|
||||
|
||||
public static class ApiCaller
|
||||
{
|
||||
public static class ApiCaller
|
||||
public static async Task<T> GetApi<T>(string url)
|
||||
{
|
||||
public static async Task<T> GetApi<T>(string url)
|
||||
T deserializedJson = default;
|
||||
|
||||
using (HttpClient client = new())
|
||||
{
|
||||
T deserializedJson = default(T);
|
||||
|
||||
using (HttpClient client = new())
|
||||
{
|
||||
string apiResponse = await client.GetStringAsync(url);
|
||||
deserializedJson = JsonSerializer.Deserialize<T>(apiResponse);
|
||||
}
|
||||
|
||||
return deserializedJson;
|
||||
string apiResponse = await client.GetStringAsync(url);
|
||||
deserializedJson = JsonSerializer.Deserialize<T>(apiResponse);
|
||||
}
|
||||
|
||||
return deserializedJson;
|
||||
}
|
||||
}
|
||||
}
|
@ -2,181 +2,180 @@
|
||||
using ReportingServices.Shared.Models.ProductionReport;
|
||||
using ReportingServices.Shared.ViewModels.ProductionReport;
|
||||
|
||||
namespace ReportingServices.Shared.HelperClasses
|
||||
namespace ReportingServices.Shared.HelperClasses;
|
||||
|
||||
public static class DailyReportHelper
|
||||
{
|
||||
public static class DailyReportHelper
|
||||
private static readonly string _dailyRptFilePath = "wwwroot/Assets/DailyReportInfo.json";
|
||||
private static readonly string _SLLFilePath = "wwwroot/Assets/SLLTools.json";
|
||||
|
||||
public static DailyReport SetUpDailyReport(ILogger logger, string baseUrlScrapeDb)
|
||||
{
|
||||
private static readonly string _dailyRptFilePath = "wwwroot/Assets/DailyReportInfo.json";
|
||||
private static readonly string _SLLFilePath = "wwwroot/Assets/SLLTools.json";
|
||||
DailyReport report = new();
|
||||
|
||||
public static DailyReport SetUpDailyReport(ILogger logger, string baseUrlScrapeDb)
|
||||
try
|
||||
{
|
||||
DailyReport report = new();
|
||||
report.SLLTools = JsonFileHandler.LoadJSONFile<List<SLLTool>>(_SLLFilePath);
|
||||
report.ManualReportEntries = JsonFileHandler.LoadJSONFile<ManualReportEntries>(_dailyRptFilePath);
|
||||
|
||||
try
|
||||
{
|
||||
report.SLLTools = JsonFileHandler.LoadJSONFile<List<SLLTool>>(_SLLFilePath);
|
||||
report.ManualReportEntries = JsonFileHandler.LoadJSONFile<ManualReportEntries>(_dailyRptFilePath);
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.LogError(ex, "Failed to load JsonFiles.");
|
||||
logger.LogInformation("SLL File Path: {path}", _SLLFilePath);
|
||||
logger.LogInformation("Manual Report Entries File Path: {path}", _dailyRptFilePath);
|
||||
}
|
||||
|
||||
List<string> cleanTools = new()
|
||||
{
|
||||
"AHPS",
|
||||
"AKRION1",
|
||||
"CB3",
|
||||
"MES",
|
||||
"SRD 1",
|
||||
"SRD 2"
|
||||
};
|
||||
|
||||
List<string> metrologyTools = new()
|
||||
{
|
||||
"ASET",
|
||||
"BIORAD2",
|
||||
"BIORAD3",
|
||||
"BIORAD4",
|
||||
"BIORAD5",
|
||||
"CDE2",
|
||||
"CDE3",
|
||||
"CDE5",
|
||||
"FLEXUS",
|
||||
"HGCV1",
|
||||
"HGCV2",
|
||||
"HGCV3",
|
||||
"SRP"
|
||||
};
|
||||
|
||||
List<Reactor> reactors = new();
|
||||
Dictionary<string, Task<int>> lastUpTransactions = new();
|
||||
List<Task<List<ReactorEvent>>> toolEvents = new();
|
||||
List<Task<ToolEvent>> cleanEvents = new();
|
||||
List<Task<ToolEvent>> metrologyEvents = new();
|
||||
|
||||
Task<YieldInformation> task1 = null;
|
||||
Task<YieldInformation> task2 = null;
|
||||
Task<QuarterlyTargets> targets = null;
|
||||
Task<List<RDS>> rds = null;
|
||||
Task<DateTime> task3 = null;
|
||||
Task<OutsAndScrapTotal> task4 = null;
|
||||
|
||||
try
|
||||
{
|
||||
reactors = ApiCaller.GetApi<List<Reactor>>(baseUrlScrapeDb + "Reactors").Result;
|
||||
|
||||
foreach (Reactor reactor in reactors)
|
||||
{
|
||||
toolEvents.Add(ApiCaller.GetApi<List<ReactorEvent>>(baseUrlScrapeDb + "ReactorEvents?startDate=" + report.StartDate.ToString() +
|
||||
"&endDate=" + DateTime.Now.ToString() + "&reactorNumber=" + reactor.ReactorNumber + "&reactorType=" + reactor.Type));
|
||||
|
||||
lastUpTransactions.Add(reactor.ReactorNumber.ToString(),
|
||||
ApiCaller.GetApi<int>(baseUrlScrapeDb + "GetLastUpTransaction?reactorNumber=" + reactor.ReactorNumber));
|
||||
}
|
||||
|
||||
foreach (string tool in cleanTools)
|
||||
{
|
||||
cleanEvents.Add(ApiCaller.GetApi<ToolEvent>(baseUrlScrapeDb + "ToolEvents?toolID=" + tool));
|
||||
}
|
||||
|
||||
foreach (string tool in metrologyTools)
|
||||
{
|
||||
metrologyEvents.Add(ApiCaller.GetApi<ToolEvent>(baseUrlScrapeDb + "ToolEvents?toolID=" + tool));
|
||||
}
|
||||
|
||||
task1 = ApiCaller.GetApi<YieldInformation>(baseUrlScrapeDb + "ReactorOuts?startDate=" + report.StartDate.ToString() + "&endDate=" + DateTime.Now.ToString());
|
||||
task2 = ApiCaller.GetApi<YieldInformation>(baseUrlScrapeDb + "ReactorOuts?startDate=" + report.StartDate.AddDays(-7).ToString() + "&endDate=" + report.StartDate.ToString());
|
||||
task3 = ApiCaller.GetApi<DateTime>(baseUrlScrapeDb + "GetQuarterStartDate");
|
||||
targets = ApiCaller.GetApi<QuarterlyTargets>(baseUrlScrapeDb + "Targets");
|
||||
|
||||
rds = ApiCaller.GetApi<List<RDS>>(baseUrlScrapeDb + "RDS?date=" + report.StartDate.ToString());
|
||||
task4 = ApiCaller.GetApi<OutsAndScrapTotal>(baseUrlScrapeDb + "GetOutsAndScrapTotals?startDate=" + task3.Result + "&endDate=" + DateTime.Now.ToString());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.LogCritical(ex, "Failed to send get requests to scrapedb endpoints.");
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
report.QuarterlyTargets = targets.Result;
|
||||
report.SetRDSInfo(rds.Result);
|
||||
report.SetReactorInfo(reactors, GetUnscheduledReactors(report));
|
||||
|
||||
foreach (var task in toolEvents)
|
||||
{
|
||||
ToolEventView toolEvent = new(task.Result,
|
||||
report.StartDate.ToString(), DateTime.Now.ToString(), task.Result[0].REACT_NO,
|
||||
reactors.FirstOrDefault(x => x.ReactorNumber == int.Parse(task.Result[0].REACT_NO)).Type);
|
||||
|
||||
toolEvent.SetDowntime(lastUpTransactions[toolEvent.Reactor].Result);
|
||||
|
||||
report.ToolEvents.Add(toolEvent);
|
||||
}
|
||||
|
||||
report.ToolEvents = report.ToolEvents
|
||||
.Where(x => x.Reactor != "100" && x.Reactor != "101" && x.Reactor != "47")
|
||||
.OrderBy(x => x.Reactor)
|
||||
.ToList();
|
||||
|
||||
foreach (Task<ToolEvent> task in cleanEvents)
|
||||
report.CleanEvents.Add(task.Result);
|
||||
|
||||
foreach (Task<ToolEvent> task in metrologyEvents)
|
||||
report.MetrologyEvents.Add(task.Result);
|
||||
|
||||
report.CleanEvents = report.CleanEvents.Where(x => (x.TOOL_MODE != "PROD" || x.TOOL_MODE_DESC != "Production") && x.TOOL_MODE != "OUT").ToList();
|
||||
report.MetrologyEvents = report.MetrologyEvents.Where(x => (x.TOOL_MODE != "PROD" || x.TOOL_MODE_DESC != "Production") && x.TOOL_MODE != "OUT").ToList();
|
||||
|
||||
report.CurrentWeek.SetYieldInformation(task1.Result, report.QuarterlyTargets);
|
||||
report.PreviousWeek.SetYieldInformation(task2.Result, report.QuarterlyTargets);
|
||||
|
||||
report.QuarterStartDate = task3.Result;
|
||||
|
||||
report.CurrentWeek.QTDOutsAndScrap = task4.Result;
|
||||
report.PreviousWeek.QTDOutsAndScrap = task4.Result;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.LogCritical(ex, "Failed to retrieve data back from Scrape DB endpoints.");
|
||||
}
|
||||
|
||||
report.ReverseLists();
|
||||
|
||||
ManualReportEntries entries = report.ManualReportEntries;
|
||||
List<SLLTool> sll = report.SLLTools;
|
||||
|
||||
try
|
||||
{
|
||||
JsonFileHandler.SaveJSONFile(entries, _dailyRptFilePath);
|
||||
JsonFileHandler.SaveJSONFile(sll, _SLLFilePath);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.LogCritical(ex, "Failed to save data back to JSON files.");
|
||||
}
|
||||
|
||||
return report;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.LogError(ex, "Failed to load JsonFiles.");
|
||||
logger.LogInformation("SLL File Path: {path}", _SLLFilePath);
|
||||
logger.LogInformation("Manual Report Entries File Path: {path}", _dailyRptFilePath);
|
||||
}
|
||||
|
||||
public static List<int> GetUnscheduledReactors(DailyReport report)
|
||||
List<string> cleanTools = new()
|
||||
{
|
||||
List<int> reactors = new();
|
||||
"AHPS",
|
||||
"AKRION1",
|
||||
"CB3",
|
||||
"MES",
|
||||
"SRD 1",
|
||||
"SRD 2"
|
||||
};
|
||||
|
||||
foreach (ToolEventView tool in report.ToolEvents)
|
||||
List<string> metrologyTools = new()
|
||||
{
|
||||
"ASET",
|
||||
"BIORAD2",
|
||||
"BIORAD3",
|
||||
"BIORAD4",
|
||||
"BIORAD5",
|
||||
"CDE2",
|
||||
"CDE3",
|
||||
"CDE5",
|
||||
"FLEXUS",
|
||||
"HGCV1",
|
||||
"HGCV2",
|
||||
"HGCV3",
|
||||
"SRP"
|
||||
};
|
||||
|
||||
List<Reactor> reactors = new();
|
||||
Dictionary<string, Task<int>> lastUpTransactions = new();
|
||||
List<Task<List<ReactorEvent>>> toolEvents = new();
|
||||
List<Task<ToolEvent>> cleanEvents = new();
|
||||
List<Task<ToolEvent>> metrologyEvents = new();
|
||||
|
||||
Task<YieldInformation> task1 = null;
|
||||
Task<YieldInformation> task2 = null;
|
||||
Task<QuarterlyTargets> targets = null;
|
||||
Task<List<RDS>> rds = null;
|
||||
Task<DateTime> task3 = null;
|
||||
Task<OutsAndScrapTotal> task4 = null;
|
||||
|
||||
try
|
||||
{
|
||||
reactors = ApiCaller.GetApi<List<Reactor>>(baseUrlScrapeDb + "Reactors").Result;
|
||||
|
||||
foreach (Reactor reactor in reactors)
|
||||
{
|
||||
if (!tool.IsInProduction)
|
||||
{
|
||||
reactors.Add(int.Parse(tool.Reactor));
|
||||
}
|
||||
toolEvents.Add(ApiCaller.GetApi<List<ReactorEvent>>(baseUrlScrapeDb + "ReactorEvents?startDate=" + report.StartDate.ToString() +
|
||||
"&endDate=" + DateTime.Now.ToString() + "&reactorNumber=" + reactor.ReactorNumber + "&reactorType=" + reactor.Type));
|
||||
|
||||
lastUpTransactions.Add(reactor.ReactorNumber.ToString(),
|
||||
ApiCaller.GetApi<int>(baseUrlScrapeDb + "GetLastUpTransaction?reactorNumber=" + reactor.ReactorNumber));
|
||||
}
|
||||
|
||||
return reactors;
|
||||
foreach (string tool in cleanTools)
|
||||
{
|
||||
cleanEvents.Add(ApiCaller.GetApi<ToolEvent>(baseUrlScrapeDb + "ToolEvents?toolID=" + tool));
|
||||
}
|
||||
|
||||
foreach (string tool in metrologyTools)
|
||||
{
|
||||
metrologyEvents.Add(ApiCaller.GetApi<ToolEvent>(baseUrlScrapeDb + "ToolEvents?toolID=" + tool));
|
||||
}
|
||||
|
||||
task1 = ApiCaller.GetApi<YieldInformation>(baseUrlScrapeDb + "ReactorOuts?startDate=" + report.StartDate.ToString() + "&endDate=" + DateTime.Now.ToString());
|
||||
task2 = ApiCaller.GetApi<YieldInformation>(baseUrlScrapeDb + "ReactorOuts?startDate=" + report.StartDate.AddDays(-7).ToString() + "&endDate=" + report.StartDate.ToString());
|
||||
task3 = ApiCaller.GetApi<DateTime>(baseUrlScrapeDb + "GetQuarterStartDate");
|
||||
targets = ApiCaller.GetApi<QuarterlyTargets>(baseUrlScrapeDb + "Targets");
|
||||
|
||||
rds = ApiCaller.GetApi<List<RDS>>(baseUrlScrapeDb + "RDS?date=" + report.StartDate.ToString());
|
||||
task4 = ApiCaller.GetApi<OutsAndScrapTotal>(baseUrlScrapeDb + "GetOutsAndScrapTotals?startDate=" + task3.Result + "&endDate=" + DateTime.Now.ToString());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.LogCritical(ex, "Failed to send get requests to scrapedb endpoints.");
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
report.QuarterlyTargets = targets.Result;
|
||||
report.SetRDSInfo(rds.Result);
|
||||
report.SetReactorInfo(reactors, GetUnscheduledReactors(report));
|
||||
|
||||
foreach (Task<List<ReactorEvent>> task in toolEvents)
|
||||
{
|
||||
ToolEventView toolEvent = new(task.Result,
|
||||
report.StartDate.ToString(), DateTime.Now.ToString(), task.Result[0].REACT_NO,
|
||||
reactors.FirstOrDefault(x => x.ReactorNumber == int.Parse(task.Result[0].REACT_NO)).Type);
|
||||
|
||||
toolEvent.SetDowntime(lastUpTransactions[toolEvent.Reactor].Result);
|
||||
|
||||
report.ToolEvents.Add(toolEvent);
|
||||
}
|
||||
|
||||
report.ToolEvents = report.ToolEvents
|
||||
.Where(x => x.Reactor is not "100" and not "101" and not "47")
|
||||
.OrderBy(x => x.Reactor)
|
||||
.ToList();
|
||||
|
||||
foreach (Task<ToolEvent> task in cleanEvents)
|
||||
report.CleanEvents.Add(task.Result);
|
||||
|
||||
foreach (Task<ToolEvent> task in metrologyEvents)
|
||||
report.MetrologyEvents.Add(task.Result);
|
||||
|
||||
report.CleanEvents = report.CleanEvents.Where(x => (x.TOOL_MODE != "PROD" || x.TOOL_MODE_DESC != "Production") && x.TOOL_MODE != "OUT").ToList();
|
||||
report.MetrologyEvents = report.MetrologyEvents.Where(x => (x.TOOL_MODE != "PROD" || x.TOOL_MODE_DESC != "Production") && x.TOOL_MODE != "OUT").ToList();
|
||||
|
||||
report.CurrentWeek.SetYieldInformation(task1.Result, report.QuarterlyTargets);
|
||||
report.PreviousWeek.SetYieldInformation(task2.Result, report.QuarterlyTargets);
|
||||
|
||||
report.QuarterStartDate = task3.Result;
|
||||
|
||||
report.CurrentWeek.QTDOutsAndScrap = task4.Result;
|
||||
report.PreviousWeek.QTDOutsAndScrap = task4.Result;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.LogCritical(ex, "Failed to retrieve data back from Scrape DB endpoints.");
|
||||
}
|
||||
|
||||
report.ReverseLists();
|
||||
|
||||
ManualReportEntries entries = report.ManualReportEntries;
|
||||
List<SLLTool> sll = report.SLLTools;
|
||||
|
||||
try
|
||||
{
|
||||
JsonFileHandler.SaveJSONFile(entries, _dailyRptFilePath);
|
||||
JsonFileHandler.SaveJSONFile(sll, _SLLFilePath);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.LogCritical(ex, "Failed to save data back to JSON files.");
|
||||
}
|
||||
|
||||
return report;
|
||||
}
|
||||
}
|
||||
|
||||
public static List<int> GetUnscheduledReactors(DailyReport report)
|
||||
{
|
||||
List<int> reactors = new();
|
||||
|
||||
foreach (ToolEventView tool in report.ToolEvents)
|
||||
{
|
||||
if (!tool.IsInProduction)
|
||||
{
|
||||
reactors.Add(int.Parse(tool.Reactor));
|
||||
}
|
||||
}
|
||||
|
||||
return reactors;
|
||||
}
|
||||
}
|
@ -1,19 +1,18 @@
|
||||
using System.Text.Json;
|
||||
|
||||
namespace ReportingServices.Shared.HelperClasses
|
||||
{
|
||||
public static class JsonFileHandler
|
||||
{
|
||||
public static T LoadJSONFile<T>(string file)
|
||||
{
|
||||
string json = File.ReadAllText(file);
|
||||
return JsonSerializer.Deserialize<T>(json);
|
||||
}
|
||||
namespace ReportingServices.Shared.HelperClasses;
|
||||
|
||||
public static void SaveJSONFile<T>(T obj, string file)
|
||||
{
|
||||
string json = JsonSerializer.Serialize(obj);
|
||||
File.WriteAllText(file, json);
|
||||
}
|
||||
public static class JsonFileHandler
|
||||
{
|
||||
public static T LoadJSONFile<T>(string file)
|
||||
{
|
||||
string json = File.ReadAllText(file);
|
||||
return JsonSerializer.Deserialize<T>(json);
|
||||
}
|
||||
}
|
||||
|
||||
public static void SaveJSONFile<T>(T obj, string file)
|
||||
{
|
||||
string json = JsonSerializer.Serialize(obj);
|
||||
File.WriteAllText(file, json);
|
||||
}
|
||||
}
|
@ -1,14 +1,13 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace ReportingServices.Shared.Models.PlanningReport
|
||||
namespace ReportingServices.Shared.Models.PlanningReport;
|
||||
|
||||
public class ReactorPSNWORuns
|
||||
{
|
||||
public class ReactorPSNWORuns
|
||||
{
|
||||
[JsonPropertyName("REACTOR")]
|
||||
public string REACTOR { get; set; }
|
||||
[JsonPropertyName("PSN")]
|
||||
public string PSN { get; set; }
|
||||
[JsonPropertyName("WO_COUNT")]
|
||||
public int WO_COUNT { get; set; }
|
||||
}
|
||||
}
|
||||
[JsonPropertyName("REACTOR")]
|
||||
public string REACTOR { get; set; }
|
||||
[JsonPropertyName("PSN")]
|
||||
public string PSN { get; set; }
|
||||
[JsonPropertyName("WO_COUNT")]
|
||||
public int WO_COUNT { get; set; }
|
||||
}
|
@ -1,10 +1,9 @@
|
||||
namespace ReportingServices.Shared.Models.PlanningReport
|
||||
namespace ReportingServices.Shared.Models.PlanningReport;
|
||||
|
||||
public class WeeklyPartChanges
|
||||
{
|
||||
public class WeeklyPartChanges
|
||||
{
|
||||
public int TotalPartChanges { get; set; }
|
||||
public string StartDate { get; set; }
|
||||
public string EndDate { get; set; }
|
||||
public List<ReactorPSNWORuns> ReactorPSNWORuns { get; set; }
|
||||
}
|
||||
}
|
||||
public int TotalPartChanges { get; set; }
|
||||
public string StartDate { get; set; }
|
||||
public string EndDate { get; set; }
|
||||
public List<ReactorPSNWORuns> ReactorPSNWORuns { get; set; }
|
||||
}
|
@ -1,21 +1,20 @@
|
||||
namespace ReportingServices.Shared.Models.ProductionReport
|
||||
namespace ReportingServices.Shared.Models.ProductionReport;
|
||||
|
||||
public class ManualReportEntries
|
||||
{
|
||||
public class ManualReportEntries
|
||||
{
|
||||
public int OperatorHeadcountDays { get; set; }
|
||||
public int OperatorHeadcountNights { get; set; }
|
||||
public int OperatorCallOutsDays { get; set; }
|
||||
public int OperatorCallOutsNights { get; set; }
|
||||
public int EngineeringHeadcountDays { get; set; }
|
||||
public int EngineeringHeadcountNights { get; set; }
|
||||
public int EngineeringCallOutsDays { get; set; }
|
||||
public int EngineeringCallOutsNights { get; set; }
|
||||
public int MaintenanceHeadcountDays { get; set; }
|
||||
public int MaintenanceHeadcountNights { get; set; }
|
||||
public int MaintenanceCallOutsDays { get; set; }
|
||||
public int MaintenanceCallOutsNights { get; set; }
|
||||
public string BottleChanges { get; set; }
|
||||
public string DailyPartChanges { get; set; }
|
||||
public string WeeklyPartChanges { get; set; }
|
||||
}
|
||||
}
|
||||
public int OperatorHeadcountDays { get; set; }
|
||||
public int OperatorHeadcountNights { get; set; }
|
||||
public int OperatorCallOutsDays { get; set; }
|
||||
public int OperatorCallOutsNights { get; set; }
|
||||
public int EngineeringHeadcountDays { get; set; }
|
||||
public int EngineeringHeadcountNights { get; set; }
|
||||
public int EngineeringCallOutsDays { get; set; }
|
||||
public int EngineeringCallOutsNights { get; set; }
|
||||
public int MaintenanceHeadcountDays { get; set; }
|
||||
public int MaintenanceHeadcountNights { get; set; }
|
||||
public int MaintenanceCallOutsDays { get; set; }
|
||||
public int MaintenanceCallOutsNights { get; set; }
|
||||
public string BottleChanges { get; set; }
|
||||
public string DailyPartChanges { get; set; }
|
||||
public string WeeklyPartChanges { get; set; }
|
||||
}
|
@ -1,16 +1,15 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace ReportingServices.Shared.Models.ProductionReport
|
||||
namespace ReportingServices.Shared.Models.ProductionReport;
|
||||
|
||||
public class OutsAndScrapTotal
|
||||
{
|
||||
public class OutsAndScrapTotal
|
||||
{
|
||||
[JsonPropertyName("Outs")]
|
||||
public int Outs { get; set; }
|
||||
[JsonPropertyName("CustomerScrap")]
|
||||
public int CustomerScrap { get; set; }
|
||||
[JsonPropertyName("ManufacturingScrap")]
|
||||
public int ManufacturingScrap { get; set; }
|
||||
[JsonPropertyName("ProductionScrap")]
|
||||
public int ProductionScrap { get; set; }
|
||||
}
|
||||
}
|
||||
[JsonPropertyName("Outs")]
|
||||
public int Outs { get; set; }
|
||||
[JsonPropertyName("CustomerScrap")]
|
||||
public int CustomerScrap { get; set; }
|
||||
[JsonPropertyName("ManufacturingScrap")]
|
||||
public int ManufacturingScrap { get; set; }
|
||||
[JsonPropertyName("ProductionScrap")]
|
||||
public int ProductionScrap { get; set; }
|
||||
}
|
@ -1,18 +1,17 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace ReportingServices.Shared.Models.ProductionReport
|
||||
namespace ReportingServices.Shared.Models.ProductionReport;
|
||||
|
||||
public class QuarterlyTargets
|
||||
{
|
||||
public class QuarterlyTargets
|
||||
{
|
||||
[JsonPropertyName("Reactor_Outs")]
|
||||
public int Reactor_Outs { get; set; }
|
||||
[JsonPropertyName("Yield_Outs")]
|
||||
public int Yield_Outs { get; set; }
|
||||
[JsonPropertyName("IFX_Scrap")]
|
||||
public int IFX_Scrap { get; set; }
|
||||
[JsonPropertyName("Yield")]
|
||||
public float Yield { get; set; }
|
||||
[JsonPropertyName("PlanWorkingDays")]
|
||||
public int PlanWorkingDays { get; set; }
|
||||
}
|
||||
}
|
||||
[JsonPropertyName("Reactor_Outs")]
|
||||
public int Reactor_Outs { get; set; }
|
||||
[JsonPropertyName("Yield_Outs")]
|
||||
public int Yield_Outs { get; set; }
|
||||
[JsonPropertyName("IFX_Scrap")]
|
||||
public int IFX_Scrap { get; set; }
|
||||
[JsonPropertyName("Yield")]
|
||||
public float Yield { get; set; }
|
||||
[JsonPropertyName("PlanWorkingDays")]
|
||||
public int PlanWorkingDays { get; set; }
|
||||
}
|
@ -1,18 +1,17 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace ReportingServices.Shared.Models.ProductionReport
|
||||
namespace ReportingServices.Shared.Models.ProductionReport;
|
||||
|
||||
public class RDS
|
||||
{
|
||||
public class RDS
|
||||
{
|
||||
[JsonPropertyName("Reactor")]
|
||||
public int Reactor { get; set; }
|
||||
[JsonPropertyName("ReactorType")]
|
||||
public string ReactorType { get; set; }
|
||||
[JsonPropertyName("DateOut")]
|
||||
public DateTime DateOut { get; set; }
|
||||
[JsonPropertyName("UnloadTemp")]
|
||||
public int UnloadTemp { get; set; }
|
||||
[JsonPropertyName("LayerType")]
|
||||
public string LayerType { get; set; }
|
||||
}
|
||||
}
|
||||
[JsonPropertyName("Reactor")]
|
||||
public int Reactor { get; set; }
|
||||
[JsonPropertyName("ReactorType")]
|
||||
public string ReactorType { get; set; }
|
||||
[JsonPropertyName("DateOut")]
|
||||
public DateTime DateOut { get; set; }
|
||||
[JsonPropertyName("UnloadTemp")]
|
||||
public int UnloadTemp { get; set; }
|
||||
[JsonPropertyName("LayerType")]
|
||||
public string LayerType { get; set; }
|
||||
}
|
@ -1,16 +1,15 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace ReportingServices.Shared.Models.ProductionReport
|
||||
namespace ReportingServices.Shared.Models.ProductionReport;
|
||||
|
||||
public class Reactor
|
||||
{
|
||||
public class Reactor
|
||||
{
|
||||
[JsonPropertyName("ReactorNumber")]
|
||||
public int ReactorNumber { get; set; }
|
||||
[JsonPropertyName("Type")]
|
||||
public string Type { get; set; }
|
||||
[JsonPropertyName("PocketSize")]
|
||||
public string PocketSize { get; set; }
|
||||
[JsonPropertyName("HasDisabledLoadLock")]
|
||||
public bool HasDisabledLoadlock { get; set; }
|
||||
}
|
||||
}
|
||||
[JsonPropertyName("ReactorNumber")]
|
||||
public int ReactorNumber { get; set; }
|
||||
[JsonPropertyName("Type")]
|
||||
public string Type { get; set; }
|
||||
[JsonPropertyName("PocketSize")]
|
||||
public string PocketSize { get; set; }
|
||||
[JsonPropertyName("HasDisabledLoadLock")]
|
||||
public bool HasDisabledLoadlock { get; set; }
|
||||
}
|
@ -1,16 +1,15 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace ReportingServices.Shared.Models.ProductionReport
|
||||
namespace ReportingServices.Shared.Models.ProductionReport;
|
||||
|
||||
public class ReactorEvent
|
||||
{
|
||||
public class ReactorEvent
|
||||
{
|
||||
[JsonPropertyName("REACT_NO")]
|
||||
public string REACT_NO { get; set; }
|
||||
[JsonPropertyName("EVENT_DTM")]
|
||||
public string EVENT_DTM { get; set; }
|
||||
[JsonPropertyName("COMMENT")]
|
||||
public string COMMENT { get; set; }
|
||||
[JsonPropertyName("REACT_MODE")]
|
||||
public string REACT_MODE { get; set; }
|
||||
}
|
||||
}
|
||||
[JsonPropertyName("REACT_NO")]
|
||||
public string REACT_NO { get; set; }
|
||||
[JsonPropertyName("EVENT_DTM")]
|
||||
public string EVENT_DTM { get; set; }
|
||||
[JsonPropertyName("COMMENT")]
|
||||
public string COMMENT { get; set; }
|
||||
[JsonPropertyName("REACT_MODE")]
|
||||
public string REACT_MODE { get; set; }
|
||||
}
|
@ -1,8 +1,7 @@
|
||||
namespace ReportingServices.Shared.Models.ProductionReport
|
||||
namespace ReportingServices.Shared.Models.ProductionReport;
|
||||
|
||||
public class ReactorOutsByDay
|
||||
{
|
||||
public class ReactorOutsByDay
|
||||
{
|
||||
public string StartDate { get; set; }
|
||||
public int TotalWafers { get; set; }
|
||||
}
|
||||
}
|
||||
public string StartDate { get; set; }
|
||||
public int TotalWafers { get; set; }
|
||||
}
|
@ -1,14 +1,13 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace ReportingServices.Shared.Models.ProductionReport
|
||||
namespace ReportingServices.Shared.Models.ProductionReport;
|
||||
|
||||
public class ReactorOutsByRDS
|
||||
{
|
||||
public class ReactorOutsByRDS
|
||||
{
|
||||
[JsonPropertyName("RDS_NO")]
|
||||
public string RDS_NO { get; set; }
|
||||
[JsonPropertyName("Units")]
|
||||
public string Units { get; set; }
|
||||
[JsonPropertyName("EndProcessTime")]
|
||||
public string EndProcessTime { get; set; }
|
||||
}
|
||||
}
|
||||
[JsonPropertyName("RDS_NO")]
|
||||
public string RDS_NO { get; set; }
|
||||
[JsonPropertyName("Units")]
|
||||
public string Units { get; set; }
|
||||
[JsonPropertyName("EndProcessTime")]
|
||||
public string EndProcessTime { get; set; }
|
||||
}
|
@ -1,18 +1,17 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace ReportingServices.Shared.Models.ProductionReport
|
||||
namespace ReportingServices.Shared.Models.ProductionReport;
|
||||
|
||||
public class ScrapByDay
|
||||
{
|
||||
public class ScrapByDay
|
||||
{
|
||||
[JsonPropertyName("StartDate")]
|
||||
public string StartDate { get; set; }
|
||||
[JsonPropertyName("TW_PROD")]
|
||||
public int TW_PROD { get; set; }
|
||||
[JsonPropertyName("TOT_REJ_CUST")]
|
||||
public int TOT_REJ_CUST { get; set; }
|
||||
[JsonPropertyName("TOT_REJ_MANU")]
|
||||
public int TOT_REJ_MANU { get; set; }
|
||||
[JsonPropertyName("TOT_REJ_WFRS")]
|
||||
public int TOT_REJ_WFRS { get; set; }
|
||||
}
|
||||
}
|
||||
[JsonPropertyName("StartDate")]
|
||||
public string StartDate { get; set; }
|
||||
[JsonPropertyName("TW_PROD")]
|
||||
public int TW_PROD { get; set; }
|
||||
[JsonPropertyName("TOT_REJ_CUST")]
|
||||
public int TOT_REJ_CUST { get; set; }
|
||||
[JsonPropertyName("TOT_REJ_MANU")]
|
||||
public int TOT_REJ_MANU { get; set; }
|
||||
[JsonPropertyName("TOT_REJ_WFRS")]
|
||||
public int TOT_REJ_WFRS { get; set; }
|
||||
}
|
@ -1,16 +1,15 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace ReportingServices.Shared.Models.ProductionReport
|
||||
namespace ReportingServices.Shared.Models.ProductionReport;
|
||||
|
||||
public class ToolEvent
|
||||
{
|
||||
public class ToolEvent
|
||||
{
|
||||
[JsonPropertyName("TOOL_ID")]
|
||||
public string TOOL_ID { get; set; }
|
||||
[JsonPropertyName("START_DTM")]
|
||||
public string START_DTM { get; set; }
|
||||
[JsonPropertyName("TOOL_MODE")]
|
||||
public string TOOL_MODE { get; set; }
|
||||
[JsonPropertyName("TOOL_MODE_DESC")]
|
||||
public string TOOL_MODE_DESC { get; set; }
|
||||
}
|
||||
}
|
||||
[JsonPropertyName("TOOL_ID")]
|
||||
public string TOOL_ID { get; set; }
|
||||
[JsonPropertyName("START_DTM")]
|
||||
public string START_DTM { get; set; }
|
||||
[JsonPropertyName("TOOL_MODE")]
|
||||
public string TOOL_MODE { get; set; }
|
||||
[JsonPropertyName("TOOL_MODE_DESC")]
|
||||
public string TOOL_MODE_DESC { get; set; }
|
||||
}
|
@ -1,8 +1,7 @@
|
||||
namespace ReportingServices.Shared.Models.ProductionReport
|
||||
namespace ReportingServices.Shared.Models.ProductionReport;
|
||||
|
||||
public class ToolUptimeData
|
||||
{
|
||||
public class ToolUptimeData
|
||||
{
|
||||
public string Date { get; set; }
|
||||
public double UptimePercentage { get; set; }
|
||||
}
|
||||
}
|
||||
public string Date { get; set; }
|
||||
public double UptimePercentage { get; set; }
|
||||
}
|
@ -1,17 +1,11 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.Json.Serialization;
|
||||
using System.Threading.Tasks;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace ReportingServices.Shared.Models.ProductionReport
|
||||
namespace ReportingServices.Shared.Models.ProductionReport;
|
||||
|
||||
public class YieldInformation
|
||||
{
|
||||
public class YieldInformation
|
||||
{
|
||||
[JsonPropertyName("Outs")]
|
||||
public List<ReactorOutsByRDS> Outs { get; set; }
|
||||
[JsonPropertyName("Scrap")]
|
||||
public List<ScrapByDay> Scrap { get; set; }
|
||||
}
|
||||
}
|
||||
[JsonPropertyName("Outs")]
|
||||
public List<ReactorOutsByRDS> Outs { get; set; }
|
||||
[JsonPropertyName("Scrap")]
|
||||
public List<ScrapByDay> Scrap { get; set; }
|
||||
}
|
@ -1,499 +1,493 @@
|
||||
using Microsoft.Data.SqlClient;
|
||||
using ReportingServices.Shared.Models.PlanningReport;
|
||||
using ReportingServices.Shared.Models.ProductionReport;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
|
||||
namespace ReportingServices.Shared.Repositories
|
||||
namespace ReportingServices.Shared.Repositories;
|
||||
|
||||
public class ScrapeDatabaseRepository : IScrapeDatabaseRepository
|
||||
{
|
||||
public class ScrapeDatabaseRepository : IScrapeDatabaseRepository
|
||||
private SqlConnection _connection;
|
||||
private readonly string _connectionString;
|
||||
|
||||
public ScrapeDatabaseRepository() => _connectionString = "Server=MESSV01EC.EC.LOCAL\\PROD1,53959;Database=LSL2SQL;User Id=srpadmin;Password=0okm9ijn;TrustServerCertificate=true";
|
||||
|
||||
public void OpenConnection()
|
||||
{
|
||||
private SqlConnection _connection;
|
||||
private readonly string _connectionString;
|
||||
_connection ??= new SqlConnection(_connectionString);
|
||||
|
||||
public ScrapeDatabaseRepository()
|
||||
{
|
||||
_connectionString = "Server=MESSV01EC.EC.LOCAL\\PROD1,53959;Database=LSL2SQL;User Id=srpadmin;Password=0okm9ijn;TrustServerCertificate=true";
|
||||
}
|
||||
|
||||
public void OpenConnection()
|
||||
{
|
||||
if (_connection == null)
|
||||
_connection = new SqlConnection(_connectionString);
|
||||
|
||||
if (_connection.State != ConnectionState.Open)
|
||||
_connection.Open();
|
||||
}
|
||||
|
||||
public void CloseConnection()
|
||||
{
|
||||
if (_connection.State != ConnectionState.Closed)
|
||||
_connection.Close();
|
||||
}
|
||||
|
||||
public int GetNumberOfPartChanges(string startDate, string endDate)
|
||||
{
|
||||
int result = 0;
|
||||
|
||||
OpenConnection();
|
||||
|
||||
SqlCommand cmd = _connection.CreateCommand();
|
||||
|
||||
string query = "SELECT COUNT(*) FROM " +
|
||||
"(SELECT REACTOR, COUNT(PROD_SPEC_ID) - 1 AS PCHANGE FROM " +
|
||||
"(SELECT REACTOR, PROD_SPEC_ID, COUNT(WO) AS PSN_COUNT FROM RDS WHERE DATE_OUT BETWEEN @startDate AND @endDate GROUP BY REACTOR, PROD_SPEC_ID) AS t " +
|
||||
"GROUP BY REACTOR) AS l WHERE PCHANGE > 0";
|
||||
|
||||
cmd.CommandText = query;
|
||||
cmd.Parameters.AddWithValue("@startDate", startDate);
|
||||
cmd.Parameters.AddWithValue("@endDate", endDate);
|
||||
|
||||
using (SqlDataReader reader = cmd.ExecuteReader())
|
||||
{
|
||||
reader.Read();
|
||||
|
||||
result = int.Parse(reader[0].ToString());
|
||||
}
|
||||
|
||||
cmd.Dispose();
|
||||
|
||||
CloseConnection();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public List<ScrapByDay> GetScrapByDay(List<ReactorOutsByRDS> outs)
|
||||
{
|
||||
List<ScrapByDay> scrap = new();
|
||||
string rdsNumbers = "";
|
||||
|
||||
foreach (ReactorOutsByRDS rout in outs)
|
||||
rdsNumbers = rdsNumbers + "'" + rout.RDS_NO + "', ";
|
||||
|
||||
rdsNumbers = rdsNumbers.Substring(0, rdsNumbers.Length - 2);
|
||||
|
||||
OpenConnection();
|
||||
|
||||
SqlCommand cmd = _connection.CreateCommand();
|
||||
|
||||
string query = "SELECT " +
|
||||
" DATE_OUT," +
|
||||
" SUM(CUST_TOT_REJ) AS TOT_REJ_CUST," +
|
||||
" SUM(LSL_TOT_REJ) AS TOT_REJ_MANU," +
|
||||
" SUM(TW_PROD) AS TW_PROD " +
|
||||
"FROM RDS " +
|
||||
"WHERE SEQ IN (" + rdsNumbers + ") " +
|
||||
"GROUP BY DATE_OUT " +
|
||||
"ORDER BY 1 DESC";
|
||||
|
||||
cmd.CommandText = query;
|
||||
|
||||
using (SqlDataReader reader = cmd.ExecuteReader())
|
||||
{
|
||||
while (reader.Read() && reader[0].ToString() != "1/1/1900 12:00:00 AM")
|
||||
scrap.Add(new ScrapByDay
|
||||
{
|
||||
StartDate = reader[0].ToString(),
|
||||
TW_PROD = int.Parse(reader[3].ToString()),
|
||||
TOT_REJ_CUST = int.Parse(reader[1].ToString()),
|
||||
TOT_REJ_MANU = int.Parse(reader[2].ToString()),
|
||||
TOT_REJ_WFRS =
|
||||
int.Parse(reader[1].ToString()) + int.Parse(reader[2].ToString())
|
||||
});
|
||||
}
|
||||
|
||||
cmd.Dispose();
|
||||
|
||||
CloseConnection();
|
||||
|
||||
return scrap;
|
||||
}
|
||||
|
||||
public List<ReactorPSNWORuns> GetReactorPSNWORuns(string startDate, string endDate)
|
||||
{
|
||||
List<ReactorPSNWORuns> weeklyPartChanges = new();
|
||||
|
||||
OpenConnection();
|
||||
|
||||
SqlCommand cmd = _connection.CreateCommand();
|
||||
|
||||
string query = "SELECT REACTOR, PROD_SPEC_ID, COUNT(WO) FROM RDS " +
|
||||
"WHERE DATE_OUT BETWEEN @startDate AND @endDate " +
|
||||
"GROUP BY REACTOR, PROD_SPEC_ID " +
|
||||
"ORDER BY 1";
|
||||
|
||||
cmd.CommandText = query;
|
||||
cmd.Parameters.AddWithValue("@startDate", startDate);
|
||||
cmd.Parameters.AddWithValue("@endDate", endDate);
|
||||
|
||||
using (SqlDataReader reader = cmd.ExecuteReader())
|
||||
{
|
||||
while (reader.Read())
|
||||
weeklyPartChanges.Add(new ReactorPSNWORuns
|
||||
{
|
||||
REACTOR = reader[0].ToString(),
|
||||
PSN = reader[1].ToString(),
|
||||
WO_COUNT = int.Parse(reader[2].ToString())
|
||||
});
|
||||
}
|
||||
|
||||
cmd.Dispose();
|
||||
|
||||
CloseConnection();
|
||||
|
||||
return weeklyPartChanges;
|
||||
}
|
||||
|
||||
public QuarterlyTargets GetQuarterlyTargets()
|
||||
{
|
||||
Dictionary<string, float> targets = new();
|
||||
|
||||
OpenConnection();
|
||||
|
||||
SqlCommand cmd = _connection.CreateCommand();
|
||||
|
||||
string query = "SELECT THRU_TARGET, THRU_QTY, THRU_PCNT FROM FISCAL_QTR_TARGETS " +
|
||||
" WHERE THRU_GROUP = 'TOT' " +
|
||||
" AND FISCAL_YR = " +
|
||||
" (SELECT FISCAL_YR FROM FISCAL_QTR " +
|
||||
" WHERE START_DT < SYSDATETIME() " +
|
||||
" AND END_DT > SYSDATETIME()) " +
|
||||
" AND FISCAL_QTR = " +
|
||||
" (SELECT FISCAL_QTR FROM FISCAL_QTR " +
|
||||
" WHERE START_DT < SYSDATETIME() " +
|
||||
" AND END_DT > SYSDATETIME()) " +
|
||||
"UNION " +
|
||||
"SELECT 'PlanWorkingDays' As THRU_TARGET," +
|
||||
" PLAN_WORKING_DAYS AS THRU_QTY," +
|
||||
" NULL AS THRU_PCNT" +
|
||||
" FROM FISCAL_QTR " +
|
||||
" WHERE SYSDATETIME() BETWEEN START_DT AND END_DT";
|
||||
|
||||
cmd.CommandText = query;
|
||||
|
||||
using (SqlDataReader reader = cmd.ExecuteReader())
|
||||
{
|
||||
while(reader.Read())
|
||||
{
|
||||
if (reader[0].ToString().ToUpper() == "YIELD")
|
||||
targets.Add(reader[0].ToString(), float.Parse(reader[2].ToString()));
|
||||
else if (!string.IsNullOrEmpty(reader[1].ToString()))
|
||||
targets.Add(reader[0].ToString(), int.Parse(reader[1].ToString()));
|
||||
}
|
||||
}
|
||||
|
||||
cmd.Dispose();
|
||||
|
||||
CloseConnection();
|
||||
|
||||
QuarterlyTargets quarterlyTargets = new()
|
||||
{
|
||||
Reactor_Outs = (int)targets["Reactor_Outs"],
|
||||
Yield_Outs = (int)targets["Yield_Outs"],
|
||||
IFX_Scrap = (int)targets["IFX_Scrap"],
|
||||
Yield = targets["Yield"],
|
||||
PlanWorkingDays = (int)targets["PlanWorkingDays"]
|
||||
};
|
||||
|
||||
return quarterlyTargets;
|
||||
}
|
||||
|
||||
public List<Reactor> GetReactors()
|
||||
{
|
||||
List<Reactor> reactors = new();
|
||||
|
||||
OpenConnection();
|
||||
|
||||
SqlCommand cmd = _connection.CreateCommand();
|
||||
|
||||
string query = "SELECT " +
|
||||
" REACT_NO, REACT_TYPE, SUSC_POCKET_SIZE, CASE WHEN ACTIVE_LL_DISABLED <> '' THEN 'TRUE' ELSE 'FALSE' END AS \"LL_DISABLED\" " +
|
||||
" FROM REACTOR " +
|
||||
" WHERE REACT_ASSIGNMENT IS NOT NULL " +
|
||||
" AND REACT_ASSIGNMENT <> 'Out of Service' " +
|
||||
" AND REACT_ASSIGNMENT<> ''";
|
||||
|
||||
cmd.CommandText = query;
|
||||
|
||||
using (SqlDataReader reader = cmd.ExecuteReader())
|
||||
{
|
||||
while (reader.Read())
|
||||
reactors.Add(new Reactor
|
||||
{
|
||||
ReactorNumber = int.Parse(reader[0].ToString()),
|
||||
Type = reader[1].ToString(),
|
||||
PocketSize = reader[2].ToString(),
|
||||
HasDisabledLoadlock = bool.Parse(reader[3].ToString())
|
||||
});
|
||||
}
|
||||
|
||||
cmd.Dispose();
|
||||
|
||||
CloseConnection();
|
||||
|
||||
return reactors;
|
||||
}
|
||||
|
||||
public List<RDS> GetRDSForLastDay(string date)
|
||||
{
|
||||
List<RDS> rdsList = new();
|
||||
|
||||
OpenConnection();
|
||||
|
||||
SqlCommand cmd = _connection.CreateCommand();
|
||||
|
||||
string query = "SELECT rds.REACTOR, rds.REACTOR_TYPE, rds.DATE_OUT, " +
|
||||
"CASE WHEN lay.UL_TEMP IS NULL THEN '1000' ELSE lay.UL_TEMP END, psn.LAYER_TYPE FROM RDS " +
|
||||
"INNER JOIN RDS_LAYER lay ON lay.RDS_NO = SEQ " +
|
||||
"INNER JOIN PROD_SPEC psn ON rds.PROD_SPEC_ID = psn.SEQ " +
|
||||
"WHERE DATE_OUT >= @date";
|
||||
|
||||
cmd.CommandText = query;
|
||||
cmd.Parameters.AddWithValue("@date", date);
|
||||
|
||||
using (SqlDataReader reader = cmd.ExecuteReader())
|
||||
{
|
||||
while (reader.Read())
|
||||
rdsList.Add(new RDS
|
||||
{
|
||||
Reactor = int.Parse(reader[0].ToString()),
|
||||
ReactorType = reader[1].ToString(),
|
||||
DateOut = DateTime.Parse(reader[2].ToString()),
|
||||
UnloadTemp = int.Parse(reader[3].ToString()),
|
||||
LayerType = reader[4].ToString()
|
||||
});
|
||||
}
|
||||
|
||||
cmd.Dispose();
|
||||
|
||||
CloseConnection();
|
||||
|
||||
return rdsList;
|
||||
}
|
||||
|
||||
public List<ReactorOutsByRDS> GetRDSRunBetweenDates(string startDate, string endDate)
|
||||
{
|
||||
List<ReactorOutsByRDS> outs = new();
|
||||
|
||||
OpenConnection();
|
||||
|
||||
SqlCommand cmd = _connection.CreateCommand();
|
||||
|
||||
string query = "SELECT SEQ, WFRS_OUT, DATE_OUT " +
|
||||
" FROM RDS " +
|
||||
" WHERE DATE_OUT >= @startDate " +
|
||||
" AND DATE_OUT < @endDate " +
|
||||
"ORDER BY DATE_OUT ASC";
|
||||
|
||||
cmd.CommandText = query;
|
||||
cmd.Parameters.AddWithValue("@startDate", startDate);
|
||||
cmd.Parameters.AddWithValue("@endDate", endDate);
|
||||
|
||||
using (SqlDataReader reader = cmd.ExecuteReader())
|
||||
{
|
||||
while (reader.Read())
|
||||
outs.Add(new ReactorOutsByRDS
|
||||
{
|
||||
RDS_NO = reader[0].ToString(),
|
||||
Units = reader[1].ToString(),
|
||||
EndProcessTime = reader[2].ToString()
|
||||
});
|
||||
}
|
||||
|
||||
cmd.Dispose();
|
||||
|
||||
CloseConnection();
|
||||
|
||||
return outs;
|
||||
}
|
||||
|
||||
public List<ReactorEvent> GetReactorEvents(string startDate, string endDate, string reactorNumber)
|
||||
{
|
||||
List<ReactorEvent> events = new();
|
||||
|
||||
OpenConnection();
|
||||
|
||||
SqlCommand cmd = _connection.CreateCommand();
|
||||
|
||||
string query = "SELECT " +
|
||||
" REACT_NO, " +
|
||||
" EVENT_DTM, " +
|
||||
" COMMENT, " +
|
||||
" REACT_MODE " +
|
||||
" FROM REACT_EVENT " +
|
||||
" WHERE EVENT_DTM > @startDate " +
|
||||
" AND EVENT_DTM < @endDate " +
|
||||
" AND REACT_NO = @reactorNumber " +
|
||||
"UNION ALL " +
|
||||
"SELECT " +
|
||||
" REACT_NO, " +
|
||||
" EVENT_DTM, " +
|
||||
" COMMENT, " +
|
||||
" REACT_MODE " +
|
||||
" FROM " +
|
||||
" (SELECT TOP 1 * FROM REACT_EVENT " +
|
||||
" WHERE EVENT_DTM < @startDate " +
|
||||
" AND REACT_NO = @reactorNumber ORDER BY EVENT_DTM DESC) AS tbl1 " +
|
||||
"ORDER BY EVENT_DTM ASC";
|
||||
|
||||
cmd.CommandText = query;
|
||||
cmd.Parameters.AddWithValue("@startDate", startDate);
|
||||
cmd.Parameters.AddWithValue("@endDate", endDate);
|
||||
cmd.Parameters.AddWithValue("@reactorNumber", reactorNumber);
|
||||
|
||||
using (SqlDataReader reader = cmd.ExecuteReader())
|
||||
{
|
||||
while (reader.Read())
|
||||
events.Add(new ReactorEvent
|
||||
{
|
||||
REACT_NO = reader[0].ToString(),
|
||||
EVENT_DTM = reader[1].ToString(),
|
||||
COMMENT = reader[2].ToString(),
|
||||
REACT_MODE = reader[3].ToString()
|
||||
});
|
||||
}
|
||||
|
||||
cmd.Dispose();
|
||||
|
||||
CloseConnection();
|
||||
|
||||
return events;
|
||||
}
|
||||
|
||||
public ToolEvent GetLatestToolEvent(string toolID)
|
||||
{
|
||||
ToolEvent evnt = new();
|
||||
|
||||
OpenConnection();
|
||||
|
||||
SqlCommand cmd = _connection.CreateCommand();
|
||||
|
||||
string query = "SELECT TOP 1 " +
|
||||
" TOOL_ID, " +
|
||||
" START_DTM, " +
|
||||
" TOOL_MODE, " +
|
||||
" TOOL_MODE_DESC " +
|
||||
" FROM TOOL_LOG " +
|
||||
" WHERE TOOL_ID = @toolID " +
|
||||
"ORDER BY START_DTM DESC";
|
||||
|
||||
cmd.CommandText = query;
|
||||
cmd.Parameters.AddWithValue("@toolID", toolID);
|
||||
|
||||
using (SqlDataReader reader = cmd.ExecuteReader())
|
||||
{
|
||||
while (reader.Read())
|
||||
evnt = new ToolEvent
|
||||
{
|
||||
TOOL_ID = reader[0].ToString(),
|
||||
START_DTM = reader[1].ToString(),
|
||||
TOOL_MODE = reader[2].ToString(),
|
||||
TOOL_MODE_DESC = reader[3].ToString()
|
||||
};
|
||||
}
|
||||
|
||||
cmd.Dispose();
|
||||
|
||||
CloseConnection();
|
||||
|
||||
return evnt;
|
||||
}
|
||||
|
||||
public int GetLastUpTransaction(string reactorNumber)
|
||||
{
|
||||
int lastTransaction = 0;
|
||||
|
||||
OpenConnection();
|
||||
|
||||
SqlCommand cmd = _connection.CreateCommand();
|
||||
|
||||
string query = "SELECT TOP 1 DATEDIFF(MINUTE,START_DTM,SYSDATETIME()) " +
|
||||
" FROM REACT_MODE " +
|
||||
" WHERE REACT_NO = @reactorNumber " +
|
||||
" AND (MODE = 'UP' OR MODE = 'UP_WITH_INCREASED_SAMPLING') " +
|
||||
"ORDER BY START_DTM DESC";
|
||||
|
||||
cmd.CommandText = query;
|
||||
cmd.Parameters.AddWithValue("@reactorNumber", reactorNumber);
|
||||
|
||||
using (SqlDataReader reader = cmd.ExecuteReader())
|
||||
{
|
||||
while (reader.Read())
|
||||
lastTransaction = int.Parse(reader[0].ToString());
|
||||
}
|
||||
|
||||
cmd.Dispose();
|
||||
|
||||
CloseConnection();
|
||||
|
||||
return lastTransaction;
|
||||
}
|
||||
|
||||
public OutsAndScrapTotal GetOutsAndScrapTotals(string startDate, string endDate)
|
||||
{
|
||||
OutsAndScrapTotal totals = new();
|
||||
|
||||
OpenConnection();
|
||||
|
||||
SqlCommand cmd = _connection.CreateCommand();
|
||||
|
||||
string query = "SELECT SUM(WFRS_OUT) AS OUTS, " +
|
||||
" SUM(CUST_TOT_REJ) AS CUST, " +
|
||||
" SUM(LSL_TOT_REJ) AS MANU, " +
|
||||
" SUM(TW_PROD) AS PROD " +
|
||||
" FROM RDS " +
|
||||
" WHERE DATE_OUT >= @startDate " +
|
||||
" AND DATE_OUT <= @endDate";
|
||||
|
||||
cmd.CommandText = query;
|
||||
cmd.Parameters.AddWithValue("@startDate", startDate);
|
||||
cmd.Parameters.AddWithValue("@endDate", endDate);
|
||||
|
||||
using (SqlDataReader reader = cmd.ExecuteReader())
|
||||
{
|
||||
while (reader.Read())
|
||||
totals = new()
|
||||
{
|
||||
Outs = int.Parse(reader[0].ToString()),
|
||||
CustomerScrap = int.Parse(reader[1].ToString()),
|
||||
ManufacturingScrap = int.Parse(reader[2].ToString()),
|
||||
ProductionScrap = int.Parse(reader[3].ToString()),
|
||||
};
|
||||
}
|
||||
|
||||
cmd.Dispose();
|
||||
|
||||
CloseConnection();
|
||||
|
||||
return totals;
|
||||
}
|
||||
|
||||
public DateTime GetQuarterStartDate()
|
||||
{
|
||||
DateTime date = new();
|
||||
|
||||
OpenConnection();
|
||||
|
||||
SqlCommand cmd = _connection.CreateCommand();
|
||||
|
||||
string query = "SELECT START_DT " +
|
||||
" FROM FISCAL_QTR " +
|
||||
" WHERE START_DT < SYSDATETIME() " +
|
||||
" AND END_DT > SYSDATETIME()";
|
||||
|
||||
cmd.CommandText = query;
|
||||
|
||||
using (SqlDataReader reader = cmd.ExecuteReader())
|
||||
{
|
||||
while (reader.Read())
|
||||
date = DateTime.Parse(reader[0].ToString());
|
||||
}
|
||||
|
||||
cmd.Dispose();
|
||||
|
||||
CloseConnection();
|
||||
|
||||
return date;
|
||||
}
|
||||
if (_connection.State != ConnectionState.Open)
|
||||
_connection.Open();
|
||||
}
|
||||
}
|
||||
|
||||
public void CloseConnection()
|
||||
{
|
||||
if (_connection.State != ConnectionState.Closed)
|
||||
_connection.Close();
|
||||
}
|
||||
|
||||
public int GetNumberOfPartChanges(string startDate, string endDate)
|
||||
{
|
||||
int result = 0;
|
||||
|
||||
OpenConnection();
|
||||
|
||||
SqlCommand cmd = _connection.CreateCommand();
|
||||
|
||||
string query = "SELECT COUNT(*) FROM " +
|
||||
"(SELECT REACTOR, COUNT(PROD_SPEC_ID) - 1 AS PCHANGE FROM " +
|
||||
"(SELECT REACTOR, PROD_SPEC_ID, COUNT(WO) AS PSN_COUNT FROM RDS WHERE DATE_OUT BETWEEN @startDate AND @endDate GROUP BY REACTOR, PROD_SPEC_ID) AS t " +
|
||||
"GROUP BY REACTOR) AS l WHERE PCHANGE > 0";
|
||||
|
||||
cmd.CommandText = query;
|
||||
_ = cmd.Parameters.AddWithValue("@startDate", startDate);
|
||||
_ = cmd.Parameters.AddWithValue("@endDate", endDate);
|
||||
|
||||
using (SqlDataReader reader = cmd.ExecuteReader())
|
||||
{
|
||||
_ = reader.Read();
|
||||
|
||||
result = int.Parse(reader[0].ToString());
|
||||
}
|
||||
|
||||
cmd.Dispose();
|
||||
|
||||
CloseConnection();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public List<ScrapByDay> GetScrapByDay(List<ReactorOutsByRDS> outs)
|
||||
{
|
||||
List<ScrapByDay> scrap = new();
|
||||
string rdsNumbers = "";
|
||||
|
||||
foreach (ReactorOutsByRDS rout in outs)
|
||||
rdsNumbers = rdsNumbers + "'" + rout.RDS_NO + "', ";
|
||||
|
||||
rdsNumbers = rdsNumbers[..^2];
|
||||
|
||||
OpenConnection();
|
||||
|
||||
SqlCommand cmd = _connection.CreateCommand();
|
||||
|
||||
string query = "SELECT " +
|
||||
" DATE_OUT," +
|
||||
" SUM(CUST_TOT_REJ) AS TOT_REJ_CUST," +
|
||||
" SUM(LSL_TOT_REJ) AS TOT_REJ_MANU," +
|
||||
" SUM(TW_PROD) AS TW_PROD " +
|
||||
"FROM RDS " +
|
||||
"WHERE SEQ IN (" + rdsNumbers + ") " +
|
||||
"GROUP BY DATE_OUT " +
|
||||
"ORDER BY 1 DESC";
|
||||
|
||||
cmd.CommandText = query;
|
||||
|
||||
using (SqlDataReader reader = cmd.ExecuteReader())
|
||||
{
|
||||
while (reader.Read() && reader[0].ToString() != "1/1/1900 12:00:00 AM")
|
||||
scrap.Add(new ScrapByDay
|
||||
{
|
||||
StartDate = reader[0].ToString(),
|
||||
TW_PROD = int.Parse(reader[3].ToString()),
|
||||
TOT_REJ_CUST = int.Parse(reader[1].ToString()),
|
||||
TOT_REJ_MANU = int.Parse(reader[2].ToString()),
|
||||
TOT_REJ_WFRS =
|
||||
int.Parse(reader[1].ToString()) + int.Parse(reader[2].ToString())
|
||||
});
|
||||
}
|
||||
|
||||
cmd.Dispose();
|
||||
|
||||
CloseConnection();
|
||||
|
||||
return scrap;
|
||||
}
|
||||
|
||||
public List<ReactorPSNWORuns> GetReactorPSNWORuns(string startDate, string endDate)
|
||||
{
|
||||
List<ReactorPSNWORuns> weeklyPartChanges = new();
|
||||
|
||||
OpenConnection();
|
||||
|
||||
SqlCommand cmd = _connection.CreateCommand();
|
||||
|
||||
string query = "SELECT REACTOR, PROD_SPEC_ID, COUNT(WO) FROM RDS " +
|
||||
"WHERE DATE_OUT BETWEEN @startDate AND @endDate " +
|
||||
"GROUP BY REACTOR, PROD_SPEC_ID " +
|
||||
"ORDER BY 1";
|
||||
|
||||
cmd.CommandText = query;
|
||||
_ = cmd.Parameters.AddWithValue("@startDate", startDate);
|
||||
_ = cmd.Parameters.AddWithValue("@endDate", endDate);
|
||||
|
||||
using (SqlDataReader reader = cmd.ExecuteReader())
|
||||
{
|
||||
while (reader.Read())
|
||||
weeklyPartChanges.Add(new ReactorPSNWORuns
|
||||
{
|
||||
REACTOR = reader[0].ToString(),
|
||||
PSN = reader[1].ToString(),
|
||||
WO_COUNT = int.Parse(reader[2].ToString())
|
||||
});
|
||||
}
|
||||
|
||||
cmd.Dispose();
|
||||
|
||||
CloseConnection();
|
||||
|
||||
return weeklyPartChanges;
|
||||
}
|
||||
|
||||
public QuarterlyTargets GetQuarterlyTargets()
|
||||
{
|
||||
Dictionary<string, float> targets = new();
|
||||
|
||||
OpenConnection();
|
||||
|
||||
SqlCommand cmd = _connection.CreateCommand();
|
||||
|
||||
string query = "SELECT THRU_TARGET, THRU_QTY, THRU_PCNT FROM FISCAL_QTR_TARGETS " +
|
||||
" WHERE THRU_GROUP = 'TOT' " +
|
||||
" AND FISCAL_YR = " +
|
||||
" (SELECT FISCAL_YR FROM FISCAL_QTR " +
|
||||
" WHERE START_DT < SYSDATETIME() " +
|
||||
" AND END_DT > SYSDATETIME()) " +
|
||||
" AND FISCAL_QTR = " +
|
||||
" (SELECT FISCAL_QTR FROM FISCAL_QTR " +
|
||||
" WHERE START_DT < SYSDATETIME() " +
|
||||
" AND END_DT > SYSDATETIME()) " +
|
||||
"UNION " +
|
||||
"SELECT 'PlanWorkingDays' As THRU_TARGET," +
|
||||
" PLAN_WORKING_DAYS AS THRU_QTY," +
|
||||
" NULL AS THRU_PCNT" +
|
||||
" FROM FISCAL_QTR " +
|
||||
" WHERE SYSDATETIME() BETWEEN START_DT AND END_DT";
|
||||
|
||||
cmd.CommandText = query;
|
||||
|
||||
using (SqlDataReader reader = cmd.ExecuteReader())
|
||||
{
|
||||
while (reader.Read())
|
||||
{
|
||||
if (reader[0].ToString().ToUpper() == "YIELD")
|
||||
targets.Add(reader[0].ToString(), float.Parse(reader[2].ToString()));
|
||||
else if (!string.IsNullOrEmpty(reader[1].ToString()))
|
||||
targets.Add(reader[0].ToString(), int.Parse(reader[1].ToString()));
|
||||
}
|
||||
}
|
||||
|
||||
cmd.Dispose();
|
||||
|
||||
CloseConnection();
|
||||
|
||||
QuarterlyTargets quarterlyTargets = new()
|
||||
{
|
||||
Reactor_Outs = (int)targets["Reactor_Outs"],
|
||||
Yield_Outs = (int)targets["Yield_Outs"],
|
||||
IFX_Scrap = (int)targets["IFX_Scrap"],
|
||||
Yield = targets["Yield"],
|
||||
PlanWorkingDays = (int)targets["PlanWorkingDays"]
|
||||
};
|
||||
|
||||
return quarterlyTargets;
|
||||
}
|
||||
|
||||
public List<Reactor> GetReactors()
|
||||
{
|
||||
List<Reactor> reactors = new();
|
||||
|
||||
OpenConnection();
|
||||
|
||||
SqlCommand cmd = _connection.CreateCommand();
|
||||
|
||||
string query = "SELECT " +
|
||||
" REACT_NO, REACT_TYPE, SUSC_POCKET_SIZE, CASE WHEN ACTIVE_LL_DISABLED <> '' THEN 'TRUE' ELSE 'FALSE' END AS \"LL_DISABLED\" " +
|
||||
" FROM REACTOR " +
|
||||
" WHERE REACT_ASSIGNMENT IS NOT NULL " +
|
||||
" AND REACT_ASSIGNMENT <> 'Out of Service' " +
|
||||
" AND REACT_ASSIGNMENT<> ''";
|
||||
|
||||
cmd.CommandText = query;
|
||||
|
||||
using (SqlDataReader reader = cmd.ExecuteReader())
|
||||
{
|
||||
while (reader.Read())
|
||||
reactors.Add(new Reactor
|
||||
{
|
||||
ReactorNumber = int.Parse(reader[0].ToString()),
|
||||
Type = reader[1].ToString(),
|
||||
PocketSize = reader[2].ToString(),
|
||||
HasDisabledLoadlock = bool.Parse(reader[3].ToString())
|
||||
});
|
||||
}
|
||||
|
||||
cmd.Dispose();
|
||||
|
||||
CloseConnection();
|
||||
|
||||
return reactors;
|
||||
}
|
||||
|
||||
public List<RDS> GetRDSForLastDay(string date)
|
||||
{
|
||||
List<RDS> rdsList = new();
|
||||
|
||||
OpenConnection();
|
||||
|
||||
SqlCommand cmd = _connection.CreateCommand();
|
||||
|
||||
string query = "SELECT rds.REACTOR, rds.REACTOR_TYPE, rds.DATE_OUT, " +
|
||||
"CASE WHEN lay.UL_TEMP IS NULL THEN '1000' ELSE lay.UL_TEMP END, psn.LAYER_TYPE FROM RDS " +
|
||||
"INNER JOIN RDS_LAYER lay ON lay.RDS_NO = SEQ " +
|
||||
"INNER JOIN PROD_SPEC psn ON rds.PROD_SPEC_ID = psn.SEQ " +
|
||||
"WHERE DATE_OUT >= @date";
|
||||
|
||||
cmd.CommandText = query;
|
||||
_ = cmd.Parameters.AddWithValue("@date", date);
|
||||
|
||||
using (SqlDataReader reader = cmd.ExecuteReader())
|
||||
{
|
||||
while (reader.Read())
|
||||
rdsList.Add(new RDS
|
||||
{
|
||||
Reactor = int.Parse(reader[0].ToString()),
|
||||
ReactorType = reader[1].ToString(),
|
||||
DateOut = DateTime.Parse(reader[2].ToString()),
|
||||
UnloadTemp = int.Parse(reader[3].ToString()),
|
||||
LayerType = reader[4].ToString()
|
||||
});
|
||||
}
|
||||
|
||||
cmd.Dispose();
|
||||
|
||||
CloseConnection();
|
||||
|
||||
return rdsList;
|
||||
}
|
||||
|
||||
public List<ReactorOutsByRDS> GetRDSRunBetweenDates(string startDate, string endDate)
|
||||
{
|
||||
List<ReactorOutsByRDS> outs = new();
|
||||
|
||||
OpenConnection();
|
||||
|
||||
SqlCommand cmd = _connection.CreateCommand();
|
||||
|
||||
string query = "SELECT SEQ, WFRS_OUT, DATE_OUT " +
|
||||
" FROM RDS " +
|
||||
" WHERE DATE_OUT >= @startDate " +
|
||||
" AND DATE_OUT < @endDate " +
|
||||
"ORDER BY DATE_OUT ASC";
|
||||
|
||||
cmd.CommandText = query;
|
||||
_ = cmd.Parameters.AddWithValue("@startDate", startDate);
|
||||
_ = cmd.Parameters.AddWithValue("@endDate", endDate);
|
||||
|
||||
using (SqlDataReader reader = cmd.ExecuteReader())
|
||||
{
|
||||
while (reader.Read())
|
||||
outs.Add(new ReactorOutsByRDS
|
||||
{
|
||||
RDS_NO = reader[0].ToString(),
|
||||
Units = reader[1].ToString(),
|
||||
EndProcessTime = reader[2].ToString()
|
||||
});
|
||||
}
|
||||
|
||||
cmd.Dispose();
|
||||
|
||||
CloseConnection();
|
||||
|
||||
return outs;
|
||||
}
|
||||
|
||||
public List<ReactorEvent> GetReactorEvents(string startDate, string endDate, string reactorNumber)
|
||||
{
|
||||
List<ReactorEvent> events = new();
|
||||
|
||||
OpenConnection();
|
||||
|
||||
SqlCommand cmd = _connection.CreateCommand();
|
||||
|
||||
string query = "SELECT " +
|
||||
" REACT_NO, " +
|
||||
" EVENT_DTM, " +
|
||||
" COMMENT, " +
|
||||
" REACT_MODE " +
|
||||
" FROM REACT_EVENT " +
|
||||
" WHERE EVENT_DTM > @startDate " +
|
||||
" AND EVENT_DTM < @endDate " +
|
||||
" AND REACT_NO = @reactorNumber " +
|
||||
"UNION ALL " +
|
||||
"SELECT " +
|
||||
" REACT_NO, " +
|
||||
" EVENT_DTM, " +
|
||||
" COMMENT, " +
|
||||
" REACT_MODE " +
|
||||
" FROM " +
|
||||
" (SELECT TOP 1 * FROM REACT_EVENT " +
|
||||
" WHERE EVENT_DTM < @startDate " +
|
||||
" AND REACT_NO = @reactorNumber ORDER BY EVENT_DTM DESC) AS tbl1 " +
|
||||
"ORDER BY EVENT_DTM ASC";
|
||||
|
||||
cmd.CommandText = query;
|
||||
_ = cmd.Parameters.AddWithValue("@startDate", startDate);
|
||||
_ = cmd.Parameters.AddWithValue("@endDate", endDate);
|
||||
_ = cmd.Parameters.AddWithValue("@reactorNumber", reactorNumber);
|
||||
|
||||
using (SqlDataReader reader = cmd.ExecuteReader())
|
||||
{
|
||||
while (reader.Read())
|
||||
events.Add(new ReactorEvent
|
||||
{
|
||||
REACT_NO = reader[0].ToString(),
|
||||
EVENT_DTM = reader[1].ToString(),
|
||||
COMMENT = reader[2].ToString(),
|
||||
REACT_MODE = reader[3].ToString()
|
||||
});
|
||||
}
|
||||
|
||||
cmd.Dispose();
|
||||
|
||||
CloseConnection();
|
||||
|
||||
return events;
|
||||
}
|
||||
|
||||
public ToolEvent GetLatestToolEvent(string toolID)
|
||||
{
|
||||
ToolEvent evnt = new();
|
||||
|
||||
OpenConnection();
|
||||
|
||||
SqlCommand cmd = _connection.CreateCommand();
|
||||
|
||||
string query = "SELECT TOP 1 " +
|
||||
" TOOL_ID, " +
|
||||
" START_DTM, " +
|
||||
" TOOL_MODE, " +
|
||||
" TOOL_MODE_DESC " +
|
||||
" FROM TOOL_LOG " +
|
||||
" WHERE TOOL_ID = @toolID " +
|
||||
"ORDER BY START_DTM DESC";
|
||||
|
||||
cmd.CommandText = query;
|
||||
_ = cmd.Parameters.AddWithValue("@toolID", toolID);
|
||||
|
||||
using (SqlDataReader reader = cmd.ExecuteReader())
|
||||
{
|
||||
while (reader.Read())
|
||||
evnt = new ToolEvent
|
||||
{
|
||||
TOOL_ID = reader[0].ToString(),
|
||||
START_DTM = reader[1].ToString(),
|
||||
TOOL_MODE = reader[2].ToString(),
|
||||
TOOL_MODE_DESC = reader[3].ToString()
|
||||
};
|
||||
}
|
||||
|
||||
cmd.Dispose();
|
||||
|
||||
CloseConnection();
|
||||
|
||||
return evnt;
|
||||
}
|
||||
|
||||
public int GetLastUpTransaction(string reactorNumber)
|
||||
{
|
||||
int lastTransaction = 0;
|
||||
|
||||
OpenConnection();
|
||||
|
||||
SqlCommand cmd = _connection.CreateCommand();
|
||||
|
||||
string query = "SELECT TOP 1 DATEDIFF(MINUTE,START_DTM,SYSDATETIME()) " +
|
||||
" FROM REACT_MODE " +
|
||||
" WHERE REACT_NO = @reactorNumber " +
|
||||
" AND (MODE = 'UP' OR MODE = 'UP_WITH_INCREASED_SAMPLING') " +
|
||||
"ORDER BY START_DTM DESC";
|
||||
|
||||
cmd.CommandText = query;
|
||||
_ = cmd.Parameters.AddWithValue("@reactorNumber", reactorNumber);
|
||||
|
||||
using (SqlDataReader reader = cmd.ExecuteReader())
|
||||
{
|
||||
while (reader.Read())
|
||||
lastTransaction = int.Parse(reader[0].ToString());
|
||||
}
|
||||
|
||||
cmd.Dispose();
|
||||
|
||||
CloseConnection();
|
||||
|
||||
return lastTransaction;
|
||||
}
|
||||
|
||||
public OutsAndScrapTotal GetOutsAndScrapTotals(string startDate, string endDate)
|
||||
{
|
||||
OutsAndScrapTotal totals = new();
|
||||
|
||||
OpenConnection();
|
||||
|
||||
SqlCommand cmd = _connection.CreateCommand();
|
||||
|
||||
string query = "SELECT SUM(WFRS_OUT) AS OUTS, " +
|
||||
" SUM(CUST_TOT_REJ) AS CUST, " +
|
||||
" SUM(LSL_TOT_REJ) AS MANU, " +
|
||||
" SUM(TW_PROD) AS PROD " +
|
||||
" FROM RDS " +
|
||||
" WHERE DATE_OUT >= @startDate " +
|
||||
" AND DATE_OUT <= @endDate";
|
||||
|
||||
cmd.CommandText = query;
|
||||
_ = cmd.Parameters.AddWithValue("@startDate", startDate);
|
||||
_ = cmd.Parameters.AddWithValue("@endDate", endDate);
|
||||
|
||||
using (SqlDataReader reader = cmd.ExecuteReader())
|
||||
{
|
||||
while (reader.Read())
|
||||
totals = new()
|
||||
{
|
||||
Outs = int.Parse(reader[0].ToString()),
|
||||
CustomerScrap = int.Parse(reader[1].ToString()),
|
||||
ManufacturingScrap = int.Parse(reader[2].ToString()),
|
||||
ProductionScrap = int.Parse(reader[3].ToString()),
|
||||
};
|
||||
}
|
||||
|
||||
cmd.Dispose();
|
||||
|
||||
CloseConnection();
|
||||
|
||||
return totals;
|
||||
}
|
||||
|
||||
public DateTime GetQuarterStartDate()
|
||||
{
|
||||
DateTime date = new();
|
||||
|
||||
OpenConnection();
|
||||
|
||||
SqlCommand cmd = _connection.CreateCommand();
|
||||
|
||||
string query = "SELECT START_DT " +
|
||||
" FROM FISCAL_QTR " +
|
||||
" WHERE START_DT < SYSDATETIME() " +
|
||||
" AND END_DT > SYSDATETIME()";
|
||||
|
||||
cmd.CommandText = query;
|
||||
|
||||
using (SqlDataReader reader = cmd.ExecuteReader())
|
||||
{
|
||||
while (reader.Read())
|
||||
date = DateTime.Parse(reader[0].ToString());
|
||||
}
|
||||
|
||||
cmd.Dispose();
|
||||
|
||||
CloseConnection();
|
||||
|
||||
return date;
|
||||
}
|
||||
}
|
@ -1,23 +1,22 @@
|
||||
using ReportingServices.Shared.Models.PlanningReport;
|
||||
using ReportingServices.Shared.Models.ProductionReport;
|
||||
|
||||
namespace ReportingServices.Shared.Repositories
|
||||
namespace ReportingServices.Shared.Repositories;
|
||||
|
||||
public interface IScrapeDatabaseRepository
|
||||
{
|
||||
public interface IScrapeDatabaseRepository
|
||||
{
|
||||
public void OpenConnection();
|
||||
public void CloseConnection();
|
||||
public List<ScrapByDay> GetScrapByDay(List<ReactorOutsByRDS> outs);
|
||||
public List<ReactorPSNWORuns> GetReactorPSNWORuns(string startDate, string endDate);
|
||||
public int GetNumberOfPartChanges(string startDate, string endDate);
|
||||
public QuarterlyTargets GetQuarterlyTargets();
|
||||
public List<Reactor> GetReactors();
|
||||
public List<RDS> GetRDSForLastDay(string date);
|
||||
public List<ReactorOutsByRDS> GetRDSRunBetweenDates(string startDate, string endDate);
|
||||
public List<ReactorEvent> GetReactorEvents(string startDate, string endDate, string reactorNumber);
|
||||
public ToolEvent GetLatestToolEvent(string toolID);
|
||||
public int GetLastUpTransaction(string reactorNumber);
|
||||
public OutsAndScrapTotal GetOutsAndScrapTotals(string startDate, string endDate);
|
||||
public DateTime GetQuarterStartDate();
|
||||
}
|
||||
}
|
||||
public void OpenConnection();
|
||||
public void CloseConnection();
|
||||
public List<ScrapByDay> GetScrapByDay(List<ReactorOutsByRDS> outs);
|
||||
public List<ReactorPSNWORuns> GetReactorPSNWORuns(string startDate, string endDate);
|
||||
public int GetNumberOfPartChanges(string startDate, string endDate);
|
||||
public QuarterlyTargets GetQuarterlyTargets();
|
||||
public List<Reactor> GetReactors();
|
||||
public List<RDS> GetRDSForLastDay(string date);
|
||||
public List<ReactorOutsByRDS> GetRDSRunBetweenDates(string startDate, string endDate);
|
||||
public List<ReactorEvent> GetReactorEvents(string startDate, string endDate, string reactorNumber);
|
||||
public ToolEvent GetLatestToolEvent(string toolID);
|
||||
public int GetLastUpTransaction(string reactorNumber);
|
||||
public OutsAndScrapTotal GetOutsAndScrapTotals(string startDate, string endDate);
|
||||
public DateTime GetQuarterStartDate();
|
||||
}
|
@ -1,131 +1,130 @@
|
||||
using ReportingServices.Shared.HelperClasses;
|
||||
using ReportingServices.Shared.Models.ProductionReport;
|
||||
|
||||
namespace ReportingServices.Shared.ViewModels.ProductionReport
|
||||
namespace ReportingServices.Shared.ViewModels.ProductionReport;
|
||||
|
||||
public class DailyReport
|
||||
{
|
||||
public class DailyReport
|
||||
public DateTime StartDate { get; set; }
|
||||
public DateTime QuarterStartDate { get; set; }
|
||||
public YieldStatistics CurrentWeek { get; set; }
|
||||
public YieldStatistics PreviousWeek { get; set; }
|
||||
public List<ToolEventView> ToolEvents { 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; }
|
||||
public List<UnloadTempsByDay> UnloadTempsByDay { get; set; }
|
||||
public List<SLLTool> SLLTools { get; set; }
|
||||
public int NumberOfToolsWaferSize6IN { get; set; }
|
||||
public int NumberOfToolsWaferSize8IN { get; set; }
|
||||
public int NumberOfToolsWaferSize6INScheduled { get; set; }
|
||||
public int NumberOfToolsWaferSize8INScheduled { get; set; }
|
||||
public QuarterlyTargets QuarterlyTargets { get; set; }
|
||||
|
||||
public DailyReport()
|
||||
{
|
||||
public DateTime StartDate { get; set; }
|
||||
public DateTime QuarterStartDate { get; set; }
|
||||
public YieldStatistics CurrentWeek { get; set; }
|
||||
public YieldStatistics PreviousWeek { get; set; }
|
||||
public List<ToolEventView> ToolEvents { 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; }
|
||||
public List<UnloadTempsByDay> UnloadTempsByDay { get; set; }
|
||||
public List<SLLTool> SLLTools { get; set; }
|
||||
public int NumberOfToolsWaferSize6IN { get; set; }
|
||||
public int NumberOfToolsWaferSize8IN { get; set; }
|
||||
public int NumberOfToolsWaferSize6INScheduled { get; set; }
|
||||
public int NumberOfToolsWaferSize8INScheduled { get; set; }
|
||||
public QuarterlyTargets QuarterlyTargets { get; set; }
|
||||
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);
|
||||
}
|
||||
|
||||
public DailyReport()
|
||||
public void SetReactorInfo(List<Reactor> reactors, List<int> unscheduledReactors)
|
||||
{
|
||||
SetToolsByPocketSize(reactors, unscheduledReactors);
|
||||
SetDisabledLoadlocks(reactors);
|
||||
}
|
||||
|
||||
public void SetRDSInfo(List<RDS> rdsList)
|
||||
{
|
||||
SetDualLayerReactors(rdsList);
|
||||
SetUnloadTempsLessThan700(rdsList);
|
||||
}
|
||||
|
||||
private void SetToolsByPocketSize(List<Reactor> reactors, List<int> unscheduledReactors)
|
||||
{
|
||||
NumberOfToolsWaferSize6IN = reactors.Where(react => react.PocketSize.Contains("150")).Count();
|
||||
NumberOfToolsWaferSize8IN = reactors.Where(react => react.PocketSize.Contains("200")).Count();
|
||||
|
||||
NumberOfToolsWaferSize6INScheduled =
|
||||
reactors.Where(react => !unscheduledReactors.Contains(react.ReactorNumber)
|
||||
&& react.PocketSize.Contains("150")).Count();
|
||||
NumberOfToolsWaferSize8INScheduled =
|
||||
reactors.Where(react => !unscheduledReactors.Contains(react.ReactorNumber)
|
||||
&& react.PocketSize.Contains("200")).Count();
|
||||
}
|
||||
|
||||
private void SetDisabledLoadlocks(List<Reactor> reactors)
|
||||
{
|
||||
List<Reactor> reactorsWithDisabledLoadlocks = reactors.Where(react => react.HasDisabledLoadlock).ToList();
|
||||
|
||||
int singleLoadlockASM = reactorsWithDisabledLoadlocks.Where(react => react.Type.Contains("ASM")).Count();
|
||||
int singleLoadlockHTR = reactorsWithDisabledLoadlocks.Where(react => react.Type.Contains("HTR")).Count();
|
||||
|
||||
foreach (SLLTool sll in SLLTools)
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
public void SetReactorInfo(List<Reactor> reactors, List<int> unscheduledReactors)
|
||||
{
|
||||
SetToolsByPocketSize(reactors, unscheduledReactors);
|
||||
SetDisabledLoadlocks(reactors);
|
||||
}
|
||||
|
||||
public void SetRDSInfo(List<RDS> rdsList)
|
||||
{
|
||||
SetDualLayerReactors(rdsList);
|
||||
SetUnloadTempsLessThan700(rdsList);
|
||||
}
|
||||
|
||||
private void SetToolsByPocketSize(List<Reactor> reactors, List<int> unscheduledReactors)
|
||||
{
|
||||
NumberOfToolsWaferSize6IN = reactors.Where(react => react.PocketSize.Contains("150")).Count();
|
||||
NumberOfToolsWaferSize8IN = reactors.Where(react => react.PocketSize.Contains("200")).Count();
|
||||
|
||||
NumberOfToolsWaferSize6INScheduled =
|
||||
reactors.Where(react => !unscheduledReactors.Contains(react.ReactorNumber)
|
||||
&& react.PocketSize.Contains("150")).Count();
|
||||
NumberOfToolsWaferSize8INScheduled =
|
||||
reactors.Where(react => !unscheduledReactors.Contains(react.ReactorNumber)
|
||||
&& react.PocketSize.Contains("200")).Count();
|
||||
}
|
||||
|
||||
private void SetDisabledLoadlocks(List<Reactor> reactors)
|
||||
{
|
||||
List<Reactor> reactorsWithDisabledLoadlocks = reactors.Where(react => react.HasDisabledLoadlock).ToList();
|
||||
|
||||
int singleLoadlockASM = reactorsWithDisabledLoadlocks.Where(react => react.Type.Contains("ASM")).Count();
|
||||
int singleLoadlockHTR = reactorsWithDisabledLoadlocks.Where(react => react.Type.Contains("HTR")).Count();
|
||||
|
||||
foreach (SLLTool sll in SLLTools)
|
||||
if (sll.Date.Date == DateTime.Now.Date)
|
||||
{
|
||||
if (sll.Date.Date == DateTime.Now.Date)
|
||||
{
|
||||
sll.ASM = singleLoadlockASM;
|
||||
sll.HTR = singleLoadlockHTR;
|
||||
return;
|
||||
}
|
||||
sll.ASM = singleLoadlockASM;
|
||||
sll.HTR = singleLoadlockHTR;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
SLLTools.Add(new SLLTool
|
||||
SLLTools.Add(new SLLTool
|
||||
{
|
||||
Date = DateTime.Now.Date,
|
||||
ASM = singleLoadlockASM,
|
||||
HTR = singleLoadlockHTR
|
||||
});
|
||||
}
|
||||
|
||||
private void SetDualLayerReactors(List<RDS> rdsList)
|
||||
{
|
||||
DateTime compareDate = DateTime.Now.Date;
|
||||
List<RDS> rdsWithDualLayerPSN = rdsList.Where(rds => rds.LayerType.Contains("2 Layer") && rds.DateOut == compareDate).ToList();
|
||||
|
||||
DualLayerReactors.Add("ASM", rdsWithDualLayerPSN.
|
||||
Where(rds => rds.ReactorType.Contains("ASM")).
|
||||
OrderBy(rds => rds.Reactor).
|
||||
Select(rds => rds.Reactor).
|
||||
Distinct().ToList());
|
||||
DualLayerReactors.Add("HTR", rdsWithDualLayerPSN.
|
||||
Where(rds => rds.ReactorType.Contains("HTR")).
|
||||
OrderBy(rds => rds.Reactor).
|
||||
Select(rds => rds.Reactor).
|
||||
Distinct().ToList());
|
||||
DualLayerReactors.Add("EPP", rdsWithDualLayerPSN.
|
||||
Where(rds => rds.ReactorType.Contains("EPP")).
|
||||
OrderBy(rds => rds.Reactor).
|
||||
Select(rds => rds.Reactor).
|
||||
Distinct().ToList());
|
||||
}
|
||||
|
||||
private void SetUnloadTempsLessThan700(List<RDS> rdsList)
|
||||
{
|
||||
IEnumerable<IGrouping<DateTime, RDS>> rdsWithTempsLessThan700 = rdsList.Where(rds => rds.UnloadTemp < 700).GroupBy(rds => rds.DateOut);
|
||||
|
||||
foreach (IGrouping<DateTime, RDS> group in rdsWithTempsLessThan700)
|
||||
{
|
||||
UnloadTempsByDay.Add(new UnloadTempsByDay
|
||||
{
|
||||
Date = DateTime.Now.Date,
|
||||
ASM = singleLoadlockASM,
|
||||
HTR = singleLoadlockHTR
|
||||
Date = group.Key,
|
||||
ASMUnloadsBelow700 = group.Where(rds => rds.ReactorType.Contains("ASM")).Select(rds => rds.Reactor).Distinct().Count(),
|
||||
HTRUnloadsBelow700 = group.Where(rds => rds.ReactorType.Contains("HTR")).Select(rds => rds.Reactor).Distinct().Count()
|
||||
});
|
||||
}
|
||||
|
||||
private void SetDualLayerReactors(List<RDS> rdsList)
|
||||
{
|
||||
DateTime compareDate = DateTime.Now.Date;
|
||||
List<RDS> rdsWithDualLayerPSN = rdsList.Where(rds => rds.LayerType.Contains("2 Layer") && rds.DateOut == compareDate).ToList();
|
||||
|
||||
DualLayerReactors.Add("ASM", rdsWithDualLayerPSN.
|
||||
Where(rds => rds.ReactorType.Contains("ASM")).
|
||||
OrderBy(rds => rds.Reactor).
|
||||
Select(rds => rds.Reactor).
|
||||
Distinct().ToList());
|
||||
DualLayerReactors.Add("HTR", rdsWithDualLayerPSN.
|
||||
Where(rds => rds.ReactorType.Contains("HTR")).
|
||||
OrderBy(rds => rds.Reactor).
|
||||
Select(rds => rds.Reactor).
|
||||
Distinct().ToList());
|
||||
DualLayerReactors.Add("EPP", rdsWithDualLayerPSN.
|
||||
Where(rds => rds.ReactorType.Contains("EPP")).
|
||||
OrderBy(rds => rds.Reactor).
|
||||
Select(rds => rds.Reactor).
|
||||
Distinct().ToList());
|
||||
}
|
||||
|
||||
private void SetUnloadTempsLessThan700(List<RDS> rdsList)
|
||||
{
|
||||
var rdsWithTempsLessThan700 = rdsList.Where(rds => rds.UnloadTemp < 700).GroupBy(rds => rds.DateOut);
|
||||
|
||||
foreach (var group in rdsWithTempsLessThan700)
|
||||
{
|
||||
UnloadTempsByDay.Add(new UnloadTempsByDay
|
||||
{
|
||||
Date = group.Key,
|
||||
ASMUnloadsBelow700 = group.Where(rds => rds.ReactorType.Contains("ASM")).Select(rds => rds.Reactor).Distinct().Count(),
|
||||
HTRUnloadsBelow700 = group.Where(rds => rds.ReactorType.Contains("HTR")).Select(rds => rds.Reactor).Distinct().Count()
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public void ReverseLists()
|
||||
{
|
||||
CurrentWeek.ScrapByDay = APIHelperFunctions.ReverseList(CurrentWeek.ScrapByDay);
|
||||
PreviousWeek.ScrapByDay = APIHelperFunctions.ReverseList(PreviousWeek.ScrapByDay);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void ReverseLists()
|
||||
{
|
||||
CurrentWeek.ScrapByDay = APIHelperFunctions.ReverseList(CurrentWeek.ScrapByDay);
|
||||
PreviousWeek.ScrapByDay = APIHelperFunctions.ReverseList(PreviousWeek.ScrapByDay);
|
||||
}
|
||||
}
|
@ -1,9 +1,8 @@
|
||||
namespace ReportingServices.Shared.ViewModels.ProductionReport
|
||||
namespace ReportingServices.Shared.ViewModels.ProductionReport;
|
||||
|
||||
public class SLLTool
|
||||
{
|
||||
public class SLLTool
|
||||
{
|
||||
public DateTime Date { get; set; }
|
||||
public int ASM { get; set; }
|
||||
public int HTR { get; set; }
|
||||
}
|
||||
}
|
||||
public DateTime Date { get; set; }
|
||||
public int ASM { get; set; }
|
||||
public int HTR { get; set; }
|
||||
}
|
@ -1,71 +1,93 @@
|
||||
using ReportingServices.Shared.Models.ProductionReport;
|
||||
using System.Data;
|
||||
|
||||
namespace ReportingServices.Shared.ViewModels.ProductionReport
|
||||
namespace ReportingServices.Shared.ViewModels.ProductionReport;
|
||||
|
||||
public class ToolEventView
|
||||
{
|
||||
public class ToolEventView
|
||||
public string Reactor { get; set; }
|
||||
public string Type { get; set; }
|
||||
public string StartDate { get; set; }
|
||||
public string EndDate { get; set; }
|
||||
public double Downtime { 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)
|
||||
{
|
||||
public string Reactor { get; set; }
|
||||
public string Type { get; set; }
|
||||
public string StartDate { get; set; }
|
||||
public string EndDate { get; set; }
|
||||
public double Downtime { get; set; }
|
||||
public bool IsInProduction { get; set; }
|
||||
public List<ReactorEvent> Events { get; set; }
|
||||
public ReactorEvent MostRecentEvent { get; set; }
|
||||
public List<ToolUptimeData> Uptime { get; set; }
|
||||
Events = events;
|
||||
StartDate = startDate;
|
||||
EndDate = endDate;
|
||||
Reactor = reactor;
|
||||
Type = type;
|
||||
MostRecentEvent = events[^1];
|
||||
IsInProduction = EventIsProduction(MostRecentEvent.REACT_MODE);
|
||||
Uptime = DetermineToolUptimeData();
|
||||
}
|
||||
|
||||
public ToolEventView(List<ReactorEvent> events, string startDate, string endDate, string reactor, string type)
|
||||
public void SetDowntime(int timeSinceLastUpTransaction)
|
||||
{
|
||||
if (IsInProduction)
|
||||
Downtime = 0;
|
||||
else
|
||||
Downtime = (double)timeSinceLastUpTransaction / 60;
|
||||
}
|
||||
|
||||
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++)
|
||||
{
|
||||
Events = events;
|
||||
StartDate = startDate;
|
||||
EndDate = endDate;
|
||||
Reactor = reactor;
|
||||
Type = type;
|
||||
MostRecentEvent = events[events.Count - 1];
|
||||
IsInProduction = EventIsProduction(MostRecentEvent.REACT_MODE);
|
||||
Uptime = DetermineToolUptimeData();
|
||||
}
|
||||
DateTime currentTransaction = DateTime.Parse(Events[i].EVENT_DTM);
|
||||
|
||||
public void SetDowntime(int timeSinceLastUpTransaction)
|
||||
{
|
||||
if (IsInProduction)
|
||||
Downtime = 0;
|
||||
else
|
||||
Downtime = (double)timeSinceLastUpTransaction / 60;
|
||||
}
|
||||
|
||||
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++)
|
||||
if (currentTransaction.Date == compareDate)
|
||||
{
|
||||
DateTime currentTransaction = DateTime.Parse(Events[i].EVENT_DTM);
|
||||
if (currentModeIsUp)
|
||||
uptime += (DateTime.Parse(Events[i].EVENT_DTM) - previousTransaction).TotalMinutes;
|
||||
|
||||
if (currentTransaction.Date == compareDate)
|
||||
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 += (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;
|
||||
uptime += (compareDate.AddDays(1) - previousTransaction).TotalMinutes;
|
||||
|
||||
data.Add(new ToolUptimeData
|
||||
{
|
||||
@ -73,19 +95,18 @@ namespace ReportingServices.Shared.ViewModels.ProductionReport
|
||||
UptimePercentage = uptime / 1440
|
||||
});
|
||||
|
||||
if (currentModeIsUp)
|
||||
uptime = (currentTransaction - currentTransaction.Date).TotalMinutes;
|
||||
else
|
||||
uptime = 0;
|
||||
uptime = 0;
|
||||
|
||||
compareDate = compareDate.AddDays(1);
|
||||
currentModeIsUp = EventIsProduction(Events[i].REACT_MODE);
|
||||
previousTransaction = DateTime.Parse(Events[i].EVENT_DTM);
|
||||
previousTransaction = compareDate;
|
||||
}
|
||||
|
||||
if ((currentTransaction.Date - compareDate).TotalHours > 24)
|
||||
}
|
||||
|
||||
if (i == Events.Count - 1)
|
||||
{
|
||||
if (DateTime.Parse(EndDate).Date != compareDate)
|
||||
{
|
||||
while (currentTransaction.Date != compareDate)
|
||||
while (DateTime.Parse(EndDate).Date != compareDate)
|
||||
{
|
||||
if (currentModeIsUp)
|
||||
uptime += (compareDate.AddDays(1) - previousTransaction).TotalMinutes;
|
||||
@ -103,71 +124,48 @@ namespace ReportingServices.Shared.ViewModels.ProductionReport
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
if (currentModeIsUp)
|
||||
uptime += (DateTime.Parse(EndDate) - 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
|
||||
Date = DateTime.Now.Date.ToString(),
|
||||
UptimePercentage = uptime / (DateTime.Parse(EndDate) - DateTime.Parse(EndDate).Date).TotalMinutes
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
private bool EventIsProduction(string evnt)
|
||||
{
|
||||
if (evnt.ToUpper() == "UP")
|
||||
return true;
|
||||
|
||||
if (evnt.ToUpper() == "UP_WITH_INCREASED_SAMPLING")
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
@ -1,9 +1,8 @@
|
||||
namespace ReportingServices.Shared.ViewModels.ProductionReport
|
||||
namespace ReportingServices.Shared.ViewModels.ProductionReport;
|
||||
|
||||
public class UnloadTempsByDay
|
||||
{
|
||||
public class UnloadTempsByDay
|
||||
{
|
||||
public DateTime Date { get; set; }
|
||||
public int ASMUnloadsBelow700 { get; set; }
|
||||
public int HTRUnloadsBelow700 { get; set; }
|
||||
}
|
||||
}
|
||||
public DateTime Date { get; set; }
|
||||
public int ASMUnloadsBelow700 { get; set; }
|
||||
public int HTRUnloadsBelow700 { get; set; }
|
||||
}
|
@ -1,62 +1,61 @@
|
||||
using ReportingServices.Shared.Models.ProductionReport;
|
||||
|
||||
namespace ReportingServices.Shared.ViewModels.ProductionReport
|
||||
namespace ReportingServices.Shared.ViewModels.ProductionReport;
|
||||
|
||||
public class YieldStatistics
|
||||
{
|
||||
public class YieldStatistics
|
||||
public DateTime StartDate { get; set; }
|
||||
public List<ReactorOutsByDay> OutsByDay { get; set; }
|
||||
public List<ScrapByDay> ScrapByDay { get; set; }
|
||||
public OutsAndScrapTotal QTDOutsAndScrap { get; set; }
|
||||
public int DailyPlanWafers { get; set; }
|
||||
public bool IsCurrentWeek { get; set; }
|
||||
|
||||
public YieldStatistics(DateTime startDate, bool isCurrentWeek)
|
||||
{
|
||||
public DateTime StartDate { get; set; }
|
||||
public List<ReactorOutsByDay> OutsByDay { get; set; }
|
||||
public List<ScrapByDay> ScrapByDay { get; set; }
|
||||
public OutsAndScrapTotal QTDOutsAndScrap { get; set; }
|
||||
public int DailyPlanWafers { get; set; }
|
||||
public bool IsCurrentWeek { get; set; }
|
||||
StartDate = startDate;
|
||||
IsCurrentWeek = isCurrentWeek;
|
||||
}
|
||||
|
||||
public YieldStatistics(DateTime startDate, bool isCurrentWeek)
|
||||
public void SetYieldInformation(YieldInformation yieldInformation, QuarterlyTargets targets)
|
||||
{
|
||||
OutsByDay = GetReactorOutsByDay(yieldInformation.Outs);
|
||||
ScrapByDay = yieldInformation.Scrap;
|
||||
DailyPlanWafers = targets.Yield_Outs / targets.PlanWorkingDays;
|
||||
}
|
||||
|
||||
public static List<string> GetDistinctDatesFromReactorOuts(List<ReactorOutsByRDS> outs)
|
||||
{
|
||||
List<string> dates = new();
|
||||
|
||||
foreach (ReactorOutsByRDS rout in outs)
|
||||
{
|
||||
StartDate = startDate;
|
||||
IsCurrentWeek = isCurrentWeek;
|
||||
if (!dates.Contains(DateTime.Parse(rout.EndProcessTime).Date.ToString()))
|
||||
dates.Add(DateTime.Parse(rout.EndProcessTime).Date.ToString());
|
||||
}
|
||||
|
||||
public void SetYieldInformation(YieldInformation yieldInformation, QuarterlyTargets targets)
|
||||
{
|
||||
OutsByDay = GetReactorOutsByDay(yieldInformation.Outs);
|
||||
ScrapByDay = yieldInformation.Scrap;
|
||||
DailyPlanWafers = targets.Yield_Outs / targets.PlanWorkingDays;
|
||||
}
|
||||
return dates;
|
||||
}
|
||||
|
||||
public static List<string> GetDistinctDatesFromReactorOuts(List<ReactorOutsByRDS> outs)
|
||||
public static List<ReactorOutsByDay> GetReactorOutsByDay(List<ReactorOutsByRDS> outs)
|
||||
{
|
||||
List<ReactorOutsByDay> outsByDay = new();
|
||||
|
||||
List<string> dates = GetDistinctDatesFromReactorOuts(outs);
|
||||
|
||||
foreach (string date in dates)
|
||||
{
|
||||
List<string> dates = new();
|
||||
int waferCount = 0;
|
||||
|
||||
foreach (ReactorOutsByRDS rout in outs)
|
||||
{
|
||||
if (!dates.Contains(DateTime.Parse(rout.EndProcessTime).Date.ToString()))
|
||||
dates.Add(DateTime.Parse(rout.EndProcessTime).Date.ToString());
|
||||
if (DateTime.Parse(rout.EndProcessTime).Date.ToString() == date)
|
||||
waferCount += (int)float.Parse(rout.Units);
|
||||
}
|
||||
|
||||
return dates;
|
||||
outsByDay.Add(new ReactorOutsByDay { StartDate = date, TotalWafers = waferCount });
|
||||
}
|
||||
|
||||
public static List<ReactorOutsByDay> GetReactorOutsByDay(List<ReactorOutsByRDS> outs)
|
||||
{
|
||||
List<ReactorOutsByDay> outsByDay = new();
|
||||
|
||||
List<string> dates = GetDistinctDatesFromReactorOuts(outs);
|
||||
|
||||
foreach (string date in dates)
|
||||
{
|
||||
int waferCount = 0;
|
||||
|
||||
foreach (ReactorOutsByRDS rout in outs)
|
||||
{
|
||||
if (DateTime.Parse(rout.EndProcessTime).Date.ToString() == date)
|
||||
waferCount += (int)float.Parse(rout.Units);
|
||||
}
|
||||
|
||||
outsByDay.Add(new ReactorOutsByDay { StartDate = date, TotalWafers = waferCount });
|
||||
}
|
||||
|
||||
return outsByDay;
|
||||
}
|
||||
return outsByDay;
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user