using Admin.Core.IService.ISys; using Admin.Core.IService; using System; using System.Threading.Tasks; using Admin.Core.IRepository; using Admin.Core.Model.Model_New; using System.Collections.Generic; using Aucma.Core.PLc; using System.Linq; using Admin.Core.Model; /// /// 钣金计划 /// namespace Aucma.Core.Tasks { public class Job_SheetMetalTask { #region 钣金任务 /// /// 实时任务信息-每日产量 /// public delegate Task SmEverDayDelegate(); public static event SmEverDayDelegate SmEverDayDelegateEvent; /// /// 实时任务信息-展示 /// public delegate Task SmShowDelegate(ExecutePlanInfo info); public static event SmShowDelegate SmShowDelegateEvent; #endregion private readonly ISmTaskExecutionServices _smTaskExecutionServices; private readonly IExecutePlanInfoServices _taskExecutionServices; public Job_SheetMetalTask(ISmTaskExecutionServices smTaskExecutionServices, IExecutePlanInfoServices taskExecutionServices) { _smTaskExecutionServices = smTaskExecutionServices; _taskExecutionServices = taskExecutionServices; } public async Task Execute() { await ShowRun(); await CompleteRun(); } #region 实施当日产量和型号统计 public Task Run() { SmEverDayDelegateEvent?.Invoke(); return Task.CompletedTask; } #endregion #region 实时计划显示 public async Task ShowRun() { var model = await _taskExecutionServices.FirstAsync(d => d.ExecuteStatus == 2); SmShowDelegateEvent?.Invoke(model); } #endregion #region 任务完成 public Task CompleteRun() { var obj = PlcHelper.melsecList.FirstOrDefault(d => d.EquipName.Equals("后板Plc")); var val = obj.plc.ReadInt32("M100");//任务结束信号存盘 if (val == 1) { //1、存储当日完成记录表、计算节拍信息 //2、更新界面计划执行、当日产量、型号统计、计划列表 //3、更新日志记录 //4、更新数据统计列表 } return Task.CompletedTask; } #endregion } }