From ca741525e9d7f5d9b28ce5ebb8b77a853525eb2d Mon Sep 17 00:00:00 2001 From: chenlin Date: Mon, 26 Jan 2026 18:41:05 +0800 Subject: [PATCH] =?UTF-8?q?=E7=94=9F=E4=BA=A7=E5=A4=A7=E5=B1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../MES/product/ProWorkorderController.cs | 2 +- .../MES/report/ReportController.cs | 12 ++++- DOAN.Model/MES/report/MonthProuctModel.cs | 13 +++++ .../MES/report/IService/IReportService.cs | 1 + DOAN.Service/MES/report/ReportService.cs | 50 +++++++++++++++++++ 5 files changed, 76 insertions(+), 2 deletions(-) diff --git a/DOAN.Admin.WebApi/Controllers/MES/product/ProWorkorderController.cs b/DOAN.Admin.WebApi/Controllers/MES/product/ProWorkorderController.cs index ac66e36..047100b 100644 --- a/DOAN.Admin.WebApi/Controllers/MES/product/ProWorkorderController.cs +++ b/DOAN.Admin.WebApi/Controllers/MES/product/ProWorkorderController.cs @@ -200,7 +200,7 @@ namespace DOAN.Admin.WebApi.Controllers /// [HttpPost("setWorkorderStatus")] [Log(Title = "设置工单状态", BusinessType = BusinessType.UPDATE)] - public IActionResult SetWorkorderStatus(ProWorkorderStatusDto param) + public IActionResult SetWorkorderStatus([FromBody] ProWorkorderStatusDto param) { if (string.IsNullOrEmpty(param.Id)) { diff --git a/DOAN.Admin.WebApi/Controllers/MES/report/ReportController.cs b/DOAN.Admin.WebApi/Controllers/MES/report/ReportController.cs index 19ad876..a2cf42e 100644 --- a/DOAN.Admin.WebApi/Controllers/MES/report/ReportController.cs +++ b/DOAN.Admin.WebApi/Controllers/MES/report/ReportController.cs @@ -97,7 +97,6 @@ namespace DOAN.WebApi.Controllers } - /// /// 生产大屏报表 /// @@ -108,5 +107,16 @@ namespace DOAN.WebApi.Controllers var response = _ReportService.ProductionReport(DateTime.Now); return SUCCESS(response); } + + /// + /// 生产大屏达成率 + /// + /// + [HttpGet("productionReportRate")] + public IActionResult ProductionReportRate() + { + var response = _ReportService.ProductionReportRate(DateTime.Now); + return SUCCESS(response); + } } } diff --git a/DOAN.Model/MES/report/MonthProuctModel.cs b/DOAN.Model/MES/report/MonthProuctModel.cs index 6767ff4..8e77756 100644 --- a/DOAN.Model/MES/report/MonthProuctModel.cs +++ b/DOAN.Model/MES/report/MonthProuctModel.cs @@ -135,4 +135,17 @@ namespace DOAN.Model.MES.report public string StatusName { get; set; } public int? Status { get; set; } } + + public class ProductionReportRate + { + public string WorkTimePeriod { get; set; } + public double Rate { get; set; } + } + public class ProductionReportRateModel + { + public List CompletionRateList { get; set; }=new List(); + public List QualifiedRateList { get; set; }= new List(); + public List UnqualifiedRateList { get; set; } = new List(); + } + } diff --git a/DOAN.Service/MES/report/IService/IReportService.cs b/DOAN.Service/MES/report/IService/IReportService.cs index 18cef3f..a940d2d 100644 --- a/DOAN.Service/MES/report/IService/IReportService.cs +++ b/DOAN.Service/MES/report/IService/IReportService.cs @@ -22,5 +22,6 @@ namespace DOAN.Service.MES.report.IService List MonthlyProductionCompletionRate(DateTime dateTime); List ProductionReport(DateTime dateTime); + ProductionReportRateModel ProductionReportRate(DateTime dateTime); } } diff --git a/DOAN.Service/MES/report/ReportService.cs b/DOAN.Service/MES/report/ReportService.cs index 0becf0f..4a7959b 100644 --- a/DOAN.Service/MES/report/ReportService.cs +++ b/DOAN.Service/MES/report/ReportService.cs @@ -339,5 +339,55 @@ namespace DOAN.Service.MES.report return woList; } + + public ProductionReportRateModel ProductionReportRate(DateTime dateTime) + { + var dt = dateTime.ToString("yyyy-MM-dd"); + ProductionReportRateModel model = new ProductionReportRateModel(); + var productionCompletionRate = ProductionCompletionRate("", dateTime); + model.CompletionRateList = productionCompletionRate.Select(t => + new ProductionReportRate + { + WorkTimePeriod = t.WorkTimePeriod, + Rate = t.CompletionRate + }).ToList(); + + string sql = @"SELECT FROM_UNIXTIME( FLOOR( UNIX_TIMESTAMP( d.created_time ) / 3600 ) * 3600 ) AS TimePeriod, + sum(number) AS Count + FROM pro_workorder AS r + RIGHT JOIN qc_finishedproduct_defect_collection AS d ON r.workorder = d.workorder + WHERE r.workorder_date = @dt + GROUP BY FLOOR( UNIX_TIMESTAMP( d.created_time ) / 600 ) + ORDER BY TimePeriod"; + + var defectList = Context.Ado.SqlQuery(sql, new { dt = dt, }); + + var tempList = defectList.Select(t => + new + { + Count = t.Count, + WorkTimePeriod = t.TimePeriod.ToString("HH:00") + } + ).ToList(); + + productionCompletionRate.ForEach(t => + { + var defectModel = tempList.Where(d => d.WorkTimePeriod == t.WorkTimePeriod).FirstOrDefault(); + var rate= defectModel==null ? 0 : Math.Round(defectModel.Count * 100.0 / t.DeliveryNum, 2); + + model.UnqualifiedRateList.Add(new ProductionReportRate + { + WorkTimePeriod = t.WorkTimePeriod, + Rate = rate + }); + model.QualifiedRateList.Add(new ProductionReportRate + { + WorkTimePeriod = t.WorkTimePeriod, + Rate = 100 - rate + }); + }); + + return model; + } } }