Compare commits

..

2 Commits

Author SHA1 Message Date
ChenYi
efa9c6a332 完善业务系统属性值获取逻辑 2026-02-05 17:28:03 +08:00
ChenYi
076989b8f1 完善业务系统属性值获取逻辑 2026-02-05 17:27:57 +08:00
3 changed files with 32 additions and 17 deletions

View File

@ -1,7 +1,7 @@
{
"App": {
"SelfUrl": "http://localhost:44315",
"CorsOrigins": "https://*.IoT.com,http://localhost:4200,http://localhost:3100,http://localhost:80,http://10.10.90.3:4200"
"CorsOrigins": "https://*.IoT.com,http://localhost:4200,http://localhost:3100,http://localhost:80,http://10.10.10.104:4200"
},
"ConnectionStrings": {
//"Default": "Data Source=192.168.111.174;Port=13306;Database=JiSheIoTProDB386;uid=root;pwd=JiShe!aqG#5kGgh&0;charset=utf8mb4;Allow User Variables=true;AllowLoadLocalInfile=true;TreatTinyAsBoolean=false;SslMode=None;Pooling=true;"

View File

@ -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<Dictionary<string, object>>("设备不存在", -106, ResponeResultEnum.Fail);
}
var packetTaskInfo = GetDeviceTelemetryPacketTaskInfo(ioTDBOptions, input, deviceInfo.Adapt<DeviceCacheInfos>(), messageBody.Commands.Serialize());
//将指令存储IoTDB数据库和Redis发布通道
if (deviceInfo.IoTPlatform == IoTPlatformTypeEnum.OneNET)
{
@ -235,10 +234,11 @@ namespace JiShe.IoT.BusinessSystemAggregation
{
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)
{
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<Dictionary<string, object>>("获取数据失败,未匹配到具体数据模型", -108);
}
var packetTaskInfo = GetDeviceTelemetryPacketTaskInfo(ioTDBOptions, input, deviceInfo.Adapt<DeviceCacheInfos>(), commands.Serialize());
//数据写入遥测任务数据存储通道
await ioTDBDataChannelManageService.DeviceTelemetryTaskWriterAsync(DataChannelManage.DeviceTelemetryTaskDataChannel.Writer, (DistributedMessageCenterConst.OneNETCommandIssuedEventName, packetTaskInfo));
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() });
var queryResult = await DevicePropertyValueToOneNET(deviceInfo, new DevicePropertyValueForApiInput() { PropertyList = commands.Select(d => d.Key).ToList() });
if (queryResult == null || queryResult.Count <= 0)
{

View File

@ -18,9 +18,9 @@ namespace JiShe.IoT.Controllers
/// <summary>
/// 接收业务系统指令信息
/// </summary>
[HttpPost(nameof(ReceiveCommandInfoAsync))]
[HttpPost(nameof(ReceiveSetCommandInfoAsync))]
[SwaggerOperation(summary: "接收业务系统指令信息", Tags = new[] { "AggregationBusiness" })]
public async Task<HttpDataResult> ReceiveCommandInfoAsync(OpenApiRequest input)
public async Task<HttpDataResult> ReceiveSetCommandInfoAsync(OpenApiRequest input)
{
return await _businessSystemAggregationService.ReceiveSetCommandInfoAsync(input);
}
@ -44,6 +44,16 @@ namespace JiShe.IoT.Controllers
public async Task<HttpDataResult> BatchCreateDeviceInfoAsync(OpenApiRequest 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);
}
}
}