diff --git a/DOAN.Model/MES/SmartScreen/Quality/Dto/QualityScreenHeadDto.cs b/DOAN.Model/MES/SmartScreen/Quality/Dto/QualityScreenHeadDto.cs index 309b01f..f2e9f5e 100644 --- a/DOAN.Model/MES/SmartScreen/Quality/Dto/QualityScreenHeadDto.cs +++ b/DOAN.Model/MES/SmartScreen/Quality/Dto/QualityScreenHeadDto.cs @@ -11,5 +11,9 @@ namespace DOAN.Model.MES.SmartScreen.Quality.Dto public int? MonthFQC { get; set; } public int? WeekFQC { get; set; } + + public string MonthPassRate { get; set; } + public string WeekPassRate { get; set; } + } } diff --git a/DOAN.Service/MES/SmartScreen/Quality/QualitySmartService.cs b/DOAN.Service/MES/SmartScreen/Quality/QualitySmartService.cs index 77dcdd8..a15741a 100644 --- a/DOAN.Service/MES/SmartScreen/Quality/QualitySmartService.cs +++ b/DOAN.Service/MES/SmartScreen/Quality/QualitySmartService.cs @@ -41,9 +41,26 @@ namespace DOAN.Service.MES.SmartScreen.Quality .AddMinutes(59) .AddSeconds(59); var response = Queryable().ToList(); + List proWorkorders = Context.Queryable().ToList(); + List proWorkordersMonth = proWorkorders.Where(o=>o.WorkorderDate>= firstDayOfMonth&& o.WorkorderDate<= lastDayOfMonth).ToList(); + List proWorkordersWeek = proWorkorders.Where(o => o.WorkorderDate >= startOfWeek && o.WorkorderDate <= endOfWeek).ToList(); + qualityScreenHeadDto.MonthFQC = response.Where(o => o.CheckDatetime >= firstDayOfMonth && o.CheckDatetime <= lastDayOfMonth).Sum(o => o.Number); qualityScreenHeadDto.WeekFQC = response.Where(o => o.CheckDatetime >= startOfWeek && o.CheckDatetime <= endOfWeek).Sum(o => o.Number); + + double planSumMonth =Convert.ToDouble(proWorkordersMonth.Sum(o => o.PlanNum)); + double numeratorMonth = planSumMonth - (double)qualityScreenHeadDto.MonthFQC; + double ratioMonth = numeratorMonth / (double)planSumMonth; + string percentageMonth = ratioMonth.ToString("P2"); + qualityScreenHeadDto.MonthPassRate = percentageMonth; + + double planSumWeek = Convert.ToDouble(proWorkordersWeek.Sum(o => o.PlanNum)); + double numeratorWeek = planSumWeek - (double)qualityScreenHeadDto.WeekFQC; + double ratioWeek = numeratorWeek / (double)planSumWeek; + string percentageWeek = ratioWeek.ToString("P2"); + qualityScreenHeadDto.WeekPassRate= percentageWeek; + return qualityScreenHeadDto; }