v2.49.2 30 Tests Passed

SRP and nuget server name
Date consistency
Delay for RAMS
This commit is contained in:
2023-05-23 12:53:37 -07:00
parent a5a44a62c0
commit 05b7f32605
20 changed files with 502 additions and 97 deletions

View File

@ -20,25 +20,38 @@ public class FromIQS
{
StringBuilder result = new();
_ = result
.AppendLine(" select iq.ev_count, iq.cl_count, iq.sl_count, iq.se_sgrp, iq.se_sgtm, iq.se_tsno, iq.td_test, iq.pr_name, iq.jd_name, iq.pl_name, iq.pd_name, iq.td_name, iq.se_val ")
.AppendLine(" from ( ")
.AppendLine(" select ")
.AppendLine(" se.f_sgrp se_sgrp, ")
.AppendLine(" se.f_sgtm se_sgtm, ")
.AppendLine(" se.f_tsno se_tsno, ")
.AppendLine(" se.f_val se_val, ")
.AppendLine(" rd.f_name rd_name, ")
.AppendLine(" pr.f_name pr_name, ")
.AppendLine(" jd.f_name jd_name, ")
.AppendLine(" pl.f_name pl_name, ")
.AppendLine(" pd.f_name pd_name, ")
.AppendLine(" td.f_test td_test, ")
.AppendLine(" td.f_name td_name, ")
.AppendLine(" (select count(cl.f_part) ")
.AppendLine(" from [spcepiworld].[dbo].[ctrl_lim] cl ")
.AppendLine(" where cl.f_part = pd.f_part ")
.AppendLine(" and cl.f_test = td.f_test ")
.AppendLine(" ) cl_count, ")
.AppendLine(" (select count(sl.f_part) ")
.AppendLine(" from [spcepiworld].[dbo].[spec_lim] sl ")
.AppendLine(" where sl.f_part = pd.f_part ")
.AppendLine(" and sl.f_test = td.f_test ")
.AppendLine(" ) sl_count, ")
.AppendLine(" (select count(ev.f_evnt) ")
.AppendLine(" from [spcepiworld].[dbo].[evnt_inf] ev ")
.AppendLine(" where ev.f_prcs = rd.f_prcs ")
.AppendLine(" where ev.f_prcs = pr.f_prcs ")
.AppendLine(" and ev.f_part = pd.f_part ")
.AppendLine(" and ev.f_sgtm = se.f_sgtm) ev_count ")
.AppendLine(" and ev.f_sgtm = se.f_sgtm ")
.AppendLine(" ) ev_count ")
.AppendLine(" from [spcepiworld].[dbo].[sgrp_ext] se ")
.AppendLine(" join [spcepiworld].[dbo].[prcs_dat] rd ")
.AppendLine(" on se.f_prcs = rd.f_prcs ")
.AppendLine(" join [spcepiworld].[dbo].[prcs_dat] pr ")
.AppendLine(" on se.f_prcs = pr.f_prcs ")
.AppendLine(" join [spcepiworld].[dbo].[job_dat] jd ")
.AppendLine(" on se.f_job = jd.f_job ")
.AppendLine(" join [spcepiworld].[dbo].[part_lot] pl ")
@ -53,11 +66,13 @@ public class FromIQS
if (!string.IsNullOrEmpty(description.RDS))
_ = result.Append(" and pl.f_name = '").Append(description.RDS).AppendLine("' ");
_ = result
.Append(" and rd.f_name = '").Append(description.Reactor).AppendLine("' ")
.Append(" and pr.f_name = '").Append(description.Reactor).AppendLine("' ")
.Append(" and pd.f_name = '").Append(description.PSN).AppendLine("' ")
.AppendLine(" and jd.f_name in ('SP101') ")
.Append(" and jd.f_name = '").Append(logistics.MesEntity).AppendLine("' ")
.Append(" and dateadd(HH, -7, (dateadd(SS, convert(bigint, se.f_sgtm), '19700101'))) = '").Append(dateTime).AppendLine("' ")
.AppendLine(" ) as iq ")
.AppendLine(" order by iq.ev_count desc, iq.cl_count desc, iq.sl_count desc, iq.se_sgrp, iq.se_tsno, iq.td_test ")
.AppendLine(" for json path ");
return result.ToString();
}
@ -99,7 +114,17 @@ public class FromIQS
{
stringBuilder = GetForJsonPath(connectionString, commandText);
if (stringBuilder.Length > 0)
{
long postBreakAfter = DateTime.Now.AddSeconds(5).Ticks;
for (short y = 0; y < short.MaxValue; y++)
{
if (DateTime.Now.Ticks > postBreakAfter)
break;
Thread.Sleep(250);
}
stringBuilder = GetForJsonPath(connectionString, commandText);
break;
}
if (DateTime.Now.Ticks > breakAfter)
// throw new Exception($"After {breakAfterSeconds} seconds, didn't find sub group id!");
break;
@ -115,13 +140,12 @@ public class FromIQS
else
{
JsonProperty[] jsonProperties = jsonElements[0].EnumerateObject().ToArray();
if (!jsonProperties.Any() || jsonProperties[0].Name != "se_sgrp" || !long.TryParse(jsonProperties[0].Value.ToString(), out long subGroupId))
if (!jsonProperties.Any() || jsonProperties[3].Name != "se_sgrp" || !long.TryParse(jsonProperties[3].Value.ToString(), out long subGroupId))
commandText = stringBuilder.ToString();
else
{
result = subGroupId;
commandText = GetCommandText(logistics, description, dateTime, subGroupId);
if (jsonProperties.Any() && jsonProperties[10].Name == "ev_count" && int.TryParse(jsonProperties[10].Value.ToString(), out int evCount))
if (jsonProperties.Any() && jsonProperties[0].Name == "ev_count" && int.TryParse(jsonProperties[0].Value.ToString(), out int evCount))
count = evCount;
}
}

View File

@ -62,10 +62,10 @@ public class Job
(int? workOrderNumber, int? _, int? workOrderCassette, int? slotNumber, bool isWorkOrder) = GetWorkOrder(input);
if (isWorkOrder || reactorNumber.HasValue)
(layer, psn, rdsNumber, zone) = (string.Empty, string.Empty, null, string.Empty);
else if (!string.IsNullOrEmpty(input.MID) && input.MID.Length is not 2 and not 3 and not 5)
(layer, psn, rdsNumber, reactorNumber, zone) = Get(input);
else
else if (!string.IsNullOrEmpty(input.MID) && input.MID.Length is 2 or 3 && Regex.IsMatch(input.MID, "^[a-zA-z]{2,3}"))
(layer, psn, rdsNumber, reactorNumber, zone) = Get(metrologyFileShare, input);
else
(layer, psn, rdsNumber, reactorNumber, zone) = Get(input);
if (IsValid(rdsNumber))
(comment, layer, rdsNumber, psn, reactorNumber, zone) = GetWithValidRDS(lsl2SQLConnectionString, layer, psn, rdsNumber, reactorNumber, zone);
else if (isWorkOrder || reactorNumber.HasValue)
@ -150,15 +150,15 @@ public class Job
private static bool IsInvalid(int? rdsNumber) => rdsNumber is null or < 100000 or > 100000000;
private static (string, string) GetReactorAndRDS(string defaultReactor, string defaultRDS, string text, string formattedText, string[] segments, bool hasRDS)
private static (string, string) GetReactorAndRDS(string defaultReactor, string defaultRDS, string text, string formattedText, string[] segments)
{
string rds;
string reactor;
if (string.IsNullOrEmpty(text) || segments.Length == 0 || string.IsNullOrEmpty(formattedText) || (segments.Length > 1 && !hasRDS))
if (string.IsNullOrEmpty(text) || segments.Length == 0 || string.IsNullOrEmpty(formattedText))
reactor = defaultReactor;
else
reactor = segments[0];
if (segments.Length <= 1 || !int.TryParse(segments[1].Replace("QP", string.Empty), out int rdsValue) || rdsValue < 99)
if (segments.Length <= 1 || !int.TryParse(segments[1], out int rdsValue) || rdsValue < 99)
rds = defaultRDS;
else
rds = segments[1];
@ -170,11 +170,11 @@ public class Job
return new(reactor, rds);
}
private static (string, string) GetLayerAndPSN(string defaultLayer, string defaultPSN, string[] segments, bool hasRDS)
private static (string, string) GetLayerAndPSN(string defaultLayer, string defaultPSN, string[] segments)
{
string psn;
string layer;
if (segments.Length <= 2 || (segments.Length > 1 && !hasRDS))
if (segments.Length <= 2)
{
psn = defaultPSN;
layer = defaultLayer;
@ -223,10 +223,10 @@ public class Job
string defaultLayer = string.Empty;
string defaultReactor = string.Empty;
string[] segments = input.MID.Split(new char[] { '-' });
bool hasRDS = Regex.IsMatch(input.MID, "[-]?([QP][0-9]{4,}|[0-9]{5,})[-]?");
// bool hasRDS = Regex.IsMatch(input.MID, "[-]?([QP][0-9]{4,}|[0-9]{5,})[-]?");
string formattedText = Regex.Replace(input.MID, @"[\\,\/,\:,\*,\?,\"",\<,\>,\|]", "_").Split('\r')[0].Split('\n')[0];
(reactor, rds) = GetReactorAndRDS(defaultReactor, defaultRDS, input.MID, formattedText, segments, hasRDS);
if (string.IsNullOrEmpty(rds))
(reactor, rds) = GetReactorAndRDS(defaultReactor, defaultRDS, input.MID, formattedText, segments);
if (string.IsNullOrEmpty(rds) || segments.Length < 2)
rdsNumber = 0;
else
_ = int.TryParse(segments[1], out rdsNumber);
@ -240,7 +240,7 @@ public class Job
else
{
reactorNumber = reactorCheck;
(layer, psn) = GetLayerAndPSN(defaultLayer, defaultPSN, segments, hasRDS);
(layer, psn) = GetLayerAndPSN(defaultLayer, defaultPSN, segments);
zone = GetZone(segments);
}
return new(layer, psn, rdsNumber, reactorNumber, zone);
@ -265,6 +265,7 @@ public class Job
private static (string, string, int?, int?, string) Get(string metrologyFileShare, Input input)
{
string lines;
const int zero = 0;
int? reactor = null;
int? rdsNumber = null;
string psn = string.Empty;
@ -272,9 +273,9 @@ public class Job
string zone = string.Empty;
string layer = string.Empty;
WorkMaterialOut? workMaterialOut;
if (!Directory.Exists(metrologyFileShare))
if (string.IsNullOrEmpty(metrologyFileShare) || !Directory.Exists(metrologyFileShare))
throw new Exception($"Unable to access file-share <{metrologyFileShare}>");
if (!string.IsNullOrEmpty(input.MID))
if (!string.IsNullOrEmpty(input.MID) && input.MID.Length is 3)
{
string[] checkDirectories = GetDirectories(metrologyFileShare);
foreach (string checkDirectory in checkDirectories)
@ -282,6 +283,7 @@ public class Job
if (!Directory.Exists(checkDirectory))
_ = Directory.CreateDirectory(checkDirectory);
files.AddRange(Directory.GetFiles(checkDirectory, $"WMO-{input.MID}.json", SearchOption.TopDirectoryOnly));
files.AddRange(Directory.GetFiles(checkDirectory, $"WMO-{input.MID.Substring(1, 2)}{input.MID[zero]}.json", SearchOption.TopDirectoryOnly));
}
}
foreach (string file in files.OrderByDescending(l => new FileInfo(l).LastWriteTime))

View File

@ -109,7 +109,9 @@ public class FileRead : Shared.FileRead, IFileRead
if (iProcessData is not ProcessData processData)
throw new Exception(string.Concat("A) No Data - ", dateTime.Ticks));
string mid;
if (!string.IsNullOrEmpty(processData.Employee) && string.IsNullOrEmpty(processData.Reactor) && string.IsNullOrEmpty(processData.RDS) && string.IsNullOrEmpty(processData.PSN))
if (!string.IsNullOrEmpty(processData.Lot) && string.IsNullOrEmpty(processData.Reactor) && string.IsNullOrEmpty(processData.RDS) && string.IsNullOrEmpty(processData.PSN))
mid = processData.Lot;
else if (!string.IsNullOrEmpty(processData.Employee) && string.IsNullOrEmpty(processData.Reactor) && string.IsNullOrEmpty(processData.RDS) && string.IsNullOrEmpty(processData.PSN))
mid = processData.Employee;
else
{

View File

@ -282,12 +282,15 @@ public class ProcessData : IProcessData
_I = 0;
_Data = string.Empty;
JobID = logistics.JobID;
Date = GetDateTime(logistics);
MesEntity = logistics.MesEntity;
Date = DateTime.Now;
_Log = LogManager.GetLogger(typeof(ProcessData));
Parse(fileRead, logistics, fileInfoCollection);
}
private static DateTime GetDateTime(Logistics logistics) =>
logistics.DateTimeFromSequence;
string IProcessData.GetCurrentReactor(IFileRead fileRead, Logistics logistics, Dictionary<string, string> reactors) => throw new Exception(string.Concat("See ", nameof(Parse)));
Tuple<string, Test[], JsonElement[], List<FileInfo>> IProcessData.GetResults(IFileRead fileRead, Logistics logistics, List<FileInfo> fileInfoCollection)
@ -532,7 +535,7 @@ public class ProcessData : IProcessData
string defaultLayer = string.Empty;
string defaultReactor = string.Empty;
string defaultEmployee = string.Empty;
if (Regex.IsMatch(text, @"^[a-zA-z][0-9]{4}$"))
if (Regex.IsMatch(text, @"^[a-zA-z][0-9]{2,4}$"))
{
lot = text.ToUpper();
psn = defaultPSN;