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,