| | 1 | | using ReportingServices.Shared.Repositories; |
| | 2 | | using ReportingServices.Shared.Models.ProductionReport; |
| | 3 | | using ReportingServices.Shared.ViewModels.ProductionReport; |
| | 4 | |
|
| | 5 | | namespace ReportingServices.Shared.HelperClasses |
| | 6 | | { |
| | 7 | | public static class DailyReportHelper |
| | 8 | | { |
| 0 | 9 | | private static readonly string _dailyRptFilePath = "wwwroot/Assets/DailyReportInfo.json"; |
| 0 | 10 | | private static readonly string _SLLFilePath = "wwwroot/Assets/SLLTools.json"; |
| 0 | 11 | | private static readonly string _baseUrlFabtime = "https://localhost:7196/api/FabTime/"; |
| 0 | 12 | | private static readonly string _baseUrlScrapeDb = "https://localhost:7196/api/ScrapeDB/"; |
| | 13 | |
|
| | 14 | | public static DailyReport SetUpDailyReport() |
| 0 | 15 | | { |
| 0 | 16 | | List<Task<List<EquipmentStateByDay>>> tasksEQState = new(); |
| 0 | 17 | | List<Task<List<ToolStateCurrent>>> tasksState = new(); |
| 0 | 18 | | DailyReport report = new() |
| 0 | 19 | | { |
| 0 | 20 | | SLLTools = JsonFileHandler.LoadJSONFile<List<SLLTool>>(_SLLFilePath), |
| 0 | 21 | | ManualReportEntries = JsonFileHandler.LoadJSONFile<ManualReportEntries>(_dailyRptFilePath) |
| 0 | 22 | | }; |
| | 23 | |
|
| 0 | 24 | | Task<YieldInformation> task1 = ApiCaller.GetApi<YieldInformation>(_baseUrlFabtime + "ReactorOuts?startDate=" |
| 0 | 25 | | Task<YieldInformation> task2 = ApiCaller.GetApi<YieldInformation>(_baseUrlFabtime + "ReactorOuts?startDate=" |
| | 26 | |
|
| 0 | 27 | | tasksEQState.Add(ApiCaller.GetApi<List<EquipmentStateByDay>>(_baseUrlFabtime + "ToolStateTrend?toolType=ASM" |
| 0 | 28 | | tasksEQState.Add(ApiCaller.GetApi<List<EquipmentStateByDay>>(_baseUrlFabtime + "ToolStateTrend?toolType=EPP" |
| 0 | 29 | | tasksEQState.Add(ApiCaller.GetApi<List<EquipmentStateByDay>>(_baseUrlFabtime + "ToolStateTrend?toolType=HTR" |
| 0 | 30 | | tasksState.Add(ApiCaller.GetApi<List<ToolStateCurrent>>(_baseUrlFabtime + "ToolState?toolType=ASM")); |
| 0 | 31 | | tasksState.Add(ApiCaller.GetApi<List<ToolStateCurrent>>(_baseUrlFabtime + "ToolState?toolType=EPP")); |
| 0 | 32 | | tasksState.Add(ApiCaller.GetApi<List<ToolStateCurrent>>(_baseUrlFabtime + "ToolState?toolType=HTR")); |
| 0 | 33 | | tasksState.Add(ApiCaller.GetApi<List<ToolStateCurrent>>(_baseUrlFabtime + "ToolState?toolType=Metrology")); |
| 0 | 34 | | tasksState.Add(ApiCaller.GetApi<List<ToolStateCurrent>>(_baseUrlFabtime + "ToolState?toolType=Cleans")); |
| | 35 | |
|
| 0 | 36 | | Task<QuarterlyTargets> targets = ApiCaller.GetApi<QuarterlyTargets>(_baseUrlScrapeDb + "Targets"); |
| 0 | 37 | | Task<List<RDS>> rds = ApiCaller.GetApi<List<RDS>>(_baseUrlScrapeDb + "RDS?date=" + report.StartDate.ToString |
| 0 | 38 | | Task<List<Reactor>> reactors = ApiCaller.GetApi<List<Reactor>>(_baseUrlScrapeDb + "Reactors"); |
| | 39 | |
|
| 0 | 40 | | report.AddToolAvailibilityByType("ASM", tasksEQState[0].Result); |
| 0 | 41 | | report.AddToolAvailibilityByType("EPP", tasksEQState[1].Result); |
| 0 | 42 | | report.AddToolAvailibilityByType("HTR", tasksEQState[2].Result); |
| | 43 | |
|
| 0 | 44 | | report.AddToolStateByType("ASM", tasksState[0].Result); |
| 0 | 45 | | report.AddToolStateByType("EPP", tasksState[1].Result); |
| 0 | 46 | | report.AddToolStateByType("HTR", tasksState[2].Result); |
| 0 | 47 | | report.AddToolStateByType("Metrology", tasksState[3].Result); |
| 0 | 48 | | report.AddToolStateByType("Cleans", tasksState[4].Result); |
| | 49 | |
|
| 0 | 50 | | report.QuarterlyTargets = targets.Result; |
| | 51 | |
|
| 0 | 52 | | report.SetRDSInfo(rds.Result); |
| 0 | 53 | | report.SetReactorInfo(reactors.Result, GetUnscheduledReactors(report)); |
| | 54 | |
|
| 0 | 55 | | report.CurrentWeek.SetYieldInformation(task1.Result, report.QuarterlyTargets); |
| 0 | 56 | | report.PreviousWeek.SetYieldInformation(task2.Result, report.QuarterlyTargets); |
| | 57 | |
|
| 0 | 58 | | report.ReverseLists(); |
| | 59 | |
|
| 0 | 60 | | ManualReportEntries entries = report.ManualReportEntries; |
| 0 | 61 | | List<SLLTool> sll = report.SLLTools; |
| | 62 | |
|
| 0 | 63 | | JsonFileHandler.SaveJSONFile(entries, _dailyRptFilePath); |
| 0 | 64 | | JsonFileHandler.SaveJSONFile(sll, _SLLFilePath); |
| | 65 | |
|
| 0 | 66 | | return report; |
| 0 | 67 | | } |
| | 68 | |
|
| | 69 | | public static List<int> GetUnscheduledReactors(DailyReport report) |
| 0 | 70 | | { |
| 0 | 71 | | List<int> reactors = new(); |
| | 72 | |
|
| 0 | 73 | | foreach (KeyValuePair<string, ToolStateByType> keyValuePairs in report.ToolStateByType) |
| 0 | 74 | | { |
| 0 | 75 | | if (keyValuePairs.Key != "Metrology" && keyValuePairs.Key != "Cleans") |
| 0 | 76 | | { |
| 0 | 77 | | foreach (ToolStateCurrent tool in keyValuePairs.Value.ToolStateCurrents) |
| 0 | 78 | | { |
| 0 | 79 | | if (tool.BasicStateDescription != "Productive" && tool.ReactorStatus != "Out of Service") |
| 0 | 80 | | { |
| 0 | 81 | | reactors.Add(int.Parse(tool.Tool.Substring(1))); |
| 0 | 82 | | } |
| 0 | 83 | | } |
| 0 | 84 | | } |
| 0 | 85 | | } |
| | 86 | |
|
| 0 | 87 | | return reactors; |
| 0 | 88 | | } |
| | 89 | | } |
| | 90 | | } |