1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 |
- 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();
- }
- /// <summary>
- /// 故障
- /// </summary>
- public List<MachineFaultDto> FaultRecords
- = new List<MachineFaultDto>();
- }
- }
|