From 00042711ddd6ae90652418b546646107e496dea6 Mon Sep 17 00:00:00 2001 From: ouellette Date: Fri, 13 Oct 2023 13:06:33 -0700 Subject: [PATCH] Fixed null values returned from SQL query. --- .../appsettings.Development.json | 2 +- ReportingServices.API/appsettings.json | 2 +- .../ScrapeDatabaseRepository.cs | 50 ++++++++++++++++--- .../appsettings.Development.json | 2 +- ReportingServices.UI/appsettings.json | 2 +- .../wwwroot/Assets/SLLTools.json | 2 +- 6 files changed, 48 insertions(+), 12 deletions(-) diff --git a/ReportingServices.API/appsettings.Development.json b/ReportingServices.API/appsettings.Development.json index 11e75b0..29ab393 100644 --- a/ReportingServices.API/appsettings.Development.json +++ b/ReportingServices.API/appsettings.Development.json @@ -1,5 +1,5 @@ { - "ConnectionString": "Server=MESSV01EC.EC.LOCAL\\PROD1,53959;Database=LSL2SQL;User Id=srpadmin;Password=0okm9ijn;TrustServerCertificate=true", + "ConnectionString": "Server=MESSQLEC1.infineon.com\\PROD1,53959;Database=LSL2SQL;User Id=srpadmin;Password=0okm9ijn;TrustServerCertificate=true", "IsDevelopment": true, "MonAResource": "ReportingServicesApiIfx", "Serilog": { diff --git a/ReportingServices.API/appsettings.json b/ReportingServices.API/appsettings.json index 08c4d9c..c5b926f 100644 --- a/ReportingServices.API/appsettings.json +++ b/ReportingServices.API/appsettings.json @@ -2,7 +2,7 @@ "AllowedHosts": "*", "BuildNumber": "1", "Company": "Infineon Technologies Americas Corp.", - "ConnectionString": "Server=MESSV01EC.EC.LOCAL\\PROD1,53959;Database=LSL2SQL;User Id=srpadmin;Password=0okm9ijn;TrustServerCertificate=true", + "ConnectionString": "Server=MESSQLEC1.infineon.com\\PROD1,53959;Database=LSL2SQL;User Id=srpadmin;Password=0okm9ijn;TrustServerCertificate=true", "GitCommitSeven": "1234567", "Logging": { "LogLevel": { diff --git a/ReportingServices.Shared/Repositories/Implementations/ScrapeDatabaseRepository.cs b/ReportingServices.Shared/Repositories/Implementations/ScrapeDatabaseRepository.cs index 4fb12a2..15bc0c1 100644 --- a/ReportingServices.Shared/Repositories/Implementations/ScrapeDatabaseRepository.cs +++ b/ReportingServices.Shared/Repositories/Implementations/ScrapeDatabaseRepository.cs @@ -574,13 +574,49 @@ public class ScrapeDatabaseRepository : IScrapeDatabaseRepository 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(CASE WHEN REACTOR_TYPE <> 'EPP' THEN TW_PROD ELSE 0 END) AS PROD " + - " FROM RDS " + - " WHERE DATE_OUT >= @startDate " + - " AND DATE_OUT < @endDate"; + //string query = "SELECT SUM(WFRS_OUT) AS OUTS, " + + // " SUM(CUST_TOT_REJ) AS CUST, " + + // " SUM(LSL_TOT_REJ) AS MANU, " + + // " SUM(CASE WHEN REACTOR_TYPE <> 'EPP' THEN TW_PROD ELSE 0 END) AS PROD " + + // " FROM RDS " + + // " WHERE DATE_OUT >= @startDate " + + // " AND DATE_OUT < @endDate"; + string query = "SELECT " + + "CASE " + + "WHEN SUM(WFRS_OUT) IS NULL THEN 0 " + + "WHEN SUM(WFRS_OUT) IS NOT NULL THEN SUM(WFRS_OUT) END " + + "AS OUTS, " + + "CASE " + + "WHEN SUM(CUST_TOT_REJ) IS NULL THEN 0 " + + "WHEN SUM(CUST_TOT_REJ) IS NOT NULL THEN SUM(CUST_TOT_REJ) END " + + "AS CUST, " + + "CASE " + + "WHEN SUM(LSL_TOT_REJ) IS NULL THEN 0 " + + "WHEN SUM(LSL_TOT_REJ) IS NOT NULL THEN SUM(LSL_TOT_REJ) END " + + "AS MANU, " + + "CASE WHEN( " + + "CASE " + + "WHEN SUM(CASE WHEN REACTOR_TYPE <> 'EPP' " + + "THEN TW_PROD ELSE 0 END) IS NULL THEN 0 " + + "WHEN " + + "SUM(CASE WHEN REACTOR_TYPE <> 'EPP' " + + "THEN TW_PROD ELSE 0 END) > 0 THEN SUM(CASE WHEN REACTOR_TYPE<> 'EPP' " + + "THEN TW_PROD ELSE 0 END) END " + + ") IS NULL THEN 0 ELSE " + + "(" + + "CASE " + + "WHEN SUM(CASE WHEN REACTOR_TYPE<> 'EPP' " + + "THEN TW_PROD ELSE 0 END) IS NULL THEN 0 " + + "WHEN " + + "SUM(CASE WHEN REACTOR_TYPE <> 'EPP' " + + "THEN TW_PROD ELSE 0 END) > 0 THEN SUM(CASE WHEN REACTOR_TYPE<> 'EPP' " + + "THEN TW_PROD ELSE 0 END) END" + + ")" + + "END " + + "AS PROD " + + "FROM RDS " + + "WHERE DATE_OUT >= @startDate " + + "AND DATE_OUT< @endDate"; cmd.CommandText = query; _ = cmd.Parameters.AddWithValue("@startDate", startDate); diff --git a/ReportingServices.UI/appsettings.Development.json b/ReportingServices.UI/appsettings.Development.json index 262bcdb..b12202d 100644 --- a/ReportingServices.UI/appsettings.Development.json +++ b/ReportingServices.UI/appsettings.Development.json @@ -1,6 +1,6 @@ { "IsDevelopment": true, - "BaseAPIAddress": "https://localhost:7196/api/ScrapeDB/", + "BaseAPIAddress": "http://messa020ec.infineon.com:50201/api/ScrapeDB/", "MonAResource": "ReportingServicesUiIfx", "Serilog": { "Using": [ diff --git a/ReportingServices.UI/appsettings.json b/ReportingServices.UI/appsettings.json index 7d9e9f6..5a6d38b 100644 --- a/ReportingServices.UI/appsettings.json +++ b/ReportingServices.UI/appsettings.json @@ -1,6 +1,6 @@ { "AllowedHosts": "*", - "BaseAPIAddress": "http://localhost:50201/api/ScrapeDB/", + "BaseAPIAddress": "http://messa020ec.infineon.com:50201/api/ScrapeDB/", "BuildNumber": "1", "Company": "Infineon Technologies Americas Corp.", "DailyReportFilePath": "wwwroot/Assets/DailyReportInfo.json", diff --git a/ReportingServices.UI/wwwroot/Assets/SLLTools.json b/ReportingServices.UI/wwwroot/Assets/SLLTools.json index 229218c..7874230 100644 --- a/ReportingServices.UI/wwwroot/Assets/SLLTools.json +++ b/ReportingServices.UI/wwwroot/Assets/SLLTools.json @@ -1 +1 @@ -[{"Date":"2023-01-23T00:00:00-07:00","ASM":7,"HTR":16},{"Date":"2023-01-24T00:00:00-07:00","ASM":7,"HTR":15},{"Date":"2023-01-26T00:00:00-07:00","ASM":7,"HTR":14},{"Date":"2023-02-20T00:00:00-07:00","ASM":3,"HTR":8},{"Date":"2023-03-01T00:00:00-07:00","ASM":3,"HTR":8},{"Date":"2023-03-03T00:00:00-07:00","ASM":3,"HTR":8},{"Date":"2023-04-03T00:00:00-07:00","ASM":2,"HTR":6},{"Date":"2023-05-25T00:00:00-07:00","ASM":2,"HTR":8},{"Date":"2023-06-12T00:00:00-07:00","ASM":2,"HTR":7},{"Date":"2023-07-05T00:00:00-07:00","ASM":0,"HTR":8}] \ No newline at end of file +[{"Date":"2023-01-23T00:00:00-07:00","ASM":7,"HTR":16},{"Date":"2023-01-24T00:00:00-07:00","ASM":7,"HTR":15},{"Date":"2023-01-26T00:00:00-07:00","ASM":7,"HTR":14},{"Date":"2023-02-20T00:00:00-07:00","ASM":3,"HTR":8},{"Date":"2023-03-01T00:00:00-07:00","ASM":3,"HTR":8},{"Date":"2023-03-03T00:00:00-07:00","ASM":3,"HTR":8},{"Date":"2023-04-03T00:00:00-07:00","ASM":2,"HTR":6},{"Date":"2023-05-25T00:00:00-07:00","ASM":2,"HTR":8},{"Date":"2023-06-12T00:00:00-07:00","ASM":2,"HTR":7},{"Date":"2023-07-05T00:00:00-07:00","ASM":0,"HTR":8},{"Date":"2023-10-12T00:00:00-07:00","ASM":2,"HTR":7},{"Date":"2023-10-13T00:00:00-07:00","ASM":4,"HTR":8}] \ No newline at end of file