From 3e44f4453a324afbb77dd08cbea2401e89ba2fcf Mon Sep 17 00:00:00 2001 From: liuwf Date: Sat, 30 Mar 2024 11:52:46 +0800 Subject: [PATCH 1/7] =?UTF-8?q?change-=E5=88=86=E5=9E=9B=E7=95=8C=E9=9D=A2?= =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Business/InstoreBusiness.cs | 13 ++- .../ViewModels/HandPalletizViewModel.cs | 8 +- .../ViewModels/IndexPageViewModel.cs | 110 ++++++++++-------- .../ViewModels/PalletizPageViewModel.cs | 2 +- .../ViewModels/SelectTypeViewModel.cs | 2 +- .../ViewModels/StatisticsPageViewModel.cs | 90 ++++++++------ .../Views/StatisticsPageView.xaml | 12 +- .../Views/StatisticsPageView.xaml.cs | 4 + 8 files changed, 154 insertions(+), 87 deletions(-) diff --git a/Aucma.Core.Palletiz/Business/InstoreBusiness.cs b/Aucma.Core.Palletiz/Business/InstoreBusiness.cs index 9ceea115..9f319776 100644 --- a/Aucma.Core.Palletiz/Business/InstoreBusiness.cs +++ b/Aucma.Core.Palletiz/Business/InstoreBusiness.cs @@ -54,7 +54,14 @@ namespace Aucma.Core.Palletiz.Business /// public delegate void RefreshMsg(string msg); public static event RefreshMsg? RefreshMsgEvent; - + + + /// + ///入库时DataGrid添加一条DataGrid记录 + /// + public delegate void AddData(RecordInStore record); + public static event AddData? AddDataEvent; + #endregion @@ -177,6 +184,8 @@ namespace Aucma.Core.Palletiz.Business } _ = _recordInstoreServices.AddAsync(recordInstore).Result; + //刷新页面 + AddDataEvent?.Invoke(recordInstore); #endregion if (!result) @@ -267,7 +276,7 @@ namespace Aucma.Core.Palletiz.Business if (plcCon == null) { - Task.Delay(1000 * 5).Wait(); + Task.Delay(1000 * 3).Wait(); plcCon = PlcHelper.melsecList.FirstOrDefault(d => d.EquipName.Equals("InStoreAPlc")); if(plcCon == null) diff --git a/Aucma.Core.Palletiz/ViewModels/HandPalletizViewModel.cs b/Aucma.Core.Palletiz/ViewModels/HandPalletizViewModel.cs index 49058440..381dabac 100644 --- a/Aucma.Core.Palletiz/ViewModels/HandPalletizViewModel.cs +++ b/Aucma.Core.Palletiz/ViewModels/HandPalletizViewModel.cs @@ -97,14 +97,18 @@ namespace Aucma.Core.Palletiz.ViewModels [RelayCommand] public void Save(Window window) { - Console.WriteLine(Area); + if (Area == null) + { + MessageBox.Show("请先选择区域"); + return; + } if (string.IsNullOrEmpty(ProductCode)) { MessageBox.Show("请先选择产品型号"); return; } - HandSendEvent?.Invoke("A", productCode); + HandSendEvent?.Invoke(Area.Content.ToString(), productCode); MessageBox.Show("手动入库成功"); window.Close(); // 入库 diff --git a/Aucma.Core.Palletiz/ViewModels/IndexPageViewModel.cs b/Aucma.Core.Palletiz/ViewModels/IndexPageViewModel.cs index 48f294cf..78ec4a3f 100644 --- a/Aucma.Core.Palletiz/ViewModels/IndexPageViewModel.cs +++ b/Aucma.Core.Palletiz/ViewModels/IndexPageViewModel.cs @@ -8,6 +8,8 @@ using System.Collections.ObjectModel; using System.Linq; using Aucma.Core.Palletiz.Views; using CommunityToolkit.Mvvm.ComponentModel; +using System.Threading.Tasks; +using static Aucma.Core.Palletiz.ViewModels.StatisticsPageViewModel; /* * 成品分垛入库首页信息 @@ -24,6 +26,7 @@ namespace Aucma.Core.Palletiz.ViewModels new InStoreBusiness().Init(); SelectTypeViewModel.RefreshPageEvent += Init; + StatisticsPageViewModel.CountInstoreEvent += CountInstore; this.inStoreBusiness = App.ServiceProvider.GetService(); InStoreBusiness.RefreshMsgEvent += RefreshMsg; InStoreBusiness.RefreshProductInfoEvent += RefreshProductInfo; @@ -31,20 +34,26 @@ namespace Aucma.Core.Palletiz.ViewModels { Console.WriteLine($"{obj};设置"); BaseSpaceInfo space = inStoreBusiness.GetSpaceinfosById(obj); - if(space != null ) + if (space != null) { SelectType direct = new SelectType(space); direct.ShowDialog(); } - + }); this.Init(); - InStoreAmount = inStoreAmount + "19"; + InStoreTaskContent = new StatisticsPageView(); } + public void CountInstore(int count) + { + InStoreAmount = "入库数量:"; + InStoreAmount = inStoreAmount + count; + } + #region 参数定义 public string productSNCode = string.Empty; @@ -55,12 +64,12 @@ namespace Aucma.Core.Palletiz.ViewModels } - public string productModel = string.Empty; + public string productModel = string.Empty; public string ProductModel { get { return this.productModel; } set => SetProperty(ref productModel, value); - + } public string orderCode = string.Empty; @@ -69,7 +78,7 @@ namespace Aucma.Core.Palletiz.ViewModels get { return this.orderCode; } set => SetProperty(ref orderCode, value); - + } public string productScanTime = string.Empty; @@ -77,7 +86,7 @@ namespace Aucma.Core.Palletiz.ViewModels { get { return this.productScanTime; } - set => SetProperty(ref productScanTime, value); + set => SetProperty(ref productScanTime, value); } public string msg = string.Empty; @@ -85,7 +94,7 @@ namespace Aucma.Core.Palletiz.ViewModels { get { return this.msg; } set => SetProperty(ref msg, value); - + } public string inStoreAmount = "入库数量:"; public string InStoreAmount @@ -93,7 +102,7 @@ namespace Aucma.Core.Palletiz.ViewModels get { return this.inStoreAmount; } set => SetProperty(ref inStoreAmount, value); - + } public System.Windows.Controls.UserControl _content; @@ -104,7 +113,7 @@ namespace Aucma.Core.Palletiz.ViewModels set => SetProperty(ref _content, value); - + } /// @@ -116,7 +125,7 @@ namespace Aucma.Core.Palletiz.ViewModels { get { return _areaA_SpaceInfo; } set => SetProperty(ref _areaA_SpaceInfo, value); - + } /// @@ -128,7 +137,7 @@ namespace Aucma.Core.Palletiz.ViewModels { get { return _areaB_SpaceInfo; } set => SetProperty(ref _areaB_SpaceInfo, value); - + } #endregion @@ -160,46 +169,55 @@ namespace Aucma.Core.Palletiz.ViewModels OrderCode = orderCode; ProductScanTime = DateTime.Now.ToString(); } - private void Init() + private async Task Init() { - - var info = inStoreBusiness.GetBaseSpaceinfos("A"); - info = info.OrderByDescending(x => x.ObjId).ToList(); - if (info != null) + await Task.Run(() => { - App.Current.Dispatcher.BeginInvoke((Action)(() => + var info = inStoreBusiness.GetBaseSpaceinfos("A"); + info = info.OrderByDescending(x => x.ObjId).ToList(); + if (info != null) { - if (spaceItems.Count > 0) + App.Current.Dispatcher.BeginInvoke((Action)(() => { - spaceItems.Clear(); - } - foreach (var item in info) + if (spaceItems.Count > 0) + { + spaceItems.Clear(); + } + foreach (var item in info) + { + spaceItems.Add(item); + } + AreaA_SpaceInfo = spaceItems; + })); + } + + var info2 = inStoreBusiness.GetBaseSpaceinfos("A"); + info2 = info2.OrderBy(x => x.ObjId).ToList(); + if (info2 != null) + { + App.Current.Dispatcher.BeginInvoke((Action)(() => { - spaceItems.Add(item); - } - AreaA_SpaceInfo = spaceItems; - })); - } - - - //var info2 = inStoreBusiness.GetBaseSpaceinfos("A"); - //info2 = info2.OrderBy(x => x.ObjId).ToList(); - //if (info2 != null) - //{ - // App.Current.Dispatcher.BeginInvoke((Action)(() => - // { - // if (spaceItemsB.Count > 0) - // { - // spaceItemsB.Clear(); - // } - // foreach (var item in info2) - // { - // spaceItemsB.Add(item); - // } - // AreaB_SpaceInfo = spaceItemsB; - // })); - //} + if (spaceItemsB.Count > 0) + { + spaceItemsB.Clear(); + } + foreach (var item in info2) + { + spaceItemsB.Add(item); + } + AreaB_SpaceInfo = spaceItemsB; + })); + } + + }); + + } + + + + } } + diff --git a/Aucma.Core.Palletiz/ViewModels/PalletizPageViewModel.cs b/Aucma.Core.Palletiz/ViewModels/PalletizPageViewModel.cs index 250eb1e5..d4b6d6b5 100644 --- a/Aucma.Core.Palletiz/ViewModels/PalletizPageViewModel.cs +++ b/Aucma.Core.Palletiz/ViewModels/PalletizPageViewModel.cs @@ -20,7 +20,7 @@ namespace Aucma.Core.Palletiz.ViewModels public PalletizPageViewModel() { _baseSpaceInfoServices = App.ServiceProvider.GetService(); LoadDataGrid(); - SelectTypeViewModel.RefreshPageEvent += LoadDataGrid; + // SelectTypeViewModel.RefreshPageEvent += LoadDataGrid; } public void LoadDataGrid() diff --git a/Aucma.Core.Palletiz/ViewModels/SelectTypeViewModel.cs b/Aucma.Core.Palletiz/ViewModels/SelectTypeViewModel.cs index d4257d3c..651afb9f 100644 --- a/Aucma.Core.Palletiz/ViewModels/SelectTypeViewModel.cs +++ b/Aucma.Core.Palletiz/ViewModels/SelectTypeViewModel.cs @@ -33,7 +33,7 @@ namespace Aucma.Core.Palletiz.ViewModels /// 刷新货道页面 /// /// - public delegate void RefreshPage(); + public delegate Task RefreshPage(); public static event RefreshPage RefreshPageEvent; private static readonly log4net.ILog logHelper = LogManager.GetLogger(typeof(BaseSpaceInfoServices)); diff --git a/Aucma.Core.Palletiz/ViewModels/StatisticsPageViewModel.cs b/Aucma.Core.Palletiz/ViewModels/StatisticsPageViewModel.cs index 69cfb168..08348c86 100644 --- a/Aucma.Core.Palletiz/ViewModels/StatisticsPageViewModel.cs +++ b/Aucma.Core.Palletiz/ViewModels/StatisticsPageViewModel.cs @@ -1,6 +1,7 @@ using Admin.Core.Common; using Admin.Core.IService; using Admin.Core.Model; +using Aucma.Core.Palletiz.Business; using Aucma.Core.Palletiz.Models; using CommunityToolkit.Mvvm.ComponentModel; using CommunityToolkit.Mvvm.Input; @@ -13,15 +14,28 @@ using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows; +using System.Windows.Documents; namespace Aucma.Core.Palletiz.ViewModels { public partial class StatisticsPageViewModel : ObservableObject { - // private static readonly Lazy lazy = new Lazy(() => new StatisticsPageViewModel()); - // public static StatisticsPageViewModel Instance => lazy.Value; - public StatisticsPageViewModel() { + + + /// + /// 入库数量统计 + /// + public delegate void CountInstore(int count); + public static event CountInstore? CountInstoreEvent; + + + + // private static readonly Lazy lazy = new Lazy(() => new StatisticsPageViewModel()); + // public static StatisticsPageViewModel Instance => lazy.Value; + public StatisticsPageViewModel() + { MainWindowViewModel.RefreshInfoEvent += LoadData; + InStoreBusiness.AddDataEvent += AddData; LoadData(); } private readonly IRecordInStoreServices? _recordInstoreServices = App.ServiceProvider.GetService(); @@ -30,36 +44,46 @@ namespace Aucma.Core.Palletiz.ViewModels public string storeCodeB = Appsettings.app("StoreInfo", "PalletizStoreCodeB"); - + + /// + /// 入库时DataGrid添加一条记录 + /// + /// + public void AddData(RecordInStore record) + { + MaterialDataGrid.Add(record); + CountInstoreEvent?.Invoke(MaterialDataGrid.Count); + } + #region 加载DataGrid数据 - private async Task LoadData() + private async Task LoadData() { + await Task.Run(() => + { + try + { - await Task.Run(() => - { - try - { + List list = _recordInstoreServices.QueryAsync(x => (x.StoreCode == storeCodeA || x.StoreCode == storeCodeB) && x.InStoreTime >= DateTime.Today).Result; + if (list != null && list.Count > 0) + { + CountInstoreEvent?.Invoke(list.Count); + 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()); - List list = _recordInstoreServices.QueryAsync(x => (x.StoreCode == storeCodeA || x.StoreCode == storeCodeB) && x.InStoreTime >= DateTime.Today).Result; - if (list != null && list.Count > 0) - { - 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()); + } + }); - } - }); - //MaterialDataGrid.Add(new MaterialComplateInfo() { No = 1, ProductPlanCode = "8659452123",MaterialCode = "8659452123", MaterialName = "SC-AUCMA-农夫山泉,SC", PlanAmount = 50, CompleteAmount = 10 }); } @@ -93,14 +117,14 @@ namespace Aucma.Core.Palletiz.ViewModels List list = _recordInstoreServices.QueryAsync(x => (x.StoreCode == storeCodeA || x.StoreCode == storeCodeB) && x.BarCodeCode.Contains(result)).Result; if (list != null && list.Count > 0) { - MaterialDataGrid.Clear(); - foreach (RecordInStore record in list) + App.Current.Dispatcher.Invoke(() => { - App.Current.Dispatcher.Invoke(() => + MaterialDataGrid.Clear(); + foreach (RecordInStore record in list) { MaterialDataGrid.Add(record); - }); - } + } + }); } }); } diff --git a/Aucma.Core.Palletiz/Views/StatisticsPageView.xaml b/Aucma.Core.Palletiz/Views/StatisticsPageView.xaml index 518741da..4c377bb6 100644 --- a/Aucma.Core.Palletiz/Views/StatisticsPageView.xaml +++ b/Aucma.Core.Palletiz/Views/StatisticsPageView.xaml @@ -108,12 +108,20 @@ + - + + + + + + + + diff --git a/Aucma.Core.Palletiz/Views/StatisticsPageView.xaml.cs b/Aucma.Core.Palletiz/Views/StatisticsPageView.xaml.cs index 5eae4837..9b6d4ddf 100644 --- a/Aucma.Core.Palletiz/Views/StatisticsPageView.xaml.cs +++ b/Aucma.Core.Palletiz/Views/StatisticsPageView.xaml.cs @@ -27,5 +27,9 @@ namespace Aucma.Core.Palletiz.Views this.DataContext = new StatisticsPageViewModel(); } + private void DataGrid_LoadingRow(object sender, DataGridRowEventArgs e) + { + e.Row.Header = (e.Row.GetIndex() + 1).ToString(); + } } } From 77ab83aed8598f0eb0753dad9df51cc1784f3a28 Mon Sep 17 00:00:00 2001 From: liuwf Date: Sat, 30 Mar 2024 12:39:43 +0800 Subject: [PATCH 2/7] =?UTF-8?q?change-=E6=8F=90=E4=BA=A4=E6=88=90=E5=93=81?= =?UTF-8?q?=E4=B8=8B=E7=BA=BF=E8=A7=A3=E5=86=B3=E6=96=B9=E6=A1=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../net6.0/Admin.Core.Common.AssemblyInfo.cs | 2 +- .../Admin.Core.Common.AssemblyInfoInputs.cache | 2 +- ...n.GeneratedMSBuildEditorConfig.editorconfig | 4 +--- Admin.Core.sln | 7 +++++++ .../Business/InstoreBusiness.cs | 4 ++-- .../ViewModels/HandPalletizViewModel.cs | 1 + .../ViewModels/StatisticsPageViewModel.cs | 18 ++++++++++++------ .../Views/HandPalletizView.xaml | 2 +- 8 files changed, 26 insertions(+), 14 deletions(-) diff --git a/Admin.Core.Common/obj/Debug/net6.0/Admin.Core.Common.AssemblyInfo.cs b/Admin.Core.Common/obj/Debug/net6.0/Admin.Core.Common.AssemblyInfo.cs index a0a51780..2aa8fa0f 100644 --- a/Admin.Core.Common/obj/Debug/net6.0/Admin.Core.Common.AssemblyInfo.cs +++ b/Admin.Core.Common/obj/Debug/net6.0/Admin.Core.Common.AssemblyInfo.cs @@ -14,7 +14,7 @@ using System.Reflection; [assembly: System.Reflection.AssemblyCompanyAttribute("Admin.Core.Common")] [assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")] [assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")] -[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+b14cee841cc126714bd9974bfb490340b0c3a348")] +[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0")] [assembly: System.Reflection.AssemblyProductAttribute("Admin.Core.Common")] [assembly: System.Reflection.AssemblyTitleAttribute("Admin.Core.Common")] [assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")] diff --git a/Admin.Core.Common/obj/Debug/net6.0/Admin.Core.Common.AssemblyInfoInputs.cache b/Admin.Core.Common/obj/Debug/net6.0/Admin.Core.Common.AssemblyInfoInputs.cache index 90a3f1b9..b3b30e6b 100644 --- a/Admin.Core.Common/obj/Debug/net6.0/Admin.Core.Common.AssemblyInfoInputs.cache +++ b/Admin.Core.Common/obj/Debug/net6.0/Admin.Core.Common.AssemblyInfoInputs.cache @@ -1 +1 @@ -084e48044896d89835d97ecf2b6482131ddb1364494a27aefb0b1990a1319ddf +3c08b2a6f95957043123cba0d01dcd1675663fc7 diff --git a/Admin.Core.Common/obj/Debug/net6.0/Admin.Core.Common.GeneratedMSBuildEditorConfig.editorconfig b/Admin.Core.Common/obj/Debug/net6.0/Admin.Core.Common.GeneratedMSBuildEditorConfig.editorconfig index 124dffb6..e43b7078 100644 --- a/Admin.Core.Common/obj/Debug/net6.0/Admin.Core.Common.GeneratedMSBuildEditorConfig.editorconfig +++ b/Admin.Core.Common/obj/Debug/net6.0/Admin.Core.Common.GeneratedMSBuildEditorConfig.editorconfig @@ -8,6 +8,4 @@ build_property.PlatformNeutralAssembly = build_property.EnforceExtendedAnalyzerRules = build_property._SupportedPlatformList = Linux,macOS,Windows build_property.RootNamespace = Admin.Core.Common -build_property.ProjectDir = D:\Project\gitea\AUCMA\SCADA\Admin.Core.Common\ -build_property.EnableComHosting = -build_property.EnableGeneratedComInterfaceComImportInterop = +build_property.ProjectDir = E:\c#\AUCMA\new\Admin.Core.Common\ diff --git a/Admin.Core.sln b/Admin.Core.sln index 67ec2494..bbd02f6e 100644 --- a/Admin.Core.sln +++ b/Admin.Core.sln @@ -83,6 +83,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Aucma.Core.SheetMetal", "Au EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Aucma.Core.DataCollector", "Aucma.Core.DataCollector\Aucma.Core.DataCollector.csproj", "{DF628848-79A6-4234-A0F6-F961DFC16A0E}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Aucma.Core.ProductOffLine", "Aucma.Core.ProductOffLine\Aucma.Core.ProductOffLine.csproj", "{1582FB18-5185-41A0-B185-914501B3FBFA}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -213,6 +215,10 @@ Global {DF628848-79A6-4234-A0F6-F961DFC16A0E}.Debug|Any CPU.Build.0 = Debug|Any CPU {DF628848-79A6-4234-A0F6-F961DFC16A0E}.Release|Any CPU.ActiveCfg = Release|Any CPU {DF628848-79A6-4234-A0F6-F961DFC16A0E}.Release|Any CPU.Build.0 = Release|Any CPU + {1582FB18-5185-41A0-B185-914501B3FBFA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {1582FB18-5185-41A0-B185-914501B3FBFA}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1582FB18-5185-41A0-B185-914501B3FBFA}.Release|Any CPU.ActiveCfg = Release|Any CPU + {1582FB18-5185-41A0-B185-914501B3FBFA}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -252,6 +258,7 @@ Global {B6955077-EEE5-429B-8A79-EDE749A8B034} = {BD987F3A-4E6C-4C47-B28F-1671F875EAE3} {D452CA9F-2CF9-4978-B0BE-7365F1F7A4EB} = {BD987F3A-4E6C-4C47-B28F-1671F875EAE3} {DF628848-79A6-4234-A0F6-F961DFC16A0E} = {F8FB57F6-5465-4E60-B052-D3A63C3C56AE} + {1582FB18-5185-41A0-B185-914501B3FBFA} = {BD987F3A-4E6C-4C47-B28F-1671F875EAE3} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {8047AB56-042B-4AE4-B06A-34137067A86A} diff --git a/Aucma.Core.Palletiz/Business/InstoreBusiness.cs b/Aucma.Core.Palletiz/Business/InstoreBusiness.cs index 9f319776..d9663bde 100644 --- a/Aucma.Core.Palletiz/Business/InstoreBusiness.cs +++ b/Aucma.Core.Palletiz/Business/InstoreBusiness.cs @@ -292,8 +292,8 @@ namespace Aucma.Core.Palletiz.Business { item.SpaceCode = ExtractNumber(item.SpaceName); var plcAddress = _appConfig.plcAddr.Where(x => x.spaceCode.ToString() == item.SpaceCode && x.spaceArea == item.SpaceArea).First(); - int isFlag = _plc.ReadInt16(plcAddress.address); - if (isFlag == 1) + bool isFlag = _plc.ReadBool(plcAddress.address); + if (isFlag) { item.SpaceStatus = 3; } diff --git a/Aucma.Core.Palletiz/ViewModels/HandPalletizViewModel.cs b/Aucma.Core.Palletiz/ViewModels/HandPalletizViewModel.cs index 381dabac..ae3dc75a 100644 --- a/Aucma.Core.Palletiz/ViewModels/HandPalletizViewModel.cs +++ b/Aucma.Core.Palletiz/ViewModels/HandPalletizViewModel.cs @@ -52,6 +52,7 @@ namespace Aucma.Core.Palletiz.ViewModels foreach (ProductAllModel info in list) { MaterialDataGrid.Add(info); + } }); } diff --git a/Aucma.Core.Palletiz/ViewModels/StatisticsPageViewModel.cs b/Aucma.Core.Palletiz/ViewModels/StatisticsPageViewModel.cs index 08348c86..e56f017c 100644 --- a/Aucma.Core.Palletiz/ViewModels/StatisticsPageViewModel.cs +++ b/Aucma.Core.Palletiz/ViewModels/StatisticsPageViewModel.cs @@ -51,8 +51,11 @@ namespace Aucma.Core.Palletiz.ViewModels /// public void AddData(RecordInStore record) { + App.Current.Dispatcher.Invoke(() => + { MaterialDataGrid.Add(record); CountInstoreEvent?.Invoke(MaterialDataGrid.Count); + }); } #region 加载DataGrid数据 @@ -66,15 +69,18 @@ namespace Aucma.Core.Palletiz.ViewModels List list = _recordInstoreServices.QueryAsync(x => (x.StoreCode == storeCodeA || x.StoreCode == storeCodeB) && x.InStoreTime >= DateTime.Today).Result; if (list != null && list.Count > 0) { - CountInstoreEvent?.Invoke(list.Count); - list.OrderByDescending(x => x.InStoreTime); - foreach (RecordInStore record in list) + App.Current.Dispatcher.Invoke(() => { - App.Current.Dispatcher.Invoke(() => + MaterialDataGrid.Clear(); + CountInstoreEvent?.Invoke(list.Count); + list.OrderByDescending(x => x.InStoreTime); + foreach (RecordInStore record in list) { + MaterialDataGrid.Add(record); - }); - } + + } + }); } } catch (Exception ex) diff --git a/Aucma.Core.Palletiz/Views/HandPalletizView.xaml b/Aucma.Core.Palletiz/Views/HandPalletizView.xaml index e5b71fd6..951174e9 100644 --- a/Aucma.Core.Palletiz/Views/HandPalletizView.xaml +++ b/Aucma.Core.Palletiz/Views/HandPalletizView.xaml @@ -113,7 +113,7 @@ From 6ce4a910ba6ad4004ed2797287e917770e948cc7 Mon Sep 17 00:00:00 2001 From: wenjy Date: Sat, 30 Mar 2024 12:40:22 +0800 Subject: [PATCH 3/7] =?UTF-8?q?change=20-=20=E4=BF=AE=E6=94=B9=E7=8F=AD?= =?UTF-8?q?=E7=BB=84=E5=88=87=E6=8D=A2=EF=BC=8C=E6=B3=A8=E9=87=8Amain?= =?UTF-8?q?=E4=B8=AD=E7=9A=84//await=20ClearProduct();?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Business/TeamSwitchBusiness.cs | 85 +++++++++++++------ .../ViewModels/MainWindowViewModel.cs | 2 +- 2 files changed, 60 insertions(+), 27 deletions(-) diff --git a/Aucma.Core.BoxFoam/Business/TeamSwitchBusiness.cs b/Aucma.Core.BoxFoam/Business/TeamSwitchBusiness.cs index bcf96c1c..51fe91cb 100644 --- a/Aucma.Core.BoxFoam/Business/TeamSwitchBusiness.cs +++ b/Aucma.Core.BoxFoam/Business/TeamSwitchBusiness.cs @@ -146,36 +146,41 @@ namespace Aucma.Core.BoxFoam.Business private void UpdateShiftInfo(int shiftType) { log.Warn($"{(shiftType == 1 ? "白班" : "夜班")}班组切换,开始处理切换逻辑"); + Console.WriteLine($"{(shiftType == 1 ? "白班" : "夜班")}班组切换,开始处理切换逻辑"); try { - #region 240325 添加清空夹具产量功能 + #region 240325 liulb 添加清空夹具产量功能; Delete By wenjy 2024-03-30 删除清空产量逻辑 //下发PLC清空产量信号 - #region 清空PLC产量,新线暂时未清除产量,如需清除可将注释取消 - var obj1 = PlcHelper.siemensList.FirstOrDefault(d => d.EquipName.Equals("foamLine1Plc")); - if (obj1 != null) - { - if (obj1.plc.IsConnected) - { - var flag = obj1.plc.WriteBool("M6.0", true);//换班 数据清空 - Thread.Sleep(500); - obj1.plc.WriteBool("M6.0", false);//数据清空后复位 - Console.WriteLine($"【{DateTime.Now}】班组切换清空1~6区产量数据:{(flag == true ? "成功" : "失败")}"); - log.Warn($"班组切换清空1~6区产量数据:{(flag == true ? "成功" : "失败")}"); - } - } - var obj2 = PlcHelper.siemensList.FirstOrDefault(d => d.EquipName.Equals("foamLine2Plc")); - if (obj2 != null) - { - if (obj2.plc.IsConnected) - { - bool flag = obj2.plc.WriteBool("M6.0", true);//换班 数据清空 - Thread.Sleep(500); - obj2.plc.WriteBool("M6.0", false);//数据清空后复位 - Console.WriteLine($"【{DateTime.Now}】班组切换清空7~12区产量数据:{(flag == true ? "成功" : "失败")}"); - log.Warn($"班组切换清空7~12区产量数据:{(flag == true ? "成功" : "失败")}"); - } - } + //var obj1 = PlcHelper.siemensList.FirstOrDefault(d => d.EquipName.Equals("foamLine1Plc")); + //if (obj1 != null) + //{ + // if (obj1.plc.IsConnected) + // { + // var flag = obj1.plc.WriteBool("M6.0", true);//换班 数据清空 + // Thread.Sleep(500); + // obj1.plc.WriteBool("M6.0", false);//数据清空后复位 + // Console.WriteLine($"【{DateTime.Now}】班组切换清空1~6区产量数据:{(flag == true ? "成功" : "失败")}"); + // log.Warn($"班组切换清空1~6区产量数据:{(flag == true ? "成功" : "失败")}"); + // } + //} + //var obj2 = PlcHelper.siemensList.FirstOrDefault(d => d.EquipName.Equals("foamLine2Plc")); + //if (obj2 != null) + //{ + // if (obj2.plc.IsConnected) + // { + // bool flag = obj2.plc.WriteBool("M6.0", true);//换班 数据清空 + // Thread.Sleep(500); + // obj2.plc.WriteBool("M6.0", false);//数据清空后复位 + // Console.WriteLine($"【{DateTime.Now}】班组切换清空7~12区产量数据:{(flag == true ? "成功" : "失败")}"); + // log.Warn($"班组切换清空7~12区产量数据:{(flag == true ? "成功" : "失败")}"); + // } + //} #endregion + + #region Add By wenjy 2024-03-30 10:56:00 清空PLC产量,写true保持500毫秒后写false + ClearPlcOutPut(true); + Thread.Sleep(3000); + ClearPlcOutPut(false); #endregion //小时统计报表数据存至记录表,清空小时统计报表 @@ -274,5 +279,33 @@ namespace Aucma.Core.BoxFoam.Business log.Warn($"{(shiftType == 1 ? "白班" : "夜班")}班组切换,切换逻辑处理异常:{ex.Message}"); } } + + /// + /// 清空PLC产量数据 + /// + /// + private void ClearPlcOutPut(bool value) + { + var obj1 = PlcHelper.siemensList.FirstOrDefault(d => d.EquipName.Equals("foamLine1Plc")); + if (obj1 != null) + { + if (obj1.plc.IsConnected) + { + var flag = obj1.plc.WriteBool("M6.0", value);//换班 数据清空 + log.Warn($"班组切换清空A区产量数据写{value}:{(flag == true ? "成功" : "失败")}"); + Console.WriteLine($"班组切换清空A区产量数据写{value}:{(flag == true ? "成功" : "失败")}"); + } + } + var obj2 = PlcHelper.siemensList.FirstOrDefault(d => d.EquipName.Equals("foamLine2Plc")); + if (obj2 != null) + { + if (obj2.plc.IsConnected) + { + bool flag = obj2.plc.WriteBool("M6.0", value);//换班 数据清空 + log.Warn($"班组切换清空B区产量数据写{value}:{(flag == true ? "成功" : "失败")}"); + Console.WriteLine($"班组切换清空B区产量数据写{value}:{(flag == true ? "成功" : "失败")}"); + } + } + } } } diff --git a/Aucma.Core.BoxFoam/ViewModels/MainWindowViewModel.cs b/Aucma.Core.BoxFoam/ViewModels/MainWindowViewModel.cs index a10e728d..a14025df 100644 --- a/Aucma.Core.BoxFoam/ViewModels/MainWindowViewModel.cs +++ b/Aucma.Core.BoxFoam/ViewModels/MainWindowViewModel.cs @@ -48,7 +48,7 @@ namespace Aucma.Core.BoxFoam.ViewModels { await init(); await RefreshTeamTime();//班组时间 - await ClearProduct(); + //await ClearProduct(); }); TeamSwitchBusiness teamSwitchBusiness = new TeamSwitchBusiness(); From 401487996f6308c24e43fd3426c25bb508a36e17 Mon Sep 17 00:00:00 2001 From: liuwf Date: Sat, 30 Mar 2024 14:35:11 +0800 Subject: [PATCH 4/7] =?UTF-8?q?change-=E8=AE=BE=E5=A4=87=E7=94=B5=E9=87=8F?= =?UTF-8?q?=E9=87=87=E9=9B=86=E6=97=B6=E9=97=B45s=E6=94=B9=E4=B8=BA5min?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Aucma.Core.DataCollector/DataCollectorFactory.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Aucma.Core.DataCollector/DataCollectorFactory.cs b/Aucma.Core.DataCollector/DataCollectorFactory.cs index 011ff764..a6e120fd 100644 --- a/Aucma.Core.DataCollector/DataCollectorFactory.cs +++ b/Aucma.Core.DataCollector/DataCollectorFactory.cs @@ -25,7 +25,7 @@ namespace Aucma.Core.DataCollector public readonly IRecordDeviceElectricityServices _deviceElectricityServices; public int AlarmReadTimer = (1000 * 5); - public int EleReadTimer = (1000 * 5); + public int EleReadTimer = (1000 * 60 * 5); public DataCollectorFactory(IBaseDeviceParamServices deviceParamServices, IRecordDeviceAlarmInfoServices deviceAlarmInfoServices, IRecordDeviceElectricityServices deviceElectricityServices) { From 987a66bb7838c7576b7cbfe37b2af8a35be83d5f Mon Sep 17 00:00:00 2001 From: liuwf Date: Sat, 30 Mar 2024 14:42:41 +0800 Subject: [PATCH 5/7] =?UTF-8?q?change-=E8=BF=87=E7=82=B9=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E6=9A=82=E4=B8=8D=E6=B7=BB=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Business/InstoreBusiness.cs | 38 +++++++++++++++++-- 1 file changed, 35 insertions(+), 3 deletions(-) diff --git a/Aucma.Core.Palletiz/Business/InstoreBusiness.cs b/Aucma.Core.Palletiz/Business/InstoreBusiness.cs index d9663bde..21bb48c6 100644 --- a/Aucma.Core.Palletiz/Business/InstoreBusiness.cs +++ b/Aucma.Core.Palletiz/Business/InstoreBusiness.cs @@ -37,8 +37,11 @@ namespace Aucma.Core.Palletiz.Business private AppConfig appConfig = new AppConfig(); public string storeCode = Appsettings.app("StoreInfo", "PalletizStoreCodeA"); + // 过点数据表,物料完成记录MaterialCompletion + private readonly IMaterialCompletionServices? _iMaterialCompletionServices = App.ServiceProvider.GetService(); - + private readonly IPrintBarCodeServices? _printBarCodeServices = App.ServiceProvider.GetService(); + private readonly ICodeBindingRecordServices? _codeBindingServices = App.ServiceProvider.GetService(); private readonly IRecordInStoreServices? _recordInstoreServices = App.ServiceProvider.GetService(); #region 委托事件 @@ -217,10 +220,39 @@ namespace Aucma.Core.Palletiz.Business RefreshMsgEvent?.Invoke(msg); } + } + /// + /// 添加过点数据,暂不添加 + /// + /// + public async Task AddCompleteData(string ProductSnCode) + { + CodeBindingRecord bindingRecord1 = _codeBindingServices.FirstAsync(x => x.ProductCode == ProductSnCode).Result; + #region 更新过点数据 + if (bindingRecord1 != null && bindingRecord1.BoxCode != "") + { + PrintBarCode print = _printBarCodeServices.FirstAsync(x => x.MaterialBarcode == bindingRecord1.BoxCode).Result; + if (print != null) + { + MaterialCompletion completion = new MaterialCompletion(); + completion.OrderCode = print.OrderCode; + completion.MaterialBarcode = bindingRecord1.BoxCode; + completion.MaterialCode = print.MaterialCode; + completion.MaterialName = print.MaterialName; + // completion.StationName = "1009"; + completion.CompleteDate = DateTime.Now; + completion.ProductLineCode = "CX_02"; + completion.isDownLine = 1; + completion.ProductionCode = ProductSnCode; + _ = _iMaterialCompletionServices.AddAsync(completion).Result; + + } + } + + #endregion + } - - /// /// 通过物料型号获取货道信息 /// From f7ce58016c198e41f5ff91a4c780367b11d09d2b Mon Sep 17 00:00:00 2001 From: liuwf Date: Sat, 30 Mar 2024 15:13:37 +0800 Subject: [PATCH 6/7] =?UTF-8?q?change-=E6=88=90=E5=93=81=E4=B8=8B=E7=BA=BF?= =?UTF-8?q?=E7=95=8C=E9=9D=A2=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Aucma.Core.CodeBinding/Startup.cs | 1 + Aucma.Core.ProductOffLine/Startup.cs | 18 ++++++++++++++---- .../Views/ChooseDirectionWindow.xaml | 4 ++-- .../Views/HandSendPlcWindow.xaml | 4 ++-- 4 files changed, 19 insertions(+), 8 deletions(-) diff --git a/Aucma.Core.CodeBinding/Startup.cs b/Aucma.Core.CodeBinding/Startup.cs index 97613316..23ff0d9e 100644 --- a/Aucma.Core.CodeBinding/Startup.cs +++ b/Aucma.Core.CodeBinding/Startup.cs @@ -116,6 +116,7 @@ namespace Aucma.Core.CodeBinding // Socketɨ app.UseTouchSocketMildd(socket); + // ݺõɼɼ app.UseDataCollectorExtensions(); } diff --git a/Aucma.Core.ProductOffLine/Startup.cs b/Aucma.Core.ProductOffLine/Startup.cs index 29719ee5..9d751814 100644 --- a/Aucma.Core.ProductOffLine/Startup.cs +++ b/Aucma.Core.ProductOffLine/Startup.cs @@ -6,6 +6,7 @@ using Admin.Core.IService.ISys; using Admin.Core.Model; using Admin.Core.Repository; using Admin.Core.Service; +using Admin.Core.Socket; using Admin.Core.Tasks; using Aucma.Core.RunPlc; using Aucma.Core.Scanner; @@ -14,6 +15,7 @@ using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; +using System.Net.Sockets; using System.Text; namespace Aucma.Core.ProductOffLine @@ -65,8 +67,12 @@ namespace Aucma.Core.ProductOffLine //ɨ services.AddScannerSetup(); + //socketɨ + // services.AddTouchSocketSetup(); + + // - // services.AddJobSetup(); + // services.AddJobSetup(); //PLC services.AddPlcSetup(); @@ -91,19 +97,23 @@ namespace Aucma.Core.ProductOffLine /// /// /// - public void Configure(IApplicationBuilder app, IScannerService scannerService, IRunPlcService runPlcService)//, ISysTasksQzService tasksQzService, ISchedulerCenter schedulerCenter + public void Configure(IApplicationBuilder app, IScannerService scannerService, IRunPlcService runPlcService)//, ISysTasksQzService tasksQzService, ISchedulerCenter schedulerCenter,ITouchSocketService socket { // ʹþ̬ļ app.UseStaticFiles(); // ȻȨм //app.UseAuthorization(); - + // QuartzNetJobȷ - // app.UseQuartzJobMildd(tasksQzService, schedulerCenter); + // app.UseQuartzJobMildd(tasksQzService, schedulerCenter); //ɨ app.UseScannerMildd(scannerService); //PLC app.UsePlcMildd(runPlcService); + + // Socketɨ + // app.UseTouchSocketMildd(socket); + } #region ע diff --git a/Aucma.Core.ProductOffLine/Views/ChooseDirectionWindow.xaml b/Aucma.Core.ProductOffLine/Views/ChooseDirectionWindow.xaml index b6c554c0..a5dbd0ce 100644 --- a/Aucma.Core.ProductOffLine/Views/ChooseDirectionWindow.xaml +++ b/Aucma.Core.ProductOffLine/Views/ChooseDirectionWindow.xaml @@ -17,8 +17,8 @@