From 4ce3c7dcc4dd58cd6ef1f636c2853ae1f12707d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=BE=BE=E5=AF=8C=E6=96=8C?= Date: Wed, 15 Oct 2025 23:09:55 +0800 Subject: [PATCH] =?UTF-8?q?fix=20(farm):=20=E5=BE=AE=E4=BF=A1=E7=AB=AF?= =?UTF-8?q?=E8=AE=BE=E5=A4=87=E7=BB=9F=E8=AE=A1=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - --- .../admin/wx/vo/DeviceStatisticsInfoRespVO.java | 4 ++-- .../farm/service/deviceinfo/DeviceInfoServiceImpl.java | 10 ++++------ 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/yudao-module-farm/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/wx/vo/DeviceStatisticsInfoRespVO.java b/yudao-module-farm/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/wx/vo/DeviceStatisticsInfoRespVO.java index aded790a..290b6999 100644 --- a/yudao-module-farm/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/wx/vo/DeviceStatisticsInfoRespVO.java +++ b/yudao-module-farm/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/wx/vo/DeviceStatisticsInfoRespVO.java @@ -20,8 +20,8 @@ public class DeviceStatisticsInfoRespVO { @Schema(description = "设备总数") private int totalNum; @Schema(description = "在线设备数") - private int onlineNum; + private long onlineNum; @Schema(description = "离线设备数") - private int offlineNum; + private long offlineNum; } diff --git a/yudao-module-farm/src/main/java/cn/iocoder/yudao/module/farm/service/deviceinfo/DeviceInfoServiceImpl.java b/yudao-module-farm/src/main/java/cn/iocoder/yudao/module/farm/service/deviceinfo/DeviceInfoServiceImpl.java index 5e09e791..2680adf2 100644 --- a/yudao-module-farm/src/main/java/cn/iocoder/yudao/module/farm/service/deviceinfo/DeviceInfoServiceImpl.java +++ b/yudao-module-farm/src/main/java/cn/iocoder/yudao/module/farm/service/deviceinfo/DeviceInfoServiceImpl.java @@ -395,15 +395,13 @@ public class DeviceInfoServiceImpl implements DeviceInfoService { List list = entry.getValue(); - int onlineCount = list.stream() + long onlineCount = list.stream() .filter(device -> device.getDeviceState() == 1) - .mapToInt(DeviceInfoDO::getDeviceState) - .sum(); + .collect(Collectors.counting()); - int offlineCount = list.stream() + long offlineCount = list.stream() .filter(device -> device.getDeviceState() != 1) - .mapToInt(DeviceInfoDO::getDeviceState) - .sum(); + .collect(Collectors.counting()); res.add(new DeviceStatisticsInfoRespVO(keyName,list.size(),onlineCount,offlineCount)); }