MachineOEEInfoByPeriod.cs 4.3 KB

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