diff --git a/src/main/java/com/dispose/service/impl/AreaCodeManagerServiceImpl.java b/src/main/java/com/dispose/service/impl/AreaCodeManagerServiceImpl.java index dbddd7d2..d3def01b 100644 --- a/src/main/java/com/dispose/service/impl/AreaCodeManagerServiceImpl.java +++ b/src/main/java/com/dispose/service/impl/AreaCodeManagerServiceImpl.java @@ -4,6 +4,7 @@ import com.dispose.common.DisposeCapacityType; import com.dispose.common.ObjectStatus; import com.dispose.pojo.entity.DisposeCapacity; import com.dispose.pojo.entity.DisposeDevice; +import com.dispose.pojo.po.AbilityInfo; import com.dispose.service.AreaCodeManagerService; import com.dispose.service.DisposeAbilityRouterService; import com.dispose.service.DisposeDeviceManagerService; @@ -11,6 +12,7 @@ import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; import javax.annotation.Resource; +import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.Optional; @@ -46,8 +48,8 @@ public class AreaCodeManagerServiceImpl implements AreaCodeManagerService { public Map> getAreaCodeGroup() { List disposeDevices = disposeDeviceManagerService.getAllDisposeDevice(); return disposeDevices.stream() - .filter(k -> k.getStatus() == ObjectStatus.NORMAL) - .collect(Collectors.groupingBy(DisposeDevice::getAreaCode)); + .filter(k -> k.getStatus() == ObjectStatus.NORMAL) + .collect(Collectors.groupingBy(DisposeDevice::getAreaCode)); } /** @@ -60,12 +62,12 @@ public class AreaCodeManagerServiceImpl implements AreaCodeManagerService { public long getAreaCodeGroupReserveNetflow(Integer areaCode) { List disposeDevices = disposeDeviceManagerService.getAllDisposeDevice(); return disposeDevices.stream() - .filter(v -> v.getAreaCode().equals(areaCode) && v.getStatus() == ObjectStatus.NORMAL) - .mapToLong(v -> v.getDevCapacity().stream() - .filter(k -> k.getCapacityType() == DisposeCapacityType.CLEANUP) - .mapToLong(m -> Optional.ofNullable(m.getReserveNetflow()).orElse(0L)) - .sum()) - .sum(); + .filter(v -> v.getAreaCode().equals(areaCode) && v.getStatus() == ObjectStatus.NORMAL) + .mapToLong(v -> v.getDevCapacity().stream() + .filter(k -> k.getCapacityType() == DisposeCapacityType.CLEANUP) + .mapToLong(m -> Optional.ofNullable(m.getReserveNetflow()).orElse(0L)) + .sum()) + .sum(); } /** @@ -76,13 +78,20 @@ public class AreaCodeManagerServiceImpl implements AreaCodeManagerService { */ @Override public int getAreaCodeOnlineDeviceNum(Integer areaCode) { + List devs = new ArrayList<>(); List disposeDevices = disposeDeviceManagerService.getAllDisposeDevice(); - return (int) disposeDevices.stream() - .filter(v -> v.getAreaCode().equals(areaCode) && v.getStatus() == ObjectStatus.NORMAL) - .filter(k -> disposeAbilityRouterService.getAbilityDevice(k.getId()) - .getDb() - .getDeviceLinkStatus()) - .count(); + + List disDevs = disposeDevices.stream() + .filter(v -> v.getAreaCode().equals(areaCode) && v.getStatus() == ObjectStatus.NORMAL) + .collect(Collectors.toList()); + + disDevs.forEach(v -> { + if (disposeAbilityRouterService.getAbilityDevice(v.getId()) != null) { + devs.add(disposeAbilityRouterService.getAbilityDevice(v.getId())); + } + }); + + return (int) devs.stream().filter(v -> v.getDb().getDeviceLinkStatus()).count(); } /** @@ -95,8 +104,8 @@ public class AreaCodeManagerServiceImpl implements AreaCodeManagerService { public int getAreaCodeTotalDeviceNum(Integer areaCode) { List disposeDevices = disposeDeviceManagerService.getAllDisposeDevice(); return (int) disposeDevices.stream() - .filter(v -> v.getAreaCode().equals(areaCode) && v.getStatus() == ObjectStatus.NORMAL) - .count(); + .filter(v -> v.getAreaCode().equals(areaCode) && v.getStatus() == ObjectStatus.NORMAL) + .count(); } /** @@ -109,10 +118,10 @@ public class AreaCodeManagerServiceImpl implements AreaCodeManagerService { public DisposeCapacityType[] getAreaCodeSupportCapacity(Integer areaCode) { List disposeDevices = disposeDeviceManagerService.getAllDisposeDevice(); return disposeDevices.stream() - .filter(v -> v.getAreaCode().equals(areaCode) && v.getStatus() == ObjectStatus.NORMAL) - .flatMap(k -> k.getDevCapacity().stream() - .map(DisposeCapacity::getCapacityType)) - .distinct() - .toArray(DisposeCapacityType[]::new); + .filter(v -> v.getAreaCode().equals(areaCode) && v.getStatus() == ObjectStatus.NORMAL) + .flatMap(k -> k.getDevCapacity().stream() + .map(DisposeCapacity::getCapacityType)) + .distinct() + .toArray(DisposeCapacityType[]::new); } } diff --git a/src/test/java/com/dispose/test/qa/impl/JsonTestCaseRun.java b/src/test/java/com/dispose/test/qa/impl/JsonTestCaseRun.java index 2a08ef53..0804135f 100644 --- a/src/test/java/com/dispose/test/qa/impl/JsonTestCaseRun.java +++ b/src/test/java/com/dispose/test/qa/impl/JsonTestCaseRun.java @@ -104,11 +104,11 @@ public class JsonTestCaseRun extends CommonRestfulJson implements TestCaseRun { Collections.addAll(usedId, CommonEnvironment.commonIdFilter); return TestCaseRun.getAllTestCase().stream() - .filter(k -> k.getCaseJsonValue() != null && k.getCaseJsonValue().length() > 0) - .filter(k -> usedId.size() == 0 || usedId.stream().anyMatch(v -> Objects.equals(v, k.getId()))) - .filter(k -> Arrays.stream(CommonEnvironment.commonPriorityFilter).anyMatch(v -> k.getPriority() == v)) - //.filter(k -> k.getId() >= 1300) - .collect(Collectors.toList()); + .filter(k -> k.getCaseJsonValue() != null && k.getCaseJsonValue().length() > 0) + .filter(k -> usedId.size() == 0 || usedId.stream().anyMatch(v -> Objects.equals(v, k.getId()))) + .filter(k -> Arrays.stream(CommonEnvironment.commonPriorityFilter).anyMatch(v -> k.getPriority() == v)) + //.filter(k -> k.getId() == 700) + .collect(Collectors.toList()); } /** @@ -120,20 +120,19 @@ public class JsonTestCaseRun extends CommonRestfulJson implements TestCaseRun { public void runQaJsonTestCase() throws Exception { log.info("[{}] Run json test: ({}) [{}] '{}' {} ", rspObject.getPriority(), rspObject.getId(), - rspObject.getMethod(), rspObject.getUrlPath(), rspObject.getName()); + rspObject.getMethod(), rspObject.getUrlPath(), rspObject.getName()); if (rspObject.getPrepareCallback() != null) { rspObject.getPrepareCallback().prepareCallback(this); } ProtocolRespDTO o = performanceRestful(rspObject.getCaseJsonValue(), - rspObject.getUrlPath(), - rspObject.getRspClass(), - rspObject.getRspCode(), - rspObject.getAutoLogin() ? getLoginToken() : - "", - true, - rspObject.getMethod()); + rspObject.getUrlPath(), + rspObject.getRspClass(), + rspObject.getRspCode(), + rspObject.getAutoLogin() ? getLoginToken() : "", + true, + rspObject.getMethod()); Assert.assertNotNull(o);