From 4d99e9fbe802a3e201cc0151caeec2fcf54283c9 Mon Sep 17 00:00:00 2001
From: ChenYi <296215406@outlook.com>
Date: Sat, 28 Feb 2026 16:47:20 +0800
Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E5=96=84=E4=B8=9A=E5=8A=A1=E7=B3=BB?=
=?UTF-8?q?=E7=BB=9F=E6=95=B0=E6=8D=AE=E6=9F=A5=E8=AF=A2=E6=8E=A5=E5=8F=A3?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../Dto/BatchQueryDeviceDataInfoInput.cs | 17 +++++++++--
.../BusinessSystemAggregationService.cs | 29 +++++++++++++------
2 files changed, 35 insertions(+), 11 deletions(-)
diff --git a/src/JiShe.IoT.Application.Contracts/BusinessSystemAggregation/Dto/BatchQueryDeviceDataInfoInput.cs b/src/JiShe.IoT.Application.Contracts/BusinessSystemAggregation/Dto/BatchQueryDeviceDataInfoInput.cs
index b1f8e51..d1c08de 100644
--- a/src/JiShe.IoT.Application.Contracts/BusinessSystemAggregation/Dto/BatchQueryDeviceDataInfoInput.cs
+++ b/src/JiShe.IoT.Application.Contracts/BusinessSystemAggregation/Dto/BatchQueryDeviceDataInfoInput.cs
@@ -33,8 +33,21 @@ namespace JiShe.IoT.BusinessSystemAggregation.Dto
public DateTime EndTime { get; set; }
///
- /// 设备地址集合
+ /// 设备地址集合,items[0]为设备地址,items[1]为子设备地址
///
- public List DeviceAddresses { get; set; }
+ public List DeviceAddressList { get; set; }
+
+ public class BatchQueryDeviceInfoRequestItem
+ {
+ ///
+ /// 设备地址,
+ ///
+ public string DeviceAddress { get; set; }
+
+ ///
+ /// 子设备地址
+ ///
+ public string SubDeviceAddress { get; set; }
+ }
}
}
diff --git a/src/JiShe.IoT.Application/BusinessSystemAggregation/BusinessSystemAggregationService.cs b/src/JiShe.IoT.Application/BusinessSystemAggregation/BusinessSystemAggregationService.cs
index e10d0df..23d6136 100644
--- a/src/JiShe.IoT.Application/BusinessSystemAggregation/BusinessSystemAggregationService.cs
+++ b/src/JiShe.IoT.Application/BusinessSystemAggregation/BusinessSystemAggregationService.cs
@@ -348,18 +348,25 @@ namespace JiShe.IoT.BusinessSystemAggregation
}
var messageBody = handleResult.Data;
- if (messageBody.DeviceAddresses == null || messageBody.DeviceAddresses.Count <= 0)
+ if (messageBody.DeviceAddressList == null || messageBody.DeviceAddressList.Count <= 0)
{
return HttpDataResultExtensions.Failed>(null, "设备地址不能为空", -103);
}
+ List deviceAddressDatas = new List();
// 验证设备地址格式,防止注入攻击
- foreach (var deviceAddress in messageBody.DeviceAddresses)
+ foreach (var deviceAddressInfo in messageBody.DeviceAddressList)
{
- if (!IsValidDeviceAddress(deviceAddress))
+ if (!IsValidDeviceAddress(deviceAddressInfo.DeviceAddress))
{
- return HttpDataResultExtensions.Failed>(null, $"设备地址格式不正确: {deviceAddress}", -107);
+ return HttpDataResultExtensions.Failed>(null, $"设备地址格式不正确: {deviceAddressInfo.DeviceAddress}", -107);
}
+ deviceAddressDatas.Add(deviceAddressInfo.DeviceAddress);
+ }
+
+ if (deviceAddressDatas == null || deviceAddressDatas.Count <= 0)
+ {
+ return HttpDataResultExtensions.Failed>(null, $"没有可用的设备地址信息", -1071);
}
//执行脚本
@@ -367,7 +374,7 @@ namespace JiShe.IoT.BusinessSystemAggregation
(
LUA_SCRIPT,
new[] { RedisConst.CacheAllDeviceInfoHashKey },
- messageBody.DeviceAddresses.ToArray()
+ deviceAddressDatas.ToArray()
);
List deviceCacheInfos = new List();
@@ -390,20 +397,24 @@ namespace JiShe.IoT.BusinessSystemAggregation
}
List queryResult = new List();
- for (int i = 0; i < messageBody.DeviceAddresses.Count; i++)
+ for (int i = 0; i < messageBody.DeviceAddressList.Count; i++)
{
- var deviceAddress = messageBody.DeviceAddresses[i];
+ var deviceAddressInfo = messageBody.DeviceAddressList[i];
var deviceCacheInfo = deviceCacheInfos.Count > i ? deviceCacheInfos[i] : null;
+ logger.LogWarning($"{nameof(BatchQueryDeviceDataInfoAsync)} 业务系统批量查询设备数据,集中器地址为:{deviceAddressInfo.DeviceAddress}");
+
if (deviceCacheInfo == null)
{
- _logger.LogError($"{nameof(BatchQueryDeviceDataInfoAsync)} 业务系统批量查询设备数据,设备地址:{deviceAddress}未找到设备地址缓存信息,消息体为:{input.Serialize()}");
+ _logger.LogError($"{nameof(BatchQueryDeviceDataInfoAsync)} 业务系统批量查询设备数据,设备地址:{deviceAddressInfo.
+ DeviceAddress}未找到设备地址缓存信息,消息体为:{input.Serialize()}");
continue;
}
var pageResult = await treeModelService.OpenRequestDeviceDataInfoPageAsync(new DeviceTreeModelDataInfoInput()
{
- DeviceAddress = deviceAddress,
+ DeviceAddress = deviceAddressInfo.DeviceAddress,
+ SubDeviceAddress = deviceAddressInfo.SubDeviceAddress,
DeviceType = messageBody.DeviceType,
IoTDataType = messageBody.IoTDataType,
IsNeedPaging = false,