change - 效率统计

master
wenjy 1 month ago
parent be328d0ff2
commit faa58cbcf3

@ -1,5 +1,7 @@
using SlnMesnac.Common; using Microsoft.Extensions.Logging;
using SlnMesnac.Common;
using SlnMesnac.Model.domain; using SlnMesnac.Model.domain;
using SlnMesnac.Model.dto;
using SlnMesnac.Repository.service.ScanLog; using SlnMesnac.Repository.service.ScanLog;
using SlnMesnac.TouchSocket; using SlnMesnac.TouchSocket;
using System; using System;
@ -8,6 +10,7 @@ using System.Diagnostics;
using System.Linq; using System.Linq;
using System.Linq.Expressions; using System.Linq.Expressions;
using System.Text; using System.Text;
using TouchSocket.Core;
#region << 版 本 注 释 >> #region << 版 本 注 释 >>
/*-------------------------------------------------------------------- /*--------------------------------------------------------------------
@ -47,11 +50,13 @@ namespace SlnMesnac.Business
public delegate void RefreshDeviceStatus(bool rfidFlag,bool camFlag); public delegate void RefreshDeviceStatus(bool rfidFlag,bool camFlag);
public event RefreshDeviceStatus? RefreshDeviceStatusEvent; public event RefreshDeviceStatus? RefreshDeviceStatusEvent;
private ILogger<TagScanBusiness> _logger;
public TagScanBusiness(ApiServer apiServer, IScanLogService scanLogService) public TagScanBusiness(ApiServer apiServer, IScanLogService scanLogService, ILogger<TagScanBusiness> logger)
{ {
this.apiServer = apiServer; this.apiServer = apiServer;
this.scanLogService = scanLogService; this.scanLogService = scanLogService;
this._logger = logger;
this.RefreshScanInfo(); this.RefreshScanInfo();
} }
@ -167,5 +172,12 @@ namespace SlnMesnac.Business
} }
public List<HourlyCount> QueryHourlyCount()
{
var info = scanLogService.QueryHourlyCount();
_logger.LogInformation($"统计信息:{info.ToJsonString()}");
return info;
}
} }
} }

@ -0,0 +1,35 @@
using System;
using System.Collections.Generic;
using System.Text;
#region << 版 本 注 释 >>
/*--------------------------------------------------------------------
* (c) 2024 WenJY
* CLR4.0.30319.42000
* T14-GEN3-7895
* SlnMesnac.Model.dto
* f2cc853b-1cda-4ef4-8ec8-0b68d974ad17
*
* WenJY
*
* 2024-12-13 13:39:09
* V1.0.0
*
*
*--------------------------------------------------------------------
*
*
*
*
* V1.0.0
*--------------------------------------------------------------------*/
#endregion << 版 本 注 释 >>
namespace SlnMesnac.Model.dto
{
public class HourlyCount
{
public string hour { get; set; }
public int count { get; set; }
}
}

@ -1,5 +1,7 @@
using SlnMesnac.Model.domain; using SlnMesnac.Model.domain;
using SlnMesnac.Model.dto;
using SlnMesnac.Repository.service.@base; using SlnMesnac.Repository.service.@base;
using System.Collections.Generic;
namespace SlnMesnac.Repository.service.ScanLog namespace SlnMesnac.Repository.service.ScanLog
{ {
@ -9,5 +11,7 @@ namespace SlnMesnac.Repository.service.ScanLog
Page<ScanLogModel> QueryPage(int pageIndex, int pageSize); Page<ScanLogModel> QueryPage(int pageIndex, int pageSize);
List<HourlyCount> QueryHourlyCount();
} }
} }

@ -1,6 +1,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using SlnMesnac.Model.domain; using SlnMesnac.Model.domain;
using SlnMesnac.Model.dto;
using SlnMesnac.Repository.service.@base; using SlnMesnac.Repository.service.@base;
namespace SlnMesnac.Repository.service.ScanLog namespace SlnMesnac.Repository.service.ScanLog
@ -45,5 +46,12 @@ namespace SlnMesnac.Repository.service.ScanLog
return page; return page;
} }
public List<HourlyCount> QueryHourlyCount()
{
var info = _rep.Context.Ado.SqlQuery<HourlyCount>("SELECT * FROM scanlog_today_hourly_count");
return info;
}
} }
} }

@ -293,7 +293,10 @@ namespace SlnMesnac.TouchSocket
bool isRfidEmpty = false; bool isRfidEmpty = false;
bool isAtrEmpty = false; bool isAtrEmpty = false;
if(hk.rfid == "noread" || string.IsNullOrEmpty(hk.rfid) || hk.rfid == "NoRead") var atrCodeArray = hk.code.Split(',');
var rfidCodeArray = hk.rfid.Split(",");
if (hk.rfid == "noread" || string.IsNullOrEmpty(hk.rfid) || hk.rfid == "NoRead")
{ {
isRfidEmpty = true; isRfidEmpty = true;
} }
@ -309,9 +312,6 @@ namespace SlnMesnac.TouchSocket
} }
else if(!isRfidEmpty && !isAtrEmpty) else if(!isRfidEmpty && !isAtrEmpty)
{ {
var atrCodeArray = hk.code.Split(',');
var rfidCodeArray = hk.rfid.Split(",");
if (atrCodeArray.Length > 1 && rfidCodeArray.Length > 1) if (atrCodeArray.Length > 1 && rfidCodeArray.Length > 1)
{ {
result = "多条码"; result = "多条码";
@ -347,6 +347,10 @@ namespace SlnMesnac.TouchSocket
{ {
if (isRfidEmpty) if (isRfidEmpty)
{ {
if(atrCodeArray.Length > 1)
{
hk.code = "多条码";
}
result = hk.code; result = hk.code;
} }
else else

@ -38,41 +38,43 @@
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<Border Grid.Column="0" CornerRadius="10" Margin="3"> <Border Grid.Column="0" CornerRadius="10" Margin="3">
<Border.Background> <Border.Background>
<ImageBrush ImageSource="/Templates/image/left.png"/> <ImageBrush ImageSource="/Templates/image/right.png"/>
</Border.Background> </Border.Background>
<Grid> <Grid>
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition Height="2*"/> <RowDefinition Height="2*"/>
<RowDefinition Height="3*"/> <RowDefinition Height="3*"/>
</Grid.RowDefinitions> </Grid.RowDefinitions>
<TextBlock Grid.Row="0" Text="条码信息" FontSize="24" Foreground="#31446E" VerticalAlignment="Center" HorizontalAlignment="Left" Margin="30,0,0,0"/> <TextBlock Grid.Row="0" Text="条码总数" FontSize="18" Foreground="#31446E" VerticalAlignment="Center" HorizontalAlignment="Left" Margin="30,0,0,0"/>
<TextBox Text="{Binding TagCode}" FontSize="24" Grid.Row="1" Width="240" Height="70" Margin="10" VerticalContentAlignment="Center" HorizontalAlignment="Center" Padding="5"> <StackPanel Grid.Row="1" Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center">
<TextBox.Template> <TextBlock Text="{Binding TagAmount}" FontSize="24" Foreground="#31446E" VerticalAlignment="Center" HorizontalAlignment="Center"/>
<ControlTemplate TargetType="TextBox"> <TextBlock Text="个" FontSize="24" Foreground="#31446E" VerticalAlignment="Center" HorizontalAlignment="Center"/>
<Border Background="White" BorderBrush="White" BorderThickness="1" CornerRadius="10"> </StackPanel>
<ScrollViewer x:Name="PART_ContentHost" />
</Border>
</ControlTemplate>
</TextBox.Template>
</TextBox>
</Grid> </Grid>
</Border> </Border>
<Border Grid.Column="1" CornerRadius="10" Margin="3"> <Border Grid.Column="1" CornerRadius="10" Margin="3">
<Border.Background> <Border.Background>
<ImageBrush ImageSource="/Templates/image/right.png"/> <ImageBrush ImageSource="/Templates/image/left.png"/>
</Border.Background> </Border.Background>
<Grid> <Grid>
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition Height="2*"/> <RowDefinition Height="2*"/>
<RowDefinition Height="3*"/> <RowDefinition Height="3*"/>
</Grid.RowDefinitions> </Grid.RowDefinitions>
<TextBlock Grid.Row="0" Text="条码总数" FontSize="24" Foreground="#31446E" VerticalAlignment="Center" HorizontalAlignment="Left" Margin="30,0,0,0"/> <TextBlock Grid.Row="0" Text="条码信息" FontSize="18" Foreground="#31446E" VerticalAlignment="Center" HorizontalAlignment="Left" Margin="30,0,0,0"/>
<StackPanel Grid.Row="1" Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center"> <TextBox Text="{Binding TagCode}" FontSize="24" Grid.Row="1" Width="200" Height="70" Margin="10" VerticalContentAlignment="Center" HorizontalAlignment="Center">
<TextBlock Text="{Binding TagAmount}" FontSize="24" Foreground="#31446E" VerticalAlignment="Center" HorizontalAlignment="Center"/> <TextBox.Template>
<TextBlock Text="个" FontSize="24" Foreground="#31446E" VerticalAlignment="Center" HorizontalAlignment="Center"/> <ControlTemplate TargetType="TextBox">
</StackPanel> <Border Background="White" BorderBrush="White" BorderThickness="1" CornerRadius="10">
<ScrollViewer x:Name="PART_ContentHost" VerticalAlignment="Center" HorizontalAlignment="Center"/>
</Border>
</ControlTemplate>
</TextBox.Template>
</TextBox>
</Grid> </Grid>
</Border> </Border>
</Grid> </Grid>
</Border> </Border>
@ -104,10 +106,16 @@
<Border Grid.Row="1" BorderBrush="Red" BorderThickness="0" Margin="10,5"> <Border Grid.Row="1" BorderBrush="Red" BorderThickness="0" Margin="10,5">
<lvc:CartesianChart Series="{Binding RecogEfficiency, UpdateSourceTrigger=PropertyChanged}"> <lvc:CartesianChart Series="{Binding RecogEfficiency, UpdateSourceTrigger=PropertyChanged}">
<lvc:CartesianChart.AxisX> <lvc:CartesianChart.AxisX>
<lvc:Axis Labels="{Binding AxisX}" FontSize="15" Foreground="#0288d1" MinValue="0"/> <lvc:Axis Labels="{Binding AxisX}" FontSize="15" Foreground="#0288d1" MinValue="0" Title="小时"/>
</lvc:CartesianChart.AxisX> </lvc:CartesianChart.AxisX>
<lvc:CartesianChart.AxisY> <lvc:CartesianChart.AxisY>
<lvc:Axis FontSize="15" Foreground="#0288d1"/> <lvc:Axis FontSize="15" Foreground="#0288d1" Title="数量" MinValue="0">
<!-- 自定义分割器以确保刻度为整数 -->
<lvc:Axis.Separator>
<lvc:Separator Step="20"/>
<!-- 设置刻度步长为整数 -->
</lvc:Axis.Separator>
</lvc:Axis>
</lvc:CartesianChart.AxisY> </lvc:CartesianChart.AxisY>
</lvc:CartesianChart> </lvc:CartesianChart>
@ -142,7 +150,7 @@
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<Border Grid.Column="0" CornerRadius="10" Background="#EBF4FD" Margin="10"> <Border Grid.Column="0" CornerRadius="10" Background="#EBF4FD" Margin="10">
<DataGrid Grid.Row="0" ItemsSource="{Binding ScanItems}" Background="Transparent" <DataGrid Grid.Row="0" ItemsSource="{Binding ScanItems}" Background="Transparent"
FontSize="16" ColumnHeaderHeight="35" FontSize="18" ColumnHeaderHeight="35"
RowHeight="31" AutoGenerateColumns="False" RowHeaderWidth="0" RowHeight="31" AutoGenerateColumns="False" RowHeaderWidth="0"
GridLinesVisibility="None" ScrollViewer.HorizontalScrollBarVisibility="Hidden" GridLinesVisibility="None" ScrollViewer.HorizontalScrollBarVisibility="Hidden"
ScrollViewer.VerticalScrollBarVisibility="Hidden" BorderThickness="0" CanUserAddRows="False" HorizontalAlignment="Center" ScrollViewer.VerticalScrollBarVisibility="Hidden" BorderThickness="0" CanUserAddRows="False" HorizontalAlignment="Center"

@ -5,6 +5,7 @@ using LiveCharts.Wpf;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using SlnMesnac.Business; using SlnMesnac.Business;
using SlnMesnac.Model.domain; using SlnMesnac.Model.domain;
using SlnMesnac.Model.dto;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
@ -51,21 +52,10 @@ namespace SlnMesnac.WPF.ViewModel
private void Init() private void Init()
{ {
//PassRate = tagScanBusiness.TagScanPassRate();
// 初始化数据 // 初始化数据
RecogEfficiency = new SeriesCollection RefreshChartLives();
{
new LineSeries
{
Title = "Achievement",
Values = new ChartValues<double> { 3, 5, 7, 2 } // 示例数据
}
};
AxisX = new ObservableCollection<string> { "8", "12", "16", "20" };
ScanItems = new ObservableCollection<ScanLogModel>(); ScanItems = new ObservableCollection<ScanLogModel>();
} }
#region 参数定义 #region 参数定义
@ -173,6 +163,10 @@ namespace SlnMesnac.WPF.ViewModel
var isOkList = scanLogModelsItems.Where(x => x.IsOk != "Ng").ToList(); var isOkList = scanLogModelsItems.Where(x => x.IsOk != "Ng").ToList();
double passRate = ((double)isOkList.Count / (double)scanLogModelsItems.Count) * 100; double passRate = ((double)isOkList.Count / (double)scanLogModelsItems.Count) * 100;
PassRate = Math.Round(passRate, 2); PassRate = Math.Round(passRate, 2);
RefreshChartLives();
}); });
}; };
@ -183,6 +177,33 @@ namespace SlnMesnac.WPF.ViewModel
}; };
} }
private void RefreshChartLives()
{
try
{
var hourly = tagScanBusiness.QueryHourlyCount();
if (hourly != null)
{
var values = hourly.Select(x => x.count).ToList();
var axisxs = hourly.Select(x => x.hour).ToList();
RecogEfficiency = new SeriesCollection
{
new LineSeries
{
Title = "数量",
Values = new ChartValues<int> (values)
}
};
AxisX = new ObservableCollection<string>(axisxs);
}
}catch(Exception ex)
{
Console.WriteLine($"效率统计异常:{ex.Message}");
}
}
private ObservableCollection<string> listItems = new ObservableCollection<string>(); private ObservableCollection<string> listItems = new ObservableCollection<string>();

Loading…
Cancel
Save