Added backend API project to segregate responsibilites - Data is now handled in API project and business is all handled in UI project.
This commit is contained in:
@ -1,109 +0,0 @@
|
||||
using System.Web;
|
||||
|
||||
namespace ReportingServices.Shared.HelperClasses
|
||||
{
|
||||
public static class APIHelperFunctions
|
||||
{
|
||||
private readonly static string fabTimeServer = "http://messa004.infineon.com/fabtime717service/GetChartData.aspx?";
|
||||
|
||||
public static string GetBeginningOfWeekAsAPIString()
|
||||
{
|
||||
DateTime date = DateTime.Now;
|
||||
|
||||
int dayOfWeek = (int)date.DayOfWeek;
|
||||
|
||||
date = dayOfWeek switch
|
||||
{
|
||||
0 => date.AddDays(-6),
|
||||
1 => date.AddDays(-7),
|
||||
_ => date.AddDays(1 - dayOfWeek)
|
||||
};
|
||||
|
||||
return GetDateTimeAsAPIString(date.ToString(), false);
|
||||
}
|
||||
|
||||
public static string GetDateWithOffsetAsAPIString(string dateString, float offset)
|
||||
{
|
||||
DateTime date = DateTime.Parse(dateString);
|
||||
|
||||
date = date.AddHours(offset);
|
||||
|
||||
return GetDateTimeAsAPIString(date.ToString(), true);
|
||||
}
|
||||
|
||||
public static string GetDateTimeAsAPIString(string dateString, bool fullDateTime)
|
||||
{
|
||||
DateTime date = DateTime.Parse(dateString);
|
||||
|
||||
if (fullDateTime)
|
||||
dateString = date.ToString("yyyy-M-d HH:mm:ss");
|
||||
else
|
||||
dateString = date.Year + "-" + date.Month + "-" + date.Day + " 0:0:0";
|
||||
|
||||
return dateString;
|
||||
}
|
||||
|
||||
public static Dictionary<string, string> SetParameters(string startDate = "", string endDate = "", string chart = "", string periodLen = "",
|
||||
string areasLike = "", string toolsLike = "", string operationsLike = "", string capacityTypesLike = "")
|
||||
{
|
||||
Dictionary<string, string> parameters = new();
|
||||
|
||||
startDate = startDate == "" ? HttpUtility.UrlEncode(GetBeginningOfWeekAsAPIString()) : startDate;
|
||||
endDate = endDate == "" ? HttpUtility.UrlEncode(GetDateTimeAsAPIString(DateTime.Now.ToString(), true)) : endDate;
|
||||
|
||||
parameters.Add("chart", chart);
|
||||
parameters.Add("starttime", startDate);
|
||||
parameters.Add("endtime", endDate);
|
||||
parameters.Add("periodlen", periodLen);
|
||||
parameters.Add("areaslike", areasLike);
|
||||
parameters.Add("toolslike", toolsLike);
|
||||
parameters.Add("operationslike", operationsLike);
|
||||
parameters.Add("capacitytypeslike", capacityTypesLike);
|
||||
parameters.Add("login", "administrator");
|
||||
parameters.Add("password", "admin");
|
||||
parameters.Add("fabtimeauthentication", "1");
|
||||
|
||||
return parameters;
|
||||
}
|
||||
|
||||
public static string GenerateURL(Dictionary<string, string> parameters)
|
||||
{
|
||||
int count = 0;
|
||||
string url = fabTimeServer;
|
||||
|
||||
foreach (KeyValuePair<string, string> pair in parameters)
|
||||
{
|
||||
if (pair.Value != "")
|
||||
url = url + pair.Key + "=" + pair.Value;
|
||||
|
||||
if (count != parameters.Count - 1 && !string.IsNullOrEmpty(pair.Value))
|
||||
url += "&";
|
||||
|
||||
count++;
|
||||
}
|
||||
|
||||
return url;
|
||||
}
|
||||
|
||||
public static string GenerateURLWithParameters(string startDate = "", string endDate = "", string chart = "", string periodLen = "",
|
||||
string areasLike = "", string toolsLike = "", string operationsLike = "", string capacityTypesLike = "")
|
||||
{
|
||||
Dictionary<string, string> parameters = SetParameters(startDate, endDate, chart,
|
||||
periodLen, areasLike, toolsLike, operationsLike, capacityTypesLike);
|
||||
|
||||
return GenerateURL(parameters);
|
||||
}
|
||||
|
||||
public static List<T> ReverseList<T>(List<T> inputList)
|
||||
{
|
||||
List<T> temp = new();
|
||||
|
||||
for (int i = inputList.Count - 1; i >= 0; i--)
|
||||
{
|
||||
temp.Add(inputList[i]);
|
||||
}
|
||||
|
||||
return temp;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,84 +0,0 @@
|
||||
using ReportingServices.Shared.Repositories;
|
||||
using ReportingServices.Shared.Models.ProductionReport;
|
||||
using ReportingServices.Shared.ViewModels.ProductionReport;
|
||||
|
||||
namespace ReportingServices.Shared.HelperClasses
|
||||
{
|
||||
public static class DailyReportHelper
|
||||
{
|
||||
private static IFabTimeReportingRepository _fabTimeReportingRepository;
|
||||
private static IScrapeDatabaseRepository _scrapeDatabaseRepository;
|
||||
private static readonly string _dailyRptFilePath = "wwwroot/Assets/DailyReportInfo.json";
|
||||
|
||||
public static void SetRepositories(IFabTimeReportingRepository fabTimeReportingRepository, IScrapeDatabaseRepository scrapeDatabaseRepository)
|
||||
{
|
||||
_fabTimeReportingRepository = fabTimeReportingRepository;
|
||||
_scrapeDatabaseRepository = scrapeDatabaseRepository;
|
||||
}
|
||||
|
||||
public static DailyReport SetUpDailyReport()
|
||||
{
|
||||
List<Task> tasks = new();
|
||||
DailyReport report = new();
|
||||
|
||||
Task<List<ReactorOutsByRDS>> task1 = _fabTimeReportingRepository.GetMovesTrendData();
|
||||
Task<List<ReactorOutsByRDS>> task2 = _fabTimeReportingRepository.GetMovesTrendData(startDate: report.StartDate.AddDays(-7).ToString(), endDate: report.StartDate.ToString());
|
||||
tasks.Add(_fabTimeReportingRepository.GetToolStateTrendData(report, "ASM"));
|
||||
tasks.Add(_fabTimeReportingRepository.GetToolStateTrendData(report, "EPP"));
|
||||
tasks.Add(_fabTimeReportingRepository.GetToolStateTrendData(report, "HTR"));
|
||||
tasks.Add(_fabTimeReportingRepository.GetToolStateData(report, "ASM"));
|
||||
tasks.Add(_fabTimeReportingRepository.GetToolStateData(report, "EPP"));
|
||||
tasks.Add(_fabTimeReportingRepository.GetToolStateData(report, "HTR"));
|
||||
tasks.Add(_fabTimeReportingRepository.GetToolStateData(report, "Metrology"));
|
||||
tasks.Add(_fabTimeReportingRepository.GetToolStateData(report, "Cleans"));
|
||||
|
||||
report.QuarterlyTargets = _scrapeDatabaseRepository.GetQuarterlyTargets();
|
||||
|
||||
Dictionary<string, List<ManualReportEntries>> entries = JsonFileHandler.LoadJSONFile<Dictionary<string, List<ManualReportEntries>>>(_dailyRptFilePath);
|
||||
|
||||
report.CurrentEntries = entries["Current Week"];
|
||||
report.PreviousEntries = entries["Previous Week"];
|
||||
|
||||
report.SetRDSInfo(_scrapeDatabaseRepository.GetRDSForLastDay());
|
||||
|
||||
Task.WaitAll(tasks.ToArray());
|
||||
|
||||
report.SetReactorInfo(_scrapeDatabaseRepository.GetReactors(), GetUnscheduledReactors(report));
|
||||
|
||||
List<ScrapByDay> scrap = _scrapeDatabaseRepository.GetScrapByDay(task1.Result);
|
||||
List<ScrapByDay> previousScrap = _scrapeDatabaseRepository.GetScrapByDay(task2.Result);
|
||||
|
||||
report.CurrentWeek.SetYieldInformation(task1.Result, scrap);
|
||||
report.PreviousWeek.SetYieldInformation(task2.Result, previousScrap);
|
||||
|
||||
report.ReverseLists();
|
||||
|
||||
entries["Current Week"] = report.CurrentEntries;
|
||||
|
||||
JsonFileHandler.SaveJSONFile(entries, _dailyRptFilePath);
|
||||
|
||||
return report;
|
||||
}
|
||||
|
||||
public static List<int> GetUnscheduledReactors(DailyReport report)
|
||||
{
|
||||
List<int> reactors = new();
|
||||
|
||||
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.Add(int.Parse(tool.Tool.Substring(1)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return reactors;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,19 +0,0 @@
|
||||
using System.Text.Json;
|
||||
|
||||
namespace ReportingServices.Shared.HelperClasses
|
||||
{
|
||||
public static class JsonFileHandler
|
||||
{
|
||||
public static T LoadJSONFile<T>(string file)
|
||||
{
|
||||
string json = File.ReadAllText(file);
|
||||
return JsonSerializer.Deserialize<T>(json);
|
||||
}
|
||||
|
||||
public static void SaveJSONFile<T>(T obj, string file)
|
||||
{
|
||||
string json = JsonSerializer.Serialize(obj);
|
||||
File.WriteAllText(file, json);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,9 +1,14 @@
|
||||
namespace ReportingServices.Shared.Models.PlanningReport
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace ReportingServices.Shared.Models.PlanningReport
|
||||
{
|
||||
public class ReactorPSNWORuns
|
||||
{
|
||||
[JsonPropertyName("REACTOR")]
|
||||
public string REACTOR { get; set; }
|
||||
[JsonPropertyName("PSN")]
|
||||
public string PSN { get; set; }
|
||||
[JsonPropertyName("WO_COUNT")]
|
||||
public int WO_COUNT { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -1,8 +1,12 @@
|
||||
namespace ReportingServices.Shared.Models.ProductionReport
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace ReportingServices.Shared.Models.ProductionReport
|
||||
{
|
||||
public class EquipmentStateByDay
|
||||
{
|
||||
[JsonPropertyName("StartTime")]
|
||||
public string StartTime { get; set; }
|
||||
[JsonPropertyName("AvailablePct")]
|
||||
public string AvailablePct { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -1,10 +1,16 @@
|
||||
namespace ReportingServices.Shared.Models.ProductionReport
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace ReportingServices.Shared.Models.ProductionReport
|
||||
{
|
||||
public class QuarterlyTargets
|
||||
{
|
||||
[JsonPropertyName("Reactor_Outs")]
|
||||
public int Reactor_Outs { get; set; }
|
||||
[JsonPropertyName("Yield_Outs")]
|
||||
public int Yield_Outs { get; set; }
|
||||
[JsonPropertyName("IFX_Scrap")]
|
||||
public int IFX_Scrap { get; set; }
|
||||
[JsonPropertyName("Yield")]
|
||||
public float Yield { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -1,11 +1,18 @@
|
||||
namespace ReportingServices.Shared.Models.ProductionReport
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace ReportingServices.Shared.Models.ProductionReport
|
||||
{
|
||||
public class RDS
|
||||
{
|
||||
[JsonPropertyName("Reactor")]
|
||||
public int Reactor { get; set; }
|
||||
[JsonPropertyName("ReactorType")]
|
||||
public string ReactorType { get; set; }
|
||||
[JsonPropertyName("DateOut")]
|
||||
public DateTime DateOut { get; set; }
|
||||
[JsonPropertyName("UnloadTemp")]
|
||||
public int UnloadTemp { get; set; }
|
||||
[JsonPropertyName("LayerType")]
|
||||
public string LayerType { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -1,10 +1,16 @@
|
||||
namespace ReportingServices.Shared.Models.ProductionReport
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace ReportingServices.Shared.Models.ProductionReport
|
||||
{
|
||||
public class Reactor
|
||||
{
|
||||
[JsonPropertyName("ReactorNumber")]
|
||||
public int ReactorNumber { get; set; }
|
||||
[JsonPropertyName("Type")]
|
||||
public string Type { get; set; }
|
||||
[JsonPropertyName("PocketSize")]
|
||||
public string PocketSize { get; set; }
|
||||
[JsonPropertyName("HasDisabledLoadLock")]
|
||||
public bool HasDisabledLoadlock { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -1,9 +1,14 @@
|
||||
namespace ReportingServices.Shared.Models.ProductionReport
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace ReportingServices.Shared.Models.ProductionReport
|
||||
{
|
||||
public class ReactorOutsByRDS
|
||||
{
|
||||
[JsonPropertyName("RDS_NO")]
|
||||
public string RDS_NO { get; set; }
|
||||
[JsonPropertyName("Units")]
|
||||
public string Units { get; set; }
|
||||
[JsonPropertyName("EndProcessTime")]
|
||||
public string EndProcessTime { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -1,11 +1,18 @@
|
||||
namespace ReportingServices.Shared.Models.ProductionReport
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace ReportingServices.Shared.Models.ProductionReport
|
||||
{
|
||||
public class ScrapByDay
|
||||
{
|
||||
[JsonPropertyName("StartDate")]
|
||||
public string StartDate { get; set; }
|
||||
[JsonPropertyName("TW_PROD")]
|
||||
public int TW_PROD { get; set; }
|
||||
[JsonPropertyName("TOT_REJ_CUST")]
|
||||
public int TOT_REJ_CUST { get; set; }
|
||||
[JsonPropertyName("TOT_REJ_MANU")]
|
||||
public int TOT_REJ_MANU { get; set; }
|
||||
[JsonPropertyName("TOT_REJ_WFRS")]
|
||||
public int TOT_REJ_WFRS { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -1,14 +1,24 @@
|
||||
namespace ReportingServices.Shared.Models.ProductionReport
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace ReportingServices.Shared.Models.ProductionReport
|
||||
{
|
||||
public class ToolStateCurrent
|
||||
{
|
||||
[JsonPropertyName("Tool")]
|
||||
public string Tool { get; set; }
|
||||
[JsonPropertyName("TranTime")]
|
||||
public string TranTime { get; set; }
|
||||
[JsonPropertyName("GanttEndTime")]
|
||||
public string GanttEndTime { get; set; }
|
||||
[JsonPropertyName("GanttElapsedHours")]
|
||||
public string GanttElapsedHours { get; set; }
|
||||
[JsonPropertyName("BasicStateDescription")]
|
||||
public string BasicStateDescription { get; set; }
|
||||
[JsonPropertyName("SubState")]
|
||||
public string SubState { get; set; }
|
||||
[JsonPropertyName("ReactorStatus")]
|
||||
public string ReactorStatus { get; set; }
|
||||
[JsonPropertyName("Comment")]
|
||||
public string Comment { get; set; }
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.Json.Serialization;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ReportingServices.Shared.Models.ProductionReport
|
||||
{
|
||||
public class YieldInformation
|
||||
{
|
||||
[JsonPropertyName("Outs")]
|
||||
public List<ReactorOutsByRDS> Outs { get; set; }
|
||||
[JsonPropertyName("Scrap")]
|
||||
public List<ScrapByDay> Scrap { get; set; }
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user