7 changed files with 223 additions and 43 deletions
@ -0,0 +1,83 @@ |
|||||
|
<?xml version="1.0" encoding="utf-8" ?> |
||||
|
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui" |
||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" |
||||
|
x:Class="SunlightAggregationTerminal.QueryDetail" |
||||
|
Title="细节"> |
||||
|
<Grid RowDefinitions="Auto, *" > |
||||
|
<Grid BackgroundColor="#CCCCCC" Padding="10" Grid.Row="0" Grid.Column="0"> |
||||
|
<VerticalStackLayout> |
||||
|
<HorizontalStackLayout> |
||||
|
<Label Text="工单: " FontAttributes="Bold" FontSize="22" TextColor="Black"/> |
||||
|
<Label Text="{Binding Dyelot}" FontAttributes="Bold" FontSize="22" TextColor="Gray"/> |
||||
|
<Label Text="@" FontAttributes="Bold" FontSize="22" TextColor="Black"/> |
||||
|
<Label Text="{Binding ReDye}" FontAttributes="Bold" FontSize="22" TextColor="Gray"/> |
||||
|
</HorizontalStackLayout> |
||||
|
<HorizontalStackLayout> |
||||
|
<Label Text="机台: " FontAttributes="Bold" FontSize="22" TextColor="Black"/> |
||||
|
<Label Text="{Binding Machine}" FontAttributes="Bold" FontSize="22" TextColor="Gray"/> |
||||
|
</HorizontalStackLayout> |
||||
|
<HorizontalStackLayout> |
||||
|
<Label Text="下单时间: " FontAttributes="Bold" FontSize="22" TextColor="Black"/> |
||||
|
<Label Text="{Binding CreationTime}" FontAttributes="Bold" FontSize="22" TextColor="Gray"/> |
||||
|
</HorizontalStackLayout> |
||||
|
<HorizontalStackLayout> |
||||
|
<Label Text="工艺: " FontAttributes="Bold" FontSize="22" TextColor="Black"/> |
||||
|
<Label Text="{Binding FabricName}" FontAttributes="Bold" FontSize="22" TextColor="Gray"/> |
||||
|
</HorizontalStackLayout> |
||||
|
<HorizontalStackLayout> |
||||
|
<Label Text="面料: " FontAttributes="Bold" FontSize="22" TextColor="Black"/> |
||||
|
<Label Text="{Binding FabricName}" FontAttributes="Bold" FontSize="22" TextColor="Gray"/> |
||||
|
</HorizontalStackLayout> |
||||
|
<HorizontalStackLayout> |
||||
|
<Label Text="客户: " FontAttributes="Bold" FontSize="22" TextColor="Black"/> |
||||
|
<Label Text="{Binding CustomerName}" FontAttributes="Bold" FontSize="22" TextColor="Gray"/> |
||||
|
</HorizontalStackLayout> |
||||
|
<HorizontalStackLayout> |
||||
|
<Label Text="颜色: " FontAttributes="Bold" FontSize="22" TextColor="Black"/> |
||||
|
<Label FontSize="22" BackgroundColor="Black"/> |
||||
|
<Label Text="{Binding ColorName}" FontAttributes="Bold" FontSize="22" TextColor="Gray"/> |
||||
|
</HorizontalStackLayout> |
||||
|
<BoxView HeightRequest="25" Color="#E0E0E0" Margin="0,0" /> |
||||
|
</VerticalStackLayout> |
||||
|
</Grid> |
||||
|
|
||||
|
<Grid x:Name="_data" Grid.Row="1" Grid.Column="0" BackgroundColor="#F0F0F0"> |
||||
|
<CollectionView x:Name="CardCollectionView_data" RemainingItemsThreshold="5"> |
||||
|
<CollectionView.ItemTemplate> |
||||
|
<DataTemplate> |
||||
|
<Border BackgroundColor="White" Stroke="#CCCCCC" |
||||
|
StrokeThickness="2" Margin="10,0,10,10" |
||||
|
StrokeShape="RoundRectangle 10"> |
||||
|
<VerticalStackLayout VerticalOptions="Center"> |
||||
|
<HorizontalStackLayout> |
||||
|
<Label Text="步骤: " FontAttributes="Bold" |
||||
|
FontSize="22" TextColor="Black"/> |
||||
|
<Label Text="{Binding Step}" FontAttributes="Bold" |
||||
|
FontSize="22" TextColor="Black"/> |
||||
|
</HorizontalStackLayout> |
||||
|
<HorizontalStackLayout> |
||||
|
<Label Text="呼叫: " FontAttributes="Bold" |
||||
|
FontSize="22" TextColor="Black"/> |
||||
|
<Label Text="{Binding Machine}" FontAttributes="Bold" |
||||
|
FontSize="22" TextColor="Black"/> |
||||
|
</HorizontalStackLayout> |
||||
|
<HorizontalStackLayout> |
||||
|
<Label Text="时间: " FontAttributes="Bold" |
||||
|
FontSize="22" TextColor="Black"/> |
||||
|
<Label Text="{Binding EndTime}" FontAttributes="Bold" |
||||
|
FontSize="22" TextColor="Black"/> |
||||
|
</HorizontalStackLayout> |
||||
|
<BoxView HeightRequest="3" Color="#CCCCCC" /> |
||||
|
<HorizontalStackLayout> |
||||
|
<Label Text="{Binding ProductName}" FontAttributes="Bold" |
||||
|
FontSize="22" TextColor="Black"/> |
||||
|
</HorizontalStackLayout> |
||||
|
</VerticalStackLayout> |
||||
|
</Border> |
||||
|
</DataTemplate> |
||||
|
</CollectionView.ItemTemplate> |
||||
|
</CollectionView> |
||||
|
</Grid> |
||||
|
|
||||
|
</Grid> |
||||
|
</ContentPage> |
||||
@ -0,0 +1,96 @@ |
|||||
|
using SunlightAggregationTerminal.Models; |
||||
|
using System.Collections.ObjectModel; |
||||
|
|
||||
|
namespace SunlightAggregationTerminal; |
||||
|
|
||||
|
public partial class QueryDetail : ContentPage |
||||
|
{ |
||||
|
public static ObservableCollection<DyelotDetailsItem> QueryDetailDyelotDetailsItems { get; set; } = new(); |
||||
|
public static ObservableCollection<DyelotDetailsItem> 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; |
||||
|
} |
||||
|
} |
||||
Loading…
Reference in new issue