From 47d7a12280b02d35cd929bf49645c0228137f02a Mon Sep 17 00:00:00 2001 From: zhaoxianglong Date: Thu, 21 Mar 2024 13:18:21 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=9C=A8=E7=BA=BF=E7=8E=87?= =?UTF-8?q?=E6=89=80=E9=9C=80=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../zc/business/controller/StatusController.java | 14 ++++++++------ .../resources/mapper/business/StatusMapper.xml | 3 +++ 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/zc-business/src/main/java/com/zc/business/controller/StatusController.java b/zc-business/src/main/java/com/zc/business/controller/StatusController.java index cb1a077c..a9a310e8 100644 --- a/zc-business/src/main/java/com/zc/business/controller/StatusController.java +++ b/zc-business/src/main/java/com/zc/business/controller/StatusController.java @@ -167,7 +167,7 @@ public class StatusController extends BaseController { List lastEntry = ipMap.get(lastKey); Map> typeMap = lastEntry.stream().filter(iteam -> iteam.getType() != null).collect(Collectors.groupingBy(Status::getType)); Map> subMap=new HashMap<>(); - + Long sumUseState = 0L; for (Map.Entry> entrys : typeMap.entrySet()) { Map maps=new HashMap<>(); List groupItems = entrys.getValue(); @@ -185,9 +185,12 @@ public class StatusController extends BaseController { //离线率 maps.put("failRate",failRate); //已使用数量 - maps.put("sum",String.valueOf(groupItems.size())); + List collect = dcDeviceList.stream().filter(item -> Objects.equals(item.getDeviceType(), entrys.getKey())).map(DcDevice::getSumAll).collect(Collectors.toList()); + String useStateNum = collect.size() > 0 ? String.valueOf(collect.get(0)) : "0"; + sumUseState += Long.valueOf(useStateNum); + maps.put("sumUseState",useStateNum); //总数 - maps.put("sumUseState", String.valueOf(dcDeviceList.stream().filter(item -> Objects.equals(item.getDeviceType(), entrys.getKey())).map(DcDevice::getSumAll).collect(Collectors.toList()).get(0))); + maps.put("sum",String.valueOf(groupItems.size())); if(itemTypeMap.get(entrys.getKey())!=null) { subMap.put(itemTypeMap.get(entrys.getKey()), maps); } @@ -207,10 +210,9 @@ public class StatusController extends BaseController { //离线率 maps.put("failRate",failRate); //已使用数量 - List list = dcDeviceService.list(); - maps.put("sumUseState",String.valueOf(lastEntry.size())); + maps.put("sumUseState", String.valueOf(sumUseState)); //总数 - maps.put("sum",String.valueOf(list.size())); + maps.put("sum",String.valueOf(lastEntry.size())); subMap.put("全部设备",maps); return AjaxResult.success(subMap); diff --git a/zc-business/src/main/resources/mapper/business/StatusMapper.xml b/zc-business/src/main/resources/mapper/business/StatusMapper.xml index 94b29f40..cc5d9b16 100644 --- a/zc-business/src/main/resources/mapper/business/StatusMapper.xml +++ b/zc-business/src/main/resources/mapper/business/StatusMapper.xml @@ -103,6 +103,9 @@ AND s.device_id = #{status.deviceId} + + AND d.use_state = #{status.useState} +