From ccd3d6ba30f96f274e37d3e1b46cf5b4ac3d2b8a Mon Sep 17 00:00:00 2001 From: wenjy Date: Wed, 9 Oct 2024 15:26:20 +0800 Subject: [PATCH] =?UTF-8?q?change=20-=20=E6=B7=BB=E5=8A=A0=E5=8E=86?= =?UTF-8?q?=E5=8F=B2=E5=9B=BE=E5=83=8F=E5=9C=A8=E7=BA=BF=E9=A2=84=E8=A7=88?= =?UTF-8?q?=E3=80=81=E5=90=88=E6=A0=BC=E7=8E=87=E7=BB=9F=E8=AE=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SlnMesnac.Business/LogInfoBusiness.cs | 6 ++- SlnMesnac.Business/TagScanBusiness.cs | 30 +++++++++++- SlnMesnac.Model/domain/ScanLog.cs | 4 ++ SlnMesnac.TouchSocket/ApiServer.cs | 36 +++++++++++--- .../Page/History/HistoryControl.xaml | 14 +++++- .../Page/LogInfo/LogInfoControl.xaml | 2 +- SlnMesnac.WPF/ViewModel/HistoryViewModel.cs | 47 ++++++++++++++++++- SlnMesnac.WPF/ViewModel/IndexViewModel.cs | 10 ++-- SlnMesnac.WPF/ViewModel/LogInfoViewModel.cs | 5 +- 9 files changed, 134 insertions(+), 20 deletions(-) diff --git a/SlnMesnac.Business/LogInfoBusiness.cs b/SlnMesnac.Business/LogInfoBusiness.cs index 56f9b3c..23d117d 100644 --- a/SlnMesnac.Business/LogInfoBusiness.cs +++ b/SlnMesnac.Business/LogInfoBusiness.cs @@ -4,6 +4,7 @@ using SlnMesnac.Repository.service.LogImpl; using SlnMesnac.Repository.service.ScanLog; using System; using System.Collections.Generic; +using System.Linq; using System.Linq.Expressions; using System.Text; @@ -65,7 +66,10 @@ namespace SlnMesnac.Business { exp = exp.And(x => x.LogLevel == logLevel); } - result = logService.Query(exp); + + var list = logService.Query(exp); + + result = list.OrderByDescending(x => x.CreateTime).ToList(); } } } diff --git a/SlnMesnac.Business/TagScanBusiness.cs b/SlnMesnac.Business/TagScanBusiness.cs index be1b040..049e35d 100644 --- a/SlnMesnac.Business/TagScanBusiness.cs +++ b/SlnMesnac.Business/TagScanBusiness.cs @@ -5,6 +5,7 @@ using SlnMesnac.TouchSocket; using System; using System.Collections.Generic; using System.Diagnostics; +using System.Linq; using System.Linq.Expressions; using System.Text; @@ -135,7 +136,34 @@ namespace SlnMesnac.Business { exp = exp.And(x => x.Rfid == rfidStr); } - result = scanLogService.Query(exp); + var list = scanLogService.Query(exp); + + result = list.OrderByDescending(x => x.CreateTime).ToList(); + } + + /// + /// 扫描合格率计算 + /// + public double TagScanPassRate() + { + + Expression> exp = s1 => true; + exp = exp.And(x => x.CreateTime >= DateTime.Now.Date && x.CreateTime <= DateTime.Now.AddDays(1).Date); + var tagScanList = scanLogService.Query(exp); + + if (tagScanList.Count > 0) + { + var isOkList = tagScanList.Where(x => x.IsOk == "Ok").ToList(); + + double passRate = ((double)isOkList.Count / (double)tagScanList.Count)*100; + + double result = Math.Round(passRate, 2); + + return result; + } + + return 0; + } } diff --git a/SlnMesnac.Model/domain/ScanLog.cs b/SlnMesnac.Model/domain/ScanLog.cs index b3a9d64..1641724 100644 --- a/SlnMesnac.Model/domain/ScanLog.cs +++ b/SlnMesnac.Model/domain/ScanLog.cs @@ -40,6 +40,10 @@ namespace SlnMesnac.Model.domain [SugarColumn(ColumnName = "url")] public string Url { get; set; } + //[ExcelColumnName("ͼ"), ExcelColumnWidth(50)] + //[SugarColumn(ColumnName = "image_name")] + //public string ImageName { get; set; } + [ExcelColumnName("״̬"), ExcelColumnWidth(50)] [SugarColumn(ColumnName = "is_ok")] diff --git a/SlnMesnac.TouchSocket/ApiServer.cs b/SlnMesnac.TouchSocket/ApiServer.cs index c16a6a8..6349065 100644 --- a/SlnMesnac.TouchSocket/ApiServer.cs +++ b/SlnMesnac.TouchSocket/ApiServer.cs @@ -219,7 +219,7 @@ namespace SlnMesnac.TouchSocket Ocr = scanLog.ocr, Url = scanLog.url, IsOk = scanLog.isOk, - Result = scanLog.result, + Result = scanLog.result }; ScanLogSocketAction?.Invoke(model); @@ -361,8 +361,7 @@ namespace SlnMesnac.TouchSocket { try { - - if(string.IsNullOrEmpty(sourceImagePath)) + if (string.IsNullOrEmpty(sourceImagePath)) { throw new ArgumentNullException("全景图像路径为空"); } @@ -381,24 +380,49 @@ namespace SlnMesnac.TouchSocket if (!Directory.Exists(destinationFolder)) { Directory.CreateDirectory(destinationFolder); + + // 创建 ok、ng、mul 文件夹 + string okFolder = Path.Combine(destinationFolder, "ok"); + string ngFolder = Path.Combine(destinationFolder, "ng"); + string mulFolder = Path.Combine(destinationFolder, "mul"); + Directory.CreateDirectory(okFolder); + Directory.CreateDirectory(ngFolder); + Directory.CreateDirectory(mulFolder); } string sourceFileName = Path.GetFileName(sourceImagePath); string extension = Path.GetExtension(sourceImagePath); - string newFileName = now.ToString("yyyyMMddHHmmss") + "-" + fileName + extension; + string newFileName = now.ToString("HHmmssfff") + "-" + fileName + extension; - destinationImagePath = Path.Combine(destinationFolder, newFileName); + string subFolder = DetermineSubFolder(fileName); + destinationImagePath = Path.Combine(destinationFolder, subFolder, newFileName); File.Copy(sourceImagePath, destinationImagePath, true); - File.Delete(sourceImagePath); + //File.Delete(sourceImagePath); } catch (Exception ex) { throw new InvalidOperationException($"将全景图像复制到指定路径处理异常:{ex.Message}"); } } + + private string DetermineSubFolder(string fileName) + { + if (fileName.Contains("ead")) + { + return "ng"; + } + else if (fileName.Contains("多条码")) + { + return "mul"; + } + else + { + return "ok"; + } + } } } diff --git a/SlnMesnac.WPF/Page/History/HistoryControl.xaml b/SlnMesnac.WPF/Page/History/HistoryControl.xaml index 038cdec..543f928 100644 --- a/SlnMesnac.WPF/Page/History/HistoryControl.xaml +++ b/SlnMesnac.WPF/Page/History/HistoryControl.xaml @@ -37,7 +37,7 @@ @@ -47,7 +47,17 @@ - + + + + + + + +