MachineOEEInfo.cs 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. using ProductionLineMonitor.Core.Models;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Text;
  6. namespace ProductionLineMonitor.Application.Services.OEEService.Dtos
  7. {
  8. public class MachineOEEInfo
  9. {
  10. public List<MachineOutPutPerHour> OutPutPerHours { get; set; }
  11. = new List<MachineOutPutPerHour>();
  12. public DateTime StartTime { get; set; }
  13. public DateTime EndTime { get; set; }
  14. public string Date
  15. {
  16. get
  17. {
  18. return StartTime.ToString("MM/dd");
  19. }
  20. }
  21. public string Shift
  22. {
  23. get
  24. {
  25. if (StartTime.Hour == 8)
  26. {
  27. return "白班";
  28. }
  29. if (StartTime.Hour == 20)
  30. {
  31. return "夜班";
  32. }
  33. return "";
  34. }
  35. }
  36. public int Outputs { get; private set; }
  37. public int RunTime { get; private set; }
  38. public int IdelTime { get; private set; }
  39. public int DownTime { get; private set; }
  40. public int TotalTime { get; private set; }
  41. public int LoadMATTime { get; private set; }
  42. public double IdelTimeRate
  43. {
  44. get
  45. {
  46. if (TotalTime == 0)
  47. {
  48. return 0;
  49. }
  50. return Math.Round(IdelTime * 1.0 / TotalTime * 100, 2);
  51. }
  52. }
  53. public double RunTimeRate
  54. {
  55. get
  56. {
  57. if (TotalTime == 0)
  58. {
  59. return 0;
  60. }
  61. return Math.Round(RunTime * 1.0 / TotalTime * 100, 2);
  62. }
  63. }
  64. public double DownTimeRate
  65. {
  66. get
  67. {
  68. if (TotalTime == 0)
  69. {
  70. return 0;
  71. }
  72. return Math.Round(DownTime * 1.0 / TotalTime * 100, 2);
  73. }
  74. }
  75. public double LoadMATTimeRate
  76. {
  77. get
  78. {
  79. if (TotalTime == 0)
  80. {
  81. return 0;
  82. }
  83. return Math.Round(LoadMATTime * 1.0 / TotalTime * 100, 2);
  84. }
  85. }
  86. public void CalculateOEE()
  87. {
  88. Outputs = OutPutPerHours.Sum(s => s.OutPut.Value);
  89. RunTime = OutPutPerHours.Sum(s => s.AutoRunTime.Value);
  90. IdelTime = OutPutPerHours.Sum(s => s.IdleTime.Value);
  91. DownTime = OutPutPerHours.Sum(s => s.AlarmTime.Value);
  92. LoadMATTime = OutPutPerHours.Sum(s => s.LoadMATTime.Value);
  93. TotalTime = OutPutPerHours.Count() * 60 * 60;
  94. }
  95. }
  96. public class MachineOEE
  97. {
  98. public List<MachineOEEInfo> Infos { get; set; }
  99. = new List<MachineOEEInfo>();
  100. }
  101. }