From 41029fd9c3ff64aca135c9eb9b80f035771d30b9 Mon Sep 17 00:00:00 2001 From: HuangXin Date: Thu, 14 May 2020 17:47:21 +0800 Subject: [PATCH] =?UTF-8?q?OCT=20REM:=201.=20=E5=88=A0=E9=99=A4=E6=97=A0?= =?UTF-8?q?=E6=95=88=E5=8F=98=E9=87=8F=EF=BC=8C=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/DisposeNodeInfoController.java | 241 ++++++------------ .../controller/DisposeTaskController.java | 9 +- 2 files changed, 85 insertions(+), 165 deletions(-) diff --git a/src/main/java/com/dispose/controller/DisposeNodeInfoController.java b/src/main/java/com/dispose/controller/DisposeNodeInfoController.java index 2a741ba4..3ee7d702 100644 --- a/src/main/java/com/dispose/controller/DisposeNodeInfoController.java +++ b/src/main/java/com/dispose/controller/DisposeNodeInfoController.java @@ -59,12 +59,6 @@ public class DisposeNodeInfoController { @Resource private TaskService taskService; - /** - * The Object mapper. - */ - @Resource - private ObjectMapper objectMapper; - /** * The Dispose node manager. */ @@ -102,8 +96,7 @@ public class DisposeNodeInfoController { List devs = disposeNodeManager.getAllDisposeDevice(); if (devs != null && devs.size() > 0) { - devs.forEach(v -> linkStatusListRsp.getItems() - .add(LinkStatusRsp.builder() + devs.forEach(v -> linkStatusListRsp.getItems().add(LinkStatusRsp.builder() .online(v.getLinkStatus()) .id(v.getId().toString()) .status(ErrorCode.ERR_OK.getCode()) @@ -113,23 +106,20 @@ public class DisposeNodeInfoController { } else { for (String v : reqInfo.getId()) { DisposeDevice dev = disposeNodeManager.getDisposeDeviceById(Long.valueOf(v)); - if (dev != null && dev.getId() - .equals(Long.valueOf(v))) { - linkStatusListRsp.getItems() - .add(LinkStatusRsp.builder() - .online(dev.getLinkStatus()) - .id(dev.getId().toString()) - .status(ErrorCode.ERR_OK.getCode()) - .message(ErrorCode.ERR_OK.getMsg()) - .build()); + if (dev != null && dev.getId().equals(Long.valueOf(v))) { + linkStatusListRsp.getItems().add(LinkStatusRsp.builder() + .online(dev.getLinkStatus()) + .id(dev.getId().toString()) + .status(ErrorCode.ERR_OK.getCode()) + .message(ErrorCode.ERR_OK.getMsg()) + .build()); } else { - linkStatusListRsp.getItems() - .add(LinkStatusRsp.builder() - .online(0) - .id(v) - .status(ErrorCode.ERR_NOSUCHDEVICE.getCode()) - .message(ErrorCode.ERR_NOSUCHDEVICE.getMsg()). - build()); + linkStatusListRsp.getItems().add(LinkStatusRsp.builder() + .online(0) + .id(v) + .status(ErrorCode.ERR_NOSUCHDEVICE.getCode()) + .message(ErrorCode.ERR_NOSUCHDEVICE.getMsg()) + .build()); } } } @@ -158,7 +148,6 @@ public class DisposeNodeInfoController { } IDArrayReq reqInfo = mr.getRequestObject(IDArrayReq.class); - List rspInfo = new ArrayList<>(); VersionListRsp versionListRsp = new VersionListRsp(); versionListRsp.setItems(new ArrayList<>()); @@ -166,8 +155,7 @@ public class DisposeNodeInfoController { List devList = disposeNodeManager.getAllDisposeDevice(); if (devList != null && devList.size() > 0) { - devList.forEach(v -> versionListRsp.getItems() - .add(VersionRsp.builder() + devList.forEach(v -> versionListRsp.getItems().add(VersionRsp.builder() .id(v.getId().toString()) .version(v.getVersion()) .status(ErrorCode.ERR_OK.getCode()) @@ -177,23 +165,19 @@ public class DisposeNodeInfoController { } else { for (String v : reqInfo.getId()) { DisposeDevice dev = disposeNodeManager.getDisposeDeviceById(Long.valueOf(v)); - VersionRsp ver; - if (dev != null && dev.getId() - .equals(Long.valueOf(v))) { - versionListRsp.getItems() - .add(VersionRsp.builder() - .id(dev.getId().toString()) - .version(dev.getVersion()) - .status(ErrorCode.ERR_OK.getCode()) - .message(ErrorCode.ERR_OK.getMsg()) - .build()); + if (dev != null && dev.getId().equals(Long.valueOf(v))) { + versionListRsp.getItems().add(VersionRsp.builder() + .id(dev.getId().toString()) + .version(dev.getVersion()) + .status(ErrorCode.ERR_OK.getCode()) + .message(ErrorCode.ERR_OK.getMsg()) + .build()); } else { - versionListRsp.getItems() - .add(VersionRsp.builder() - .id(v) - .status(ErrorCode.ERR_NOSUCHDEVICE.getCode()) - .message(ErrorCode.ERR_NOSUCHDEVICE.getMsg()) - .build()); + versionListRsp.getItems().add(VersionRsp.builder() + .id(v) + .status(ErrorCode.ERR_NOSUCHDEVICE.getCode()) + .message(ErrorCode.ERR_NOSUCHDEVICE.getMsg()) + .build()); } } @@ -231,68 +215,38 @@ public class DisposeNodeInfoController { List 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(), - ErrorCode.ERR_OK - ))); + 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 + ))); } } else { for (String v : reqInfo.getId()) { DisposeDevice dev = disposeNodeManager.getDisposeDeviceById(Long.valueOf(v)); - if (dev != null - && 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(), - ErrorCode.ERR_OK - )); + if (dev != null && 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(), + ErrorCode.ERR_OK + )); } else { - rspInfo.getItems() - .add(new DeviceInfoData( - v, - ErrorCode.ERR_NOSUCHDEVICE - )); + rspInfo.getItems().add(new DeviceInfoData(v, ErrorCode.ERR_NOSUCHDEVICE)); } } } @@ -332,40 +286,34 @@ 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); + String rspMessage = new ObjectMapper() + .writerWithView(DisposeCapacity.CapacityView.class) + .writeValueAsString(rspInfo); return ProtocolRespDTO.result(ErrorCode.ERR_OK, rspMessage, ConstValue.Protocol.CRYPTO_NONE); } @@ -402,40 +350,33 @@ 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); + String rspMessage = new ObjectMapper().writerWithView(DisposeCapacity.DependIpView.class) + .writeValueAsString(rspInfo); return ProtocolRespDTO.result(ErrorCode.ERR_OK, rspMessage, ConstValue.Protocol.CRYPTO_NONE); } @@ -488,30 +429,25 @@ 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); @@ -565,19 +501,16 @@ 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(), @@ -589,19 +522,16 @@ 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); } } } @@ -634,8 +564,7 @@ public class DisposeNodeInfoController { List valuableData = disposeNodeManager.getAllDisposeDevice() .stream() .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.forEach(v -> { @@ -712,9 +641,7 @@ public class DisposeNodeInfoController { List valuableData = disposeNodeManager.getAllDisposeDevice() .stream() .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.forEach(v -> { diff --git a/src/main/java/com/dispose/controller/DisposeTaskController.java b/src/main/java/com/dispose/controller/DisposeTaskController.java index b6609815..af01c7a4 100644 --- a/src/main/java/com/dispose/controller/DisposeTaskController.java +++ b/src/main/java/com/dispose/controller/DisposeTaskController.java @@ -5,7 +5,6 @@ import com.dispose.common.ErrorCode; import com.dispose.common.FlowDirection; import com.dispose.common.Helper; import com.dispose.manager.TaskCacheManager; -import com.dispose.mapper.DisposeTaskMapper; import com.dispose.pojo.dto.ProtocolReqDTO; import com.dispose.pojo.dto.ProtocolRespDTO; import com.dispose.pojo.entity.DisposeDevice; @@ -77,12 +76,6 @@ public class DisposeTaskController { @Resource private UserAccountService userAccountService; - /** - * The Dispose task manager. - */ - @Resource - private DisposeTaskMapper disposeTaskMapper; - /** * Task start protocol resp dto. * @@ -229,7 +222,7 @@ public class DisposeTaskController { rspInfo.getItems().add(taskData); } else { ret.forEach(k -> { - if(k.getFirstParam() == ErrorCode.ERR_OK) { + if (k.getFirstParam() == ErrorCode.ERR_OK) { ErrorCode retError = k.getFirstParam(); TaskInfoDetail taskInfo = k.getSecondParam(); taskData.setId(String.valueOf(taskInfo.getDeviceId()));