parent
2dc4867721
commit
44cce111d5
|
@ -89,20 +89,20 @@ public class DisposeInfoController {
|
||||||
public ProtocolRespDTO<GetAreaInfoRsp> getAllDisposeDeviceAreaInfo() {
|
public ProtocolRespDTO<GetAreaInfoRsp> getAllDisposeDeviceAreaInfo() {
|
||||||
|
|
||||||
GetAreaInfoRsp rspInfo = GetAreaInfoRsp.builder()
|
GetAreaInfoRsp rspInfo = GetAreaInfoRsp.builder()
|
||||||
.items(new ArrayList<>())
|
.items(new ArrayList<>())
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
Map<Integer, List<DisposeDevice>> groupDev = areaCodeManagerService.getAreaCodeGroup();
|
Map<Integer, List<DisposeDevice>> groupDev = areaCodeManagerService.getAreaCodeGroup();
|
||||||
|
|
||||||
for (Integer areaCode : groupDev.keySet()) {
|
for (Integer areaCode : groupDev.keySet()) {
|
||||||
AreaInfoDetail info = AreaInfoDetail.builder()
|
AreaInfoDetail info = AreaInfoDetail.builder()
|
||||||
.nodeId(areaCode.toString())
|
.nodeId(areaCode.toString())
|
||||||
.totalNetflow(areaCodeManagerService.getAreaCodeGroupReserveNetflow(areaCode))
|
.totalNetflow(areaCodeManagerService.getAreaCodeGroupReserveNetflow(areaCode))
|
||||||
.onlineDevices(areaCodeManagerService.getAreaCodeOnlineDeviceNum(areaCode))
|
.onlineDevices(areaCodeManagerService.getAreaCodeOnlineDeviceNum(areaCode))
|
||||||
.capacityType(Arrays.stream(areaCodeManagerService.getAreaCodeSupportCapacity(areaCode))
|
.capacityType(Arrays.stream(areaCodeManagerService.getAreaCodeSupportCapacity(areaCode))
|
||||||
.map(DisposeCapacityType::getValue)
|
.map(DisposeCapacityType::getValue)
|
||||||
.toArray(Integer[]::new))
|
.toArray(Integer[]::new))
|
||||||
.build();
|
.build();
|
||||||
rspInfo.getItems().add(info);
|
rspInfo.getItems().add(info);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -122,8 +122,8 @@ public class DisposeInfoController {
|
||||||
@ApiOperation("获取平台版本信息")
|
@ApiOperation("获取平台版本信息")
|
||||||
public ProtocolRespDTO<GetPlatformVerInfoRsp> getPlatformVersionInfo() {
|
public ProtocolRespDTO<GetPlatformVerInfoRsp> getPlatformVersionInfo() {
|
||||||
GetPlatformVerInfoRsp rspInfo = GetPlatformVerInfoRsp.builder()
|
GetPlatformVerInfoRsp rspInfo = GetPlatformVerInfoRsp.builder()
|
||||||
.platVer(projectGitVersionInfo)
|
.platVer(projectGitVersionInfo)
|
||||||
.build();
|
.build();
|
||||||
rspInfo.setStatus(ErrorCode.ERR_OK.getCode());
|
rspInfo.setStatus(ErrorCode.ERR_OK.getCode());
|
||||||
rspInfo.setMessage(new String[]{ErrorCode.ERR_OK.getMsg()});
|
rspInfo.setMessage(new String[]{ErrorCode.ERR_OK.getMsg()});
|
||||||
return ProtocolRespDTO.result(ErrorCode.ERR_OK, rspInfo);
|
return ProtocolRespDTO.result(ErrorCode.ERR_OK, rspInfo);
|
||||||
|
@ -147,42 +147,42 @@ public class DisposeInfoController {
|
||||||
|
|
||||||
// 获取请求id列表
|
// 获取请求id列表
|
||||||
List<Long> reqIds = Arrays.stream(mr.getMsgContent().getId()).map(Long::parseLong)
|
List<Long> reqIds = Arrays.stream(mr.getMsgContent().getId()).map(Long::parseLong)
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
// 获取所有可用设备
|
// 获取所有可用设备
|
||||||
List<DisposeDevice> disposeDevice = disposeDeviceManagerService.getAllDisposeDevice();
|
List<DisposeDevice> disposeDevice = disposeDeviceManagerService.getAllDisposeDevice();
|
||||||
|
|
||||||
// 获取设备版本信息
|
// 获取设备版本信息
|
||||||
disposeDevice.stream().filter(v -> reqIds.size() == 0 || reqIds.contains(v.getId()))
|
disposeDevice.stream().filter(v -> reqIds.size() == 0 || reqIds.contains(v.getId()))
|
||||||
.forEach(d -> {
|
.forEach(d -> {
|
||||||
DeviceDetail dv = DeviceDetail.builder().build();
|
DeviceDetail dv = DeviceDetail.builder().build();
|
||||||
dv.setId(String.valueOf(d.getId()));
|
dv.setId(String.valueOf(d.getId()));
|
||||||
dv.setIpAddr(d.getIpAddr());
|
dv.setIpAddr(d.getIpAddr());
|
||||||
dv.setIpPort(Helper.ipPortNormalize(d.getIpPort(), d.getUrlType()));
|
dv.setIpPort(Helper.ipPortNormalize(d.getIpPort(), d.getUrlType()));
|
||||||
dv.setVersion(disposeAbilityRouterService.getAbilityDevice(d.getId())
|
dv.setVersion(disposeAbilityRouterService.getAbilityDevice(d.getId())
|
||||||
.getFirewareInfo()
|
.getFirewareInfo()
|
||||||
.getVersion());
|
.getVersion());
|
||||||
|
|
||||||
dv.setStatus(ErrorCode.ERR_OK.getCode());
|
dv.setStatus(ErrorCode.ERR_OK.getCode());
|
||||||
dv.setMessage(new String[]{ErrorCode.ERR_OK.getMsg()});
|
dv.setMessage(new String[]{ErrorCode.ERR_OK.getMsg()});
|
||||||
rspList.add(dv);
|
rspList.add(dv);
|
||||||
});
|
});
|
||||||
|
|
||||||
// 设置不存在id的错误码
|
// 设置不存在id的错误码
|
||||||
reqIds.stream()
|
reqIds.stream()
|
||||||
.filter(v -> disposeDevice.stream().noneMatch(k -> k.getId().equals(v)))
|
.filter(v -> disposeDevice.stream().noneMatch(k -> k.getId().equals(v)))
|
||||||
.forEach(v -> {
|
.forEach(v -> {
|
||||||
DeviceDetail dv = DeviceDetail.builder().build();
|
DeviceDetail dv = DeviceDetail.builder().build();
|
||||||
dv.setId(String.valueOf(v));
|
dv.setId(String.valueOf(v));
|
||||||
dv.setStatus(ErrorCode.ERR_NOSUCHDEVICE.getCode());
|
dv.setStatus(ErrorCode.ERR_NOSUCHDEVICE.getCode());
|
||||||
dv.setMessage(new String[]{ErrorCode.ERR_NOSUCHDEVICE.getMsg()});
|
dv.setMessage(new String[]{ErrorCode.ERR_NOSUCHDEVICE.getMsg()});
|
||||||
rspList.add(dv);
|
rspList.add(dv);
|
||||||
});
|
});
|
||||||
|
|
||||||
// 对返回的信息按照设备ID排序
|
// 对返回的信息按照设备ID排序
|
||||||
rspInfo.setItems(rspList.stream()
|
rspInfo.setItems(rspList.stream()
|
||||||
.sorted(Comparator.comparing(DeviceDetail::getId))
|
.sorted(Comparator.comparing(DeviceDetail::getId))
|
||||||
.collect(Collectors.toList()));
|
.collect(Collectors.toList()));
|
||||||
|
|
||||||
return ProtocolRespDTO.result(ErrorCode.ERR_OK, rspInfo);
|
return ProtocolRespDTO.result(ErrorCode.ERR_OK, rspInfo);
|
||||||
}
|
}
|
||||||
|
@ -205,41 +205,40 @@ public class DisposeInfoController {
|
||||||
|
|
||||||
// 获取请求id列表
|
// 获取请求id列表
|
||||||
List<Long> reqIds = Arrays.stream(mr.getMsgContent().getId()).map(Long::parseLong)
|
List<Long> reqIds = Arrays.stream(mr.getMsgContent().getId()).map(Long::parseLong)
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
// 获取所有可用设备
|
// 获取所有可用设备
|
||||||
List<DisposeDevice> disposeDevice = disposeDeviceManagerService.getAllDisposeDevice();
|
List<DisposeDevice> disposeDevice = disposeDeviceManagerService.getAllDisposeDevice();
|
||||||
|
|
||||||
// 获取设备版本信息
|
// 获取设备版本信息
|
||||||
disposeDevice.stream().filter(v -> reqIds.size() == 0 || reqIds.contains(v.getId()))
|
disposeDevice.stream().filter(v -> reqIds.size() == 0 || reqIds.contains(v.getId()))
|
||||||
.forEach(d -> {
|
.forEach(d -> {
|
||||||
DeviceDetail dv = DeviceDetail.builder().build();
|
DeviceDetail dv = DeviceDetail.builder().build();
|
||||||
dv.setId(String.valueOf(d.getId()));
|
dv.setId(String.valueOf(d.getId()));
|
||||||
dv.setIpAddr(d.getIpAddr());
|
dv.setIpAddr(d.getIpAddr());
|
||||||
dv.setIpPort(Helper.ipPortNormalize(d.getIpPort(), d.getUrlType()));
|
dv.setIpPort(Helper.ipPortNormalize(d.getIpPort(), d.getUrlType()));
|
||||||
dv.setOnline(disposeAbilityRouterService.getAbilityDevice(d.getId())
|
dv.setOnline(disposeAbilityRouterService.getAbilityDevice(d.getId())
|
||||||
.getDb()
|
.getLinkStatus() ? 1 : 0);
|
||||||
.getDeviceLinkStatus() ? 1 : 0);
|
dv.setStatus(ErrorCode.ERR_OK.getCode());
|
||||||
dv.setStatus(ErrorCode.ERR_OK.getCode());
|
dv.setMessage(new String[]{ErrorCode.ERR_OK.getMsg()});
|
||||||
dv.setMessage(new String[]{ErrorCode.ERR_OK.getMsg()});
|
rspList.add(dv);
|
||||||
rspList.add(dv);
|
});
|
||||||
});
|
|
||||||
|
|
||||||
// 设置不存在id的错误码
|
// 设置不存在id的错误码
|
||||||
reqIds.stream()
|
reqIds.stream()
|
||||||
.filter(v -> disposeDevice.stream().noneMatch(k -> k.getId().equals(v)))
|
.filter(v -> disposeDevice.stream().noneMatch(k -> k.getId().equals(v)))
|
||||||
.forEach(v -> {
|
.forEach(v -> {
|
||||||
DeviceDetail dv = DeviceDetail.builder().build();
|
DeviceDetail dv = DeviceDetail.builder().build();
|
||||||
dv.setId(String.valueOf(v));
|
dv.setId(String.valueOf(v));
|
||||||
dv.setStatus(ErrorCode.ERR_NOSUCHDEVICE.getCode());
|
dv.setStatus(ErrorCode.ERR_NOSUCHDEVICE.getCode());
|
||||||
dv.setMessage(new String[]{ErrorCode.ERR_NOSUCHDEVICE.getMsg()});
|
dv.setMessage(new String[]{ErrorCode.ERR_NOSUCHDEVICE.getMsg()});
|
||||||
rspList.add(dv);
|
rspList.add(dv);
|
||||||
});
|
});
|
||||||
|
|
||||||
// 对返回的信息按照设备ID排序
|
// 对返回的信息按照设备ID排序
|
||||||
rspInfo.setItems(rspList.stream()
|
rspInfo.setItems(rspList.stream()
|
||||||
.sorted(Comparator.comparing(DeviceDetail::getId))
|
.sorted(Comparator.comparing(DeviceDetail::getId))
|
||||||
.collect(Collectors.toList()));
|
.collect(Collectors.toList()));
|
||||||
|
|
||||||
return ProtocolRespDTO.result(ErrorCode.ERR_OK, rspInfo);
|
return ProtocolRespDTO.result(ErrorCode.ERR_OK, rspInfo);
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,5 +36,5 @@ public class AbilityInfo {
|
||||||
/**
|
/**
|
||||||
* The Link status.
|
* The Link status.
|
||||||
*/
|
*/
|
||||||
private boolean linkStatus;
|
private Boolean linkStatus;
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,7 +36,7 @@ public class DeviceManagerTask {
|
||||||
log.debug("{}{} get link status {}", v.getDev().getIpAddr(),
|
log.debug("{}{} get link status {}", v.getDev().getIpAddr(),
|
||||||
((v.getDev().getIpPort() == null || v.getDev().getIpPort().length() == 0) ? "" :
|
((v.getDev().getIpPort() == null || v.getDev().getIpPort().length() == 0) ? "" :
|
||||||
":" + v.getDev().getIpPort()),
|
":" + v.getDev().getIpPort()),
|
||||||
v.isLinkStatus());
|
v.getLinkStatus());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -135,7 +135,7 @@ public class DisposeAbilityRouterServiceTest extends InitTestEnvironment {
|
||||||
Assert.assertNotNull(v.getDb());
|
Assert.assertNotNull(v.getDb());
|
||||||
Assert.assertNotNull(v.getFirewareInfo());
|
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.getDb());
|
||||||
Assert.assertNotNull(abilityInfo.getFirewareInfo());
|
Assert.assertNotNull(abilityInfo.getFirewareInfo());
|
||||||
}
|
}
|
||||||
Assert.assertTrue(abilityInfo.isLinkStatus());
|
Assert.assertTrue(abilityInfo.getLinkStatus());
|
||||||
|
|
||||||
abilityInfo = disposeAbilityRouterService.getAbilityDevice(v.getId());
|
abilityInfo = disposeAbilityRouterService.getAbilityDevice(v.getId());
|
||||||
|
|
||||||
|
@ -173,7 +173,7 @@ public class DisposeAbilityRouterServiceTest extends InitTestEnvironment {
|
||||||
if (abilityInfo.getDev().getDeviceType() != DisposeDeviceType.VIRTUAL_DISPOSE) {
|
if (abilityInfo.getDev().getDeviceType() != DisposeDeviceType.VIRTUAL_DISPOSE) {
|
||||||
Assert.assertNotNull(abilityInfo.getFirewareInfo());
|
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) {
|
if (abilityInfo.getDev().getDeviceType() != DisposeDeviceType.VIRTUAL_DISPOSE) {
|
||||||
Assert.assertNotNull(abilityInfo.getFirewareInfo());
|
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) {
|
if (abilityInfo.getDev().getDeviceType() == DisposeDeviceType.DPTECH_UMC) {
|
||||||
Assert.assertNotNull(abilityInfo.getFirewareInfo());
|
Assert.assertNotNull(abilityInfo.getFirewareInfo());
|
||||||
Assert.assertTrue(abilityInfo.isLinkStatus());
|
Assert.assertTrue(abilityInfo.getLinkStatus());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue