diff --git a/Admin.Core.Tasks/QuartzNet/Jobs/Job_SheetMetalTask_Quartz.cs b/Admin.Core.Tasks/QuartzNet/Jobs/Job_SheetMetalTask_Quartz.cs index 34e2791c..a574cb60 100644 --- a/Admin.Core.Tasks/QuartzNet/Jobs/Job_SheetMetalTask_Quartz.cs +++ b/Admin.Core.Tasks/QuartzNet/Jobs/Job_SheetMetalTask_Quartz.cs @@ -20,31 +20,29 @@ namespace Admin.Core.Tasks { #region 钣金任务 /// - /// 实时任务信息-每日产量 + /// 实时任务信息-每日产量、型号 /// public delegate Task SmEverDayDelegate(); public static event SmEverDayDelegate SmEverDayDelegateEvent; /// - /// 实时任务信息-展示 + /// 实时任务信息 /// - public delegate Task SmShowDelegate(ExecutePlanInfo info); - public static event SmShowDelegate SmShowDelegateEvent; + public delegate Task SmTaskDelegate(); + public static event SmTaskDelegate SmTaskDelegateEvent; #endregion - private readonly ISmTaskExecutionServices _smTaskExecutionServices; private readonly IExecutePlanInfoServices _taskExecutionServices; + public Job_SheetMetalTask_Quartz(ISysTasksQzService SysTasksQzService, ISysJobLogService sysJobLogService, - ISmTaskExecutionServices smTaskExecutionServices, IExecutePlanInfoServices taskExecutionServices) + IExecutePlanInfoServices taskExecutionServices) { _SysTasksQzService = SysTasksQzService; _sysJobLogService = sysJobLogService; - _smTaskExecutionServices = smTaskExecutionServices; _taskExecutionServices = taskExecutionServices; } public async Task Execute(IJobExecutionContext context) { - //await ExecuteJob(context, async () => await Run(context)); await ExecuteJob(context, async () => await ShowRun(context)); await ExecuteJob(context, async () => await CompleteRun(context)); } @@ -60,8 +58,7 @@ namespace Admin.Core.Tasks #region 实时计划显示 public async Task ShowRun(IJobExecutionContext context) { - var model = await _taskExecutionServices.FirstAsync(d => d.ExecuteStatus == 2); - SmShowDelegateEvent?.Invoke(model); + await SmTaskDelegateEvent?.Invoke(); } #endregion diff --git a/Aucma.Core.SheetMetal/ViewModels/IndexPageViewModel.cs b/Aucma.Core.SheetMetal/ViewModels/IndexPageViewModel.cs index 34c63793..378476f2 100644 --- a/Aucma.Core.SheetMetal/ViewModels/IndexPageViewModel.cs +++ b/Aucma.Core.SheetMetal/ViewModels/IndexPageViewModel.cs @@ -29,6 +29,7 @@ namespace Aucma.Core.SheetMetal.ViewModels public partial class IndexPageViewModel : ObservableObject { protected readonly IExecutePlanInfoServices? _taskExecutionPlanInfoServices; + private AppConfigHelper appConfig = new AppConfigHelper(); List list = new List() { new SelectModel() { @@ -48,7 +49,7 @@ namespace Aucma.Core.SheetMetal.ViewModels _taskExecutionPlanInfoServices = App.ServiceProvider.GetService(); StationName = Appsettings.app("StoreInfo", "StationName"); //Job_SheetMetalTask_Quartz.SmEverDayDelegateEvent += InitEveryDayMethod; - //Job_SheetMetalTask_Quartz.SmShowDelegateEvent += UpdatePlanSHow;//计划内容展示 + Job_SheetMetalTask_Quartz.SmTaskDelegateEvent += UpdatePlanSHow;//计划内容展示 WeakReferenceMessenger.Default.Register(this, Recive); Task.WaitAll(LoadData(), InitExecMethod()); @@ -66,7 +67,7 @@ namespace Aucma.Core.SheetMetal.ViewModels private async Task InitExecMethod() { - string station = "1001"; + string station = Appsettings.app("StoreInfo", "StationCode"); ExecutePlanInfo info = await _taskExecutionPlanInfoServices.FirstAsync(d => d.ProductLineCode.Equals(station) && d.ExecuteStatus == 2); if (info == null) return; @@ -224,7 +225,7 @@ namespace Aucma.Core.SheetMetal.ViewModels if (result) { PlanInfoDataGrid.Clear(); - LoadData(); + await LoadData(); } } #endregion @@ -572,9 +573,11 @@ namespace Aucma.Core.SheetMetal.ViewModels /// /// /// - public Task UpdatePlanSHow(ExecutePlanInfo info) + public async Task UpdatePlanSHow() { - if (info == null) return Task.CompletedTask; + string stationCode = Appsettings.app("StoreInfo", "StationCode"); + var info =await _taskExecutionPlanInfoServices.FirstAsync(d=>d.ExecuteStatus==3&& d.ProductLineCode == stationCode); + if (info == null) return; System.Windows.Application.Current.Dispatcher.Invoke((Action)(() => { @@ -584,7 +587,6 @@ namespace Aucma.Core.SheetMetal.ViewModels ProductModel = info.MaterialName; BeginTime = info.BeginTime.ToString(); })); - return Task.CompletedTask; } #endregion diff --git a/Aucma.Core.SheetMetal/ViewModels/QuantityIssuedViewModel.cs b/Aucma.Core.SheetMetal/ViewModels/QuantityIssuedViewModel.cs index abe811bf..6c09d18e 100644 --- a/Aucma.Core.SheetMetal/ViewModels/QuantityIssuedViewModel.cs +++ b/Aucma.Core.SheetMetal/ViewModels/QuantityIssuedViewModel.cs @@ -1,4 +1,5 @@ -using Admin.Core.IService; +using Admin.Core.Common; +using Admin.Core.IService; using Admin.Core.Model; using Admin.Core.Service; using Aucma.Core.SheetMetal.Models; @@ -62,7 +63,8 @@ namespace Aucma.Core.SheetMetal.ViewModels if (productPlanInfo != null) { //下传到PLC - var list = await _executePlanInfoServices.QueryAsync(d => d.ProductLineCode.Equals("1001")); + string stationCode = Appsettings.app("StoreInfo", "StationCode"); + var list = await _executePlanInfoServices.QueryAsync(d => d.ProductLineCode.Equals(stationCode)); ExecutePlanInfo task = new ExecutePlanInfo(); task.ExecutePlanCode = Guid.NewGuid().ToString(); task.ProductPlanCode = PlanInfo.PlanCode; @@ -80,6 +82,7 @@ namespace Aucma.Core.SheetMetal.ViewModels task.PlanAmount = PlanInfo.SpliteResidueAmount; task.CompleteAmount = PlanInfo.CompleteAmount; task.CreatedTime = DateTime.Now; + task.PlanType= productPlanInfo.PlanType; var result = await _executePlanInfoServices.AddAsync(task); if (result > 0) { diff --git a/Aucma.Core.Tasks/AucamTaskService.cs b/Aucma.Core.Tasks/AucamTaskService.cs index c81136f7..63082d42 100644 --- a/Aucma.Core.Tasks/AucamTaskService.cs +++ b/Aucma.Core.Tasks/AucamTaskService.cs @@ -6,7 +6,7 @@ using System.Timers; namespace Aucma.Core.Tasks { /// - /// 实时任务列表 + /// 钣金实时任务列表 /// public class AucamTaskService : IAucamTaskService { @@ -15,6 +15,8 @@ namespace Aucma.Core.Tasks System.Timers.Timer timer2 = new System.Timers.Timer(1000); System.Timers.Timer timer3 = new System.Timers.Timer(1000); + bool qFlay=true; + bool hFlay = true; public Task AucamTaskAsync() { timer1.Elapsed += new System.Timers.ElapsedEventHandler(Run1); //到达时间的时候执行事件; @@ -40,7 +42,17 @@ namespace Aucma.Core.Tasks /// private void Run1(object? sender, ElapsedEventArgs e) { - + if (qFlay) + { + //执行存盘操作 + //计划编号 + //物料编号 + //计划完成数 + //计划下线数 + //设备状态 + //生产节拍 + qFlay = true; + } Console.WriteLine("前板"); } /// @@ -50,15 +62,27 @@ namespace Aucma.Core.Tasks /// private void Run2(object? sender, ElapsedEventArgs e) { + if (hFlay) + { + //执行存盘操作 + //计划编号 + //物料编号 + //计划完成数 + //计划下线数 + //设备状态 + //生产节拍 + hFlay = true; + } Console.WriteLine("后板"); } /// - /// 钣金——实时任务列表 + /// 钣金—实时任务列表 /// /// /// private void Run3(object? sender, ElapsedEventArgs e) { + Console.WriteLine("实时任务列表"); }