QueryProductionReportDto.cs 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. using Castle.Components.DictionaryAdapter.Xml;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. namespace ShwasherSys.ProductionOrderInfo.Dto
  6. {
  7. public class EnterFailureRateDto
  8. {
  9. public EnterFailureRateDto()
  10. {
  11. // FailureRate = Math.Round((this.FailureQuantity * 100) / (this.ApplyTotalEnterQuantity * 100) / 100, 2);
  12. }
  13. public decimal ApplyTotalEnterQuantity { get; set; }
  14. public decimal FailureQuantity { get; set; }
  15. //public decimal FailureRate => Math.Round((this.FailureQuantity * 100) / (this.ApplyTotalEnterQuantity * 100) / 100, 2);
  16. public decimal FailureRate
  17. {
  18. get
  19. {
  20. try
  21. {
  22. return Math.Round((this.FailureQuantity * 100) / (this.ApplyTotalEnterQuantity * 100) / 100, 2);
  23. }
  24. catch (Exception err)
  25. {
  26. return 0;
  27. }
  28. }
  29. }
  30. }
  31. public class QueryProductionReportDto
  32. {
  33. public int Year { get; set; }
  34. public int? Month { get; set; }
  35. public int? EmployeeId { get; set; }
  36. }
  37. public class ProductionReportDto
  38. {
  39. public ProductionReportDto(string dayDate,List<ProductionReportItem> items,int? employeeId )
  40. {
  41. DayDate = dayDate;
  42. if (items != null && items.Any())
  43. {
  44. if (employeeId==null)
  45. {
  46. Items=new List<ProductionReportItem>();
  47. var temps = items.GroupBy(a =>a.EmployeeId).Select(a=>new ProductionReportItem
  48. {
  49. EmployeeId= a.Key,
  50. KgQuantity = a.Sum(s=>s.KgQuantity),
  51. PcsQuantity = a.Sum(s=>s.PcsQuantity)
  52. } );
  53. foreach (var item in temps)
  54. {
  55. var temp = items.FirstOrDefault(a => a.EmployeeId == item.EmployeeId);
  56. if (temp == null)
  57. {
  58. continue;
  59. }
  60. var newItem= new ProductionReportItem()
  61. {
  62. ProductDate = temp.ProductDate,
  63. EmployeeId = item.EmployeeId,
  64. EmployeeNo = temp.EmployeeNo,
  65. EmployeeName = temp.EmployeeName,
  66. KgQuantity = item.KgQuantity,
  67. PcsQuantity = item.PcsQuantity
  68. };
  69. Items.Add(newItem);
  70. }
  71. }
  72. else
  73. {
  74. var employee = items.FirstOrDefault();
  75. EmployeeNo = employee?.EmployeeNo;
  76. EmployeeName = employee?.EmployeeName;
  77. Items = items;
  78. }
  79. KgTotal = items.Sum(a => a.KgQuantity);
  80. PcsTotal = items.Sum(a => a.PcsQuantity);
  81. }
  82. else
  83. {
  84. KgTotal = 0;
  85. PcsTotal = 0;
  86. }
  87. }
  88. public int EmployeeId { get; set; }
  89. public string EmployeeNo { get; set; }
  90. public string EmployeeName { get; set; }
  91. public decimal KgTotal{ get; set; }
  92. public decimal PcsTotal{ get; set; }
  93. public string DayDate { get; set; }
  94. public List<ProductionReportItem> Items { get; set; }
  95. }
  96. public class ProductionReportItem
  97. {
  98. public DateTime? ProductDate { get; set; }
  99. public string ProductionOrderNo { get; set; }
  100. public string ProductNo { get; set; }
  101. public string ProductName { get; set; }
  102. public string CarNo { get; set; }
  103. public string PartNo { get; set; }
  104. public string Model { get; set; }
  105. public string Material { get; set; }
  106. public string SurfaceColor { get; set; }
  107. public string Rigidity { get; set; }
  108. public decimal KgQuantity{ get; set; }
  109. public decimal PcsQuantity{ get; set; }
  110. public decimal KgWeight { get; set; }
  111. public string EmployeeNo { get; set; }
  112. public string EmployeeName { get; set; }
  113. public int EmployeeId { get; set; }
  114. }
  115. }