126 lines
4.1 KiB
C#
Raw Normal View History

2026-01-20 09:23:56 +08:00
using Microsoft.AspNetCore.Mvc;
using RIZO.Model.MES.alarm;
using RIZO.Model.MES.alarm.Dto;
using RIZO.Service.MES.alarm.IService;
//创建时间2026-01-19
namespace RIZO.Admin.WebApi.Controllers.Mes.alerm
{
/// <summary>
/// PLC报警信息
/// </summary>
[Route("mes/AlarmInfo")]
[AllowAnonymous]
public class AlarmInfoController : BaseController
{
/// <summary>
/// PLC报警信息接口
/// </summary>
private readonly IAlarmInfoService _AlarmInfoService;
public AlarmInfoController(IAlarmInfoService AlarmInfoService)
{
_AlarmInfoService = AlarmInfoService;
}
/// <summary>
/// 查询PLC报警信息列表
/// </summary>
/// <param name="parm"></param>
/// <returns></returns>
[HttpGet("list")]
[ActionPermissionFilter(Permission = "alarminfo:list")]
public IActionResult QueryAlarmInfo([FromQuery] AlarmInfoQueryDto parm)
{
var response = _AlarmInfoService.GetList(parm);
return SUCCESS(response);
}
/// <summary>
/// 查询PLC报警信息详情
/// </summary>
/// <param name="Id"></param>
/// <returns></returns>
[HttpGet("{Id}")]
[ActionPermissionFilter(Permission = "alarminfo:query")]
public IActionResult GetAlarmInfo(int Id)
{
var response = _AlarmInfoService.GetInfo(Id);
var info = response.Adapt<AlarmInfoDto>();
return SUCCESS(info);
}
/// <summary>
/// 添加PLC报警信息
/// </summary>
/// <returns></returns>
[HttpPost]
[ActionPermissionFilter(Permission = "alarminfo:add")]
[Log(Title = "PLC报警信息", BusinessType = BusinessType.INSERT)]
public IActionResult AddAlarmInfo([FromBody] AlarmInfoDto parm)
{
var modal = parm.Adapt<AlarmInfo>().ToCreate(HttpContext);
var response = _AlarmInfoService.AddAlarmInfo(modal);
return SUCCESS(response);
}
/// <summary>
/// 更新PLC报警信息
/// </summary>
/// <returns></returns>
[HttpPut]
[ActionPermissionFilter(Permission = "alarminfo:edit")]
[Log(Title = "PLC报警信息", BusinessType = BusinessType.UPDATE)]
public IActionResult UpdateAlarmInfo([FromBody] AlarmInfoDto parm)
{
var modal = parm.Adapt<AlarmInfo>().ToUpdate(HttpContext);
var response = _AlarmInfoService.UpdateAlarmInfo(modal);
return ToResponse(response);
}
/// <summary>
/// 删除PLC报警信息
/// </summary>
/// <returns></returns>
[HttpPost("delete/{ids}")]
[ActionPermissionFilter(Permission = "alarminfo:delete")]
[Log(Title = "PLC报警信息", BusinessType = BusinessType.DELETE)]
public IActionResult DeleteAlarmInfo([FromRoute]string ids)
{
var idArr = Tools.SplitAndConvert<int>(ids);
return ToResponse(_AlarmInfoService.Delete(idArr));
}
2026-01-21 10:26:48 +08:00
/// 导出设备报警信息
/// </summary>
/// <returns></returns>
[HttpGet("export")]
[Log(Title = "设备报警信息", BusinessType = BusinessType.EXPORT)]
public IActionResult Export([FromQuery] AlarmInfoQueryDto parm)
{
var list = _AlarmInfoService.GetList(parm).Result;
if (list == null || list.Count <= 0)
{
return ToResponse(ResultCode.FAIL, "没有要导出的数据");
}
var (sFileName, sFilePath) = ExportExcelMini(list, "设备报警信息", "设备报警信息");
if (string.IsNullOrWhiteSpace(sFilePath))
{
return ToResponse(ResultCode.FAIL, "Excel生成失败");
}
return PhysicalFile(
sFilePath,
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
sFileName,
true
);
}
2026-01-20 09:23:56 +08:00
}
}