diff --git a/src/JiShe.IoT.Application/DeviceAggregation/DeviceAggregationService.cs b/src/JiShe.IoT.Application/DeviceAggregation/DeviceAggregationService.cs index a2ffda4..9970fb4 100644 --- a/src/JiShe.IoT.Application/DeviceAggregation/DeviceAggregationService.cs +++ b/src/JiShe.IoT.Application/DeviceAggregation/DeviceAggregationService.cs @@ -301,11 +301,21 @@ namespace JiShe.IoT.DeviceAggregation { throw new UserFriendlyException($"设备不存在"); } - + + //将指令存储 + var receiveCommandInfoDto = new ReceiveCommandInfoDto() + { + DeviceAddress = deviceInfo.DeviceAddress, + Commands = input.CommandContent, + DeviceType = deviceInfo.DeviceType, + SourceType = DeviceTelemetrySourceTypeEnum.AdminSystem, + IoTPlatform = deviceInfo.IoTPlatform, + }; + //数据写入遥测任务数据存储通道 if (deviceInfo.IoTPlatform == IoTPlatformTypeEnum.OneNET) { - return await DeviceCommandInfoToOneNET(deviceInfo, input); + return await DeviceCommandInfoToOneNET(deviceInfo, receiveCommandInfoDto); } else if (deviceInfo.IoTPlatform == IoTPlatformTypeEnum.CTWing) { @@ -611,25 +621,15 @@ namespace JiShe.IoT.DeviceAggregation /// /// /// - public async Task DeviceCommandInfoToOneNET(DeviceManagementInfoDto deviceInfo, DeviceCommandForApiInput input) + public async Task DeviceCommandInfoToOneNET(DeviceManagementInfoDto deviceInfo, ReceiveCommandInfoDto input) { try - { - //将指令存储 - var receiveCommandInfoDto = new ReceiveCommandInfoDto() - { - DeviceAddress = deviceInfo.DeviceAddress, - Commands = input.CommandContent, - DeviceType = deviceInfo.DeviceType, - SourceType = DeviceTelemetrySourceTypeEnum.AdminSystem, - IoTPlatform = deviceInfo.IoTPlatform, - }; - + { //检查设备是否有配置设备端物模型信息 //如果有配置,就检查指令字典中是否有SpecialCommand标识符 //如果有就需要构建 SpecialCommand 的特别指令 - if (deviceInfo.IsNeedConfigDevicMdoel && deviceInfo.DeviceThingModelDataId.HasValue && receiveCommandInfoDto.Commands.ContainsKey(ThingModelFixedTypeConst.SpecialCommand)) + if (deviceInfo.IsNeedConfigDevicMdoel && deviceInfo.DeviceThingModelDataId.HasValue && input.Commands.ContainsKey(ThingModelFixedTypeConst.SpecialCommand)) { var propertyInfo = await oneNETProductService.GetProductThingModelSpecialCommandDataTypeListAsync(new IdInput() { Id = deviceInfo.IoTPlatformProductId }); @@ -640,12 +640,12 @@ namespace JiShe.IoT.DeviceAggregation Dictionary tempSpecialCommand = await deviceThingModelService.BuildThingModelSpecialCommandAsync(propertyInfo, deviceInfo.DeviceThingModelDataId.Value); - receiveCommandInfoDto.Commands[ThingModelFixedTypeConst.SpecialCommand] = tempSpecialCommand; + input.Commands[ThingModelFixedTypeConst.SpecialCommand] = tempSpecialCommand; } var commandRequest = new OpenApiRequest() { - Message = receiveCommandInfoDto.Serialize(), + Message = input.Serialize(), }; var packetTaskInfo = GetDeviceTelemetryPacketTaskInfo(ioTDBOptions, commandRequest, deviceInfo.Adapt(), commandRequest.Message);