Added backend API project to segregate responsibilites - Data is now handled in API project and business is all handled in UI project.
This commit is contained in:
22
ReportingServices.Shared/HelperClasses/ApiCaller.cs
Normal file
22
ReportingServices.Shared/HelperClasses/ApiCaller.cs
Normal file
@ -0,0 +1,22 @@
|
||||
using ReportingServices.Shared.Models.ProductionReport;
|
||||
using System.Net.Http.Json;
|
||||
using System.Text.Json;
|
||||
|
||||
namespace ReportingServices.Shared.HelperClasses
|
||||
{
|
||||
public static class ApiCaller
|
||||
{
|
||||
public static async Task<T> GetApi<T>(string url)
|
||||
{
|
||||
T deserializedJson;
|
||||
|
||||
using (HttpClient client = new())
|
||||
{
|
||||
string apiResponse = await client.GetStringAsync(url);
|
||||
deserializedJson = JsonSerializer.Deserialize<T>(apiResponse);
|
||||
}
|
||||
|
||||
return deserializedJson;
|
||||
}
|
||||
}
|
||||
}
|
@ -9,6 +9,7 @@ namespace ReportingServices.Shared.HelperClasses
|
||||
private static IFabTimeReportingRepository _fabTimeReportingRepository;
|
||||
private static IScrapeDatabaseRepository _scrapeDatabaseRepository;
|
||||
private static readonly string _dailyRptFilePath = "wwwroot/Assets/DailyReportInfo.json";
|
||||
private static readonly string _baseUrlFabtime = "https://localhost:7196/api/FabTime/";
|
||||
|
||||
public static void SetRepositories(IFabTimeReportingRepository fabTimeReportingRepository, IScrapeDatabaseRepository scrapeDatabaseRepository)
|
||||
{
|
||||
@ -16,21 +17,23 @@ namespace ReportingServices.Shared.HelperClasses
|
||||
_scrapeDatabaseRepository = scrapeDatabaseRepository;
|
||||
}
|
||||
|
||||
public static DailyReport SetUpDailyReport()
|
||||
public async static Task<DailyReport> SetUpDailyReport()
|
||||
{
|
||||
List<Task> tasks = new();
|
||||
List<Task<List<EquipmentStateByDay>>> tasksEQState = new();
|
||||
List<Task<List<ToolStateCurrent>>> tasksState = new();
|
||||
DailyReport report = new();
|
||||
|
||||
Task<List<ReactorOutsByRDS>> task1 = _fabTimeReportingRepository.GetMovesTrendData();
|
||||
Task<List<ReactorOutsByRDS>> task2 = _fabTimeReportingRepository.GetMovesTrendData(startDate: report.StartDate.AddDays(-7).ToString(), endDate: report.StartDate.ToString());
|
||||
tasks.Add(_fabTimeReportingRepository.GetToolStateTrendData(report, "ASM"));
|
||||
tasks.Add(_fabTimeReportingRepository.GetToolStateTrendData(report, "EPP"));
|
||||
tasks.Add(_fabTimeReportingRepository.GetToolStateTrendData(report, "HTR"));
|
||||
tasks.Add(_fabTimeReportingRepository.GetToolStateData(report, "ASM"));
|
||||
tasks.Add(_fabTimeReportingRepository.GetToolStateData(report, "EPP"));
|
||||
tasks.Add(_fabTimeReportingRepository.GetToolStateData(report, "HTR"));
|
||||
tasks.Add(_fabTimeReportingRepository.GetToolStateData(report, "Metrology"));
|
||||
tasks.Add(_fabTimeReportingRepository.GetToolStateData(report, "Cleans"));
|
||||
Task<YieldInformation> task1 = ApiCaller.GetApi<YieldInformation>(_baseUrlFabtime + "ReactorOuts?startDate=" + report.StartDate.ToString() + "&endDate=" + DateTime.Now.ToString());
|
||||
Task<YieldInformation> task2 = ApiCaller.GetApi<YieldInformation>(_baseUrlFabtime + "ReactorOuts?startDate=" + report.StartDate.AddDays(-7).ToString() + "&endDate=" + report.StartDate.ToString());
|
||||
|
||||
tasksEQState.Add(ApiCaller.GetApi<List<EquipmentStateByDay>>(_baseUrlFabtime + "ToolStateTrend?toolType=ASM"));
|
||||
tasksEQState.Add(ApiCaller.GetApi<List<EquipmentStateByDay>>(_baseUrlFabtime + "ToolStateTrend?toolType=EPP"));
|
||||
tasksEQState.Add(ApiCaller.GetApi<List<EquipmentStateByDay>>(_baseUrlFabtime + "ToolStateTrend?toolType=HTR"));
|
||||
tasksState.Add(ApiCaller.GetApi<List<ToolStateCurrent>>(_baseUrlFabtime + "ToolState?toolType=ASM"));
|
||||
tasksState.Add(ApiCaller.GetApi<List<ToolStateCurrent>>(_baseUrlFabtime + "ToolState?toolType=EPP"));
|
||||
tasksState.Add(ApiCaller.GetApi<List<ToolStateCurrent>>(_baseUrlFabtime + "ToolState?toolType=HTR"));
|
||||
tasksState.Add(ApiCaller.GetApi<List<ToolStateCurrent>>(_baseUrlFabtime + "ToolState?toolType=Metrology"));
|
||||
tasksState.Add(ApiCaller.GetApi<List<ToolStateCurrent>>(_baseUrlFabtime + "ToolState?toolType=Cleans"));
|
||||
|
||||
report.QuarterlyTargets = _scrapeDatabaseRepository.GetQuarterlyTargets();
|
||||
|
||||
@ -41,15 +44,20 @@ namespace ReportingServices.Shared.HelperClasses
|
||||
|
||||
report.SetRDSInfo(_scrapeDatabaseRepository.GetRDSForLastDay());
|
||||
|
||||
Task.WaitAll(tasks.ToArray());
|
||||
report.AddToolAvailibilityByType("ASM", tasksEQState[0].Result);
|
||||
report.AddToolAvailibilityByType("EPP", tasksEQState[1].Result);
|
||||
report.AddToolAvailibilityByType("HTR", tasksEQState[2].Result);
|
||||
|
||||
report.AddToolStateByType("ASM", tasksState[0].Result);
|
||||
report.AddToolStateByType("EPP", tasksState[1].Result);
|
||||
report.AddToolStateByType("HTR", tasksState[2].Result);
|
||||
report.AddToolStateByType("Metrology", tasksState[3].Result);
|
||||
report.AddToolStateByType("Cleans", tasksState[4].Result);
|
||||
|
||||
report.SetReactorInfo(_scrapeDatabaseRepository.GetReactors(), GetUnscheduledReactors(report));
|
||||
|
||||
List<ScrapByDay> scrap = _scrapeDatabaseRepository.GetScrapByDay(task1.Result);
|
||||
List<ScrapByDay> previousScrap = _scrapeDatabaseRepository.GetScrapByDay(task2.Result);
|
||||
|
||||
report.CurrentWeek.SetYieldInformation(task1.Result, scrap);
|
||||
report.PreviousWeek.SetYieldInformation(task2.Result, previousScrap);
|
||||
report.CurrentWeek.SetYieldInformation(task1.Result);
|
||||
report.PreviousWeek.SetYieldInformation(task2.Result);
|
||||
|
||||
report.ReverseLists();
|
||||
|
@ -1,9 +1,14 @@
|
||||
namespace ReportingServices.Shared.Models.PlanningReport
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace ReportingServices.Shared.Models.PlanningReport
|
||||
{
|
||||
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; }
|
||||
}
|
||||
}
|
||||
|
@ -1,8 +1,12 @@
|
||||
namespace ReportingServices.Shared.Models.ProductionReport
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace ReportingServices.Shared.Models.ProductionReport
|
||||
{
|
||||
public class EquipmentStateByDay
|
||||
{
|
||||
[JsonPropertyName("StartTime")]
|
||||
public string StartTime { get; set; }
|
||||
[JsonPropertyName("AvailablePct")]
|
||||
public string AvailablePct { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -1,10 +1,16 @@
|
||||
namespace ReportingServices.Shared.Models.ProductionReport
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace ReportingServices.Shared.Models.ProductionReport
|
||||
{
|
||||
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; }
|
||||
}
|
||||
}
|
||||
|
@ -1,11 +1,18 @@
|
||||
namespace ReportingServices.Shared.Models.ProductionReport
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace ReportingServices.Shared.Models.ProductionReport
|
||||
{
|
||||
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; }
|
||||
}
|
||||
}
|
||||
|
@ -1,10 +1,16 @@
|
||||
namespace ReportingServices.Shared.Models.ProductionReport
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace ReportingServices.Shared.Models.ProductionReport
|
||||
{
|
||||
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; }
|
||||
}
|
||||
}
|
||||
|
@ -1,9 +1,14 @@
|
||||
namespace ReportingServices.Shared.Models.ProductionReport
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace ReportingServices.Shared.Models.ProductionReport
|
||||
{
|
||||
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; }
|
||||
}
|
||||
}
|
||||
|
@ -1,11 +1,18 @@
|
||||
namespace ReportingServices.Shared.Models.ProductionReport
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace ReportingServices.Shared.Models.ProductionReport
|
||||
{
|
||||
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; }
|
||||
}
|
||||
}
|
||||
|
@ -1,14 +1,24 @@
|
||||
namespace ReportingServices.Shared.Models.ProductionReport
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace ReportingServices.Shared.Models.ProductionReport
|
||||
{
|
||||
public class ToolStateCurrent
|
||||
{
|
||||
[JsonPropertyName("Tool")]
|
||||
public string Tool { get; set; }
|
||||
[JsonPropertyName("TranTime")]
|
||||
public string TranTime { get; set; }
|
||||
[JsonPropertyName("GanttEndTime")]
|
||||
public string GanttEndTime { get; set; }
|
||||
[JsonPropertyName("GanttElapsedHours")]
|
||||
public string GanttElapsedHours { get; set; }
|
||||
[JsonPropertyName("BasicStateDescription")]
|
||||
public string BasicStateDescription { get; set; }
|
||||
[JsonPropertyName("SubState")]
|
||||
public string SubState { get; set; }
|
||||
[JsonPropertyName("ReactorStatus")]
|
||||
public string ReactorStatus { get; set; }
|
||||
[JsonPropertyName("Comment")]
|
||||
public string Comment { get; set; }
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.Json.Serialization;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ReportingServices.Shared.Models.ProductionReport
|
||||
{
|
||||
public class YieldInformation
|
||||
{
|
||||
[JsonPropertyName("Outs")]
|
||||
public List<ReactorOutsByRDS> Outs { get; set; }
|
||||
[JsonPropertyName("Scrap")]
|
||||
public List<ScrapByDay> Scrap { get; set; }
|
||||
}
|
||||
}
|
@ -17,16 +17,14 @@ namespace ReportingServices.Shared.Repositories
|
||||
return await GetJsonData<List<ReactorOutsByRDS>>(url);
|
||||
}
|
||||
|
||||
public async Task GetToolStateTrendData(DailyReport rpt, string toolType)
|
||||
public async Task<List<EquipmentStateByDay>> GetToolStateTrendData(string toolType)
|
||||
{
|
||||
string url = APIHelperFunctions.GenerateURLWithParameters(chart: "TOOLSTATE", periodLen: "24", capacityTypesLike: toolType, toolsLike: _toolFilter);
|
||||
|
||||
rpt.AddToolAvailibilityByType(toolType, await GetJsonData<List<EquipmentStateByDay>>(url));
|
||||
|
||||
return;
|
||||
return await GetJsonData<List<EquipmentStateByDay>>(url);
|
||||
}
|
||||
|
||||
public async Task GetToolStateData(DailyReport rpt, string toolType)
|
||||
public async Task<List<ToolStateCurrent>> GetToolStateData(string toolType)
|
||||
{
|
||||
string capacityFilter = toolType == "ASM" ? toolType + "%2CASM%2B" : toolType;
|
||||
string startDate = HttpUtility.UrlEncode(APIHelperFunctions.GetDateWithOffsetAsAPIString(DateTime.Now.ToString(), -12.5f));
|
||||
@ -34,9 +32,7 @@ namespace ReportingServices.Shared.Repositories
|
||||
string url = APIHelperFunctions.GenerateURLWithParameters(chart: "ToolStateGantt", periodLen: "24",
|
||||
capacityTypesLike: capacityFilter, toolsLike: _toolFilter, startDate: startDate);
|
||||
|
||||
rpt.AddToolStateByType(toolType, await GetJsonData<List<ToolStateCurrent>>(url));
|
||||
|
||||
return;
|
||||
return await GetJsonData<List<ToolStateCurrent>>(url);
|
||||
}
|
||||
|
||||
public async Task<T> GetJsonData<T>(string url)
|
||||
|
@ -6,8 +6,8 @@ namespace ReportingServices.Shared.Repositories
|
||||
public interface IFabTimeReportingRepository
|
||||
{
|
||||
public Task<List<ReactorOutsByRDS>> GetMovesTrendData(string startDate = "", string endDate = "");
|
||||
public Task GetToolStateTrendData(DailyReport rpt, string toolType);
|
||||
public Task GetToolStateData(DailyReport rpt, string toolType);
|
||||
public Task<List<EquipmentStateByDay>> GetToolStateTrendData(string toolType);
|
||||
public Task<List<ToolStateCurrent>> GetToolStateData(string toolType);
|
||||
public Task<T> GetJsonData<T>(string url);
|
||||
}
|
||||
}
|
||||
|
@ -15,10 +15,10 @@ namespace ReportingServices.Shared.ViewModels.ProductionReport
|
||||
IsCurrentWeek = isCurrentWeek;
|
||||
}
|
||||
|
||||
public void SetYieldInformation(List<ReactorOutsByRDS> outs, List<ScrapByDay> scrap)
|
||||
public void SetYieldInformation(YieldInformation yieldInformation)
|
||||
{
|
||||
OutsByDay = GetReactorOutsByDay(outs);
|
||||
ScrapByDay = scrap;
|
||||
OutsByDay = GetReactorOutsByDay(yieldInformation.Outs);
|
||||
ScrapByDay = yieldInformation.Scrap;
|
||||
}
|
||||
|
||||
public static List<string> GetDistinctDatesFromReactorOuts(List<ReactorOutsByRDS> outs)
|
||||
|
Reference in New Issue
Block a user