diff --git a/Class/DataReceived.cs b/Class/DataReceived.cs
index fceb579..b85a727 100644
--- a/Class/DataReceived.cs
+++ b/Class/DataReceived.cs
@@ -137,6 +137,10 @@ namespace SunlightAggregationTerminal.Class
//发送消息
WeakReferenceMessenger.Default.Send(new object());
}
+ if (data.TryGetValue("ChemicalStatistics", out val) && val != null)//查询接受
+ {
+ InfoChemicalStatistics.Total_data(val.ToString()!);
+ }
if (data.TryGetValue("Query", out val) && val != null)//查询接受
{
QueryPage.Query_data(val.ToString()!);
diff --git a/InfoChemicalStatistics.xaml b/InfoChemicalStatistics.xaml
new file mode 100644
index 0000000..38a367d
--- /dev/null
+++ b/InfoChemicalStatistics.xaml
@@ -0,0 +1,57 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/InfoChemicalStatistics.xaml.cs b/InfoChemicalStatistics.xaml.cs
new file mode 100644
index 0000000..7bb4ed2
--- /dev/null
+++ b/InfoChemicalStatistics.xaml.cs
@@ -0,0 +1,73 @@
+using SunlightAggregationTerminal.Class;
+using SunlightAggregationTerminal.Models;
+using System.Collections.ObjectModel;
+using System.Reflection;
+using System.Text.Json;
+using TouchSocket.Core;
+
+namespace SunlightAggregationTerminal;
+
+public partial class InfoChemicalStatistics : ContentPage
+{
+ public class ChemicalTotal
+{
+ public string? ProductName { get; set; }
+ public string? ProductCode { get; set; }
+ public float? TotalDispenseGrams { get; set; }
+}
+
+ public static ObservableCollection ChemicalTotals { get; set; } = new();
+ public InfoChemicalStatistics()
+ {
+ InitializeComponent();
+ Dictionary Dictionary = new Dictionary();
+ Dictionary.Add("Command", "ChemicalStatistics");
+ Total_Command(Dictionary.ToJsonString());
+ }
+
+ public async void Total_Command(string dat)
+ {
+ LoadingIndicator.IsVisible = true;
+ ChemicalTotals.Clear();
+
+ DataReceived.Transmit(dat);
+
+ // 创建一个 15 秒的延时任务
+ Task delayTask = Task.Delay(15000);
+ // 创建一个监测任务,不断检查变量
+ Task monitorTask = Task.Run(async () =>
+ {
+ while (ChemicalTotals.Count == 0)
+ {
+ // 每隔 100 毫秒检查一次,避免 CPU 占用过高
+ await Task.Delay(100);
+ }
+ });
+ // 使用 Task.WhenAny 等待任意一个任务完成
+ await Task.WhenAny(delayTask, monitorTask);
+ CardCollectionView.ItemsSource = ChemicalTotals;
+
+ LoadingIndicator.IsVisible = false;
+ }
+ public static void Total_data(string dat)
+ {
+
+ try
+ {
+ var data = JsonSerializer.Deserialize>(dat);
+
+ if (data != null)
+ {
+ foreach (var item in data)
+ {
+ item.TotalDispenseGrams = item.TotalDispenseGrams / 1000;
+
+ ChemicalTotals.Add(item);
+ }
+ }
+ }
+ catch (Exception)
+ {
+ }
+ }
+}
\ No newline at end of file
diff --git a/InfoPage.xaml.cs b/InfoPage.xaml.cs
index 2c4e6cd..0be7418 100644
--- a/InfoPage.xaml.cs
+++ b/InfoPage.xaml.cs
@@ -46,9 +46,9 @@ public partial class InfoPage : ContentPage
};
}
- private void TapGestureRecognizer_ChemicalStatistics(object sender, TappedEventArgs e)
+ private async void TapGestureRecognizer_ChemicalStatistics(object sender, TappedEventArgs e)
{
-
+ await Navigation.PushAsync(new InfoChemicalStatistics());
}
private void HandleUITrigger()
diff --git a/SunlightAggregationTerminal.csproj b/SunlightAggregationTerminal.csproj
index 1a91c63..4bd297c 100644
--- a/SunlightAggregationTerminal.csproj
+++ b/SunlightAggregationTerminal.csproj
@@ -102,6 +102,9 @@
+
+ MSBuild:Compile
+
MSBuild:Compile