优化事件处理以及升级结果处理
This commit is contained in:
parent
f492dd3092
commit
cd2090d4a1
@ -729,9 +729,9 @@ namespace JiShe.IoT.DeviceAggregation
|
|||||||
SourceType = DeviceTelemetrySourceTypeEnum.AdminSystem,
|
SourceType = DeviceTelemetrySourceTypeEnum.AdminSystem,
|
||||||
DeviceAddress = item.DeviceAddress,
|
DeviceAddress = item.DeviceAddress,
|
||||||
IoTPlatform = item.IoTPlatform,
|
IoTPlatform = item.IoTPlatform,
|
||||||
Commands = new Dictionary<string, object>() {
|
Commands = new Dictionary<string, object>() {
|
||||||
{ThingModelFixedTypeConst.SpecialCommand,
|
{ThingModelFixedTypeConst.SpecialCommand,
|
||||||
""}
|
""}
|
||||||
},
|
},
|
||||||
}, platformThingModelInfos);
|
}, platformThingModelInfos);
|
||||||
}
|
}
|
||||||
@ -1113,7 +1113,7 @@ namespace JiShe.IoT.DeviceAggregation
|
|||||||
};
|
};
|
||||||
var packetTaskInfo = GetDeviceTelemetryPacketTaskInfo(ioTDBOptions, commandRequest, deviceInfo.Adapt<DeviceCacheInfos>(), input.Commands.Serialize());
|
var packetTaskInfo = GetDeviceTelemetryPacketTaskInfo(ioTDBOptions, commandRequest, deviceInfo.Adapt<DeviceCacheInfos>(), input.Commands.Serialize());
|
||||||
|
|
||||||
await ioTDBDataChannelManageService.DeviceTelemetryTaskWriterAsync(DataChannelManage.DeviceTelemetryTaskDataChannel.Writer, (DistributedMessageCenterConst.OneNETCommandIssuedEventName, packetTaskInfo));
|
await ioTDBDataChannelManageService.DeviceTelemetryTaskWriterAsync(DataChannelManage.DeviceTelemetryTaskDataChannel.Writer, (DistributedMessageCenterConst.OneNETCommandIssuedEventName, packetTaskInfo));
|
||||||
|
|
||||||
await redisPubSubService.PublishReliableAsync(DistributedMessageCenterConst.OneNETCommandIssuedEventName, packetTaskInfo);
|
await redisPubSubService.PublishReliableAsync(DistributedMessageCenterConst.OneNETCommandIssuedEventName, packetTaskInfo);
|
||||||
return true;
|
return true;
|
||||||
@ -1308,6 +1308,23 @@ namespace JiShe.IoT.DeviceAggregation
|
|||||||
throw new UserFriendlyException($"设备{deviceInfo.DeviceName}获取数据失败");
|
throw new UserFriendlyException($"设备{deviceInfo.DeviceName}获取数据失败");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//获取设备产品平台端物模型信息
|
||||||
|
var platformThingModelInfo = await platformThingModelInfoAppService.FindByPlatformProductIdAsync(new IdInput<string>() { Id = deviceInfo.IoTPlatformProductId });
|
||||||
|
if (platformThingModelInfo == null || platformThingModelInfo.Count <= 0)
|
||||||
|
{
|
||||||
|
return deviceDataResult.Data;
|
||||||
|
}
|
||||||
|
|
||||||
|
var platformUpdatePropertyInfo = platformThingModelInfo.Where(d => d.StandardFieldName.ToLowerInvariant() == ThingModelFixedTypeConst.FIRMWARE_VERSION.ToLowerInvariant()).FirstOrDefault();
|
||||||
|
//抄读结果如果有固件版本号,则更新固件版本号到设备信息中
|
||||||
|
var firmwareVersionKey = platformUpdatePropertyInfo?.IoTPlatformRawFieldName.ToLowerInvariant();
|
||||||
|
|
||||||
|
if (!string.IsNullOrWhiteSpace(firmwareVersionKey) && deviceDataResult.Data.ContainsKey(firmwareVersionKey))
|
||||||
|
{
|
||||||
|
deviceInfo.FirmwareVersion = deviceDataResult.Data[firmwareVersionKey].ToString();
|
||||||
|
await deviceAppService.UpdateDeviceFirmwareVersion(deviceInfo);
|
||||||
|
}
|
||||||
|
|
||||||
return deviceDataResult.Data;
|
return deviceDataResult.Data;
|
||||||
}
|
}
|
||||||
catch (Exception)
|
catch (Exception)
|
||||||
|
|||||||
@ -9,6 +9,7 @@ using Mapster;
|
|||||||
using Microsoft.Extensions.Caching.Memory;
|
using Microsoft.Extensions.Caching.Memory;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
|
using Polly;
|
||||||
using Volo.Abp;
|
using Volo.Abp;
|
||||||
using Volo.Abp.Auditing;
|
using Volo.Abp.Auditing;
|
||||||
|
|
||||||
@ -172,6 +173,7 @@ namespace JiShe.ServicePro.OneNETManagement.Subscribers
|
|||||||
throw new UserFriendlyException($"设备升级结果消息处理失败,参数为空");
|
throw new UserFriendlyException($"设备升级结果消息处理失败,参数为空");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var currentTime = DateTime.Now;
|
||||||
var deviceUpgradeRecordEntity = await FreeSqlDbContext.Instance.Select<DeviceUpgradeRecord>()
|
var deviceUpgradeRecordEntity = await FreeSqlDbContext.Instance.Select<DeviceUpgradeRecord>()
|
||||||
.Where(d => d.UpgradeIdentifier == input.UpgradeIdentifier && d.DeviceAddress == input.DeviceAddress)
|
.Where(d => d.UpgradeIdentifier == input.UpgradeIdentifier && d.DeviceAddress == input.DeviceAddress)
|
||||||
.FirstAsync();
|
.FirstAsync();
|
||||||
@ -186,6 +188,15 @@ namespace JiShe.ServicePro.OneNETManagement.Subscribers
|
|||||||
deviceUpgradeRecordEntity.UpgradeResult = input.ResultType;
|
deviceUpgradeRecordEntity.UpgradeResult = input.ResultType;
|
||||||
deviceUpgradeRecordEntity.UpgradeStatus = DeviceUpgradeStatusTypeEnum.UpgradeSuccess;
|
deviceUpgradeRecordEntity.UpgradeStatus = DeviceUpgradeStatusTypeEnum.UpgradeSuccess;
|
||||||
deviceUpgradeRecordEntity.UpgradeDate = TimestampHelper.ConvertToDateTime(input.ReceivedTime, TimestampUnit.Milliseconds, DateTimeKind.Local);
|
deviceUpgradeRecordEntity.UpgradeDate = TimestampHelper.ConvertToDateTime(input.ReceivedTime, TimestampUnit.Milliseconds, DateTimeKind.Local);
|
||||||
|
|
||||||
|
//更新成功后,更新设备固件版本号
|
||||||
|
await FreeSqlDbContext.Instance.Update<DeviceManagementInfo>()
|
||||||
|
.Set(d=>d.FirmwareVersion, deviceUpgradeRecordEntity.NowFirmwareVersion)
|
||||||
|
.Set(d => d.UpgradeDate, currentTime)
|
||||||
|
.Set(d => d.LastModificationTime, currentTime)
|
||||||
|
.Set(d => d.LastModifierId, CurrentUser.Id)
|
||||||
|
.Where(d=>d.DeviceAddress == deviceUpgradeRecordEntity.DeviceAddress)
|
||||||
|
.ExecuteAffrowsAsync();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user