diff --git a/src/JiShe.IoT.Application/BusinessSystemAggregation/BusinessSystemAggregationService.cs b/src/JiShe.IoT.Application/BusinessSystemAggregation/BusinessSystemAggregationService.cs index dfd21b4..1e2d91e 100644 --- a/src/JiShe.IoT.Application/BusinessSystemAggregation/BusinessSystemAggregationService.cs +++ b/src/JiShe.IoT.Application/BusinessSystemAggregation/BusinessSystemAggregationService.cs @@ -20,6 +20,7 @@ using Microsoft.Extensions.Options; using System.Linq; using Volo.Abp; using Volo.Abp.Auditing; +using static FreeSql.Internal.GlobalFilter; using static Volo.Abp.Ui.LayoutHooks.LayoutHooks; namespace JiShe.IoT.BusinessSystemAggregation @@ -221,9 +222,7 @@ namespace JiShe.IoT.BusinessSystemAggregation { return HttpDataResultExtensions.Failed>("设备不存在", -106, ResponeResultEnum.Fail); } - - var packetTaskInfo = GetDeviceTelemetryPacketTaskInfo(ioTDBOptions, input, deviceInfo.Adapt(), messageBody.Commands.Serialize()); - + //将指令存储IoTDB数据库和Redis发布通道 if (deviceInfo.IoTPlatform == IoTPlatformTypeEnum.OneNET) { @@ -235,10 +234,11 @@ namespace JiShe.IoT.BusinessSystemAggregation { return HttpDataResultExtensions.Failed>($"业务系统推送指令时设备{deviceInfo.DeviceAddress}的平台端物模型信息不存在。", -107, ResponeResultEnum.Fail); } - + + Dictionary commands = new Dictionary; foreach (var item in messageBody.Commands) { - var tempPlatformThingModelInfo = platformThingModelInfo.Where(d => d.IoTPlatformRawFieldName == item.Key).FirstOrDefault(); + var tempPlatformThingModelInfo = platformThingModelInfo.Where(d => d.StandardFieldName == item.Key).FirstOrDefault(); if (tempPlatformThingModelInfo == null) { _logger.LogError($"业务系统推送指令时设备设备{deviceInfo.DeviceAddress}平台端物模型信息不存在属性标识符{item.Key}。"); @@ -260,18 +260,23 @@ namespace JiShe.IoT.BusinessSystemAggregation messageBody.Commands.RemoveAll(d => d.Key == item.Key); continue; } + + commands.Add(item.Key,item.Value); } + if (commands == null || commands.Count <= 0) + { + _logger.LogError($"业务系统推送指令时设备{deviceInfo.DeviceAddress}未匹配到具体数据模型,被禁止。"); + return HttpDataResultExtensions.Failed>("获取数据失败,未匹配到具体数据模型", -108); + } + + + var packetTaskInfo = GetDeviceTelemetryPacketTaskInfo(ioTDBOptions, input, deviceInfo.Adapt(), commands.Serialize()); + //数据写入遥测任务数据存储通道 await ioTDBDataChannelManageService.DeviceTelemetryTaskWriterAsync(DataChannelManage.DeviceTelemetryTaskDataChannel.Writer, (DistributedMessageCenterConst.OneNETCommandIssuedEventName, packetTaskInfo)); - - - if (messageBody.Commands == null || messageBody.Commands.Count <= 0) - { - return HttpDataResultExtensions.Failed>("获取数据失败,OneNET平台未返回数据", -108); - } - - var queryResult = await DevicePropertyValueToOneNET(deviceInfo, new DevicePropertyValueForApiInput() { PropertyList = messageBody.Commands.Select(d => d.Key).ToList() }); + + var queryResult = await DevicePropertyValueToOneNET(deviceInfo, new DevicePropertyValueForApiInput() { PropertyList = commands.Select(d => d.Key).ToList() }); if (queryResult == null || queryResult.Count <= 0) { diff --git a/src/JiShe.IoT.HttpApi/Controllers/BusinessSystemAggregationController.cs b/src/JiShe.IoT.HttpApi/Controllers/BusinessSystemAggregationController.cs index 1ec8f6f..863687e 100644 --- a/src/JiShe.IoT.HttpApi/Controllers/BusinessSystemAggregationController.cs +++ b/src/JiShe.IoT.HttpApi/Controllers/BusinessSystemAggregationController.cs @@ -18,9 +18,9 @@ namespace JiShe.IoT.Controllers /// /// 接收业务系统指令信息 /// - [HttpPost(nameof(ReceiveCommandInfoAsync))] + [HttpPost(nameof(ReceiveSetCommandInfoAsync))] [SwaggerOperation(summary: "接收业务系统指令信息", Tags = new[] { "AggregationBusiness" })] - public async Task ReceiveCommandInfoAsync(OpenApiRequest input) + public async Task ReceiveSetCommandInfoAsync(OpenApiRequest input) { return await _businessSystemAggregationService.ReceiveSetCommandInfoAsync(input); } @@ -44,6 +44,16 @@ namespace JiShe.IoT.Controllers public async Task BatchCreateDeviceInfoAsync(OpenApiRequest input) { return await _businessSystemAggregationService.BatchCreateDeviceInfoAsync(input); - } + } + + /// + /// 接收业务系统获取属性指令信息 + /// + [HttpPost(nameof(ReceiveGetCommandInfoAsync))] + [SwaggerOperation(summary: "接收业务系统获取属性指令信息", Tags = new[] { "AggregationBusiness" })] + public async Task ReceiveGetCommandInfoAsync(OpenApiRequest input) + { + return await _businessSystemAggregationService.ReceiveGetCommandInfoAsync(input); + } } }