zhuangpei-mesbackend/DOAN.Admin.WebApi/Controllers/MES/dev/DeviceDowntimeRecordController.cs
qianhao.xu 3c0a8e1531 1
2025-06-16 10:22:28 +08:00

151 lines
5.0 KiB
C#

using Microsoft.AspNetCore.Mvc;
using DOAN.Model.Dto;
using DOAN.Service.MES.dev.IService;
using DOAN.Model.MES.dev.Dto;
using DOAN.Admin.WebApi.Filters;
using DOAN.Model.MES.dev;
using Infrastructure.Converter;
using DOAN.Model.mes.echarts;
namespace DOAN.Admin.WebApi.Controllers
{
/// <summary>
/// 设备停机时间
/// </summary>
[Verify]
[Route("mes/deviceManagement/DeviceDowntimeRecord")]
public class DeviceDowntimeRecordController : BaseController
{
/// <summary>
/// 设备停机时间接口
/// </summary>
private readonly IDeviceDowntimeRecordService _DeviceDowntimeRecordService;
public DeviceDowntimeRecordController(IDeviceDowntimeRecordService DeviceDowntimeRecordService)
{
_DeviceDowntimeRecordService = DeviceDowntimeRecordService;
}
//TODO 筛选设备
[HttpGet("getDevices")]
public IActionResult GetDevices(string query)
{
var response= _DeviceDowntimeRecordService.GetDevices(query);
return SUCCESS(response);
}
/// <summary>
/// 查询设备停机时间列表
/// </summary>
/// <param name="parm"></param>
/// <returns></returns>
[HttpPost("list")]
[ActionPermissionFilter(Permission = "deviceManagement:devicedowntimerecord:list")]
public IActionResult QueryDeviceDowntimeRecord([FromBody] DeviceDowntimeRecordQueryDto parm)
{
parm.DateTimeRange[0] = DOANConvertDateTime.ConvertLocalDateTime(parm.DateTimeRange[0]);
parm.DateTimeRange[1] = DOANConvertDateTime.ConvertLocalDateTime(parm.DateTimeRange[1]);
var response = _DeviceDowntimeRecordService.GetList(parm);
return SUCCESS(response);
}
/// <summary>
/// 查询设备停机时间详情
/// </summary>
/// <param name="Id"></param>
/// <returns></returns>
[HttpGet("{Id}")]
[ActionPermissionFilter(Permission = "deviceManagement:devicedowntimerecord:query")]
public IActionResult GetDeviceDowntimeRecord(int Id)
{
var response = _DeviceDowntimeRecordService.GetInfo(Id);
var info = response.Adapt<DeviceDowntimeRecord>();
return SUCCESS(info);
}
/// <summary>
/// 添加设备停机时间
/// </summary>
/// <returns></returns>
[HttpPost]
[ActionPermissionFilter(Permission = "deviceManagement:devicedowntimerecord:add")]
[Log(Title = "设备停机时间", BusinessType = BusinessType.INSERT)]
public IActionResult AddDeviceDowntimeRecord([FromBody] DeviceDowntimeRecordDto parm)
{
var modal = parm.Adapt<DeviceDowntimeRecord>().ToCreate(HttpContext);
var response = _DeviceDowntimeRecordService.AddDeviceDowntimeRecord(modal);
return SUCCESS(response);
}
/// <summary>
/// 更新设备停机时间
/// </summary>
/// <returns></returns>
[HttpPut]
[ActionPermissionFilter(Permission = "deviceManagement:devicedowntimerecord:edit")]
[Log(Title = "设备停机时间", BusinessType = BusinessType.UPDATE)]
public IActionResult UpdateDeviceDowntimeRecord([FromBody] DeviceDowntimeRecordDto parm)
{
var modal = parm.Adapt<DeviceDowntimeRecord>().ToUpdate(HttpContext);
var response = _DeviceDowntimeRecordService.UpdateDeviceDowntimeRecord(modal);
return ToResponse(response);
}
/// <summary>
/// 删除设备停机时间
/// </summary>
/// <returns></returns>
[HttpDelete("{ids}")]
[ActionPermissionFilter(Permission = "deviceManagement:devicedowntimerecord:delete")]
[Log(Title = "设备停机时间", BusinessType = BusinessType.DELETE)]
public IActionResult DeleteDeviceDowntimeRecord(string ids)
{
int[] idsArr = Tools.SpitIntArrary(ids);
if (idsArr.Length <= 0) { return ToResponse(ApiResult.Error($"删除失败Id 不能为空")); }
var response = _DeviceDowntimeRecordService.Delete(idsArr);
return ToResponse(response);
}
#region BI
//TODO 每月停机时间柱状图
/// <summary>
/// 每月停机时间柱状图
/// </summary>
/// <returns></returns>
public IActionResult GetDeviceDowntimeRecordMonthBarChart()
{
EchartsOptions response = _DeviceDowntimeRecordService.GetDeviceDowntimeRecordMonthBarChart();
//TODO 每月停机时间柱状图
return SUCCESS(response);
}
//TODO 停机原因TOP3
//public IActionResult actionResult GetDeviceDowntimeRecordReasonTop3()
//{
// //TODO 停机原因TOP3
// return ToResponse(new ApiResult((int)ResultCode.SUCCESS, "停机原因TOP3"));
//}
#endregion
}
}