REM:
1. Fix Some CheckStyle Warnings
This commit is contained in:
HuangXin 2020-04-28 14:38:33 +08:00
parent df3e6dde4e
commit 456a4e8fbb
1 changed files with 274 additions and 176 deletions

View File

@ -98,8 +98,11 @@ public class DisposeNodeInfoController {
if (devs != null && devs.size() > 0) {
devs.forEach(v -> {
LinkStatusRsp linkStat = LinkStatusRsp.builder().online(v.getLinkStatus()).build();
linkStat.setId(v.getId().toString());
LinkStatusRsp linkStat = LinkStatusRsp.builder()
.online(v.getLinkStatus())
.build();
linkStat.setId(v.getId()
.toString());
linkStat.setStatus(ErrorCode.ERR_OK.getCode());
linkStat.setMessage(ErrorCode.ERR_OK.getMsg());
@ -110,12 +113,18 @@ public class DisposeNodeInfoController {
for (String v : reqInfo.getId()) {
DisposeDevice dev = disposeNodeManager.getDisposeDeviceById(Long.valueOf(v));
LinkStatusRsp linkStat;
if (dev != null && dev.getId().equals(Long.valueOf(v))) {
linkStat = LinkStatusRsp.builder().online(dev.getLinkStatus()).build();
linkStat.setId(dev.getId().toString());
if (dev != null && dev.getId()
.equals(Long.valueOf(v))) {
linkStat = LinkStatusRsp.builder()
.online(dev.getLinkStatus())
.build();
linkStat.setId(dev.getId()
.toString());
err = ErrorCode.ERR_OK;
} else {
linkStat = LinkStatusRsp.builder().online(0).build();
linkStat = LinkStatusRsp.builder()
.online(0)
.build();
linkStat.setId(v);
err = ErrorCode.ERR_NOSUCHDEVICE;
}
@ -159,9 +168,11 @@ public class DisposeNodeInfoController {
if (devList != null && devList.size() > 0) {
devList.forEach(v -> {
VersionRsp ver = VersionRsp.builder()
.version(v.getVersion()).build();
.version(v.getVersion())
.build();
ver.setId(v.getId().toString());
ver.setId(v.getId()
.toString());
ver.setStatus(ErrorCode.ERR_OK.getCode());
ver.setMessage(ErrorCode.ERR_OK.getMsg());
@ -173,13 +184,17 @@ public class DisposeNodeInfoController {
for (String v : reqInfo.getId()) {
DisposeDevice dev = disposeNodeManager.getDisposeDeviceById(Long.valueOf(v));
VersionRsp ver;
if (dev != null && dev.getId().equals(Long.valueOf(v))) {
if (dev != null && dev.getId()
.equals(Long.valueOf(v))) {
ver = VersionRsp.builder()
.version(dev.getVersion()).build();
ver.setId(dev.getId().toString());
.version(dev.getVersion())
.build();
ver.setId(dev.getId()
.toString());
err = ErrorCode.ERR_OK;
} else {
ver = VersionRsp.builder().build();
ver = VersionRsp.builder()
.build();
ver.setId(v);
err = ErrorCode.ERR_NOSUCHDEVICE;
}
@ -223,17 +238,28 @@ public class DisposeNodeInfoController {
List<DisposeDevice> devList = disposeNodeManager.getAllDisposeDevice();
if (devList != null && devList.size() > 0) {
devList.forEach(v -> rspInfo.getItems().add(new DeviceInfoData(
v.getId().toString(),
v.getDevInfo().getVendor(),
v.getDevInfo().getModel(),
v.getDevInfo().getFirmware(),
v.getDevInfo().getOs(),
v.getDevInfo().getKernel(),
v.getDevInfo().getArch(),
v.getDevInfo().getMemory(),
v.getDevInfo().getFreeMemory(),
v.getDevInfo().getCpuUsed(),
devList.forEach(v -> rspInfo.getItems()
.add(new DeviceInfoData(
v.getId()
.toString(),
v.getDevInfo()
.getVendor(),
v.getDevInfo()
.getModel(),
v.getDevInfo()
.getFirmware(),
v.getDevInfo()
.getOs(),
v.getDevInfo()
.getKernel(),
v.getDevInfo()
.getArch(),
v.getDevInfo()
.getMemory(),
v.getDevInfo()
.getFreeMemory(),
v.getDevInfo()
.getCpuUsed(),
ErrorCode.ERR_OK
)));
}
@ -241,23 +267,36 @@ public class DisposeNodeInfoController {
for (String v : reqInfo.getId()) {
DisposeDevice dev = disposeNodeManager.getDisposeDeviceById(Long.valueOf(v));
if (dev != null
&& dev.getId().equals(Long.valueOf(v))
&& dev.getId()
.equals(Long.valueOf(v))
&& dev.getDevInfo() != null) {
rspInfo.getItems().add(new DeviceInfoData(
dev.getId().toString(),
dev.getDevInfo().getVendor(),
dev.getDevInfo().getModel(),
dev.getDevInfo().getFirmware(),
dev.getDevInfo().getOs(),
dev.getDevInfo().getKernel(),
dev.getDevInfo().getArch(),
dev.getDevInfo().getMemory(),
dev.getDevInfo().getFreeMemory(),
dev.getDevInfo().getCpuUsed(),
rspInfo.getItems()
.add(new DeviceInfoData(
dev.getId()
.toString(),
dev.getDevInfo()
.getVendor(),
dev.getDevInfo()
.getModel(),
dev.getDevInfo()
.getFirmware(),
dev.getDevInfo()
.getOs(),
dev.getDevInfo()
.getKernel(),
dev.getDevInfo()
.getArch(),
dev.getDevInfo()
.getMemory(),
dev.getDevInfo()
.getFreeMemory(),
dev.getDevInfo()
.getCpuUsed(),
ErrorCode.ERR_OK
));
} else {
rspInfo.getItems().add(new DeviceInfoData(
rspInfo.getItems()
.add(new DeviceInfoData(
v,
ErrorCode.ERR_NOSUCHDEVICE
));
@ -300,33 +339,40 @@ public class DisposeNodeInfoController {
if (devList != null && devList.size() > 0) {
devList.forEach(v -> {
DeviceCapacityData cpData = new DeviceCapacityData(v.getDevCaps());
cpData.setId(v.getId().toString());
cpData.setId(v.getId()
.toString());
cpData.setStatus(ErrorCode.ERR_OK.getCode());
cpData.setMessage(ErrorCode.ERR_OK.getMsg());
rspInfo.getItems().add(cpData);
rspInfo.getItems()
.add(cpData);
});
}
} else {
for (String v : reqInfo.getId()) {
DisposeDevice dev = disposeNodeManager.getDisposeDeviceById(Long.valueOf(v));
if (dev != null && dev.getId().equals(Long.valueOf(v))) {
if (dev != null && dev.getId()
.equals(Long.valueOf(v))) {
DeviceCapacityData cpData = new DeviceCapacityData(dev.getDevCaps());
cpData.setId(dev.getId().toString());
cpData.setId(dev.getId()
.toString());
cpData.setStatus(ErrorCode.ERR_OK.getCode());
cpData.setMessage(ErrorCode.ERR_OK.getMsg());
rspInfo.getItems().add(cpData);
rspInfo.getItems()
.add(cpData);
} else {
DeviceCapacityData cpData = new DeviceCapacityData();
cpData.setId(v);
cpData.setStatus(ErrorCode.ERR_NOSUCHDEVICE.getCode());
cpData.setMessage(ErrorCode.ERR_NOSUCHDEVICE.getMsg());
rspInfo.getItems().add(cpData);
rspInfo.getItems()
.add(cpData);
}
}
}
String rspMessage =
new ObjectMapper().writerWithView(DisposeCapacity.CapacityView.class).writeValueAsString(rspInfo);
new ObjectMapper().writerWithView(DisposeCapacity.CapacityView.class)
.writeValueAsString(rspInfo);
return ProtocolRespDTO.result(ErrorCode.ERR_OK, rspMessage, ConstValue.Protocol.CRYPTO_NONE);
}
@ -363,33 +409,40 @@ public class DisposeNodeInfoController {
if (devList != null && devList.size() > 0) {
devList.forEach(v -> {
DeviceCapacityData cpData = new DeviceCapacityData(v.getDevCaps());
cpData.setId(v.getId().toString());
cpData.setId(v.getId()
.toString());
cpData.setStatus(ErrorCode.ERR_OK.getCode());
cpData.setMessage(ErrorCode.ERR_OK.getMsg());
rspInfo.getItems().add(cpData);
rspInfo.getItems()
.add(cpData);
});
}
} else {
for (String v : reqInfo.getId()) {
DisposeDevice dev = disposeNodeManager.getDisposeDeviceById(Long.valueOf(v));
if (dev != null && dev.getId().equals(Long.valueOf(v))) {
if (dev != null && dev.getId()
.equals(Long.valueOf(v))) {
DeviceCapacityData cpData = new DeviceCapacityData(dev.getDevCaps());
cpData.setId(dev.getId().toString());
cpData.setId(dev.getId()
.toString());
cpData.setStatus(ErrorCode.ERR_OK.getCode());
cpData.setMessage(ErrorCode.ERR_OK.getMsg());
rspInfo.getItems().add(cpData);
rspInfo.getItems()
.add(cpData);
} else {
DeviceCapacityData cpData = new DeviceCapacityData();
cpData.setId(v);
cpData.setStatus(ErrorCode.ERR_NOSUCHDEVICE.getCode());
cpData.setMessage(ErrorCode.ERR_NOSUCHDEVICE.getMsg());
rspInfo.getItems().add(cpData);
rspInfo.getItems()
.add(cpData);
}
}
}
String rspMessage =
new ObjectMapper().writerWithView(DisposeCapacity.DependIpView.class).writeValueAsString(rspInfo);
new ObjectMapper().writerWithView(DisposeCapacity.DependIpView.class)
.writeValueAsString(rspInfo);
return ProtocolRespDTO.result(ErrorCode.ERR_OK, rspMessage, ConstValue.Protocol.CRYPTO_NONE);
}
@ -418,7 +471,8 @@ public class DisposeNodeInfoController {
return ProtocolRespDTO.result(err);
}
if (mr.getMsgContent() == null || mr.getMsgContent().length() == 0) {
if (mr.getMsgContent() == null || mr.getMsgContent()
.length() == 0) {
isGetAllNode = true;
} else {
reqInfo = mr.getRequestObject(IDArrayReq.class);
@ -441,31 +495,37 @@ public class DisposeNodeInfoController {
.ip(v.getIpAddr())
.build();
dpData.setId(v.getId().toString());
dpData.setId(v.getId()
.toString());
dpData.setStatus(ErrorCode.ERR_OK.getCode());
dpData.setMessage(ErrorCode.ERR_OK.getMsg());
rspInfo.getItems().add(dpData);
rspInfo.getItems()
.add(dpData);
});
}
} else {
for (String v : reqInfo.getId()) {
DisposeDevice dev = disposeNodeManager.getDisposeDeviceById(Long.valueOf(v));
if (dev != null && dev.getId().equals(Long.valueOf(v))) {
if (dev != null && dev.getId()
.equals(Long.valueOf(v))) {
DisposeNodeData dpData = DisposeNodeData.builder()
.type(dev.getType())
.name(dev.getName())
.ip(dev.getIpAddr())
.build();
dpData.setId(dev.getId().toString());
dpData.setId(dev.getId()
.toString());
dpData.setStatus(ErrorCode.ERR_OK.getCode());
dpData.setMessage(ErrorCode.ERR_OK.getMsg());
rspInfo.getItems().add(dpData);
rspInfo.getItems()
.add(dpData);
} else {
DisposeNodeData dpData = new DisposeNodeData();
dpData.setId(v);
dpData.setStatus(ErrorCode.ERR_NOSUCHDEVICE.getCode());
dpData.setMessage(ErrorCode.ERR_NOSUCHDEVICE.getMsg());
rspInfo.getItems().add(dpData);
rspInfo.getItems()
.add(dpData);
}
}
}
@ -513,16 +573,19 @@ public class DisposeNodeInfoController {
v.getReadme(),
v.getDevCaps()
);
dpData.setId(v.getId().toString());
dpData.setId(v.getId()
.toString());
dpData.setStatus(ErrorCode.ERR_OK.getCode());
dpData.setMessage(ErrorCode.ERR_OK.getMsg());
rspInfo.getItems().add(dpData);
rspInfo.getItems()
.add(dpData);
});
}
} else {
for (String v : reqInfo.getId()) {
DisposeDevice dev = disposeNodeManager.getDisposeDeviceById(Long.valueOf(v));
if (dev != null && dev.getId().equals(Long.valueOf(v))) {
if (dev != null && dev.getId()
.equals(Long.valueOf(v))) {
DisposeNodeData dpData = new DisposeNodeData(
dev.getType(),
dev.getName(),
@ -534,16 +597,19 @@ public class DisposeNodeInfoController {
dev.getReadme(),
dev.getDevCaps()
);
dpData.setId(dev.getId().toString());
dpData.setId(dev.getId()
.toString());
dpData.setStatus(ErrorCode.ERR_OK.getCode());
dpData.setMessage(ErrorCode.ERR_OK.getMsg());
rspInfo.getItems().add(dpData);
rspInfo.getItems()
.add(dpData);
} else {
DisposeNodeData dpData = new DisposeNodeData();
dpData.setId(v);
dpData.setStatus(ErrorCode.ERR_NOSUCHDEVICE.getCode());
dpData.setMessage(ErrorCode.ERR_NOSUCHDEVICE.getMsg());
rspInfo.getItems().add(dpData);
rspInfo.getItems()
.add(dpData);
}
}
}
@ -576,23 +642,35 @@ public class DisposeNodeInfoController {
List<DisposeDevice> valuableData = disposeNodeManager.getAllDisposeDevice()
.parallelStream()
.filter(v -> reqInfo.getId().length == 0
|| Arrays.stream(reqInfo.getId()).anyMatch(s -> s.equals(v.getId().toString())))
|| Arrays.stream(reqInfo.getId())
.anyMatch(s -> s.equals(v.getId()
.toString())))
.collect(Collectors.toList());
valuableData.parallelStream().forEach(v -> {
valuableData.parallelStream()
.forEach(v -> {
NodeTaskData taskData = new NodeTaskData();
rspInfo.getItems().add(taskData);
taskData.setId(v.getId().toString());
rspInfo.getItems()
.add(taskData);
taskData.setId(v.getId()
.toString());
taskData.setStatus(ErrorCode.ERR_OK.getCode());
taskData.setMessage(ErrorCode.ERR_OK.getMsg());
taskService.getNodeAllRunningTask(v.getId()).parallelStream().forEach(k -> {
Long tmLong = Timestamp.valueOf(k.getBeginTime()).toInstant().toEpochMilli() / 1000;
Long endTm = Timestamp.valueOf(k.getPlanEndTime()).toInstant().toEpochMilli() / 1000;
taskService.getNodeAllRunningTask(v.getId())
.parallelStream()
.forEach(k -> {
Long tmLong = Timestamp.valueOf(k.getBeginTime())
.toInstant()
.toEpochMilli() / 1000;
Long endTm = Timestamp.valueOf(k.getPlanEndTime())
.toInstant()
.toEpochMilli() / 1000;
Long diff = endTm - tmLong;
TaskInfoData taskInfoData = TaskInfoData.builder()
.taskId(k.getId().toString())
.taskId(k.getId()
.toString())
.type(k.getType())
.startTime(tmLong.intValue())
.disposeTime(diff.intValue())
@ -601,18 +679,22 @@ public class DisposeNodeInfoController {
.flowClean(0)
.build();
taskData.getTaskArray().add(taskInfoData);
taskData.getTaskArray()
.add(taskInfoData);
});
});
if (reqInfo.getId().length != 0) {
List<String> unExists = Arrays.stream(reqInfo.getId())
.filter(v -> valuableData.parallelStream().noneMatch(k -> k.getId() == Long.parseLong(v)))
.filter(v -> valuableData.parallelStream()
.noneMatch(k -> k.getId() == Long.parseLong(v)))
.collect(Collectors.toList());
unExists.parallelStream().forEach(v -> {
unExists.parallelStream()
.forEach(v -> {
NodeTaskData taskData = new NodeTaskData();
rspInfo.getItems().add(taskData);
rspInfo.getItems()
.add(taskData);
taskData.setId(v);
taskData.setStatus(ErrorCode.ERR_NOSUCHDEVICE.getCode());
taskData.setMessage(ErrorCode.ERR_NOSUCHDEVICE.getMsg());
@ -648,23 +730,35 @@ public class DisposeNodeInfoController {
List<DisposeDevice> valuableData = disposeNodeManager.getAllDisposeDevice()
.parallelStream()
.filter(v -> reqInfo.getId().length == 0
|| Arrays.stream(reqInfo.getId()).anyMatch(s -> s.equals(v.getId().toString())))
|| Arrays.stream(reqInfo.getId())
.anyMatch(s -> s.equals(v.getId()
.toString())))
.collect(Collectors.toList());
valuableData.parallelStream().forEach(v -> {
valuableData.parallelStream()
.forEach(v -> {
NodeTaskData taskData = new NodeTaskData();
rspInfo.getItems().add(taskData);
taskData.setId(v.getId().toString());
rspInfo.getItems()
.add(taskData);
taskData.setId(v.getId()
.toString());
taskData.setStatus(ErrorCode.ERR_OK.getCode());
taskData.setMessage(ErrorCode.ERR_OK.getMsg());
taskService.getNodeAllRunningTask(v.getId()).parallelStream().forEach(k -> {
Long tmLong = Timestamp.valueOf(k.getBeginTime()).toInstant().toEpochMilli() / 1000;
Long endTm = Timestamp.valueOf(k.getPlanEndTime()).toInstant().toEpochMilli() / 1000;
taskService.getNodeAllRunningTask(v.getId())
.parallelStream()
.forEach(k -> {
Long tmLong = Timestamp.valueOf(k.getBeginTime())
.toInstant()
.toEpochMilli() / 1000;
Long endTm = Timestamp.valueOf(k.getPlanEndTime())
.toInstant()
.toEpochMilli() / 1000;
Long diff = endTm - tmLong;
TaskInfoData taskInfoData = TaskInfoData.builder()
.taskId(k.getId().toString())
.taskId(k.getId()
.toString())
.type(k.getType())
.startTime(tmLong.intValue())
.disposeTime(diff.intValue())
@ -673,18 +767,22 @@ public class DisposeNodeInfoController {
.flowClean(0)
.build();
taskData.getTaskArray().add(taskInfoData);
taskData.getTaskArray()
.add(taskInfoData);
});
});
if (reqInfo.getId().length != 0) {
List<String> unExists = Arrays.stream(reqInfo.getId())
.filter(v -> valuableData.parallelStream().noneMatch(k -> k.getId() == Long.parseLong(v)))
.filter(v -> valuableData.parallelStream()
.noneMatch(k -> k.getId() == Long.parseLong(v)))
.collect(Collectors.toList());
unExists.parallelStream().forEach(v -> {
unExists.parallelStream()
.forEach(v -> {
NodeTaskData taskData = new NodeTaskData();
rspInfo.getItems().add(taskData);
rspInfo.getItems()
.add(taskData);
taskData.setId(v);
taskData.setStatus(ErrorCode.ERR_NOSUCHDEVICE.getCode());
taskData.setMessage(ErrorCode.ERR_NOSUCHDEVICE.getMsg());