using ProductionLineMonitor.Application.Services.FaultService.Dtos;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;
namespace ProductionLineMonitor.Web.Services.LineService
{
public class MachineFaultViewModel : MachineViewModel
{
public MachineFaultViewModel(string topic, string date)
{
Date = date;
AnalysisTopic(topic);
ProductionPlans = MesApiService.GetProductionPlansV1(Floor, Line, Date);
if (ProductionPlans.Count == 0)
return;
if (ProductionPlans.Count == 1)
if (ProductionPlans[0].ModuleType == "未指定")
return;
KeyInInfos = MesApiService.GetKeyInInfos(Floor, Line, Date);
foreach (var key in KeyInInfos)
{
if (key.KeyInType == 2 || key.KeyInType == 3 || key.KeyInType == 4 ||
key.KeyInType == 6 || key.KeyInType == 7 || key.KeyInType == 9)
if (key.AffectTime >= 1440)
return;
}
FaultRecords.AddRange(MesApiService.GetFaults(Topic, Date));
FaultRecords.AddRange(MesApiService.GetKeyInFaults(Floor, Line, Date, Type));
switch (Type)
{
case "AG":
FaultRecords.AddRange(MesApiService.GetKeyInFaults(Floor, Line, Date, "TPA"));
FaultRecords.AddRange(MesApiService.GetKeyInFaults(Floor, Line, Date, "FPL"));
FaultRecords.AddRange(MesApiService.GetKeyInFaults(Floor, Line, Date, "FPL01"));
FaultRecords.AddRange(MesApiService.GetKeyInFaults(Floor, Line, Date, "FPL02"));
FaultRecords.AddRange(MesApiService.GetKeyInFaults(Floor, Line, Date, "FPL03"));
FaultRecords.AddRange(MesApiService.GetKeyInFaults(Floor, Line, Date, "FPL04"));
break;
case "FPL":
FaultRecords.AddRange(MesApiService.GetKeyInFaults(Floor, Line, Date, "FPL"));
FaultRecords.AddRange(MesApiService.GetKeyInFaults(Floor, Line, Date, "FPL01"));
FaultRecords.AddRange(MesApiService.GetKeyInFaults(Floor, Line, Date, "FPL02"));
FaultRecords.AddRange(MesApiService.GetKeyInFaults(Floor, Line, Date, "FPL03"));
FaultRecords.AddRange(MesApiService.GetKeyInFaults(Floor, Line, Date, "FPL04"));
break;
case "FOG":
FaultRecords.AddRange(MesApiService.GetKeyInFaults(Floor, Line, Date, "COG"));
break;
default:
break;
}
foreach (var key in KeyInInfos)
{
if (key.KeyInType == 2 || key.KeyInType == 3 || key.KeyInType == 4 ||
key.KeyInType == 6 || key.KeyInType == 7 || key.KeyInType == 9)
FaultRecords.RemoveAll(x => x.StartTime >= key.StartTime && x.StartTime <= key.EndTime);
}
//FaultRecords = FaultRecords.Where(x => x.Duration >= 3).OrderBy(o => o.StartTime).ToList();
FaultRecords = FaultRecords.OrderBy(o => o.StartTime).ToList();
}
///
/// 故障
///
public List FaultRecords
= new List();
}
}