From 9017d807570fa018d6d008ae09fba2062b0020df Mon Sep 17 00:00:00 2001 From: liuwf Date: Wed, 26 Jun 2024 21:28:44 +0800 Subject: [PATCH] =?UTF-8?q?add-=E6=8C=89=E5=9E=8B=E5=8F=B7=E7=BB=9F?= =?UTF-8?q?=E8=AE=A1=E7=95=8C=E9=9D=A2=E6=B7=BB=E5=8A=A0=E5=9E=8B=E5=8F=B7?= =?UTF-8?q?=E7=BC=96=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SlnMesnac.Business/LogoBusiness.cs | 26 ++++++++++++--- .../service/Impl/LogoConfigImpl.cs | 7 +++- SlnMesnac.WPF/ConvertTo/IsSuccessConverter.cs | 2 +- SlnMesnac.WPF/MainWindow.xaml | 33 ++++++++++++++++++- SlnMesnac.WPF/Models/ModelCount.cs | 1 + SlnMesnac.WPF/ViewModel/IndexViewModel.cs | 8 +++-- .../ViewModel/MainWindowViewModel.cs | 10 ++++++ .../ViewModel/StatisticsPageViewModel.cs | 8 +++-- SlnMesnac.WPF/Views/IndexPage.xaml | 8 ++--- SlnMesnac.WPF/Views/StatisticsPageView.xaml | 1 + 10 files changed, 89 insertions(+), 15 deletions(-) diff --git a/SlnMesnac.Business/LogoBusiness.cs b/SlnMesnac.Business/LogoBusiness.cs index 11a4c6c..3ce0fa7 100644 --- a/SlnMesnac.Business/LogoBusiness.cs +++ b/SlnMesnac.Business/LogoBusiness.cs @@ -104,6 +104,10 @@ namespace SlnMesnac.Business /// public async void BarCodeHandler(string materialCodeStr, string ip) { + #region 复位报警灯 + // 声光电报警复位 + gunHelper.SendData("OK"); + #endregion Console.WriteLine("相机流程开始:"); // 传入照片 byte[] ImageData = null; @@ -125,6 +129,12 @@ namespace SlnMesnac.Business //2.根据箱体码查询型号,根据型号判断是否需要校验LOGO ProductModel mode = logoConfigService.GetMaterialTypeByBarCode(materialCodeStr); + if(mode == null) + { + // 根据成品码查询不到型号 + Warning($"根据成品码{materialCodeStr}查询不到型号,检查网络!"); + return; + } LogoConfig logoConfig = logoConfigService.GetByMaterialType(mode.MaterialCode); // 海康校验结果 bool hikFlag = false; @@ -141,13 +151,13 @@ namespace SlnMesnac.Business { //校验成功放行 - RefreshMessageEvent?.Invoke("Logo识别成功,下发放行"); + RefreshMessageEvent?.Invoke("LOGO+PCI识别成功,下发放行"); logger.LogInformation($"箱体码:{materialCodeStr},Logo识别成功,下发放行"); } else { //校验失败禁止放行 - WarningAndStop($"Logo识别失败,禁止放行"); + WarningAndStop($"LOGO+PCI识别失败,禁止放行"); } } else @@ -155,7 +165,7 @@ namespace SlnMesnac.Business // 不需要校验 hikFlag = true; - RefreshMessageEvent?.Invoke("Logo无需识别,下发放行"); + RefreshMessageEvent?.Invoke("LOGO+PCI无需识别,下发放行"); logger.LogInformation($"箱体码:{materialCodeStr},Logo无需识别,下发放行"); } @@ -222,7 +232,7 @@ namespace SlnMesnac.Business return true; } // 检查是否超过两秒 - if (stopwatch.ElapsedMilliseconds > 2500) + if (stopwatch.ElapsedMilliseconds > 3000) { return false; } @@ -387,6 +397,14 @@ namespace SlnMesnac.Business RefreshMessageEvent?.Invoke(message, true); Stop(); } + + + public void Warning(string message) + { + logger.LogError(message); + RefreshMessageEvent?.Invoke(message, true); + + } #endregion diff --git a/SlnMesnac.Repository/service/Impl/LogoConfigImpl.cs b/SlnMesnac.Repository/service/Impl/LogoConfigImpl.cs index 73f2e67..40170c4 100644 --- a/SlnMesnac.Repository/service/Impl/LogoConfigImpl.cs +++ b/SlnMesnac.Repository/service/Impl/LogoConfigImpl.cs @@ -75,7 +75,12 @@ FROM { string sql = $"SELECT a.BAR_CODE, b.ORDER_NO, b.MATERIAL_CODE,b.MATERIAL_NAME,b.ORDER_QTY FROM IMOS_TM_PRINT_INFO a LEFT JOIN IMOS_PR_ORDER b ON a.ORDER_NUMBER = lpad( b.ORDER_NO, '12', '0' ) WHERE a.BAR_CODE = '{barCode}'"; // 查询MES所有型号 - model = _rep.Context.SqlQueryable(sql).First(); + var list = _rep.Context.SqlQueryable(sql); + if(list==null || list.Count() == 0) + { + return null; + } + model = list.First(); } catch (Exception ex) { diff --git a/SlnMesnac.WPF/ConvertTo/IsSuccessConverter.cs b/SlnMesnac.WPF/ConvertTo/IsSuccessConverter.cs index 4ee4640..846169e 100644 --- a/SlnMesnac.WPF/ConvertTo/IsSuccessConverter.cs +++ b/SlnMesnac.WPF/ConvertTo/IsSuccessConverter.cs @@ -17,7 +17,7 @@ namespace SlnMesnac.WPF.ConvertTo { if (value is int IsSuccess) { - return IsSuccess == 1 ? "成功" : "失败"; + return IsSuccess == 1 ? "OK" : "NG"; } return string.Empty; // or handle unexpected value } diff --git a/SlnMesnac.WPF/MainWindow.xaml b/SlnMesnac.WPF/MainWindow.xaml index e80995a..5c05267 100644 --- a/SlnMesnac.WPF/MainWindow.xaml +++ b/SlnMesnac.WPF/MainWindow.xaml @@ -73,6 +73,7 @@ + @@ -102,7 +103,7 @@ - + @@ -167,6 +168,36 @@ + + + + + + + + + + + + + + + + + + diff --git a/SlnMesnac.WPF/Models/ModelCount.cs b/SlnMesnac.WPF/Models/ModelCount.cs index 568c5b7..2e5d4a6 100644 --- a/SlnMesnac.WPF/Models/ModelCount.cs +++ b/SlnMesnac.WPF/Models/ModelCount.cs @@ -9,6 +9,7 @@ namespace SlnMesnac.WPF.Models public class ModelCount { public int No { get; set; } + public string MaterialType { get; set; } public string ProductName { get; set; } public int Amount { get; set; } } diff --git a/SlnMesnac.WPF/ViewModel/IndexViewModel.cs b/SlnMesnac.WPF/ViewModel/IndexViewModel.cs index b151ea4..fe0e23a 100644 --- a/SlnMesnac.WPF/ViewModel/IndexViewModel.cs +++ b/SlnMesnac.WPF/ViewModel/IndexViewModel.cs @@ -20,6 +20,7 @@ using System.Collections.ObjectModel; using System.Drawing; using System.IO; using System.Linq; +using System.ServiceModel.Channels; using System.Text; using System.Threading; using System.Threading.Tasks; @@ -78,7 +79,7 @@ namespace SlnMesnac.WPF.ViewModel /// private void Reset() { - + Message = ""; logoBusiness.Pass(); } @@ -150,7 +151,10 @@ namespace SlnMesnac.WPF.ViewModel RefreshResultColor(isSuccess); RefreshDataGrid(); - + if (!isSuccess) + { + ImageData = null; + } } /// diff --git a/SlnMesnac.WPF/ViewModel/MainWindowViewModel.cs b/SlnMesnac.WPF/ViewModel/MainWindowViewModel.cs index b789fea..4b4a9b4 100644 --- a/SlnMesnac.WPF/ViewModel/MainWindowViewModel.cs +++ b/SlnMesnac.WPF/ViewModel/MainWindowViewModel.cs @@ -88,6 +88,16 @@ namespace SlnMesnac.WPF.ViewModel } #region 参数定义 + /// + /// 数据库状态 + /// + private int _DataBaseStatus = 1; + public int DataBaseStatus + { + get { return _DataBaseStatus; } + set { _DataBaseStatus = value; RaisePropertyChanged(nameof(DataBaseStatus)); } + } + /// /// PLC设备状态 /// diff --git a/SlnMesnac.WPF/ViewModel/StatisticsPageViewModel.cs b/SlnMesnac.WPF/ViewModel/StatisticsPageViewModel.cs index 2f13234..a4a5f35 100644 --- a/SlnMesnac.WPF/ViewModel/StatisticsPageViewModel.cs +++ b/SlnMesnac.WPF/ViewModel/StatisticsPageViewModel.cs @@ -58,14 +58,18 @@ namespace SlnMesnac.WPF.ViewModel { var ModelList = list.GroupBy(x => x.MaterialName). - Select(x => new { ProductModel = x.Key, Amount = x.Count() }).ToList(); + Select(x => new { + ProductModel = x.Key, + MaterialType = x.FirstOrDefault().MaterialType, + Amount = x.Count() + }).ToList(); App.Current.Dispatcher.BeginInvoke((Action)(() => { ModelDataGrid.Clear(); int index = 1; foreach (var item in ModelList) { - ModelDataGrid.Add(new ModelCount() { No = index++, ProductName = item.ProductModel, Amount = item.Amount }); + ModelDataGrid.Add(new ModelCount() { No = index++, MaterialType = item.MaterialType,ProductName = item.ProductModel, Amount = item.Amount }); } })); diff --git a/SlnMesnac.WPF/Views/IndexPage.xaml b/SlnMesnac.WPF/Views/IndexPage.xaml index 701896a..a09948e 100644 --- a/SlnMesnac.WPF/Views/IndexPage.xaml +++ b/SlnMesnac.WPF/Views/IndexPage.xaml @@ -117,7 +117,7 @@ - +