From c1423d549f968a7bfeac669fe9a75c5436016713 Mon Sep 17 00:00:00 2001 From: ChenYi <296215406@outlook.com> Date: Tue, 9 Dec 2025 17:24:27 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=B3=A8=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DeviceAggregationService.cs | 34 +++++++++---------- 1 file changed, 17 insertions(+), 17 deletions(-) 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);