From ee9ed1fd5016630abf5446c82bf829f427b0a8c6 Mon Sep 17 00:00:00 2001 From: root <295172551@qq.com> Date: Sat, 6 Sep 2025 11:28:53 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=90=AF=E5=8A=A8=E7=BD=91?= =?UTF-8?q?=E7=BB=9C=E5=8F=82=E6=95=B0=E5=88=A4=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ApplicationServices/DeviceRuntimeService.cs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/X1.Application/ApplicationServices/DeviceRuntimeService.cs b/src/X1.Application/ApplicationServices/DeviceRuntimeService.cs index 82ffad1..5b8643c 100644 --- a/src/X1.Application/ApplicationServices/DeviceRuntimeService.cs +++ b/src/X1.Application/ApplicationServices/DeviceRuntimeService.cs @@ -380,9 +380,9 @@ public class DeviceRuntimeService : IDeviceRuntimeCoreService try { _logger.LogInformation("开始批量启动设备运行时状态,设备数量: {DeviceCount}", deviceRequests?.Count ?? 0); - + bool checkRequestsParameter = deviceRequests != null && deviceRequests.Any() && deviceRequests.All(d => !string.IsNullOrEmpty(d.DeviceCode) && !string.IsNullOrEmpty(d.NetworkStackCode)); // 验证命令参数 - if (deviceRequests != null && deviceRequests.Any() && deviceRequests.All(d => !string.IsNullOrEmpty(d.DeviceCode) && !string.IsNullOrEmpty(d.NetworkStackCode))) + if (!checkRequestsParameter) { _logger.LogWarning("命令参数验证失败"); return OperationResult.CreateFailure("命令参数验证失败"); @@ -826,9 +826,11 @@ public class DeviceRuntimeService : IDeviceRuntimeCoreService try { + bool checkRequestsParameter = deviceCodes != null && deviceCodes.Any() && deviceCodes.All(code => !string.IsNullOrEmpty(code)); + // 验证请求参数 _logger.LogDebug("[{RequestId}] 开始验证请求参数", requestId); - if (deviceCodes != null && deviceCodes.Any() && deviceCodes.All(code => !string.IsNullOrEmpty(code))) + if (!checkRequestsParameter) { _logger.LogWarning("[{RequestId}] 请求参数验证失败", requestId); return OperationResult.CreateFailure("请求参数无效");