diff --git a/SlnMesnac.Business/TagScanBusiness.cs b/SlnMesnac.Business/TagScanBusiness.cs index c41deda..17e8f14 100644 --- a/SlnMesnac.Business/TagScanBusiness.cs +++ b/SlnMesnac.Business/TagScanBusiness.cs @@ -1,5 +1,7 @@ -using SlnMesnac.Common; +using Microsoft.Extensions.Logging; +using SlnMesnac.Common; using SlnMesnac.Model.domain; +using SlnMesnac.Model.dto; using SlnMesnac.Repository.service.ScanLog; using SlnMesnac.TouchSocket; using System; @@ -8,6 +10,7 @@ using System.Diagnostics; using System.Linq; using System.Linq.Expressions; using System.Text; +using TouchSocket.Core; #region << 版 本 注 释 >> /*-------------------------------------------------------------------- @@ -47,11 +50,13 @@ namespace SlnMesnac.Business public delegate void RefreshDeviceStatus(bool rfidFlag,bool camFlag); public event RefreshDeviceStatus? RefreshDeviceStatusEvent; + private ILogger _logger; - public TagScanBusiness(ApiServer apiServer, IScanLogService scanLogService) + public TagScanBusiness(ApiServer apiServer, IScanLogService scanLogService, ILogger logger) { this.apiServer = apiServer; this.scanLogService = scanLogService; + this._logger = logger; this.RefreshScanInfo(); } @@ -167,5 +172,12 @@ namespace SlnMesnac.Business } + public List QueryHourlyCount() + { + var info = scanLogService.QueryHourlyCount(); + _logger.LogInformation($"统计信息:{info.ToJsonString()}"); + return info; + } + } } diff --git a/SlnMesnac.Model/dto/HourlyCount.cs b/SlnMesnac.Model/dto/HourlyCount.cs new file mode 100644 index 0000000..0fe53f8 --- /dev/null +++ b/SlnMesnac.Model/dto/HourlyCount.cs @@ -0,0 +1,35 @@ +using System; +using System.Collections.Generic; +using System.Text; + +#region << 版 本 注 释 >> +/*-------------------------------------------------------------------- +* 版权所有 (c) 2024 WenJY 保留所有权利。 +* CLR版本:4.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; } + } +} diff --git a/SlnMesnac.Repository/service/ScanLog/IScanLogService.cs b/SlnMesnac.Repository/service/ScanLog/IScanLogService.cs index 4a87885..dc222e9 100644 --- a/SlnMesnac.Repository/service/ScanLog/IScanLogService.cs +++ b/SlnMesnac.Repository/service/ScanLog/IScanLogService.cs @@ -1,5 +1,7 @@ using SlnMesnac.Model.domain; +using SlnMesnac.Model.dto; using SlnMesnac.Repository.service.@base; +using System.Collections.Generic; namespace SlnMesnac.Repository.service.ScanLog { @@ -9,5 +11,7 @@ namespace SlnMesnac.Repository.service.ScanLog Page QueryPage(int pageIndex, int pageSize); + + List QueryHourlyCount(); } } \ No newline at end of file diff --git a/SlnMesnac.Repository/service/ScanLog/ScanLogServiceImpl.cs b/SlnMesnac.Repository/service/ScanLog/ScanLogServiceImpl.cs index 3b7b0c8..a1d7d05 100644 --- a/SlnMesnac.Repository/service/ScanLog/ScanLogServiceImpl.cs +++ b/SlnMesnac.Repository/service/ScanLog/ScanLogServiceImpl.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using SlnMesnac.Model.domain; +using SlnMesnac.Model.dto; using SlnMesnac.Repository.service.@base; namespace SlnMesnac.Repository.service.ScanLog @@ -45,5 +46,12 @@ namespace SlnMesnac.Repository.service.ScanLog return page; } + + public List QueryHourlyCount() + { + var info = _rep.Context.Ado.SqlQuery("SELECT * FROM scanlog_today_hourly_count"); + + return info; + } } } \ No newline at end of file diff --git a/SlnMesnac.TouchSocket/ApiServer.cs b/SlnMesnac.TouchSocket/ApiServer.cs index e92e074..c1ad5d9 100644 --- a/SlnMesnac.TouchSocket/ApiServer.cs +++ b/SlnMesnac.TouchSocket/ApiServer.cs @@ -293,7 +293,10 @@ namespace SlnMesnac.TouchSocket bool isRfidEmpty = 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; } @@ -309,9 +312,6 @@ namespace SlnMesnac.TouchSocket } else if(!isRfidEmpty && !isAtrEmpty) { - var atrCodeArray = hk.code.Split(','); - var rfidCodeArray = hk.rfid.Split(","); - if (atrCodeArray.Length > 1 && rfidCodeArray.Length > 1) { result = "多条码"; @@ -347,6 +347,10 @@ namespace SlnMesnac.TouchSocket { if (isRfidEmpty) { + if(atrCodeArray.Length > 1) + { + hk.code = "多条码"; + } result = hk.code; } else diff --git a/SlnMesnac.WPF/Page/IndexControl.xaml b/SlnMesnac.WPF/Page/IndexControl.xaml index ea7b13a..8158a46 100644 --- a/SlnMesnac.WPF/Page/IndexControl.xaml +++ b/SlnMesnac.WPF/Page/IndexControl.xaml @@ -38,41 +38,43 @@ - + - - - - - - - - - - + + + + + + - + - - - - - + + + + + + + + + + + @@ -104,10 +106,16 @@ - + - + + + + + + + @@ -142,7 +150,7 @@ { 3, 5, 7, 2 } // 示例数据 - } - }; + RefreshChartLives(); - AxisX = new ObservableCollection { "8", "12", "16", "20" }; - - ScanItems = new ObservableCollection(); + ScanItems = new ObservableCollection(); } #region 参数定义 @@ -173,6 +163,10 @@ namespace SlnMesnac.WPF.ViewModel var isOkList = scanLogModelsItems.Where(x => x.IsOk != "Ng").ToList(); double passRate = ((double)isOkList.Count / (double)scanLogModelsItems.Count) * 100; 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 (values) + } + }; + + AxisX = new ObservableCollection(axisxs); + } + }catch(Exception ex) + { + Console.WriteLine($"效率统计异常:{ex.Message}"); + } + + } + private ObservableCollection listItems = new ObservableCollection();