2024-12-30 16:59:54 +08:00
|
|
|
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;
|
2025-06-16 10:21:40 +08:00
|
|
|
using DOAN.Model.mes.echarts;
|
2024-12-30 16:59:54 +08:00
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
2024-12-30 17:19:33 +08:00
|
|
|
//TODO 筛选设备
|
|
|
|
|
[HttpGet("getDevices")]
|
|
|
|
|
public IActionResult GetDevices(string query)
|
|
|
|
|
{
|
|
|
|
|
var response= _DeviceDowntimeRecordService.GetDevices(query);
|
|
|
|
|
return SUCCESS(response);
|
|
|
|
|
|
|
|
|
|
}
|
2024-12-30 16:59:54 +08:00
|
|
|
/// <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);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2025-06-16 10:21:40 +08:00
|
|
|
#region 设备停机时间BI
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//TODO 每月停机时间柱状图
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 每月停机时间柱状图
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
2025-06-16 10:42:15 +08:00
|
|
|
[HttpGet("getMonthBarChart")]
|
2025-06-16 10:21:40 +08:00
|
|
|
public IActionResult GetDeviceDowntimeRecordMonthBarChart()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
EchartsOptions response = _DeviceDowntimeRecordService.GetDeviceDowntimeRecordMonthBarChart();
|
|
|
|
|
//TODO 每月停机时间柱状图
|
2025-06-16 10:22:28 +08:00
|
|
|
return SUCCESS(response);
|
2025-06-16 10:21:40 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//TODO 停机原因TOP3
|
2025-06-16 10:42:15 +08:00
|
|
|
[HttpGet("getReasonTopN")]
|
2025-06-16 10:38:57 +08:00
|
|
|
public IActionResult GetDeviceDowntimeRecordReasonTop3()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
EchartsOptions response = _DeviceDowntimeRecordService.GetDeviceDowntimeRecordReasonTop3(10);
|
|
|
|
|
return SUCCESS(response);
|
|
|
|
|
}
|
2025-06-16 10:21:40 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
2024-12-30 16:59:54 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|