diff --git a/DBPatch/sqlScripts/dacpac/SystemX.DB.AccountDB.dacpac b/DBPatch/sqlScripts/dacpac/SystemX.DB.AccountDB.dacpac index 1fe1660..da184b7 100644 Binary files a/DBPatch/sqlScripts/dacpac/SystemX.DB.AccountDB.dacpac and b/DBPatch/sqlScripts/dacpac/SystemX.DB.AccountDB.dacpac differ diff --git a/DBPatch/sqlScripts/dacpac/SystemX.DB.CPXV2.dacpac b/DBPatch/sqlScripts/dacpac/SystemX.DB.CPXV2.dacpac index 023540b..3d50610 100644 Binary files a/DBPatch/sqlScripts/dacpac/SystemX.DB.CPXV2.dacpac and b/DBPatch/sqlScripts/dacpac/SystemX.DB.CPXV2.dacpac differ diff --git a/DBPatch/sqlScripts/dacpac/SystemX.DB.CPXV2Log.dacpac b/DBPatch/sqlScripts/dacpac/SystemX.DB.CPXV2Log.dacpac index b979d21..43c8247 100644 Binary files a/DBPatch/sqlScripts/dacpac/SystemX.DB.CPXV2Log.dacpac and b/DBPatch/sqlScripts/dacpac/SystemX.DB.CPXV2Log.dacpac differ diff --git a/DBPatch/sqlScripts/dacpac/SystemX.DB.UniqueKeyDB.dacpac b/DBPatch/sqlScripts/dacpac/SystemX.DB.UniqueKeyDB.dacpac index d30f09d..5688695 100644 Binary files a/DBPatch/sqlScripts/dacpac/SystemX.DB.UniqueKeyDB.dacpac and b/DBPatch/sqlScripts/dacpac/SystemX.DB.UniqueKeyDB.dacpac differ diff --git a/DBPatch/sqlScripts/dacpac/SystemX.DB.VPKI_DataDB.dacpac b/DBPatch/sqlScripts/dacpac/SystemX.DB.VPKI_DataDB.dacpac index bc0514f..606e544 100644 Binary files a/DBPatch/sqlScripts/dacpac/SystemX.DB.VPKI_DataDB.dacpac and b/DBPatch/sqlScripts/dacpac/SystemX.DB.VPKI_DataDB.dacpac differ diff --git a/Projects/DLL/SystemX.Core.DB.dll b/Projects/DLL/SystemX.Core.DB.dll index 74eb067..942993d 100644 Binary files a/Projects/DLL/SystemX.Core.DB.dll and b/Projects/DLL/SystemX.Core.DB.dll differ diff --git a/Projects/DLL/SystemX.Core.dll b/Projects/DLL/SystemX.Core.dll index fc5c005..045260d 100644 Binary files a/Projects/DLL/SystemX.Core.dll and b/Projects/DLL/SystemX.Core.dll differ diff --git a/Projects/WebClient/Web.Tra/Components/Module/TraGrid.razor b/Projects/WebClient/Web.Tra/Components/Module/TraGrid.razor new file mode 100644 index 0000000..b57b030 --- /dev/null +++ b/Projects/WebClient/Web.Tra/Components/Module/TraGrid.razor @@ -0,0 +1,181 @@ +@typeparam TDataModel where TDataModel : IDataModel + +@inject ContextMenuService ContextMenuService + + + + + @if (VisibleRowNo == true) + { + + + + } + + @foreach (var col in typeof(TDataModel).GetProperties()) + { + if (col.Name.ToLower().Equals("rn") || col.Name.ToLower().Equals("stepversion")) + continue; + + if (col.Name.ToLower().Equals("testdate")) + { + + + + } + else if (col.Name.ToLower().Equals("ok")) + { + + + + } + else if (col.Name.ToLower().Equals("ng")) + { + + + + } + else + { + + + } + } + + + +@code { + [Parameter] + public IEnumerable DataList { get; set; } + + [Parameter] + public EventCallback OnSelectRow { get; set; } + + [Parameter] + public EventCallback OnClickContextMenu { get; set; } + + [Parameter] + public bool VisibleRowNo { get; set; } + + [Parameter] + public bool HostColumnMerge { get; set; } + + private IList SelectedRow; + + private void CellRender(DataGridCellRenderEventArgs args) + { + if (args.Column.Property == null) + return; + + //testdate 컬럼일때 날짜 병합 + if (args.Column.Property.ToLower().Equals("testdate")) + { + var properties = typeof(TDataModel).GetProperties().ToList(); + + var testDate = properties.Find(x => x.Name.ToLower() == "testdate"); + var host = properties.Find(x => x.Name.ToLower() == "host"); + var section = properties.Find(x => x.Name.ToLower() == "section"); + + if (testDate != null && host != null && section != null) + { + var rowTestDate = testDate.GetValue(args.Data); + var rowHost = host.GetValue(args.Data); + var rowSection = section.GetValue(args.Data); + + var data = DataList.First(x => (DateTime?)testDate.GetValue(x) == (DateTime?)rowTestDate); + if (data != null) + { + var dataTestDate = testDate.GetValue(data); + var dataHost = host.GetValue(data); + var dataSection = section.GetValue(data); + + if (rowHost == dataHost && rowSection == dataSection) + { + int rowCount = DataList.Count(x => (DateTime?)testDate.GetValue(x) == (DateTime?)rowTestDate); + + args.Attributes.Add("rowspan", rowCount); + } + } + } + } + + //host merge 옵션 + if (HostColumnMerge == true) + { + if (args.Column.Property.ToLower().Equals("host")) + { + var properties = typeof(TDataModel).GetProperties().ToList(); + + var testDate = properties.Find(x => x.Name.ToLower() == "testdate"); + var host = properties.Find(x => x.Name.ToLower() == "host"); + var section = properties.Find(x => x.Name.ToLower() == "section"); + + if (testDate != null && host != null && section != null) + { + var rowTestDate = testDate.GetValue(args.Data); + var rowHost = host.GetValue(args.Data); + var rowSection = section.GetValue(args.Data); + + var data = DataList.First(x => host.GetValue(x).ToString() == rowHost.ToString()); + if (data != null) + { + var dataTestDate = testDate.GetValue(data); + var dataHost = host.GetValue(data); + var dataSection = section.GetValue(data); + + if (rowHost == dataHost && rowSection == dataSection) + { + int rowCount = DataList.Count(x => host.GetValue(x).ToString() == rowHost.ToString()); + + args.Attributes.Add("rowspan", rowCount); + } + } + } + } + } + } + + private async Task OnCellContextMenu(DataGridCellMouseEventArgs args) + { + SelectedRow = new List() { args.Data }; + + ContextMenuService.Open(args, + new List { + new ContextMenuItem(){ Text = "Overview", Value = 1, Icon = "home" }, + new ContextMenuItem(){ Text = "Detail Overview", Value =2 , Icon = "assessment" }, + new ContextMenuItem(){ Text = "Test History", Value = 3, Icon = "description" }, + new ContextMenuItem(){ Text = "Test Summary", Value = 4, Icon = "assignment_turned_in" }, + new ContextMenuItem(){ Text = "Detail Data", Value = 5, Icon = "list" }, + new ContextMenuItem(){ Text = "Test-Error/Extended Search", Value = 6, Icon = "search" }, + }, + (e) => + { + ContextMenuService.Close(); + OnClickContextMenu.InvokeAsync(); + } + ); + + await OnSelectRow.InvokeAsync(args.Data); + } + + private async Task SelectRow(TDataModel data) + { + await OnSelectRow.InvokeAsync(data); + StateHasChanged(); + } +} diff --git a/Projects/WebClient/Web.Tra/Components/Pages/TRA.razor b/Projects/WebClient/Web.Tra/Components/Pages/TRA.razor index 7f7877c..31aeabd 100644 --- a/Projects/WebClient/Web.Tra/Components/Pages/TRA.razor +++ b/Projects/WebClient/Web.Tra/Components/Pages/TRA.razor @@ -9,11 +9,11 @@ - + - + @@ -25,13 +25,131 @@ + + + +@* + + @foreach (var tab in ListTabs) + { + + + + @if (tab.Key == EnumTabs.OverviewC1.ToString()) + { + + + } + + @if (tab.Key == EnumTabs.OverviewC1Detail.ToString()) + { + + + } + + @if (tab.Key.Contains(EnumTabs.TestHistoryC1.ToString())) + { + + + } + + + } + + + *@ @code { + private RequestSearch RequestSearch = new RequestSearch(); + + RadzenTabs tabs; + protected override async Task OnInitializedAsync() { } private async Task OnSearch() { - await CPXV2LogService.Test(); + //날짜 오류 + if(RequestSearch.SearchStart > RequestSearch.SearchEnd) + { + LogXnet.WriteLine("DateTime Set Error", LogXLabel.Error); + return; + } + + Overviews = await CPXV2LogService.GetOverview(RequestSearch); + } + + int SelectedTabIndex = 0; + Dictionary ListTabs = new Dictionary(); + List Overviews = new List(); + List DetailOverviews = new List(); + // List TestHistories = new List(); + + protected override void OnInitialized() + { + + } + + protected override void OnAfterRender(bool firstRender) + { + + } + + protected override void OnParametersSet() + { + + // var searchData = OverviewService.SearchOverview(); + //Overviews = searchData; + + // if (ListTabs.ContainsKey(EnumTabs.OverviewC1.ToString()) == false) + // ListTabs.Add($"{EnumTabs.OverviewC1}", EnumTabs.OverviewC1); + } + + private void OnSelectRowOverview(Overview overview) + { + // if (SelectedTabIndex < 0) + // SelectedTabIndex = 0; + + // SelectedDataService.SetSelectedOverview(overview); + } + + private void OnClickDetailOverviewContextMenu() + { + // DetailOverviews = OverviewService.SearchDetailOverview(SelectedDataService.SelectedOverview); + + // if (ListTabs.ContainsKey(EnumTabs.OverviewC1Detail.ToString()) == false) + // ListTabs.Add($"{EnumTabs.OverviewC1Detail.ToString()}", EnumTabs.OverviewC1Detail); + // tabs.Reload(); + + // SelectedTabIndex = ListTabs.Keys.ToList().IndexOf(EnumTabs.OverviewC1Detail.ToString()); + } + + private void OnClickHistoryContextMenu() + { + // TestHistories = OverviewService.SearchTestHistory(SelectedDataService.SelectedOverview); + + // int index = ListTabs.Count(x => x.Key.Contains(EnumTabs.TestHistoryC1.ToString())) + 1; + + // ListTabs.Add($"{EnumTabs.TestHistoryC1}({index})", EnumTabs.TestHistoryC1); + // tabs.Reload(); + + // SelectedTabIndex = ListTabs.Keys.ToList().IndexOf($"{EnumTabs.TestHistoryC1}({index})"); + } + + void OnClickClose(string tabKey) + { + if (ListTabs.ContainsKey(tabKey)) + { + ListTabs.Remove(tabKey); + if (SelectedTabIndex >= ListTabs.Count) + SelectedTabIndex = ListTabs.Count - 1; + } + tabs.Reload(); } } \ No newline at end of file diff --git a/Projects/WebClient/Web.Tra/Components/_Imports.razor b/Projects/WebClient/Web.Tra/Components/_Imports.razor index c569c68..8935bd4 100644 --- a/Projects/WebClient/Web.Tra/Components/_Imports.razor +++ b/Projects/WebClient/Web.Tra/Components/_Imports.razor @@ -8,6 +8,9 @@ @using Microsoft.JSInterop @using Web.Tra @using Web.Tra.Components +@using Web.Tra.Model +@using Web.Tra.Model.Enum +@using Web.Tra.Components.Module @using Radzen -@using Radzen.Blazor \ No newline at end of file +@using Radzen.Blazor diff --git a/Projects/WebClient/Web.Tra/Extended/ObjectExtended.cs b/Projects/WebClient/Web.Tra/Extended/ObjectExtended.cs new file mode 100644 index 0000000..ba19b90 --- /dev/null +++ b/Projects/WebClient/Web.Tra/Extended/ObjectExtended.cs @@ -0,0 +1,60 @@ +using Web.Tra.Model; + +public static class ObjectExtend +{ + public static Overview ToOverview(this IEnumerable data) + { + return new Overview + { + TestDate = data.Max(x => x.Summary.TestDT.Date), + StationName = data.Last().Summary.StationName, + Host = data.Last().Summary.HostID, + Section = data.Last().Summary.Section, + ModelName = data.Last().TestInfo?.PROD_Group?.ModelName, + TestType = data.Last().Summary.TestType, + ProductNo = data.Last().Summary.ProdNo_C, + TestCode = data.Last().Summary.Testcode, + ParentNo = data.GroupBy(x => x.Summary.TestListCntID).Last().Last().Summary.ProdNo_P, + TestListFileNo = data.GroupBy(x => x.Summary.TestListCntID).Last().Last().Summary.TestListFileNo, + TestListVariantNo = data.GroupBy(x => x.Summary.TestListCntID).Last().Last().Summary.TestListVariantNo, + FileCode = data.Last().Summary.ProdCode, + FileVersion = data.Last().Summary.Version, + StepVersion = data.Last().Summary.StepVersion, + FirstTestTime = data.GroupBy(x => x.Summary.TestListCntID).Last().Min(y => y.Summary.TestDT).ToString("HH:mm:ss"), + FinalTestTime = data.GroupBy(x => x.Summary.TestListCntID).Last().Max(y => y.Summary.TestDT).ToString("HH:mm:ss"), + Total = data.GroupBy(x => (x.Summary.TestListCntID, x.Summary.TestDT.Date)).Last().Count(), + OK = data.GroupBy(x => (x.Summary.TestListCntID, x.Summary.TestDT.Date)).Last().Count(y => y.Summary.Result.ToLower().Equals("ok")), + NG = data.GroupBy(x => (x.Summary.TestListCntID, x.Summary.TestDT.Date)).Last().Count(y => !y.Summary.Result.ToLower().Equals("ok")), + RN = 0, + TestListCntID = data.Last().Summary.TestListCntID + }; + } + + public static Overview ToDetailOverview(this IEnumerable data) + { + return data.ToOverview(); + } + + public static TestHistory ToTestHistory(this IEnumerable data) + { + return new TestHistory + { + No = data.Last().Summary.No, + TestDateTime = data.Last().Summary.TestDT, + StationName = data.Last().Summary.StationName, + Host = data.Last().Summary.HostID, + Section = data.Last().Summary.Section, + ProductID = data.Last().Summary.ProductID, + TestType = data.Last().Summary.TestType, + ProductNo = data.Last().Summary.ProdNo_C, + TestCode = data.Last().Summary.Testcode, + ParentNo = data.Last().Summary.ProdNo_P, + FileCode = data.Last().Summary.ProdCode, + FileVersion = data.Last().Summary.Version, + StepVersion = data.Last().Summary.StepVersion, + Duration = data.Last().Summary.Duration, + TestResult = data.Last().Summary.Result, + TestlistReqID = data.Last().Summary.TestListCntID, + }; + } +} \ No newline at end of file diff --git a/Projects/WebClient/Web.Tra/Model/Enum/EnumTabs.cs b/Projects/WebClient/Web.Tra/Model/Enum/EnumTabs.cs new file mode 100644 index 0000000..36f02d2 --- /dev/null +++ b/Projects/WebClient/Web.Tra/Model/Enum/EnumTabs.cs @@ -0,0 +1,11 @@ +namespace Web.Tra.Model.Enum +{ + public enum EnumTabs + { + None = 0, + OverviewC1 = 10, + OverviewC1Detail = 20, + TestHistoryC1 = 30, + End = 10000 + } +} diff --git a/Projects/WebClient/Web.Tra/Model/IDataModel.cs b/Projects/WebClient/Web.Tra/Model/IDataModel.cs new file mode 100644 index 0000000..941c3dd --- /dev/null +++ b/Projects/WebClient/Web.Tra/Model/IDataModel.cs @@ -0,0 +1,6 @@ +namespace Web.Tra.Model +{ + public interface IDataModel + { + } +} diff --git a/Projects/WebClient/Web.Tra/Model/Overview.cs b/Projects/WebClient/Web.Tra/Model/Overview.cs new file mode 100644 index 0000000..ff2ffeb --- /dev/null +++ b/Projects/WebClient/Web.Tra/Model/Overview.cs @@ -0,0 +1,27 @@ +namespace Web.Tra.Model +{ + public class Overview : IDataModel + { + public DateTime? TestDate { get; set; } + public string StationName { get; set; } + public string Host { get; set; } + public string Section { get; set; } + public string ModelName { get; set; } + public string TestType { get; set; } + public string ProductNo { get; set; } + public string TestCode { get; set; } + public string ParentNo { get; set; } + public int? TestListFileNo { get; set; } + public int? TestListVariantNo { get; set; } + public string FileCode { get; set; } + public string FileVersion { get; set; } + public int? StepVersion { get; set; } + public string FirstTestTime { get; set; } + public string FinalTestTime { get; set; } + public int Total { get; set; } + public int OK { get; set; } + public int NG { get; set; } + public int RN { get; set; } + public string TestListCntID { get; set; } + } +} diff --git a/Projects/WebClient/Web.Tra/Model/SearchData.cs b/Projects/WebClient/Web.Tra/Model/SearchData.cs new file mode 100644 index 0000000..8399601 --- /dev/null +++ b/Projects/WebClient/Web.Tra/Model/SearchData.cs @@ -0,0 +1,26 @@ +using SystemX.Core.DB; + +namespace Web.Tra.Model +{ + public class RequestSearch() + { + public DateOnly SearchStart { get; set; } = DateOnly.FromDateTime(DateTime.Now.AddDays(-7)); + public DateOnly SearchEnd { get; set; } = DateOnly.FromDateTime(DateTime.Now); + } + + public class SearchData + { + //CPXV2 + public TestInfo TestInfo { get; set; } + + //Log + public HIST_LogSummary Summary { get; set; } + public HIST_TestResult TestResult { get; set; } + } + + public class TestInfo + { + public PROD_Group PROD_Group { get; set; } + public PROD_Variant PROD_Variant { get; set; } + } +} diff --git a/Projects/WebClient/Web.Tra/Model/TestHistory.cs b/Projects/WebClient/Web.Tra/Model/TestHistory.cs new file mode 100644 index 0000000..c206e82 --- /dev/null +++ b/Projects/WebClient/Web.Tra/Model/TestHistory.cs @@ -0,0 +1,22 @@ +namespace Web.Tra.Model +{ + public class TestHistory : IDataModel + { + public long No { get; set; } + public DateTime TestDateTime { get; set; } + public string StationName { get; set; } + public string Host { get; set; } + public string Section { get; set; } + public string ProductID { get; set; } + public string TestType { get; set; } + public string ProductNo { get; set; } + public string TestCode { get; set; } + public string ParentNo { get; set; } + public string FileCode { get; set; } + public string FileVersion { get; set; } + public int? StepVersion { get; set; } + public string Duration { get; set; } + public string TestResult { get; set; } + public string TestlistReqID { get; set; } + } +} diff --git a/Projects/WebClient/Web.Tra/Services/CPXV2LogService.cs b/Projects/WebClient/Web.Tra/Services/CPXV2LogService.cs index d66f630..6c2a972 100644 --- a/Projects/WebClient/Web.Tra/Services/CPXV2LogService.cs +++ b/Projects/WebClient/Web.Tra/Services/CPXV2LogService.cs @@ -3,6 +3,7 @@ using Microsoft.EntityFrameworkCore; using System.Data; using SystemX.Core.DB; using SystemX.Core.Services; +using Web.Tra.Model; using WebClient.Library.Config; namespace Web.Tra.Services @@ -17,8 +18,33 @@ namespace Web.Tra.Services _scopeFactory = scopeFactory; _configService = configService; } - public async Task Test() + + //Get Overview + public async Task> GetOverview(RequestSearch request) { + List overview = new List(); + + int startYear = request.SearchStart.Year; + int endYear = request.SearchEnd.Year; + + //search log + List SearchLogList = new List(); + for (int i = startYear; i <= endYear; i++) + { + using (var scope = _scopeFactory.CreateScope()) + { + var provider = scope.ServiceProvider.GetRequiredService(); + using (var context = GetDBContext(provider, i)) + { + if (context is not null) + { + SearchLogList.AddRange(await context.HIST_LogSummaries.Where(x => request.SearchStart <= DateOnly.FromDateTime(x.TestDT) && DateOnly.FromDateTime(x.TestDT) <= request.SearchEnd).ToListAsync()); + } + } + } + } + + //search testlist using (var scope = _scopeFactory.CreateScope()) { var provider = scope.ServiceProvider.GetRequiredService(); @@ -26,88 +52,49 @@ namespace Web.Tra.Services { if (context is not null) { + var varProdVariant = context.PROD_Variants.ToList(); + var varProudGroup = context.PROD_Groups.ToList(); + var TesetInfoList = varProdVariant.Select(x => new TestInfo + { + PROD_Variant = x, + PROD_Group = varProudGroup.Find(y => y.No == x.GroupNo) + }).ToList(); + + var search = SearchLogList.Select(x => new SearchData + { + Summary = x, + TestInfo = TesetInfoList.Find(y => y.PROD_Variant.No == x.TestListVariantNo) + }); + + var ListSearchData = search + .Where(x => x.Summary.TestListVariantNo > 0) + .OrderBy(x => x.Summary.TestDT).ToList(); + + var group = ListSearchData + .GroupBy(x => (x.Summary.HostID, x.Summary.Section)) + .Select(x => x.ToOverview()) + .OrderBy(x => x.Host); + + overview.AddRange(group); } } } - using (var scope = _scopeFactory.CreateScope()) - { - var provider = scope.ServiceProvider.GetRequiredService(); - using (var context = GetDBContext(provider, 2023)) - { - if (context is not null) - { - } - } - } - - using (var scope = _scopeFactory.CreateScope()) - { - var provider = scope.ServiceProvider.GetRequiredService(); - using (var context = GetDBContext(provider, 2024)) - { - if (context is not null) - { - } - } - } + return overview.OrderBy(x=>x.TestDate).ToList(); } - + + //Get DBContext private T? GetDBContext(DbContextProvider provider, int dbID) where T : DbContext { - var findDB = provider.DBDictionary.Keys.First(x => x.Contains(dbID.ToString())); - if(string.IsNullOrEmpty(findDB) == false) + var contextName = typeof(T).Name; + + var findDB = provider.DBDictionary.Values.First(x => x.DBID == dbID); + if(findDB is not null) { - if (provider.DBDictionary.TryGetValue(findDB, out var dbContext)) - { - return provider?.GetDBContext($"{dbContext.DBName}"); - } + return provider?.GetDBContext($"{findDB.DBName}"); } return null; - } - - //public async Task Request_SelectUniqueKey(Request_SelectUniqueKey request, string guid = "") - //{ - // Response_SelectUniqueKy response = new Response_SelectUniqueKy(); - - // if (request != null) - // { - // response.Identity = request.Identity; - // using (var scope = _scopeFactory.CreateScope()) - // { - // var provider = scope.ServiceProvider.GetRequiredService(); - // using (var context = GetUniqueKeyDBContext(provider, 1)) - // { - // if (context is not null) - // { - // try - // { - // using (var transaction = await context.CreateTransactionAsync(IsolationLevel.ReadUncommitted)) - // { - // var data = await context.tUniqueKeyStorages.AsNoTracking().FirstOrDefaultAsync(x => x.cIdentity == request.Identity); - // await context.CloseTransactionAsync(transaction); - // if (data != null) - // { - // response.Data1 = data.cData1; - // response.Data2 = data.cData2; - // response.Data3 = data.cData3; - // response.Data4 = data.cData4; - // response.Data5 = data.cData5; - // } - // } - // } - // catch (Exception e) - // { - // LogXnet.WriteLine($"Select Unique Key Transaction Error::{guid}", LogXLabel.Error); - // LogXnet.WriteLine(e); - // } - // } - // } - // } - // } - - // return response; - //} + } } }