Compare commits

...

3 Commits

Author SHA1 Message Date
ChenYi
6e70b026c9 更新 2025-07-29 17:31:02 +08:00
ChenYi
62d1715c38 设备聚合服务新增平台重推接口 2025-07-29 17:30:52 +08:00
ChenYi
caf5bf0c19 完善产品OneNET产品管理 2025-07-29 14:30:48 +08:00
11 changed files with 302 additions and 92 deletions

1
.gitignore vendored
View File

@ -55,3 +55,4 @@
/test/JiShe.IoT.EntityFrameworkCore.Tests/bin/Release/net9.0 /test/JiShe.IoT.EntityFrameworkCore.Tests/bin/Release/net9.0
/test/JiShe.IoT.HttpApi.Client.ConsoleTestApp/bin/Release/net9.0 /test/JiShe.IoT.HttpApi.Client.ConsoleTestApp/bin/Release/net9.0
/test/JiShe.IoT.TestBase/bin/Release/net9.0 /test/JiShe.IoT.TestBase/bin/Release/net9.0
/host/JiShe.IoT.HttpApi.Host/UploadFile/20250729/host/abp-file-management

@ -1 +1 @@
Subproject commit 39fae252a272635ec7fd926b3e3d25b183b3fc7a Subproject commit cf3eff7465d5f3d89b4f95d372a0a7e797f4dec0

View File

@ -1,7 +1,7 @@
{ {
"App": { "App": {
"SelfUrl": "http://localhost:44315", "SelfUrl": "http://localhost:44315",
"CorsOrigins": "https://*.IoT.com,http://localhost:4200,http://localhost:3100,http://localhost:80,http://localhost" "CorsOrigins": "https://*.IoT.com,http://localhost:4200,http://localhost:3100,http://localhost:80,http://10.10.70.11:4200"
}, },
"ConnectionStrings": { "ConnectionStrings": {
"Default": "Data Source=47.110.60.222;Port=13306;Database=JiSheIoTProDB;uid=root;pwd=JiShe!aqG#5kGgh&0;charset=utf8mb4;Allow User Variables=true;AllowLoadLocalInfile=true;", "Default": "Data Source=47.110.60.222;Port=13306;Database=JiSheIoTProDB;uid=root;pwd=JiShe!aqG#5kGgh&0;charset=utf8mb4;Allow User Variables=true;AllowLoadLocalInfile=true;",

View File

@ -20,26 +20,11 @@ namespace JiShe.IoT.DeviceAggregation.Dto
[Required(ErrorMessage = "物联网平台类型不能为空")] [Required(ErrorMessage = "物联网平台类型不能为空")]
public IoTPlatformTypeEnum IoTPlatform { get; set; } public IoTPlatformTypeEnum IoTPlatform { get; set; }
/// <summary>
/// 电表密码
/// </summary>
[Required(ErrorMessage = "电表密码不能为空")]
public string PlatformPassword { get; set; }
/// <summary> /// <summary>
/// 集中器在物联网平台中对应的产品Id /// 集中器在物联网平台中对应的产品Id
/// </summary> /// </summary>
[Required(ErrorMessage = "产品Id不能为空")] [Required(ErrorMessage = "产品Id不能为空")]
public string IoTPlatformProductId { get; set; } public string IoTPlatformProductId { get; set; }
/// <summary>
/// 集中器在物联网平台中对应的设备Id或者名称
/// </summary>
public string IoTPlatformDeviceOpenInfo { get; set; }
/// <summary>
/// 物联网平台中对应的账号Id
/// </summary>
public string IoTPlatformAccountId { get; set; }
} }
} }

View File

@ -32,5 +32,14 @@ namespace JiShe.IoT.DeviceAggregation
/// <returns></returns> /// <returns></returns>
/// <exception cref="UserFriendlyException"></exception> /// <exception cref="UserFriendlyException"></exception>
Task<DeviceManagementInfoDto> FindByIdAsync(IdInput input); Task<DeviceManagementInfoDto> FindByIdAsync(IdInput input);
/// <summary>
/// 重新推送设备信息到物联网平台
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
/// <exception cref="UserFriendlyException"></exception>
Task<DeviceManagementInfoDto> RepushDeviceInfoToIoTPlatform(IdInput input);
} }
} }

View File

@ -1,10 +1,13 @@
using JiShe.IoT.DeviceAggregation.Dto; using JiShe.IoT.DeviceAggregation.Dto;
using JiShe.IoT.OneNETAggregation.Dto; using JiShe.IoT.OneNETAggregation.Dto;
using JiShe.ServicePro;
using JiShe.ServicePro.Core; using JiShe.ServicePro.Core;
using JiShe.ServicePro.DeviceManagement.DeviceInfos; using JiShe.ServicePro.DeviceManagement.DeviceInfos;
using JiShe.ServicePro.DeviceManagement.DeviceInfos.Dto; using JiShe.ServicePro.DeviceManagement.DeviceInfos.Dto;
using JiShe.ServicePro.DeviceManagement.Permissions; using JiShe.ServicePro.DeviceManagement.Permissions;
using JiShe.ServicePro.FreeRedisProvider;
using JiShe.ServicePro.OneNETManagement.OneNETDevices; using JiShe.ServicePro.OneNETManagement.OneNETDevices;
using JiShe.ServicePro.OneNETManagement.OneNETProducts;
using Mapster; using Mapster;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using System; using System;
@ -32,11 +35,60 @@ namespace JiShe.IoT.DeviceAggregation
[Authorize(DeviceManagementPermissions.DeviceInfoManagement.Create)] [Authorize(DeviceManagementPermissions.DeviceInfoManagement.Create)]
public async Task<bool> CreateAsync(CreateDeviceAggregationInput input) public async Task<bool> CreateAsync(CreateDeviceAggregationInput input)
{ {
try
{
if (input.IoTPlatform == ServicePro.Enums.IoTPlatformTypeEnum.CTWing)
{
return await CTWingDeviceCreateAsync(input);
}
else if (input.IoTPlatform == ServicePro.Enums.IoTPlatformTypeEnum.OneNET)
{
return await OneNETDeviceCreateAsync(input);
}
throw new UserFriendlyException($"不支持的物联网平台");
}
catch (Exception)
{
throw;
}
}
/// <summary>
/// OneNET设备创建
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
public async Task<bool> OneNETDeviceCreateAsync(CreateDeviceAggregationInput input)
{
try try
{ {
CreateDeviceInput createDeviceInput = input.Adapt<CreateDeviceInput>(); CreateDeviceInput createDeviceInput = input.Adapt<CreateDeviceInput>();
var productInfo = await FreeSqlDbContext.Instance.Select<OneNETProductInfos>()
.Where(e => e.IsEnabled == true && e.IoTPlatformProductId == input.IoTPlatformProductId)
.FirstAsync();
if (productInfo == null)
{
throw new UserFriendlyException($"创建设备失败,未找到对应的产品配置信息。");
}
//检查设备信息是不是已经存在
var existsDeviceInfo = await deviceAppService.FindDeviceInfosAsync(input.DeviceAddress, createDeviceInput.IoTPlatform);
if (existsDeviceInfo != null)
{
throw new UserFriendlyException($"创建设备失败,当前平台设备信息已经存在。");
}
createDeviceInput.DeviceName = input.DeviceAddress;
createDeviceInput.IoTPlatformAccountId = productInfo.OneNETAccountId;
createDeviceInput.IoTPlatformDeviceOpenInfo = $"{input.IoTPlatformProductId}{input.DeviceAddress}";
createDeviceInput.PlatformPassword = productInfo.ProductAccesskey;
var insertResult = await deviceAppService.CreateAsync(createDeviceInput); var insertResult = await deviceAppService.CreateAsync(createDeviceInput);
if (insertResult == null) if (insertResult == null)
{ {
@ -47,9 +99,9 @@ namespace JiShe.IoT.DeviceAggregation
//推送至OneNET平台 //推送至OneNET平台
var pushResult = await oneNETDeviceService.CreateDeviceInfoAsync(new CreateDeviceInfoInput() var pushResult = await oneNETDeviceService.CreateDeviceInfoAsync(new CreateDeviceInfoInput()
{ {
DeviceName = $"{input.IoTPlatformProductId}{input.DeviceAddress}", DeviceName = createDeviceInput.IoTPlatformDeviceOpenInfo,
ProductId = input.IoTPlatformProductId, ProductId = productInfo.IoTPlatformProductId,
OneNETAccountId = input.IoTPlatformAccountId, OneNETAccountId = productInfo.OneNETAccountId,
Description = input.DeviceAddress, Description = input.DeviceAddress,
}); });
@ -69,6 +121,11 @@ namespace JiShe.IoT.DeviceAggregation
return false; return false;
} }
//设备数据缓存到Redis
DeviceCacheInfos deviceCacheInfos = insertResult.Adapt<DeviceCacheInfos>();
deviceCacheInfos.IoTPlatformResponse = updateDeviceInput.IoTPlatformResponse;
RedisProvider.Instance.HSet<DeviceCacheInfos>(RedisConst.CacheAllDeviceInfoHashKey, insertResult.DeviceAddress, deviceCacheInfos);
return true; return true;
} }
catch (Exception) catch (Exception)
@ -78,6 +135,16 @@ namespace JiShe.IoT.DeviceAggregation
} }
} }
/// <summary>
/// CTWing 设备创建
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
public async Task<bool> CTWingDeviceCreateAsync(CreateDeviceAggregationInput input)
{
throw new UserFriendlyException($"CTWing 设备创建失败,功能未实现。");
}
/// <summary> /// <summary>
/// 删除设备信息 /// 删除设备信息
/// </summary> /// </summary>
@ -101,5 +168,71 @@ namespace JiShe.IoT.DeviceAggregation
{ {
return await deviceAppService.FindByIdAsync(input); return await deviceAppService.FindByIdAsync(input);
} }
/// <summary>
/// 重新推送设备信息到物联网平台
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
/// <exception cref="UserFriendlyException"></exception>
public async Task<DeviceManagementInfoDto> RepushDeviceInfoToIoTPlatform(IdInput input)
{
try
{
var entityDevice = await FreeSqlDbContext.Instance.Select<DeviceManagementInfo>().Where(f => f.Id == input.Id).FirstAsync();
if (entityDevice == null)
{
throw new UserFriendlyException($"推送失败,未找到设备数据");
}
var productInfo = await FreeSqlDbContext.Instance.Select<OneNETProductInfos>()
.Where(e => e.IsEnabled == true && e.IoTPlatformProductId == entityDevice.IoTPlatformProductId)
.FirstAsync();
if (productInfo == null)
{
throw new UserFriendlyException($"推送失败,未找到对应的产品配置信息。");
}
//推送至OneNET平台
var pushResult = await oneNETDeviceService.CreateDeviceInfoAsync(new CreateDeviceInfoInput()
{
DeviceName = entityDevice.IoTPlatformDeviceOpenInfo,
ProductId = productInfo.IoTPlatformProductId,
OneNETAccountId = productInfo.OneNETAccountId,
Description = entityDevice.DeviceAddress,
});
if (pushResult == null || pushResult.Code != ServicePro.Enums.ResponeResultEnum.Success)
{
logger.LogError($"{nameof(CreateAsync)} 推送设备信息失败:{pushResult.Serialize()}");
throw new UserFriendlyException($"平台请求失败。");
}
UpdateDeviceInput updateDeviceInput = entityDevice.Adapt<UpdateDeviceInput>();
updateDeviceInput.IoTPlatformResponse = pushResult.Serialize();
var updateResult = await deviceAppService.UpdateAsync(updateDeviceInput);
if (updateResult == null)
{
logger.LogError($"{nameof(CreateAsync)} 更新设备信息失败:{input.Serialize()}");
throw new UserFriendlyException($"推送结果更新失败。");
}
//设备数据缓存到Redis
DeviceCacheInfos deviceCacheInfos = entityDevice.Adapt<DeviceCacheInfos>();
deviceCacheInfos.IoTPlatformResponse = updateDeviceInput.IoTPlatformResponse;
RedisProvider.Instance.HSet<DeviceCacheInfos>(RedisConst.CacheAllDeviceInfoHashKey, entityDevice.DeviceAddress, deviceCacheInfos);
return entityDevice.Adapt<DeviceManagementInfoDto>();
}
catch (Exception)
{
throw;
}
}
} }
} }

View File

@ -5,13 +5,16 @@ using JiShe.ServicePro.DeviceManagement.DeviceInfos;
using JiShe.ServicePro.DeviceManagement.DeviceInfos.Dto; using JiShe.ServicePro.DeviceManagement.DeviceInfos.Dto;
using JiShe.ServicePro.Encrypt; using JiShe.ServicePro.Encrypt;
using JiShe.ServicePro.Enums; using JiShe.ServicePro.Enums;
using JiShe.ServicePro.FreeRedisProvider;
using JiShe.ServicePro.Kafka.Consts; using JiShe.ServicePro.Kafka.Consts;
using JiShe.ServicePro.Kafka.Producer; using JiShe.ServicePro.Kafka.Producer;
using JiShe.ServicePro.OneNETManagement.OneNETDevices; using JiShe.ServicePro.OneNETManagement.OneNETDevices;
using JiShe.ServicePro.OneNETManagement.OneNETProducts; using JiShe.ServicePro.OneNETManagement.OneNETProducts;
using JiShe.ServicePro.ServerOptions; using JiShe.ServicePro.ServerOptions;
using Mapster;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options; using Microsoft.Extensions.Options;
using System.IO.Pipelines;
namespace JiShe.IoT.OneNETAggregation namespace JiShe.IoT.OneNETAggregation
{ {
@ -90,10 +93,10 @@ namespace JiShe.IoT.OneNETAggregation
}; };
//创建本地设备信息 //创建本地设备信息
await deviceAppService.CreateAsync(meterInfoEntity); var insertResult = await deviceAppService.CreateAsync(meterInfoEntity);
//推送至OneNET平台 //推送至OneNET平台
await oneNETDeviceService.CreateDeviceInfoAsync(new CreateDeviceInfoInput() var pushResult = await oneNETDeviceService.CreateDeviceInfoAsync(new CreateDeviceInfoInput()
{ {
DeviceName = productionEquipmentMessageBody.DeviceOpenInfo, DeviceName = productionEquipmentMessageBody.DeviceOpenInfo,
ProductId = productionEquipmentMessageBody.IoTPlatformProductId, ProductId = productionEquipmentMessageBody.IoTPlatformProductId,
@ -101,6 +104,28 @@ namespace JiShe.IoT.OneNETAggregation
Description = productionEquipmentMessageBody.DeviceOpenInfo, Description = productionEquipmentMessageBody.DeviceOpenInfo,
}); });
if (pushResult == null || pushResult.Code != ServicePro.Enums.ResponeResultEnum.Success)
{
logger.LogError($"{nameof(ReceiveWorkshopProductionInfoAsync)} 推送设备信息失败:{pushResult.Serialize()}");
return HttpDataResultExtensions.Failed("推送设备信息OneNET失败", -109, ResponeResultEnum.Fail);
}
UpdateDeviceInput updateDeviceInput = insertResult.Adapt<UpdateDeviceInput>();
updateDeviceInput.IoTPlatformResponse = pushResult.Serialize();
var updateResult = await deviceAppService.UpdateAsync(updateDeviceInput);
if (updateResult == null)
{
logger.LogError($"{nameof(ReceiveWorkshopProductionInfoAsync)} OneNET返回的设备信息更新失败{input.Serialize()}");
return HttpDataResultExtensions.Failed("OneNET返回的设备信息更新失败", -110, ResponeResultEnum.Fail);
}
//设备数据缓存到Redis
DeviceCacheInfos deviceCacheInfos = insertResult.Adapt<DeviceCacheInfos>();
deviceCacheInfos.IoTPlatformResponse = updateDeviceInput.IoTPlatformResponse;
RedisProvider.Instance.HSet<DeviceCacheInfos>(RedisConst.CacheAllDeviceInfoHashKey, insertResult.DeviceAddress, deviceCacheInfos);
return HttpDataResultExtensions.Failed("签名校验失败", -101, ResponeResultEnum.NotAllowed); return HttpDataResultExtensions.Failed("签名校验失败", -101, ResponeResultEnum.NotAllowed);
} }
catch (Exception ex) catch (Exception ex)

View File

@ -13,7 +13,7 @@ using Volo.Abp.EntityFrameworkCore;
namespace JiShe.IoT.Migrations namespace JiShe.IoT.Migrations
{ {
[DbContext(typeof(IoTDbContext))] [DbContext(typeof(IoTDbContext))]
[Migration("20250725092548_InitialCreate")] [Migration("20250729024912_InitialCreate")]
partial class InitialCreate partial class InitialCreate
{ {
/// <inheritdoc /> /// <inheritdoc />
@ -307,8 +307,8 @@ namespace JiShe.IoT.Migrations
.HasColumnName("LastModifierId"); .HasColumnName("LastModifierId");
b.Property<string>("MasterKey") b.Property<string>("MasterKey")
.HasMaxLength(128) .HasMaxLength(1024)
.HasColumnType("varchar(128)") .HasColumnType("varchar(1024)")
.HasComment("主密钥"); .HasComment("主密钥");
b.Property<int>("NetworkType") b.Property<int>("NetworkType")
@ -1204,8 +1204,8 @@ namespace JiShe.IoT.Migrations
b.Property<string>("AccountAccesskey") b.Property<string>("AccountAccesskey")
.IsRequired() .IsRequired()
.HasMaxLength(50) .HasMaxLength(1024)
.HasColumnType("varchar(50)") .HasColumnType("varchar(1024)")
.HasComment("账户通信密钥,平台可以重置密钥"); .HasComment("账户通信密钥,平台可以重置密钥");
b.Property<string>("AccountName") b.Property<string>("AccountName")
@ -1311,10 +1311,12 @@ namespace JiShe.IoT.Migrations
.HasColumnType("char(36)"); .HasColumnType("char(36)");
b.Property<int>("AccessProtocol") b.Property<int>("AccessProtocol")
.HasColumnType("int"); .HasColumnType("int")
.HasComment("接入协议");
b.Property<string>("Brand") b.Property<string>("Brand")
.HasColumnType("longtext"); .HasColumnType("longtext")
.HasComment("产品品牌");
b.Property<string>("CommunicationAddress") b.Property<string>("CommunicationAddress")
.HasMaxLength(256) .HasMaxLength(256)
@ -1342,7 +1344,8 @@ namespace JiShe.IoT.Migrations
.HasColumnName("CreatorId"); .HasColumnName("CreatorId");
b.Property<int>("DataProtocol") b.Property<int>("DataProtocol")
.HasColumnType("int"); .HasColumnType("int")
.HasComment("数据协议");
b.Property<Guid?>("DeleterId") b.Property<Guid?>("DeleterId")
.HasColumnType("char(36)") .HasColumnType("char(36)")
@ -1352,10 +1355,15 @@ namespace JiShe.IoT.Migrations
.HasColumnType("datetime(6)") .HasColumnType("datetime(6)")
.HasColumnName("DeletionTime"); .HasColumnName("DeletionTime");
b.Property<string>("DeviceThingModelUrl") b.Property<string>("DeviceThingModelFileId")
.HasMaxLength(50)
.HasColumnType("varchar(50)")
.HasComment("设备物模型文件Id");
b.Property<string>("DeviceThingModelFileName")
.HasMaxLength(256) .HasMaxLength(256)
.HasColumnType("varchar(256)") .HasColumnType("varchar(256)")
.HasComment("设备物模型文件管理地址"); .HasComment("设备物模型文件名称");
b.Property<string>("ExtraProperties") b.Property<string>("ExtraProperties")
.HasColumnType("longtext") .HasColumnType("longtext")
@ -1377,9 +1385,6 @@ namespace JiShe.IoT.Migrations
b.Property<bool>("IsEnabled") b.Property<bool>("IsEnabled")
.HasColumnType("tinyint(1)"); .HasColumnType("tinyint(1)");
b.Property<bool>("IsEncrypted")
.HasColumnType("tinyint(1)");
b.Property<DateTime?>("LastModificationTime") b.Property<DateTime?>("LastModificationTime")
.HasColumnType("datetime(6)") .HasColumnType("datetime(6)")
.HasColumnName("LastModificationTime"); .HasColumnName("LastModificationTime");
@ -1389,19 +1394,24 @@ namespace JiShe.IoT.Migrations
.HasColumnName("LastModifierId"); .HasColumnName("LastModifierId");
b.Property<string>("Manufacturer") b.Property<string>("Manufacturer")
.HasColumnType("longtext"); .HasColumnType("longtext")
.HasComment("产品厂商");
b.Property<string>("Model") b.Property<string>("Model")
.HasColumnType("longtext"); .HasColumnType("longtext")
.HasComment("产品型号");
b.Property<string>("Network") b.Property<string>("Network")
.HasColumnType("longtext"); .HasColumnType("longtext")
.HasComment("联网方式");
b.Property<int>("NodeType") b.Property<int>("NodeType")
.HasColumnType("int"); .HasColumnType("int")
.HasComment("节点类型");
b.Property<int>("NotActiveDeviceCount") b.Property<int>("NotActiveDeviceCount")
.HasColumnType("int"); .HasColumnType("int")
.HasComment("未激活设备数");
b.Property<int?>("OSACreatorId") b.Property<int?>("OSACreatorId")
.HasColumnType("int") .HasColumnType("int")
@ -1416,7 +1426,8 @@ namespace JiShe.IoT.Migrations
.HasComment("旧系统授权最后修改者Id"); .HasComment("旧系统授权最后修改者Id");
b.Property<int>("OfflineDeviceCount") b.Property<int>("OfflineDeviceCount")
.HasColumnType("int"); .HasColumnType("int")
.HasComment("离线设备数");
b.Property<string>("OneNETAccountId") b.Property<string>("OneNETAccountId")
.IsRequired() .IsRequired()
@ -1425,19 +1436,22 @@ namespace JiShe.IoT.Migrations
.HasComment("账户Id"); .HasComment("账户Id");
b.Property<int>("OnlineDeviceCount") b.Property<int>("OnlineDeviceCount")
.HasColumnType("int"); .HasColumnType("int")
.HasComment("在线设备总数");
b.Property<int>("OwnDeviceCount") b.Property<int>("OwnDeviceCount")
.HasColumnType("int"); .HasColumnType("int")
.HasComment("自有设备总数");
b.Property<string>("ProductAccesskey") b.Property<string>("ProductAccesskey")
.IsRequired() .IsRequired()
.HasMaxLength(128) .HasMaxLength(1024)
.HasColumnType("varchar(128)") .HasColumnType("varchar(1024)")
.HasComment("产品访问密钥"); .HasComment("产品访问密钥");
b.Property<DateTime>("ProductCreateTime") b.Property<DateTime>("ProductCreateTime")
.HasColumnType("datetime(6)"); .HasColumnType("datetime(6)")
.HasComment("产品创建时间");
b.Property<string>("ProductName") b.Property<string>("ProductName")
.HasMaxLength(128) .HasMaxLength(128)
@ -1445,14 +1459,16 @@ namespace JiShe.IoT.Migrations
.HasComment("产品名称"); .HasComment("产品名称");
b.Property<DateTime>("ProductUpdateTime") b.Property<DateTime>("ProductUpdateTime")
.HasColumnType("datetime(6)"); .HasColumnType("datetime(6)")
.HasComment("最近修改时间");
b.Property<string>("Remark") b.Property<string>("Remark")
.HasColumnType("longtext") .HasColumnType("longtext")
.HasComment("备注"); .HasComment("备注");
b.Property<int>("Status") b.Property<int>("Status")
.HasColumnType("int"); .HasColumnType("int")
.HasComment("开发状态");
b.Property<Guid?>("TenantId") b.Property<Guid?>("TenantId")
.HasColumnType("char(36)") .HasColumnType("char(36)")
@ -1463,6 +1479,9 @@ namespace JiShe.IoT.Migrations
b.HasIndex("CreationTime"); b.HasIndex("CreationTime");
b.HasIndex("IoTPlatformProductId")
.IsUnique();
b.HasIndex(new[] { "Id", "IoTPlatformProductId", "ProductName", "CreationTime" }, "IX_ServiceProOneNETProductInfo_IsNotUniqueKey") b.HasIndex(new[] { "Id", "IoTPlatformProductId", "ProductName", "CreationTime" }, "IX_ServiceProOneNETProductInfo_IsNotUniqueKey")
.IsDescending(); .IsDescending();

View File

@ -792,7 +792,7 @@ namespace JiShe.IoT.Migrations
.Annotation("MySql:CharSet", "utf8mb4"), .Annotation("MySql:CharSet", "utf8mb4"),
CommunicationAddress = table.Column<string>(type: "varchar(128)", maxLength: 128, nullable: false, comment: "通讯服务地址") CommunicationAddress = table.Column<string>(type: "varchar(128)", maxLength: 128, nullable: false, comment: "通讯服务地址")
.Annotation("MySql:CharSet", "utf8mb4"), .Annotation("MySql:CharSet", "utf8mb4"),
MasterKey = table.Column<string>(type: "varchar(128)", maxLength: 128, nullable: true, comment: "主密钥") MasterKey = table.Column<string>(type: "varchar(1024)", maxLength: 1024, nullable: true, comment: "主密钥")
.Annotation("MySql:CharSet", "utf8mb4"), .Annotation("MySql:CharSet", "utf8mb4"),
IoTPlatformProductId = table.Column<int>(type: "int", nullable: false), IoTPlatformProductId = table.Column<int>(type: "int", nullable: false),
ProductName = table.Column<string>(type: "varchar(128)", maxLength: 128, nullable: true, comment: "产品名称") ProductName = table.Column<string>(type: "varchar(128)", maxLength: 128, nullable: true, comment: "产品名称")
@ -949,7 +949,7 @@ namespace JiShe.IoT.Migrations
.Annotation("MySql:CharSet", "utf8mb4"), .Annotation("MySql:CharSet", "utf8mb4"),
PhoneNumber = table.Column<string>(type: "varchar(50)", maxLength: 50, nullable: false, comment: "手机号码") PhoneNumber = table.Column<string>(type: "varchar(50)", maxLength: 50, nullable: false, comment: "手机号码")
.Annotation("MySql:CharSet", "utf8mb4"), .Annotation("MySql:CharSet", "utf8mb4"),
AccountAccesskey = table.Column<string>(type: "varchar(50)", maxLength: 50, nullable: false, comment: "账户通信密钥,平台可以重置密钥") AccountAccesskey = table.Column<string>(type: "varchar(1024)", maxLength: 1024, nullable: false, comment: "账户通信密钥,平台可以重置密钥")
.Annotation("MySql:CharSet", "utf8mb4"), .Annotation("MySql:CharSet", "utf8mb4"),
ProductCount = table.Column<int>(type: "int", nullable: false), ProductCount = table.Column<int>(type: "int", nullable: false),
ConcurrencyStamp = table.Column<string>(type: "varchar(40)", maxLength: 40, nullable: false) ConcurrencyStamp = table.Column<string>(type: "varchar(40)", maxLength: 40, nullable: false)
@ -988,30 +988,31 @@ namespace JiShe.IoT.Migrations
.Annotation("MySql:CharSet", "utf8mb4"), .Annotation("MySql:CharSet", "utf8mb4"),
ProductName = table.Column<string>(type: "varchar(128)", maxLength: 128, nullable: true, comment: "产品名称") ProductName = table.Column<string>(type: "varchar(128)", maxLength: 128, nullable: true, comment: "产品名称")
.Annotation("MySql:CharSet", "utf8mb4"), .Annotation("MySql:CharSet", "utf8mb4"),
ProductAccesskey = table.Column<string>(type: "varchar(128)", maxLength: 128, nullable: false, comment: "产品访问密钥") ProductAccesskey = table.Column<string>(type: "varchar(1024)", maxLength: 1024, nullable: false, comment: "产品访问密钥")
.Annotation("MySql:CharSet", "utf8mb4"), .Annotation("MySql:CharSet", "utf8mb4"),
DeviceThingModelUrl = table.Column<string>(type: "varchar(256)", maxLength: 256, nullable: true, comment: "设备物模型文件管理地址") DeviceThingModelFileId = table.Column<string>(type: "varchar(50)", maxLength: 50, nullable: true, comment: "设备物模型文件Id")
.Annotation("MySql:CharSet", "utf8mb4"),
DeviceThingModelFileName = table.Column<string>(type: "varchar(256)", maxLength: 256, nullable: true, comment: "设备物模型文件名称")
.Annotation("MySql:CharSet", "utf8mb4"), .Annotation("MySql:CharSet", "utf8mb4"),
IsEncrypted = table.Column<bool>(type: "tinyint(1)", nullable: false),
IsEnabled = table.Column<bool>(type: "tinyint(1)", nullable: false), IsEnabled = table.Column<bool>(type: "tinyint(1)", nullable: false),
AccessProtocol = table.Column<int>(type: "int", nullable: false), AccessProtocol = table.Column<int>(type: "int", nullable: false, comment: "接入协议"),
DataProtocol = table.Column<int>(type: "int", nullable: false), DataProtocol = table.Column<int>(type: "int", nullable: false, comment: "数据协议"),
NodeType = table.Column<int>(type: "int", nullable: false), NodeType = table.Column<int>(type: "int", nullable: false, comment: "节点类型"),
ProductCreateTime = table.Column<DateTime>(type: "datetime(6)", nullable: false), ProductCreateTime = table.Column<DateTime>(type: "datetime(6)", nullable: false, comment: "产品创建时间"),
ProductUpdateTime = table.Column<DateTime>(type: "datetime(6)", nullable: false), ProductUpdateTime = table.Column<DateTime>(type: "datetime(6)", nullable: false, comment: "最近修改时间"),
Network = table.Column<string>(type: "longtext", nullable: true) Network = table.Column<string>(type: "longtext", nullable: true, comment: "联网方式")
.Annotation("MySql:CharSet", "utf8mb4"), .Annotation("MySql:CharSet", "utf8mb4"),
Manufacturer = table.Column<string>(type: "longtext", nullable: true) Manufacturer = table.Column<string>(type: "longtext", nullable: true, comment: "产品厂商")
.Annotation("MySql:CharSet", "utf8mb4"), .Annotation("MySql:CharSet", "utf8mb4"),
Model = table.Column<string>(type: "longtext", nullable: true) Model = table.Column<string>(type: "longtext", nullable: true, comment: "产品型号")
.Annotation("MySql:CharSet", "utf8mb4"), .Annotation("MySql:CharSet", "utf8mb4"),
Brand = table.Column<string>(type: "longtext", nullable: true) Brand = table.Column<string>(type: "longtext", nullable: true, comment: "产品品牌")
.Annotation("MySql:CharSet", "utf8mb4"), .Annotation("MySql:CharSet", "utf8mb4"),
Status = table.Column<int>(type: "int", nullable: false), Status = table.Column<int>(type: "int", nullable: false, comment: "开发状态"),
OwnDeviceCount = table.Column<int>(type: "int", nullable: false), OwnDeviceCount = table.Column<int>(type: "int", nullable: false, comment: "自有设备总数"),
OnlineDeviceCount = table.Column<int>(type: "int", nullable: false), OnlineDeviceCount = table.Column<int>(type: "int", nullable: false, comment: "在线设备总数"),
OfflineDeviceCount = table.Column<int>(type: "int", nullable: false), OfflineDeviceCount = table.Column<int>(type: "int", nullable: false, comment: "离线设备数"),
NotActiveDeviceCount = table.Column<int>(type: "int", nullable: false), NotActiveDeviceCount = table.Column<int>(type: "int", nullable: false, comment: "未激活设备数"),
CommunicationAddress = table.Column<string>(type: "varchar(256)", maxLength: 256, nullable: true, comment: "通讯服务地址") CommunicationAddress = table.Column<string>(type: "varchar(256)", maxLength: 256, nullable: true, comment: "通讯服务地址")
.Annotation("MySql:CharSet", "utf8mb4"), .Annotation("MySql:CharSet", "utf8mb4"),
CommunicationAddressTLS = table.Column<string>(type: "varchar(256)", maxLength: 256, nullable: true, comment: "TLS通讯服务地址") CommunicationAddressTLS = table.Column<string>(type: "varchar(256)", maxLength: 256, nullable: true, comment: "TLS通讯服务地址")
@ -1725,6 +1726,12 @@ namespace JiShe.IoT.Migrations
table: "ServiceProOneNETProductInfo", table: "ServiceProOneNETProductInfo",
column: "CreationTime"); column: "CreationTime");
migrationBuilder.CreateIndex(
name: "IX_ServiceProOneNETProductInfo_IoTPlatformProductId",
table: "ServiceProOneNETProductInfo",
column: "IoTPlatformProductId",
unique: true);
migrationBuilder.CreateIndex( migrationBuilder.CreateIndex(
name: "IX_ServiceProOneNETProductInfo_IsNotUniqueKey", name: "IX_ServiceProOneNETProductInfo_IsNotUniqueKey",
table: "ServiceProOneNETProductInfo", table: "ServiceProOneNETProductInfo",

View File

@ -304,8 +304,8 @@ namespace JiShe.IoT.Migrations
.HasColumnName("LastModifierId"); .HasColumnName("LastModifierId");
b.Property<string>("MasterKey") b.Property<string>("MasterKey")
.HasMaxLength(128) .HasMaxLength(1024)
.HasColumnType("varchar(128)") .HasColumnType("varchar(1024)")
.HasComment("主密钥"); .HasComment("主密钥");
b.Property<int>("NetworkType") b.Property<int>("NetworkType")
@ -1201,8 +1201,8 @@ namespace JiShe.IoT.Migrations
b.Property<string>("AccountAccesskey") b.Property<string>("AccountAccesskey")
.IsRequired() .IsRequired()
.HasMaxLength(50) .HasMaxLength(1024)
.HasColumnType("varchar(50)") .HasColumnType("varchar(1024)")
.HasComment("账户通信密钥,平台可以重置密钥"); .HasComment("账户通信密钥,平台可以重置密钥");
b.Property<string>("AccountName") b.Property<string>("AccountName")
@ -1308,10 +1308,12 @@ namespace JiShe.IoT.Migrations
.HasColumnType("char(36)"); .HasColumnType("char(36)");
b.Property<int>("AccessProtocol") b.Property<int>("AccessProtocol")
.HasColumnType("int"); .HasColumnType("int")
.HasComment("接入协议");
b.Property<string>("Brand") b.Property<string>("Brand")
.HasColumnType("longtext"); .HasColumnType("longtext")
.HasComment("产品品牌");
b.Property<string>("CommunicationAddress") b.Property<string>("CommunicationAddress")
.HasMaxLength(256) .HasMaxLength(256)
@ -1339,7 +1341,8 @@ namespace JiShe.IoT.Migrations
.HasColumnName("CreatorId"); .HasColumnName("CreatorId");
b.Property<int>("DataProtocol") b.Property<int>("DataProtocol")
.HasColumnType("int"); .HasColumnType("int")
.HasComment("数据协议");
b.Property<Guid?>("DeleterId") b.Property<Guid?>("DeleterId")
.HasColumnType("char(36)") .HasColumnType("char(36)")
@ -1349,10 +1352,15 @@ namespace JiShe.IoT.Migrations
.HasColumnType("datetime(6)") .HasColumnType("datetime(6)")
.HasColumnName("DeletionTime"); .HasColumnName("DeletionTime");
b.Property<string>("DeviceThingModelUrl") b.Property<string>("DeviceThingModelFileId")
.HasMaxLength(50)
.HasColumnType("varchar(50)")
.HasComment("设备物模型文件Id");
b.Property<string>("DeviceThingModelFileName")
.HasMaxLength(256) .HasMaxLength(256)
.HasColumnType("varchar(256)") .HasColumnType("varchar(256)")
.HasComment("设备物模型文件管理地址"); .HasComment("设备物模型文件名称");
b.Property<string>("ExtraProperties") b.Property<string>("ExtraProperties")
.HasColumnType("longtext") .HasColumnType("longtext")
@ -1374,9 +1382,6 @@ namespace JiShe.IoT.Migrations
b.Property<bool>("IsEnabled") b.Property<bool>("IsEnabled")
.HasColumnType("tinyint(1)"); .HasColumnType("tinyint(1)");
b.Property<bool>("IsEncrypted")
.HasColumnType("tinyint(1)");
b.Property<DateTime?>("LastModificationTime") b.Property<DateTime?>("LastModificationTime")
.HasColumnType("datetime(6)") .HasColumnType("datetime(6)")
.HasColumnName("LastModificationTime"); .HasColumnName("LastModificationTime");
@ -1386,19 +1391,24 @@ namespace JiShe.IoT.Migrations
.HasColumnName("LastModifierId"); .HasColumnName("LastModifierId");
b.Property<string>("Manufacturer") b.Property<string>("Manufacturer")
.HasColumnType("longtext"); .HasColumnType("longtext")
.HasComment("产品厂商");
b.Property<string>("Model") b.Property<string>("Model")
.HasColumnType("longtext"); .HasColumnType("longtext")
.HasComment("产品型号");
b.Property<string>("Network") b.Property<string>("Network")
.HasColumnType("longtext"); .HasColumnType("longtext")
.HasComment("联网方式");
b.Property<int>("NodeType") b.Property<int>("NodeType")
.HasColumnType("int"); .HasColumnType("int")
.HasComment("节点类型");
b.Property<int>("NotActiveDeviceCount") b.Property<int>("NotActiveDeviceCount")
.HasColumnType("int"); .HasColumnType("int")
.HasComment("未激活设备数");
b.Property<int?>("OSACreatorId") b.Property<int?>("OSACreatorId")
.HasColumnType("int") .HasColumnType("int")
@ -1413,7 +1423,8 @@ namespace JiShe.IoT.Migrations
.HasComment("旧系统授权最后修改者Id"); .HasComment("旧系统授权最后修改者Id");
b.Property<int>("OfflineDeviceCount") b.Property<int>("OfflineDeviceCount")
.HasColumnType("int"); .HasColumnType("int")
.HasComment("离线设备数");
b.Property<string>("OneNETAccountId") b.Property<string>("OneNETAccountId")
.IsRequired() .IsRequired()
@ -1422,19 +1433,22 @@ namespace JiShe.IoT.Migrations
.HasComment("账户Id"); .HasComment("账户Id");
b.Property<int>("OnlineDeviceCount") b.Property<int>("OnlineDeviceCount")
.HasColumnType("int"); .HasColumnType("int")
.HasComment("在线设备总数");
b.Property<int>("OwnDeviceCount") b.Property<int>("OwnDeviceCount")
.HasColumnType("int"); .HasColumnType("int")
.HasComment("自有设备总数");
b.Property<string>("ProductAccesskey") b.Property<string>("ProductAccesskey")
.IsRequired() .IsRequired()
.HasMaxLength(128) .HasMaxLength(1024)
.HasColumnType("varchar(128)") .HasColumnType("varchar(1024)")
.HasComment("产品访问密钥"); .HasComment("产品访问密钥");
b.Property<DateTime>("ProductCreateTime") b.Property<DateTime>("ProductCreateTime")
.HasColumnType("datetime(6)"); .HasColumnType("datetime(6)")
.HasComment("产品创建时间");
b.Property<string>("ProductName") b.Property<string>("ProductName")
.HasMaxLength(128) .HasMaxLength(128)
@ -1442,14 +1456,16 @@ namespace JiShe.IoT.Migrations
.HasComment("产品名称"); .HasComment("产品名称");
b.Property<DateTime>("ProductUpdateTime") b.Property<DateTime>("ProductUpdateTime")
.HasColumnType("datetime(6)"); .HasColumnType("datetime(6)")
.HasComment("最近修改时间");
b.Property<string>("Remark") b.Property<string>("Remark")
.HasColumnType("longtext") .HasColumnType("longtext")
.HasComment("备注"); .HasComment("备注");
b.Property<int>("Status") b.Property<int>("Status")
.HasColumnType("int"); .HasColumnType("int")
.HasComment("开发状态");
b.Property<Guid?>("TenantId") b.Property<Guid?>("TenantId")
.HasColumnType("char(36)") .HasColumnType("char(36)")
@ -1460,6 +1476,9 @@ namespace JiShe.IoT.Migrations
b.HasIndex("CreationTime"); b.HasIndex("CreationTime");
b.HasIndex("IoTPlatformProductId")
.IsUnique();
b.HasIndex(new[] { "Id", "IoTPlatformProductId", "ProductName", "CreationTime" }, "IX_ServiceProOneNETProductInfo_IsNotUniqueKey") b.HasIndex(new[] { "Id", "IoTPlatformProductId", "ProductName", "CreationTime" }, "IX_ServiceProOneNETProductInfo_IsNotUniqueKey")
.IsDescending(); .IsDescending();

View File

@ -48,5 +48,17 @@ namespace JiShe.IoT.Controllers
{ {
return await _deviceAggregationService.FindByIdAsync(input); return await _deviceAggregationService.FindByIdAsync(input);
} }
/// <summary>
/// 重新推送设备信息到物联网平台
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpPost("RepushDeviceInfoToIoTPlatform")]
[SwaggerOperation(summary: "重新推送设备信息到物联网平台", Tags = new[] { "AggregationDevice" })]
public Task<DeviceManagementInfoDto> RepushDeviceInfoToIoTPlatform(IdInput input)
{
return _deviceAggregationService.RepushDeviceInfoToIoTPlatform(input);
}
} }
} }