Removed console logging for hold date and added display of daily and weekly part changes (completed and projected).

This commit is contained in:
Daniel Wathen
2023-01-23 13:47:17 -07:00
parent 649805bde6
commit a67cc55abe
13 changed files with 232 additions and 95 deletions

View File

@ -124,10 +124,10 @@ public class ScrapeDatabaseRepository : IScrapeDatabaseRepository
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";
string query = "SELECT REACTOR, PROD_SPEC_ID, WO, COUNT(WO) FROM RDS " +
" WHERE DATE_OUT BETWEEN @startDate AND @endDate " +
"GROUP BY REACTOR, PROD_SPEC_ID, WO " +
"ORDER BY 1";
cmd.CommandText = query;
_ = cmd.Parameters.AddWithValue("@startDate", startDate);
@ -140,7 +140,55 @@ public class ScrapeDatabaseRepository : IScrapeDatabaseRepository
{
REACTOR = reader[0].ToString(),
PSN = reader[1].ToString(),
WO_COUNT = int.Parse(reader[2].ToString())
WO = reader[2].ToString(),
WO_COUNT = int.Parse(reader[3].ToString())
});
}
cmd.Dispose();
CloseConnection();
return weeklyPartChanges;
}
public List<ReactorPSNWORuns> GetReactorPartChanges(string startDate, string endDate)
{
List<ReactorPSNWORuns> weeklyPartChanges = new();
OpenConnection();
SqlCommand cmd = _connection.CreateCommand();
string query = "SELECT REACTOR, PROD_SPEC_ID, WO, COUNT(WO) AS WO_COUNT FROM RDS " +
" WHERE DATE_OUT BETWEEN @startDate AND @endDate " +
" AND REACTOR IN (SELECT REACTOR " +
" 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 l.PCHANGE > 0) " +
"GROUP BY REACTOR, PROD_SPEC_ID, WO " +
"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 = "R" + reader[0].ToString(),
PSN = reader[1].ToString(),
WO = reader[2].ToString(),
WO_COUNT = int.Parse(reader[3].ToString())
});
}
@ -593,7 +641,7 @@ public class ScrapeDatabaseRepository : IScrapeDatabaseRepository
SqlCommand cmd = _connection.CreateCommand();
string query = "SELECT REACT_NO " +
string query = "SELECT DISTINCT(REACT_NO) " +
" FROM SCHED_DET_NG schd " +
"INNER JOIN WO_LOG wlog ON WO = WO_NO " +
" WHERE STOP_DTM > SYSDATETIME() " +
@ -615,4 +663,108 @@ public class ScrapeDatabaseRepository : IScrapeDatabaseRepository
return lots;
}
public List<ScheduledEvent> GetScheduledEvents(string startDate, string endDate)
{
List<ScheduledEvent> events = new();
OpenConnection();
SqlCommand cmd = _connection.CreateCommand();
string query = "SELECT REACT_NO, " +
" schd.WO_NO, " +
" PROC_SPEC_ID, " +
" START_DTM, " +
" STOP_DTM, " +
" BLOCKOUT, " +
" BLOCK_OUT_TYPE " +
" FROM SCHED_DET_NG schd " +
"FULL OUTER JOIN WO_STEP step " +
" ON step.WO_NO = schd.WO_NO " +
" WHERE ((STOP_DTM > @startDate AND STOP_DTM < @endDate) " +
" OR (START_DTM > @startDate AND START_DTM < @endDate)) " +
"ORDER BY REACT_NO, START_DTM ASC";
cmd.CommandText = query;
_ = cmd.Parameters.AddWithValue("@startDate", startDate);
_ = cmd.Parameters.AddWithValue("@endDate", endDate);
using (SqlDataReader reader = cmd.ExecuteReader())
{
while (reader.Read())
events.Add(new ScheduledEvent
{
REACT_NO = reader[0].ToString(),
WO_NO = reader[1].ToString(),
PROD_SPEC_ID = reader[2].ToString(),
START_DTM = DateTime.Parse(reader[3].ToString()),
STOP_DTM = DateTime.Parse(reader[4].ToString()),
BLOCKOUT = reader[5].ToString(),
BLOCKOUT_TYPE = reader[6].ToString()
});
}
cmd.Dispose();
CloseConnection();
return events;
}
public List<ReactorPSNWORuns> GetProjectedPartChanges(string startDate, string endDate)
{
List<ReactorPSNWORuns> events = new();
OpenConnection();
SqlCommand cmd = _connection.CreateCommand();
string query = "SELECT REACT_NO, " +
" PROC_SPEC_ID, " +
" schd.WO_NO " +
" FROM SCHED_DET_NG schd " +
"FULL OUTER JOIN WO_STEP step " +
" ON step.WO_NO = schd.WO_NO " +
" WHERE ((STOP_DTM > @startDate AND STOP_DTM < @endDate) " +
" OR (START_DTM > @startDate AND START_DTM < @endDate)) " +
" AND BLOCKOUT IS NULL " +
" AND REACT_NO IN (SELECT REACT_NO " +
" FROM (SELECT REACT_NO, " +
" COUNT(PROC_SPEC_ID) - 1 AS PCHANGE " +
" FROM (SELECT REACT_NO, " +
" PROC_SPEC_ID, " +
" COUNT(schd.WO_NO) AS WO_COUNT " +
" FROM SCHED_DET_NG schd " +
" FULL OUTER JOIN WO_STEP step " +
" ON step.WO_NO = schd.WO_NO " +
" WHERE ((STOP_DTM > @startDate AND STOP_DTM < @endDate) " +
" OR (START_DTM > @startDate AND START_DTM < @endDate)) " +
" AND BLOCKOUT IS NULL GROUP BY REACT_NO, PROC_SPEC_ID) AS l " +
" GROUP BY REACT_NO) AS p " +
" WHERE PCHANGE > 0) " +
"ORDER BY REACT_NO";
cmd.CommandText = query;
_ = cmd.Parameters.AddWithValue("@startDate", startDate);
_ = cmd.Parameters.AddWithValue("@endDate", endDate);
using (SqlDataReader reader = cmd.ExecuteReader())
{
while (reader.Read())
events.Add(new ReactorPSNWORuns
{
REACTOR = "R" + reader[0].ToString(),
PSN = reader[1].ToString(),
WO = reader[2].ToString(),
WO_COUNT = 0
});
}
cmd.Dispose();
CloseConnection();
return events;
}
}