REM:
1. 更是设备能力信息链接状态数据类型
This commit is contained in:
HuangXin 2020-09-14 15:38:05 +08:00
parent 2dc4867721
commit 44cce111d5
4 changed files with 63 additions and 64 deletions

View File

@ -89,20 +89,20 @@ public class DisposeInfoController {
public ProtocolRespDTO<GetAreaInfoRsp> getAllDisposeDeviceAreaInfo() {
GetAreaInfoRsp rspInfo = GetAreaInfoRsp.builder()
.items(new ArrayList<>())
.build();
.items(new ArrayList<>())
.build();
Map<Integer, List<DisposeDevice>> 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<GetPlatformVerInfoRsp> 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<Long> reqIds = Arrays.stream(mr.getMsgContent().getId()).map(Long::parseLong)
.collect(Collectors.toList());
.collect(Collectors.toList());
// 获取所有可用设备
List<DisposeDevice> 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<Long> reqIds = Arrays.stream(mr.getMsgContent().getId()).map(Long::parseLong)
.collect(Collectors.toList());
.collect(Collectors.toList());
// 获取所有可用设备
List<DisposeDevice> 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);
}

View File

@ -36,5 +36,5 @@ public class AbilityInfo {
/**
* The Link status.
*/
private boolean linkStatus;
private Boolean linkStatus;
}

View File

@ -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());
});
}

View File

@ -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());
}
});
}