diff --git a/DOAN.Model/MES/SmartScreen/Quality/Dto/QualityScreenHeadDto.cs b/DOAN.Model/MES/SmartScreen/Quality/Dto/QualityScreenHeadDto.cs index f2e9f5e..6ee5388 100644 --- a/DOAN.Model/MES/SmartScreen/Quality/Dto/QualityScreenHeadDto.cs +++ b/DOAN.Model/MES/SmartScreen/Quality/Dto/QualityScreenHeadDto.cs @@ -15,5 +15,9 @@ namespace DOAN.Model.MES.SmartScreen.Quality.Dto public string MonthPassRate { get; set; } public string WeekPassRate { get; set; } + + public string OnYearMonthPassRate { get; set; } + public string OnYearWeekPassRate { get; set; } + } } diff --git a/DOAN.Service/MES/SmartScreen/Quality/QualitySmartService.cs b/DOAN.Service/MES/SmartScreen/Quality/QualitySmartService.cs index ffbaf27..523e9fa 100644 --- a/DOAN.Service/MES/SmartScreen/Quality/QualitySmartService.cs +++ b/DOAN.Service/MES/SmartScreen/Quality/QualitySmartService.cs @@ -40,15 +40,25 @@ namespace DOAN.Service.MES.SmartScreen.Quality .AddHours(23) .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(); + + List proWorkordersUpperMonth = proWorkorders.Where(o => o.WorkorderDate >= firstDayOfMonth.AddMonths(-1) && o.WorkorderDate <= lastDayOfMonth.AddMonths(-1)).ToList(); + List proWorkordersUpperWeek = proWorkorders.Where(o => o.WorkorderDate >= startOfWeek.AddDays(-7) && o.WorkorderDate <= endOfWeek.AddDays(-7)).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); + int? UpperMonthFQC = response.Where(o => o.CheckDatetime >= firstDayOfMonth.AddMonths(-1) && o.CheckDatetime <= lastDayOfMonth.AddMonths(-1)).Sum(o => o.Number); + int? UpperWeekFQC = response.Where(o => o.CheckDatetime >= startOfWeek.AddDays(-7) && o.CheckDatetime <= endOfWeek.AddDays(-7)).Sum(o => o.Number); + double planSumMonth =Convert.ToDouble(proWorkordersMonth.Sum(o => o.PlanNum)); double numeratorMonth = planSumMonth - (double)qualityScreenHeadDto.MonthFQC; double ratioMonth = numeratorMonth / (double)planSumMonth; @@ -61,6 +71,20 @@ namespace DOAN.Service.MES.SmartScreen.Quality string percentageWeek = ratioWeek.ToString("P2"); qualityScreenHeadDto.WeekPassRate= percentageWeek; + double planSumUpperMonth = Convert.ToDouble(proWorkordersUpperMonth.Sum(o => o.PlanNum)); + double numeratorUpperMonth = planSumUpperMonth - (double)qualityScreenHeadDto.MonthFQC; + double ratioUpperMonth = numeratorUpperMonth / (double)planSumUpperMonth; + //string percentageUpperMonth = ratioUpperMonth.ToString("P2"); + //qualityScreenHeadDto.MonthPassRate = percentageMonth; + + double planSumUpperWeek = Convert.ToDouble(proWorkordersUpperWeek.Sum(o => o.PlanNum)); + double numeratorUpperWeek = planSumUpperWeek - (double)qualityScreenHeadDto.WeekFQC; + double ratioUpperWeek = numeratorUpperWeek / (double)planSumUpperWeek; + //string percentageWeek = ratioWeek.ToString("P2"); + //qualityScreenHeadDto.WeekPassRate = percentageWeek; + + qualityScreenHeadDto.OnYearMonthPassRate = (ratioMonth - ratioUpperMonth).ToString("P2"); + qualityScreenHeadDto.OnYearWeekPassRate = (ratioWeek - ratioUpperWeek).ToString("P2"); return qualityScreenHeadDto; } @@ -243,7 +267,15 @@ namespace DOAN.Service.MES.SmartScreen.Quality decimal passnum = plannum - nopassnum; EchartsSeriesData echartsSeriesData = new EchartsSeriesData(); echartsSeriesData.Name = dateitem.ToString("MM-dd"); - echartsSeriesData.Value = passnum/ plannum; + if (plannum==0) + { + echartsSeriesData.Value =0; + } + else + { + echartsSeriesData.Value = passnum / plannum; + } + echartsSeriesDatas.Add(echartsSeriesData); }