shgx_tz_mom/ZR.Admin.WebApi/Controllers/mes/dc/DeviceUploadDataController.cs
赵正易 8e459d0ccd feat(mqtt): 添加设备数据上传功能及相关服务
实现设备数据通过MQTT上传功能,包括:
1. 新增DeviceUploadData实体及DTO
2. 添加MQTT服务处理设备消息
3. 实现设备数据存储逻辑
4. 创建相关控制器和服务接口
2025-09-21 13:52:06 +08:00

105 lines
3.1 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using Microsoft.AspNetCore.Mvc;
using ZR.Model.Dto;
using ZR.Model.Business;
using ZR.Service.Business.IBusinessService;
using ZR.Admin.WebApi.Extensions;
using ZR.Admin.WebApi.Filters;
using ZR.Service.MES.dc.IService;
using ZR.Model.dc;
//创建时间2025-09-21
namespace ZR.Admin.WebApi.Controllers
{
/// <summary>
/// 设备数据上传
/// </summary>
[Route("business/DeviceUploadData")]
public class DeviceUploadDataController : BaseController
{
/// <summary>
/// 接口
/// </summary>
private readonly IDeviceUploadDataService _DeviceUploadDataService;
public DeviceUploadDataController(IDeviceUploadDataService DeviceUploadDataService)
{
_DeviceUploadDataService = DeviceUploadDataService;
}
/// <summary>
/// 查询列表
/// </summary>
/// <param name="parm"></param>
/// <returns></returns>
[HttpGet("list")]
public IActionResult QueryDeviceUploadData([FromQuery] DeviceUploadDataQueryDto parm)
{
var response = _DeviceUploadDataService.GetList(parm);
return SUCCESS(response);
}
/// <summary>
/// 查询详情
/// </summary>
/// <param name="Id"></param>
/// <returns></returns>
[HttpGet("{Id}")]
public IActionResult GetDeviceUploadData(long Id)
{
var response = _DeviceUploadDataService.GetInfo(Id);
var info = response.Adapt<DeviceUploadData>();
return SUCCESS(info);
}
/// <summary>
/// 添加
/// </summary>
/// <returns></returns>
[HttpPost]
[Log(Title = "", BusinessType = BusinessType.INSERT)]
public IActionResult AddDeviceUploadData([FromBody] DeviceUploadDataDto parm)
{
var modal = parm.Adapt<DeviceUploadData>().ToCreate(HttpContext);
var response = _DeviceUploadDataService.AddDeviceUploadData(modal);
return SUCCESS(response);
}
/// <summary>
/// 更新
/// </summary>
/// <returns></returns>
[HttpPut]
[Log(Title = "", BusinessType = BusinessType.UPDATE)]
public IActionResult UpdateDeviceUploadData([FromBody] DeviceUploadDataDto parm)
{
var modal = parm.Adapt<DeviceUploadData>().ToUpdate(HttpContext);
var response = _DeviceUploadDataService.UpdateDeviceUploadData(modal);
return ToResponse(response);
}
/// <summary>
/// 删除
/// </summary>
/// <returns></returns>
[HttpDelete("{ids}")]
[Log(Title = "", BusinessType = BusinessType.DELETE)]
public IActionResult DeleteDeviceUploadData(string ids)
{
int[] idsArr = Tools.SpitIntArrary(ids);
if (idsArr.Length <= 0) { return ToResponse(ApiResult.Error($"删除失败Id 不能为空")); }
var response = _DeviceUploadDataService.Delete(idsArr);
return ToResponse(response);
}
}
}