MachineOEEInfo.cs 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  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 int ReservedOne { get; private set; }
  43. public int ReservedThree { get; private set; }
  44. public double IdelTimeRate
  45. {
  46. get
  47. {
  48. if (TotalTime == 0)
  49. {
  50. return 0;
  51. }
  52. return Math.Round(IdelTime * 1.0 / TotalTime * 100, 2);
  53. }
  54. }
  55. public double RunTimeRate
  56. {
  57. get
  58. {
  59. if (TotalTime == 0)
  60. {
  61. return 0;
  62. }
  63. return Math.Round(RunTime * 1.0 / TotalTime * 100, 2);
  64. }
  65. }
  66. public double DownTimeRate
  67. {
  68. get
  69. {
  70. if (TotalTime == 0)
  71. {
  72. return 0;
  73. }
  74. return Math.Round(DownTime * 1.0 / TotalTime * 100, 2);
  75. }
  76. }
  77. public double LoadMATTimeRate
  78. {
  79. get
  80. {
  81. if (TotalTime == 0)
  82. {
  83. return 0;
  84. }
  85. return Math.Round(LoadMATTime * 1.0 / TotalTime * 100, 2);
  86. }
  87. }
  88. public double ReservedOneTimeRate
  89. {
  90. get
  91. {
  92. if (TotalTime == 0)
  93. {
  94. return 0;
  95. }
  96. return Math.Round(ReservedOne * 1.0 / TotalTime * 100, 2);
  97. }
  98. }
  99. public double ReservedThreeTimeRate
  100. {
  101. get
  102. {
  103. if (TotalTime == 0)
  104. {
  105. return 0;
  106. }
  107. return Math.Round(ReservedThree * 1.0 / TotalTime * 100, 2);
  108. }
  109. }
  110. public void CalculateOEE()
  111. {
  112. Outputs = OutPutPerHours.Sum(s => s.OutPut.Value);
  113. RunTime = OutPutPerHours.Sum(s => s.AutoRunTime.Value);
  114. IdelTime = OutPutPerHours.Sum(s => s.IdleTime.Value);
  115. DownTime = OutPutPerHours.Sum(s => s.AlarmTime.Value);
  116. LoadMATTime = OutPutPerHours.Sum(s => s.LoadMATTime.Value);
  117. ReservedOne = OutPutPerHours.Sum(s => s.ReservedOne == null ? 0 : s.ReservedOne.Value);
  118. ReservedThree = OutPutPerHours.Sum(s => s.ReservedThree == null ? 0 : s.ReservedThree.Value);
  119. TotalTime = OutPutPerHours.Count() * 60 * 60;
  120. }
  121. }
  122. public class MachineOEE
  123. {
  124. public List<MachineOEEInfo> Infos { get; set; }
  125. = new List<MachineOEEInfo>();
  126. }
  127. }