change - 监控首页扫描数据刷新

master
wenjy 20 hours ago
parent 1131d1e6a1
commit 0b82efcda3

@ -5,4 +5,8 @@
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\SlnMesnac.TouchSocket\SlnMesnac.TouchSocket.csproj" />
</ItemGroup>
</Project>

@ -0,0 +1,75 @@
using SlnMesnac.Model.domain;
using SlnMesnac.TouchSocket;
using System;
using System.Collections.Generic;
using System.Text;
#region << 版 本 注 释 >>
/*--------------------------------------------------------------------
* (c) 2024 WenJY
* CLR4.0.30319.42000
* T14-GEN3-7895
* SlnMesnac.Business
* 1a936e54-f672-4d86-b9bd-2747b75d4732
*
* WenJY
*
* 2024-09-19 9:49:11
* V1.0.0
*
*
*--------------------------------------------------------------------
*
*
*
*
* V1.0.0
*--------------------------------------------------------------------*/
#endregion << 版 本 注 释 >>
namespace SlnMesnac.Business
{
public class TagScanBusiness
{
private ApiServer apiServer;
public delegate void RefreshTagScanInfo(ScanLogModel scanLogModel);
public event RefreshTagScanInfo? RefreshTagScanInfoEvent;
public delegate void RefreshDeviceAlarmMessage(string message);
public event RefreshDeviceAlarmMessage? RefreshDeviceAlarmMessageEvent;
public TagScanBusiness(ApiServer apiServer)
{
this.apiServer = apiServer;
this.RefreshScanInfo();
}
private void RefreshScanInfo()
{
//扫描记录刷新
apiServer.ScanLogSocketAction += scan =>
{
RefreshTagScanInfoEvent?.Invoke(scan);
};
//告警状态刷新
apiServer.ScanStatusSocketAction += info =>
{
if (info != null && info.is_alarm == 1)
{
if (info.status_txt != null)
{
foreach (var item in info.status_txt)
{
RefreshDeviceAlarmMessageEvent?.Invoke(item);
}
}
}
};
}
}
}

@ -17,7 +17,7 @@ namespace SlnMesnac.TouchSocket
private readonly IBaseCodeService _baseCodeService;
public Action<ScanLogSocket>? ScanLogSocketAction;
public Action<ScanLogModel>? ScanLogSocketAction; //Update By WenJY 2024-09-19将返回值改为ScanLogModel
public Action<ScanStatusSocket>? ScanStatusSocketAction;
@ -71,8 +71,7 @@ namespace SlnMesnac.TouchSocket
[WebApi(HttpMethodType.POST)]
public Back ScanBack(ScanLogSocket scanStatus)
{
ScanLogSocketAction?.Invoke(scanStatus);
_scanService.Insert(new ScanLogModel()
var scan = new ScanLogModel()
{
CreateTime = scanStatus.CreateTime,
DataType = scanStatus.data_type,
@ -80,8 +79,10 @@ namespace SlnMesnac.TouchSocket
Rfid = scanStatus.rfid,
Ocr = scanStatus.ocr,
Url = scanStatus.url
});
};
ScanLogSocketAction?.Invoke(scan); //Update By WenJY 2024-09-19将返回值改为ScanLogModel
_scanService.Insert(scan);
return new Back();
}
}

@ -12,16 +12,35 @@
<RowDefinition Height="14*"/>
</Grid.RowDefinitions>
<Border Grid.Row="0" BorderBrush="#EBF4FD" BorderThickness="2" CornerRadius="10" Background="#EBF4FD" Margin="10,10">
<StackPanel Grid.Column="0" VerticalAlignment="Center" HorizontalAlignment="Left" Orientation="Horizontal">
<TextBlock Text="RFID" FontSize="18" Foreground="#31446E" Margin="10,3"/>
<TextBox Text="{Binding TagCode}" FontSize="24" Grid.Row="1" Width="180" Height="30" VerticalContentAlignment="Center" HorizontalAlignment="Center" Padding="5">
<TextBox.Template>
<ControlTemplate TargetType="TextBox">
<Border Background="White" BorderBrush="White" BorderThickness="1" CornerRadius="5">
<ScrollViewer x:Name="PART_ContentHost" />
</Border>
</ControlTemplate>
</TextBox.Template>
</TextBox>
<TextBlock Text="扫描时间" FontSize="18" Foreground="#31446E" Margin="20,3,10,0"/>
<DatePicker x:Name="BeginTimeDatePicker" Width="120" VerticalAlignment="Center" Margin="0,0,5,0"/>
<TextBlock Text="-" FontSize="18" Foreground="#31446E" Margin="10,3"/>
<DatePicker x:Name="EndTimeDatePicker" Width="120" VerticalAlignment="Center" Margin="0,0,5,0"/>
<Button Content="查 询" Command="{Binding QueryCommand}" Style="{StaticResource BUTTON_AGREE}" Width="100" Height="30" Background="#5095F3" BorderBrush="#5095F3" Margin="10,0,10,0"/>
<Button Content="导 出" Command="{Binding ExportCommand}" Style="{StaticResource BUTTON_AGREE}" Width="100" Height="30" Background="#009999" BorderBrush="#FF36B5C1" Margin="0,0,10,0"/>
</StackPanel>
</Border>
<Border Grid.Row="1" BorderBrush="#EBF4FD" BorderThickness="2" CornerRadius="10" Background="#EBF4FD" Margin="10,10">
<DataGrid Grid.Row="0" ItemsSource="{Binding ScanItems}" Background="Transparent"
FontSize="16" ColumnHeaderHeight="35"
FontSize="18" ColumnHeaderHeight="35"
RowHeight="31" AutoGenerateColumns="False" RowHeaderWidth="0"
GridLinesVisibility="None" ScrollViewer.HorizontalScrollBarVisibility="Hidden"
ScrollViewer.VerticalScrollBarVisibility="Hidden" BorderThickness="0" CanUserAddRows="False" HorizontalAlignment="Center"
Foreground="#31446E" x:Name="dataGrid" >
Foreground="#31446E" x:Name="dataGrid" Margin="0,10,0,0" >
<!--resourceStyle 399行修改选中字体颜色-->
<DataGrid.Columns>
<DataGridTextColumn Binding="{Binding CreateTime ,StringFormat=\{0:yyyy-MM-dd HH:mm:ss\}}" Header="记录时间" Width="1.5*" IsReadOnly="True"/>

@ -146,14 +146,14 @@
RowHeight="31" AutoGenerateColumns="False" RowHeaderWidth="0"
GridLinesVisibility="None" ScrollViewer.HorizontalScrollBarVisibility="Hidden"
ScrollViewer.VerticalScrollBarVisibility="Hidden" BorderThickness="0" CanUserAddRows="False" HorizontalAlignment="Center"
Foreground="#31446E" x:Name="dataGrid" >
Foreground="#31446E" x:Name="dataGrid" Margin="10,0,10,0">
<!--resourceStyle 399行修改选中字体颜色-->
<DataGrid.Columns>
<DataGridTextColumn Binding="{Binding CreateTime ,StringFormat=\{0:yyyy-MM-dd HH:mm:ss\}}" Header="记录时间" Width="1.5*" IsReadOnly="True"/>
<DataGridTextColumn Binding="{Binding Rfid}" Header="RFID" Width="2*" IsReadOnly="True"/>
<DataGridTextColumn Binding="{Binding Code}" Header="ATR" Width="2*" IsReadOnly="True"/>
<DataGridTextColumn Binding="{Binding Ocr}" Header="OCR" Width="2*" IsReadOnly="True"/>
<DataGridTextColumn Binding="{Binding url}" Header="图像路径" Width="2*" IsReadOnly="True"/>
<DataGridTextColumn Binding="{Binding Url}" Header="图像路径" Width="2*" IsReadOnly="True"/>
</DataGrid.Columns>
</DataGrid>
</Border>

@ -2,10 +2,13 @@
using CommunityToolkit.Mvvm.ComponentModel;
using LiveCharts;
using LiveCharts.Wpf;
using Microsoft.Extensions.DependencyInjection;
using SlnMesnac.Business;
using SlnMesnac.Model.domain;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
@ -37,8 +40,16 @@ namespace SlnMesnac.WPF.ViewModel
{
public class IndexViewModel : ObservableObject
{
private TagScanBusiness tagScanBusiness;
public IndexViewModel()
{
tagScanBusiness = App.ServiceProvider.GetService<TagScanBusiness>();
this.Init();
this.RefreshScanInfo();
}
private void Init()
{
PassRate = 30;
@ -54,19 +65,11 @@ namespace SlnMesnac.WPF.ViewModel
AxisX = new ObservableCollection<string> { "8", "12", "16", "20" };
ImagePath = "E:\\2024年项目\\RFID行李跟踪\\程序设计\\SlnMesnac.RfidIdentification\\SlnMesnac.WPF\\bin\\Debug\\net6.0-windows\\picture\\3898291920.jpg";
RefreshLogMessage($"1#站台任务下发站台任务下发站台任务下发站台任务下发站台任务下发站台任务下发");
ScanItems = new ObservableCollection<ScanLogModel>()
{
new ScanLogModel {CreateTime = DateTime.Now,DataType=1,Rfid="20240918",Code="20240918",Ocr="20240918"},
new ScanLogModel {CreateTime = DateTime.Now,DataType=1,Rfid="20240918",Code="20240918",Ocr="20240918"},
new ScanLogModel {CreateTime = DateTime.Now,DataType=1,Rfid="20240918",Code="20240918",Ocr="20240918"},
};
TagCode = "20240918";
TagAmount = 362;
ScanItems = new ObservableCollection<ScanLogModel>();
}
/// <summary>
@ -150,6 +153,25 @@ namespace SlnMesnac.WPF.ViewModel
set => SetProperty(ref _scanItems, value);
}
private void RefreshScanInfo()
{
tagScanBusiness.RefreshTagScanInfoEvent += info =>
{
App.Current.Dispatcher.Invoke(() =>
{
TagCode = info.Rfid;
ImagePath = info.Url;
string fileName = Path.GetFileName(info.Url);
info.Url = fileName;
ScanItems.Add(info);
TagAmount++;
});
};
}
private ObservableCollection<string> listItems = new ObservableCollection<string>();

Loading…
Cancel
Save