优化事件处理以及升级结果处理
This commit is contained in:
parent
f492dd3092
commit
cd2090d4a1
@ -1308,6 +1308,23 @@ namespace JiShe.IoT.DeviceAggregation
|
||||
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;
|
||||
}
|
||||
catch (Exception)
|
||||
|
||||
@ -9,6 +9,7 @@ using Mapster;
|
||||
using Microsoft.Extensions.Caching.Memory;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Polly;
|
||||
using Volo.Abp;
|
||||
using Volo.Abp.Auditing;
|
||||
|
||||
@ -172,6 +173,7 @@ namespace JiShe.ServicePro.OneNETManagement.Subscribers
|
||||
throw new UserFriendlyException($"设备升级结果消息处理失败,参数为空");
|
||||
}
|
||||
|
||||
var currentTime = DateTime.Now;
|
||||
var deviceUpgradeRecordEntity = await FreeSqlDbContext.Instance.Select<DeviceUpgradeRecord>()
|
||||
.Where(d => d.UpgradeIdentifier == input.UpgradeIdentifier && d.DeviceAddress == input.DeviceAddress)
|
||||
.FirstAsync();
|
||||
@ -186,6 +188,15 @@ namespace JiShe.ServicePro.OneNETManagement.Subscribers
|
||||
deviceUpgradeRecordEntity.UpgradeResult = input.ResultType;
|
||||
deviceUpgradeRecordEntity.UpgradeStatus = DeviceUpgradeStatusTypeEnum.UpgradeSuccess;
|
||||
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
|
||||
{
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user