feat(mqtt): 添加设备数据上传功能及相关服务
实现设备数据通过MQTT上传功能,包括: 1. 新增DeviceUploadData实体及DTO 2. 添加MQTT服务处理设备消息 3. 实现设备数据存储逻辑 4. 创建相关控制器和服务接口
This commit is contained in:
105
ZR.Admin.WebApi/Controllers/mes/dc/DeviceUploadDataController.cs
Normal file
105
ZR.Admin.WebApi/Controllers/mes/dc/DeviceUploadDataController.cs
Normal file
@@ -0,0 +1,105 @@
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using MQTTnet.Protocol;
|
||||
using ZR.Common.MqttHelper;
|
||||
using ZR.Service.mqtt;
|
||||
|
||||
namespace ZR.Admin.WebApi.Controllers
|
||||
{
|
||||
|
||||
@@ -12,6 +12,7 @@ using ZR.Admin.WebApi.Hubs;
|
||||
using ZR.Admin.WebApi.Middleware;
|
||||
using ZR.Common.Cache;
|
||||
using ZR.Common.MqttHelper;
|
||||
using ZR.Service.mqtt;
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
// Add services to the container.
|
||||
|
||||
BIN
ZR.Admin.WebApi/wwwroot/Generatecode/ZrAdmin.NET--0921123904.zip
Normal file
BIN
ZR.Admin.WebApi/wwwroot/Generatecode/ZrAdmin.NET--0921123904.zip
Normal file
Binary file not shown.
Reference in New Issue
Block a user