diff --git a/InfoDetail.xaml.cs b/InfoDetail.xaml.cs index 00923d9..1ba4739 100644 --- a/InfoDetail.xaml.cs +++ b/InfoDetail.xaml.cs @@ -8,7 +8,7 @@ namespace SunlightAggregationTerminal; public partial class InfoDetail : ContentPage { public static ObservableCollection InfoProbuctItems { get; set; } = new(); - public static ObservableCollection InfoDyelotItems { get; set; } = new(); + public static ObservableCollection InfoDyelotDetailsItems { get; set; } = new(); public InfoDetail(InfoItem item) { InitializeComponent(); @@ -20,75 +20,47 @@ public partial class InfoDetail : ContentPage InfoProbuctItems.Add(new ProbuctItem { ProductName = "afars", ProductCode = "cs", ProductState = "", ProductInf = "" }); - InfoDyelotItems.Add(new DyelotItem { Dyelot = "2134566", Machine = "g01", CreationTime = "", CallTime = "" , + InfoDyelotDetailsItems.Add(new DyelotDetailsItem + { Dyelot = "2134566", Machine = "g01", CreationTime = "", CallTime = "" , ReDye="0", - Step = "0", - FabricName = "21345122343566", - ColorName = "g01", - CustomerName = "", - EndTime = "", - StartTime = "", Information = "yyjjy\nfxfxdsdg\n", - }); - InfoDyelotItems.Add(new DyelotItem + }); + InfoDyelotDetailsItems.Add(new DyelotDetailsItem { - Step = "3", Dyelot = "231423134566", Machine = "g01", CreationTime = "", CallTime = "", - FabricName = "2134566", - ColorName = "g01", - CustomerName = "", - EndTime = "", - StartTime = "", Information = "yyjjy\nfxfxdsdg\n", }); - InfoDyelotItems.Add(new DyelotItem + InfoDyelotDetailsItems.Add(new DyelotDetailsItem { - Step = "3", Dyelot = "2131324354566", Machine = "g01", CreationTime = "", CallTime = "", - FabricName = "2134566", - ColorName = "g01", - CustomerName = "", - EndTime = "", - StartTime = "", Information = "yyjjy\nfxfxdsdg\n", }); - InfoDyelotItems.Add(new DyelotItem + InfoDyelotDetailsItems.Add(new DyelotDetailsItem { Dyelot = "2134123243566", Machine = "g01", CreationTime = "", CallTime = "", - FabricName = "2134566", - ColorName = "g01", - CustomerName = "", - EndTime = "", - StartTime = "", Information = "yyjjy\nfxfxdsdg\n", }); - InfoDyelotItems.Add(new DyelotItem + InfoDyelotDetailsItems.Add(new DyelotDetailsItem { Dyelot = "2134566", Machine = "g01", CreationTime = "", - CallTime = "", - FabricName = "2134566", - ColorName = "g01", - CustomerName = "", - EndTime = "", - StartTime = "", Information = "yyjjy\nfxfxdsdg\n", }); CardCollectionView_machine.ItemsSource = InfoProbuctItems; - CardCollectionView_history.ItemsSource = InfoDyelotItems; + CardCollectionView_history.ItemsSource = InfoDyelotDetailsItems; } private void Button_real(object sender, EventArgs e) diff --git a/Models/DataSource.cs b/Models/DataSource.cs index ae923bb..f336eac 100644 --- a/Models/DataSource.cs +++ b/Models/DataSource.cs @@ -48,18 +48,31 @@ namespace SunlightAggregationTerminal.Models public string? ProductState { get; set; } public string? ProductInf { get; set; } } - public class DyelotItem { public string? Dyelot { get; set; } public string? ReDye { get; set; } - public string? Step { get; set; } public string? Machine { get; set; } public string? CreationTime { get; set; } - public string? CallTime { get; set; } public string? FabricName { get; set; } public string? ColorName { get; set; } public string? CustomerName { get; set; } + public string? Information { get; set; } + } + public class DyelotDetailsItem + { + public string? Dyelot { get; set; } + public string? ReDye { get; set; } + public string? Step { get; set; } + public string? ProductName { get; set; } + public string? ProductCode { get; set; } + public string? ProductType { get; set; } + public string? ProductProgram { get; set; } + public string? DispenserGram { get; set; } + public string? Gram { get; set; } + public string? Machine { get; set; } + public string? CreationTime { get; set; } + public string? CallTime { get; set; } public string? EndTime { get; set; } public string? StartTime { get; set; } public string? Information { get; set; } diff --git a/QueryDetail.xaml b/QueryDetail.xaml new file mode 100644 index 0000000..d2fef09 --- /dev/null +++ b/QueryDetail.xaml @@ -0,0 +1,83 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/QueryDetail.xaml.cs b/QueryDetail.xaml.cs new file mode 100644 index 0000000..1a5c0dd --- /dev/null +++ b/QueryDetail.xaml.cs @@ -0,0 +1,96 @@ +using SunlightAggregationTerminal.Models; +using System.Collections.ObjectModel; + +namespace SunlightAggregationTerminal; + +public partial class QueryDetail : ContentPage +{ + public static ObservableCollection QueryDetailDyelotDetailsItems { get; set; } = new(); + public static ObservableCollection QueryDetailDyelotDetailsItemst { get; set; } = new(); + public QueryDetail(DyelotItem item) + { + + + InitializeComponent(); + + QueryDetailDyelotDetailsItems.Add(new DyelotDetailsItem + { + Dyelot = "2134566", + Machine = "g01", + Step="3", + CreationTime = "", + DispenserGram="32434", + Gram = "3212", + ReDye = "0", + ProductName="sdvsf1", + Information = "yyjjy\nfxfxdsdg\n", + }); + QueryDetailDyelotDetailsItems.Add(new DyelotDetailsItem + { + Dyelot = "2134566", + Machine = "g01", + Step = "3", + CreationTime = "", + DispenserGram = "32423434", + Gram = "3212434", + ReDye = "0", + ProductName = "sdvsf2", + Information = "yyjjy\nfxfxdsdg\n", + }); + QueryDetailDyelotDetailsItems.Add(new DyelotDetailsItem + { + Dyelot = "2134566", + Machine = "g01", + CreationTime = "", + DispenserGram = "3212434", + Gram= "3212434", + Step = "4", + ReDye = "0", + ProductName = "sdvsf3", + Information = "yyjjy\nfxfxdsdg\n", + }); + + Data_(); + + + } + + private void Data_() + { + + var processedList = QueryDetailDyelotDetailsItems + .GroupBy(item => new + { + // 建议加上 ?.Trim() 防止空格和 null 导致的分组偏差 + Dyelot = item.Dyelot?.Trim(), + Step = item.Step?.Trim() + }) + .Select(g => + { + var firstItem = g.First(); + // 提取该组内所有的 ProductName 并转为字符串 + // 提取该组内所有的 Gram,安全地转为字符串(防止 null 报错) + // 将两者用 Zip 方法一一配对,拼接成 "ProductName(Gram)" 的格式 + // 如果只想简单的全部堆在一起,也可以直接用 string.Join(",", productNames.Concat(grams)) + var productNames = g.Select(x => x.ProductName); + var grams = g.Select(x => x.Gram?.ToString()); + var dispenserGrams = g.Select(x => x.DispenserGram?.ToString()); + // 使用 Zip 将三者一一配对,拼接成 "名称(Gram/dispenserGram)" 的格式 + var combinedInfo = string.Join("\n",productNames.Zip(grams, (name, gram) => (name, gram)) // 先把前两个拼成元组 + .Zip(dispenserGrams, (pair, dispGram) => $"原料:{pair.name}\n目标用量:{pair.gram}g\n实际用量:{dispGram}g")); + + // 赋值给最终展示的 ProductName + firstItem.ProductName = combinedInfo; + return firstItem; + }) + .ToList(); // 强制立刻执行查询 + + // 更新 UI 绑定的 ObservableCollection + QueryDetailDyelotDetailsItems.Clear(); + foreach (var item in processedList) + { + QueryDetailDyelotDetailsItems.Add(item); + } + CardCollectionView_data.ItemsSource = QueryDetailDyelotDetailsItems; + } +} \ No newline at end of file diff --git a/QueryPage.xaml b/QueryPage.xaml index ec31c88..e61c112 100644 --- a/QueryPage.xaml +++ b/QueryPage.xaml @@ -34,8 +34,7 @@ - diff --git a/QueryPage.xaml.cs b/QueryPage.xaml.cs index 01081c9..0339f0b 100644 --- a/QueryPage.xaml.cs +++ b/QueryPage.xaml.cs @@ -18,6 +18,16 @@ public partial class QueryPage : ContentPage { ResultEntry.Text = scannedValue; }); + + DyelotItems.Add(new DyelotItem + { + Dyelot = "2134566", + Machine = "g01", + CreationTime = "", + ReDye = "0", + Information = "yyjjy\nfxfxdsdg\n", + }); + CardCollectionView.ItemsSource = DyelotItems; } private async void OnScanButtonClicked(object sender, EventArgs e) { @@ -33,7 +43,7 @@ public partial class QueryPage : ContentPage if (context is DyelotItem item) { - //await Navigation.PushAsync(new QueryDetail(item)); + await Navigation.PushAsync(new QueryDetail(item)); } } } diff --git a/SunlightAggregationTerminal.csproj b/SunlightAggregationTerminal.csproj index 0d56272..cd23f38 100644 --- a/SunlightAggregationTerminal.csproj +++ b/SunlightAggregationTerminal.csproj @@ -47,6 +47,10 @@ 10.0.17763.0 + + False + + @@ -122,6 +126,9 @@ MSBuild:Compile + + MSBuild:Compile + MSBuild:Compile