From 44cce111d54a2b198a6367491fb3a500cd31f152 Mon Sep 17 00:00:00 2001 From: HuangXin Date: Mon, 14 Sep 2020 15:38:05 +0800 Subject: [PATCH] =?UTF-8?q?OCT=20REM:=201.=20=E6=9B=B4=E6=98=AF=E8=AE=BE?= =?UTF-8?q?=E5=A4=87=E8=83=BD=E5=8A=9B=E4=BF=A1=E6=81=AF=E9=93=BE=E6=8E=A5?= =?UTF-8?q?=E7=8A=B6=E6=80=81=E6=95=B0=E6=8D=AE=E7=B1=BB=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/DisposeInfoController.java | 113 +++++++++--------- .../java/com/dispose/pojo/po/AbilityInfo.java | 2 +- .../com/dispose/task/DeviceManagerTask.java | 2 +- .../DisposeAbilityRouterServiceTest.java | 10 +- 4 files changed, 63 insertions(+), 64 deletions(-) diff --git a/src/main/java/com/dispose/controller/DisposeInfoController.java b/src/main/java/com/dispose/controller/DisposeInfoController.java index bde4a7d6..8d5c8268 100644 --- a/src/main/java/com/dispose/controller/DisposeInfoController.java +++ b/src/main/java/com/dispose/controller/DisposeInfoController.java @@ -89,20 +89,20 @@ public class DisposeInfoController { public ProtocolRespDTO getAllDisposeDeviceAreaInfo() { GetAreaInfoRsp rspInfo = GetAreaInfoRsp.builder() - .items(new ArrayList<>()) - .build(); + .items(new ArrayList<>()) + .build(); Map> groupDev = areaCodeManagerService.getAreaCodeGroup(); for (Integer areaCode : groupDev.keySet()) { AreaInfoDetail info = AreaInfoDetail.builder() - .nodeId(areaCode.toString()) - .totalNetflow(areaCodeManagerService.getAreaCodeGroupReserveNetflow(areaCode)) - .onlineDevices(areaCodeManagerService.getAreaCodeOnlineDeviceNum(areaCode)) - .capacityType(Arrays.stream(areaCodeManagerService.getAreaCodeSupportCapacity(areaCode)) - .map(DisposeCapacityType::getValue) - .toArray(Integer[]::new)) - .build(); + .nodeId(areaCode.toString()) + .totalNetflow(areaCodeManagerService.getAreaCodeGroupReserveNetflow(areaCode)) + .onlineDevices(areaCodeManagerService.getAreaCodeOnlineDeviceNum(areaCode)) + .capacityType(Arrays.stream(areaCodeManagerService.getAreaCodeSupportCapacity(areaCode)) + .map(DisposeCapacityType::getValue) + .toArray(Integer[]::new)) + .build(); rspInfo.getItems().add(info); } @@ -122,8 +122,8 @@ public class DisposeInfoController { @ApiOperation("获取平台版本信息") public ProtocolRespDTO getPlatformVersionInfo() { GetPlatformVerInfoRsp rspInfo = GetPlatformVerInfoRsp.builder() - .platVer(projectGitVersionInfo) - .build(); + .platVer(projectGitVersionInfo) + .build(); rspInfo.setStatus(ErrorCode.ERR_OK.getCode()); rspInfo.setMessage(new String[]{ErrorCode.ERR_OK.getMsg()}); return ProtocolRespDTO.result(ErrorCode.ERR_OK, rspInfo); @@ -147,42 +147,42 @@ public class DisposeInfoController { // 获取请求id列表 List reqIds = Arrays.stream(mr.getMsgContent().getId()).map(Long::parseLong) - .collect(Collectors.toList()); + .collect(Collectors.toList()); // 获取所有可用设备 List disposeDevice = disposeDeviceManagerService.getAllDisposeDevice(); // 获取设备版本信息 disposeDevice.stream().filter(v -> reqIds.size() == 0 || reqIds.contains(v.getId())) - .forEach(d -> { - DeviceDetail dv = DeviceDetail.builder().build(); - dv.setId(String.valueOf(d.getId())); - dv.setIpAddr(d.getIpAddr()); - dv.setIpPort(Helper.ipPortNormalize(d.getIpPort(), d.getUrlType())); - dv.setVersion(disposeAbilityRouterService.getAbilityDevice(d.getId()) - .getFirewareInfo() - .getVersion()); + .forEach(d -> { + DeviceDetail dv = DeviceDetail.builder().build(); + dv.setId(String.valueOf(d.getId())); + dv.setIpAddr(d.getIpAddr()); + dv.setIpPort(Helper.ipPortNormalize(d.getIpPort(), d.getUrlType())); + dv.setVersion(disposeAbilityRouterService.getAbilityDevice(d.getId()) + .getFirewareInfo() + .getVersion()); - dv.setStatus(ErrorCode.ERR_OK.getCode()); - dv.setMessage(new String[]{ErrorCode.ERR_OK.getMsg()}); - rspList.add(dv); - }); + dv.setStatus(ErrorCode.ERR_OK.getCode()); + dv.setMessage(new String[]{ErrorCode.ERR_OK.getMsg()}); + rspList.add(dv); + }); // 设置不存在id的错误码 reqIds.stream() - .filter(v -> disposeDevice.stream().noneMatch(k -> k.getId().equals(v))) - .forEach(v -> { - DeviceDetail dv = DeviceDetail.builder().build(); - dv.setId(String.valueOf(v)); - dv.setStatus(ErrorCode.ERR_NOSUCHDEVICE.getCode()); - dv.setMessage(new String[]{ErrorCode.ERR_NOSUCHDEVICE.getMsg()}); - rspList.add(dv); - }); + .filter(v -> disposeDevice.stream().noneMatch(k -> k.getId().equals(v))) + .forEach(v -> { + DeviceDetail dv = DeviceDetail.builder().build(); + dv.setId(String.valueOf(v)); + dv.setStatus(ErrorCode.ERR_NOSUCHDEVICE.getCode()); + dv.setMessage(new String[]{ErrorCode.ERR_NOSUCHDEVICE.getMsg()}); + rspList.add(dv); + }); // 对返回的信息按照设备ID排序 rspInfo.setItems(rspList.stream() - .sorted(Comparator.comparing(DeviceDetail::getId)) - .collect(Collectors.toList())); + .sorted(Comparator.comparing(DeviceDetail::getId)) + .collect(Collectors.toList())); return ProtocolRespDTO.result(ErrorCode.ERR_OK, rspInfo); } @@ -205,41 +205,40 @@ public class DisposeInfoController { // 获取请求id列表 List reqIds = Arrays.stream(mr.getMsgContent().getId()).map(Long::parseLong) - .collect(Collectors.toList()); + .collect(Collectors.toList()); // 获取所有可用设备 List disposeDevice = disposeDeviceManagerService.getAllDisposeDevice(); // 获取设备版本信息 disposeDevice.stream().filter(v -> reqIds.size() == 0 || reqIds.contains(v.getId())) - .forEach(d -> { - DeviceDetail dv = DeviceDetail.builder().build(); - dv.setId(String.valueOf(d.getId())); - dv.setIpAddr(d.getIpAddr()); - dv.setIpPort(Helper.ipPortNormalize(d.getIpPort(), d.getUrlType())); - dv.setOnline(disposeAbilityRouterService.getAbilityDevice(d.getId()) - .getDb() - .getDeviceLinkStatus() ? 1 : 0); - dv.setStatus(ErrorCode.ERR_OK.getCode()); - dv.setMessage(new String[]{ErrorCode.ERR_OK.getMsg()}); - rspList.add(dv); - }); + .forEach(d -> { + DeviceDetail dv = DeviceDetail.builder().build(); + dv.setId(String.valueOf(d.getId())); + dv.setIpAddr(d.getIpAddr()); + dv.setIpPort(Helper.ipPortNormalize(d.getIpPort(), d.getUrlType())); + dv.setOnline(disposeAbilityRouterService.getAbilityDevice(d.getId()) + .getLinkStatus() ? 1 : 0); + dv.setStatus(ErrorCode.ERR_OK.getCode()); + dv.setMessage(new String[]{ErrorCode.ERR_OK.getMsg()}); + rspList.add(dv); + }); // 设置不存在id的错误码 reqIds.stream() - .filter(v -> disposeDevice.stream().noneMatch(k -> k.getId().equals(v))) - .forEach(v -> { - DeviceDetail dv = DeviceDetail.builder().build(); - dv.setId(String.valueOf(v)); - dv.setStatus(ErrorCode.ERR_NOSUCHDEVICE.getCode()); - dv.setMessage(new String[]{ErrorCode.ERR_NOSUCHDEVICE.getMsg()}); - rspList.add(dv); - }); + .filter(v -> disposeDevice.stream().noneMatch(k -> k.getId().equals(v))) + .forEach(v -> { + DeviceDetail dv = DeviceDetail.builder().build(); + dv.setId(String.valueOf(v)); + dv.setStatus(ErrorCode.ERR_NOSUCHDEVICE.getCode()); + dv.setMessage(new String[]{ErrorCode.ERR_NOSUCHDEVICE.getMsg()}); + rspList.add(dv); + }); // 对返回的信息按照设备ID排序 rspInfo.setItems(rspList.stream() - .sorted(Comparator.comparing(DeviceDetail::getId)) - .collect(Collectors.toList())); + .sorted(Comparator.comparing(DeviceDetail::getId)) + .collect(Collectors.toList())); return ProtocolRespDTO.result(ErrorCode.ERR_OK, rspInfo); } diff --git a/src/main/java/com/dispose/pojo/po/AbilityInfo.java b/src/main/java/com/dispose/pojo/po/AbilityInfo.java index 0a6e9f3d..5c6d3e59 100644 --- a/src/main/java/com/dispose/pojo/po/AbilityInfo.java +++ b/src/main/java/com/dispose/pojo/po/AbilityInfo.java @@ -36,5 +36,5 @@ public class AbilityInfo { /** * The Link status. */ - private boolean linkStatus; + private Boolean linkStatus; } diff --git a/src/main/java/com/dispose/task/DeviceManagerTask.java b/src/main/java/com/dispose/task/DeviceManagerTask.java index c50a663d..76b4c464 100644 --- a/src/main/java/com/dispose/task/DeviceManagerTask.java +++ b/src/main/java/com/dispose/task/DeviceManagerTask.java @@ -36,7 +36,7 @@ public class DeviceManagerTask { log.debug("{}{} get link status {}", v.getDev().getIpAddr(), ((v.getDev().getIpPort() == null || v.getDev().getIpPort().length() == 0) ? "" : ":" + v.getDev().getIpPort()), - v.isLinkStatus()); + v.getLinkStatus()); }); } diff --git a/src/test/java/com/dispose/test/dev/service/DisposeAbilityRouterServiceTest.java b/src/test/java/com/dispose/test/dev/service/DisposeAbilityRouterServiceTest.java index 869fbd56..70557a0b 100644 --- a/src/test/java/com/dispose/test/dev/service/DisposeAbilityRouterServiceTest.java +++ b/src/test/java/com/dispose/test/dev/service/DisposeAbilityRouterServiceTest.java @@ -135,7 +135,7 @@ public class DisposeAbilityRouterServiceTest extends InitTestEnvironment { Assert.assertNotNull(v.getDb()); Assert.assertNotNull(v.getFirewareInfo()); } - Assert.assertTrue(v.isLinkStatus()); + Assert.assertTrue(v.getLinkStatus()); }); } @@ -162,7 +162,7 @@ public class DisposeAbilityRouterServiceTest extends InitTestEnvironment { Assert.assertNotNull(abilityInfo.getDb()); Assert.assertNotNull(abilityInfo.getFirewareInfo()); } - Assert.assertTrue(abilityInfo.isLinkStatus()); + Assert.assertTrue(abilityInfo.getLinkStatus()); abilityInfo = disposeAbilityRouterService.getAbilityDevice(v.getId()); @@ -173,7 +173,7 @@ public class DisposeAbilityRouterServiceTest extends InitTestEnvironment { if (abilityInfo.getDev().getDeviceType() != DisposeDeviceType.VIRTUAL_DISPOSE) { Assert.assertNotNull(abilityInfo.getFirewareInfo()); } - Assert.assertTrue(abilityInfo.isLinkStatus()); + Assert.assertTrue(abilityInfo.getLinkStatus()); }); } @@ -264,7 +264,7 @@ public class DisposeAbilityRouterServiceTest extends InitTestEnvironment { if (abilityInfo.getDev().getDeviceType() != DisposeDeviceType.VIRTUAL_DISPOSE) { Assert.assertNotNull(abilityInfo.getFirewareInfo()); } - Assert.assertTrue(abilityInfo.isLinkStatus()); + Assert.assertTrue(abilityInfo.getLinkStatus()); }); } @@ -285,7 +285,7 @@ public class DisposeAbilityRouterServiceTest extends InitTestEnvironment { if (abilityInfo.getDev().getDeviceType() == DisposeDeviceType.DPTECH_UMC) { Assert.assertNotNull(abilityInfo.getFirewareInfo()); - Assert.assertTrue(abilityInfo.isLinkStatus()); + Assert.assertTrue(abilityInfo.getLinkStatus()); } }); }