200 lines
8.9 KiB
C#
200 lines
8.9 KiB
C#
using Microsoft.AspNetCore.Mvc;
|
|
using ReportingServices.Dependency_Injections;
|
|
using ReportingServices.HelperClasses;
|
|
using ReportingServices.Models.ProductionReport;
|
|
using ReportingServices.ReportingObjects;
|
|
using System.Web;
|
|
|
|
namespace ReportingServices.Controllers
|
|
{
|
|
public class ProductionReportController : Controller
|
|
{
|
|
private readonly IJsonFileHandler _jsonFileHandler;
|
|
private readonly IScrapeDatabaseRepository _scrapeDatabaseRepository;
|
|
private readonly IFabTimeReportingRepository _fabTimeReportingRepository;
|
|
private readonly ILogger<ProductionReportController> _logger;
|
|
private readonly int _reportIndex = (int)DateTime.Now.DayOfWeek;
|
|
private readonly string _dailyRptFilePath = "wwwroot/Assets/DailyReportInfo.json";
|
|
private readonly string _toolStateOwnerFilePath = "wwwroot/Assets/ToolStates.json";
|
|
private readonly string _toolFilter = "~R76%2C%20~R78%2C%20~R25%2C%20~R67%2C%20~R69%2C%20~R71%2C%20~R47%2C%20~R51%2C%20~R28";
|
|
|
|
public ProductionReportController(IJsonFileHandler jsonFileHandler, IScrapeDatabaseRepository scrapeDatabaseRepository,
|
|
IFabTimeReportingRepository fabTimeReportingRepository, ILogger<ProductionReportController> logger)
|
|
{
|
|
_jsonFileHandler = jsonFileHandler;
|
|
_scrapeDatabaseRepository = scrapeDatabaseRepository;
|
|
_fabTimeReportingRepository = fabTimeReportingRepository;
|
|
_logger = logger;
|
|
}
|
|
|
|
|
|
public IActionResult Index()
|
|
{
|
|
return View();
|
|
}
|
|
|
|
public IActionResult DailyReport()
|
|
{
|
|
try
|
|
{
|
|
DailyReport dailyReport = SetUpDailyReport();
|
|
Dictionary<string, List<string>> toolStateOwners = _jsonFileHandler.LoadJSONFile<Dictionary<string, List<string>>>(_toolStateOwnerFilePath);
|
|
|
|
dailyReport.ToolStatesByOwner = toolStateOwners;
|
|
|
|
return View(dailyReport);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
_logger.LogCritical(ex, "Failed to load report");
|
|
return View();
|
|
}
|
|
|
|
}
|
|
|
|
public IActionResult EditDailyReport()
|
|
{
|
|
Dictionary<string, List<ManualReportEntries>> entries = _jsonFileHandler.LoadJSONFile<Dictionary<string, List<ManualReportEntries>>>(_dailyRptFilePath);
|
|
|
|
ManualReportEntries rpt = entries["Current Week"][_reportIndex];
|
|
|
|
return View(rpt);
|
|
}
|
|
|
|
[HttpPost]
|
|
public IActionResult EditDailyReport(ManualReportEntries rpt)
|
|
{
|
|
Dictionary<string, List<ManualReportEntries>> report = _jsonFileHandler.LoadJSONFile<Dictionary<string, List<ManualReportEntries>>>(_dailyRptFilePath);
|
|
|
|
rpt.Date = DateTime.Parse(DateTime.Now.ToShortDateString());
|
|
rpt.Day = DateTime.Now.DayOfWeek;
|
|
|
|
report["Current Week"][_reportIndex] = rpt;
|
|
|
|
_jsonFileHandler.SaveJSONFile(report, _dailyRptFilePath);
|
|
|
|
return RedirectToAction("DailyReport");
|
|
}
|
|
|
|
public async Task<List<ReactorOutsByRDS>> MovesTrendCaller(string startDate = "", string endDate = "")
|
|
{
|
|
string url = APIHelperFunctions.GenerateURLWithParameters(startDate: startDate, endDate: endDate, chart: "MOVESLOTLIST", areasLike: "CLEANROOM", operationsLike: "1UNLOAD");
|
|
|
|
List<ReactorOutsByRDS> outsByRDS = await _fabTimeReportingRepository.GetMovesTrendData(url);
|
|
|
|
return outsByRDS;
|
|
}
|
|
|
|
public async Task<List<EquipmentStateByDay>> ToolStateTrendCaller(string toolType)
|
|
{
|
|
string url = APIHelperFunctions.GenerateURLWithParameters(chart: "TOOLSTATE", periodLen: "24", capacityTypesLike: toolType, toolsLike: _toolFilter);
|
|
|
|
List<EquipmentStateByDay> toolAvailability = await _fabTimeReportingRepository.GetToolStateTrendData(url);
|
|
|
|
return toolAvailability;
|
|
}
|
|
|
|
public async Task<List<ToolStateCurrent>> ToolStatesCaller(string toolType)
|
|
{
|
|
string capacityFilter = toolType == "ASM" ? toolType + "%2CASM%2B" : toolType;
|
|
string startDate = HttpUtility.UrlEncode(APIHelperFunctions.GetDateWithOffsetAsAPIString(DateTime.Now.ToString(), -12.5f));
|
|
|
|
string url = APIHelperFunctions.GenerateURLWithParameters(chart: "ToolStateGantt", periodLen: "24",
|
|
capacityTypesLike: capacityFilter, toolsLike: _toolFilter, startDate: startDate);
|
|
|
|
List<ToolStateCurrent> toolStates = await _fabTimeReportingRepository.GetToolStateData(url);
|
|
|
|
return toolStates;
|
|
}
|
|
|
|
public DailyReport SetUpDailyReport()
|
|
{
|
|
DailyReport report = new();
|
|
|
|
Task<List<ReactorOutsByRDS>> task1 = MovesTrendCaller();
|
|
Task<List<ReactorOutsByRDS>> task2 = MovesTrendCaller(startDate: report.StartDate.AddDays(-7).ToString(), endDate: report.StartDate.ToString());
|
|
Task<List<EquipmentStateByDay>> task3 = ToolStateTrendCaller("ASM");
|
|
Task<List<EquipmentStateByDay>> task4 = ToolStateTrendCaller("EPP");
|
|
Task<List<EquipmentStateByDay>> task5 = ToolStateTrendCaller("HTR");
|
|
Task<List<ToolStateCurrent>> task6 = ToolStatesCaller("ASM");
|
|
Task<List<ToolStateCurrent>> task7 = ToolStatesCaller("EPP");
|
|
Task<List<ToolStateCurrent>> task8 = ToolStatesCaller("HTR");
|
|
Task<List<ToolStateCurrent>> task9 = ToolStatesCaller("Metrology");
|
|
Task<List<ToolStateCurrent>> task10 = ToolStatesCaller("Cleans");
|
|
|
|
report.AddToolAvailibilityByType("ASM", task3.Result);
|
|
report.AddToolAvailibilityByType("EPP", task4.Result);
|
|
report.AddToolAvailibilityByType("HTR", task5.Result);
|
|
report.AddToolStateByType("ASM", task6.Result);
|
|
report.AddToolStateByType("EPP", task7.Result);
|
|
report.AddToolStateByType("HTR", task8.Result);
|
|
report.AddToolStateByType("Metrology", task9.Result);
|
|
report.AddToolStateByType("Cleans", task10.Result);
|
|
|
|
report.CurrentWeek.SetOutsByDay(task1.Result);
|
|
report.PreviousWeek.SetOutsByDay(task2.Result);
|
|
|
|
List<ScrapByDay> scrap = _scrapeDatabaseRepository.GetScrapByDay(task1.Result);
|
|
List<ScrapByDay> previousScrap = _scrapeDatabaseRepository.GetScrapByDay(task2.Result);
|
|
|
|
report.CurrentWeek.SetScrapByDay(scrap);
|
|
report.PreviousWeek.SetScrapByDay(previousScrap);
|
|
|
|
report.ReverseLists();
|
|
|
|
report.QuarterlyTargets = _scrapeDatabaseRepository.GetQuarterlyTargets();
|
|
|
|
int[] toolsByWaferSize = _scrapeDatabaseRepository.GetNumberOfToolsByWaferSize("''");
|
|
|
|
report.NumberOfToolsWaferSize6IN = toolsByWaferSize[0];
|
|
report.NumberOfToolsWaferSize8IN = toolsByWaferSize[1];
|
|
|
|
string reactors = "";
|
|
|
|
foreach (KeyValuePair<string, ToolStateByType> keyValuePairs in report.ToolStateByType)
|
|
{
|
|
if (keyValuePairs.Key != "Metrology" && keyValuePairs.Key != "Cleans")
|
|
{
|
|
foreach (ToolStateCurrent tool in keyValuePairs.Value.ToolStateCurrents)
|
|
{
|
|
if (tool.BasicStateDescription != "Productive" && tool.ReactorStatus != "Out of Service")
|
|
{
|
|
reactors = reactors + "'" + tool.Tool.Substring(1) + "', ";
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
reactors = reactors.Substring(0, reactors.Length - 2);
|
|
|
|
report.DualLayerReactors = _scrapeDatabaseRepository.GetDualLayerReactors();
|
|
|
|
int[] toolsByWaferSizeScheduled = _scrapeDatabaseRepository.GetNumberOfToolsByWaferSize(reactors);
|
|
|
|
report.NumberOfToolsWaferSize6INScheduled = toolsByWaferSizeScheduled[0];
|
|
report.NumberOfToolsWaferSize8INScheduled = toolsByWaferSizeScheduled[1];
|
|
|
|
Dictionary<string, List<ManualReportEntries>> entries = _jsonFileHandler.LoadJSONFile<Dictionary<string, List<ManualReportEntries>>>(_dailyRptFilePath);
|
|
|
|
report.CurrentEntries = entries["Current Week"];
|
|
report.PreviousEntries = entries["Previous Week"];
|
|
|
|
int[] singleLoadLocks = _scrapeDatabaseRepository.GetNumberOfSingleLoadLocks();
|
|
|
|
report.CurrentEntries[_reportIndex].ASMSingleLoadLock = singleLoadLocks[0];
|
|
report.CurrentEntries[_reportIndex].HTRSingleLoadLock = singleLoadLocks[1];
|
|
|
|
int[] unloadTempsLessThan700 = _scrapeDatabaseRepository.GetNumberOfToolUnloadTempsLessThan700();
|
|
|
|
report.CurrentEntries[_reportIndex].ASMUnloadTempsLessThan700 = unloadTempsLessThan700[0];
|
|
report.CurrentEntries[_reportIndex].HTRUnloadTempsLessThan700 = unloadTempsLessThan700[1];
|
|
|
|
entries["Current Week"] = report.CurrentEntries;
|
|
|
|
_jsonFileHandler.SaveJSONFile(entries, _dailyRptFilePath);
|
|
|
|
return report;
|
|
}
|
|
}
|
|
}
|