Fixed HTR downed tools header, added quarter to date information, and put extended downtime into tool downed tables.
This commit is contained in:
@ -1,6 +1,7 @@
|
||||
using Microsoft.Data.SqlClient;
|
||||
using ReportingServices.Shared.Models.PlanningReport;
|
||||
using ReportingServices.Shared.Models.ProductionReport;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
|
||||
namespace ReportingServices.Shared.Repositories
|
||||
@ -333,7 +334,7 @@ namespace ReportingServices.Shared.Repositories
|
||||
" (SELECT TOP 1 * FROM REACT_EVENT " +
|
||||
" WHERE EVENT_DTM < @startDate " +
|
||||
" AND REACT_NO = @reactorNumber ORDER BY EVENT_DTM DESC) AS tbl1 " +
|
||||
"ORDER BY EVENT_DTM ASC;";
|
||||
"ORDER BY EVENT_DTM ASC";
|
||||
|
||||
cmd.CommandText = query;
|
||||
cmd.Parameters.AddWithValue("@startDate", startDate);
|
||||
@ -374,7 +375,7 @@ namespace ReportingServices.Shared.Repositories
|
||||
" TOOL_MODE_DESC " +
|
||||
" FROM TOOL_LOG " +
|
||||
" WHERE TOOL_ID = @toolID " +
|
||||
"ORDER BY START_DTM DESC;";
|
||||
"ORDER BY START_DTM DESC";
|
||||
|
||||
cmd.CommandText = query;
|
||||
cmd.Parameters.AddWithValue("@toolID", toolID);
|
||||
@ -397,5 +398,102 @@ namespace ReportingServices.Shared.Repositories
|
||||
|
||||
return evnt;
|
||||
}
|
||||
|
||||
public int GetLastUpTransaction(string reactorNumber)
|
||||
{
|
||||
int lastTransaction = 0;
|
||||
|
||||
OpenConnection();
|
||||
|
||||
SqlCommand cmd = _connection.CreateCommand();
|
||||
|
||||
string query = "SELECT TOP 1 DATEDIFF(MINUTE,START_DTM,SYSDATETIME()) " +
|
||||
" FROM REACT_MODE " +
|
||||
" WHERE REACT_NO = @reactorNumber " +
|
||||
" AND (MODE = 'UP' OR MODE = 'UP_WITH_INCREASED_SAMPLING') " +
|
||||
"ORDER BY START_DTM DESC";
|
||||
|
||||
cmd.CommandText = query;
|
||||
cmd.Parameters.AddWithValue("@reactorNumber", reactorNumber);
|
||||
|
||||
using (SqlDataReader reader = cmd.ExecuteReader())
|
||||
{
|
||||
while (reader.Read())
|
||||
lastTransaction = int.Parse(reader[0].ToString());
|
||||
}
|
||||
|
||||
cmd.Dispose();
|
||||
|
||||
CloseConnection();
|
||||
|
||||
return lastTransaction;
|
||||
}
|
||||
|
||||
public OutsAndScrapTotal GetOutsAndScrapTotals(string startDate, string endDate)
|
||||
{
|
||||
OutsAndScrapTotal totals = new();
|
||||
|
||||
OpenConnection();
|
||||
|
||||
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(TW_PROD) AS PROD " +
|
||||
" FROM RDS " +
|
||||
" WHERE DATE_OUT >= @startDate " +
|
||||
" AND DATE_OUT <= @endDate";
|
||||
|
||||
cmd.CommandText = query;
|
||||
cmd.Parameters.AddWithValue("@startDate", startDate);
|
||||
cmd.Parameters.AddWithValue("@endDate", endDate);
|
||||
|
||||
using (SqlDataReader reader = cmd.ExecuteReader())
|
||||
{
|
||||
while (reader.Read())
|
||||
totals = new()
|
||||
{
|
||||
Outs = int.Parse(reader[0].ToString()),
|
||||
CustomerScrap = int.Parse(reader[1].ToString()),
|
||||
ManufacturingScrap = int.Parse(reader[2].ToString()),
|
||||
ProductionScrap = int.Parse(reader[3].ToString()),
|
||||
};
|
||||
}
|
||||
|
||||
cmd.Dispose();
|
||||
|
||||
CloseConnection();
|
||||
|
||||
return totals;
|
||||
}
|
||||
|
||||
public DateTime GetQuarterStartDate()
|
||||
{
|
||||
DateTime date = new();
|
||||
|
||||
OpenConnection();
|
||||
|
||||
SqlCommand cmd = _connection.CreateCommand();
|
||||
|
||||
string query = "SELECT START_DT " +
|
||||
" FROM FISCAL_QTR " +
|
||||
" WHERE START_DT < SYSDATETIME() " +
|
||||
" AND END_DT > SYSDATETIME()";
|
||||
|
||||
cmd.CommandText = query;
|
||||
|
||||
using (SqlDataReader reader = cmd.ExecuteReader())
|
||||
{
|
||||
while (reader.Read())
|
||||
date = DateTime.Parse(reader[0].ToString());
|
||||
}
|
||||
|
||||
cmd.Dispose();
|
||||
|
||||
CloseConnection();
|
||||
|
||||
return date;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user