ProductionPlanDto.cs 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Diagnostics.CodeAnalysis;
  4. using System.Linq;
  5. using System.Text;
  6. namespace ProductionLineMonitor.Application.Services.LineService.Dtos
  7. {
  8. public class ProductionPlanDto
  9. {
  10. /// <summary>
  11. /// 机种
  12. /// </summary>
  13. public string ModuleType { get; set; } = string.Empty;
  14. /// <summary>
  15. /// 计划产能
  16. /// </summary>
  17. public int PlanCapacity { get; set; }
  18. /// <summary>
  19. /// 理论产能
  20. /// </summary>
  21. public int Capa { get; set; }
  22. /// <summary>
  23. /// 理论TT
  24. /// </summary>
  25. public double TT { get; set; }
  26. }
  27. public class ProductionPlanDtoV1 : ProductionPlanDto
  28. {
  29. public string Shift { get; set; } = string.Empty;
  30. }
  31. public class OverProductionPlanDto
  32. {
  33. public OverProductionPlanDto(int floor, int line, IList<ProductionPlanDtoV1> lst, string lineId, string topic, string lineName)
  34. {
  35. LineId = lineId;
  36. Floor = floor;
  37. Line = line;
  38. LineName = lineName;
  39. HourDataTopic = topic;
  40. IList<string> ModuleTypes = lst
  41. .Where(x => x.ModuleType != "")
  42. .Select(x => x.ModuleType)
  43. .Distinct().ToList();
  44. int[] capas = new int[ModuleTypes.Count()];
  45. for (int i = 0; i < ModuleTypes.Count(); i++)
  46. {
  47. var l = lst.FirstOrDefault(x => x.ModuleType == ModuleTypes[i]);
  48. if (l != null)
  49. {
  50. capas[i] = l.Capa;
  51. }
  52. }
  53. Capa = string.Join (" / ", capas);
  54. //for (int i = 0; i < ModuleTypes.Count(); i++)
  55. //{
  56. // if (ModuleTypes[i].Length > 10)
  57. // {
  58. // ModuleTypes[i] = ModuleTypes[i][..10];
  59. // }
  60. //}
  61. ModuleType = string.Join(" / ", ModuleTypes);
  62. var ms = lst.Where(x => x.Shift == "1");
  63. if (ms != null && ms.Count() > 0)
  64. {
  65. PlanMorningShiftCapacity = ms.Select(x => x.PlanCapacity).Sum();
  66. }
  67. var ns = lst.Where(x => x.Shift == "2");
  68. if (ns != null && ns.Count() > 0)
  69. {
  70. PlanNightShiftCapacity = ns.Select(x => x.PlanCapacity).Sum();
  71. }
  72. }
  73. public void SetModuleType(string moduleType)
  74. {
  75. // 11 12 不截取
  76. if ((Line == 11 || Line == 12) && Floor == 2)
  77. {
  78. ModuleType = moduleType;
  79. return;
  80. }
  81. if (moduleType.Length > 10)
  82. {
  83. moduleType = moduleType[..10];
  84. }
  85. ModuleType = moduleType;
  86. }
  87. public string LineId { get; private set; }
  88. public void SetCapacity(int capacity)
  89. {
  90. Capacity = capacity;
  91. }
  92. public int Floor { get; set; }
  93. public int Line { get; set; }
  94. public string HourDataTopic { get; set; }
  95. public string ModuleType { get; private set; } = string.Empty;
  96. public string Capa { get; set; } = string.Empty;
  97. public string LineName { get; set; } = string.Empty;
  98. public bool MorningShiftState
  99. {
  100. get
  101. {
  102. return PlanMorningShiftCapacity != 0;
  103. }
  104. }
  105. public int PlanMorningShiftCapacity { get; set; } = 0;
  106. public bool NightShiftState
  107. {
  108. get
  109. {
  110. return PlanNightShiftCapacity != 0;
  111. }
  112. }
  113. public int PlanNightShiftCapacity { get; set; } = 0;
  114. /// <summary>
  115. /// 实时产能
  116. /// </summary>
  117. public int Capacity { get; private set; } = 0;
  118. /// <summary>
  119. /// 达成率
  120. /// </summary>
  121. //public string AchievementRate
  122. //{
  123. // get
  124. // {
  125. // int p = PlanMorningShiftCapacity + PlanNightShiftCapacity;
  126. // if (p == 0)
  127. // {
  128. // return "-";
  129. // }
  130. // return Math.Round((float)Capacity / p * 100, 2).ToString() + " %";
  131. // }
  132. //}
  133. public double AchievementRate
  134. {
  135. get
  136. {
  137. int p = PlanMorningShiftCapacity + PlanNightShiftCapacity;
  138. if (p == 0)
  139. {
  140. return 0;
  141. }
  142. return Math.Round((float)Capacity / p * 100, 2);
  143. }
  144. }
  145. }
  146. }