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
{
///
/// 设备停机时间
///
[Verify]
[Route("mes/deviceManagement/DeviceDowntimeRecord")]
public class DeviceDowntimeRecordController : BaseController
{
///
/// 设备停机时间接口
///
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);
}
///
/// 查询设备停机时间列表
///
///
///
[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);
}
///
/// 查询设备停机时间详情
///
///
///
[HttpGet("{Id}")]
[ActionPermissionFilter(Permission = "deviceManagement:devicedowntimerecord:query")]
public IActionResult GetDeviceDowntimeRecord(int Id)
{
var response = _DeviceDowntimeRecordService.GetInfo(Id);
var info = response.Adapt();
return SUCCESS(info);
}
///
/// 添加设备停机时间
///
///
[HttpPost]
[ActionPermissionFilter(Permission = "deviceManagement:devicedowntimerecord:add")]
[Log(Title = "设备停机时间", BusinessType = BusinessType.INSERT)]
public IActionResult AddDeviceDowntimeRecord([FromBody] DeviceDowntimeRecordDto parm)
{
var modal = parm.Adapt().ToCreate(HttpContext);
var response = _DeviceDowntimeRecordService.AddDeviceDowntimeRecord(modal);
return SUCCESS(response);
}
///
/// 更新设备停机时间
///
///
[HttpPut]
[ActionPermissionFilter(Permission = "deviceManagement:devicedowntimerecord:edit")]
[Log(Title = "设备停机时间", BusinessType = BusinessType.UPDATE)]
public IActionResult UpdateDeviceDowntimeRecord([FromBody] DeviceDowntimeRecordDto parm)
{
var modal = parm.Adapt().ToUpdate(HttpContext);
var response = _DeviceDowntimeRecordService.UpdateDeviceDowntimeRecord(modal);
return ToResponse(response);
}
///
/// 删除设备停机时间
///
///
[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 每月停机时间柱状图
///
/// 每月停机时间柱状图
///
///
public IActionResult GetDeviceDowntimeRecordMonthBarChart()
{
EchartsOptions response = _DeviceDowntimeRecordService.GetDeviceDowntimeRecordMonthBarChart();
//TODO 每月停机时间柱状图
return SUCCESS(response);
}
//TODO 停机原因TOP3
public IActionResult GetDeviceDowntimeRecordReasonTop3()
{
EchartsOptions response = _DeviceDowntimeRecordService.GetDeviceDowntimeRecordReasonTop3(10);
return SUCCESS(response);
}
#endregion
}
}