MET08DDUPSP1TBI - v2.43.0 - More changes to

Main / Job
This commit is contained in:
2022-07-07 10:41:55 -07:00
parent 48bba76f11
commit ee67aa5403
9 changed files with 399 additions and 133 deletions

View File

@ -28,7 +28,7 @@ public class Job
public DateTime DateTime { get; }
public List<Item> Items { get; }
public Job(string lsl2SQLConnectionString, Dictionary<int, List<(string MID, int Count)>> _RDS, string mid)
public Job(string lsl2SQLConnectionString, string mid)
{
Items = new List<Item>();
if (string.IsNullOrEmpty(mid) || mid[0] != '{' || mid[mid.Length - 1] != '}' || !mid.Contains("\"Si\""))
@ -37,7 +37,10 @@ public class Job
{
string psn;
int rds = 0;
string lotName;
string reactor;
string basicType;
const string hyphen = "-";
Input input = JsonSerializer.Deserialize<Input>(mid);
IsAreaSi = input.Area == "Si";
if (input.MID is null)
@ -47,7 +50,6 @@ public class Job
else
DateTime = new DateTime(sequence);
string[] segments = Regex.Split(input.MID, @"[^0-9']");
List<IGrouping<string, (string MID, int Count)>> orderedMatches = new();
if (segments.Length < 3 || (segments.Length > 1 && !int.TryParse(segments[1], out rds)))
{
psn = string.Empty;
@ -62,55 +64,49 @@ public class Job
{
psn = segments[2];
reactor = segments[0];
lock (_RDS)
{
if (!_RDS.ContainsKey(rds))
_RDS.Add(rds, new());
bool rdsCollectionCountIsZero = _RDS[rds].Count == 0;
if (rdsCollectionCountIsZero)
{
if (!string.IsNullOrEmpty(reactor) && !string.IsNullOrEmpty(psn))
_RDS[rds].Add(new(input.MID, 1));
else
{
string lsl2SQLMID = GetMID(lsl2SQLConnectionString, rds);
if (string.IsNullOrEmpty(lsl2SQLMID))
_RDS[rds].Add(new(input.MID, 1));
else
_RDS[rds].Add(new(lsl2SQLMID, 1));
}
}
IEnumerable<IGrouping<string, (string MID, int Count)>> grouped = _RDS[rds].GroupBy(l => l.MID);
orderedMatches.AddRange(from l in grouped orderby l.Count() descending select l);
if (!rdsCollectionCountIsZero)
{
int length = (from l in orderedMatches where l.Key == input.MID select true).Count();
_RDS[rds].Add(new(input.MID, length + 1));
}
if (_RDS.Count > 1000)
_ = _RDS.Remove(_RDS.ElementAt(0).Key);
}
}
AutomationMode = string.Concat(DateTime.Ticks, ".", input.MesEntity);
Equipment = input.MesEntity;
JobName = DateTime.Ticks.ToString();
if (orderedMatches.Any() && (string.IsNullOrEmpty(reactor) || string.IsNullOrEmpty(psn)))
{
segments = Regex.Split(orderedMatches[0].Key, @"[^0-9']");
psn = segments[2];
reactor = segments[0];
}
const string hyphen = "-";
if (rds is < 100000 or > 100000000)
{
BasicType = hyphen;
LotName = input.MID;
basicType = hyphen;
lotName = input.MID;
}
else
{
LotName = rds.ToString();
BasicType = GetBasicType(lsl2SQLConnectionString, hyphen, rds);
lotName = rds.ToString();
string json = GetRunJson(lsl2SQLConnectionString, rds);
if (string.IsNullOrEmpty(json))
basicType = hyphen;
else
{
Run[] runs;
try
{ runs = JsonSerializer.Deserialize<Run[]>(json); }
catch (Exception)
{ runs = Array.Empty<Run>(); }
if (!runs.Any())
basicType = hyphen;
else
{
if (string.IsNullOrEmpty(reactor))
reactor = runs[0].REACTOR.ToString();
if (string.IsNullOrEmpty(psn))
psn = runs[0].PS_NO;
string loadLockSide = runs[0].LOAD_LOCK_SIDE;
string loadLockSideFull = loadLockSide switch
{
"L" => "Left",
"R" => "Right",
_ => loadLockSide,
};
basicType = $"{loadLockSideFull} - {runs[0].REACTOR_TYPE}";
}
}
}
BasicType = basicType;
LotName = lotName;
PackageName = hyphen; //WAFER_ID WaferLot
ProcessSpecName = hyphen; //WAFER_POS PocketNumber
ProcessType = reactor;
@ -122,89 +118,70 @@ public class Job
}
}
private static string GetBasicType(string lsl2SQLConnectionString, string hyphen, int rds)
private static string GetRunJson(string lsl2SQLConnectionString, int rds)
{
string result;
// string json;
// string loadLock;
// JsonElement jsonElement;
// DateTime dateTime = DateTime.Now;
// string rdsFile = Path.Combine(configData.OIContextDataResultsPath, $"{DateTime.Ticks}.rds");
// string jsonFile = Path.Combine(configData.OIContextDataResultsPath, $"{DateTime.Ticks}.json");
// File.WriteAllText(Path.Combine(configData.OIContextDataSearchPath, $"{DateTime.Ticks}.rds"), rds);
// CultureInfo cultureInfo = new CultureInfo("en-US");
// Calendar calendar = cultureInfo.Calendar;
// string weekOfYear = calendar.GetWeekOfYear(dateTime, CalendarWeekRule.FirstDay, DayOfWeek.Sunday).ToString("00");
// string yearWeek = string.Concat(dateTime.ToString("yyyy"), "___Week_", weekOfYear);
// string resultsDirectory = Path.Combine(configData.OIContextDataResultsPath, yearWeek);
// if (!Directory.Exists(resultsDirectory))
// Directory.CreateDirectory(resultsDirectory);
// long breakAfter = dateTime.AddSeconds(60).Ticks;
// for (int i = 0; i < short.MaxValue; i++)
// {
// if (File.Exists(rdsFile) && File.Exists(jsonFile))
// {
// loadLock = string.Empty;
// json = File.ReadAllText(jsonFile);
// jsonElement = JsonSerializer.Deserialize<JsonElement>(json);
// if (jsonElement.ValueKind == JsonValueKind.Object)
// {
// foreach (JsonProperty jsonProperty in jsonElement.EnumerateObject())
// {
// if (jsonProperty.Name != "LoadLock")
// continue;
// loadLock = jsonProperty.Value.ToString();
// }
// }
// if (string.IsNullOrEmpty(loadLock))
// File.Move(jsonFile, Path.Combine(configData.OIContextDataResultsPath, $"{DateTime.Ticks}.err"));
// else
// {
// File.Move(rdsFile, Path.Combine(configData.OIContextDataResultsPath, yearWeek, $"{DateTime.Ticks}.rds"));
// File.Move(jsonFile, Path.Combine(configData.OIContextDataResultsPath, yearWeek, $"{DateTime.Ticks}.json"));
// result = loadLock;
// }
// break;
// }
// if (DateTime.Now.Ticks > breakAfter)
// break;
// }
object scalar = null;
StringBuilder sql = new();
_ = sql.Append(" SELECT ").
Append(" CASE ").
Append(" WHEN LOAD_LOCK_SIDE = 'L' THEN 'Left - ' ").
Append(" WHEN LOAD_LOCK_SIDE = 'R' THEN 'Right - ' ").
Append(" ELSE LOAD_LOCK_SIDE ").
Append(" END + REACTOR_TYPE AS LOAD_LOCK ").
Append(" FROM [LSL2SQL].[dbo].[REACT_RUN] ").
Append($" WHERE RDS_NO = '{rds}' ");
//Append(" AND LOAD_SIG != '' ");
try
{
using SqlConnection sqlConnection = new(lsl2SQLConnectionString);
sqlConnection.Open();
using (SqlCommand sqlCommand = new(sql.ToString(), sqlConnection))
scalar = sqlCommand.ExecuteScalar();
sqlConnection.Close();
}
catch (Exception)
{ }
if (scalar is null)
result = hyphen;
else
result = scalar.ToString();
return result;
}
private static string GetMID(string lsl2SQLConnectionString, int rds)
{
string result;
object scalar = null;
StringBuilder sql = new();
_ = sql.Append(" SELECT CONCAT(REACTOR, '-', RDS_NO, '-', PS_NO) [MID] ").
Append(" FROM [LSL2SQL].[dbo].[REACT_RUN] ").
Append($" WHERE RDS_NO = '{rds}' ");
Append(" RDS_NO, ").
Append(" WO_NO, ").
Append(" WO_STEP, ").
Append(" CASS_NO, ").
Append(" REACTOR, ").
Append(" VER_WFR_CNT, ").
Append(" LOAD_WFR_CNT, ").
Append(" ENTER_BY, ").
Append(" ENTER_DTM, ").
Append(" VER_SIG, ").
Append(" VER_SIG_DTM, ").
Append(" PRE_SIG, ").
Append(" PRE_SIG_DTM, ").
Append(" LOAD_SIG, ").
Append(" LOAD_SIG_DTM, ").
Append(" WFR_SIG, ").
Append(" WFR_SIG_DTM, ").
Append(" UNLOAD_SIG, ").
Append(" UNLOAD_SIG_DTM, ").
Append(" POST_SIG, ").
Append(" POST_SIG_DTM, ").
Append(" FINAL_SIG, ").
Append(" FINAL_SIG_DTM, ").
Append(" SCHED_DT, ").
Append(" REACT_IDLE_TIME, ").
Append(" SHIFT, ").
Append(" LOAD_LOCK_SIDE, ").
Append(" ADE_READ, ").
Append(" INJECTORS, ").
Append(" TUBE_ID, ").
Append(" TUBE_GRADE, ").
Append(" SUSCEPTOR_ID, ").
Append(" SUPP_INST, ").
Append(" SUPP_ENTRY_ID, ").
Append(" SUPP_ENTRY_DTM, ").
Append(" SUPP_SIG, ").
Append(" SUPP_SIG_DTM, ").
Append(" REACT_ACT_ESC_DTM, ").
Append(" SCHED_WFR_QTY, ").
Append(" CURR_WFR_CNT, ").
Append(" CURR_WFR_CNT_REJ, ").
Append(" CUST_NAME, ").
Append(" CUST_NO, ").
Append(" LOT_NO, ").
Append(" PART_NO, ").
Append(" PS_NO, ").
Append(" REACTOR_TYPE, ").
Append(" RECIPE_NAME, ").
Append(" RECIPE_NO, ").
Append(" SPEC_TYPE, ").
Append(" WFR_UNLOAD_DAYS, ").
Append(" WFR_UNLOAD_NIGHTS, ").
Append(" WFR_UNLOAD_QTY, ").
Append(" CASS_ID_SAP, ").
Append(" REACT_TOOL_ID ").
Append(" FROM [LSL2SQL].[dbo].[REACT_RUN] ").
Append(" WHERE RDS_NO = '").Append(rds).Append("' ").
Append(" FOR JSON PATH ");
try
{
using SqlConnection sqlConnection = new(lsl2SQLConnectionString);