MachineFaultViewModel.cs 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. using ProductionLineMonitor.Application.Services.FaultService.Dtos;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.IO;
  5. using System.Linq;
  6. using System.Numerics;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. namespace ProductionLineMonitor.Web.Services.LineService
  10. {
  11. public class MachineFaultViewModel : MachineViewModel
  12. {
  13. public MachineFaultViewModel(string topic, string date)
  14. {
  15. Date = date;
  16. AnalysisTopic(topic);
  17. ProductionPlans = MesApiService.GetProductionPlansV1(Floor, Line, Date);
  18. if (ProductionPlans.Count == 0)
  19. return;
  20. if (ProductionPlans.Count == 1)
  21. if (ProductionPlans[0].ModuleType == "未指定")
  22. return;
  23. KeyInInfos = MesApiService.GetKeyInInfos(Floor, Line, Date);
  24. foreach (var key in KeyInInfos)
  25. {
  26. if (key.KeyInType == 2 || key.KeyInType == 3 || key.KeyInType == 4 ||
  27. key.KeyInType == 6 || key.KeyInType == 7 || key.KeyInType == 9)
  28. if (key.AffectTime >= 1440)
  29. return;
  30. }
  31. FaultRecords.AddRange(MesApiService.GetFaults(Topic, Date));
  32. FaultRecords.AddRange(MesApiService.GetKeyInFaults(Floor, Line, Date, Type));
  33. switch (Type)
  34. {
  35. case "AG":
  36. FaultRecords.AddRange(MesApiService.GetKeyInFaults(Floor, Line, Date, "TPA"));
  37. FaultRecords.AddRange(MesApiService.GetKeyInFaults(Floor, Line, Date, "FPL"));
  38. FaultRecords.AddRange(MesApiService.GetKeyInFaults(Floor, Line, Date, "FPL01"));
  39. FaultRecords.AddRange(MesApiService.GetKeyInFaults(Floor, Line, Date, "FPL02"));
  40. FaultRecords.AddRange(MesApiService.GetKeyInFaults(Floor, Line, Date, "FPL03"));
  41. FaultRecords.AddRange(MesApiService.GetKeyInFaults(Floor, Line, Date, "FPL04"));
  42. break;
  43. case "FPL":
  44. FaultRecords.AddRange(MesApiService.GetKeyInFaults(Floor, Line, Date, "FPL"));
  45. FaultRecords.AddRange(MesApiService.GetKeyInFaults(Floor, Line, Date, "FPL01"));
  46. FaultRecords.AddRange(MesApiService.GetKeyInFaults(Floor, Line, Date, "FPL02"));
  47. FaultRecords.AddRange(MesApiService.GetKeyInFaults(Floor, Line, Date, "FPL03"));
  48. FaultRecords.AddRange(MesApiService.GetKeyInFaults(Floor, Line, Date, "FPL04"));
  49. break;
  50. case "FOG":
  51. FaultRecords.AddRange(MesApiService.GetKeyInFaults(Floor, Line, Date, "COG"));
  52. break;
  53. default:
  54. break;
  55. }
  56. foreach (var key in KeyInInfos)
  57. {
  58. if (key.KeyInType == 2 || key.KeyInType == 3 || key.KeyInType == 4 ||
  59. key.KeyInType == 6 || key.KeyInType == 7 || key.KeyInType == 9)
  60. FaultRecords.RemoveAll(x => x.StartTime >= key.StartTime && x.StartTime <= key.EndTime);
  61. }
  62. //FaultRecords = FaultRecords.Where(x => x.Duration >= 3).OrderBy(o => o.StartTime).ToList();
  63. FaultRecords = FaultRecords.OrderBy(o => o.StartTime).ToList();
  64. }
  65. /// <summary>
  66. /// 故障
  67. /// </summary>
  68. public List<MachineFaultDto> FaultRecords
  69. = new List<MachineFaultDto>();
  70. }
  71. }