From 5bc34aa758449174ab21e233d3e102368a45886d Mon Sep 17 00:00:00 2001 From: liuwf Date: Wed, 26 Jun 2024 23:42:51 +0800 Subject: [PATCH] =?UTF-8?q?add-=E5=8E=8B=E7=BC=A9=E5=90=8E=E7=9A=84?= =?UTF-8?q?=E7=85=A7=E7=89=87=E4=BF=9D=E5=AD=98=E5=88=B0=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E5=BA=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SlnMesnac.Business/LogoBusiness.cs | 12 ++++++++++-- SlnMesnac.Model/domain/LogoIdentify.cs | 7 ++++++- SlnMesnac.Repository/service/ILogoIdentifyService.cs | 2 +- SlnMesnac.WPF/ViewModel/IndexViewModel.cs | 6 +++--- 4 files changed, 20 insertions(+), 7 deletions(-) diff --git a/SlnMesnac.Business/LogoBusiness.cs b/SlnMesnac.Business/LogoBusiness.cs index 446fcea..bca40e8 100644 --- a/SlnMesnac.Business/LogoBusiness.cs +++ b/SlnMesnac.Business/LogoBusiness.cs @@ -54,6 +54,8 @@ namespace SlnMesnac.Business public delegate void RefreshMessage(string message, bool isWarning = false); public static event RefreshMessage? RefreshMessageEvent; + public delegate void RefreshDataGrid(); + public static event RefreshDataGrid? RefreshDataGridEvent; #endregion @@ -111,6 +113,8 @@ namespace SlnMesnac.Business Console.WriteLine("相机流程开始:"); // 传入照片 byte[] ImageData = null; + // 压缩后的图片 + byte[] compressedImageData = null; try { #region 初始操作:复位海康上次结果,删除海康上次保存文件 @@ -196,7 +200,7 @@ namespace SlnMesnac.Business if (ImageData != null) { // 图片压缩 - byte[] compressedImageData = FileHelper.CompressImageData(ImageData, 20); + compressedImageData = FileHelper.CompressImageData(ImageData, 20); FileHelper.SaveImage(compressedImageData, materialCodeStr + ".jpg", PicturePath); RefreshPictureEvent?.Invoke(ImageData); } @@ -216,9 +220,13 @@ namespace SlnMesnac.Business record.isChecked = logoConfig.IsChecked; record.Result = hikFlag ? 1 : 0; record.RecordTime = DateTime.Now; + if (compressedImageData != null) + { + record.Picture = compressedImageData; + } logoIdentifyService.InsertRecord(record); #endregion - + RefreshDataGridEvent?.Invoke(); } catch (Exception ex) diff --git a/SlnMesnac.Model/domain/LogoIdentify.cs b/SlnMesnac.Model/domain/LogoIdentify.cs index 1d3af5b..8ad4a38 100644 --- a/SlnMesnac.Model/domain/LogoIdentify.cs +++ b/SlnMesnac.Model/domain/LogoIdentify.cs @@ -52,7 +52,12 @@ namespace SlnMesnac.Model.domain [SugarColumn(ColumnName = "RECORD_TIME")] public DateTime RecordTime { get; set; } - + /// + /// 记录时间 + /// + [SugarColumn(ColumnName = "PICTURE")] + public Byte[]? Picture { get; set; } + } } diff --git a/SlnMesnac.Repository/service/ILogoIdentifyService.cs b/SlnMesnac.Repository/service/ILogoIdentifyService.cs index 9acc504..6f582d0 100644 --- a/SlnMesnac.Repository/service/ILogoIdentifyService.cs +++ b/SlnMesnac.Repository/service/ILogoIdentifyService.cs @@ -15,8 +15,8 @@ namespace SlnMesnac.Repository.service /// Task> GetAllRecordAsync(); + - /// /// 时间段条件查询 diff --git a/SlnMesnac.WPF/ViewModel/IndexViewModel.cs b/SlnMesnac.WPF/ViewModel/IndexViewModel.cs index fe0e23a..77b5353 100644 --- a/SlnMesnac.WPF/ViewModel/IndexViewModel.cs +++ b/SlnMesnac.WPF/ViewModel/IndexViewModel.cs @@ -17,6 +17,7 @@ using SqlSugar; using System; using System.Collections.Generic; using System.Collections.ObjectModel; +using System.Diagnostics; using System.Drawing; using System.IO; using System.Linq; @@ -54,6 +55,7 @@ namespace SlnMesnac.WPF.ViewModel LogoBusiness.RefreshMessageEvent += RefreshMessage; LogoBusiness.RefreshBoxInfoEvent += RefreshBoxInfo; LogoBusiness.RefreshPictureEvent += RefreshPicture; + LogoBusiness.RefreshDataGridEvent += RefreshDataGrid; ResetCommand = new RelayCommand(Reset); RefreshDataGrid(); @@ -83,7 +85,7 @@ namespace SlnMesnac.WPF.ViewModel logoBusiness.Pass(); } - + /// /// 测试方法 /// @@ -148,9 +150,7 @@ namespace SlnMesnac.WPF.ViewModel BoxCode = boxCode; BoxTime = boxTime; ProductModel = model; - RefreshResultColor(isSuccess); - RefreshDataGrid(); if (!isSuccess) { ImageData = null;