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

@ -83,7 +83,7 @@ public class DisposeNodeInfoController {
@ApiOperation("链接状态") @ApiOperation("链接状态")
public ProtocolRespDTO getLinkStatus(@RequestBody ProtocolReqDTO mr, public ProtocolRespDTO getLinkStatus(@RequestBody ProtocolReqDTO mr,
@RequestHeader HttpHeaders headers) @RequestHeader HttpHeaders headers)
throws JsonProcessingException { throws JsonProcessingException {
ErrorCode err = mr.verifyRequest(headers); ErrorCode err = mr.verifyRequest(headers);
if (err != ErrorCode.ERR_OK) { if (err != ErrorCode.ERR_OK) {
@ -98,8 +98,11 @@ public class DisposeNodeInfoController {
if (devs != null && devs.size() > 0) { if (devs != null && devs.size() > 0) {
devs.forEach(v -> { devs.forEach(v -> {
LinkStatusRsp linkStat = LinkStatusRsp.builder().online(v.getLinkStatus()).build(); LinkStatusRsp linkStat = LinkStatusRsp.builder()
linkStat.setId(v.getId().toString()); .online(v.getLinkStatus())
.build();
linkStat.setId(v.getId()
.toString());
linkStat.setStatus(ErrorCode.ERR_OK.getCode()); linkStat.setStatus(ErrorCode.ERR_OK.getCode());
linkStat.setMessage(ErrorCode.ERR_OK.getMsg()); linkStat.setMessage(ErrorCode.ERR_OK.getMsg());
@ -110,12 +113,18 @@ public class DisposeNodeInfoController {
for (String v : reqInfo.getId()) { for (String v : reqInfo.getId()) {
DisposeDevice dev = disposeNodeManager.getDisposeDeviceById(Long.valueOf(v)); DisposeDevice dev = disposeNodeManager.getDisposeDeviceById(Long.valueOf(v));
LinkStatusRsp linkStat; LinkStatusRsp linkStat;
if (dev != null && dev.getId().equals(Long.valueOf(v))) { if (dev != null && dev.getId()
linkStat = LinkStatusRsp.builder().online(dev.getLinkStatus()).build(); .equals(Long.valueOf(v))) {
linkStat.setId(dev.getId().toString()); linkStat = LinkStatusRsp.builder()
.online(dev.getLinkStatus())
.build();
linkStat.setId(dev.getId()
.toString());
err = ErrorCode.ERR_OK; err = ErrorCode.ERR_OK;
} else { } else {
linkStat = LinkStatusRsp.builder().online(0).build(); linkStat = LinkStatusRsp.builder()
.online(0)
.build();
linkStat.setId(v); linkStat.setId(v);
err = ErrorCode.ERR_NOSUCHDEVICE; err = ErrorCode.ERR_NOSUCHDEVICE;
} }
@ -143,7 +152,7 @@ public class DisposeNodeInfoController {
@ApiOperation("处置设备版本") @ApiOperation("处置设备版本")
public ProtocolRespDTO getVersion(@RequestBody ProtocolReqDTO mr, public ProtocolRespDTO getVersion(@RequestBody ProtocolReqDTO mr,
@RequestHeader HttpHeaders headers) @RequestHeader HttpHeaders headers)
throws JsonProcessingException { throws JsonProcessingException {
ErrorCode err = mr.verifyRequest(headers); ErrorCode err = mr.verifyRequest(headers);
if (err != ErrorCode.ERR_OK) { if (err != ErrorCode.ERR_OK) {
@ -159,9 +168,11 @@ public class DisposeNodeInfoController {
if (devList != null && devList.size() > 0) { if (devList != null && devList.size() > 0) {
devList.forEach(v -> { devList.forEach(v -> {
VersionRsp ver = VersionRsp.builder() 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.setStatus(ErrorCode.ERR_OK.getCode());
ver.setMessage(ErrorCode.ERR_OK.getMsg()); ver.setMessage(ErrorCode.ERR_OK.getMsg());
@ -173,13 +184,17 @@ public class DisposeNodeInfoController {
for (String v : reqInfo.getId()) { for (String v : reqInfo.getId()) {
DisposeDevice dev = disposeNodeManager.getDisposeDeviceById(Long.valueOf(v)); DisposeDevice dev = disposeNodeManager.getDisposeDeviceById(Long.valueOf(v));
VersionRsp ver; VersionRsp ver;
if (dev != null && dev.getId().equals(Long.valueOf(v))) { if (dev != null && dev.getId()
.equals(Long.valueOf(v))) {
ver = VersionRsp.builder() ver = VersionRsp.builder()
.version(dev.getVersion()).build(); .version(dev.getVersion())
ver.setId(dev.getId().toString()); .build();
ver.setId(dev.getId()
.toString());
err = ErrorCode.ERR_OK; err = ErrorCode.ERR_OK;
} else { } else {
ver = VersionRsp.builder().build(); ver = VersionRsp.builder()
.build();
ver.setId(v); ver.setId(v);
err = ErrorCode.ERR_NOSUCHDEVICE; err = ErrorCode.ERR_NOSUCHDEVICE;
} }
@ -207,7 +222,7 @@ public class DisposeNodeInfoController {
@ApiOperation("处置设备信息") @ApiOperation("处置设备信息")
public ProtocolRespDTO getDeviceInfo(@RequestBody ProtocolReqDTO mr, public ProtocolRespDTO getDeviceInfo(@RequestBody ProtocolReqDTO mr,
@RequestHeader HttpHeaders headers) @RequestHeader HttpHeaders headers)
throws JsonProcessingException { throws JsonProcessingException {
ErrorCode err = mr.verifyRequest(headers); ErrorCode err = mr.verifyRequest(headers);
if (err != ErrorCode.ERR_OK) { if (err != ErrorCode.ERR_OK) {
@ -223,44 +238,68 @@ public class DisposeNodeInfoController {
List<DisposeDevice> devList = disposeNodeManager.getAllDisposeDevice(); List<DisposeDevice> devList = disposeNodeManager.getAllDisposeDevice();
if (devList != null && devList.size() > 0) { if (devList != null && devList.size() > 0) {
devList.forEach(v -> rspInfo.getItems().add(new DeviceInfoData( devList.forEach(v -> rspInfo.getItems()
v.getId().toString(), .add(new DeviceInfoData(
v.getDevInfo().getVendor(), v.getId()
v.getDevInfo().getModel(), .toString(),
v.getDevInfo().getFirmware(), v.getDevInfo()
v.getDevInfo().getOs(), .getVendor(),
v.getDevInfo().getKernel(), v.getDevInfo()
v.getDevInfo().getArch(), .getModel(),
v.getDevInfo().getMemory(), v.getDevInfo()
v.getDevInfo().getFreeMemory(), .getFirmware(),
v.getDevInfo().getCpuUsed(), v.getDevInfo()
ErrorCode.ERR_OK .getOs(),
))); v.getDevInfo()
.getKernel(),
v.getDevInfo()
.getArch(),
v.getDevInfo()
.getMemory(),
v.getDevInfo()
.getFreeMemory(),
v.getDevInfo()
.getCpuUsed(),
ErrorCode.ERR_OK
)));
} }
} else { } else {
for (String v : reqInfo.getId()) { for (String v : reqInfo.getId()) {
DisposeDevice dev = disposeNodeManager.getDisposeDeviceById(Long.valueOf(v)); DisposeDevice dev = disposeNodeManager.getDisposeDeviceById(Long.valueOf(v));
if (dev != null if (dev != null
&& dev.getId().equals(Long.valueOf(v)) && dev.getId()
&& dev.getDevInfo() != null) { .equals(Long.valueOf(v))
rspInfo.getItems().add(new DeviceInfoData( && dev.getDevInfo() != null) {
dev.getId().toString(), rspInfo.getItems()
dev.getDevInfo().getVendor(), .add(new DeviceInfoData(
dev.getDevInfo().getModel(), dev.getId()
dev.getDevInfo().getFirmware(), .toString(),
dev.getDevInfo().getOs(), dev.getDevInfo()
dev.getDevInfo().getKernel(), .getVendor(),
dev.getDevInfo().getArch(), dev.getDevInfo()
dev.getDevInfo().getMemory(), .getModel(),
dev.getDevInfo().getFreeMemory(), dev.getDevInfo()
dev.getDevInfo().getCpuUsed(), .getFirmware(),
ErrorCode.ERR_OK dev.getDevInfo()
)); .getOs(),
dev.getDevInfo()
.getKernel(),
dev.getDevInfo()
.getArch(),
dev.getDevInfo()
.getMemory(),
dev.getDevInfo()
.getFreeMemory(),
dev.getDevInfo()
.getCpuUsed(),
ErrorCode.ERR_OK
));
} else { } else {
rspInfo.getItems().add(new DeviceInfoData( rspInfo.getItems()
v, .add(new DeviceInfoData(
ErrorCode.ERR_NOSUCHDEVICE v,
)); ErrorCode.ERR_NOSUCHDEVICE
));
} }
} }
} }
@ -282,7 +321,7 @@ public class DisposeNodeInfoController {
//@JsonView(DisposeCapacity.CapacityView.class) //@JsonView(DisposeCapacity.CapacityView.class)
public ProtocolRespDTO getCapacity(@RequestBody ProtocolReqDTO mr, public ProtocolRespDTO getCapacity(@RequestBody ProtocolReqDTO mr,
@RequestHeader HttpHeaders headers) @RequestHeader HttpHeaders headers)
throws JsonProcessingException { throws JsonProcessingException {
ErrorCode err = mr.verifyRequest(headers); ErrorCode err = mr.verifyRequest(headers);
if (err != ErrorCode.ERR_OK) { if (err != ErrorCode.ERR_OK) {
@ -300,33 +339,40 @@ public class DisposeNodeInfoController {
if (devList != null && devList.size() > 0) { if (devList != null && devList.size() > 0) {
devList.forEach(v -> { devList.forEach(v -> {
DeviceCapacityData cpData = new DeviceCapacityData(v.getDevCaps()); DeviceCapacityData cpData = new DeviceCapacityData(v.getDevCaps());
cpData.setId(v.getId().toString()); cpData.setId(v.getId()
.toString());
cpData.setStatus(ErrorCode.ERR_OK.getCode()); cpData.setStatus(ErrorCode.ERR_OK.getCode());
cpData.setMessage(ErrorCode.ERR_OK.getMsg()); cpData.setMessage(ErrorCode.ERR_OK.getMsg());
rspInfo.getItems().add(cpData); rspInfo.getItems()
.add(cpData);
}); });
} }
} else { } else {
for (String v : reqInfo.getId()) { for (String v : reqInfo.getId()) {
DisposeDevice dev = disposeNodeManager.getDisposeDeviceById(Long.valueOf(v)); 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()); DeviceCapacityData cpData = new DeviceCapacityData(dev.getDevCaps());
cpData.setId(dev.getId().toString()); cpData.setId(dev.getId()
.toString());
cpData.setStatus(ErrorCode.ERR_OK.getCode()); cpData.setStatus(ErrorCode.ERR_OK.getCode());
cpData.setMessage(ErrorCode.ERR_OK.getMsg()); cpData.setMessage(ErrorCode.ERR_OK.getMsg());
rspInfo.getItems().add(cpData); rspInfo.getItems()
.add(cpData);
} else { } else {
DeviceCapacityData cpData = new DeviceCapacityData(); DeviceCapacityData cpData = new DeviceCapacityData();
cpData.setId(v); cpData.setId(v);
cpData.setStatus(ErrorCode.ERR_NOSUCHDEVICE.getCode()); cpData.setStatus(ErrorCode.ERR_NOSUCHDEVICE.getCode());
cpData.setMessage(ErrorCode.ERR_NOSUCHDEVICE.getMsg()); cpData.setMessage(ErrorCode.ERR_NOSUCHDEVICE.getMsg());
rspInfo.getItems().add(cpData); rspInfo.getItems()
.add(cpData);
} }
} }
} }
String rspMessage = 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); return ProtocolRespDTO.result(ErrorCode.ERR_OK, rspMessage, ConstValue.Protocol.CRYPTO_NONE);
} }
@ -345,7 +391,7 @@ public class DisposeNodeInfoController {
//@JsonView(DisposeCapacity.CapacityView.class) //@JsonView(DisposeCapacity.CapacityView.class)
public ProtocolRespDTO getProtectedIp(@RequestBody ProtocolReqDTO mr, public ProtocolRespDTO getProtectedIp(@RequestBody ProtocolReqDTO mr,
@RequestHeader HttpHeaders headers) @RequestHeader HttpHeaders headers)
throws JsonProcessingException { throws JsonProcessingException {
ErrorCode err = mr.verifyRequest(headers); ErrorCode err = mr.verifyRequest(headers);
if (err != ErrorCode.ERR_OK) { if (err != ErrorCode.ERR_OK) {
@ -363,33 +409,40 @@ public class DisposeNodeInfoController {
if (devList != null && devList.size() > 0) { if (devList != null && devList.size() > 0) {
devList.forEach(v -> { devList.forEach(v -> {
DeviceCapacityData cpData = new DeviceCapacityData(v.getDevCaps()); DeviceCapacityData cpData = new DeviceCapacityData(v.getDevCaps());
cpData.setId(v.getId().toString()); cpData.setId(v.getId()
.toString());
cpData.setStatus(ErrorCode.ERR_OK.getCode()); cpData.setStatus(ErrorCode.ERR_OK.getCode());
cpData.setMessage(ErrorCode.ERR_OK.getMsg()); cpData.setMessage(ErrorCode.ERR_OK.getMsg());
rspInfo.getItems().add(cpData); rspInfo.getItems()
.add(cpData);
}); });
} }
} else { } else {
for (String v : reqInfo.getId()) { for (String v : reqInfo.getId()) {
DisposeDevice dev = disposeNodeManager.getDisposeDeviceById(Long.valueOf(v)); 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()); DeviceCapacityData cpData = new DeviceCapacityData(dev.getDevCaps());
cpData.setId(dev.getId().toString()); cpData.setId(dev.getId()
.toString());
cpData.setStatus(ErrorCode.ERR_OK.getCode()); cpData.setStatus(ErrorCode.ERR_OK.getCode());
cpData.setMessage(ErrorCode.ERR_OK.getMsg()); cpData.setMessage(ErrorCode.ERR_OK.getMsg());
rspInfo.getItems().add(cpData); rspInfo.getItems()
.add(cpData);
} else { } else {
DeviceCapacityData cpData = new DeviceCapacityData(); DeviceCapacityData cpData = new DeviceCapacityData();
cpData.setId(v); cpData.setId(v);
cpData.setStatus(ErrorCode.ERR_NOSUCHDEVICE.getCode()); cpData.setStatus(ErrorCode.ERR_NOSUCHDEVICE.getCode());
cpData.setMessage(ErrorCode.ERR_NOSUCHDEVICE.getMsg()); cpData.setMessage(ErrorCode.ERR_NOSUCHDEVICE.getMsg());
rspInfo.getItems().add(cpData); rspInfo.getItems()
.add(cpData);
} }
} }
} }
String rspMessage = 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); return ProtocolRespDTO.result(ErrorCode.ERR_OK, rspMessage, ConstValue.Protocol.CRYPTO_NONE);
} }
@ -408,7 +461,7 @@ public class DisposeNodeInfoController {
//@JsonView(DisposeCapacity.CapacityView.class) //@JsonView(DisposeCapacity.CapacityView.class)
public ProtocolRespDTO getDisposeNodeList(@RequestBody ProtocolReqDTO mr, public ProtocolRespDTO getDisposeNodeList(@RequestBody ProtocolReqDTO mr,
@RequestHeader HttpHeaders headers) @RequestHeader HttpHeaders headers)
throws JsonProcessingException { throws JsonProcessingException {
boolean isGetAllNode = false; boolean isGetAllNode = false;
IDArrayReq reqInfo = null; IDArrayReq reqInfo = null;
@ -418,7 +471,8 @@ public class DisposeNodeInfoController {
return ProtocolRespDTO.result(err); return ProtocolRespDTO.result(err);
} }
if (mr.getMsgContent() == null || mr.getMsgContent().length() == 0) { if (mr.getMsgContent() == null || mr.getMsgContent()
.length() == 0) {
isGetAllNode = true; isGetAllNode = true;
} else { } else {
reqInfo = mr.getRequestObject(IDArrayReq.class); reqInfo = mr.getRequestObject(IDArrayReq.class);
@ -436,36 +490,42 @@ public class DisposeNodeInfoController {
if (devList != null && devList.size() > 0) { if (devList != null && devList.size() > 0) {
devList.forEach(v -> { devList.forEach(v -> {
DisposeNodeData dpData = DisposeNodeData.builder() DisposeNodeData dpData = DisposeNodeData.builder()
.type(v.getType()) .type(v.getType())
.name(v.getName()) .name(v.getName())
.ip(v.getIpAddr()) .ip(v.getIpAddr())
.build(); .build();
dpData.setId(v.getId().toString()); dpData.setId(v.getId()
.toString());
dpData.setStatus(ErrorCode.ERR_OK.getCode()); dpData.setStatus(ErrorCode.ERR_OK.getCode());
dpData.setMessage(ErrorCode.ERR_OK.getMsg()); dpData.setMessage(ErrorCode.ERR_OK.getMsg());
rspInfo.getItems().add(dpData); rspInfo.getItems()
.add(dpData);
}); });
} }
} else { } else {
for (String v : reqInfo.getId()) { for (String v : reqInfo.getId()) {
DisposeDevice dev = disposeNodeManager.getDisposeDeviceById(Long.valueOf(v)); 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() DisposeNodeData dpData = DisposeNodeData.builder()
.type(dev.getType()) .type(dev.getType())
.name(dev.getName()) .name(dev.getName())
.ip(dev.getIpAddr()) .ip(dev.getIpAddr())
.build(); .build();
dpData.setId(dev.getId().toString()); dpData.setId(dev.getId()
.toString());
dpData.setStatus(ErrorCode.ERR_OK.getCode()); dpData.setStatus(ErrorCode.ERR_OK.getCode());
dpData.setMessage(ErrorCode.ERR_OK.getMsg()); dpData.setMessage(ErrorCode.ERR_OK.getMsg());
rspInfo.getItems().add(dpData); rspInfo.getItems()
.add(dpData);
} else { } else {
DisposeNodeData dpData = new DisposeNodeData(); DisposeNodeData dpData = new DisposeNodeData();
dpData.setId(v); dpData.setId(v);
dpData.setStatus(ErrorCode.ERR_NOSUCHDEVICE.getCode()); dpData.setStatus(ErrorCode.ERR_NOSUCHDEVICE.getCode());
dpData.setMessage(ErrorCode.ERR_NOSUCHDEVICE.getMsg()); dpData.setMessage(ErrorCode.ERR_NOSUCHDEVICE.getMsg());
rspInfo.getItems().add(dpData); rspInfo.getItems()
.add(dpData);
} }
} }
} }
@ -485,7 +545,7 @@ public class DisposeNodeInfoController {
@ApiOperation("处置节点详细信息") @ApiOperation("处置节点详细信息")
public ProtocolRespDTO getDisposeNodeDetails(@RequestBody ProtocolReqDTO mr, public ProtocolRespDTO getDisposeNodeDetails(@RequestBody ProtocolReqDTO mr,
@RequestHeader HttpHeaders headers) @RequestHeader HttpHeaders headers)
throws JsonProcessingException { throws JsonProcessingException {
ErrorCode err = mr.verifyRequest(headers); ErrorCode err = mr.verifyRequest(headers);
if (err != ErrorCode.ERR_OK) { if (err != ErrorCode.ERR_OK) {
@ -503,47 +563,53 @@ public class DisposeNodeInfoController {
if (devList != null && devList.size() > 0) { if (devList != null && devList.size() > 0) {
devList.forEach(v -> { devList.forEach(v -> {
DisposeNodeData dpData = new DisposeNodeData( DisposeNodeData dpData = new DisposeNodeData(
v.getType(), v.getType(),
v.getName(), v.getName(),
v.getIpAddr(), v.getIpAddr(),
v.getAreaCode(), v.getAreaCode(),
v.getManufacturer(), v.getManufacturer(),
v.getModel(), v.getModel(),
v.getVersion(), v.getVersion(),
v.getReadme(), v.getReadme(),
v.getDevCaps() v.getDevCaps()
); );
dpData.setId(v.getId().toString()); dpData.setId(v.getId()
.toString());
dpData.setStatus(ErrorCode.ERR_OK.getCode()); dpData.setStatus(ErrorCode.ERR_OK.getCode());
dpData.setMessage(ErrorCode.ERR_OK.getMsg()); dpData.setMessage(ErrorCode.ERR_OK.getMsg());
rspInfo.getItems().add(dpData); rspInfo.getItems()
.add(dpData);
}); });
} }
} else { } else {
for (String v : reqInfo.getId()) { for (String v : reqInfo.getId()) {
DisposeDevice dev = disposeNodeManager.getDisposeDeviceById(Long.valueOf(v)); 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( DisposeNodeData dpData = new DisposeNodeData(
dev.getType(), dev.getType(),
dev.getName(), dev.getName(),
dev.getIpAddr(), dev.getIpAddr(),
dev.getAreaCode(), dev.getAreaCode(),
dev.getManufacturer(), dev.getManufacturer(),
dev.getModel(), dev.getModel(),
dev.getVersion(), dev.getVersion(),
dev.getReadme(), dev.getReadme(),
dev.getDevCaps() dev.getDevCaps()
); );
dpData.setId(dev.getId().toString()); dpData.setId(dev.getId()
.toString());
dpData.setStatus(ErrorCode.ERR_OK.getCode()); dpData.setStatus(ErrorCode.ERR_OK.getCode());
dpData.setMessage(ErrorCode.ERR_OK.getMsg()); dpData.setMessage(ErrorCode.ERR_OK.getMsg());
rspInfo.getItems().add(dpData); rspInfo.getItems()
.add(dpData);
} else { } else {
DisposeNodeData dpData = new DisposeNodeData(); DisposeNodeData dpData = new DisposeNodeData();
dpData.setId(v); dpData.setId(v);
dpData.setStatus(ErrorCode.ERR_NOSUCHDEVICE.getCode()); dpData.setStatus(ErrorCode.ERR_NOSUCHDEVICE.getCode());
dpData.setMessage(ErrorCode.ERR_NOSUCHDEVICE.getMsg()); dpData.setMessage(ErrorCode.ERR_NOSUCHDEVICE.getMsg());
rspInfo.getItems().add(dpData); rspInfo.getItems()
.add(dpData);
} }
} }
} }
@ -563,7 +629,7 @@ public class DisposeNodeInfoController {
@ApiOperation("获取正在进行的处置任务") @ApiOperation("获取正在进行的处置任务")
public ProtocolRespDTO getRunningDisposeTaskList(@RequestBody ProtocolReqDTO mr, public ProtocolRespDTO getRunningDisposeTaskList(@RequestBody ProtocolReqDTO mr,
@RequestHeader HttpHeaders headers) @RequestHeader HttpHeaders headers)
throws JsonProcessingException { throws JsonProcessingException {
ErrorCode err = mr.verifyRequest(headers); ErrorCode err = mr.verifyRequest(headers);
if (err != ErrorCode.ERR_OK) { if (err != ErrorCode.ERR_OK) {
@ -574,49 +640,65 @@ public class DisposeNodeInfoController {
NodeTaskRsp rspInfo = new NodeTaskRsp(); NodeTaskRsp rspInfo = new NodeTaskRsp();
List<DisposeDevice> valuableData = disposeNodeManager.getAllDisposeDevice() List<DisposeDevice> valuableData = disposeNodeManager.getAllDisposeDevice()
.parallelStream() .parallelStream()
.filter(v -> reqInfo.getId().length == 0 .filter(v -> reqInfo.getId().length == 0
|| Arrays.stream(reqInfo.getId()).anyMatch(s -> s.equals(v.getId().toString()))) || Arrays.stream(reqInfo.getId())
.collect(Collectors.toList()); .anyMatch(s -> s.equals(v.getId()
.toString())))
.collect(Collectors.toList());
valuableData.parallelStream().forEach(v -> { valuableData.parallelStream()
NodeTaskData taskData = new NodeTaskData(); .forEach(v -> {
rspInfo.getItems().add(taskData); NodeTaskData taskData = new NodeTaskData();
taskData.setId(v.getId().toString()); rspInfo.getItems()
taskData.setStatus(ErrorCode.ERR_OK.getCode()); .add(taskData);
taskData.setMessage(ErrorCode.ERR_OK.getMsg()); taskData.setId(v.getId()
.toString());
taskData.setStatus(ErrorCode.ERR_OK.getCode());
taskData.setMessage(ErrorCode.ERR_OK.getMsg());
taskService.getNodeAllRunningTask(v.getId()).parallelStream().forEach(k -> { taskService.getNodeAllRunningTask(v.getId())
Long tmLong = Timestamp.valueOf(k.getBeginTime()).toInstant().toEpochMilli() / 1000; .parallelStream()
Long endTm = Timestamp.valueOf(k.getPlanEndTime()).toInstant().toEpochMilli() / 1000; .forEach(k -> {
Long diff = endTm - tmLong; 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() TaskInfoData taskInfoData = TaskInfoData.builder()
.taskId(k.getId().toString()) .taskId(k.getId()
.type(k.getType()) .toString())
.startTime(tmLong.intValue()) .type(k.getType())
.disposeTime(diff.intValue()) .startTime(tmLong.intValue())
.disposeIp(k.getDisposeIp()) .disposeTime(diff.intValue())
.flowAttack(0) .disposeIp(k.getDisposeIp())
.flowClean(0) .flowAttack(0)
.build(); .flowClean(0)
.build();
taskData.getTaskArray().add(taskInfoData); taskData.getTaskArray()
}); .add(taskInfoData);
}); });
});
if (reqInfo.getId().length != 0) { if (reqInfo.getId().length != 0) {
List<String> unExists = Arrays.stream(reqInfo.getId()) List<String> unExists = Arrays.stream(reqInfo.getId())
.filter(v -> valuableData.parallelStream().noneMatch(k -> k.getId() == Long.parseLong(v))) .filter(v -> valuableData.parallelStream()
.collect(Collectors.toList()); .noneMatch(k -> k.getId() == Long.parseLong(v)))
.collect(Collectors.toList());
unExists.parallelStream().forEach(v -> { unExists.parallelStream()
NodeTaskData taskData = new NodeTaskData(); .forEach(v -> {
rspInfo.getItems().add(taskData); NodeTaskData taskData = new NodeTaskData();
taskData.setId(v); rspInfo.getItems()
taskData.setStatus(ErrorCode.ERR_NOSUCHDEVICE.getCode()); .add(taskData);
taskData.setMessage(ErrorCode.ERR_NOSUCHDEVICE.getMsg()); taskData.setId(v);
}); taskData.setStatus(ErrorCode.ERR_NOSUCHDEVICE.getCode());
taskData.setMessage(ErrorCode.ERR_NOSUCHDEVICE.getMsg());
});
} }
return ProtocolRespDTO.result(err, rspInfo); return ProtocolRespDTO.result(err, rspInfo);
@ -635,7 +717,7 @@ public class DisposeNodeInfoController {
@ApiOperation("获取所有处置任务") @ApiOperation("获取所有处置任务")
public ProtocolRespDTO getAllDisposeTaskList(@RequestBody ProtocolReqDTO mr, public ProtocolRespDTO getAllDisposeTaskList(@RequestBody ProtocolReqDTO mr,
@RequestHeader HttpHeaders headers) @RequestHeader HttpHeaders headers)
throws JsonProcessingException { throws JsonProcessingException {
ErrorCode err = mr.verifyRequest(headers); ErrorCode err = mr.verifyRequest(headers);
if (err != ErrorCode.ERR_OK) { if (err != ErrorCode.ERR_OK) {
@ -646,49 +728,65 @@ public class DisposeNodeInfoController {
NodeTaskRsp rspInfo = new NodeTaskRsp(); NodeTaskRsp rspInfo = new NodeTaskRsp();
List<DisposeDevice> valuableData = disposeNodeManager.getAllDisposeDevice() List<DisposeDevice> valuableData = disposeNodeManager.getAllDisposeDevice()
.parallelStream() .parallelStream()
.filter(v -> reqInfo.getId().length == 0 .filter(v -> reqInfo.getId().length == 0
|| Arrays.stream(reqInfo.getId()).anyMatch(s -> s.equals(v.getId().toString()))) || Arrays.stream(reqInfo.getId())
.collect(Collectors.toList()); .anyMatch(s -> s.equals(v.getId()
.toString())))
.collect(Collectors.toList());
valuableData.parallelStream().forEach(v -> { valuableData.parallelStream()
NodeTaskData taskData = new NodeTaskData(); .forEach(v -> {
rspInfo.getItems().add(taskData); NodeTaskData taskData = new NodeTaskData();
taskData.setId(v.getId().toString()); rspInfo.getItems()
taskData.setStatus(ErrorCode.ERR_OK.getCode()); .add(taskData);
taskData.setMessage(ErrorCode.ERR_OK.getMsg()); taskData.setId(v.getId()
.toString());
taskData.setStatus(ErrorCode.ERR_OK.getCode());
taskData.setMessage(ErrorCode.ERR_OK.getMsg());
taskService.getNodeAllRunningTask(v.getId()).parallelStream().forEach(k -> { taskService.getNodeAllRunningTask(v.getId())
Long tmLong = Timestamp.valueOf(k.getBeginTime()).toInstant().toEpochMilli() / 1000; .parallelStream()
Long endTm = Timestamp.valueOf(k.getPlanEndTime()).toInstant().toEpochMilli() / 1000; .forEach(k -> {
Long diff = endTm - tmLong; 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() TaskInfoData taskInfoData = TaskInfoData.builder()
.taskId(k.getId().toString()) .taskId(k.getId()
.type(k.getType()) .toString())
.startTime(tmLong.intValue()) .type(k.getType())
.disposeTime(diff.intValue()) .startTime(tmLong.intValue())
.disposeIp(k.getDisposeIp()) .disposeTime(diff.intValue())
.flowAttack(0) .disposeIp(k.getDisposeIp())
.flowClean(0) .flowAttack(0)
.build(); .flowClean(0)
.build();
taskData.getTaskArray().add(taskInfoData); taskData.getTaskArray()
}); .add(taskInfoData);
}); });
});
if (reqInfo.getId().length != 0) { if (reqInfo.getId().length != 0) {
List<String> unExists = Arrays.stream(reqInfo.getId()) List<String> unExists = Arrays.stream(reqInfo.getId())
.filter(v -> valuableData.parallelStream().noneMatch(k -> k.getId() == Long.parseLong(v))) .filter(v -> valuableData.parallelStream()
.collect(Collectors.toList()); .noneMatch(k -> k.getId() == Long.parseLong(v)))
.collect(Collectors.toList());
unExists.parallelStream().forEach(v -> { unExists.parallelStream()
NodeTaskData taskData = new NodeTaskData(); .forEach(v -> {
rspInfo.getItems().add(taskData); NodeTaskData taskData = new NodeTaskData();
taskData.setId(v); rspInfo.getItems()
taskData.setStatus(ErrorCode.ERR_NOSUCHDEVICE.getCode()); .add(taskData);
taskData.setMessage(ErrorCode.ERR_NOSUCHDEVICE.getMsg()); taskData.setId(v);
}); taskData.setStatus(ErrorCode.ERR_NOSUCHDEVICE.getCode());
taskData.setMessage(ErrorCode.ERR_NOSUCHDEVICE.getMsg());
});
} }
return ProtocolRespDTO.result(err, rspInfo); return ProtocolRespDTO.result(err, rspInfo);