144 lines
5.5 KiB
C#
144 lines
5.5 KiB
C#
using JiShe.IoT.DeviceAggregation;
|
|
using JiShe.IoT.DeviceAggregation.Dto;
|
|
using JiShe.ServicePro;
|
|
using JiShe.ServicePro.Core;
|
|
using JiShe.ServicePro.DeviceManagement.DeviceInfos;
|
|
using Microsoft.AspNetCore.Authorization;
|
|
using Volo.Abp.Content;
|
|
|
|
namespace JiShe.IoT.Controllers
|
|
{
|
|
/// <summary>
|
|
/// 设备聚合服务
|
|
/// </summary>
|
|
[Route("/Aggregation/Device")]
|
|
public class DeviceAggregationController : IoTController
|
|
{
|
|
private readonly IDeviceAggregationService _deviceAggregationService;
|
|
public DeviceAggregationController(IDeviceAggregationService deviceAggregationService)
|
|
{
|
|
_deviceAggregationService = deviceAggregationService;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 创建设备信息
|
|
/// </summary>
|
|
/// <param name="input"></param>
|
|
/// <returns></returns>
|
|
[HttpPost(nameof(CreateAsync))]
|
|
[SwaggerOperation(summary: "创建设备信息", Tags = new[] { "AggregationDevice" })]
|
|
public async Task<bool> CreateAsync(CreateDeviceAggregationInput input)
|
|
{
|
|
return await _deviceAggregationService.CreateDeviceForApiAsync(input);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 批量创建设备信息
|
|
/// </summary>
|
|
/// <param name="input"></param>
|
|
/// <returns></returns>
|
|
[HttpPost(nameof(BatchCreateAsync))]
|
|
[SwaggerOperation(summary: "批量创建设备信息", Tags = new[] { "AggregationDevice" })]
|
|
public async Task<bool> BatchCreateAsync(BatchCreateDeviceAggregationInput input)
|
|
{
|
|
return await _deviceAggregationService.BatchCreateDeviceForApiAsync(input);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 删除设备信息
|
|
/// </summary>
|
|
[HttpPost(nameof(DeleteAsync))]
|
|
[SwaggerOperation(summary: "删除设备信息", Tags = new[] { "AggregationDevice" })]
|
|
public async Task<bool> DeleteAsync(IdInput input)
|
|
{
|
|
return await _deviceAggregationService.DeleteAsync(input);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 根据设备ID查询设备信息
|
|
/// </summary>
|
|
[HttpPost(nameof(FindByIdAsync))]
|
|
[SwaggerOperation(summary: "根据设备ID查询设备信息", Tags = new[] { "AggregationDevice" })]
|
|
public async Task<DeviceManagementInfoDto> FindByIdAsync(IdInput input)
|
|
{
|
|
return await _deviceAggregationService.FindByIdAsync(input);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 重新推送设备信息到物联网平台
|
|
/// </summary>
|
|
/// <param name="input"></param>
|
|
/// <returns></returns>
|
|
[HttpPost(nameof(RepushDeviceInfoToIoTPlatform))]
|
|
[SwaggerOperation(summary: "重新推送设备信息到物联网平台", Tags = new[] { "AggregationDevice" })]
|
|
public Task<DeviceManagementInfoDto> RepushDeviceInfoToIoTPlatform(IdInput input)
|
|
{
|
|
return _deviceAggregationService.RepushDeviceInfoToIoTPlatform(input);
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 发送设备指令信息
|
|
/// </summary>
|
|
/// <param name="input"></param>
|
|
/// <returns></returns>
|
|
[HttpPost(nameof(DeviceCommandForApiAsync))]
|
|
[SwaggerOperation(summary: "发送设备指令信息", Tags = new[] { "AggregationDevice" })]
|
|
public Task<bool> DeviceCommandForApiAsync(DeviceCommandForApiInput input)
|
|
{
|
|
return _deviceAggregationService.DeviceCommandForApiAsync(input);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取设备属性最新值
|
|
/// </summary>
|
|
/// <param name="input"></param>
|
|
/// <returns></returns>
|
|
[HttpPost(nameof(GetDevicePropertyValueForApiAsync))]
|
|
[SwaggerOperation(summary: "获取设备属性最新值", Tags = new[] { "AggregationDevice" })]
|
|
public Task<Dictionary<string, object>> GetDevicePropertyValueForApiAsync(DevicePropertyValueForApiInput input)
|
|
{
|
|
return _deviceAggregationService.GetDevicePropertyValueForApiAsync(input);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 发送设备升级指令信息
|
|
/// </summary>
|
|
/// <param name="input"></param>
|
|
/// <returns></returns>
|
|
[HttpPost(nameof(DeviceUpgradeForApiAsync))]
|
|
[SwaggerOperation(summary: "发送设备升级指令信息", Tags = new[] { "AggregationDevice" })]
|
|
public Task<bool> DeviceUpgradeForApiAsync(DeviceUpgradeForApiInput input)
|
|
{
|
|
return _deviceAggregationService.DeviceUpgradeForApiAsync(input);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 批量发送设备升级指令信息
|
|
/// </summary>
|
|
/// <param name="input"></param>
|
|
/// <returns></returns>
|
|
[HttpPost(nameof(DeviceBatchUpgradeForApiAsync))]
|
|
[SwaggerOperation(summary: "批量发送设备升级指令信息", Tags = new[] { "AggregationDevice" })]
|
|
public Task<bool> DeviceBatchUpgradeForApiAsync(DeviceBatchUpgradeForApiInput input)
|
|
{
|
|
return _deviceAggregationService.DeviceBatchUpgradeForApiAsync(input);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 下载设备固件文件
|
|
/// </summary>
|
|
/// <param name="input"></param>
|
|
/// <returns></returns>
|
|
[HttpPost("DownloadFirmware")]
|
|
[HttpGet("DownloadFirmware")]
|
|
[SwaggerOperation(summary: "下载设备固件文件", Tags = new[] { "AggregationDevice" })]
|
|
[AllowAnonymous]
|
|
public Task<RemoteStreamContent> DownloadFirmwareInfoAsync(IdInput input)
|
|
{
|
|
return _deviceAggregationService.DownloadFirmwareInfoAsync(input);
|
|
}
|
|
|
|
}
|
|
}
|