ready to test
This commit is contained in:
@ -1,3 +1,4 @@
|
||||
using OI.Metrology.Server.Models;
|
||||
using OI.Metrology.Shared.DataModels;
|
||||
using OI.Metrology.Shared.Models.Stateless;
|
||||
using OI.Metrology.Shared.Repositories;
|
||||
@ -15,9 +16,9 @@ public class InfinityQSRepository : IInfinityQSRepository
|
||||
private readonly string _RepositoryName;
|
||||
private readonly IDbConnectionFactory _DBConnectionFactory;
|
||||
|
||||
public InfinityQSRepository(string mockRoot, IDbConnectionFactory dbConnectionFactory)
|
||||
public InfinityQSRepository(AppSettings appSettings, IDbConnectionFactory dbConnectionFactory)
|
||||
{
|
||||
_MockRoot = mockRoot;
|
||||
_MockRoot = appSettings.MockRoot;
|
||||
_DBConnectionFactory = dbConnectionFactory;
|
||||
_RepositoryName = nameof(InfinityQSRepository)[..^10];
|
||||
}
|
||||
|
@ -1,3 +1,4 @@
|
||||
using OI.Metrology.Server.Models;
|
||||
using OI.Metrology.Shared.DataModels;
|
||||
using OI.Metrology.Shared.Models.Stateless;
|
||||
using OI.Metrology.Shared.Repositories;
|
||||
@ -15,9 +16,9 @@ public class InfinityQSV2Repository : IInfinityQSV2Repository
|
||||
private readonly string _RepositoryName;
|
||||
private readonly IDbConnectionFactory _DBConnectionFactory;
|
||||
|
||||
public InfinityQSV2Repository(string mockRoot, IDbConnectionFactory dbConnectionFactory)
|
||||
public InfinityQSV2Repository(AppSettings appSettings, IDbConnectionFactory dbConnectionFactory)
|
||||
{
|
||||
_MockRoot = mockRoot;
|
||||
_MockRoot = appSettings.MockRoot;
|
||||
_DBConnectionFactory = dbConnectionFactory;
|
||||
_RepositoryName = nameof(InfinityQSV2Repository)[..^10];
|
||||
}
|
||||
|
@ -1,6 +1,9 @@
|
||||
using OI.Metrology.Server.Models;
|
||||
using OI.Metrology.Shared.DataModels;
|
||||
using OI.Metrology.Shared.Models;
|
||||
using OI.Metrology.Shared.Models.Stateless;
|
||||
using OI.Metrology.Shared.Repositories;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Data;
|
||||
using System.Data.Common;
|
||||
using System.Text;
|
||||
@ -13,13 +16,17 @@ public class InfinityQSV3Repository : IInfinityQSV3Repository
|
||||
|
||||
private readonly string _MockRoot;
|
||||
private readonly string _RepositoryName;
|
||||
private readonly IHttpClientFactory _HttpClientFactory;
|
||||
private readonly IDbConnectionFactory _DBConnectionFactory;
|
||||
private readonly string _OpenInsightApplicationProgrammingInterface;
|
||||
|
||||
public InfinityQSV3Repository(string mockRoot, IDbConnectionFactory dbConnectionFactory)
|
||||
public InfinityQSV3Repository(AppSettings appSettings, IDbConnectionFactory dbConnectionFactory, IHttpClientFactory httpClientFactory)
|
||||
{
|
||||
_MockRoot = mockRoot;
|
||||
_MockRoot = appSettings.MockRoot;
|
||||
_HttpClientFactory = httpClientFactory;
|
||||
_DBConnectionFactory = dbConnectionFactory;
|
||||
_RepositoryName = nameof(InfinityQSV3Repository)[..^10];
|
||||
_OpenInsightApplicationProgrammingInterface = appSettings.OpenInsightApplicationProgrammingInterface;
|
||||
}
|
||||
|
||||
string IInfinityQSV3Repository.GetCommandText(string subGroupId)
|
||||
@ -318,4 +325,131 @@ public class InfinityQSV3Repository : IInfinityQSV3Repository
|
||||
return result.ToString();
|
||||
}
|
||||
|
||||
private JsonElement[] GetAllReactorsAsJsonElementElement()
|
||||
{
|
||||
JsonElement[]? results;
|
||||
HttpClient httpClient = _HttpClientFactory.CreateClient();
|
||||
Task<string> task = httpClient.GetStringAsync($"{_OpenInsightApplicationProgrammingInterface}/reactors");
|
||||
task.Wait();
|
||||
JsonElement? jsonElement = JsonSerializer.Deserialize<JsonElement>(task.Result);
|
||||
if (jsonElement is null)
|
||||
throw new NullReferenceException(nameof(jsonElement));
|
||||
string json = jsonElement.Value.EnumerateObject().First().Value.ToString();
|
||||
results = JsonSerializer.Deserialize<JsonElement[]>(json);
|
||||
if (results is null)
|
||||
throw new NullReferenceException(nameof(results));
|
||||
return results;
|
||||
}
|
||||
|
||||
private ReadOnlyDictionary<int, Reactor> GetReactorsMatchingType(string? reactTypeFilter)
|
||||
{
|
||||
Dictionary<int, Reactor> results = new();
|
||||
string json;
|
||||
Reactor? reactor;
|
||||
JsonElement[]? jsonElements = GetAllReactorsAsJsonElementElement();
|
||||
foreach (JsonElement jsonElement in jsonElements)
|
||||
{
|
||||
json = jsonElement.EnumerateObject().First().Value.ToString();
|
||||
if (reactTypeFilter is not null && !json.Contains(reactTypeFilter))
|
||||
continue;
|
||||
try
|
||||
{ reactor = JsonSerializer.Deserialize(json, ReactorSourceGenerationContext.Default.Reactor); }
|
||||
catch (Exception) { reactor = null; }
|
||||
if (reactor is null || reactor.ReactType != reactTypeFilter)
|
||||
continue;
|
||||
results.Add(reactor.ReactorNo, reactor);
|
||||
}
|
||||
return new(results);
|
||||
}
|
||||
|
||||
string IInfinityQSV3Repository.GetCommandText(List<string> eppReactorNumbers)
|
||||
{
|
||||
StringBuilder result = new();
|
||||
_ = result
|
||||
.AppendLine(" select se.f_sgrp, ")
|
||||
.AppendLine(" dateadd(HH, -7, (dateadd(SS, convert(bigint, se.f_sgrp), '19700101'))) date_time, ")
|
||||
.AppendLine(" iq.pr_name, ")
|
||||
.AppendLine(" iq.pd_name, ")
|
||||
.AppendLine(" max(case ")
|
||||
.AppendLine(" when td.f_test = 1104769646 ")
|
||||
.AppendLine(" then se.f_val ")
|
||||
.AppendLine(" else null ")
|
||||
.AppendLine(" end) as iq_value, ")
|
||||
.AppendLine(" max(case ")
|
||||
.AppendLine(" when td.f_test = 1312288843 ")
|
||||
.AppendLine(" then se.f_val else null ")
|
||||
.AppendLine(" end) as iq_temp_offset_percent ")
|
||||
.AppendLine(" from ( ")
|
||||
.AppendLine(" select ")
|
||||
.AppendLine(" max(se.f_sgrp) se_max_sgrp, ")
|
||||
.AppendLine(" se.f_test se_test, ")
|
||||
.AppendLine(" pr.f_name pr_name, ")
|
||||
.AppendLine(" pd.f_name pd_name ")
|
||||
.AppendLine(" from [spcepiworld].[dbo].[sgrp_ext] se ")
|
||||
.AppendLine(" join [spcepiworld].[dbo].[prcs_dat] pr ")
|
||||
.AppendLine(" on se.f_prcs = pr.f_prcs ")
|
||||
.AppendLine(" join [spcepiworld].[dbo].[part_dat] pd ")
|
||||
.AppendLine(" on se.f_part = pd.f_part ")
|
||||
.AppendLine(" where se.f_flag = 0 ")
|
||||
.Append(" and pr.f_name in (").Append(string.Join(',', eppReactorNumbers)).AppendLine(") ")
|
||||
.AppendLine(" and pd.f_name = '1090 - Full Load' ")
|
||||
.AppendLine(" and se.f_test in (1104769646, 1312288843) ")
|
||||
.AppendLine(" group by se.f_test, ")
|
||||
.AppendLine(" pr.f_name, ")
|
||||
.AppendLine(" pd.f_name ")
|
||||
.AppendLine(" ) as iq ")
|
||||
.AppendLine(" join [spcepiworld].[dbo].[sgrp_ext] se ")
|
||||
.AppendLine(" on iq.se_max_sgrp = se.f_sgrp ")
|
||||
.AppendLine(" join [spcepiworld].[dbo].[test_dat] td ")
|
||||
.AppendLine(" on iq.se_test = td.f_test ")
|
||||
.AppendLine(" and se.f_test = td.f_test ")
|
||||
.AppendLine(" where se.f_flag = 0 ")
|
||||
.AppendLine(" and td.f_test in (1104769646, 1312288843) ")
|
||||
.AppendLine(" group by se.f_sgrp, ")
|
||||
.AppendLine(" iq.pr_name, ")
|
||||
.AppendLine(" iq.pd_name ")
|
||||
.AppendLine(" order by se.f_sgrp desc ")
|
||||
.AppendLine(" for json path; ");
|
||||
return result.ToString();
|
||||
}
|
||||
|
||||
string IInfinityQSV3Repository.GetEpiProTempVerification()
|
||||
{
|
||||
StringBuilder result;
|
||||
List<string> eppReactorNumbers = new();
|
||||
ReadOnlyDictionary<int, Reactor> eppReactors = GetReactorsMatchingType("EPP");
|
||||
foreach (KeyValuePair<int, Reactor> keyValuePair in eppReactors)
|
||||
eppReactorNumbers.Add($"'{keyValuePair.Key}'");
|
||||
if (!string.IsNullOrEmpty(_MockRoot))
|
||||
{
|
||||
string html = File.ReadAllText(Path.Combine(string.Concat(AppContext.BaseDirectory, _MockRoot), $"{_RepositoryName}-{nameof(IInfinityQSV3Repository.GetEpiProTempVerification)}.html"));
|
||||
result = new(html);
|
||||
}
|
||||
else
|
||||
{
|
||||
result = new();
|
||||
Reactor? reactor;
|
||||
IInfinityQSV3Repository infinityQSV3Repository = this;
|
||||
string commandText = infinityQSV3Repository.GetCommandText(eppReactorNumbers);
|
||||
StringBuilder stringBuilder = GetForJsonPath(_DBConnectionFactory, commandText);
|
||||
InfinityQS1090FullLoad[]? results = stringBuilder.Length == 0 ? Array.Empty<InfinityQS1090FullLoad>() : JsonSerializer.Deserialize(stringBuilder.ToString(), InfinityQS1090FullLoadArraySourceGenerationContext.Default.InfinityQS1090FullLoadArray);
|
||||
if (results is null)
|
||||
throw new NullReferenceException(nameof(results));
|
||||
foreach (InfinityQS1090FullLoad infinityQS1090FullLoad in results)
|
||||
{
|
||||
if (infinityQS1090FullLoad.Reactor is null || !eppReactors.TryGetValue(infinityQS1090FullLoad.Reactor.Value, out reactor))
|
||||
continue;
|
||||
_ = result.Append("<tr>").
|
||||
Append("<td>").Append(reactor.ReactorNo).Append("</td>").
|
||||
Append("<td class='").Append(reactor.E10State).Append("'>").Append(reactor.E10State).Append("</td>").
|
||||
Append("<td class='LoadedRDSCount").Append(reactor.LoadedRDS.Count).Append("'>").Append(reactor.LoadedRDS.Count == 0 ? "" : reactor.LoadedRDS[0]).Append("</td>").
|
||||
Append("<td>").Append(infinityQS1090FullLoad.Value).Append("</td>").
|
||||
Append("<td>").Append(infinityQS1090FullLoad.TemperatureOffsetPercentage).Append("</td>").
|
||||
Append("<td>").Append(infinityQS1090FullLoad.SubGroupIdFormated).Append("</td>").
|
||||
Append("</tr>");
|
||||
}
|
||||
}
|
||||
return result.ToString();
|
||||
}
|
||||
|
||||
}
|
@ -1,3 +1,4 @@
|
||||
using OI.Metrology.Server.Models;
|
||||
using OI.Metrology.Shared.DataModels;
|
||||
using OI.Metrology.Shared.Models.Stateless;
|
||||
using System.Text.Json;
|
||||
@ -11,9 +12,9 @@ public class PinRepository : IPinRepository
|
||||
private readonly string _RepositoryName;
|
||||
private readonly Dictionary<string, Dictionary<long, HeaderCommon>> _RdsToHeaderCommonCollection;
|
||||
|
||||
public PinRepository(string mockRoot)
|
||||
public PinRepository(AppSettings appSettings)
|
||||
{
|
||||
_MockRoot = mockRoot;
|
||||
_MockRoot = appSettings.MockRoot;
|
||||
_RdsToHeaderCommonCollection = new();
|
||||
_RepositoryName = nameof(PinRepository)[..^10];
|
||||
}
|
||||
|
@ -7,11 +7,6 @@ namespace OI.Metrology.Server.Repository;
|
||||
public class ServiceShopOrderRepository : IServiceShopOrderRepository
|
||||
{
|
||||
|
||||
private readonly ILogger<ServiceShopOrderRepository> _Logger;
|
||||
|
||||
public ServiceShopOrderRepository(ILogger<ServiceShopOrderRepository> logger) =>
|
||||
_Logger = logger;
|
||||
|
||||
private static ServiceShopOrder[] GetServiceShopOrders(Shared.Models.ServiceShop? serviceShop)
|
||||
{
|
||||
ServiceShopOrder[] result = IServiceShopOrder.GetServiceShopOrders(serviceShop);
|
||||
|
@ -1,3 +1,4 @@
|
||||
using OI.Metrology.Server.Models;
|
||||
using OI.Metrology.Shared.DataModels;
|
||||
using OI.Metrology.Shared.Models.Stateless;
|
||||
using OI.Metrology.Shared.Services;
|
||||
@ -13,9 +14,9 @@ public class ToolTypesRepository : IToolTypesRepository
|
||||
private readonly string _MockRoot;
|
||||
private readonly string _RepositoryName;
|
||||
|
||||
public ToolTypesRepository(string mockRoot)
|
||||
public ToolTypesRepository(AppSettings appSettings)
|
||||
{
|
||||
_MockRoot = mockRoot;
|
||||
_MockRoot = appSettings.MockRoot;
|
||||
_RepositoryName = nameof(ToolTypesRepository)[..^10];
|
||||
}
|
||||
|
||||
|
@ -1,3 +1,4 @@
|
||||
using OI.Metrology.Server.Models;
|
||||
using OI.Metrology.Shared.DataModels;
|
||||
using OI.Metrology.Shared.Models.Stateless;
|
||||
using OI.Metrology.Shared.Repositories;
|
||||
@ -16,9 +17,9 @@ public class WorkMaterialRepository : IWorkMaterialRepository
|
||||
private readonly string _RepositoryName;
|
||||
private readonly IDbConnectionFactory _DBConnectionFactory;
|
||||
|
||||
public WorkMaterialRepository(string mockRoot, IDbConnectionFactory dbConnectionFactory)
|
||||
public WorkMaterialRepository(AppSettings appSettings, IDbConnectionFactory dbConnectionFactory)
|
||||
{
|
||||
_MockRoot = mockRoot;
|
||||
_MockRoot = appSettings.MockRoot;
|
||||
_DBConnectionFactory = dbConnectionFactory;
|
||||
_RepositoryName = nameof(WorkMaterialRepository)[..^10];
|
||||
}
|
||||
|
Reference in New Issue
Block a user