diff --git a/ReportingServices.Shared/HelperClasses/DailyReportHelper.cs b/ReportingServices.Shared/HelperClasses/DailyReportHelper.cs index 7b16dfb..d52b05c 100644 --- a/ReportingServices.Shared/HelperClasses/DailyReportHelper.cs +++ b/ReportingServices.Shared/HelperClasses/DailyReportHelper.cs @@ -12,11 +12,49 @@ public static class DailyReportHelper public static DailyReport SetUpDailyReport(ILogger logger, string baseUrlScrapeDb) { DailyReport report = new(); + DateTime currentDateTime = DateTime.Now; try { - report.SLLTools = JsonFileHandler.LoadJSONFile>(_SLLFilePath); - report.ManualReportEntries = JsonFileHandler.LoadJSONFile(_dailyRptFilePath); + List tools = JsonFileHandler.LoadJSONFile>(_SLLFilePath); + ManualReportEntries manualEntries = JsonFileHandler.LoadJSONFile(_dailyRptFilePath); + + if (currentDateTime.DayOfWeek == DayOfWeek.Monday && tools[tools.Count - 1].Date == currentDateTime.Date.AddDays(-1)) + report.SLLTools = new List(); + else + report.SLLTools = tools; + + if (currentDateTime.Date > manualEntries.Date) + { + string weeklyPtChng; + + if (currentDateTime.DayOfWeek == DayOfWeek.Monday) + weeklyPtChng = null; + else + weeklyPtChng = manualEntries.WeeklyPartChanges; + + report.ManualReportEntries = new ManualReportEntries() + { + Date = currentDateTime.Date, + OperatorHeadcountDays = 0, + OperatorHeadcountNights = 0, + OperatorCallOutsDays = 0, + OperatorCallOutsNights = 0, + MaintenanceHeadcountDays = 0, + MaintenanceHeadcountNights = 0, + MaintenanceCallOutsDays = 0, + MaintenanceCallOutsNights = 0, + EngineeringHeadcountDays = 0, + EngineeringHeadcountNights = 0, + EngineeringCallOutsDays = 0, + EngineeringCallOutsNights = 0, + BottleChanges = null, + DailyPartChanges = null, + WeeklyPartChanges = weeklyPtChng + }; + } + else + report.ManualReportEntries = manualEntries; } catch (Exception ex) @@ -75,7 +113,7 @@ public static class DailyReportHelper foreach (Reactor reactor in reactors) { toolEvents.Add(ApiCaller.GetApi>(baseUrlScrapeDb + "ReactorEvents?startDate=" + report.StartDate.ToString() + - "&endDate=" + DateTime.Now.ToString() + "&reactorNumber=" + reactor.ReactorNumber + "&reactorType=" + reactor.Type)); + "&endDate=" + currentDateTime.ToString() + "&reactorNumber=" + reactor.ReactorNumber + "&reactorType=" + reactor.Type)); lastUpTransactions.Add(reactor.ReactorNumber.ToString(), ApiCaller.GetApi(baseUrlScrapeDb + "GetLastUpTransaction?reactorNumber=" + reactor.ReactorNumber)); @@ -91,13 +129,13 @@ public static class DailyReportHelper metrologyEvents.Add(ApiCaller.GetApi(baseUrlScrapeDb + "ToolEvents?toolID=" + tool)); } - task1 = ApiCaller.GetApi(baseUrlScrapeDb + "ReactorOuts?startDate=" + report.StartDate.ToString() + "&endDate=" + DateTime.Now.ToString()); + task1 = ApiCaller.GetApi(baseUrlScrapeDb + "ReactorOuts?startDate=" + report.StartDate.ToString() + "&endDate=" + currentDateTime.ToString()); task2 = ApiCaller.GetApi(baseUrlScrapeDb + "ReactorOuts?startDate=" + report.StartDate.AddDays(-7).ToString() + "&endDate=" + report.StartDate.ToString()); task3 = ApiCaller.GetApi(baseUrlScrapeDb + "GetQuarterStartDate"); targets = ApiCaller.GetApi(baseUrlScrapeDb + "Targets"); rds = ApiCaller.GetApi>(baseUrlScrapeDb + "RDS?date=" + report.StartDate.ToString()); - task4 = ApiCaller.GetApi(baseUrlScrapeDb + "GetOutsAndScrapTotals?startDate=" + task3.Result + "&endDate=" + DateTime.Now.ToString()); + task4 = ApiCaller.GetApi(baseUrlScrapeDb + "GetOutsAndScrapTotals?startDate=" + task3.Result + "&endDate=" + currentDateTime.ToString()); task5 = ApiCaller.GetApi(baseUrlScrapeDb + "GetOutsAndScrapTotals?startDate=" + task3.Result + "&endDate=" + report.StartDate.ToString()); task6 = ApiCaller.GetApi(baseUrlScrapeDb + "GetOutsAndScrapTotals?startDate=" + task3.Result + "&endDate=" + report.StartDate.AddDays(-7).ToString()); } @@ -115,7 +153,7 @@ public static class DailyReportHelper foreach (Task> task in toolEvents) { ToolEventView toolEvent = new(task.Result, - report.StartDate.ToString(), DateTime.Now.ToString(), task.Result[0].REACT_NO, + report.StartDate.ToString(), currentDateTime.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); diff --git a/ReportingServices.Shared/Models/ProductionReport/ManualReportEntries.cs b/ReportingServices.Shared/Models/ProductionReport/ManualReportEntries.cs index a6eaa89..75094d2 100644 --- a/ReportingServices.Shared/Models/ProductionReport/ManualReportEntries.cs +++ b/ReportingServices.Shared/Models/ProductionReport/ManualReportEntries.cs @@ -2,6 +2,7 @@ public class ManualReportEntries { + public DateTime Date { get; set; } public int OperatorHeadcountDays { get; set; } public int OperatorHeadcountNights { get; set; } public int OperatorCallOutsDays { get; set; } diff --git a/ReportingServices.Shared/Repositories/Implementations/ScrapeDatabaseRepository.cs b/ReportingServices.Shared/Repositories/Implementations/ScrapeDatabaseRepository.cs index ef5632b..65f8bf8 100644 --- a/ReportingServices.Shared/Repositories/Implementations/ScrapeDatabaseRepository.cs +++ b/ReportingServices.Shared/Repositories/Implementations/ScrapeDatabaseRepository.cs @@ -86,15 +86,21 @@ public class ScrapeDatabaseRepository : IScrapeDatabaseRepository using (SqlDataReader reader = cmd.ExecuteReader()) { while (reader.Read() && reader[0].ToString() != "1/1/1900 12:00:00 AM") + { + int twProd = string.IsNullOrEmpty(reader[3].ToString()) ? 0 : int.Parse(reader[3].ToString()); + int custScrap = string.IsNullOrEmpty(reader[1].ToString()) ? 0 : int.Parse(reader[1].ToString()); + int manuScrap = string.IsNullOrEmpty(reader[2].ToString()) ? 0 : int.Parse(reader[2].ToString()); + int totScrap = custScrap + manuScrap; + 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()) + TW_PROD = twProd, + TOT_REJ_CUST = custScrap, + TOT_REJ_MANU = manuScrap, + TOT_REJ_WFRS = totScrap }); + } } cmd.Dispose(); diff --git a/ReportingServices.UI/Controllers/ProductionReportController.cs b/ReportingServices.UI/Controllers/ProductionReportController.cs index a661875..5d581a5 100644 --- a/ReportingServices.UI/Controllers/ProductionReportController.cs +++ b/ReportingServices.UI/Controllers/ProductionReportController.cs @@ -52,6 +52,8 @@ public class ProductionReportController : Controller [HttpPost] public IActionResult EditDailyReport(ManualReportEntries rpt) { + rpt.Date = DateTime.Now.Date; + JsonFileHandler.SaveJSONFile(rpt, _dailyRptFilePath); return RedirectToAction("DailyReport"); diff --git a/ReportingServices.UI/Views/ProductionReport/DailyReport.cshtml b/ReportingServices.UI/Views/ProductionReport/DailyReport.cshtml index 61144db..3ba6165 100644 --- a/ReportingServices.UI/Views/ProductionReport/DailyReport.cshtml +++ b/ReportingServices.UI/Views/ProductionReport/DailyReport.cshtml @@ -417,7 +417,7 @@ } } - @(ASMSLL / numberOfDaysInWeek) + @(Math.Round((double)ASMSLL / (double)numberOfDaysInWeek)) 0 @@ -437,7 +437,7 @@ } } - @(HTRSLL / numberOfDaysInWeek) + @(Math.Round((double)HTRSLL / (double)numberOfDaysInWeek)) 0 @@ -455,7 +455,7 @@ } } - @(ASMUnloadTemps / numberOfDaysInWeek) + @(Math.Round((double)ASMUnloadTemps / (double)numberOfDaysInWeek)) 0 @@ -473,7 +473,7 @@ } } - @(HTRUnloadTemps / numberOfDaysInWeek) + @(Math.Round((double)HTRUnloadTemps / (double)numberOfDaysInWeek)) 0 diff --git a/ReportingServices.UI/wwwroot/Assets/DailyReportInfo.json b/ReportingServices.UI/wwwroot/Assets/DailyReportInfo.json index 09ce689..0e8aa37 100644 --- a/ReportingServices.UI/wwwroot/Assets/DailyReportInfo.json +++ b/ReportingServices.UI/wwwroot/Assets/DailyReportInfo.json @@ -1 +1 @@ -{"OperatorHeadcountDays":0,"OperatorHeadcountNights":0,"OperatorCallOutsDays":0,"OperatorCallOutsNights":0,"EngineeringHeadcountDays":0,"EngineeringHeadcountNights":0,"EngineeringCallOutsDays":0,"EngineeringCallOutsNights":0,"MaintenanceHeadcountDays":0,"MaintenanceHeadcountNights":0,"MaintenanceCallOutsDays":0,"MaintenanceCallOutsNights":0,"BottleChanges":null,"DailyPartChanges":null,"WeeklyPartChanges":null} \ No newline at end of file +{"Date":"2023-01-15T00:00:00-07:00","OperatorHeadcountDays":14,"OperatorHeadcountNights":12,"OperatorCallOutsDays":0,"OperatorCallOutsNights":1,"EngineeringHeadcountDays":1,"EngineeringHeadcountNights":1,"EngineeringCallOutsDays":0,"EngineeringCallOutsNights":0,"MaintenanceHeadcountDays":3,"MaintenanceHeadcountNights":3,"MaintenanceCallOutsDays":0,"MaintenanceCallOutsNights":0,"BottleChanges":"R22","DailyPartChanges":"R23,R25","WeeklyPartChanges":"R23,R25,R27,R29,R36,R37"} \ No newline at end of file diff --git a/ReportingServices.UI/wwwroot/Assets/SLLTools.json b/ReportingServices.UI/wwwroot/Assets/SLLTools.json index 38d4bc4..dc07525 100644 --- a/ReportingServices.UI/wwwroot/Assets/SLLTools.json +++ b/ReportingServices.UI/wwwroot/Assets/SLLTools.json @@ -1 +1,37 @@ -[{"Date":"2023-01-09T00:00:00-07:00","ASM":8,"HTR":16},{"Date":"2023-01-10T00:00:00-07:00","ASM":8,"HTR":16},{"Date":"2023-01-11T00:00:00-07:00","ASM":8,"HTR":16},{"Date":"2023-01-12T00:00:00-07:00","ASM":7,"HTR":16},{"Date":"2023-01-13T00:00:00-07:00","ASM":7,"HTR":15}] \ No newline at end of file +[ + { + "Date": "2023-01-09T00:00:00-07:00", + "ASM": 8, + "HTR": 16 + }, + { + "Date": "2023-01-10T00:00:00-07:00", + "ASM": 8, + "HTR": 16 + }, + { + "Date": "2023-01-11T00:00:00-07:00", + "ASM": 8, + "HTR": 16 + }, + { + "Date": "2023-01-12T00:00:00-07:00", + "ASM": 7, + "HTR": 16 + }, + { + "Date": "2023-01-13T00:00:00-07:00", + "ASM": 7, + "HTR": 15 + }, + { + "Date": "2023-01-14T00:00:00-07:00", + "ASM": 8, + "HTR": 15 + }, + { + "Date": "2023-01-15T00:00:00-07:00", + "ASM": 9, + "HTR": 15 + } +] \ No newline at end of file