From 71f13c7087de0c58c64f2336edc1c7918e41b1ea Mon Sep 17 00:00:00 2001 From: liuwf Date: Fri, 29 Mar 2024 15:45:52 +0800 Subject: [PATCH 1/2] =?UTF-8?q?change-=E5=88=86=E5=9E=9B=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Service_New/CodeBindingRecordServices.cs | 18 +++-- Aucma.Core.CodeBinding/Common/SpeechStr.cs | 36 +++++++++ .../ViewModels/HandPalletizViewModel.cs | 14 ++++ .../ViewModels/IndexPageViewModel.cs | 13 +++ .../ViewModels/MainWindowViewModel.cs | 10 +++ .../ViewModels/StatisticsPageViewModel.cs | 79 +++++++++++-------- .../Views/HandPalletizView.xaml | 19 +++-- Aucma.Core.Palletiz/Views/IndexPageView.xaml | 33 +++++--- .../Views/StatisticsPageView.xaml | 2 +- Aucma.Core.Palletiz/appsettings.json | 2 +- .../Business/SpeechStr.cs | 36 +++++++++ 11 files changed, 205 insertions(+), 57 deletions(-) create mode 100644 Aucma.Core.CodeBinding/Common/SpeechStr.cs create mode 100644 Aucma.Core.ProductOffLine/Business/SpeechStr.cs diff --git a/Admin.Core.Service/Service_New/CodeBindingRecordServices.cs b/Admin.Core.Service/Service_New/CodeBindingRecordServices.cs index 9da2c907..8fb64445 100644 --- a/Admin.Core.Service/Service_New/CodeBindingRecordServices.cs +++ b/Admin.Core.Service/Service_New/CodeBindingRecordServices.cs @@ -117,11 +117,19 @@ namespace Admin.Core.Service /// public List GetAllProductModel() { - var _db = this.BaseDal.Db; - - List list = _db.Ado.SqlQuery("select * from C##AUCMA_SCADA.GET_OFFLINE_ALL_MODEL"); - - return list; + try + { + var _db = this.BaseDal.Db; + + List list = _db.Ado.SqlQuery("select * from C##AUCMA_SCADA.GET_OFFLINE_ALL_MODEL"); + + return list; + } + catch (Exception ex) + { + Console.WriteLine("GetAllProductModel异常:" + ex.Message.ToString()); + } + return null; } diff --git a/Aucma.Core.CodeBinding/Common/SpeechStr.cs b/Aucma.Core.CodeBinding/Common/SpeechStr.cs new file mode 100644 index 00000000..5a1dac7a --- /dev/null +++ b/Aucma.Core.CodeBinding/Common/SpeechStr.cs @@ -0,0 +1,36 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Speech.Synthesis; +using System.Text; +using System.Threading.Tasks; + +namespace Aucma.Core.CodeBinding.Common +{ + public class SpeechStr + { + private static readonly Lazy lazy = new Lazy(() => new SpeechStr()); + + public static SpeechStr Instance { + get + { + return lazy.Value; + } + } + + public void speech(string str) { + + SpeechSynthesizer speech = new SpeechSynthesizer(); + speech.Rate = 3;//设置语速 + speech.Volume = 100;//设置音量 + speech.SelectVoice("Microsoft Huihui Desktop");//设置播音员(中文) + speech.SpeakAsync(str); + + } + + + } + + + +} diff --git a/Aucma.Core.Palletiz/ViewModels/HandPalletizViewModel.cs b/Aucma.Core.Palletiz/ViewModels/HandPalletizViewModel.cs index 62d302f7..49058440 100644 --- a/Aucma.Core.Palletiz/ViewModels/HandPalletizViewModel.cs +++ b/Aucma.Core.Palletiz/ViewModels/HandPalletizViewModel.cs @@ -14,6 +14,7 @@ using System.Collections.Generic; using System.Collections.ObjectModel; using System.Linq; using System.Windows; +using System.Windows.Controls; namespace Aucma.Core.Palletiz.ViewModels { @@ -96,6 +97,7 @@ namespace Aucma.Core.Palletiz.ViewModels [RelayCommand] public void Save(Window window) { + Console.WriteLine(Area); if (string.IsNullOrEmpty(ProductCode)) { MessageBox.Show("请先选择产品型号"); @@ -147,6 +149,18 @@ namespace Aucma.Core.Palletiz.ViewModels #endregion + /// + /// 区域 + /// + private ComboBoxItem area; + public ComboBoxItem Area + { + get { return area; } + set => SetProperty(ref area, value); + + } + + #region 选中型号 private string productModel; diff --git a/Aucma.Core.Palletiz/ViewModels/IndexPageViewModel.cs b/Aucma.Core.Palletiz/ViewModels/IndexPageViewModel.cs index 4cc3b284..026b4e44 100644 --- a/Aucma.Core.Palletiz/ViewModels/IndexPageViewModel.cs +++ b/Aucma.Core.Palletiz/ViewModels/IndexPageViewModel.cs @@ -42,6 +42,7 @@ namespace Aucma.Core.Palletiz.ViewModels this.Init(); InStoreAmount = inStoreAmount + "19"; + InStoreTaskContent = new StatisticsPageView(); } #region 参数定义 @@ -111,6 +112,18 @@ namespace Aucma.Core.Palletiz.ViewModels } } + public System.Windows.Controls.UserControl _content; + + public System.Windows.Controls.UserControl InStoreTaskContent + { + get { return this._content; } + set + { + _content = value; + RaisePropertyChanged(nameof(InStoreTaskContent)); + } + } + /// /// A区域货道集合 /// diff --git a/Aucma.Core.Palletiz/ViewModels/MainWindowViewModel.cs b/Aucma.Core.Palletiz/ViewModels/MainWindowViewModel.cs index 434acf02..07de3695 100644 --- a/Aucma.Core.Palletiz/ViewModels/MainWindowViewModel.cs +++ b/Aucma.Core.Palletiz/ViewModels/MainWindowViewModel.cs @@ -22,6 +22,15 @@ namespace Aucma.Core.Palletiz.ViewModels { public partial class MainWindowViewModel : ObservableObject { + + /// + /// 扫描记录刷新 + /// + public delegate void RefreshInfo(); + public static event RefreshInfo? RefreshInfoEvent; + + + private static readonly log4net.ILog log = LogManager.GetLogger(typeof(MainWindowViewModel)); private IndexPageView firstPage = new IndexPageView();//首页 private StatisticsPageView recordPage = new StatisticsPageView(); @@ -215,6 +224,7 @@ namespace Aucma.Core.Palletiz.ViewModels UserContent = firstPage; break; case "RecordPage": + RefreshInfoEvent?.Invoke(); UserContent = recordPage; break; case "PalletizPage": diff --git a/Aucma.Core.Palletiz/ViewModels/StatisticsPageViewModel.cs b/Aucma.Core.Palletiz/ViewModels/StatisticsPageViewModel.cs index 03338044..2f4d9643 100644 --- a/Aucma.Core.Palletiz/ViewModels/StatisticsPageViewModel.cs +++ b/Aucma.Core.Palletiz/ViewModels/StatisticsPageViewModel.cs @@ -18,33 +18,48 @@ namespace Aucma.Core.Palletiz.ViewModels { public partial class StatisticsPageViewModel : ObservableObject { - public StatisticsPageViewModel() { LoadData(); } + // private static readonly Lazy lazy = new Lazy(() => new StatisticsPageViewModel()); + // public static StatisticsPageViewModel Instance => lazy.Value; + public StatisticsPageViewModel() { + MainWindowViewModel.RefreshInfoEvent += LoadData; + LoadData(); + } private readonly IRecordInStoreServices? _recordInstoreServices = App.ServiceProvider.GetService(); List materialComplateInfos = new List(); public string storeCodeA = Appsettings.app("StoreInfo", "PalletizStoreCodeA"); public string storeCodeB = Appsettings.app("StoreInfo", "PalletizStoreCodeB"); + #region 加载DataGrid数据 - private async void LoadData() + private async void LoadData() { - try - { - - List list = await _recordInstoreServices.QueryAsync(x => x.StoreCode == storeCodeA || x.StoreCode == storeCodeB); - if (list != null && list.Count > 0) + + //Task.Run(() => + //{ + try { - foreach (RecordInStore record in list) + + List list = await _recordInstoreServices.QueryAsync(x => (x.StoreCode == storeCodeA || x.StoreCode == storeCodeB) && x.InStoreTime >= DateTime.Today); + if (list != null && list.Count > 0) { - MaterialDataGrid.Add(record); + list.OrderByDescending(x => x.InStoreTime); + foreach (RecordInStore record in list) + { + App.Current.Dispatcher.Invoke(() => + { + MaterialDataGrid.Add(record); + }); + } } } - } - catch (Exception ex) - { - Console.WriteLine("" + ex.Message.ToString()); - - } + catch (Exception ex) + { + Console.WriteLine("" + ex.Message.ToString()); + + } + // }); + //MaterialDataGrid.Add(new MaterialComplateInfo() { No = 1, ProductPlanCode = "8659452123",MaterialCode = "8659452123", MaterialName = "SC-AUCMA-农夫山泉,SC", PlanAmount = 50, CompleteAmount = 10 }); } @@ -71,27 +86,25 @@ namespace Aucma.Core.Palletiz.ViewModels [RelayCommand] private void ExecQuery(object obj) { - string result =(string)obj; - - System.Windows.Application.Current.Dispatcher.Invoke((Action)(() => - { - if (!string.IsNullOrEmpty(result)) - { - MaterialDataGrid.Clear(); - - //foreach (MaterialComplateInfo info in materialDataGrid) - //{ - // MaterialDataGrid.Add(info); - //} - } - else + + string result = (string)obj; + List list = _recordInstoreServices.QueryAsync(x => (x.StoreCode == storeCodeA || x.StoreCode == storeCodeB) && x.BarCodeCode.Contains(result)).Result; + if (list != null && list.Count > 0) { MaterialDataGrid.Clear(); - LoadData(); + foreach (RecordInStore record in list) + { + App.Current.Dispatcher.Invoke(() => + { + MaterialDataGrid.Add(record); + }); + } } - //Datalist.Insert(0, Datalist[Datalist.Count - 1]); - //Datalist.RemoveAt(Datalist.Count - 1); - })); + + + + + } #endregion } diff --git a/Aucma.Core.Palletiz/Views/HandPalletizView.xaml b/Aucma.Core.Palletiz/Views/HandPalletizView.xaml index 6d65bd96..e5b71fd6 100644 --- a/Aucma.Core.Palletiz/Views/HandPalletizView.xaml +++ b/Aucma.Core.Palletiz/Views/HandPalletizView.xaml @@ -5,7 +5,7 @@ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d" WindowStartupLocation="CenterScreen" FontFamily="Microsoft YaHei" - Title="手动分垛" Height="800" Width="1300" Name="window" Background="White" + Title="手动分垛" Height="800" Width="1600" Name="window" Background="White" ResizeMode="NoResize"> @@ -126,17 +126,24 @@ -