From 6ef5a5f1898189e2450b50aad96c413f6a45b928 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8D=A2=E6=B1=9F=E6=B5=B7?= <18360817963@163.com> Date: Thu, 27 Mar 2025 20:31:00 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B4=A8=E9=87=8F=E5=A4=A7=E5=B1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Quality/Dto/QualityScreenHeadDto.cs | 4 +++ .../Quality/QualitySmartService.cs | 34 ++++++++++++++++++- 2 files changed, 37 insertions(+), 1 deletion(-) 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); }