diff --git a/DOAN.Admin.WebApi/Controllers/MES/dev/DevicePerformanceController.cs b/DOAN.Admin.WebApi/Controllers/MES/dev/DevicePerformanceController.cs new file mode 100644 index 0000000..524ab48 --- /dev/null +++ b/DOAN.Admin.WebApi/Controllers/MES/dev/DevicePerformanceController.cs @@ -0,0 +1,111 @@ +using Microsoft.AspNetCore.Mvc; +using DOAN.Service.MES.dev.IService; +using DOAN.Model.MES.dev.Dto; +using DOAN.Admin.WebApi.Filters; +using DOAN.Model.MES.dev.Dto; +using DOAN.Model.MES.dev; +using Infrastructure.Converter; + +//创建时间:2024-05-27 +namespace DOAN.Admin.WebApi.Controllers +{ + /// + /// 设备运行绩效分析 + /// + [Verify] + [Route("mes/deviceManagement/DevicePerformance")] + public class DevicePerformanceController : BaseController + { + /// + /// 设备运行绩效分析接口 + /// + private readonly IDevicePerformanceService _DevicePerformanceService; + + public DevicePerformanceController(IDevicePerformanceService DevicePerformanceService) + { + _DevicePerformanceService = DevicePerformanceService; + } + + /// + /// 查询设备运行绩效分析列表 + /// + /// + /// + [HttpGet("list")] + [ActionPermissionFilter(Permission = "business:deviceperformance:list")] + public IActionResult QueryDevicePerformance([FromQuery] DevicePerformanceQueryDto parm) + { + parm.FillDate = DOANConvertDateTime.ConvertLocalDateTime(parm.FillDate.Value); + var response = _DevicePerformanceService.GetList(parm); + 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); + } + + /// + /// 添加设备运行绩效分析 + /// + /// + [HttpPost] + [ActionPermissionFilter(Permission = "business:deviceperformance:add")] + [Log(Title = "设备运行绩效分析", BusinessType = BusinessType.INSERT)] + public IActionResult AddDevicePerformance([FromBody] DevicePerformanceDto parm) + { + var modal = parm.Adapt().ToCreate(HttpContext); + + var response = _DevicePerformanceService.AddDevicePerformance(modal); + + return SUCCESS(response); + } + + /// + /// 更新设备运行绩效分析 + /// + /// + [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); + } + + /// + /// 删除设备运行绩效分析 + /// + /// + [HttpDelete("{ids}")] + [ActionPermissionFilter(Permission = "business:deviceperformance:delete")] + [Log(Title = "设备运行绩效分析", BusinessType = BusinessType.DELETE)] + public IActionResult DeleteDevicePerformance(string ids) + { + int[] idsArr = Tools.SpitIntArrary(ids); + if (idsArr.Length <= 0) { return ToResponse(ApiResult.Error($"删除失败Id 不能为空")); } + + var response = _DevicePerformanceService.Delete(idsArr); + + return ToResponse(response); + } + + + + + } +} \ No newline at end of file diff --git a/DOAN.Admin.WebApi/wwwroot/Generatecode/DOANAdmin.NET-设备运行绩效分析-0227172410.zip b/DOAN.Admin.WebApi/wwwroot/Generatecode/DOANAdmin.NET-设备运行绩效分析-0227172410.zip new file mode 100644 index 0000000..d0fe6a8 Binary files /dev/null and b/DOAN.Admin.WebApi/wwwroot/Generatecode/DOANAdmin.NET-设备运行绩效分析-0227172410.zip differ diff --git a/DOAN.Model/MES/dev/DevicePerformance.cs b/DOAN.Model/MES/dev/DevicePerformance.cs new file mode 100644 index 0000000..39f742c --- /dev/null +++ b/DOAN.Model/MES/dev/DevicePerformance.cs @@ -0,0 +1,193 @@ + +namespace DOAN.Model.MES.dev +{ + /// + /// 设备运行绩效分析 + /// + [SugarTable("device_performance")] + public class DevicePerformance + { + /// + /// 雪花 + /// + [SugarColumn(IsPrimaryKey = true, IsIdentity = false)] + public string Id { get; set; } + + /// + /// 可用时间 + /// + public decimal Usabletime { get; set; } + + /// + /// 节假日 + /// + public int? Holiday { get; set; } + + /// + /// 设备计划运行时间:(分钟) + /// + [SugarColumn(ColumnName = "plan_runtime")] + public decimal PlanRuntime { get; set; } + + /// + /// 计划内停机损失-无生产计划 + /// + [SugarColumn(ColumnName = "planning_no_production_time")] + public decimal PlanningNoProductionTime { get; set; } + + /// + /// 计划内停机损失-用餐时间 + /// + [SugarColumn(ColumnName = "planning_eat_time")] + public decimal PlanningEatTime { get; set; } + + /// + /// 计划内停机损失-班组会议 + /// + [SugarColumn(ColumnName = "planning_team_time")] + public decimal PlanningTeamTime { get; set; } + + /// + /// 计划内停机损失-培训 + /// + [SugarColumn(ColumnName = "planning_training")] + public decimal PlanningTraining { get; set; } + + /// + /// 计划内停机损失-员工休息时间 + /// + [SugarColumn(ColumnName = "planning_rest")] + public decimal PlanningRest { get; set; } + + /// + /// 计划内停机损失-周期性维护保养 + /// + [SugarColumn(ColumnName = "planning_maintenance")] + public decimal PlanningMaintenance { get; set; } + + /// + /// 计划内停机损失-停水/电/气 + /// + [SugarColumn(ColumnName = "planning_stop_energy")] + public decimal PlanningStopEnergy { get; set; } + + /// + /// 设备实际可用时间:(分钟) Actual usable time of equipment + /// + [SugarColumn(ColumnName = "actual_usabletime")] + public decimal ActualUsableTime { get; set; } + + /// + /// 计划外停机损失-设备故障停机时间 + /// + [SugarColumn(ColumnName = "accident_device_failure_time")] + public decimal AccidentDeviceFailureTime { get; set; } + + /// + /// 计划外停机损失-生产准备/调整时间 + /// + [SugarColumn(ColumnName = "accident_product_prepare")] + public decimal AccidentProductPrepare { get; set; } + + /// + /// 计划外停机损失-产线缺料停机 + /// + [SugarColumn(ColumnName = "accident_line_lack_material")] + public decimal AccidentLineLackMaterial { get; set; } + + /// + /// 计划外停机损失-产线换型时间 + /// + [SugarColumn(ColumnName = "accident_line_replace_model")] + public decimal AccidentLineReplaceModel { get; set; } + + /// + /// 计划外停机损失-质量问题停机 + /// + [SugarColumn(ColumnName = "accident_quality_problem")] + public decimal AccidentQualityProblem { get; set; } + + /// + /// 计划外停机损失-其他制造/工程问题 + /// + [SugarColumn(ColumnName = "accident_others")] + public decimal AccidentOthers { get; set; } + + /// + /// 设备实际运行时间:(分钟) + /// + [SugarColumn(ColumnName = "device_actual_runtime")] + public decimal DeviceActualRuntime { get; set; } + + /// + /// 故障停机总次数 + /// + [SugarColumn(ColumnName = "fault_shutdown_quantity")] + public int? FaultShutdownQuantity { get; set; } + + /// + /// 故障停机率 + /// + [SugarColumn(ColumnName = "fault_shutdown_rate")] + public decimal FaultShutdownRate { get; set; } + + /// + /// 设备完好率 + /// + [SugarColumn(ColumnName = "good_condition_rate")] + public decimal GoodConditionRate { get; set; } + + /// + /// 计划外停机率 + /// + [SugarColumn(ColumnName = "accident_shutdown_rate")] + public decimal AccidentShutdownRate { get; set; } + + /// + /// 综合设备开机率 + /// + [SugarColumn(ColumnName = "comprehensive_equipment_operating_rate")] + public decimal ComprehensiveEquipmentOperatingRate { get; set; } + + /// + /// MTBF(设备实际运行时间/故障总次数/20) + /// + public decimal Mtbf { get; set; } + + /// + /// MTTR(设备故障停机时间/故障总次数) + /// + public decimal Mttr { get; set; } + + /// + /// 填写日期 + /// + [SugarColumn(ColumnName = "fill_date")] + public DateTime? FillDate { get; set; } + + /// + /// 创建人 + /// + [SugarColumn(ColumnName = "cREATED_BY")] + public string CreatedBy { get; set; } + + /// + /// 创建时间 + /// + [SugarColumn(ColumnName = "cREATED_TIME")] + public DateTime? CreatedTime { get; set; } + + /// + /// 更新人 + /// + [SugarColumn(ColumnName = "uPDATED_BY")] + public string UpdatedBy { get; set; } + + /// + /// 更新时间 + /// + [SugarColumn(ColumnName = "uPDATED_TIME")] + public DateTime? UpdatedTime { get; set; } + + } +} \ No newline at end of file diff --git a/DOAN.Model/MES/dev/Dto/DevicePerformanceDto.cs b/DOAN.Model/MES/dev/Dto/DevicePerformanceDto.cs new file mode 100644 index 0000000..4bb74c1 --- /dev/null +++ b/DOAN.Model/MES/dev/Dto/DevicePerformanceDto.cs @@ -0,0 +1,84 @@ +using System.ComponentModel.DataAnnotations; + +namespace DOAN.Model.MES.dev.Dto +{ + /// + /// 设备运行绩效分析查询对象 + /// + public class DevicePerformanceQueryDto : PagerInfo + { + public DateTime? FillDate { get; set; } + } + + /// + /// 设备运行绩效分析输入输出对象 + /// + public class DevicePerformanceDto + { + + public string Id { get; set; } + + public decimal Usabletime { get; set; } + + public int? Holiday { get; set; } + + public decimal PlanRuntime { get; set; } + + public decimal PlanningNoProductionTime { get; set; } + + public decimal PlanningEatTime { get; set; } + + public decimal PlanningTeamTime { get; set; } + + public decimal PlanningTraining { get; set; } + + public decimal PlanningRest { get; set; } + + public decimal PlanningMaintenance { get; set; } + + public decimal PlanningStopEnergy { get; set; } + + public decimal ActualUsableTime { get; set; } + + public decimal AccidentDeviceFailureTime { get; set; } + + public decimal AccidentProductPrepare { get; set; } + + public decimal AccidentLineLackMaterial { get; set; } + + public decimal AccidentLineReplaceModel { get; set; } + + public decimal AccidentQualityProblem { get; set; } + + public decimal AccidentOthers { get; set; } + + public decimal DeviceActualRuntime { get; set; } + + public int? FaultShutdownQuantity { get; set; } + + public decimal FaultShutdownRate { get; set; } + + public decimal GoodConditionRate { get; set; } + + public decimal AccidentShutdownRate { get; set; } + + public decimal ComprehensiveEquipmentOperatingRate { get; set; } + + public decimal Mtbf { get; set; } + + public decimal Mttr { get; set; } + + public DateTime? FillDate { get; set; } + + public string CreatedBy { get; set; } + + public DateTime? CreatedTime { get; set; } + + public string UpdatedBy { get; set; } + + public DateTime? UpdatedTime { get; set; } + + + + } +} \ No newline at end of file diff --git a/DOAN.Service/MES/BI/AndonDataAnalysisService.cs b/DOAN.Service/MES/BI/AndonDataAnalysisService.cs index 37e2eab..b53e753 100644 --- a/DOAN.Service/MES/BI/AndonDataAnalysisService.cs +++ b/DOAN.Service/MES/BI/AndonDataAnalysisService.cs @@ -106,7 +106,7 @@ namespace DOAN.Service.MES.BI public EchartsOptions ShutdownBar() { EchartsOptions echartsOptions = new EchartsOptions(); - echartsOptions.Title = new EchartsTitle { Text = "本月停机时间统计", SubText = "本月停机时间统计" }; + echartsOptions.Title = new EchartsTitle { Text = "本月异常停机时间统计", SubText = "本月异常停机时间统计" }; // 获取当前日期和时间 DateTime now = DateTime.Now; // 获取本月的最开始时间(本月的第一天的午夜时间) diff --git a/DOAN.Service/MES/dev/DevicePerformanceService.cs b/DOAN.Service/MES/dev/DevicePerformanceService.cs new file mode 100644 index 0000000..d009662 --- /dev/null +++ b/DOAN.Service/MES/dev/DevicePerformanceService.cs @@ -0,0 +1,143 @@ +using System; +using SqlSugar; +using Infrastructure.Attribute; +using Infrastructure.Extensions; +using DOAN.Model; +using DOAN.Model.Dto; +using DOAN.Model.MES.dev.Dto; +using DOAN.Model.MES.dev; +using DOAN.Repository; +using DOAN.Service.MES.dev.IService; +using System.Linq; + +namespace DOAN.Service.MES.dev +{ + /// + /// 设备运行绩效分析Service业务层处理 + /// + [AppService(ServiceType = typeof(IDevicePerformanceService), ServiceLifetime = LifeTime.Transient)] + public class DevicePerformanceService : BaseService, IDevicePerformanceService + { + /// + /// 查询设备运行绩效分析列表 + /// + /// + /// + public PagedInfo GetList(DevicePerformanceQueryDto parm) + { + var predicate = Expressionable.Create() + .AndIF(parm.FillDate>DateTime.MinValue,it=>it.FillDate==parm.FillDate) + ; + var response = Queryable() + .Where(predicate.ToExpression()) + .ToPage(parm); + return response; + } + + + /// + /// 获取详情 + /// + /// + /// + public DevicePerformance GetInfo(string Id) + { + var response = Queryable() + .Where(x => x.Id == Id) + .First(); + + return response; + } + + /// + /// 添加设备运行绩效分析 + /// + /// + /// + public DevicePerformance AddDevicePerformance(DevicePerformance model) + { + model.Id = XueHua; + AutoCalculation(ref model); + return Context.Insertable(model).ExecuteReturnEntity(); + } + + /// + /// 修改设备运行绩效分析 + /// + /// + /// + public int UpdateDevicePerformance(DevicePerformance model) + { + AutoCalculation(ref model); + //var response = Update(w => w.Id == model.Id, it => new DevicePerformance() + //{ + // Usabletime = model.Usabletime, + // PlanRuntime = model.PlanRuntime, + // PlanningNoProductionTime = model.PlanningNoProductionTime, + // PlanningEatTime = model.PlanningEatTime, + // PlanningTeamTime = model.PlanningTeamTime, + // PlanningTraining = model.PlanningTraining, + // PlanningRest = model.PlanningRest, + // PlanningMaintenance = model.PlanningMaintenance, + // PlanningStopEnergy = model.PlanningStopEnergy, + // DeviceActualRuntime = model.DeviceActualRuntime, + // FaultShutdownQuantity = model.FaultShutdownQuantity, + // FaultShutdownRate = model.FaultShutdownRate, + // GoodConditionRate = model.GoodConditionRate, + // ComprehensiveEquipmentOperatingRate = model.ComprehensiveEquipmentOperatingRate, + // Mtbf = model.Mtbf, + // Mttr = model.Mttr, + // FillDate = model.FillDate, + // CreatedBy = model.CreatedBy, + // CreatedTime = model.CreatedTime, + // UpdatedBy = model.UpdatedBy, + // UpdatedTime = model.UpdatedTime, + //}); + //return response; + return Update(model, true); + } + + private void AutoCalculation(ref DevicePerformance model) + { + + // 设备计划运行时间:(分钟)=设备可使用时间:(分钟)-节假日 + model.PlanRuntime = model.Usabletime - model.Holiday??0; + + //设备实际可用时间:(分钟) + model.ActualUsableTime = model.PlanRuntime - model.PlanningNoProductionTime - model.PlanningEatTime - model.PlanningTeamTime - model.PlanningTraining - model.PlanningRest - model.PlanningMaintenance - model.PlanningStopEnergy; + + //设备实际运行时间:(分钟) + model.DeviceActualRuntime = model.ActualUsableTime - model.AccidentDeviceFailureTime - model.AccidentProductPrepare - model.AccidentLineLackMaterial - model.AccidentLineReplaceModel - model.AccidentQualityProblem - model.AccidentOthers; + + + //故障停机率 + if (model.ActualUsableTime > 0) + { + model.FaultShutdownRate = Math.Round(model.AccidentDeviceFailureTime / model.ActualUsableTime, 2); + } + + //设备完好率 + if (model.ActualUsableTime > 0) + { + model.GoodConditionRate = Math.Round(model.DeviceActualRuntime / model.ActualUsableTime, 2); + } + + //计划外停机率 + model.AccidentShutdownRate = 1 - model.DeviceActualRuntime; + + //综合设备开机率 + if(model.PlanRuntime>0) + { + model.ComprehensiveEquipmentOperatingRate = model.DeviceActualRuntime / model.PlanRuntime; + } + //MTBF(设备实际运行时间/故障总次数/60 + model.Mtbf = Math.Round(model.DeviceActualRuntime / model.FaultShutdownQuantity??0 / 60,2); + + //MTTR(设备故障停机时间/故障总次数) + model.Mttr = Math.Round(model.AccidentDeviceFailureTime / model.FaultShutdownQuantity ?? 0, 2); + + + } + + } +} \ No newline at end of file diff --git a/DOAN.Service/MES/dev/IService/IDevicePerformanceService.cs b/DOAN.Service/MES/dev/IService/IDevicePerformanceService.cs new file mode 100644 index 0000000..a18d57f --- /dev/null +++ b/DOAN.Service/MES/dev/IService/IDevicePerformanceService.cs @@ -0,0 +1,24 @@ +using System; +using DOAN.Model; +using DOAN.Model.Dto; +using DOAN.Model.MES.dev.Dto; +using DOAN.Model.MES.dev; +using System.Collections.Generic; + +namespace DOAN.Service.MES.dev.IService +{ + /// + /// 设备运行绩效分析service接口 + /// + public interface IDevicePerformanceService : IBaseService + { + PagedInfo GetList(DevicePerformanceQueryDto parm); + + DevicePerformance GetInfo(string Id); + + DevicePerformance AddDevicePerformance(DevicePerformance parm); + + int UpdateDevicePerformance(DevicePerformance parm); + + } +}