完善设备添加

This commit is contained in:
ChenYi 2025-07-30 17:19:01 +08:00
parent 1f2cd7e110
commit a75c7d34d7
5 changed files with 8 additions and 10 deletions

@ -1 +1 @@
Subproject commit 8abbb9899b01f6bc94a0d699cedc00cfbf2cbd7e Subproject commit 10b46cf5ae3d45d61e494478ea8a17ded5b60b44

View File

@ -69,7 +69,7 @@ namespace JiShe.IoT.DeviceAggregation
CreateDeviceInput createDeviceInput = input.Adapt<CreateDeviceInput>(); CreateDeviceInput createDeviceInput = input.Adapt<CreateDeviceInput>();
var productInfo = await FreeSqlDbContext.Instance.Select<OneNETProductInfos>() var productInfo = await FreeSqlDbContext.Instance.Select<OneNETProductInfos>()
.Where(e => e.IsEnabled == true && e.IoTPlatformProductId == input.IoTPlatformProductId) .Where(e => e.IoTPlatformProductId == input.IoTPlatformProductId)//此处不需要过滤产品状态,方便测试产品配置信息是否准确,避免跟车间生产搞混
.FirstAsync(); .FirstAsync();
if (productInfo == null) if (productInfo == null)
@ -113,6 +113,7 @@ namespace JiShe.IoT.DeviceAggregation
UpdateDeviceInput updateDeviceInput = insertResult.Adapt<UpdateDeviceInput>(); UpdateDeviceInput updateDeviceInput = insertResult.Adapt<UpdateDeviceInput>();
updateDeviceInput.IoTPlatformResponse = pushResult.Serialize(); updateDeviceInput.IoTPlatformResponse = pushResult.Serialize();
updateDeviceInput.IsPlatformPushSuccess = true;
var updateResult = await deviceAppService.UpdateAsync(updateDeviceInput); var updateResult = await deviceAppService.UpdateAsync(updateDeviceInput);
if (updateResult == null) if (updateResult == null)
@ -124,6 +125,7 @@ namespace JiShe.IoT.DeviceAggregation
//设备数据缓存到Redis //设备数据缓存到Redis
DeviceCacheInfos deviceCacheInfos = insertResult.Adapt<DeviceCacheInfos>(); DeviceCacheInfos deviceCacheInfos = insertResult.Adapt<DeviceCacheInfos>();
deviceCacheInfos.IoTPlatformResponse = updateDeviceInput.IoTPlatformResponse; deviceCacheInfos.IoTPlatformResponse = updateDeviceInput.IoTPlatformResponse;
RedisProvider.Instance.HSet<DeviceCacheInfos>(RedisConst.CacheAllDeviceInfoHashKey, insertResult.DeviceAddress, deviceCacheInfos); RedisProvider.Instance.HSet<DeviceCacheInfos>(RedisConst.CacheAllDeviceInfoHashKey, insertResult.DeviceAddress, deviceCacheInfos);
return true; return true;

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("20250730030313_InitialCreate")] [Migration("20250730091642_InitialCreate")]
partial class InitialCreate partial class InitialCreate
{ {
/// <inheritdoc /> /// <inheritdoc />
@ -614,9 +614,7 @@ namespace JiShe.IoT.Migrations
.HasComment("物联网平台中对应的产品Id"); .HasComment("物联网平台中对应的产品Id");
b.Property<string>("IoTPlatformResponse") b.Property<string>("IoTPlatformResponse")
.IsRequired() .HasColumnType("text")
.HasMaxLength(512)
.HasColumnType("varchar(512)")
.HasComment("物联网平台返回的响应信息"); .HasComment("物联网平台返回的响应信息");
b.Property<bool>("IsDeleted") b.Property<bool>("IsDeleted")

View File

@ -874,7 +874,7 @@ namespace JiShe.IoT.Migrations
.Annotation("MySql:CharSet", "utf8mb4"), .Annotation("MySql:CharSet", "utf8mb4"),
IoTPlatformAccountId = table.Column<string>(type: "varchar(50)", maxLength: 50, nullable: false, comment: "物联网平台中对应的账号Id") IoTPlatformAccountId = table.Column<string>(type: "varchar(50)", maxLength: 50, nullable: false, comment: "物联网平台中对应的账号Id")
.Annotation("MySql:CharSet", "utf8mb4"), .Annotation("MySql:CharSet", "utf8mb4"),
IoTPlatformResponse = table.Column<string>(type: "varchar(512)", maxLength: 512, nullable: false, comment: "物联网平台返回的响应信息") IoTPlatformResponse = table.Column<string>(type: "text", nullable: true, comment: "物联网平台返回的响应信息")
.Annotation("MySql:CharSet", "utf8mb4"), .Annotation("MySql:CharSet", "utf8mb4"),
IsPlatformPushSuccess = table.Column<bool>(type: "tinyint(1)", nullable: false), IsPlatformPushSuccess = table.Column<bool>(type: "tinyint(1)", nullable: false),
ConcurrencyStamp = table.Column<string>(type: "varchar(40)", maxLength: 40, nullable: false) ConcurrencyStamp = table.Column<string>(type: "varchar(40)", maxLength: 40, nullable: false)

View File

@ -611,9 +611,7 @@ namespace JiShe.IoT.Migrations
.HasComment("物联网平台中对应的产品Id"); .HasComment("物联网平台中对应的产品Id");
b.Property<string>("IoTPlatformResponse") b.Property<string>("IoTPlatformResponse")
.IsRequired() .HasColumnType("text")
.HasMaxLength(512)
.HasColumnType("varchar(512)")
.HasComment("物联网平台返回的响应信息"); .HasComment("物联网平台返回的响应信息");
b.Property<bool>("IsDeleted") b.Property<bool>("IsDeleted")