This commit is contained in:
lijinxing 2020-05-09 14:48:50 +08:00
commit 391a062e69
40 changed files with 197 additions and 85 deletions

View File

@ -3,11 +3,12 @@ package com.dispose.config;
import com.dispose.common.GlobalVar; import com.dispose.common.GlobalVar;
import com.dispose.service.DisposeNodeManager; import com.dispose.service.DisposeNodeManager;
import com.dispose.service.TaskService; import com.dispose.service.TaskService;
import javax.annotation.Resource;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.CommandLineRunner; import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import javax.annotation.Resource;
/** /**
* The type Setup init. * The type Setup init.
*/ */

View File

@ -639,13 +639,13 @@ public class DisposeNodeInfoController {
NodeTaskRsp rspInfo = new NodeTaskRsp(); NodeTaskRsp rspInfo = new NodeTaskRsp();
List<DisposeDevice> valuableData = disposeNodeManager.getAllDisposeDevice() List<DisposeDevice> valuableData = disposeNodeManager.getAllDisposeDevice()
.parallelStream() .stream()
.filter(v -> reqInfo.getId().length == 0 .filter(v -> reqInfo.getId().length == 0
|| Arrays.stream(reqInfo.getId()) || Arrays.stream(reqInfo.getId())
.anyMatch(s -> s.equals(v.getId().toString()))) .anyMatch(s -> s.equals(v.getId().toString())))
.collect(Collectors.toList()); .collect(Collectors.toList());
valuableData.parallelStream().forEach(v -> { valuableData.forEach(v -> {
NodeTaskData taskData = new NodeTaskData(); NodeTaskData taskData = new NodeTaskData();
rspInfo.getItems().add(taskData); rspInfo.getItems().add(taskData);
taskData.setId(v.getId().toString()); taskData.setId(v.getId().toString());
@ -658,7 +658,7 @@ public class DisposeNodeInfoController {
taskData.setStatus(ErrorCode.ERR_NOSUCHTASK.getCode()); taskData.setStatus(ErrorCode.ERR_NOSUCHTASK.getCode());
taskData.setMessage(ErrorCode.ERR_NOSUCHTASK.getMsg()); taskData.setMessage(ErrorCode.ERR_NOSUCHTASK.getMsg());
} else { } else {
runTasks.parallelStream().forEach(k -> { runTasks.forEach(k -> {
int diff = Helper.getTimestampDiff(k.getBeginTime(), k.getPlanEndTime()); int diff = Helper.getTimestampDiff(k.getBeginTime(), k.getPlanEndTime());
TaskInfoData taskInfoData = TaskInfoData.builder() TaskInfoData taskInfoData = TaskInfoData.builder()
@ -678,10 +678,10 @@ public class DisposeNodeInfoController {
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.stream().noneMatch(k -> k.getId() == Long.parseLong(v)))
.collect(Collectors.toList()); .collect(Collectors.toList());
unExists.parallelStream().forEach(v -> { unExists.forEach(v -> {
NodeTaskData taskData = new NodeTaskData(); NodeTaskData taskData = new NodeTaskData();
rspInfo.getItems().add(taskData); rspInfo.getItems().add(taskData);
taskData.setId(v); taskData.setId(v);
@ -717,14 +717,14 @@ public class DisposeNodeInfoController {
NodeTaskRsp rspInfo = new NodeTaskRsp(); NodeTaskRsp rspInfo = new NodeTaskRsp();
List<DisposeDevice> valuableData = disposeNodeManager.getAllDisposeDevice() List<DisposeDevice> valuableData = disposeNodeManager.getAllDisposeDevice()
.parallelStream() .stream()
.filter(v -> reqInfo.getId().length == 0 .filter(v -> reqInfo.getId().length == 0
|| Arrays.stream(reqInfo.getId()) || Arrays.stream(reqInfo.getId())
.anyMatch(s -> s.equals(v.getId() .anyMatch(s -> s.equals(v.getId()
.toString()))) .toString())))
.collect(Collectors.toList()); .collect(Collectors.toList());
valuableData.parallelStream().forEach(v -> { valuableData.forEach(v -> {
NodeTaskData taskData = new NodeTaskData(); NodeTaskData taskData = new NodeTaskData();
rspInfo.getItems().add(taskData); rspInfo.getItems().add(taskData);
taskData.setId(v.getId().toString()); taskData.setId(v.getId().toString());
@ -737,7 +737,7 @@ public class DisposeNodeInfoController {
taskData.setStatus(ErrorCode.ERR_NOSUCHTASK.getCode()); taskData.setStatus(ErrorCode.ERR_NOSUCHTASK.getCode());
taskData.setMessage(ErrorCode.ERR_NOSUCHTASK.getMsg()); taskData.setMessage(ErrorCode.ERR_NOSUCHTASK.getMsg());
} else { } else {
runTasks.parallelStream().forEach(k -> { runTasks.forEach(k -> {
int diff = Helper.getTimestampDiff(k.getBeginTime(), k.getPlanEndTime()); int diff = Helper.getTimestampDiff(k.getBeginTime(), k.getPlanEndTime());
TaskInfoData taskInfoData = TaskInfoData.builder() TaskInfoData taskInfoData = TaskInfoData.builder()
@ -758,10 +758,10 @@ public class DisposeNodeInfoController {
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.stream().noneMatch(k -> k.getId() == Long.parseLong(v)))
.collect(Collectors.toList()); .collect(Collectors.toList());
unExists.parallelStream().forEach(v -> { unExists.forEach(v -> {
NodeTaskData taskData = new NodeTaskData(); NodeTaskData taskData = new NodeTaskData();
rspInfo.getItems().add(taskData); rspInfo.getItems().add(taskData);
taskData.setId(v); taskData.setId(v);

View File

@ -396,12 +396,12 @@ public class DisposeTaskController {
NodeTaskRsp rspInfo = new NodeTaskRsp(); NodeTaskRsp rspInfo = new NodeTaskRsp();
List<DisposeDevice> valuableData = disposeNodeManager.getAllDisposeDevice() List<DisposeDevice> valuableData = disposeNodeManager.getAllDisposeDevice()
.parallelStream() .stream()
.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()).anyMatch(s -> s.equals(v.getId().toString())))
.collect(Collectors.toList()); .collect(Collectors.toList());
valuableData.parallelStream().forEach(v -> { valuableData.forEach(v -> {
NodeTaskData taskData = new NodeTaskData(); NodeTaskData taskData = new NodeTaskData();
rspInfo.getItems().add(taskData); rspInfo.getItems().add(taskData);
taskData.setId(v.getId().toString()); taskData.setId(v.getId().toString());
@ -437,10 +437,10 @@ public class DisposeTaskController {
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.stream().noneMatch(k -> k.getId() == Long.parseLong(v)))
.collect(Collectors.toList()); .collect(Collectors.toList());
unExists.parallelStream().forEach(v -> { unExists.forEach(v -> {
NodeTaskData taskData = new NodeTaskData(); NodeTaskData taskData = new NodeTaskData();
rspInfo.getItems().add(taskData); rspInfo.getItems().add(taskData);
taskData.setId(v); taskData.setId(v);
@ -477,12 +477,12 @@ public class DisposeTaskController {
TaskInfoRsp rspInfo = new TaskInfoRsp(); TaskInfoRsp rspInfo = new TaskInfoRsp();
List<TaskInfoDetail> valuableData = taskService.getAllTask() List<TaskInfoDetail> valuableData = taskService.getAllTask()
.parallelStream() .stream()
.filter(v -> reqInfo.getTaskId().length == 0 .filter(v -> reqInfo.getTaskId().length == 0
|| Arrays.stream(reqInfo.getTaskId()).anyMatch(s -> s.equals(v.getId().toString()))) || Arrays.stream(reqInfo.getTaskId()).anyMatch(s -> s.equals(v.getId().toString())))
.collect(Collectors.toList()); .collect(Collectors.toList());
valuableData.parallelStream().forEach(v -> { valuableData.forEach(v -> {
int diff = Helper.getTimestampDiff(v.getBeginTime(), v.getPlanEndTime()); int diff = Helper.getTimestampDiff(v.getBeginTime(), v.getPlanEndTime());
TaskInfoData taskInfoData = TaskInfoData.builder() TaskInfoData taskInfoData = TaskInfoData.builder()
@ -506,10 +506,10 @@ public class DisposeTaskController {
if (reqInfo.getTaskId().length != 0) { if (reqInfo.getTaskId().length != 0) {
List<String> unExists = Arrays.stream(reqInfo.getTaskId()) List<String> 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()); .collect(Collectors.toList());
unExists.parallelStream().forEach(v -> { unExists.forEach(v -> {
TaskInfoData taskData = new TaskInfoData(); TaskInfoData taskData = new TaskInfoData();
rspInfo.getItems().add(taskData); rspInfo.getItems().add(taskData);
taskData.setId(v); taskData.setId(v);

View File

@ -5,6 +5,7 @@ import com.dispose.common.GlobalVar;
import com.dispose.common.IPAddrType; import com.dispose.common.IPAddrType;
import com.dispose.dispose.impl.DPTechImpl; import com.dispose.dispose.impl.DPTechImpl;
import com.dispose.dispose.impl.VirtualDeviceImpl; import com.dispose.dispose.impl.VirtualDeviceImpl;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
/** /**

View File

@ -5,6 +5,7 @@ import com.dispose.common.DeviceCapacity;
import com.dispose.common.ErrorCode; import com.dispose.common.ErrorCode;
import com.dispose.dispose.po.DeviceInfo; import com.dispose.dispose.po.DeviceInfo;
import com.dispose.pojo.po.DisposeDeviceCapacity; import com.dispose.pojo.po.DisposeDeviceCapacity;
import java.util.List; import java.util.List;
/** /**

View File

@ -7,6 +7,7 @@ import com.dispose.common.IPAddrType;
import com.dispose.dispose.DisposeEntryManager; import com.dispose.dispose.DisposeEntryManager;
import com.dispose.dispose.po.DeviceInfo; import com.dispose.dispose.po.DeviceInfo;
import com.dispose.pojo.po.DisposeDeviceCapacity; import com.dispose.pojo.po.DisposeDeviceCapacity;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;

View File

@ -1,10 +1,11 @@
package com.dispose.dispose.po; package com.dispose.dispose.po;
import java.io.Serializable;
import lombok.Builder; import lombok.Builder;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
import java.io.Serializable;
/** /**
* The type Device info. * The type Device info.
*/ */

View File

@ -4,12 +4,13 @@ import com.dispose.common.ConstValue;
import com.dispose.common.ErrorCode; import com.dispose.common.ErrorCode;
import com.dispose.pojo.dto.ProtocolRespDTO; import com.dispose.pojo.dto.ProtocolRespDTO;
import com.dispose.pojo.po.ReturnStatus; import com.dispose.pojo.po.ReturnStatus;
import javax.servlet.http.HttpServletRequest;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ControllerAdvice; import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler; import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.ResponseBody;
import javax.servlet.http.HttpServletRequest;
/** /**
* The type Global exception handler. * The type Global exception handler.
*/ */

View File

@ -1,9 +1,10 @@
package com.dispose.interceptor; package com.dispose.interceptor;
import com.dispose.common.ConstValue; import com.dispose.common.ConstValue;
import org.apache.wss4j.common.ext.WSPasswordCallback;
import javax.security.auth.callback.Callback; import javax.security.auth.callback.Callback;
import javax.security.auth.callback.CallbackHandler; import javax.security.auth.callback.CallbackHandler;
import org.apache.wss4j.common.ext.WSPasswordCallback;
/** /**
* The type Soap password callback handler. * The type Soap password callback handler.

View File

@ -2,6 +2,7 @@ package com.dispose.manager;
import com.dispose.common.ErrorCode; import com.dispose.common.ErrorCode;
import com.dispose.pojo.vo.common.TaskInfoDetail; import com.dispose.pojo.vo.common.TaskInfoDetail;
import java.util.List; import java.util.List;
/** /**

View File

@ -2,6 +2,7 @@ package com.dispose.manager;
import com.dispose.common.ErrorCode; import com.dispose.common.ErrorCode;
import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonProcessingException;
import java.security.NoSuchAlgorithmException; import java.security.NoSuchAlgorithmException;
/** /**

View File

@ -8,15 +8,16 @@ import com.dispose.manager.UserAccountCacheManager;
import com.dispose.pojo.po.UserAccountCache; import com.dispose.pojo.po.UserAccountCache;
import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper; 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.MessageDigest;
import java.security.NoSuchAlgorithmException; import java.security.NoSuchAlgorithmException;
import java.util.Optional; import java.util.Optional;
import java.util.Random; import java.util.Random;
import java.util.concurrent.ConcurrentHashMap; 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. * The type User account cache manager.

View File

@ -1,12 +1,13 @@
package com.dispose.mapper; package com.dispose.mapper;
import com.dispose.pojo.vo.common.TaskInfoDetail; import com.dispose.pojo.vo.common.TaskInfoDetail;
import java.util.List;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import tk.mybatis.mapper.common.IdsMapper; import tk.mybatis.mapper.common.IdsMapper;
import tk.mybatis.mapper.common.Mapper; import tk.mybatis.mapper.common.Mapper;
import tk.mybatis.mapper.common.MySqlMapper; import tk.mybatis.mapper.common.MySqlMapper;
import java.util.List;
/** /**
* The interface Dispose task mapper. * The interface Dispose task mapper.
*/ */

View File

@ -3,11 +3,6 @@ package com.dispose.pojo.entity;
import com.dispose.dispose.po.DeviceInfo; import com.dispose.dispose.po.DeviceInfo;
import com.dispose.pojo.po.DisposeDeviceCapacity; import com.dispose.pojo.po.DisposeDeviceCapacity;
import com.fasterxml.jackson.annotation.JsonInclude; 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.AllArgsConstructor;
import lombok.Builder; import lombok.Builder;
import lombok.Getter; import lombok.Getter;
@ -18,6 +13,12 @@ import tk.mybatis.mapper.annotation.KeySql;
import tk.mybatis.mapper.annotation.NameStyle; import tk.mybatis.mapper.annotation.NameStyle;
import tk.mybatis.mapper.code.Style; 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. * The type Dispose device.
*/ */

View File

@ -1,8 +1,5 @@
package com.dispose.pojo.entity; package com.dispose.pojo.entity;
import java.io.Serializable;
import javax.persistence.Id;
import javax.persistence.Table;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Builder; import lombok.Builder;
import lombok.Getter; import lombok.Getter;
@ -13,6 +10,10 @@ import tk.mybatis.mapper.annotation.KeySql;
import tk.mybatis.mapper.annotation.NameStyle; import tk.mybatis.mapper.annotation.NameStyle;
import tk.mybatis.mapper.code.Style; import tk.mybatis.mapper.code.Style;
import javax.persistence.Id;
import javax.persistence.Table;
import java.io.Serializable;
/** /**
* The type User account. * The type User account.
*/ */

View File

@ -1,6 +1,5 @@
package com.dispose.pojo.po; package com.dispose.pojo.po;
import java.io.Serializable;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Builder; import lombok.Builder;
import lombok.Getter; import lombok.Getter;
@ -8,6 +7,8 @@ import lombok.NoArgsConstructor;
import lombok.Setter; import lombok.Setter;
import lombok.ToString; import lombok.ToString;
import java.io.Serializable;
/** /**
* The type Dispose device capacity. * The type Dispose device capacity.
*/ */

View File

@ -1,8 +1,5 @@
package com.dispose.pojo.vo.common; package com.dispose.pojo.vo.common;
import java.io.Serializable;
import javax.persistence.Id;
import javax.persistence.Table;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Builder; import lombok.Builder;
import lombok.Data; import lombok.Data;
@ -10,6 +7,10 @@ import lombok.NoArgsConstructor;
import tk.mybatis.mapper.annotation.NameStyle; import tk.mybatis.mapper.annotation.NameStyle;
import tk.mybatis.mapper.code.Style; import tk.mybatis.mapper.code.Style;
import javax.persistence.Id;
import javax.persistence.Table;
import java.io.Serializable;
/** /**
* The type Task info detail. * The type Task info detail.
*/ */

View File

@ -2,12 +2,13 @@ package com.dispose.pojo.vo.device;
import com.dispose.pojo.po.NewNodeInfo; import com.dispose.pojo.po.NewNodeInfo;
import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude;
import java.util.List;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Builder; import lombok.Builder;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
import java.util.List;
/** /**
* The type Add node req. * The type Add node req.
*/ */

View File

@ -2,12 +2,13 @@ package com.dispose.pojo.vo.device;
import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude;
import java.util.ArrayList;
import java.util.List;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Builder; import lombok.Builder;
import lombok.Data; import lombok.Data;
import java.util.ArrayList;
import java.util.List;
/** /**
* The type Add node rsp. * The type Add node rsp.
*/ */

View File

@ -5,13 +5,14 @@ import com.dispose.pojo.vo.common.DisposeCapacity;
import com.dispose.pojo.vo.common.IDReturnStatus; import com.dispose.pojo.vo.common.IDReturnStatus;
import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonPropertyOrder; import com.fasterxml.jackson.annotation.JsonPropertyOrder;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
/** /**
* The type Device capacity data. * The type Device capacity data.
*/ */

View File

@ -2,10 +2,11 @@ package com.dispose.pojo.vo.information;
import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonPropertyOrder; import com.fasterxml.jackson.annotation.JsonPropertyOrder;
import java.util.List;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
import java.util.List;
/** /**
* The type Device capacity rsp. * The type Device capacity rsp.
*/ */

View File

@ -1,8 +1,9 @@
package com.dispose.pojo.vo.information; package com.dispose.pojo.vo.information;
import java.util.List;
import lombok.Data; import lombok.Data;
import java.util.List;
/** /**
* The type Device info rsp. * The type Device info rsp.
*/ */

View File

@ -3,13 +3,14 @@ package com.dispose.pojo.vo.information;
import com.dispose.pojo.po.DisposeDeviceCapacity; import com.dispose.pojo.po.DisposeDeviceCapacity;
import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonPropertyOrder; import com.fasterxml.jackson.annotation.JsonPropertyOrder;
import java.util.List;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Builder; import lombok.Builder;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
import java.util.List;
/** /**
* The type Dispose node data. * The type Dispose node data.
*/ */

View File

@ -1,9 +1,10 @@
package com.dispose.pojo.vo.information; package com.dispose.pojo.vo.information;
import java.util.List;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
import java.util.List;
/** /**
* The type Dispose node list rsp. * The type Dispose node list rsp.
*/ */

View File

@ -4,13 +4,14 @@ import com.dispose.pojo.vo.common.IDReturnStatus;
import com.dispose.pojo.vo.common.TaskInfoData; import com.dispose.pojo.vo.common.TaskInfoData;
import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonPropertyOrder; import com.fasterxml.jackson.annotation.JsonPropertyOrder;
import java.util.ArrayList;
import java.util.List;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Builder; import lombok.Builder;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import java.util.ArrayList;
import java.util.List;
/** /**
* The type Node task data. * The type Node task data.
*/ */

View File

@ -1,11 +1,12 @@
package com.dispose.pojo.vo.information; package com.dispose.pojo.vo.information;
import java.util.ArrayList;
import java.util.List;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Builder; import lombok.Builder;
import lombok.Data; import lombok.Data;
import java.util.ArrayList;
import java.util.List;
/** /**
* The type Node task rsp. * The type Node task rsp.
*/ */

View File

@ -1,12 +1,13 @@
package com.dispose.pojo.vo.task; package com.dispose.pojo.vo.task;
import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude;
import java.util.List;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Builder; import lombok.Builder;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
import java.util.List;
/** /**
* The type Stop task req. * The type Stop task req.
*/ */

View File

@ -1,12 +1,13 @@
package com.dispose.pojo.vo.task; package com.dispose.pojo.vo.task;
import com.dispose.pojo.vo.common.TaskInfoData; import com.dispose.pojo.vo.common.TaskInfoData;
import java.util.ArrayList;
import java.util.List;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Builder; import lombok.Builder;
import lombok.Data; import lombok.Data;
import java.util.ArrayList;
import java.util.List;
/** /**
* The type Task info rsp. * The type Task info rsp.
*/ */

View File

@ -4,6 +4,7 @@ import com.dispose.common.DeviceCapacity;
import com.dispose.common.ErrorCode; import com.dispose.common.ErrorCode;
import com.dispose.pojo.entity.DisposeDevice; import com.dispose.pojo.entity.DisposeDevice;
import com.dispose.pojo.po.MReturnType; import com.dispose.pojo.po.MReturnType;
import java.util.List; import java.util.List;
/** /**

View File

@ -3,6 +3,7 @@ package com.dispose.service;
import com.dispose.common.ErrorCode; import com.dispose.common.ErrorCode;
import com.dispose.pojo.po.MReturnType; import com.dispose.pojo.po.MReturnType;
import com.dispose.pojo.vo.common.TaskInfoDetail; import com.dispose.pojo.vo.common.TaskInfoDetail;
import java.util.List; import java.util.List;
/** /**

View File

@ -3,6 +3,7 @@ package com.dispose.service;
import com.dispose.common.ErrorCode; import com.dispose.common.ErrorCode;
import com.dispose.pojo.entity.UserAccount; import com.dispose.pojo.entity.UserAccount;
import com.dispose.pojo.po.MReturnType; import com.dispose.pojo.po.MReturnType;
import java.security.NoSuchAlgorithmException; import java.security.NoSuchAlgorithmException;
/** /**

View File

@ -12,15 +12,15 @@ import com.dispose.pojo.po.MReturnType;
import com.dispose.service.DisposeNodeManager; import com.dispose.service.DisposeNodeManager;
import com.dispose.service.UserAccountService; import com.dispose.service.UserAccountService;
import inet.ipaddr.AddressStringException; 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.ArrayList;
import java.util.List; import java.util.List;
import java.util.Optional; import java.util.Optional;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import javax.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
/** /**
* The type Dispose node manager. * The type Dispose node manager.

View File

@ -105,12 +105,12 @@ public class TaskServiceImpl implements TaskService {
public void loadTaskFromDatabase() { public void loadTaskFromDatabase() {
// 从数据库中取出所有新建和正在运行的任务 // 从数据库中取出所有新建和正在运行的任务
List<TaskInfoDetail> taskList = disposeTaskMapper.selectAll() List<TaskInfoDetail> taskList = disposeTaskMapper.selectAll()
.parallelStream() .stream()
.filter(v -> v.getType().equals(DisposeTaskStatus.TASK_NEW.getCode()) .filter(v -> v.getType().equals(DisposeTaskStatus.TASK_NEW.getCode())
|| v.getType().equals(DisposeTaskStatus.TASK_RUNNING.getCode())) || v.getType().equals(DisposeTaskStatus.TASK_RUNNING.getCode()))
.collect(Collectors.toList()); .collect(Collectors.toList());
taskList.parallelStream().forEach(v -> { taskList.forEach(v -> {
if (taskCacheManager.addTask(v) != ErrorCode.ERR_OK) { if (taskCacheManager.addTask(v) != ErrorCode.ERR_OK) {
try { try {
log.error("load error:\n" + objectMapper.writerWithDefaultPrettyPrinter().writeValueAsString(v)); log.error("load error:\n" + objectMapper.writerWithDefaultPrettyPrinter().writeValueAsString(v));
@ -151,7 +151,7 @@ public class TaskServiceImpl implements TaskService {
// 查询当前是否有相同能力节点相同用户相同处置IP的且正在执行的处置任务如果存在则忽略该次任务依照产品需求 // 查询当前是否有相同能力节点相同用户相同处置IP的且正在执行的处置任务如果存在则忽略该次任务依照产品需求
List<TaskInfoDetail> taskList = taskCacheManager.getAllTask() List<TaskInfoDetail> taskList = taskCacheManager.getAllTask()
.parallelStream() .stream()
.filter(v -> ((taskId == null || taskId == -1L) || Objects.equals(v.getDeviceId(), task.getDeviceId())) .filter(v -> ((taskId == null || taskId == -1L) || Objects.equals(v.getDeviceId(), task.getDeviceId()))
&& Objects.equals(v.getAccountId(), task.getAccountId()) && Objects.equals(v.getAccountId(), task.getAccountId())
&& taskIsRunning(v) && taskIsRunning(v)
@ -398,13 +398,13 @@ public class TaskServiceImpl implements TaskService {
List<MReturnType<ErrorCode, TaskInfoDetail>> retList = new ArrayList<>(); List<MReturnType<ErrorCode, TaskInfoDetail>> retList = new ArrayList<>();
// 根据处置IP拿出所有正在处置的任务 // 根据处置IP拿出所有正在处置的任务
List<TaskInfoDetail> taskList = taskCacheManager.getAllTask().parallelStream() List<TaskInfoDetail> taskList = taskCacheManager.getAllTask().stream()
.filter(v -> (Objects.equals(v.getId(), taskId)) .filter(v -> (Objects.equals(v.getId(), taskId))
&& taskIsRunning(v)) && taskIsRunning(v))
.collect(Collectors.toList()); .collect(Collectors.toList());
// 对符合条件的任务调用停止命令 // 对符合条件的任务调用停止命令
taskList.parallelStream().forEach(v -> { taskList.forEach(v -> {
ErrorCode err = stopTask(v.getId()); ErrorCode err = stopTask(v.getId());
retList.add(new MReturnType<>(err, v)); retList.add(new MReturnType<>(err, v));
}); });
@ -423,7 +423,7 @@ public class TaskServiceImpl implements TaskService {
*/ */
@Override @Override
public boolean taskIsExists(Long devId, Long userId, String disposeIp, int disposeType) { 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) .anyMatch(v -> Objects.equals(v.getAccountId(), userId)
&& Objects.equals(v.getDeviceId(), devId) && Objects.equals(v.getDeviceId(), devId)
&& Objects.equals(v.getDisposeIp(), disposeIp) && Objects.equals(v.getDisposeIp(), disposeIp)
@ -435,7 +435,7 @@ public class TaskServiceImpl implements TaskService {
List<MReturnType<ErrorCode, TaskInfoDetail>> retList = new ArrayList<>(); List<MReturnType<ErrorCode, TaskInfoDetail>> retList = new ArrayList<>();
// 根据处置IP拿出所有正在处置的任务 // 根据处置IP拿出所有正在处置的任务
List<TaskInfoDetail> taskList = taskCacheManager.getAllTask().parallelStream() List<TaskInfoDetail> taskList = taskCacheManager.getAllTask().stream()
.filter(v -> ((devId == null || devId == -1L) || Objects.equals(v.getDeviceId(), devId)) .filter(v -> ((devId == null || devId == -1L) || Objects.equals(v.getDeviceId(), devId))
&& (Objects.equals(v.getType(), type) || type == -1) && (Objects.equals(v.getType(), type) || type == -1)
&& Objects.equals(v.getDisposeIp(), ipAddr) && Objects.equals(v.getDisposeIp(), ipAddr)
@ -443,7 +443,7 @@ public class TaskServiceImpl implements TaskService {
.collect(Collectors.toList()); .collect(Collectors.toList());
// 对符合条件的任务调用停止命令 // 对符合条件的任务调用停止命令
taskList.parallelStream().forEach(v -> { taskList.forEach(v -> {
ErrorCode err = stopTask(v.getId()); ErrorCode err = stopTask(v.getId());
retList.add(new MReturnType<>(err, v)); retList.add(new MReturnType<>(err, v));
}); });
@ -456,14 +456,14 @@ public class TaskServiceImpl implements TaskService {
List<MReturnType<ErrorCode, TaskInfoDetail>> retList = new ArrayList<>(); List<MReturnType<ErrorCode, TaskInfoDetail>> retList = new ArrayList<>();
// 根据处置IP拿出所有正在处置的任务 // 根据处置IP拿出所有正在处置的任务
List<TaskInfoDetail> taskList = taskCacheManager.getAllTask().parallelStream() List<TaskInfoDetail> taskList = taskCacheManager.getAllTask().stream()
.filter(v -> ((devId == null || devId == -1L) || Objects.equals(v.getDeviceId(), devId)) .filter(v -> ((devId == null || devId == -1L) || Objects.equals(v.getDeviceId(), devId))
&& (Objects.equals(v.getType(), type) || type == -1) && (Objects.equals(v.getType(), type) || type == -1)
&& taskIsRunning(v)) && taskIsRunning(v))
.collect(Collectors.toList()); .collect(Collectors.toList());
// 对符合条件的任务调用停止命令 // 对符合条件的任务调用停止命令
taskList.parallelStream().forEach(v -> { taskList.forEach(v -> {
ErrorCode err = stopTask(v.getId()); ErrorCode err = stopTask(v.getId());
retList.add(new MReturnType<>(err, v)); retList.add(new MReturnType<>(err, v));
}); });
@ -476,13 +476,13 @@ public class TaskServiceImpl implements TaskService {
List<MReturnType<ErrorCode, TaskInfoDetail>> retList = new ArrayList<>(); List<MReturnType<ErrorCode, TaskInfoDetail>> retList = new ArrayList<>();
// 根据处置IP拿出所有正在处置的任务 // 根据处置IP拿出所有正在处置的任务
List<TaskInfoDetail> taskList = taskCacheManager.getAllTask().parallelStream() List<TaskInfoDetail> taskList = taskCacheManager.getAllTask().stream()
.filter(v -> (Objects.equals(v.getType(), type) || type == -1) .filter(v -> (Objects.equals(v.getType(), type) || type == -1)
&& taskIsRunning(v)) && taskIsRunning(v))
.collect(Collectors.toList()); .collect(Collectors.toList());
// 对符合条件的任务调用停止命令 // 对符合条件的任务调用停止命令
taskList.parallelStream().forEach(v -> { taskList.forEach(v -> {
ErrorCode err = stopTask(v.getId()); ErrorCode err = stopTask(v.getId());
retList.add(new MReturnType<>(err, v)); retList.add(new MReturnType<>(err, v));
}); });

View File

@ -8,11 +8,12 @@ import com.dispose.mapper.UserAccountMapper;
import com.dispose.pojo.entity.UserAccount; import com.dispose.pojo.entity.UserAccount;
import com.dispose.pojo.po.MReturnType; import com.dispose.pojo.po.MReturnType;
import com.dispose.service.UserAccountService; import com.dispose.service.UserAccountService;
import java.security.NoSuchAlgorithmException;
import javax.annotation.Resource;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.security.NoSuchAlgorithmException;
/** /**
* The type User account service. * The type User account service.
*/ */

View File

@ -2,8 +2,6 @@ package com.dispose.swagger;
import com.dispose.config.MyConfig; import com.dispose.config.MyConfig;
import com.google.common.base.Predicates; 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.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.PathSelectors; import springfox.documentation.builders.PathSelectors;
@ -14,6 +12,9 @@ import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket; import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2; import springfox.documentation.swagger2.annotations.EnableSwagger2;
import javax.annotation.Resource;
import java.util.Collections;
/** /**
* The type Swagger 2 config. * The type Swagger 2 config.
*/ */

View File

@ -5,12 +5,13 @@ import com.dispose.dispose.DeviceRouter;
import com.dispose.dispose.DisposeEntryManager; import com.dispose.dispose.DisposeEntryManager;
import com.dispose.pojo.entity.DisposeDevice; import com.dispose.pojo.entity.DisposeDevice;
import com.dispose.service.DisposeNodeManager; import com.dispose.service.DisposeNodeManager;
import java.util.List;
import javax.annotation.Resource;
import org.springframework.scheduling.annotation.Async; import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.Scheduled; import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.util.List;
/** /**
* The type Device manager task. * The type Device manager task.
*/ */

View File

@ -1,10 +1,11 @@
package com.dispose.thread; package com.dispose.thread;
import java.util.concurrent.Executor;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import java.util.concurrent.Executor;
/** /**
* The type Thread pool config. * The type Thread pool config.
*/ */

View File

@ -1,6 +1,7 @@
package com.dispose.TestSuit; package com.dispose.TestSuit;
import com.dispose.controller.AuthControllerSmokeTest; import com.dispose.controller.AuthControllerSmokeTest;
import com.dispose.controller.DeviceNodeInfoControllerSmokeTest;
import com.dispose.controller.TaskControllerSmokeTest; import com.dispose.controller.TaskControllerSmokeTest;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.junit.runners.Suite; import org.junit.runners.Suite;
@ -11,6 +12,7 @@ import org.junit.runners.Suite;
@RunWith(Suite.class) @RunWith(Suite.class)
@Suite.SuiteClasses({ @Suite.SuiteClasses({
AuthControllerSmokeTest.class, AuthControllerSmokeTest.class,
DeviceNodeInfoControllerSmokeTest.class,
TaskControllerSmokeTest.class TaskControllerSmokeTest.class
}) })

View File

@ -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()));
}
}

View File

@ -4,13 +4,9 @@ import com.dispose.Global.InitTestEnvironment;
import com.dispose.common.ErrorCode; import com.dispose.common.ErrorCode;
import com.dispose.pojo.entity.DisposeDevice; import com.dispose.pojo.entity.DisposeDevice;
import com.dispose.pojo.po.MReturnType; 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.common.IDReturnStatus;
import com.dispose.pojo.vo.device.AddNodeRetData; import com.dispose.pojo.vo.device.AddNodeRetData;
import com.dispose.pojo.vo.device.AddNodeRsp; import com.dispose.pojo.vo.device.AddNodeRsp;
import com.dispose.pojo.vo.task.StartTaskRsp;
import com.dispose.service.DisposeNodeManager; import com.dispose.service.DisposeNodeManager;
import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper; 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 org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print; import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print;