批量发送设备升级指令信息
This commit is contained in:
parent
ecfc7d0b4f
commit
69676584dc
@ -56,11 +56,11 @@ namespace JiShe.IoT.DeviceAggregation
|
||||
Task<bool> DeviceUpgradeForApiAsync(DeviceUpgradeForApiInput input);
|
||||
|
||||
/// <summary>
|
||||
/// 批量发送设备升级指令信息
|
||||
/// 批量发送设备升级指令信息,只对同一个平台下,同一个产品下的设备进行固件升级信息
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
Task<bool> DeviceBatchUpgradeForApiAsync(DeviceBatchUpgradeForApiInput input);
|
||||
Task<List<string>> DeviceBatchUpgradeForApiAsync(DeviceBatchUpgradeForApiInput input);
|
||||
|
||||
/// <summary>
|
||||
/// 下载设备固件文件
|
||||
|
||||
@ -409,11 +409,11 @@ namespace JiShe.IoT.DeviceAggregation
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 批量发送设备升级指令信息
|
||||
/// 批量发送设备升级指令信息,只对同一个平台下,同一个产品下的设备进行固件升级信息
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<bool> DeviceBatchUpgradeForApiAsync(DeviceBatchUpgradeForApiInput input)
|
||||
public async Task<List<string>> DeviceBatchUpgradeForApiAsync(DeviceBatchUpgradeForApiInput input)
|
||||
{
|
||||
try
|
||||
{
|
||||
@ -422,27 +422,38 @@ namespace JiShe.IoT.DeviceAggregation
|
||||
throw new UserFriendlyException($"{nameof(DeviceBatchUpgradeForApiAsync)} 设备批量升级时地址列表不能为空","-101");
|
||||
}
|
||||
|
||||
if (input.AddressList.Count >200)
|
||||
{
|
||||
throw new UserFriendlyException($"{nameof(DeviceBatchUpgradeForApiAsync)} 设备批量升级时地址列表数量不能超过200", "-102");
|
||||
}
|
||||
|
||||
//固件信息
|
||||
var deviceFirmwareVersionInfo = await deviceFirmwareInfoService.FindByIdAsync(new IdInput() { Id = input.NowFirmwareVersionDataId });
|
||||
|
||||
if (deviceFirmwareVersionInfo == null)
|
||||
{
|
||||
throw new UserFriendlyException($"产品Id{input.IoTPlatformProductId}的新固件信息{input.NowFirmwareVersionDataId}不存在");
|
||||
throw new UserFriendlyException($"产品Id{input.IoTPlatformProductId}的新固件信息{input.NowFirmwareVersionDataId}不存在", "-103");
|
||||
}
|
||||
|
||||
var fileInfo = await fileAppService.GetFileAsync(new IdInput() { Id = deviceFirmwareVersionInfo.FirmwareFileId });
|
||||
|
||||
if (fileInfo == null)
|
||||
{
|
||||
throw new UserFriendlyException($"产品Id{input.IoTPlatformProductId}的新固件信息{deviceFirmwareVersionInfo.FirmwareFileName}固件文件不存在");
|
||||
throw new UserFriendlyException($"产品Id{input.IoTPlatformProductId}的新固件信息{deviceFirmwareVersionInfo.FirmwareFileName}固件文件不存在", "-104");
|
||||
}
|
||||
|
||||
var deviceInfoList = await deviceAppService.FindByDeviceAddressAsync(new FindByDeviceAddressInput() { AddressList = input.AddressList ,IoTPlatform = input.IoTPlatform,IoTPlatformProductId = input.IoTPlatformProductId});
|
||||
|
||||
List<string> deviceAddress = new List<string>();//异常的设备地址集合
|
||||
|
||||
foreach (var item in input.AddressList)
|
||||
{
|
||||
var deviceInfo = await deviceAppService.FindByDeviceAddressAsync(item);
|
||||
var deviceInfo = deviceInfoList.Where(d=>d.DeviceAddress== item).FirstOrDefault();
|
||||
if (deviceInfo == null)
|
||||
{
|
||||
throw new UserFriendlyException($"{nameof(DeviceBatchUpgradeForApiAsync)} 设备{item}不存在", "-102");
|
||||
deviceAddress.Add(item);
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
//将指令存储
|
||||
@ -460,7 +471,12 @@ namespace JiShe.IoT.DeviceAggregation
|
||||
//数据写入遥测任务数据存储通道
|
||||
if (deviceInfo.IoTPlatform == IoTPlatformTypeEnum.OneNET)
|
||||
{
|
||||
return await DeviceUpgradeCommandToOneNET(deviceInfo, receiveCommandInfoDto, deviceFirmwareVersionInfo, fileInfo, deviceUpgradeRecordInput);
|
||||
var oneNETHandleResult = await DeviceUpgradeCommandToOneNET(deviceInfo, receiveCommandInfoDto, deviceFirmwareVersionInfo, fileInfo, deviceUpgradeRecordInput);
|
||||
|
||||
if (!oneNETHandleResult)
|
||||
{
|
||||
deviceAddress.Add(item);
|
||||
}
|
||||
}
|
||||
else if (deviceInfo.IoTPlatform == IoTPlatformTypeEnum.CTWing)
|
||||
{
|
||||
@ -474,7 +490,7 @@ namespace JiShe.IoT.DeviceAggregation
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
return deviceAddress;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
|
||||
@ -114,13 +114,13 @@ namespace JiShe.IoT.Controllers
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 批量发送设备升级指令信息
|
||||
/// 批量发送设备升级指令信息,只对同一个平台下,同一个产品下的设备进行固件升级信息
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost(nameof(DeviceBatchUpgradeForApiAsync))]
|
||||
[SwaggerOperation(summary: "批量发送设备升级指令信息", Tags = new[] { "AggregationDevice" })]
|
||||
public Task<bool> DeviceBatchUpgradeForApiAsync(DeviceBatchUpgradeForApiInput input)
|
||||
[SwaggerOperation(summary: "批量发送设备升级指令信息,只对同一个平台下,同一个产品下的设备进行固件升级信息", Tags = new[] { "AggregationDevice" })]
|
||||
public Task<List<string>> DeviceBatchUpgradeForApiAsync(DeviceBatchUpgradeForApiInput input)
|
||||
{
|
||||
return _deviceAggregationService.DeviceBatchUpgradeForApiAsync(input);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user