设备固件和升级指令封装
This commit is contained in:
parent
0b3b4a7c70
commit
68ad13af77
@ -27,5 +27,10 @@ namespace JiShe.IoT.DeviceAggregation
|
|||||||
[Required]
|
[Required]
|
||||||
public Guid NowFirmwareVersionDataId { get; set; }
|
public Guid NowFirmwareVersionDataId { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 升级描述
|
||||||
|
/// </summary>
|
||||||
|
public string UpgradeDescription { get; set; }
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -8,11 +8,13 @@ using JiShe.ServicePro.DeviceManagement.DeviceInfos.Dto;
|
|||||||
using JiShe.ServicePro.DeviceManagement.Permissions;
|
using JiShe.ServicePro.DeviceManagement.Permissions;
|
||||||
using JiShe.ServicePro.DeviceManagement.ThingModels;
|
using JiShe.ServicePro.DeviceManagement.ThingModels;
|
||||||
using JiShe.ServicePro.Dto;
|
using JiShe.ServicePro.Dto;
|
||||||
|
using JiShe.ServicePro.Encrypt;
|
||||||
using JiShe.ServicePro.Enums;
|
using JiShe.ServicePro.Enums;
|
||||||
using JiShe.ServicePro.FileManagement.Files;
|
using JiShe.ServicePro.FileManagement.Files;
|
||||||
using JiShe.ServicePro.FreeRedisProvider;
|
using JiShe.ServicePro.FreeRedisProvider;
|
||||||
using JiShe.ServicePro.IoTDBManagement.DataChannels;
|
using JiShe.ServicePro.IoTDBManagement.DataChannels;
|
||||||
using JiShe.ServicePro.IoTDBManagement.TableModels;
|
using JiShe.ServicePro.IoTDBManagement.TableModels;
|
||||||
|
using JiShe.ServicePro.OneNET.Provider.OpenApiModels.Commands;
|
||||||
using JiShe.ServicePro.OneNETManagement.OneNETDevices;
|
using JiShe.ServicePro.OneNETManagement.OneNETDevices;
|
||||||
using JiShe.ServicePro.OneNETManagement.OneNETProducts;
|
using JiShe.ServicePro.OneNETManagement.OneNETProducts;
|
||||||
using Mapster;
|
using Mapster;
|
||||||
@ -38,9 +40,11 @@ namespace JiShe.IoT.DeviceAggregation
|
|||||||
/// <param name="deviceFirmwareInfoService">设备固件服务</param>
|
/// <param name="deviceFirmwareInfoService">设备固件服务</param>
|
||||||
/// <param name="deviceUpgradeRecordService">设备升级记录服务</param>
|
/// <param name="deviceUpgradeRecordService">设备升级记录服务</param>
|
||||||
/// <param name="fileAppService">文件管理服务</param>
|
/// <param name="fileAppService">文件管理服务</param>
|
||||||
public class DeviceAggregationService(ILogger<DeviceAggregationService> logger, IDeviceAppService deviceAppService, IOneNETDeviceService oneNETDeviceService, IReliableRedisPubSubService redisPubSubService, IIoTDBDataChannelManageService ioTDBDataChannelManageService, IOptions<IoTDBOptions> _ioTDBOptions, IOneNETProductService oneNETProductService, IDeviceThingModelManagementAppService deviceThingModelService, IIoTPlatformThingModelInfoAppService platformThingModelInfoAppService, IDeviceFirmwareInfoService deviceFirmwareInfoService, IDeviceUpgradeRecordService deviceUpgradeRecordService,IFileAppService fileAppService) : IoTAppService, IDeviceAggregationService
|
/// <param name="_serverOptions">应用服务配置</param>
|
||||||
|
public class DeviceAggregationService(ILogger<DeviceAggregationService> logger, IDeviceAppService deviceAppService, IOneNETDeviceService oneNETDeviceService, IReliableRedisPubSubService redisPubSubService, IIoTDBDataChannelManageService ioTDBDataChannelManageService, IOptions<IoTDBOptions> _ioTDBOptions, IOptions<ServerApplicationOptions> _serverOptions, IOneNETProductService oneNETProductService, IDeviceThingModelManagementAppService deviceThingModelService, IIoTPlatformThingModelInfoAppService platformThingModelInfoAppService, IDeviceFirmwareInfoService deviceFirmwareInfoService, IDeviceUpgradeRecordService deviceUpgradeRecordService, IFileAppService fileAppService) : IoTAppService, IDeviceAggregationService
|
||||||
{
|
{
|
||||||
IoTDBOptions ioTDBOptions = _ioTDBOptions.Value;
|
IoTDBOptions ioTDBOptions = _ioTDBOptions.Value;
|
||||||
|
ServerApplicationOptions serverApplicationOptions = _serverOptions.Value;
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -354,7 +358,7 @@ namespace JiShe.IoT.DeviceAggregation
|
|||||||
var deviceInfo = await deviceAppService.FindByIdAsync(input);
|
var deviceInfo = await deviceAppService.FindByIdAsync(input);
|
||||||
if (deviceInfo == null)
|
if (deviceInfo == null)
|
||||||
{
|
{
|
||||||
throw new UserFriendlyException($"设备不存在");
|
throw new UserFriendlyException($"设备{input.Id}不存在");
|
||||||
}
|
}
|
||||||
|
|
||||||
//将指令存储
|
//将指令存储
|
||||||
@ -369,13 +373,22 @@ namespace JiShe.IoT.DeviceAggregation
|
|||||||
//固件信息
|
//固件信息
|
||||||
var deviceFirmwareVersionInfo = await deviceFirmwareInfoService.FindByIdAsync(new IdInput() { Id = input.NowFirmwareVersionDataId });
|
var deviceFirmwareVersionInfo = await deviceFirmwareInfoService.FindByIdAsync(new IdInput() { Id = input.NowFirmwareVersionDataId });
|
||||||
|
|
||||||
var fileInfo = await fileAppService.DeleteAsync(new IdInput() { Id = fileInfo.Id });
|
if (deviceFirmwareVersionInfo == null)
|
||||||
|
{
|
||||||
|
throw new UserFriendlyException($"产品Id{input.IoTPlatformProductId}的新固件信息{input.NowFirmwareVersionDataId}不存在");
|
||||||
|
}
|
||||||
|
|
||||||
|
var fileInfo = await fileAppService.GetFileAsync(new IdInput() { Id = deviceFirmwareVersionInfo.FirmwareFileId });
|
||||||
|
|
||||||
|
if (fileInfo == null)
|
||||||
|
{
|
||||||
|
throw new UserFriendlyException($"产品Id{input.IoTPlatformProductId}的新固件信息{deviceFirmwareVersionInfo.FirmwareFileName}固件文件不存在");
|
||||||
|
}
|
||||||
|
|
||||||
//数据写入遥测任务数据存储通道
|
//数据写入遥测任务数据存储通道
|
||||||
if (deviceInfo.IoTPlatform == IoTPlatformTypeEnum.OneNET)
|
if (deviceInfo.IoTPlatform == IoTPlatformTypeEnum.OneNET)
|
||||||
{
|
{
|
||||||
return await DeviceUpgradeCommandToOneNET(deviceInfo, receiveCommandInfoDto, deviceFirmwareVersionInfo);
|
return await DeviceUpgradeCommandToOneNET(deviceInfo, receiveCommandInfoDto, deviceFirmwareVersionInfo, fileInfo,input);
|
||||||
}
|
}
|
||||||
else if (deviceInfo.IoTPlatform == IoTPlatformTypeEnum.CTWing)
|
else if (deviceInfo.IoTPlatform == IoTPlatformTypeEnum.CTWing)
|
||||||
{
|
{
|
||||||
@ -822,22 +835,32 @@ namespace JiShe.IoT.DeviceAggregation
|
|||||||
/// 发送OneNET平台设备升级指令
|
/// 发送OneNET平台设备升级指令
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="deviceInfo"></param>
|
/// <param name="deviceInfo"></param>
|
||||||
/// <param name="input"></param>
|
/// <param name="taskInput">设置属性请求内容相关</param>
|
||||||
/// <param name="deviceFirmwareInfo">固件数据Id</param>
|
/// <param name="deviceFirmwareInfo">固件数据Id</param>
|
||||||
|
/// <param name="fileObject">固件文件信息</param>
|
||||||
|
/// <param name="input">入参</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
/// <exception cref="UserFriendlyException"></exception>
|
/// <exception cref="UserFriendlyException"></exception>
|
||||||
protected async Task<bool> DeviceUpgradeCommandToOneNET(DeviceManagementInfoDto deviceInfo, ReceiveCommandInfoDto input, DeviceFirmwareInfoDto deviceFirmwareInfo)
|
protected async Task<bool> DeviceUpgradeCommandToOneNET(DeviceManagementInfoDto deviceInfo, ReceiveCommandInfoDto taskInput, DeviceFirmwareInfoDto deviceFirmwareInfo, FileObjectDto fileObject, DeviceUpgradeForApiInput input)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (deviceInfo == null || deviceFirmwareInfo == null)
|
if (deviceInfo == null || deviceFirmwareInfo == null || fileObject == null)
|
||||||
{
|
{
|
||||||
throw new UserFriendlyException($"{nameof(DeviceUpgradeCommandToOneNET)}设备或固件信息不能为空");
|
throw new UserFriendlyException($"{nameof(DeviceUpgradeCommandToOneNET)}设备或固件信息不能为空");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (deviceInfo.IoTPlatformProductId != deviceFirmwareInfo.IoTPlatformProductId)
|
if ((deviceInfo.IoTPlatformProductId != deviceFirmwareInfo.IoTPlatformProductId) || (deviceInfo.IoTPlatform != deviceFirmwareInfo.IoTPlatform))
|
||||||
{
|
{
|
||||||
throw new UserFriendlyException($"设备{deviceInfo.DeviceAddress}平台产品Id固件信息中不一致");
|
throw new UserFriendlyException($"设备{deviceInfo.DeviceAddress}平台产品信息固件中不一致");
|
||||||
|
}
|
||||||
|
|
||||||
|
//获取设备对应的产品信息
|
||||||
|
var productInfo = await oneNETProductService.GetProductInfoAsync(new IdInput<string>() { Id = deviceInfo.IoTPlatformProductId });
|
||||||
|
|
||||||
|
if (productInfo == null)
|
||||||
|
{
|
||||||
|
throw new UserFriendlyException($"{nameof(DeviceUpgradeCommandToOneNET)} OneNET设备升级属性设置失败,产品Id{deviceInfo.IoTPlatformProductId}未找到对应的产品信息。");
|
||||||
}
|
}
|
||||||
|
|
||||||
//获取设备对应的平台端物模型信息,校验前端传入的属性标识集合是否存在不合法的属性标识符
|
//获取设备对应的平台端物模型信息,校验前端传入的属性标识集合是否存在不合法的属性标识符
|
||||||
@ -864,15 +887,41 @@ namespace JiShe.IoT.DeviceAggregation
|
|||||||
NowFirmwareVersion = deviceFirmwareInfo.FirmwareVersion,
|
NowFirmwareVersion = deviceFirmwareInfo.FirmwareVersion,
|
||||||
UpgradeSource = DeviceUpgradeSourceTypeEnum.AdminSystem,
|
UpgradeSource = DeviceUpgradeSourceTypeEnum.AdminSystem,
|
||||||
UpgradeIdentifier = Yitter.IdGenerator.YitIdHelper.NextId(),
|
UpgradeIdentifier = Yitter.IdGenerator.YitIdHelper.NextId(),
|
||||||
|
UpgradeDescription = input.UpgradeDescription,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
var md5HashRaw = $"{fileObject.Md5Hash}{productInfo.ProductAccesskey}{upgradeRecordInput.UpgradeIdentifier}{fileObject.FileSize}";
|
||||||
|
|
||||||
|
var upgradeRequest = new DeviceUpgradeCommandRequest()
|
||||||
|
{
|
||||||
|
Length = fileObject.FileSize,
|
||||||
|
UpgradeIdentifier = upgradeRecordInput.UpgradeIdentifier,
|
||||||
|
SignatureValue = md5HashRaw.Md5Fun(),
|
||||||
|
FirmwareUrl = $"{serverApplicationOptions.DownloadDeviceFirmwareBasicUrl}",
|
||||||
|
TimeOut = serverApplicationOptions.DownloadDeviceFirmwareTimeOut,
|
||||||
|
};
|
||||||
|
|
||||||
|
upgradeRecordInput.UpgradeMessage = upgradeRequest.Serialize();
|
||||||
|
upgradeRecordInput.FirmwareSignature = upgradeRequest.SignatureValue;
|
||||||
|
|
||||||
var insertResult = await deviceUpgradeRecordService.CreateAsync(upgradeRecordInput);
|
var insertResult = await deviceUpgradeRecordService.CreateAsync(upgradeRecordInput);
|
||||||
|
|
||||||
|
if (insertResult == null)
|
||||||
|
{
|
||||||
|
throw new UserFriendlyException($"设备{deviceInfo.DeviceAddress}升级记录失败");
|
||||||
|
}
|
||||||
|
|
||||||
|
//发送OneNET平台设备升级指令,HEX格式字符串
|
||||||
|
taskInput.Commands = new Dictionary<string, object>()
|
||||||
|
{
|
||||||
|
{ upgradeProperty.IoTPlatformRawFieldName, upgradeRecordInput.UpgradeMessage.ToHexString() }
|
||||||
|
};
|
||||||
|
|
||||||
var commandRequest = new OpenApiRequest()
|
var commandRequest = new OpenApiRequest()
|
||||||
{
|
{
|
||||||
Message = input.Serialize(),
|
Message = taskInput.Serialize(),
|
||||||
};
|
};
|
||||||
var packetTaskInfo = GetDeviceTelemetryPacketTaskInfo(ioTDBOptions, commandRequest, deviceInfo.Adapt<DeviceCacheInfos>(), input.Commands.Serialize());
|
var packetTaskInfo = GetDeviceTelemetryPacketTaskInfo(ioTDBOptions, commandRequest, deviceInfo.Adapt<DeviceCacheInfos>(), taskInput.Commands.Serialize());
|
||||||
|
|
||||||
await ioTDBDataChannelManageService.DeviceTelemetryTaskWriterAsync(DataChannelManage.DeviceTelemetryTaskDataChannel.Writer, (DistributedMessageCenterConst.OneNETCommandIssuedEventName, packetTaskInfo));
|
await ioTDBDataChannelManageService.DeviceTelemetryTaskWriterAsync(DataChannelManage.DeviceTelemetryTaskDataChannel.Writer, (DistributedMessageCenterConst.OneNETCommandIssuedEventName, packetTaskInfo));
|
||||||
|
|
||||||
|
|||||||
@ -13,7 +13,7 @@ using Volo.Abp.EntityFrameworkCore;
|
|||||||
namespace JiShe.IoT.Migrations
|
namespace JiShe.IoT.Migrations
|
||||||
{
|
{
|
||||||
[DbContext(typeof(IoTDbContext))]
|
[DbContext(typeof(IoTDbContext))]
|
||||||
[Migration("20251229083115_InitialCreate")]
|
[Migration("20251231054101_InitialCreate")]
|
||||||
partial class InitialCreate
|
partial class InitialCreate
|
||||||
{
|
{
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
@ -589,7 +589,7 @@ namespace JiShe.IoT.Migrations
|
|||||||
.HasColumnName("ExtraProperties")
|
.HasColumnName("ExtraProperties")
|
||||||
.HasComment("扩展属性,用于存储自定义字段,JSON格式");
|
.HasComment("扩展属性,用于存储自定义字段,JSON格式");
|
||||||
|
|
||||||
b.Property<Guid?>("FirmwareFileId")
|
b.Property<Guid>("FirmwareFileId")
|
||||||
.HasColumnType("char(36)")
|
.HasColumnType("char(36)")
|
||||||
.HasComment("固件文件Id");
|
.HasComment("固件文件Id");
|
||||||
|
|
||||||
@ -657,10 +657,6 @@ namespace JiShe.IoT.Migrations
|
|||||||
.HasColumnType("int")
|
.HasColumnType("int")
|
||||||
.HasComment("旧系统授权最后修改者Id");
|
.HasComment("旧系统授权最后修改者Id");
|
||||||
|
|
||||||
b.Property<Guid>("ProductDataId")
|
|
||||||
.HasColumnType("char(36)")
|
|
||||||
.HasComment("产品数据Id");
|
|
||||||
|
|
||||||
b.Property<string>("Remark")
|
b.Property<string>("Remark")
|
||||||
.HasColumnType("longtext")
|
.HasColumnType("longtext")
|
||||||
.HasComment("备注");
|
.HasComment("备注");
|
||||||
@ -841,6 +837,11 @@ namespace JiShe.IoT.Migrations
|
|||||||
.HasColumnType("longtext")
|
.HasColumnType("longtext")
|
||||||
.HasComment("备注");
|
.HasComment("备注");
|
||||||
|
|
||||||
|
b.Property<string>("SecurityKey")
|
||||||
|
.HasMaxLength(256)
|
||||||
|
.HasColumnType("varchar(256)")
|
||||||
|
.HasComment("设备接入鉴权key");
|
||||||
|
|
||||||
b.Property<Guid?>("TenantId")
|
b.Property<Guid?>("TenantId")
|
||||||
.HasColumnType("char(36)")
|
.HasColumnType("char(36)")
|
||||||
.HasColumnName("TenantId")
|
.HasColumnName("TenantId")
|
||||||
@ -899,10 +900,6 @@ namespace JiShe.IoT.Migrations
|
|||||||
.HasColumnType("varchar(50)")
|
.HasColumnType("varchar(50)")
|
||||||
.HasComment("设备地址");
|
.HasComment("设备地址");
|
||||||
|
|
||||||
b.Property<Guid>("DeviceDataId")
|
|
||||||
.HasColumnType("char(36)")
|
|
||||||
.HasComment("设备数据Id");
|
|
||||||
|
|
||||||
b.Property<string>("DeviceName")
|
b.Property<string>("DeviceName")
|
||||||
.IsRequired()
|
.IsRequired()
|
||||||
.HasMaxLength(50)
|
.HasMaxLength(50)
|
||||||
@ -915,7 +912,10 @@ namespace JiShe.IoT.Migrations
|
|||||||
.HasComment("扩展属性,用于存储自定义字段,JSON格式");
|
.HasComment("扩展属性,用于存储自定义字段,JSON格式");
|
||||||
|
|
||||||
b.Property<string>("FirmwareSignature")
|
b.Property<string>("FirmwareSignature")
|
||||||
.HasColumnType("longtext");
|
.IsRequired()
|
||||||
|
.HasMaxLength(50)
|
||||||
|
.HasColumnType("varchar(50)")
|
||||||
|
.HasComment("签名校验值");
|
||||||
|
|
||||||
b.Property<bool>("IsDeleted")
|
b.Property<bool>("IsDeleted")
|
||||||
.ValueGeneratedOnAdd()
|
.ValueGeneratedOnAdd()
|
||||||
@ -965,30 +965,41 @@ namespace JiShe.IoT.Migrations
|
|||||||
.HasComment("租户ID");
|
.HasComment("租户ID");
|
||||||
|
|
||||||
b.Property<DateTime>("UpgradeDate")
|
b.Property<DateTime>("UpgradeDate")
|
||||||
.HasColumnType("datetime(6)");
|
.HasColumnType("datetime(6)")
|
||||||
|
.HasComment("升级日期");
|
||||||
|
|
||||||
b.Property<long>("UpgradeIdentifier")
|
b.Property<long>("UpgradeIdentifier")
|
||||||
.HasColumnType("bigint");
|
.HasColumnType("bigint")
|
||||||
|
.HasComment("升级标识符号");
|
||||||
|
|
||||||
b.Property<string>("UpgradeMessage")
|
b.Property<string>("UpgradeMessage")
|
||||||
.HasColumnType("longtext");
|
.IsRequired()
|
||||||
|
.HasMaxLength(512)
|
||||||
|
.HasColumnType("varchar(512)")
|
||||||
|
.HasComment("升级信息");
|
||||||
|
|
||||||
b.Property<int?>("UpgradeResult")
|
b.Property<int?>("UpgradeResult")
|
||||||
.HasColumnType("int");
|
.HasColumnType("int")
|
||||||
|
.HasComment("升级结果");
|
||||||
|
|
||||||
b.Property<int>("UpgradeSource")
|
b.Property<int>("UpgradeSource")
|
||||||
.HasColumnType("int");
|
.HasColumnType("int")
|
||||||
|
.HasComment("升级来源");
|
||||||
|
|
||||||
b.Property<int>("UpgradeStatus")
|
b.Property<int>("UpgradeStatus")
|
||||||
.HasColumnType("int");
|
.HasColumnType("int")
|
||||||
|
.HasComment("升级状态");
|
||||||
|
|
||||||
b.HasKey("Id");
|
b.HasKey("Id");
|
||||||
|
|
||||||
b.HasIndex("CreationTime");
|
b.HasIndex("CreationTime");
|
||||||
|
|
||||||
b.HasIndex("DeviceDataId");
|
b.HasIndex("DeviceAddress");
|
||||||
|
|
||||||
b.HasIndex(new[] { "Id", "DeviceDataId", "NowFirmwareVersion", "CreationTime" }, "IX_ServiceProDeviceUpgradeRecord_IsNotUniqueKey")
|
b.HasIndex("UpgradeIdentifier")
|
||||||
|
.IsUnique();
|
||||||
|
|
||||||
|
b.HasIndex(new[] { "Id", "DeviceAddress", "UpgradeIdentifier", "NowFirmwareVersion", "CreationTime" }, "IX_ServiceProDeviceUpgradeRecord_IsNotUniqueKey")
|
||||||
.IsDescending();
|
.IsDescending();
|
||||||
|
|
||||||
b.ToTable("ServiceProDeviceUpgradeRecord", null, t =>
|
b.ToTable("ServiceProDeviceUpgradeRecord", null, t =>
|
||||||
@ -1724,6 +1735,12 @@ namespace JiShe.IoT.Migrations
|
|||||||
.HasColumnType("char(36)")
|
.HasColumnType("char(36)")
|
||||||
.HasColumnName("LastModifierId");
|
.HasColumnName("LastModifierId");
|
||||||
|
|
||||||
|
b.Property<string>("Md5Hash")
|
||||||
|
.IsRequired()
|
||||||
|
.HasMaxLength(50)
|
||||||
|
.HasColumnType("varchar(50)")
|
||||||
|
.HasComment("文件MD5");
|
||||||
|
|
||||||
b.Property<Guid?>("TenantId")
|
b.Property<Guid?>("TenantId")
|
||||||
.HasColumnType("char(36)")
|
.HasColumnType("char(36)")
|
||||||
.HasColumnName("TenantId");
|
.HasColumnName("TenantId");
|
||||||
@ -250,6 +250,8 @@ namespace JiShe.IoT.Migrations
|
|||||||
FileSize = table.Column<long>(type: "bigint", nullable: false, comment: "文件大小"),
|
FileSize = table.Column<long>(type: "bigint", nullable: false, comment: "文件大小"),
|
||||||
ContentType = table.Column<string>(type: "varchar(128)", maxLength: 128, nullable: false, comment: "文件名称")
|
ContentType = table.Column<string>(type: "varchar(128)", maxLength: 128, nullable: false, comment: "文件名称")
|
||||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||||
|
Md5Hash = table.Column<string>(type: "varchar(50)", maxLength: 50, nullable: false, comment: "文件MD5")
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||||
ExtraProperties = table.Column<string>(type: "longtext", nullable: false)
|
ExtraProperties = table.Column<string>(type: "longtext", nullable: false)
|
||||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||||
ConcurrencyStamp = table.Column<string>(type: "varchar(40)", maxLength: 40, nullable: false)
|
ConcurrencyStamp = table.Column<string>(type: "varchar(40)", maxLength: 40, nullable: false)
|
||||||
@ -879,7 +881,6 @@ namespace JiShe.IoT.Migrations
|
|||||||
columns: table => new
|
columns: table => new
|
||||||
{
|
{
|
||||||
Id = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
Id = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
||||||
ProductDataId = table.Column<Guid>(type: "char(36)", nullable: false, comment: "产品数据Id", collation: "ascii_general_ci"),
|
|
||||||
IoTPlatform = table.Column<int>(type: "int", nullable: false, comment: "物联网平台类型"),
|
IoTPlatform = table.Column<int>(type: "int", nullable: false, comment: "物联网平台类型"),
|
||||||
IoTPlatformProductId = table.Column<string>(type: "varchar(50)", maxLength: 50, nullable: false, comment: "物联网平台中对应的产品Id")
|
IoTPlatformProductId = table.Column<string>(type: "varchar(50)", maxLength: 50, nullable: false, comment: "物联网平台中对应的产品Id")
|
||||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||||
@ -887,7 +888,7 @@ namespace JiShe.IoT.Migrations
|
|||||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||||
FirmwareVersion = table.Column<string>(type: "varchar(50)", maxLength: 50, nullable: false, comment: "固件版本")
|
FirmwareVersion = table.Column<string>(type: "varchar(50)", maxLength: 50, nullable: false, comment: "固件版本")
|
||||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||||
FirmwareFileId = table.Column<Guid>(type: "char(36)", nullable: true, comment: "固件文件Id", collation: "ascii_general_ci"),
|
FirmwareFileId = table.Column<Guid>(type: "char(36)", nullable: false, comment: "固件文件Id", collation: "ascii_general_ci"),
|
||||||
FirmwareFileName = table.Column<string>(type: "varchar(256)", maxLength: 256, nullable: false, comment: "固件文件名称")
|
FirmwareFileName = table.Column<string>(type: "varchar(256)", maxLength: 256, nullable: false, comment: "固件文件名称")
|
||||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||||
FirmwareHashCode = table.Column<string>(type: "longtext", nullable: true)
|
FirmwareHashCode = table.Column<string>(type: "longtext", nullable: true)
|
||||||
@ -954,6 +955,8 @@ namespace JiShe.IoT.Migrations
|
|||||||
FirmwareVersion = table.Column<string>(type: "varchar(50)", maxLength: 50, nullable: true, comment: "固件版本")
|
FirmwareVersion = table.Column<string>(type: "varchar(50)", maxLength: 50, nullable: true, comment: "固件版本")
|
||||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||||
UpgradeDate = table.Column<DateTime>(type: "datetime(6)", nullable: true, comment: "升级日期"),
|
UpgradeDate = table.Column<DateTime>(type: "datetime(6)", nullable: true, comment: "升级日期"),
|
||||||
|
SecurityKey = table.Column<string>(type: "varchar(256)", maxLength: 256, nullable: true, comment: "设备接入鉴权key")
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||||
ConcurrencyStamp = table.Column<string>(type: "varchar(40)", maxLength: 40, nullable: false)
|
ConcurrencyStamp = table.Column<string>(type: "varchar(40)", maxLength: 40, nullable: false)
|
||||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||||
CreationTime = table.Column<DateTime>(type: "datetime(6)", nullable: false),
|
CreationTime = table.Column<DateTime>(type: "datetime(6)", nullable: false),
|
||||||
@ -1117,7 +1120,6 @@ namespace JiShe.IoT.Migrations
|
|||||||
columns: table => new
|
columns: table => new
|
||||||
{
|
{
|
||||||
Id = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
Id = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
||||||
DeviceDataId = table.Column<Guid>(type: "char(36)", nullable: false, comment: "设备数据Id", collation: "ascii_general_ci"),
|
|
||||||
DeviceName = table.Column<string>(type: "varchar(50)", maxLength: 50, nullable: false, comment: "设备名称")
|
DeviceName = table.Column<string>(type: "varchar(50)", maxLength: 50, nullable: false, comment: "设备名称")
|
||||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||||
DeviceAddress = table.Column<string>(type: "varchar(50)", maxLength: 50, nullable: false, comment: "设备地址")
|
DeviceAddress = table.Column<string>(type: "varchar(50)", maxLength: 50, nullable: false, comment: "设备地址")
|
||||||
@ -1126,15 +1128,15 @@ namespace JiShe.IoT.Migrations
|
|||||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||||
NowFirmwareVersion = table.Column<string>(type: "varchar(50)", maxLength: 50, nullable: false, comment: "当前固件版本")
|
NowFirmwareVersion = table.Column<string>(type: "varchar(50)", maxLength: 50, nullable: false, comment: "当前固件版本")
|
||||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||||
UpgradeDate = table.Column<DateTime>(type: "datetime(6)", nullable: false),
|
UpgradeDate = table.Column<DateTime>(type: "datetime(6)", nullable: false, comment: "升级日期"),
|
||||||
UpgradeSource = table.Column<int>(type: "int", nullable: false),
|
UpgradeSource = table.Column<int>(type: "int", nullable: false, comment: "升级来源"),
|
||||||
UpgradeMessage = table.Column<string>(type: "longtext", nullable: true)
|
UpgradeMessage = table.Column<string>(type: "varchar(512)", maxLength: 512, nullable: false, comment: "升级信息")
|
||||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||||
UpgradeStatus = table.Column<int>(type: "int", nullable: false),
|
UpgradeStatus = table.Column<int>(type: "int", nullable: false, comment: "升级状态"),
|
||||||
UpgradeIdentifier = table.Column<long>(type: "bigint", nullable: false),
|
UpgradeIdentifier = table.Column<long>(type: "bigint", nullable: false, comment: "升级标识符号"),
|
||||||
FirmwareSignature = table.Column<string>(type: "longtext", nullable: true)
|
FirmwareSignature = table.Column<string>(type: "varchar(50)", maxLength: 50, nullable: false, comment: "签名校验值")
|
||||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||||
UpgradeResult = table.Column<int>(type: "int", nullable: true),
|
UpgradeResult = table.Column<int>(type: "int", nullable: true, comment: "升级结果"),
|
||||||
ConcurrencyStamp = table.Column<string>(type: "varchar(40)", maxLength: 40, nullable: false)
|
ConcurrencyStamp = table.Column<string>(type: "varchar(40)", maxLength: 40, nullable: false)
|
||||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||||
CreationTime = table.Column<DateTime>(type: "datetime(6)", nullable: false),
|
CreationTime = table.Column<DateTime>(type: "datetime(6)", nullable: false),
|
||||||
@ -2104,16 +2106,22 @@ namespace JiShe.IoT.Migrations
|
|||||||
column: "CreationTime");
|
column: "CreationTime");
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
migrationBuilder.CreateIndex(
|
||||||
name: "IX_ServiceProDeviceUpgradeRecord_DeviceDataId",
|
name: "IX_ServiceProDeviceUpgradeRecord_DeviceAddress",
|
||||||
table: "ServiceProDeviceUpgradeRecord",
|
table: "ServiceProDeviceUpgradeRecord",
|
||||||
column: "DeviceDataId");
|
column: "DeviceAddress");
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
migrationBuilder.CreateIndex(
|
||||||
name: "IX_ServiceProDeviceUpgradeRecord_IsNotUniqueKey",
|
name: "IX_ServiceProDeviceUpgradeRecord_IsNotUniqueKey",
|
||||||
table: "ServiceProDeviceUpgradeRecord",
|
table: "ServiceProDeviceUpgradeRecord",
|
||||||
columns: new[] { "Id", "DeviceDataId", "NowFirmwareVersion", "CreationTime" },
|
columns: new[] { "Id", "DeviceAddress", "UpgradeIdentifier", "NowFirmwareVersion", "CreationTime" },
|
||||||
descending: new bool[0]);
|
descending: new bool[0]);
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_ServiceProDeviceUpgradeRecord_UpgradeIdentifier",
|
||||||
|
table: "ServiceProDeviceUpgradeRecord",
|
||||||
|
column: "UpgradeIdentifier",
|
||||||
|
unique: true);
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
migrationBuilder.CreateIndex(
|
||||||
name: "IX_ServiceProIoTPlatformThingModelInfo_CreationTime",
|
name: "IX_ServiceProIoTPlatformThingModelInfo_CreationTime",
|
||||||
table: "ServiceProIoTPlatformThingModelInfo",
|
table: "ServiceProIoTPlatformThingModelInfo",
|
||||||
4145
src/JiShe.IoT.EntityFrameworkCore/Migrations/20251231074453_update20251231.Designer.cs
generated
Normal file
4145
src/JiShe.IoT.EntityFrameworkCore/Migrations/20251231074453_update20251231.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,32 @@
|
|||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace JiShe.IoT.Migrations
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
public partial class update20251231 : Migration
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.AddColumn<string>(
|
||||||
|
name: "UpgradeDescription",
|
||||||
|
table: "ServiceProDeviceUpgradeRecord",
|
||||||
|
type: "varchar(512)",
|
||||||
|
maxLength: 512,
|
||||||
|
nullable: false,
|
||||||
|
defaultValue: "",
|
||||||
|
comment: "升级描述")
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "UpgradeDescription",
|
||||||
|
table: "ServiceProDeviceUpgradeRecord");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -586,7 +586,7 @@ namespace JiShe.IoT.Migrations
|
|||||||
.HasColumnName("ExtraProperties")
|
.HasColumnName("ExtraProperties")
|
||||||
.HasComment("扩展属性,用于存储自定义字段,JSON格式");
|
.HasComment("扩展属性,用于存储自定义字段,JSON格式");
|
||||||
|
|
||||||
b.Property<Guid?>("FirmwareFileId")
|
b.Property<Guid>("FirmwareFileId")
|
||||||
.HasColumnType("char(36)")
|
.HasColumnType("char(36)")
|
||||||
.HasComment("固件文件Id");
|
.HasComment("固件文件Id");
|
||||||
|
|
||||||
@ -654,10 +654,6 @@ namespace JiShe.IoT.Migrations
|
|||||||
.HasColumnType("int")
|
.HasColumnType("int")
|
||||||
.HasComment("旧系统授权最后修改者Id");
|
.HasComment("旧系统授权最后修改者Id");
|
||||||
|
|
||||||
b.Property<Guid>("ProductDataId")
|
|
||||||
.HasColumnType("char(36)")
|
|
||||||
.HasComment("产品数据Id");
|
|
||||||
|
|
||||||
b.Property<string>("Remark")
|
b.Property<string>("Remark")
|
||||||
.HasColumnType("longtext")
|
.HasColumnType("longtext")
|
||||||
.HasComment("备注");
|
.HasComment("备注");
|
||||||
@ -838,6 +834,11 @@ namespace JiShe.IoT.Migrations
|
|||||||
.HasColumnType("longtext")
|
.HasColumnType("longtext")
|
||||||
.HasComment("备注");
|
.HasComment("备注");
|
||||||
|
|
||||||
|
b.Property<string>("SecurityKey")
|
||||||
|
.HasMaxLength(256)
|
||||||
|
.HasColumnType("varchar(256)")
|
||||||
|
.HasComment("设备接入鉴权key");
|
||||||
|
|
||||||
b.Property<Guid?>("TenantId")
|
b.Property<Guid?>("TenantId")
|
||||||
.HasColumnType("char(36)")
|
.HasColumnType("char(36)")
|
||||||
.HasColumnName("TenantId")
|
.HasColumnName("TenantId")
|
||||||
@ -896,10 +897,6 @@ namespace JiShe.IoT.Migrations
|
|||||||
.HasColumnType("varchar(50)")
|
.HasColumnType("varchar(50)")
|
||||||
.HasComment("设备地址");
|
.HasComment("设备地址");
|
||||||
|
|
||||||
b.Property<Guid>("DeviceDataId")
|
|
||||||
.HasColumnType("char(36)")
|
|
||||||
.HasComment("设备数据Id");
|
|
||||||
|
|
||||||
b.Property<string>("DeviceName")
|
b.Property<string>("DeviceName")
|
||||||
.IsRequired()
|
.IsRequired()
|
||||||
.HasMaxLength(50)
|
.HasMaxLength(50)
|
||||||
@ -912,7 +909,10 @@ namespace JiShe.IoT.Migrations
|
|||||||
.HasComment("扩展属性,用于存储自定义字段,JSON格式");
|
.HasComment("扩展属性,用于存储自定义字段,JSON格式");
|
||||||
|
|
||||||
b.Property<string>("FirmwareSignature")
|
b.Property<string>("FirmwareSignature")
|
||||||
.HasColumnType("longtext");
|
.IsRequired()
|
||||||
|
.HasMaxLength(50)
|
||||||
|
.HasColumnType("varchar(50)")
|
||||||
|
.HasComment("签名校验值");
|
||||||
|
|
||||||
b.Property<bool>("IsDeleted")
|
b.Property<bool>("IsDeleted")
|
||||||
.ValueGeneratedOnAdd()
|
.ValueGeneratedOnAdd()
|
||||||
@ -962,30 +962,47 @@ namespace JiShe.IoT.Migrations
|
|||||||
.HasComment("租户ID");
|
.HasComment("租户ID");
|
||||||
|
|
||||||
b.Property<DateTime>("UpgradeDate")
|
b.Property<DateTime>("UpgradeDate")
|
||||||
.HasColumnType("datetime(6)");
|
.HasColumnType("datetime(6)")
|
||||||
|
.HasComment("升级日期");
|
||||||
|
|
||||||
|
b.Property<string>("UpgradeDescription")
|
||||||
|
.IsRequired()
|
||||||
|
.HasMaxLength(512)
|
||||||
|
.HasColumnType("varchar(512)")
|
||||||
|
.HasComment("升级描述");
|
||||||
|
|
||||||
b.Property<long>("UpgradeIdentifier")
|
b.Property<long>("UpgradeIdentifier")
|
||||||
.HasColumnType("bigint");
|
.HasColumnType("bigint")
|
||||||
|
.HasComment("升级标识符号");
|
||||||
|
|
||||||
b.Property<string>("UpgradeMessage")
|
b.Property<string>("UpgradeMessage")
|
||||||
.HasColumnType("longtext");
|
.IsRequired()
|
||||||
|
.HasMaxLength(512)
|
||||||
|
.HasColumnType("varchar(512)")
|
||||||
|
.HasComment("升级信息");
|
||||||
|
|
||||||
b.Property<int?>("UpgradeResult")
|
b.Property<int?>("UpgradeResult")
|
||||||
.HasColumnType("int");
|
.HasColumnType("int")
|
||||||
|
.HasComment("升级结果");
|
||||||
|
|
||||||
b.Property<int>("UpgradeSource")
|
b.Property<int>("UpgradeSource")
|
||||||
.HasColumnType("int");
|
.HasColumnType("int")
|
||||||
|
.HasComment("升级来源");
|
||||||
|
|
||||||
b.Property<int>("UpgradeStatus")
|
b.Property<int>("UpgradeStatus")
|
||||||
.HasColumnType("int");
|
.HasColumnType("int")
|
||||||
|
.HasComment("升级状态");
|
||||||
|
|
||||||
b.HasKey("Id");
|
b.HasKey("Id");
|
||||||
|
|
||||||
b.HasIndex("CreationTime");
|
b.HasIndex("CreationTime");
|
||||||
|
|
||||||
b.HasIndex("DeviceDataId");
|
b.HasIndex("DeviceAddress");
|
||||||
|
|
||||||
b.HasIndex(new[] { "Id", "DeviceDataId", "NowFirmwareVersion", "CreationTime" }, "IX_ServiceProDeviceUpgradeRecord_IsNotUniqueKey")
|
b.HasIndex("UpgradeIdentifier")
|
||||||
|
.IsUnique();
|
||||||
|
|
||||||
|
b.HasIndex(new[] { "Id", "DeviceAddress", "UpgradeIdentifier", "NowFirmwareVersion", "CreationTime" }, "IX_ServiceProDeviceUpgradeRecord_IsNotUniqueKey")
|
||||||
.IsDescending();
|
.IsDescending();
|
||||||
|
|
||||||
b.ToTable("ServiceProDeviceUpgradeRecord", null, t =>
|
b.ToTable("ServiceProDeviceUpgradeRecord", null, t =>
|
||||||
@ -1721,6 +1738,12 @@ namespace JiShe.IoT.Migrations
|
|||||||
.HasColumnType("char(36)")
|
.HasColumnType("char(36)")
|
||||||
.HasColumnName("LastModifierId");
|
.HasColumnName("LastModifierId");
|
||||||
|
|
||||||
|
b.Property<string>("Md5Hash")
|
||||||
|
.IsRequired()
|
||||||
|
.HasMaxLength(50)
|
||||||
|
.HasColumnType("varchar(50)")
|
||||||
|
.HasComment("文件MD5");
|
||||||
|
|
||||||
b.Property<Guid?>("TenantId")
|
b.Property<Guid?>("TenantId")
|
||||||
.HasColumnType("char(36)")
|
.HasColumnType("char(36)")
|
||||||
.HasColumnName("TenantId");
|
.HasColumnName("TenantId");
|
||||||
|
|||||||
@ -3,6 +3,7 @@ using JiShe.IoT.DeviceAggregation.Dto;
|
|||||||
using JiShe.ServicePro;
|
using JiShe.ServicePro;
|
||||||
using JiShe.ServicePro.Core;
|
using JiShe.ServicePro.Core;
|
||||||
using JiShe.ServicePro.DeviceManagement.DeviceInfos;
|
using JiShe.ServicePro.DeviceManagement.DeviceInfos;
|
||||||
|
using Microsoft.AspNetCore.Authorization;
|
||||||
using Volo.Abp.Content;
|
using Volo.Abp.Content;
|
||||||
|
|
||||||
namespace JiShe.IoT.Controllers
|
namespace JiShe.IoT.Controllers
|
||||||
@ -120,6 +121,7 @@ namespace JiShe.IoT.Controllers
|
|||||||
[HttpPost("DownloadFirmware")]
|
[HttpPost("DownloadFirmware")]
|
||||||
[HttpGet("DownloadFirmware")]
|
[HttpGet("DownloadFirmware")]
|
||||||
[SwaggerOperation(summary: "下载设备固件文件", Tags = new[] { "AggregationDevice" })]
|
[SwaggerOperation(summary: "下载设备固件文件", Tags = new[] { "AggregationDevice" })]
|
||||||
|
[AllowAnonymous]
|
||||||
public Task<RemoteStreamContent> DownloadFirmwareInfoAsync(IdInput input)
|
public Task<RemoteStreamContent> DownloadFirmwareInfoAsync(IdInput input)
|
||||||
{
|
{
|
||||||
return _deviceAggregationService.DownloadFirmwareInfoAsync(input);
|
return _deviceAggregationService.DownloadFirmwareInfoAsync(input);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user