From 938696d5134dc1cd1bce4e5add7cf24b4be77912 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8D=A2=E6=B1=9F=E6=B5=B7?= <18360817963@163.com> Date: Tue, 18 Mar 2025 16:19:31 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AE=BE=E5=A4=87=E8=BF=90=E8=A1=8C=E7=BB=A9?= =?UTF-8?q?=E6=95=88=E5=88=86=E6=9E=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../MES/dev/DevicePerformanceController.cs | 182 +++++++++--------- .../MES/dev/DevicePerformanceService.cs | 44 +++-- 2 files changed, 125 insertions(+), 101 deletions(-) diff --git a/DOAN.Admin.WebApi/Controllers/MES/dev/DevicePerformanceController.cs b/DOAN.Admin.WebApi/Controllers/MES/dev/DevicePerformanceController.cs index 65ebf62..73174e7 100644 --- a/DOAN.Admin.WebApi/Controllers/MES/dev/DevicePerformanceController.cs +++ b/DOAN.Admin.WebApi/Controllers/MES/dev/DevicePerformanceController.cs @@ -9,113 +9,117 @@ using Infrastructure.Converter; //创建时间:2024-05-27 namespace DOAN.Admin.WebApi.Controllers { - /// - /// 设备运行绩效分析 - /// - [Verify] - [Route("mes/deviceManagement/DevicePerformance")] - public class DevicePerformanceController : BaseController - { - /// - /// 设备运行绩效分析接口 - /// - private readonly IDevicePerformanceService _DevicePerformanceService; + /// + /// 设备运行绩效分析 + /// + [Verify] + [Route("mes/deviceManagement/DevicePerformance")] + public class DevicePerformanceController : BaseController + { + /// + /// 设备运行绩效分析接口 + /// + private readonly IDevicePerformanceService _DevicePerformanceService; - public DevicePerformanceController(IDevicePerformanceService DevicePerformanceService) - { - _DevicePerformanceService = DevicePerformanceService; - } + public DevicePerformanceController(IDevicePerformanceService DevicePerformanceService) + { + _DevicePerformanceService = DevicePerformanceService; + } + + /// + /// 查询设备运行绩效分析列表 + /// + /// + /// + [HttpPost("list")] + [ActionPermissionFilter(Permission = "business:deviceperformance:list")] + public IActionResult QueryDevicePerformance([FromBody] DevicePerformanceQueryDto parm) + { - /// - /// 查询设备运行绩效分析列表 - /// - /// - /// - [HttpPost("list")] - [ActionPermissionFilter(Permission = "business:deviceperformance:list")] - public IActionResult QueryDevicePerformance([FromBody] DevicePerformanceQueryDto parm) - { - var response = _DevicePerformanceService.GetList(parm); - return SUCCESS(response); - } + return SUCCESS(response); + } - /// - /// 查询设备运行绩效分析详情 - /// - /// - /// - [HttpGet("{Id}")] - [ActionPermissionFilter(Permission = "business:deviceperformance:query")] - public IActionResult GetDevicePerformance(string Id) - { - var response = _DevicePerformanceService.GetInfo(Id); - - var info = response.Adapt(); - return SUCCESS(info); - } + /// + /// 查询设备运行绩效分析详情 + /// + /// + /// + [HttpGet("{Id}")] + [ActionPermissionFilter(Permission = "business:deviceperformance:query")] + public IActionResult GetDevicePerformance(string Id) + { + var response = _DevicePerformanceService.GetInfo(Id); - /// - /// 添加设备运行绩效分析 - /// - /// - [HttpPost] - [ActionPermissionFilter(Permission = "business:deviceperformance:add")] - [Log(Title = "设备运行绩效分析", BusinessType = BusinessType.INSERT)] - public IActionResult AddDevicePerformance([FromBody] DevicePerformanceDto parm) - { - var modal = parm.Adapt().ToCreate(HttpContext); + var info = response.Adapt(); + return SUCCESS(info); + } - var response = _DevicePerformanceService.AddDevicePerformance(modal); - string data = ""; - if (response == -1) - { - data = "填写日期不能重复"; + /// + /// 添加设备运行绩效分析 + /// + /// + [HttpPost] + [ActionPermissionFilter(Permission = "business:deviceperformance:add")] + [Log(Title = "设备运行绩效分析", BusinessType = BusinessType.INSERT)] + public IActionResult AddDevicePerformance([FromBody] DevicePerformanceDto parm) + { + var modal = parm.Adapt().ToCreate(HttpContext); - } - else - { + var response = _DevicePerformanceService.AddDevicePerformance(modal); + string data = ""; + if (response == -1) + { + data = "填写日期不能重复"; + + } + else if (response == -2) + { + data = "填写日期不能为空"; + } + else + { data = "成功"; } - return SUCCESS(data); - } + return SUCCESS(data); + } - /// - /// 更新设备运行绩效分析 - /// - /// - [HttpPut] - [ActionPermissionFilter(Permission = "business:deviceperformance:edit")] - [Log(Title = "设备运行绩效分析", BusinessType = BusinessType.UPDATE)] - public IActionResult UpdateDevicePerformance([FromBody] DevicePerformanceDto parm) - { - var modal = parm.Adapt().ToUpdate(HttpContext); - var response = _DevicePerformanceService.UpdateDevicePerformance(modal); + /// + /// 更新设备运行绩效分析 + /// + /// + [HttpPut] + [ActionPermissionFilter(Permission = "business:deviceperformance:edit")] + [Log(Title = "设备运行绩效分析", BusinessType = BusinessType.UPDATE)] + public IActionResult UpdateDevicePerformance([FromBody] DevicePerformanceDto parm) + { + var modal = parm.Adapt().ToUpdate(HttpContext); + var response = _DevicePerformanceService.UpdateDevicePerformance(modal); - return ToResponse(response); - } + return ToResponse(response); + } - /// - /// 删除设备运行绩效分析 - /// - /// - [HttpDelete("{ids}")] - [ActionPermissionFilter(Permission = "business:deviceperformance:delete")] - [Log(Title = "设备运行绩效分析", BusinessType = BusinessType.DELETE)] - public IActionResult DeleteDevicePerformance(string ids) - { - string [] idsArr = Tools.SpitStrArrary(ids); - if (idsArr.Length <= 0) { return ToResponse(ApiResult.Error($"删除失败Id 不能为空")); } + /// + /// 删除设备运行绩效分析 + /// + /// + [HttpDelete("{ids}")] + [ActionPermissionFilter(Permission = "business:deviceperformance:delete")] + [Log(Title = "设备运行绩效分析", BusinessType = BusinessType.DELETE)] + public IActionResult DeleteDevicePerformance(string ids) + { + string[] idsArr = Tools.SpitStrArrary(ids); + if (idsArr.Length <= 0) { return ToResponse(ApiResult.Error($"删除失败Id 不能为空")); } - var response = _DevicePerformanceService.Delete(idsArr); + var response = _DevicePerformanceService.Delete(idsArr); - return ToResponse(response); - } + return ToResponse(response); + } - } + } } \ No newline at end of file diff --git a/DOAN.Service/MES/dev/DevicePerformanceService.cs b/DOAN.Service/MES/dev/DevicePerformanceService.cs index 992e5d2..2e2f6f7 100644 --- a/DOAN.Service/MES/dev/DevicePerformanceService.cs +++ b/DOAN.Service/MES/dev/DevicePerformanceService.cs @@ -29,7 +29,6 @@ namespace DOAN.Service.MES.dev { var response = Queryable(); - if (parm.FillDateTime != null && parm.FillDateTime.Length == 2) { @@ -71,16 +70,24 @@ namespace DOAN.Service.MES.dev /// public int AddDevicePerformance(DevicePerformance model) { - if (Queryable().Where(x => x.FillDate.Value.ToString("yyyy-MM-dd") == model.FillDate.Value.ToString("yyyy-MM-dd")).Count() > 0) + if (model.FillDate!=null) { - return -1;//填写日期不能重复 + if (Queryable().Where(x => x.FillDate.Value.ToString("yyyy-MM-dd") == model.FillDate.Value.ToString("yyyy-MM-dd")).Count() > 0) + { + return -1;//填写日期不能重复 + } + else + { + model.Id = XueHua; + AutoCalculation(ref model); + return Context.Insertable(model).ExecuteCommand(); + } } else { - model.Id = XueHua; - AutoCalculation(ref model); - return Context.Insertable(model).ExecuteCommand(); + return -2;//填写日期不能为空 } + } @@ -135,27 +142,40 @@ namespace DOAN.Service.MES.dev //故障停机率 - if (model.ActualUsableTime > 0) + if (model.ActualUsableTime > 0 || model.ActualUsableTime < 0) { model.FaultShutdownRate = Math.Round(model.AccidentDeviceFailureTime / model.ActualUsableTime, 2); } + else + { + model.FaultShutdownRate = -1; + } //设备完好率 - if (model.ActualUsableTime > 0) + if (model.ActualUsableTime > 0 || model.ActualUsableTime < 0) { model.GoodConditionRate = Math.Round(model.DeviceActualRuntime / model.ActualUsableTime, 2); } + else + { + model.GoodConditionRate = -1; + } //计划外停机率 - model.AccidentShutdownRate = 1 - model.DeviceActualRuntime; + model.AccidentShutdownRate = 1 - model.GoodConditionRate; //综合设备开机率 - if(model.PlanRuntime>0) + if (model.PlanRuntime > 0|| model.PlanRuntime <0) { - model.ComprehensiveEquipmentOperatingRate = model.DeviceActualRuntime / model.PlanRuntime; + model.ComprehensiveEquipmentOperatingRate = Math.Round( model.DeviceActualRuntime / model.PlanRuntime,2); } + else + { + model.ComprehensiveEquipmentOperatingRate = 0; + + } //MTBF(设备实际运行时间/故障总次数/60 - model.Mtbf = Math.Round(model.DeviceActualRuntime / model.FaultShutdownQuantity??0 / 60,2); + model.Mtbf = Math.Round((model.DeviceActualRuntime / model.FaultShutdownQuantity??0) / 60,2); //MTTR(设备故障停机时间/故障总次数) model.Mttr = Math.Round(model.AccidentDeviceFailureTime / model.FaultShutdownQuantity ?? 0, 2);