diff --git a/src/main/java/com/dispose/config/SetupInit.java b/src/main/java/com/dispose/config/SetupInit.java index 0d38c065..87f34692 100644 --- a/src/main/java/com/dispose/config/SetupInit.java +++ b/src/main/java/com/dispose/config/SetupInit.java @@ -3,11 +3,12 @@ package com.dispose.config; import com.dispose.common.GlobalVar; import com.dispose.service.DisposeNodeManager; import com.dispose.service.TaskService; -import javax.annotation.Resource; import lombok.extern.slf4j.Slf4j; import org.springframework.boot.CommandLineRunner; import org.springframework.stereotype.Component; +import javax.annotation.Resource; + /** * The type Setup init. */ diff --git a/src/main/java/com/dispose/controller/DisposeNodeInfoController.java b/src/main/java/com/dispose/controller/DisposeNodeInfoController.java index 9267a277..d7577528 100644 --- a/src/main/java/com/dispose/controller/DisposeNodeInfoController.java +++ b/src/main/java/com/dispose/controller/DisposeNodeInfoController.java @@ -639,13 +639,13 @@ public class DisposeNodeInfoController { NodeTaskRsp rspInfo = new NodeTaskRsp(); List valuableData = disposeNodeManager.getAllDisposeDevice() - .parallelStream() + .stream() .filter(v -> reqInfo.getId().length == 0 || Arrays.stream(reqInfo.getId()) .anyMatch(s -> s.equals(v.getId().toString()))) .collect(Collectors.toList()); - valuableData.parallelStream().forEach(v -> { + valuableData.forEach(v -> { NodeTaskData taskData = new NodeTaskData(); rspInfo.getItems().add(taskData); taskData.setId(v.getId().toString()); @@ -658,7 +658,7 @@ public class DisposeNodeInfoController { taskData.setStatus(ErrorCode.ERR_NOSUCHTASK.getCode()); taskData.setMessage(ErrorCode.ERR_NOSUCHTASK.getMsg()); } else { - runTasks.parallelStream().forEach(k -> { + runTasks.forEach(k -> { int diff = Helper.getTimestampDiff(k.getBeginTime(), k.getPlanEndTime()); TaskInfoData taskInfoData = TaskInfoData.builder() @@ -678,10 +678,10 @@ public class DisposeNodeInfoController { if (reqInfo.getId().length != 0) { List unExists = Arrays.stream(reqInfo.getId()) - .filter(v -> valuableData.parallelStream().noneMatch(k -> k.getId() == Long.parseLong(v))) + .filter(v -> valuableData.stream().noneMatch(k -> k.getId() == Long.parseLong(v))) .collect(Collectors.toList()); - unExists.parallelStream().forEach(v -> { + unExists.forEach(v -> { NodeTaskData taskData = new NodeTaskData(); rspInfo.getItems().add(taskData); taskData.setId(v); @@ -717,14 +717,14 @@ public class DisposeNodeInfoController { NodeTaskRsp rspInfo = new NodeTaskRsp(); List valuableData = disposeNodeManager.getAllDisposeDevice() - .parallelStream() + .stream() .filter(v -> reqInfo.getId().length == 0 || Arrays.stream(reqInfo.getId()) .anyMatch(s -> s.equals(v.getId() .toString()))) .collect(Collectors.toList()); - valuableData.parallelStream().forEach(v -> { + valuableData.forEach(v -> { NodeTaskData taskData = new NodeTaskData(); rspInfo.getItems().add(taskData); taskData.setId(v.getId().toString()); @@ -737,7 +737,7 @@ public class DisposeNodeInfoController { taskData.setStatus(ErrorCode.ERR_NOSUCHTASK.getCode()); taskData.setMessage(ErrorCode.ERR_NOSUCHTASK.getMsg()); } else { - runTasks.parallelStream().forEach(k -> { + runTasks.forEach(k -> { int diff = Helper.getTimestampDiff(k.getBeginTime(), k.getPlanEndTime()); TaskInfoData taskInfoData = TaskInfoData.builder() @@ -758,10 +758,10 @@ public class DisposeNodeInfoController { if (reqInfo.getId().length != 0) { List unExists = Arrays.stream(reqInfo.getId()) - .filter(v -> valuableData.parallelStream().noneMatch(k -> k.getId() == Long.parseLong(v))) + .filter(v -> valuableData.stream().noneMatch(k -> k.getId() == Long.parseLong(v))) .collect(Collectors.toList()); - unExists.parallelStream().forEach(v -> { + unExists.forEach(v -> { NodeTaskData taskData = new NodeTaskData(); rspInfo.getItems().add(taskData); taskData.setId(v); diff --git a/src/main/java/com/dispose/controller/DisposeTaskController.java b/src/main/java/com/dispose/controller/DisposeTaskController.java index ec1faee8..829fd7b6 100644 --- a/src/main/java/com/dispose/controller/DisposeTaskController.java +++ b/src/main/java/com/dispose/controller/DisposeTaskController.java @@ -396,12 +396,12 @@ public class DisposeTaskController { NodeTaskRsp rspInfo = new NodeTaskRsp(); List valuableData = disposeNodeManager.getAllDisposeDevice() - .parallelStream() + .stream() .filter(v -> reqInfo.getId().length == 0 || Arrays.stream(reqInfo.getId()).anyMatch(s -> s.equals(v.getId().toString()))) .collect(Collectors.toList()); - valuableData.parallelStream().forEach(v -> { + valuableData.forEach(v -> { NodeTaskData taskData = new NodeTaskData(); rspInfo.getItems().add(taskData); taskData.setId(v.getId().toString()); @@ -437,10 +437,10 @@ public class DisposeTaskController { if (reqInfo.getId().length != 0) { List unExists = Arrays.stream(reqInfo.getId()) - .filter(v -> valuableData.parallelStream().noneMatch(k -> k.getId() == Long.parseLong(v))) + .filter(v -> valuableData.stream().noneMatch(k -> k.getId() == Long.parseLong(v))) .collect(Collectors.toList()); - unExists.parallelStream().forEach(v -> { + unExists.forEach(v -> { NodeTaskData taskData = new NodeTaskData(); rspInfo.getItems().add(taskData); taskData.setId(v); @@ -477,12 +477,12 @@ public class DisposeTaskController { TaskInfoRsp rspInfo = new TaskInfoRsp(); List valuableData = taskService.getAllTask() - .parallelStream() + .stream() .filter(v -> reqInfo.getTaskId().length == 0 || Arrays.stream(reqInfo.getTaskId()).anyMatch(s -> s.equals(v.getId().toString()))) .collect(Collectors.toList()); - valuableData.parallelStream().forEach(v -> { + valuableData.forEach(v -> { int diff = Helper.getTimestampDiff(v.getBeginTime(), v.getPlanEndTime()); TaskInfoData taskInfoData = TaskInfoData.builder() @@ -506,10 +506,10 @@ public class DisposeTaskController { if (reqInfo.getTaskId().length != 0) { List unExists = Arrays.stream(reqInfo.getTaskId()) - .filter(v -> valuableData.parallelStream().noneMatch(k -> k.getId() == Long.parseLong(v))) + .filter(v -> valuableData.stream().noneMatch(k -> k.getId() == Long.parseLong(v))) .collect(Collectors.toList()); - unExists.parallelStream().forEach(v -> { + unExists.forEach(v -> { TaskInfoData taskData = new TaskInfoData(); rspInfo.getItems().add(taskData); taskData.setId(v); diff --git a/src/main/java/com/dispose/dispose/DeviceRouter.java b/src/main/java/com/dispose/dispose/DeviceRouter.java index f1da9f13..0ca871d2 100644 --- a/src/main/java/com/dispose/dispose/DeviceRouter.java +++ b/src/main/java/com/dispose/dispose/DeviceRouter.java @@ -5,6 +5,7 @@ import com.dispose.common.GlobalVar; import com.dispose.common.IPAddrType; import com.dispose.dispose.impl.DPTechImpl; import com.dispose.dispose.impl.VirtualDeviceImpl; + import java.util.concurrent.ConcurrentHashMap; /** diff --git a/src/main/java/com/dispose/dispose/DisposeEntryManager.java b/src/main/java/com/dispose/dispose/DisposeEntryManager.java index 31b7f115..c193df5f 100644 --- a/src/main/java/com/dispose/dispose/DisposeEntryManager.java +++ b/src/main/java/com/dispose/dispose/DisposeEntryManager.java @@ -5,6 +5,7 @@ import com.dispose.common.DeviceCapacity; import com.dispose.common.ErrorCode; import com.dispose.dispose.po.DeviceInfo; import com.dispose.pojo.po.DisposeDeviceCapacity; + import java.util.List; /** diff --git a/src/main/java/com/dispose/dispose/impl/VirtualDeviceImpl.java b/src/main/java/com/dispose/dispose/impl/VirtualDeviceImpl.java index 4f6e8d39..ca79766f 100644 --- a/src/main/java/com/dispose/dispose/impl/VirtualDeviceImpl.java +++ b/src/main/java/com/dispose/dispose/impl/VirtualDeviceImpl.java @@ -7,6 +7,7 @@ import com.dispose.common.IPAddrType; import com.dispose.dispose.DisposeEntryManager; import com.dispose.dispose.po.DeviceInfo; import com.dispose.pojo.po.DisposeDeviceCapacity; + import java.util.ArrayList; import java.util.List; diff --git a/src/main/java/com/dispose/dispose/po/DeviceInfo.java b/src/main/java/com/dispose/dispose/po/DeviceInfo.java index 4c4c30cf..1f415a89 100644 --- a/src/main/java/com/dispose/dispose/po/DeviceInfo.java +++ b/src/main/java/com/dispose/dispose/po/DeviceInfo.java @@ -1,10 +1,11 @@ package com.dispose.dispose.po; -import java.io.Serializable; import lombok.Builder; import lombok.Data; import lombok.NoArgsConstructor; +import java.io.Serializable; + /** * The type Device info. */ diff --git a/src/main/java/com/dispose/exception/GlobalExceptionHandler.java b/src/main/java/com/dispose/exception/GlobalExceptionHandler.java index 48d1000c..6855f5b7 100644 --- a/src/main/java/com/dispose/exception/GlobalExceptionHandler.java +++ b/src/main/java/com/dispose/exception/GlobalExceptionHandler.java @@ -4,12 +4,13 @@ import com.dispose.common.ConstValue; import com.dispose.common.ErrorCode; import com.dispose.pojo.dto.ProtocolRespDTO; import com.dispose.pojo.po.ReturnStatus; -import javax.servlet.http.HttpServletRequest; import lombok.extern.slf4j.Slf4j; import org.springframework.web.bind.annotation.ControllerAdvice; import org.springframework.web.bind.annotation.ExceptionHandler; import org.springframework.web.bind.annotation.ResponseBody; +import javax.servlet.http.HttpServletRequest; + /** * The type Global exception handler. */ diff --git a/src/main/java/com/dispose/interceptor/SoapPasswordCallbackHandler.java b/src/main/java/com/dispose/interceptor/SoapPasswordCallbackHandler.java index a47f74ea..9c7f086b 100644 --- a/src/main/java/com/dispose/interceptor/SoapPasswordCallbackHandler.java +++ b/src/main/java/com/dispose/interceptor/SoapPasswordCallbackHandler.java @@ -1,9 +1,10 @@ package com.dispose.interceptor; import com.dispose.common.ConstValue; +import org.apache.wss4j.common.ext.WSPasswordCallback; + import javax.security.auth.callback.Callback; import javax.security.auth.callback.CallbackHandler; -import org.apache.wss4j.common.ext.WSPasswordCallback; /** * The type Soap password callback handler. diff --git a/src/main/java/com/dispose/manager/TaskCacheManager.java b/src/main/java/com/dispose/manager/TaskCacheManager.java index a91229b9..52ce339a 100644 --- a/src/main/java/com/dispose/manager/TaskCacheManager.java +++ b/src/main/java/com/dispose/manager/TaskCacheManager.java @@ -2,6 +2,7 @@ package com.dispose.manager; import com.dispose.common.ErrorCode; import com.dispose.pojo.vo.common.TaskInfoDetail; + import java.util.List; /** diff --git a/src/main/java/com/dispose/manager/UserAccountCacheManager.java b/src/main/java/com/dispose/manager/UserAccountCacheManager.java index e2e35289..5b26ff4f 100644 --- a/src/main/java/com/dispose/manager/UserAccountCacheManager.java +++ b/src/main/java/com/dispose/manager/UserAccountCacheManager.java @@ -2,6 +2,7 @@ package com.dispose.manager; import com.dispose.common.ErrorCode; import com.fasterxml.jackson.core.JsonProcessingException; + import java.security.NoSuchAlgorithmException; /** diff --git a/src/main/java/com/dispose/manager/impl/UserAccountCacheManagerImpl.java b/src/main/java/com/dispose/manager/impl/UserAccountCacheManagerImpl.java index 61c62f6a..df3883d0 100644 --- a/src/main/java/com/dispose/manager/impl/UserAccountCacheManagerImpl.java +++ b/src/main/java/com/dispose/manager/impl/UserAccountCacheManagerImpl.java @@ -8,15 +8,16 @@ import com.dispose.manager.UserAccountCacheManager; import com.dispose.pojo.po.UserAccountCache; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.codec.binary.Hex; +import org.springframework.stereotype.Component; + +import javax.annotation.Resource; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; import java.util.Optional; import java.util.Random; import java.util.concurrent.ConcurrentHashMap; -import javax.annotation.Resource; -import lombok.extern.slf4j.Slf4j; -import org.apache.commons.codec.binary.Hex; -import org.springframework.stereotype.Component; /** * The type User account cache manager. diff --git a/src/main/java/com/dispose/mapper/DisposeTaskMapper.java b/src/main/java/com/dispose/mapper/DisposeTaskMapper.java index b8048e47..8cd0fd95 100644 --- a/src/main/java/com/dispose/mapper/DisposeTaskMapper.java +++ b/src/main/java/com/dispose/mapper/DisposeTaskMapper.java @@ -1,12 +1,13 @@ package com.dispose.mapper; import com.dispose.pojo.vo.common.TaskInfoDetail; -import java.util.List; import org.apache.ibatis.annotations.Param; import tk.mybatis.mapper.common.IdsMapper; import tk.mybatis.mapper.common.Mapper; import tk.mybatis.mapper.common.MySqlMapper; +import java.util.List; + /** * The interface Dispose task mapper. */ diff --git a/src/main/java/com/dispose/pojo/entity/DisposeDevice.java b/src/main/java/com/dispose/pojo/entity/DisposeDevice.java index 13abf6c9..0b52b2ca 100644 --- a/src/main/java/com/dispose/pojo/entity/DisposeDevice.java +++ b/src/main/java/com/dispose/pojo/entity/DisposeDevice.java @@ -3,11 +3,6 @@ package com.dispose.pojo.entity; import com.dispose.dispose.po.DeviceInfo; import com.dispose.pojo.po.DisposeDeviceCapacity; import com.fasterxml.jackson.annotation.JsonInclude; -import java.io.Serializable; -import java.util.List; -import javax.persistence.Id; -import javax.persistence.Table; -import javax.persistence.Transient; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Getter; @@ -18,6 +13,12 @@ import tk.mybatis.mapper.annotation.KeySql; import tk.mybatis.mapper.annotation.NameStyle; import tk.mybatis.mapper.code.Style; +import javax.persistence.Id; +import javax.persistence.Table; +import javax.persistence.Transient; +import java.io.Serializable; +import java.util.List; + /** * The type Dispose device. */ diff --git a/src/main/java/com/dispose/pojo/entity/UserAccount.java b/src/main/java/com/dispose/pojo/entity/UserAccount.java index 087892f2..5942ecdc 100644 --- a/src/main/java/com/dispose/pojo/entity/UserAccount.java +++ b/src/main/java/com/dispose/pojo/entity/UserAccount.java @@ -1,8 +1,5 @@ package com.dispose.pojo.entity; -import java.io.Serializable; -import javax.persistence.Id; -import javax.persistence.Table; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Getter; @@ -13,6 +10,10 @@ import tk.mybatis.mapper.annotation.KeySql; import tk.mybatis.mapper.annotation.NameStyle; import tk.mybatis.mapper.code.Style; +import javax.persistence.Id; +import javax.persistence.Table; +import java.io.Serializable; + /** * The type User account. */ diff --git a/src/main/java/com/dispose/pojo/po/DisposeDeviceCapacity.java b/src/main/java/com/dispose/pojo/po/DisposeDeviceCapacity.java index 4d8b6234..29953177 100644 --- a/src/main/java/com/dispose/pojo/po/DisposeDeviceCapacity.java +++ b/src/main/java/com/dispose/pojo/po/DisposeDeviceCapacity.java @@ -1,6 +1,5 @@ package com.dispose.pojo.po; -import java.io.Serializable; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Getter; @@ -8,6 +7,8 @@ import lombok.NoArgsConstructor; import lombok.Setter; import lombok.ToString; +import java.io.Serializable; + /** * The type Dispose device capacity. */ diff --git a/src/main/java/com/dispose/pojo/vo/common/TaskInfoDetail.java b/src/main/java/com/dispose/pojo/vo/common/TaskInfoDetail.java index 136fbd7f..0770c272 100644 --- a/src/main/java/com/dispose/pojo/vo/common/TaskInfoDetail.java +++ b/src/main/java/com/dispose/pojo/vo/common/TaskInfoDetail.java @@ -1,8 +1,5 @@ package com.dispose.pojo.vo.common; -import java.io.Serializable; -import javax.persistence.Id; -import javax.persistence.Table; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; @@ -10,6 +7,10 @@ import lombok.NoArgsConstructor; import tk.mybatis.mapper.annotation.NameStyle; import tk.mybatis.mapper.code.Style; +import javax.persistence.Id; +import javax.persistence.Table; +import java.io.Serializable; + /** * The type Task info detail. */ diff --git a/src/main/java/com/dispose/pojo/vo/device/AddNodeReq.java b/src/main/java/com/dispose/pojo/vo/device/AddNodeReq.java index fb8ca1e3..35c44438 100644 --- a/src/main/java/com/dispose/pojo/vo/device/AddNodeReq.java +++ b/src/main/java/com/dispose/pojo/vo/device/AddNodeReq.java @@ -2,12 +2,13 @@ package com.dispose.pojo.vo.device; import com.dispose.pojo.po.NewNodeInfo; import com.fasterxml.jackson.annotation.JsonInclude; -import java.util.List; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; import lombok.NoArgsConstructor; +import java.util.List; + /** * The type Add node req. */ diff --git a/src/main/java/com/dispose/pojo/vo/device/AddNodeRsp.java b/src/main/java/com/dispose/pojo/vo/device/AddNodeRsp.java index de9243a6..d9c9835d 100644 --- a/src/main/java/com/dispose/pojo/vo/device/AddNodeRsp.java +++ b/src/main/java/com/dispose/pojo/vo/device/AddNodeRsp.java @@ -2,12 +2,13 @@ package com.dispose.pojo.vo.device; import com.fasterxml.jackson.annotation.JsonInclude; -import java.util.ArrayList; -import java.util.List; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; +import java.util.ArrayList; +import java.util.List; + /** * The type Add node rsp. */ diff --git a/src/main/java/com/dispose/pojo/vo/information/DeviceCapacityData.java b/src/main/java/com/dispose/pojo/vo/information/DeviceCapacityData.java index 73382eee..4e9a1d2e 100644 --- a/src/main/java/com/dispose/pojo/vo/information/DeviceCapacityData.java +++ b/src/main/java/com/dispose/pojo/vo/information/DeviceCapacityData.java @@ -5,13 +5,14 @@ import com.dispose.pojo.vo.common.DisposeCapacity; import com.dispose.pojo.vo.common.IDReturnStatus; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonPropertyOrder; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; import lombok.Data; import lombok.EqualsAndHashCode; import lombok.NoArgsConstructor; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + /** * The type Device capacity data. */ diff --git a/src/main/java/com/dispose/pojo/vo/information/DeviceCapacityRsp.java b/src/main/java/com/dispose/pojo/vo/information/DeviceCapacityRsp.java index b4a63862..b0c82e74 100644 --- a/src/main/java/com/dispose/pojo/vo/information/DeviceCapacityRsp.java +++ b/src/main/java/com/dispose/pojo/vo/information/DeviceCapacityRsp.java @@ -2,10 +2,11 @@ package com.dispose.pojo.vo.information; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonPropertyOrder; -import java.util.List; import lombok.Data; import lombok.NoArgsConstructor; +import java.util.List; + /** * The type Device capacity rsp. */ diff --git a/src/main/java/com/dispose/pojo/vo/information/DeviceInfoRsp.java b/src/main/java/com/dispose/pojo/vo/information/DeviceInfoRsp.java index 1e908241..295d3550 100644 --- a/src/main/java/com/dispose/pojo/vo/information/DeviceInfoRsp.java +++ b/src/main/java/com/dispose/pojo/vo/information/DeviceInfoRsp.java @@ -1,8 +1,9 @@ package com.dispose.pojo.vo.information; -import java.util.List; import lombok.Data; +import java.util.List; + /** * The type Device info rsp. */ diff --git a/src/main/java/com/dispose/pojo/vo/information/DisposeNodeData.java b/src/main/java/com/dispose/pojo/vo/information/DisposeNodeData.java index 0c81c6c2..4c91675c 100644 --- a/src/main/java/com/dispose/pojo/vo/information/DisposeNodeData.java +++ b/src/main/java/com/dispose/pojo/vo/information/DisposeNodeData.java @@ -3,13 +3,14 @@ package com.dispose.pojo.vo.information; import com.dispose.pojo.po.DisposeDeviceCapacity; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonPropertyOrder; -import java.util.List; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; import lombok.EqualsAndHashCode; import lombok.NoArgsConstructor; +import java.util.List; + /** * The type Dispose node data. */ diff --git a/src/main/java/com/dispose/pojo/vo/information/DisposeNodeListRsp.java b/src/main/java/com/dispose/pojo/vo/information/DisposeNodeListRsp.java index 5e22920a..c302dc52 100644 --- a/src/main/java/com/dispose/pojo/vo/information/DisposeNodeListRsp.java +++ b/src/main/java/com/dispose/pojo/vo/information/DisposeNodeListRsp.java @@ -1,9 +1,10 @@ package com.dispose.pojo.vo.information; -import java.util.List; import lombok.Data; import lombok.NoArgsConstructor; +import java.util.List; + /** * The type Dispose node list rsp. */ diff --git a/src/main/java/com/dispose/pojo/vo/information/NodeTaskData.java b/src/main/java/com/dispose/pojo/vo/information/NodeTaskData.java index d3297a3b..2924087c 100644 --- a/src/main/java/com/dispose/pojo/vo/information/NodeTaskData.java +++ b/src/main/java/com/dispose/pojo/vo/information/NodeTaskData.java @@ -4,13 +4,14 @@ import com.dispose.pojo.vo.common.IDReturnStatus; import com.dispose.pojo.vo.common.TaskInfoData; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonPropertyOrder; -import java.util.ArrayList; -import java.util.List; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; import lombok.EqualsAndHashCode; +import java.util.ArrayList; +import java.util.List; + /** * The type Node task data. */ diff --git a/src/main/java/com/dispose/pojo/vo/information/NodeTaskRsp.java b/src/main/java/com/dispose/pojo/vo/information/NodeTaskRsp.java index 8b54cbf2..d043b761 100644 --- a/src/main/java/com/dispose/pojo/vo/information/NodeTaskRsp.java +++ b/src/main/java/com/dispose/pojo/vo/information/NodeTaskRsp.java @@ -1,11 +1,12 @@ package com.dispose.pojo.vo.information; -import java.util.ArrayList; -import java.util.List; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; +import java.util.ArrayList; +import java.util.List; + /** * The type Node task rsp. */ diff --git a/src/main/java/com/dispose/pojo/vo/task/StopTaskReq.java b/src/main/java/com/dispose/pojo/vo/task/StopTaskReq.java index 20de0d87..bac2930f 100644 --- a/src/main/java/com/dispose/pojo/vo/task/StopTaskReq.java +++ b/src/main/java/com/dispose/pojo/vo/task/StopTaskReq.java @@ -1,12 +1,13 @@ package com.dispose.pojo.vo.task; import com.fasterxml.jackson.annotation.JsonInclude; -import java.util.List; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; import lombok.NoArgsConstructor; +import java.util.List; + /** * The type Stop task req. */ diff --git a/src/main/java/com/dispose/pojo/vo/task/TaskInfoRsp.java b/src/main/java/com/dispose/pojo/vo/task/TaskInfoRsp.java index 9c5e312d..799ac865 100644 --- a/src/main/java/com/dispose/pojo/vo/task/TaskInfoRsp.java +++ b/src/main/java/com/dispose/pojo/vo/task/TaskInfoRsp.java @@ -1,12 +1,13 @@ package com.dispose.pojo.vo.task; import com.dispose.pojo.vo.common.TaskInfoData; -import java.util.ArrayList; -import java.util.List; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; +import java.util.ArrayList; +import java.util.List; + /** * The type Task info rsp. */ diff --git a/src/main/java/com/dispose/service/DisposeNodeManager.java b/src/main/java/com/dispose/service/DisposeNodeManager.java index 63af27eb..0f75f343 100644 --- a/src/main/java/com/dispose/service/DisposeNodeManager.java +++ b/src/main/java/com/dispose/service/DisposeNodeManager.java @@ -4,6 +4,7 @@ import com.dispose.common.DeviceCapacity; import com.dispose.common.ErrorCode; import com.dispose.pojo.entity.DisposeDevice; import com.dispose.pojo.po.MReturnType; + import java.util.List; /** diff --git a/src/main/java/com/dispose/service/TaskService.java b/src/main/java/com/dispose/service/TaskService.java index ed6e6418..2da7be6b 100644 --- a/src/main/java/com/dispose/service/TaskService.java +++ b/src/main/java/com/dispose/service/TaskService.java @@ -3,6 +3,7 @@ package com.dispose.service; import com.dispose.common.ErrorCode; import com.dispose.pojo.po.MReturnType; import com.dispose.pojo.vo.common.TaskInfoDetail; + import java.util.List; /** diff --git a/src/main/java/com/dispose/service/UserAccountService.java b/src/main/java/com/dispose/service/UserAccountService.java index ba4b9376..0c4be70b 100644 --- a/src/main/java/com/dispose/service/UserAccountService.java +++ b/src/main/java/com/dispose/service/UserAccountService.java @@ -3,6 +3,7 @@ package com.dispose.service; import com.dispose.common.ErrorCode; import com.dispose.pojo.entity.UserAccount; import com.dispose.pojo.po.MReturnType; + import java.security.NoSuchAlgorithmException; /** diff --git a/src/main/java/com/dispose/service/impl/DisposeNodeManagerImpl.java b/src/main/java/com/dispose/service/impl/DisposeNodeManagerImpl.java index 05c5c0a7..84a7d888 100644 --- a/src/main/java/com/dispose/service/impl/DisposeNodeManagerImpl.java +++ b/src/main/java/com/dispose/service/impl/DisposeNodeManagerImpl.java @@ -12,15 +12,15 @@ import com.dispose.pojo.po.MReturnType; import com.dispose.service.DisposeNodeManager; import com.dispose.service.UserAccountService; import inet.ipaddr.AddressStringException; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; import java.util.ArrayList; import java.util.List; import java.util.Optional; import java.util.concurrent.ConcurrentHashMap; import java.util.stream.Collectors; -import javax.annotation.Resource; - -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Service; /** * The type Dispose node manager. diff --git a/src/main/java/com/dispose/service/impl/TaskServiceImpl.java b/src/main/java/com/dispose/service/impl/TaskServiceImpl.java index 249f86df..c145c44d 100644 --- a/src/main/java/com/dispose/service/impl/TaskServiceImpl.java +++ b/src/main/java/com/dispose/service/impl/TaskServiceImpl.java @@ -105,12 +105,12 @@ public class TaskServiceImpl implements TaskService { public void loadTaskFromDatabase() { // 从数据库中取出所有新建和正在运行的任务 List taskList = disposeTaskMapper.selectAll() - .parallelStream() + .stream() .filter(v -> v.getType().equals(DisposeTaskStatus.TASK_NEW.getCode()) || v.getType().equals(DisposeTaskStatus.TASK_RUNNING.getCode())) .collect(Collectors.toList()); - taskList.parallelStream().forEach(v -> { + taskList.forEach(v -> { if (taskCacheManager.addTask(v) != ErrorCode.ERR_OK) { try { log.error("load error:\n" + objectMapper.writerWithDefaultPrettyPrinter().writeValueAsString(v)); @@ -151,7 +151,7 @@ public class TaskServiceImpl implements TaskService { // 查询当前是否有相同能力节点,相同用户,相同处置IP的且正在执行的处置任务,如果存在则忽略该次任务(依照产品需求) List taskList = taskCacheManager.getAllTask() - .parallelStream() + .stream() .filter(v -> ((taskId == null || taskId == -1L) || Objects.equals(v.getDeviceId(), task.getDeviceId())) && Objects.equals(v.getAccountId(), task.getAccountId()) && taskIsRunning(v) @@ -398,13 +398,13 @@ public class TaskServiceImpl implements TaskService { List> retList = new ArrayList<>(); // 根据处置IP,拿出所有正在处置的任务 - List taskList = taskCacheManager.getAllTask().parallelStream() + List taskList = taskCacheManager.getAllTask().stream() .filter(v -> (Objects.equals(v.getId(), taskId)) && taskIsRunning(v)) .collect(Collectors.toList()); // 对符合条件的任务调用停止命令 - taskList.parallelStream().forEach(v -> { + taskList.forEach(v -> { ErrorCode err = stopTask(v.getId()); retList.add(new MReturnType<>(err, v)); }); @@ -423,7 +423,7 @@ public class TaskServiceImpl implements TaskService { */ @Override public boolean taskIsExists(Long devId, Long userId, String disposeIp, int disposeType) { - return taskCacheManager.getAllTask().parallelStream() + return taskCacheManager.getAllTask().stream() .anyMatch(v -> Objects.equals(v.getAccountId(), userId) && Objects.equals(v.getDeviceId(), devId) && Objects.equals(v.getDisposeIp(), disposeIp) @@ -435,7 +435,7 @@ public class TaskServiceImpl implements TaskService { List> retList = new ArrayList<>(); // 根据处置IP,拿出所有正在处置的任务 - List taskList = taskCacheManager.getAllTask().parallelStream() + List taskList = taskCacheManager.getAllTask().stream() .filter(v -> ((devId == null || devId == -1L) || Objects.equals(v.getDeviceId(), devId)) && (Objects.equals(v.getType(), type) || type == -1) && Objects.equals(v.getDisposeIp(), ipAddr) @@ -443,7 +443,7 @@ public class TaskServiceImpl implements TaskService { .collect(Collectors.toList()); // 对符合条件的任务调用停止命令 - taskList.parallelStream().forEach(v -> { + taskList.forEach(v -> { ErrorCode err = stopTask(v.getId()); retList.add(new MReturnType<>(err, v)); }); @@ -456,14 +456,14 @@ public class TaskServiceImpl implements TaskService { List> retList = new ArrayList<>(); // 根据处置IP,拿出所有正在处置的任务 - List taskList = taskCacheManager.getAllTask().parallelStream() + List taskList = taskCacheManager.getAllTask().stream() .filter(v -> ((devId == null || devId == -1L) || Objects.equals(v.getDeviceId(), devId)) && (Objects.equals(v.getType(), type) || type == -1) && taskIsRunning(v)) .collect(Collectors.toList()); // 对符合条件的任务调用停止命令 - taskList.parallelStream().forEach(v -> { + taskList.forEach(v -> { ErrorCode err = stopTask(v.getId()); retList.add(new MReturnType<>(err, v)); }); @@ -476,13 +476,13 @@ public class TaskServiceImpl implements TaskService { List> retList = new ArrayList<>(); // 根据处置IP,拿出所有正在处置的任务 - List taskList = taskCacheManager.getAllTask().parallelStream() + List taskList = taskCacheManager.getAllTask().stream() .filter(v -> (Objects.equals(v.getType(), type) || type == -1) && taskIsRunning(v)) .collect(Collectors.toList()); // 对符合条件的任务调用停止命令 - taskList.parallelStream().forEach(v -> { + taskList.forEach(v -> { ErrorCode err = stopTask(v.getId()); retList.add(new MReturnType<>(err, v)); }); diff --git a/src/main/java/com/dispose/service/impl/UserAccountServiceImpl.java b/src/main/java/com/dispose/service/impl/UserAccountServiceImpl.java index 24b0f3a0..08c67e39 100644 --- a/src/main/java/com/dispose/service/impl/UserAccountServiceImpl.java +++ b/src/main/java/com/dispose/service/impl/UserAccountServiceImpl.java @@ -8,11 +8,12 @@ import com.dispose.mapper.UserAccountMapper; import com.dispose.pojo.entity.UserAccount; import com.dispose.pojo.po.MReturnType; import com.dispose.service.UserAccountService; -import java.security.NoSuchAlgorithmException; -import javax.annotation.Resource; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; +import javax.annotation.Resource; +import java.security.NoSuchAlgorithmException; + /** * The type User account service. */ diff --git a/src/main/java/com/dispose/swagger/Swagger2Config.java b/src/main/java/com/dispose/swagger/Swagger2Config.java index e1990b03..5b91ca5d 100644 --- a/src/main/java/com/dispose/swagger/Swagger2Config.java +++ b/src/main/java/com/dispose/swagger/Swagger2Config.java @@ -2,8 +2,6 @@ package com.dispose.swagger; import com.dispose.config.MyConfig; import com.google.common.base.Predicates; -import java.util.Collections; -import javax.annotation.Resource; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import springfox.documentation.builders.PathSelectors; @@ -14,6 +12,9 @@ import springfox.documentation.spi.DocumentationType; import springfox.documentation.spring.web.plugins.Docket; import springfox.documentation.swagger2.annotations.EnableSwagger2; +import javax.annotation.Resource; +import java.util.Collections; + /** * The type Swagger 2 config. */ diff --git a/src/main/java/com/dispose/task/DeviceManagerTask.java b/src/main/java/com/dispose/task/DeviceManagerTask.java index 71c6f4fc..da60c29e 100644 --- a/src/main/java/com/dispose/task/DeviceManagerTask.java +++ b/src/main/java/com/dispose/task/DeviceManagerTask.java @@ -5,12 +5,13 @@ import com.dispose.dispose.DeviceRouter; import com.dispose.dispose.DisposeEntryManager; import com.dispose.pojo.entity.DisposeDevice; import com.dispose.service.DisposeNodeManager; -import java.util.List; -import javax.annotation.Resource; import org.springframework.scheduling.annotation.Async; import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Component; +import javax.annotation.Resource; +import java.util.List; + /** * The type Device manager task. */ diff --git a/src/main/java/com/dispose/thread/ThreadPoolConfig.java b/src/main/java/com/dispose/thread/ThreadPoolConfig.java index 65cd44e6..e19c2b6c 100644 --- a/src/main/java/com/dispose/thread/ThreadPoolConfig.java +++ b/src/main/java/com/dispose/thread/ThreadPoolConfig.java @@ -1,10 +1,11 @@ package com.dispose.thread; -import java.util.concurrent.Executor; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; +import java.util.concurrent.Executor; + /** * The type Thread pool config. */ diff --git a/src/test/java/com/dispose/TestSuit/SmokeTest.java b/src/test/java/com/dispose/TestSuit/SmokeTest.java index 2548b808..e82c10b9 100644 --- a/src/test/java/com/dispose/TestSuit/SmokeTest.java +++ b/src/test/java/com/dispose/TestSuit/SmokeTest.java @@ -1,6 +1,7 @@ package com.dispose.TestSuit; import com.dispose.controller.AuthControllerSmokeTest; +import com.dispose.controller.DeviceNodeInfoControllerSmokeTest; import com.dispose.controller.TaskControllerSmokeTest; import org.junit.runner.RunWith; import org.junit.runners.Suite; @@ -11,6 +12,7 @@ import org.junit.runners.Suite; @RunWith(Suite.class) @Suite.SuiteClasses({ AuthControllerSmokeTest.class, + DeviceNodeInfoControllerSmokeTest.class, TaskControllerSmokeTest.class }) diff --git a/src/test/java/com/dispose/controller/DeviceNodeInfoControllerSmokeTest.java b/src/test/java/com/dispose/controller/DeviceNodeInfoControllerSmokeTest.java new file mode 100644 index 00000000..4d859a49 --- /dev/null +++ b/src/test/java/com/dispose/controller/DeviceNodeInfoControllerSmokeTest.java @@ -0,0 +1,83 @@ +package com.dispose.controller; + +import com.dispose.Global.InitTestEnvironment; +import com.dispose.common.ErrorCode; +import com.dispose.pojo.vo.information.NodeTaskRsp; +import com.fasterxml.jackson.databind.ObjectMapper; +import lombok.extern.slf4j.Slf4j; +import org.junit.Assert; +import org.junit.FixMethodOrder; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.MethodSorters; +import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.http.MediaType; +import org.springframework.test.annotation.DirtiesContext; +import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.test.web.servlet.MockMvc; +import org.springframework.test.web.servlet.request.MockMvcRequestBuilders; + +import javax.annotation.Resource; + +import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; + +@AutoConfigureMockMvc +@RunWith(SpringRunner.class) +@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) +@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_EACH_TEST_METHOD) +@FixMethodOrder(MethodSorters.NAME_ASCENDING) +@Slf4j +public class DeviceNodeInfoControllerSmokeTest extends InitTestEnvironment { + /** + * The Mock mvc. + */ + @Resource + private MockMvc mockMvc; + /** + * The Object mapper. + */ + @Resource + private ObjectMapper objectMapper; + + /** + * A 1 login normal login test. + * + * @throws Exception the exception + */ + @Test + public void a1_getAllTaskNormalTest() throws Exception { + String reqData = "{\"ver\":2,\"cryptoType\":0,\"timeStamp\":1587604310504," + + "\"msgContent\":\"{\\\"id\\\":[\\\"465\\\"]}\"}"; + +// String ret = mockMvc.perform(MockMvcRequestBuilders +// .post("/auth/login") +// .contentType(MediaType.APPLICATION_JSON) +// .content(reqData)) +// .andDo(print()).andExpect(status().isOk()) +// .andExpect(jsonPath("$.code").value(ErrorCode.ERR_OK.getHttpCode())) +// .andReturn() +// .getResponse() +// .getContentAsString(); + + String ret = mockMvc.perform(MockMvcRequestBuilders + .post("/information/all_task") + .contentType(MediaType.APPLICATION_JSON) + .header("Authorization", "Bearer " + getLogToken()) + .content(reqData)) + .andDo(print()).andExpect(status().isOk()) + .andExpect(jsonPath("$.code").value(ErrorCode.ERR_OK.getHttpCode())) + .andReturn() + .getResponse() + .getContentAsString(); + + NodeTaskRsp rspInfo = objectMapper.readValue(verifyResp(ret), NodeTaskRsp.class) ; + + Assert.assertNotNull(rspInfo); + Assert.assertNotEquals(rspInfo.getItems().size(), 0); + + //Assert.assertEquals(Long.valueOf(rspInfo.getStatus()), Long.valueOf(ErrorCode.ERR_OK.getCode())); + } +} diff --git a/src/test/java/com/dispose/controller/DeviceNodeManagerControlllerSmokeTest.java b/src/test/java/com/dispose/controller/DeviceNodeManagerControlllerSmokeTest.java index 37598dad..c8cc2d58 100644 --- a/src/test/java/com/dispose/controller/DeviceNodeManagerControlllerSmokeTest.java +++ b/src/test/java/com/dispose/controller/DeviceNodeManagerControlllerSmokeTest.java @@ -4,13 +4,9 @@ import com.dispose.Global.InitTestEnvironment; import com.dispose.common.ErrorCode; import com.dispose.pojo.entity.DisposeDevice; import com.dispose.pojo.po.MReturnType; -import com.dispose.pojo.po.ReturnStatus; -import com.dispose.pojo.vo.auth.LoginRsp; -import com.dispose.pojo.vo.common.IDArrayReq; import com.dispose.pojo.vo.common.IDReturnStatus; import com.dispose.pojo.vo.device.AddNodeRetData; import com.dispose.pojo.vo.device.AddNodeRsp; -import com.dispose.pojo.vo.task.StartTaskRsp; import com.dispose.service.DisposeNodeManager; import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; @@ -29,8 +25,6 @@ import org.springframework.test.web.servlet.MockMvc; import org.springframework.test.web.servlet.request.MockMvcRequestBuilders; import javax.annotation.Resource; - -import java.util.ArrayList; import java.util.List; import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print;