From bd8a8f3ca7e5bc7cb51a4f8a6bb304aebf2e7746 Mon Sep 17 00:00:00 2001 From: liuwf Date: Tue, 12 Dec 2023 11:39:23 +0800 Subject: [PATCH] =?UTF-8?q?change=20-=20=E5=AE=9A=E6=97=B6=E5=99=A8?= =?UTF-8?q?=E6=94=B9=E5=AE=9A=E6=97=B6=E4=BB=BB=E5=8A=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../QuartzNet/Jobs/Job_AllState_Quartz.cs | 11 ++-- .../ViewModels/MainWindowViewModel.cs | 4 +- Aucma.Core.CodeBinding/appsettings.json | 2 +- Aucma.Core.ProductOffLine/Startup.cs | 6 +-- .../ViewModels/DirectionEditViewModel.cs | 24 +++++---- .../ViewModels/MainWindowViewModel.cs | 52 +++++++------------ .../ViewModels/SelectQualityViewModel.cs | 14 +++-- Aucma.Core.ProductOffLine/appsettings.json | 8 +-- 8 files changed, 58 insertions(+), 63 deletions(-) diff --git a/Admin.Core.Tasks/QuartzNet/Jobs/Job_AllState_Quartz.cs b/Admin.Core.Tasks/QuartzNet/Jobs/Job_AllState_Quartz.cs index 2e128a96..0efcd9cd 100644 --- a/Admin.Core.Tasks/QuartzNet/Jobs/Job_AllState_Quartz.cs +++ b/Admin.Core.Tasks/QuartzNet/Jobs/Job_AllState_Quartz.cs @@ -20,8 +20,8 @@ namespace Admin.Core.Tasks { public class Job_AllState_Quartz : JobBase, IJob { - public delegate Task RefreshCodeBindingState(bool mesState, bool plcState, bool scanner1, bool scanner2); - public static event RefreshCodeBindingState RefreshCodeBindingStateEvent; + public delegate Task RefreshState(bool mesState, bool plcState, bool scanner1, bool scanner2); + public static event RefreshState RefreshStateEvent; private readonly IBaseServices baseServices; public Job_AllState_Quartz(ISysTasksQzService SysTasksQzService, ISysJobLogService sysJobLogService,IBaseBomInfoServices baseBomInfoServices) @@ -45,7 +45,8 @@ namespace Admin.Core.Tasks bool scanner1; bool scanner2; mesState = baseServices.GetConnectionState(); - var obj = PlcHelper.melsecList.FirstOrDefault(d => d.EquipName.Equals("条码绑定Plc")); + // var obj = PlcHelper.melsecList.FirstOrDefault(d => d.EquipName.Equals("条码绑定Plc")); + var obj = PlcHelper.melsecList.FirstOrDefault(d => d.EquipName.Equals("成品下线Plc")); if (obj != null && obj.plc.IsConnected) { plcState = true; @@ -58,8 +59,8 @@ namespace Admin.Core.Tasks string ip2 = Appsettings.app("Middleware", "Scanner2", "Ip"); scanner1 = MvCodeHelper.ConnectionStatus(ip1); scanner2 = MvCodeHelper.ConnectionStatus(ip2); - //条码绑定上位机状态刷新 - RefreshCodeBindingStateEvent(mesState,plcState,scanner1,scanner2); + //状态刷新 + RefreshStateEvent(mesState,plcState,scanner1,scanner2); return Task.FromResult(0); #endregion } diff --git a/Aucma.Core.CodeBinding/ViewModels/MainWindowViewModel.cs b/Aucma.Core.CodeBinding/ViewModels/MainWindowViewModel.cs index 59cc27cc..396078ac 100644 --- a/Aucma.Core.CodeBinding/ViewModels/MainWindowViewModel.cs +++ b/Aucma.Core.CodeBinding/ViewModels/MainWindowViewModel.cs @@ -40,7 +40,7 @@ namespace Aucma.Core.CodeBinding.ViewModels { UserContent = firstPage; - Job_AllState_Quartz.RefreshCodeBindingStateEvent += RefreshStatus; + Job_AllState_Quartz.RefreshStateEvent += RefreshStatus; } @@ -49,8 +49,6 @@ namespace Aucma.Core.CodeBinding.ViewModels /// /// 设备状态刷新 /// - /// - /// public Task RefreshStatus(bool mesState,bool plcState,bool scanner1,bool scanner2) { MesDbState(mesState); diff --git a/Aucma.Core.CodeBinding/appsettings.json b/Aucma.Core.CodeBinding/appsettings.json index d495c94e..10dee713 100644 --- a/Aucma.Core.CodeBinding/appsettings.json +++ b/Aucma.Core.CodeBinding/appsettings.json @@ -105,7 +105,7 @@ "Remark": "执行任务调度系统", "RunTimes": 3881, "BeginTime": "2023-04-23 11:08:50.000", - "EndTime": "2080-12-01 16:45:30.000", + "EndTime": "2180-12-01 16:45:30.000", "TriggerType": 1, "IntervalSecond": 5, "CycleRunTimes": 1, diff --git a/Aucma.Core.ProductOffLine/Startup.cs b/Aucma.Core.ProductOffLine/Startup.cs index 19d29bf5..fc64ab2b 100644 --- a/Aucma.Core.ProductOffLine/Startup.cs +++ b/Aucma.Core.ProductOffLine/Startup.cs @@ -66,7 +66,7 @@ namespace Aucma.Core.ProductOffLine services.AddScannerSetup(); // - // services.AddJobSetup(); + services.AddJobSetup(); //PLC services.AddPlcSetup(); @@ -91,7 +91,7 @@ namespace Aucma.Core.ProductOffLine /// /// /// - public void Configure(IApplicationBuilder app, IScannerService scannerService, IRunPlcService runPlcService) + public void Configure(IApplicationBuilder app, IScannerService scannerService, IRunPlcService runPlcService, ISysTasksQzService tasksQzService, ISchedulerCenter schedulerCenter) { // ʹþ̬ļ app.UseStaticFiles(); @@ -99,7 +99,7 @@ namespace Aucma.Core.ProductOffLine //app.UseAuthorization(); // QuartzNetJobȷ - // app.UseQuartzJobMildd(tasksQzService, schedulerCenter); + app.UseQuartzJobMildd(tasksQzService, schedulerCenter); //ɨ app.UseScannerMildd(scannerService); //PLC diff --git a/Aucma.Core.ProductOffLine/ViewModels/DirectionEditViewModel.cs b/Aucma.Core.ProductOffLine/ViewModels/DirectionEditViewModel.cs index a1797754..93d7af96 100644 --- a/Aucma.Core.ProductOffLine/ViewModels/DirectionEditViewModel.cs +++ b/Aucma.Core.ProductOffLine/ViewModels/DirectionEditViewModel.cs @@ -43,17 +43,23 @@ namespace Aucma.Core.ProductOffLine.ViewModels private async void ExecuteQuery() { - MaterialDataGrid.Clear(); - // 处理查询按钮点击事件 - List materialInfoList = await _baseMaterialInfoServices.queryAsyncLike(Search); - int count = 0; - Application.Current.Dispatcher.Invoke(() => + try + { + MaterialDataGrid.Clear(); + // 处理查询按钮点击事件 + List materialInfoList = await _baseMaterialInfoServices.queryAsyncLike(Search); + int count = 0; + Application.Current.Dispatcher.Invoke(() => + { + foreach (BaseMaterialInfo materialInfo in materialInfoList) + { + MaterialDataGrid.Add(new DirectionEditModel() { No = ++count, ObjId = materialInfo.ObjId, MaterialCode = materialInfo.MaterialCode, MaterialName = materialInfo.MaterialName, SpaceCode = materialInfo.InboundDirection }); + } + }); + } + catch (Exception ex) { - foreach (BaseMaterialInfo materialInfo in materialInfoList) - { - MaterialDataGrid.Add(new DirectionEditModel() { No = ++count, ObjId = materialInfo.ObjId, MaterialCode = materialInfo.MaterialCode, MaterialName = materialInfo.MaterialName, SpaceCode = materialInfo.InboundDirection }); } - }); } public void MouseClick(object obj) { diff --git a/Aucma.Core.ProductOffLine/ViewModels/MainWindowViewModel.cs b/Aucma.Core.ProductOffLine/ViewModels/MainWindowViewModel.cs index 2c232ca4..2ab0e351 100644 --- a/Aucma.Core.ProductOffLine/ViewModels/MainWindowViewModel.cs +++ b/Aucma.Core.ProductOffLine/ViewModels/MainWindowViewModel.cs @@ -13,14 +13,13 @@ using System.Threading.Tasks; using System.Windows.Threading; using Admin.Core.Common; using Aucma.Core.Scanner; +using Admin.Core.Tasks; namespace Aucma.Core.ProductOffLine.ViewModels { public partial class MainWindowViewModel : ObservableObject { - #region plc状态刷新 - #endregion private static readonly log4net.ILog log = LogManager.GetLogger(typeof(MainWindowViewModel)); private IndexPageView firstPage = new IndexPageView();//首页 private StatisticsPageView recordPage = new StatisticsPageView(); // 统计页面 @@ -29,22 +28,7 @@ namespace Aucma.Core.ProductOffLine.ViewModels public MainWindowViewModel() { UserContent = firstPage; - - MesDbState(true); - PlcState(true); - Scanner1State(true); - Scanner2State(true); - init(); - - } - public void init() - { - // 设备状态刷新定时器 - System.Timers.Timer timer = new System.Timers.Timer(1000 * 5); - timer.Elapsed += new System.Timers.ElapsedEventHandler(RefreshStatus); - timer.AutoReset = true; - timer.Enabled = true; - timer.Start(); + Job_AllState_Quartz.RefreshStateEvent += RefreshStatus; } @@ -52,15 +36,15 @@ namespace Aucma.Core.ProductOffLine.ViewModels /// /// 设备状态刷新 /// - /// - /// - public void RefreshStatus(object sender, System.Timers.ElapsedEventArgs e) + public Task RefreshStatus(bool mesState, bool plcState, bool scanner1, bool scanner2) { - RefreshMesDb(); - RefreshPlc(); - RefreshScanner(); - + MesDbState(mesState); + PlcState(plcState); + Scanner1State(scanner1); + Scanner2State(scanner2); + return Task.CompletedTask; } + /// /// 数据库状态刷新 /// @@ -257,14 +241,14 @@ namespace Aucma.Core.ProductOffLine.ViewModels Application.Current.Dispatcher.Invoke(() => { if (type) - { - MesDbUIStatusWb = "MES数据库连接成功"; + { + MesDbUIStatusWb = "MES数据库"; MesDbUIColor = "Green"; MesUIIcon = "Assets/Images/Green.png"; } else { - MesDbUIStatusWb = "MES数据库异常"; + MesDbUIStatusWb = "MES数据库"; MesDbUIColor = "Red"; MesUIIcon = "Assets/Images/Red.png"; } @@ -311,13 +295,13 @@ namespace Aucma.Core.ProductOffLine.ViewModels { if (type) { - PlcUIStatusWb = "PLC连接成功"; + PlcUIStatusWb = "PLC状态"; PlcUIColor = "Green"; PlcUIIcon = "Assets/Images/Green.png"; } else { - PlcUIStatusWb = "PLC状态异常"; + PlcUIStatusWb = "PLC状态"; PlcUIColor = "Red"; PlcUIIcon = "Assets/Images/Red.png"; } @@ -370,13 +354,13 @@ namespace Aucma.Core.ProductOffLine.ViewModels { if (type) { - Scanner1UIStatusWb = "扫码器1连接成功"; + Scanner1UIStatusWb = "扫码器1状态"; Scanner1UIColor = "Green"; Scanner1UIIcon = "Assets/Images/Green.png"; } else { - Scanner1UIStatusWb = "扫码器1状态异常"; + Scanner1UIStatusWb = "扫码器1状态"; Scanner1UIColor = "Red"; Scanner1UIIcon = "Assets/Images/Red.png"; } @@ -429,13 +413,13 @@ namespace Aucma.Core.ProductOffLine.ViewModels { if (type) { - Scanner2UIStatusWb = "扫码器2连接成功"; + Scanner2UIStatusWb = "扫码器2状态"; Scanner2UIColor = "Green"; Scanner2UIIcon = "Assets/Images/Green.png"; } else { - Scanner2UIStatusWb = "扫码器2状态异常"; + Scanner2UIStatusWb = "扫码器2状态"; Scanner2UIColor = "Red"; Scanner2UIIcon = "Assets/Images/Red.png"; } diff --git a/Aucma.Core.ProductOffLine/ViewModels/SelectQualityViewModel.cs b/Aucma.Core.ProductOffLine/ViewModels/SelectQualityViewModel.cs index 2be25b35..cd533e07 100644 --- a/Aucma.Core.ProductOffLine/ViewModels/SelectQualityViewModel.cs +++ b/Aucma.Core.ProductOffLine/ViewModels/SelectQualityViewModel.cs @@ -53,11 +53,17 @@ namespace Aucma.Core.ProductOffLine.ViewModels private async void ExecuteQuery() { - List list = await _baseQualityInspectionItemInfoServices.query(); - qualityItemGrid.Clear(); - for (int i = 0; i < list.Count; i++) + try + { + List list = await _baseQualityInspectionItemInfoServices.query(); + qualityItemGrid.Clear(); + for (int i = 0; i < list.Count; i++) + { + qualityItemGrid.Add(new QualityInspectionModel() { No = i + 1, ObjId = list[i].ObjId, QualityDefectCode = list[i].QualityDefectCode, QualityDefectName = list[i].QualityDefectName, IsInSpection = list[i].IsInSpection == "0" ? "否" : "是" }); + } + } + catch (Exception) { - qualityItemGrid.Add(new QualityInspectionModel() { No = i + 1, ObjId = list[i].ObjId, QualityDefectCode = list[i].QualityDefectCode, QualityDefectName = list[i].QualityDefectName, IsInSpection = list[i].IsInSpection == "0" ? "否" : "是" }); } } diff --git a/Aucma.Core.ProductOffLine/appsettings.json b/Aucma.Core.ProductOffLine/appsettings.json index 337a1d6a..f8b57572 100644 --- a/Aucma.Core.ProductOffLine/appsettings.json +++ b/Aucma.Core.ProductOffLine/appsettings.json @@ -110,13 +110,13 @@ "JobGroup": "DEFAULT", "Cron": "*/1 * * * * ?", "AssemblyName": "Admin.Core.Tasks", - "ClassName": "Job_Admin_Quartz", + "ClassName": "Job_AllState_Quartz", "Remark": "执行任务调度系统", "RunTimes": 3881, "BeginTime": "2023-04-23 11:08:50.000", - "EndTime": "2324-08-06 16:45:30.000", + "EndTime": "2180-12-01 16:45:30.000", "TriggerType": 1, - "IntervalSecond": 1, + "IntervalSecond": 5, "CycleRunTimes": 1, "IsStart": true, "JobParams": null, @@ -136,7 +136,7 @@ "Remark": "执行任务调度系统", "RunTimes": 3881, "BeginTime": "2023-04-23 11:08:50.000", - "EndTime": "2324-08-06 16:45:30.000", + "EndTime": "2022-08-06 16:45:30.000", "TriggerType": 1, "IntervalSecond": 1, "CycleRunTimes": 1,