完善业务系统属性值获取逻辑
This commit is contained in:
parent
3229ac917f
commit
076989b8f1
@ -20,6 +20,7 @@ using Microsoft.Extensions.Options;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Volo.Abp;
|
using Volo.Abp;
|
||||||
using Volo.Abp.Auditing;
|
using Volo.Abp.Auditing;
|
||||||
|
using static FreeSql.Internal.GlobalFilter;
|
||||||
using static Volo.Abp.Ui.LayoutHooks.LayoutHooks;
|
using static Volo.Abp.Ui.LayoutHooks.LayoutHooks;
|
||||||
|
|
||||||
namespace JiShe.IoT.BusinessSystemAggregation
|
namespace JiShe.IoT.BusinessSystemAggregation
|
||||||
@ -222,8 +223,6 @@ namespace JiShe.IoT.BusinessSystemAggregation
|
|||||||
return HttpDataResultExtensions.Failed<Dictionary<string, object>>("设备不存在", -106, ResponeResultEnum.Fail);
|
return HttpDataResultExtensions.Failed<Dictionary<string, object>>("设备不存在", -106, ResponeResultEnum.Fail);
|
||||||
}
|
}
|
||||||
|
|
||||||
var packetTaskInfo = GetDeviceTelemetryPacketTaskInfo(ioTDBOptions, input, deviceInfo.Adapt<DeviceCacheInfos>(), messageBody.Commands.Serialize());
|
|
||||||
|
|
||||||
//将指令存储IoTDB数据库和Redis发布通道
|
//将指令存储IoTDB数据库和Redis发布通道
|
||||||
if (deviceInfo.IoTPlatform == IoTPlatformTypeEnum.OneNET)
|
if (deviceInfo.IoTPlatform == IoTPlatformTypeEnum.OneNET)
|
||||||
{
|
{
|
||||||
@ -236,9 +235,10 @@ namespace JiShe.IoT.BusinessSystemAggregation
|
|||||||
return HttpDataResultExtensions.Failed<Dictionary<string, object>>($"业务系统推送指令时设备{deviceInfo.DeviceAddress}的平台端物模型信息不存在。", -107, ResponeResultEnum.Fail);
|
return HttpDataResultExtensions.Failed<Dictionary<string, object>>($"业务系统推送指令时设备{deviceInfo.DeviceAddress}的平台端物模型信息不存在。", -107, ResponeResultEnum.Fail);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Dictionary<string, object> commands = new Dictionary<string, object>;
|
||||||
foreach (var item in messageBody.Commands)
|
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)
|
if (tempPlatformThingModelInfo == null)
|
||||||
{
|
{
|
||||||
_logger.LogError($"业务系统推送指令时设备设备{deviceInfo.DeviceAddress}平台端物模型信息不存在属性标识符{item.Key}。");
|
_logger.LogError($"业务系统推送指令时设备设备{deviceInfo.DeviceAddress}平台端物模型信息不存在属性标识符{item.Key}。");
|
||||||
@ -260,18 +260,23 @@ namespace JiShe.IoT.BusinessSystemAggregation
|
|||||||
messageBody.Commands.RemoveAll(d => d.Key == item.Key);
|
messageBody.Commands.RemoveAll(d => d.Key == item.Key);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
commands.Add(item.Key,item.Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (commands == null || commands.Count <= 0)
|
||||||
|
{
|
||||||
|
_logger.LogError($"业务系统推送指令时设备{deviceInfo.DeviceAddress}未匹配到具体数据模型,被禁止。");
|
||||||
|
return HttpDataResultExtensions.Failed<Dictionary<string, object>>("获取数据失败,未匹配到具体数据模型", -108);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
var packetTaskInfo = GetDeviceTelemetryPacketTaskInfo(ioTDBOptions, input, deviceInfo.Adapt<DeviceCacheInfos>(), commands.Serialize());
|
||||||
|
|
||||||
//数据写入遥测任务数据存储通道
|
//数据写入遥测任务数据存储通道
|
||||||
await ioTDBDataChannelManageService.DeviceTelemetryTaskWriterAsync(DataChannelManage.DeviceTelemetryTaskDataChannel.Writer, (DistributedMessageCenterConst.OneNETCommandIssuedEventName, packetTaskInfo));
|
await ioTDBDataChannelManageService.DeviceTelemetryTaskWriterAsync(DataChannelManage.DeviceTelemetryTaskDataChannel.Writer, (DistributedMessageCenterConst.OneNETCommandIssuedEventName, packetTaskInfo));
|
||||||
|
|
||||||
|
var queryResult = await DevicePropertyValueToOneNET(deviceInfo, new DevicePropertyValueForApiInput() { PropertyList = commands.Select(d => d.Key).ToList() });
|
||||||
if (messageBody.Commands == null || messageBody.Commands.Count <= 0)
|
|
||||||
{
|
|
||||||
return HttpDataResultExtensions.Failed<Dictionary<string, object>>("获取数据失败,OneNET平台未返回数据", -108);
|
|
||||||
}
|
|
||||||
|
|
||||||
var queryResult = await DevicePropertyValueToOneNET(deviceInfo, new DevicePropertyValueForApiInput() { PropertyList = messageBody.Commands.Select(d => d.Key).ToList() });
|
|
||||||
|
|
||||||
if (queryResult == null || queryResult.Count <= 0)
|
if (queryResult == null || queryResult.Count <= 0)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -18,9 +18,9 @@ namespace JiShe.IoT.Controllers
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 接收业务系统指令信息
|
/// 接收业务系统指令信息
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[HttpPost(nameof(ReceiveCommandInfoAsync))]
|
[HttpPost(nameof(ReceiveSetCommandInfoAsync))]
|
||||||
[SwaggerOperation(summary: "接收业务系统指令信息", Tags = new[] { "AggregationBusiness" })]
|
[SwaggerOperation(summary: "接收业务系统指令信息", Tags = new[] { "AggregationBusiness" })]
|
||||||
public async Task<HttpDataResult> ReceiveCommandInfoAsync(OpenApiRequest input)
|
public async Task<HttpDataResult> ReceiveSetCommandInfoAsync(OpenApiRequest input)
|
||||||
{
|
{
|
||||||
return await _businessSystemAggregationService.ReceiveSetCommandInfoAsync(input);
|
return await _businessSystemAggregationService.ReceiveSetCommandInfoAsync(input);
|
||||||
}
|
}
|
||||||
@ -45,5 +45,15 @@ namespace JiShe.IoT.Controllers
|
|||||||
{
|
{
|
||||||
return await _businessSystemAggregationService.BatchCreateDeviceInfoAsync(input);
|
return await _businessSystemAggregationService.BatchCreateDeviceInfoAsync(input);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 接收业务系统获取属性指令信息
|
||||||
|
/// </summary>
|
||||||
|
[HttpPost(nameof(ReceiveGetCommandInfoAsync))]
|
||||||
|
[SwaggerOperation(summary: "接收业务系统获取属性指令信息", Tags = new[] { "AggregationBusiness" })]
|
||||||
|
public async Task<HttpDataResult> ReceiveGetCommandInfoAsync(OpenApiRequest input)
|
||||||
|
{
|
||||||
|
return await _businessSystemAggregationService.ReceiveGetCommandInfoAsync(input);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user