REM:
1. 区域信息统计排除异常状态的设备
This commit is contained in:
HuangXin 2020-09-24 09:57:19 +08:00
parent 2e93985685
commit 2a8ca2e0b7
1 changed files with 9 additions and 6 deletions

View File

@ -1,6 +1,7 @@
package com.dispose.service.impl; package com.dispose.service.impl;
import com.dispose.common.DisposeCapacityType; import com.dispose.common.DisposeCapacityType;
import com.dispose.common.ObjectStatus;
import com.dispose.pojo.entity.DisposeCapacity; import com.dispose.pojo.entity.DisposeCapacity;
import com.dispose.pojo.entity.DisposeDevice; import com.dispose.pojo.entity.DisposeDevice;
import com.dispose.service.AreaCodeManagerService; import com.dispose.service.AreaCodeManagerService;
@ -44,7 +45,9 @@ public class AreaCodeManagerServiceImpl implements AreaCodeManagerService {
@Override @Override
public Map<Integer, List<DisposeDevice>> getAreaCodeGroup() { public Map<Integer, List<DisposeDevice>> getAreaCodeGroup() {
List<DisposeDevice> disposeDevices = disposeDeviceManagerService.getAllDisposeDevice(); List<DisposeDevice> disposeDevices = disposeDeviceManagerService.getAllDisposeDevice();
return disposeDevices.stream().collect(Collectors.groupingBy(DisposeDevice::getAreaCode)); return disposeDevices.stream()
.filter(k -> k.getStatus() == ObjectStatus.NORMAL)
.collect(Collectors.groupingBy(DisposeDevice::getAreaCode));
} }
/** /**
@ -57,7 +60,7 @@ public class AreaCodeManagerServiceImpl implements AreaCodeManagerService {
public int getAreaCodeGroupReserveNetflow(Integer areaCode) { public int getAreaCodeGroupReserveNetflow(Integer areaCode) {
List<DisposeDevice> disposeDevices = disposeDeviceManagerService.getAllDisposeDevice(); List<DisposeDevice> disposeDevices = disposeDeviceManagerService.getAllDisposeDevice();
return disposeDevices.stream() return disposeDevices.stream()
.filter(v -> v.getAreaCode().equals(areaCode)) .filter(v -> v.getAreaCode().equals(areaCode) && v.getStatus() == ObjectStatus.NORMAL)
.mapToInt(v -> v.getDevCapacity().stream() .mapToInt(v -> v.getDevCapacity().stream()
.filter(k -> k.getCapacityType() == DisposeCapacityType.CLEANUP) .filter(k -> k.getCapacityType() == DisposeCapacityType.CLEANUP)
.mapToInt(m -> Optional.ofNullable(m.getReserveNetflow()).orElse(0)) .mapToInt(m -> Optional.ofNullable(m.getReserveNetflow()).orElse(0))
@ -75,7 +78,7 @@ public class AreaCodeManagerServiceImpl implements AreaCodeManagerService {
public int getAreaCodeOnlineDeviceNum(Integer areaCode) { public int getAreaCodeOnlineDeviceNum(Integer areaCode) {
List<DisposeDevice> disposeDevices = disposeDeviceManagerService.getAllDisposeDevice(); List<DisposeDevice> disposeDevices = disposeDeviceManagerService.getAllDisposeDevice();
return (int) disposeDevices.stream() return (int) disposeDevices.stream()
.filter(v -> v.getAreaCode().equals(areaCode)) .filter(v -> v.getAreaCode().equals(areaCode) && v.getStatus() == ObjectStatus.NORMAL)
.filter(k -> disposeAbilityRouterService.getAbilityDevice(k.getId()) .filter(k -> disposeAbilityRouterService.getAbilityDevice(k.getId())
.getDb() .getDb()
.getDeviceLinkStatus()) .getDeviceLinkStatus())
@ -92,8 +95,8 @@ public class AreaCodeManagerServiceImpl implements AreaCodeManagerService {
public int getAreaCodeTotalDeviceNum(Integer areaCode) { public int getAreaCodeTotalDeviceNum(Integer areaCode) {
List<DisposeDevice> disposeDevices = disposeDeviceManagerService.getAllDisposeDevice(); List<DisposeDevice> disposeDevices = disposeDeviceManagerService.getAllDisposeDevice();
return (int) disposeDevices.stream() return (int) disposeDevices.stream()
.filter(v -> v.getAreaCode().equals(areaCode)) .filter(v -> v.getAreaCode().equals(areaCode) && v.getStatus() == ObjectStatus.NORMAL)
.count(); .count();
} }
/** /**
@ -106,7 +109,7 @@ public class AreaCodeManagerServiceImpl implements AreaCodeManagerService {
public DisposeCapacityType[] getAreaCodeSupportCapacity(Integer areaCode) { public DisposeCapacityType[] getAreaCodeSupportCapacity(Integer areaCode) {
List<DisposeDevice> disposeDevices = disposeDeviceManagerService.getAllDisposeDevice(); List<DisposeDevice> disposeDevices = disposeDeviceManagerService.getAllDisposeDevice();
return disposeDevices.stream() return disposeDevices.stream()
.filter(v -> v.getAreaCode().equals(areaCode)) .filter(v -> v.getAreaCode().equals(areaCode) && v.getStatus() == ObjectStatus.NORMAL)
.flatMap(k -> k.getDevCapacity().stream() .flatMap(k -> k.getDevCapacity().stream()
.map(DisposeCapacity::getCapacityType)) .map(DisposeCapacity::getCapacityType))
.distinct() .distinct()