using ProductionLineMonitor.Core.Models; using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace ProductionLineMonitor.Application.Services.OEEService.Dtos { public class MachineOEEInfo { public List OutPutPerHours { get; set; } = new List(); public DateTime StartTime { get; set; } public DateTime EndTime { get; set; } public string Date { get { return StartTime.ToString("MM/dd"); } } public string Shift { get { if (StartTime.Hour == 8) { return "白班"; } if (StartTime.Hour == 20) { return "夜班"; } return ""; } } public int Outputs { get; private set; } public int RunTime { get; private set; } public int IdelTime { get; private set; } public int DownTime { get; private set; } public int TotalTime { get; private set; } public int LoadMATTime { get; private set; } public double IdelTimeRate { get { if (TotalTime == 0) { return 0; } return Math.Round(IdelTime * 1.0 / TotalTime * 100, 2); } } public double RunTimeRate { get { if (TotalTime == 0) { return 0; } return Math.Round(RunTime * 1.0 / TotalTime * 100, 2); } } public double DownTimeRate { get { if (TotalTime == 0) { return 0; } return Math.Round(DownTime * 1.0 / TotalTime * 100, 2); } } public double LoadMATTimeRate { get { if (TotalTime == 0) { return 0; } return Math.Round(LoadMATTime * 1.0 / TotalTime * 100, 2); } } public void CalculateOEE() { Outputs = OutPutPerHours.Sum(s => s.OutPut.Value); RunTime = OutPutPerHours.Sum(s => s.AutoRunTime.Value); IdelTime = OutPutPerHours.Sum(s => s.IdleTime.Value); DownTime = OutPutPerHours.Sum(s => s.AlarmTime.Value); LoadMATTime = OutPutPerHours.Sum(s => s.LoadMATTime.Value); TotalTime = OutPutPerHours.Count() * 60 * 60; } } public class MachineOEE { public List Infos { get; set; } = new List(); } }