OCT
REM: 1.修改获取全部处置任务接口单元测试 2.修改controller层获取全部处置任务接口,增加入参字段 3.修改manager层、service层分页获取处置任务方法,增加获取全部任务方法 4.修改查询处置任务类
This commit is contained in:
parent
74b8508e83
commit
14e1bb35c3
|
@ -45,9 +45,11 @@ import org.springframework.web.bind.annotation.ResponseBody;
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import javax.validation.constraints.NotNull;
|
import javax.validation.constraints.NotNull;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The type Dispose task controller.
|
* The type Dispose task controller.
|
||||||
|
@ -93,30 +95,30 @@ public class DisposeTaskController {
|
||||||
|
|
||||||
// 构造处置任务参数
|
// 构造处置任务参数
|
||||||
DisposeTask task = DisposeTask.builder()
|
DisposeTask task = DisposeTask.builder()
|
||||||
.deviceId(Long.parseLong(Optional.ofNullable(req.getId()).orElse("-1")))
|
.deviceId(Long.parseLong(Optional.ofNullable(req.getId()).orElse("-1")))
|
||||||
.accountId(userAccountService.getUserIdByAuthHead(Objects.requireNonNull(headers.get("Authorization"))
|
.accountId(userAccountService.getUserIdByAuthHead(Objects.requireNonNull(headers.get("Authorization"))
|
||||||
.get(0)))
|
.get(0)))
|
||||||
.disposeCapacity(CommonEnumHandler.codeOf(DisposeCapacityType.class,
|
.disposeCapacity(CommonEnumHandler.codeOf(DisposeCapacityType.class,
|
||||||
req.getType()))
|
req.getType()))
|
||||||
.disposeIp(Helper.ipAddressNormalize(req.getDisposeIp()))
|
.disposeIp(Helper.ipAddressNormalize(req.getDisposeIp()))
|
||||||
.planEndTime(String.valueOf(req.getDisposeTime()))
|
.planEndTime(String.valueOf(req.getDisposeTime()))
|
||||||
.flowDirection(CommonEnumHandler.codeOf(NetflowDirection.class,
|
.flowDirection(CommonEnumHandler.codeOf(NetflowDirection.class,
|
||||||
Optional.ofNullable(req.getFlowDirection())
|
Optional.ofNullable(req.getFlowDirection())
|
||||||
.orElse(2)))
|
.orElse(2)))
|
||||||
.attackType(DDoSAttackType.getTypeMaskFromAttackType(
|
.attackType(DDoSAttackType.getTypeMaskFromAttackType(
|
||||||
Optional.ofNullable(req.getAttackType())
|
Optional.ofNullable(req.getAttackType())
|
||||||
.orElse(new Integer[]{DDoSAttackType.ALL_ATTACKS.getValue()})))
|
.orElse(new Integer[]{DDoSAttackType.ALL_ATTACKS.getValue()})))
|
||||||
.flowBandWidth(Optional.ofNullable(req.getFlowBandwidth())
|
.flowBandWidth(Optional.ofNullable(req.getFlowBandwidth())
|
||||||
.orElse(DisposeConfigValue.DEFAULT_DISPOSE_BANDWIDTH))
|
.orElse(DisposeConfigValue.DEFAULT_DISPOSE_BANDWIDTH))
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
// 创建处置任务
|
// 创建处置任务
|
||||||
MulReturnType<ErrorCode, DisposeTask> ret = disposeTaskService.createTask(task);
|
MulReturnType<ErrorCode, DisposeTask> ret = disposeTaskService.createTask(task);
|
||||||
|
|
||||||
// 设置返回消息
|
// 设置返回消息
|
||||||
TaskStartRsp rspInfo = TaskStartRsp.builder()
|
TaskStartRsp rspInfo = TaskStartRsp.builder()
|
||||||
.disposeIp(task.getDisposeIp())
|
.disposeIp(task.getDisposeIp())
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
rspInfo.setStatus(ret.getFirstParam().getCode());
|
rspInfo.setStatus(ret.getFirstParam().getCode());
|
||||||
rspInfo.setMessage(new String[]{ret.getFirstParam().getMsg()});
|
rspInfo.setMessage(new String[]{ret.getFirstParam().getMsg()});
|
||||||
|
@ -154,40 +156,40 @@ public class DisposeTaskController {
|
||||||
DisposeCapacityType capType = CommonEnumHandler.codeOf(DisposeCapacityType.class, req.getType());
|
DisposeCapacityType capType = CommonEnumHandler.codeOf(DisposeCapacityType.class, req.getType());
|
||||||
String endTime = String.valueOf(req.getDisposeTime());
|
String endTime = String.valueOf(req.getDisposeTime());
|
||||||
NetflowDirection netDir = CommonEnumHandler.codeOf(NetflowDirection.class,
|
NetflowDirection netDir = CommonEnumHandler.codeOf(NetflowDirection.class,
|
||||||
Optional.ofNullable(req.getFlowDirection()).orElse(2));
|
Optional.ofNullable(req.getFlowDirection()).orElse(2));
|
||||||
Long attackType = DDoSAttackType.getTypeMaskFromAttackType(Optional.ofNullable(req.getAttackType())
|
Long attackType = DDoSAttackType.getTypeMaskFromAttackType(Optional.ofNullable(req.getAttackType())
|
||||||
.orElse(new Integer[]{DDoSAttackType.ALL_ATTACKS.getValue()}));
|
.orElse(new Integer[]{DDoSAttackType.ALL_ATTACKS.getValue()}));
|
||||||
Integer flowBand = Optional.ofNullable(req.getFlowBandwidth())
|
Integer flowBand = Optional.ofNullable(req.getFlowBandwidth())
|
||||||
.orElse(DisposeConfigValue.DEFAULT_DISPOSE_BANDWIDTH);
|
.orElse(DisposeConfigValue.DEFAULT_DISPOSE_BANDWIDTH);
|
||||||
|
|
||||||
TaskStartMulRsp mulRsp = TaskStartMulRsp.builder()
|
TaskStartMulRsp mulRsp = TaskStartMulRsp.builder()
|
||||||
.items(new ArrayList<>())
|
.items(new ArrayList<>())
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
for (String ip : req.getMulDisposeIp()) {
|
for (String ip : req.getMulDisposeIp()) {
|
||||||
// 构造处置任务参数
|
// 构造处置任务参数
|
||||||
DisposeTask task = DisposeTask.builder()
|
DisposeTask task = DisposeTask.builder()
|
||||||
.deviceId(devId)
|
.deviceId(devId)
|
||||||
.accountId(aId)
|
.accountId(aId)
|
||||||
.disposeCapacity(capType)
|
.disposeCapacity(capType)
|
||||||
.disposeIp(Helper.ipAddressNormalize(ip))
|
.disposeIp(Helper.ipAddressNormalize(ip))
|
||||||
.planEndTime(endTime)
|
.planEndTime(endTime)
|
||||||
.flowDirection(netDir)
|
.flowDirection(netDir)
|
||||||
.attackType(attackType)
|
.attackType(attackType)
|
||||||
.flowBandWidth(flowBand)
|
.flowBandWidth(flowBand)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
// 创建处置任务
|
// 创建处置任务
|
||||||
MulReturnType<ErrorCode, DisposeTask> ret = disposeTaskService.createTask(task);
|
MulReturnType<ErrorCode, DisposeTask> ret = disposeTaskService.createTask(task);
|
||||||
|
|
||||||
// 设置返回消息
|
// 设置返回消息
|
||||||
TaskStartRsp rspInfo = TaskStartRsp.builder()
|
TaskStartRsp rspInfo = TaskStartRsp.builder()
|
||||||
.disposeIp(ip)
|
.disposeIp(ip)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
// 启动任务成功
|
// 启动任务成功
|
||||||
if (ret.getFirstParam() == ErrorCode.ERR_OK ||
|
if (ret.getFirstParam() == ErrorCode.ERR_OK ||
|
||||||
ret.getFirstParam() == ErrorCode.ERR_TASKRUNNING) {
|
ret.getFirstParam() == ErrorCode.ERR_TASKRUNNING) {
|
||||||
rspInfo.setTaskId(ret.getSecondParam().getId().toString());
|
rspInfo.setTaskId(ret.getSecondParam().getId().toString());
|
||||||
rspInfo.setExpireTime(ret.getSecondParam().getPlanEndTime());
|
rspInfo.setExpireTime(ret.getSecondParam().getPlanEndTime());
|
||||||
}
|
}
|
||||||
|
@ -228,13 +230,13 @@ public class DisposeTaskController {
|
||||||
// 停止成功
|
// 停止成功
|
||||||
if (ret.getFirstParam() == ErrorCode.ERR_OK) {
|
if (ret.getFirstParam() == ErrorCode.ERR_OK) {
|
||||||
rspInfo.setDisposeDevice(ret.getSecondParam().getDeviceTask().stream()
|
rspInfo.setDisposeDevice(ret.getSecondParam().getDeviceTask().stream()
|
||||||
.map(DeviceTask::getDeviceId)
|
.map(DeviceTask::getDeviceId)
|
||||||
.map(String::valueOf)
|
.map(String::valueOf)
|
||||||
.toArray(String[]::new));
|
.toArray(String[]::new));
|
||||||
rspInfo.setType(ret.getSecondParam().getDisposeCapacity().getValue());
|
rspInfo.setType(ret.getSecondParam().getDisposeCapacity().getValue());
|
||||||
rspInfo.setDisposeIp(ret.getSecondParam().getDisposeIp());
|
rspInfo.setDisposeIp(ret.getSecondParam().getDisposeIp());
|
||||||
rspInfo.setLeftTime(String.valueOf(Math.abs(
|
rspInfo.setLeftTime(String.valueOf(Math.abs(
|
||||||
Helper.getTimestampDiffNow(ret.getSecondParam().getPlanEndTime())) / 60));
|
Helper.getTimestampDiffNow(ret.getSecondParam().getPlanEndTime())) / 60));
|
||||||
}
|
}
|
||||||
|
|
||||||
rspInfo.setTaskId(tId);
|
rspInfo.setTaskId(tId);
|
||||||
|
@ -257,53 +259,79 @@ public class DisposeTaskController {
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
@ApiOperation("获取处置任务")
|
@ApiOperation("获取处置任务")
|
||||||
public ProtocolRespDTO<? extends BaseRespStatus> getAllDisposeTask(
|
public ProtocolRespDTO<? extends BaseRespStatus> getAllDisposeTask(
|
||||||
@Validated(ValidGroups.ProtocolCommonValid.class)
|
@Validated(ValidGroups.ProtocolCommonValid.class)
|
||||||
@RequestBody ProtocolReqDTO<BasePagesGetReq> mr
|
@RequestBody ProtocolReqDTO<BasePagesGetReq> mr
|
||||||
) {
|
) {
|
||||||
GetTaskRsp rspInfo = new GetTaskRsp();
|
GetTaskRsp rspInfo = GetTaskRsp.builder().build();
|
||||||
|
List<GetTaskDetail> getTaskDetail = new ArrayList<>();
|
||||||
|
|
||||||
MulReturnType<PageInfo<DisposeTask>, List<DisposeTask>> ret =
|
//获取TaskId列表
|
||||||
disposeTaskService.getPageDisposeTask(mr.getMsgContent().getStartPage(),
|
List<Long> reqTaskIds = Arrays.stream(mr.getMsgContent().getTaskId()).
|
||||||
mr.getMsgContent().getPageSize());
|
map(Long::parseLong).collect(Collectors.toList());
|
||||||
|
|
||||||
// 拼装返回数据
|
//获取所有可用处置任务
|
||||||
rspInfo.setStatus(ErrorCode.ERR_OK.getCode());
|
List<DisposeTask> taskList = disposeTaskService.getAllDisposeTask();
|
||||||
rspInfo.setMessage(new String[]{ErrorCode.ERR_OK.getMsg()});
|
List<Long> idArray = taskList.stream().filter(v -> reqTaskIds.size() == 0 || reqTaskIds.contains(v.getId()))
|
||||||
|
.map(DisposeTask::getId).collect(Collectors.toList());
|
||||||
|
|
||||||
// 分页信息
|
if (idArray.size() > 0) {
|
||||||
rspInfo.setCurPageNumber(ret.getFirstParam().getPageNum());
|
MulReturnType<PageInfo<DisposeTask>, List<DisposeTask>> ret =
|
||||||
rspInfo.setPageSize(ret.getFirstParam().getPageSize());
|
disposeTaskService.getPageDisposeTask(idArray,
|
||||||
rspInfo.setTotalItems((int) ret.getFirstParam().getTotal());
|
mr.getMsgContent().getStartPage(),
|
||||||
rspInfo.setTotalPages(ret.getFirstParam().getPages());
|
mr.getMsgContent().getPageSize());
|
||||||
|
|
||||||
ret.getSecondParam().forEach(v -> {
|
// 分页信息
|
||||||
GetTaskDetail taskDetail = GetTaskDetail.builder()
|
rspInfo.setCurPageNumber(ret.getFirstParam().getPageNum());
|
||||||
.taskId(String.valueOf(v.getId()))
|
rspInfo.setPageSize(ret.getFirstParam().getPageSize());
|
||||||
.accountId(String.valueOf(v.getAccountId()))
|
rspInfo.setTotalItems((int) ret.getFirstParam().getTotal());
|
||||||
.disposeCapacity(v.getDisposeCapacity().getValue())
|
rspInfo.setTotalPages(ret.getFirstParam().getPages());
|
||||||
.disposeIp(v.getDisposeIp())
|
|
||||||
.createTime(v.getCreateTime())
|
|
||||||
.planEndTime(v.getPlanEndTime())
|
|
||||||
.endTime(v.getEndTime())
|
|
||||||
.flowDirection(v.getFlowDirection().getValue())
|
|
||||||
.attackType(v.getAttackType().toString())
|
|
||||||
.flowBandWidth(v.getFlowBandWidth())
|
|
||||||
.currentStatus(v.getCurrentStatus().getValue())
|
|
||||||
.deviceTask(new ArrayList<>())
|
|
||||||
.build();
|
|
||||||
v.getDeviceTask().forEach(k -> {
|
|
||||||
GetDeviceTaskDetail deviceTaskDetail = GetDeviceTaskDetail.builder()
|
|
||||||
.devTaskId(String.valueOf(k.getId()))
|
|
||||||
.devId(String.valueOf(k.getDeviceId()))
|
|
||||||
.externId(String.valueOf(k.getExternId()))
|
|
||||||
.status(k.getStatus())
|
|
||||||
.build();
|
|
||||||
|
|
||||||
taskDetail.getDeviceTask().add(deviceTaskDetail);
|
ret.getSecondParam().forEach(v -> {
|
||||||
|
GetTaskDetail taskDetail = GetTaskDetail.builder()
|
||||||
|
.taskId(String.valueOf(v.getId()))
|
||||||
|
.accountId(String.valueOf(v.getAccountId()))
|
||||||
|
.disposeCapacity(v.getDisposeCapacity().getValue())
|
||||||
|
.disposeIp(v.getDisposeIp())
|
||||||
|
.createTime(v.getCreateTime())
|
||||||
|
.planEndTime(v.getPlanEndTime())
|
||||||
|
.endTime(v.getEndTime())
|
||||||
|
.flowDirection(v.getFlowDirection().getValue())
|
||||||
|
.attackType(v.getAttackType().toString())
|
||||||
|
.flowBandWidth(v.getFlowBandWidth())
|
||||||
|
.currentStatus(v.getCurrentStatus().getValue())
|
||||||
|
.status(ErrorCode.ERR_OK.getCode())
|
||||||
|
.message(new String[]{ErrorCode.ERR_OK.getMsg()})
|
||||||
|
.deviceTask(new ArrayList<>())
|
||||||
|
.build();
|
||||||
|
v.getDeviceTask().forEach(k -> {
|
||||||
|
GetDeviceTaskDetail deviceTaskDetail = GetDeviceTaskDetail.builder()
|
||||||
|
.devTaskId(String.valueOf(k.getId()))
|
||||||
|
.devId(String.valueOf(k.getDeviceId()))
|
||||||
|
.externId(String.valueOf(k.getExternId()))
|
||||||
|
.status(k.getStatus())
|
||||||
|
.build();
|
||||||
|
|
||||||
|
taskDetail.getDeviceTask().add(deviceTaskDetail);
|
||||||
|
});
|
||||||
|
|
||||||
|
getTaskDetail.add(taskDetail);
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
rspInfo.getItems().add(taskDetail);
|
// 设置不存在taskId的错误码
|
||||||
});
|
if (reqTaskIds.stream().anyMatch(v -> taskList.stream().noneMatch(k -> k.getId().equals(v)))) {
|
||||||
|
reqTaskIds.stream()
|
||||||
|
.filter(v -> taskList.stream().noneMatch(k -> k.getId().equals(v)))
|
||||||
|
.forEach(v -> {
|
||||||
|
GetTaskDetail td = GetTaskDetail.builder().build();
|
||||||
|
td.setTaskId(String.valueOf(v));
|
||||||
|
td.setStatus(ErrorCode.ERR_NOSUCHTASK.getCode());
|
||||||
|
td.setMessage(new String[]{ErrorCode.ERR_NOSUCHTASK.getMsg()});
|
||||||
|
getTaskDetail.add(td);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
rspInfo.setItems(getTaskDetail);
|
||||||
|
|
||||||
return ProtocolRespDTO.result(ErrorCode.ERR_OK, rspInfo);
|
return ProtocolRespDTO.result(ErrorCode.ERR_OK, rspInfo);
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,13 +64,22 @@ public interface DisposeTaskManager {
|
||||||
*/
|
*/
|
||||||
DisposeTask getDisposeTaskById(Long taskId);
|
DisposeTask getDisposeTaskById(Long taskId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets dispose task by id.
|
||||||
|
*
|
||||||
|
* @return the dispose task list
|
||||||
|
*/
|
||||||
|
List<DisposeTask> getDisposeTasks();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets pages of task.
|
* Gets pages of task.
|
||||||
*
|
*
|
||||||
|
* @param taskId the task id
|
||||||
* @param startPage the start page
|
* @param startPage the start page
|
||||||
* @param pageSize the page size
|
* @param pageSize the page size
|
||||||
* @return the pages of task
|
* @return the pages of task
|
||||||
*/
|
*/
|
||||||
MulReturnType<PageInfo<DisposeTask>, List<DisposeTask>> getPagesOfTask(Integer startPage,
|
MulReturnType<PageInfo<DisposeTask>, List<DisposeTask>> getPagesOfTask(List<Long> taskId,
|
||||||
|
Integer startPage,
|
||||||
Integer pageSize);
|
Integer pageSize);
|
||||||
}
|
}
|
||||||
|
|
|
@ -109,20 +109,35 @@ public class DisposeTaskManagerImpl implements DisposeTaskManager {
|
||||||
return disposeTaskMapper.getDisposeTaskById(taskId);
|
return disposeTaskMapper.getDisposeTaskById(taskId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets dispose task by id.
|
||||||
|
*
|
||||||
|
* @return the dispose task list
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<DisposeTask> getDisposeTasks() {
|
||||||
|
return disposeTaskMapper.selectAll();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets pages of task.
|
* Gets pages of task.
|
||||||
*
|
*
|
||||||
|
* @param taskId the task id
|
||||||
* @param startPage the start page
|
* @param startPage the start page
|
||||||
* @param pageSize the page size
|
* @param pageSize the page size
|
||||||
* @return the pages of task
|
* @return the pages of task
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public MulReturnType<PageInfo<DisposeTask>, List<DisposeTask>> getPagesOfTask(Integer startPage,
|
public MulReturnType<PageInfo<DisposeTask>, List<DisposeTask>> getPagesOfTask(List<Long> taskId,
|
||||||
|
Integer startPage,
|
||||||
Integer pageSize) {
|
Integer pageSize) {
|
||||||
List<DisposeTask> rspList = new ArrayList<>();
|
List<DisposeTask> rspList = new ArrayList<>();
|
||||||
// 设置分页信息
|
// 设置分页信息
|
||||||
PageHelper.startPage(startPage, pageSize);
|
PageHelper.startPage(startPage, pageSize);
|
||||||
List<DisposeTask> taskList = disposeTaskMapper.selectPageAll();
|
|
||||||
|
//获取所有可用处置任务
|
||||||
|
List<DisposeTask> taskList = disposeTaskMapper.selectPageAll().stream().
|
||||||
|
filter(v->taskId.size() == 0 || taskId.contains(v.getId())).collect(Collectors.toList());
|
||||||
|
|
||||||
if (taskList == null) {
|
if (taskList == null) {
|
||||||
taskList = new ArrayList<>();
|
taskList = new ArrayList<>();
|
||||||
|
|
|
@ -10,6 +10,7 @@ import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
import javax.validation.constraints.NotNull;
|
import javax.validation.constraints.NotNull;
|
||||||
import javax.validation.constraints.Positive;
|
import javax.validation.constraints.Positive;
|
||||||
|
import javax.validation.constraints.Size;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The type Get device req.
|
* The type Get device req.
|
||||||
|
@ -22,6 +23,12 @@ import javax.validation.constraints.Positive;
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||||
public class BasePagesGetReq {
|
public class BasePagesGetReq {
|
||||||
|
/**
|
||||||
|
* The Task Id.
|
||||||
|
*/
|
||||||
|
@NotNull(message = "taskId 字段不能为空", groups = ValidGroups.ProtocolCommonValid.class)
|
||||||
|
@Size(min = 1, message = "taskId 字段必须指定明确任务id编号", groups = ValidGroups.ExplicitIdArrayValid.class)
|
||||||
|
private String[] taskId;
|
||||||
/**
|
/**
|
||||||
* The Start page.
|
* The Start page.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -19,7 +19,7 @@ import java.util.List;
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@JsonPropertyOrder({"taskId", "accountId", "disposeCapacity", "disposeIp", "createTime", "planEndTime", "endTime",
|
@JsonPropertyOrder({"taskId", "accountId", "disposeCapacity", "disposeIp", "createTime", "planEndTime", "endTime",
|
||||||
"flowDirection", "attackType", "flowBandWidth", "currentStatus", "deviceTask"})
|
"flowDirection", "attackType", "flowBandWidth", "currentStatus", "deviceTask", "status", "message"})
|
||||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||||
public class GetTaskDetail {
|
public class GetTaskDetail {
|
||||||
|
|
||||||
|
@ -67,6 +67,15 @@ public class GetTaskDetail {
|
||||||
* The Current status.
|
* The Current status.
|
||||||
*/
|
*/
|
||||||
private Integer currentStatus;
|
private Integer currentStatus;
|
||||||
|
/**
|
||||||
|
* 0:成功;其它:失败原因.
|
||||||
|
*/
|
||||||
|
private Integer status;
|
||||||
|
/**
|
||||||
|
* 登录消息: status状态码对应的提示信息
|
||||||
|
*/
|
||||||
|
private String[] message;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Device task.
|
* The Device task.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -38,13 +38,22 @@ public interface DisposeTaskService {
|
||||||
*/
|
*/
|
||||||
DisposeTask getDisposeTask(Long taskId);
|
DisposeTask getDisposeTask(Long taskId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets dispose task.
|
||||||
|
*
|
||||||
|
* @return the dispose task list
|
||||||
|
*/
|
||||||
|
List<DisposeTask> getAllDisposeTask();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets page dispose task.
|
* Gets page dispose task.
|
||||||
*
|
*
|
||||||
|
* @param taskId the task id
|
||||||
* @param startPage the start page
|
* @param startPage the start page
|
||||||
* @param pageSize the page size
|
* @param pageSize the page size
|
||||||
* @return the page dispose task
|
* @return the page dispose task
|
||||||
*/
|
*/
|
||||||
MulReturnType<PageInfo<DisposeTask>, List<DisposeTask>> getPageDisposeTask(Integer startPage,
|
MulReturnType<PageInfo<DisposeTask>, List<DisposeTask>> getPageDisposeTask(List<Long> taskId,
|
||||||
|
Integer startPage,
|
||||||
Integer pageSize);
|
Integer pageSize);
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,14 +41,14 @@ public class DisposeTaskServiceImpl implements DisposeTaskService {
|
||||||
@Override
|
@Override
|
||||||
public MulReturnType<ErrorCode, DisposeTask> createTask(DisposeTask task) {
|
public MulReturnType<ErrorCode, DisposeTask> createTask(DisposeTask task) {
|
||||||
DisposeTask exitTask = disposeTaskManager.getDisposeTask(task.getDeviceId(),
|
DisposeTask exitTask = disposeTaskManager.getDisposeTask(task.getDeviceId(),
|
||||||
task.getDisposeIp(), task.getDisposeCapacity());
|
task.getDisposeIp(), task.getDisposeCapacity());
|
||||||
|
|
||||||
if (exitTask != null) {
|
if (exitTask != null) {
|
||||||
return new MulReturnType<>(ErrorCode.ERR_TASKRUNNING, exitTask);
|
return new MulReturnType<>(ErrorCode.ERR_TASKRUNNING, exitTask);
|
||||||
}
|
}
|
||||||
|
|
||||||
ErrorCode err = disposeAbilityRouterService.verifyDisposeCapacity(
|
ErrorCode err = disposeAbilityRouterService.verifyDisposeCapacity(
|
||||||
task.getDeviceId(), task.getDisposeIp(), task.getDisposeCapacity()
|
task.getDeviceId(), task.getDisposeIp(), task.getDisposeCapacity()
|
||||||
);
|
);
|
||||||
|
|
||||||
if (err != ErrorCode.ERR_OK) {
|
if (err != ErrorCode.ERR_OK) {
|
||||||
|
@ -56,7 +56,7 @@ public class DisposeTaskServiceImpl implements DisposeTaskService {
|
||||||
}
|
}
|
||||||
|
|
||||||
return new MulReturnType<>(disposeTaskManager.addDisposeTask(task),
|
return new MulReturnType<>(disposeTaskManager.addDisposeTask(task),
|
||||||
disposeTaskManager.getDisposeTaskById(task.getId()));
|
disposeTaskManager.getDisposeTaskById(task.getId()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -95,6 +95,15 @@ public class DisposeTaskServiceImpl implements DisposeTaskService {
|
||||||
return disposeTaskManager.getDisposeTaskById(taskId);
|
return disposeTaskManager.getDisposeTaskById(taskId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets dispose task.
|
||||||
|
*
|
||||||
|
* @return the dispose task list
|
||||||
|
*/
|
||||||
|
public List<DisposeTask> getAllDisposeTask() {
|
||||||
|
return disposeTaskManager.getDisposeTasks();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets page dispose task.
|
* Gets page dispose task.
|
||||||
*
|
*
|
||||||
|
@ -103,8 +112,9 @@ public class DisposeTaskServiceImpl implements DisposeTaskService {
|
||||||
* @return the page dispose task
|
* @return the page dispose task
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public MulReturnType<PageInfo<DisposeTask>, List<DisposeTask>> getPageDisposeTask(Integer startPage,
|
public MulReturnType<PageInfo<DisposeTask>, List<DisposeTask>> getPageDisposeTask(List<Long> taskId,
|
||||||
|
Integer startPage,
|
||||||
Integer pageSize) {
|
Integer pageSize) {
|
||||||
return disposeTaskManager.getPagesOfTask(startPage, pageSize);
|
return disposeTaskManager.getPagesOfTask(taskId, startPage, pageSize);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,6 +46,7 @@ import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
@ -347,7 +348,9 @@ public class DisposeTaskControllerTest extends InitTestEnvironment {
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void a5_getAllDisposeTask() throws Exception {
|
public void a5_getAllDisposeTask() throws Exception {
|
||||||
|
String[] taskId = {};
|
||||||
BasePagesGetReq req = BasePagesGetReq.builder()
|
BasePagesGetReq req = BasePagesGetReq.builder()
|
||||||
|
.taskId(taskId)
|
||||||
.startPage(1)
|
.startPage(1)
|
||||||
.pageSize(20)
|
.pageSize(20)
|
||||||
.build();
|
.build();
|
||||||
|
@ -379,9 +382,9 @@ public class DisposeTaskControllerTest extends InitTestEnvironment {
|
||||||
|
|
||||||
Assert.assertNotNull(rspInfo.getMsgContent());
|
Assert.assertNotNull(rspInfo.getMsgContent());
|
||||||
Assert.assertTrue(rspInfo.getMsgContent().getCurPageNumber() <= req.getPageSize());
|
Assert.assertTrue(rspInfo.getMsgContent().getCurPageNumber() <= req.getPageSize());
|
||||||
Assert.assertEquals(rspInfo.getMsgContent().getPageSize(), req.getPageSize());
|
|
||||||
|
|
||||||
MulReturnType<PageInfo<DisposeTask>, List<DisposeTask>> result = disposeTaskService.getPageDisposeTask(req.getStartPage(), req.getPageSize());
|
List<Long> taskIds = Arrays.stream(req.getTaskId()).map(Long::parseLong).collect(Collectors.toList());
|
||||||
|
MulReturnType<PageInfo<DisposeTask>, List<DisposeTask>> result = disposeTaskService.getPageDisposeTask(taskIds, req.getStartPage(), req.getPageSize());
|
||||||
Assert.assertTrue(rspInfo.getMsgContent().getTotalItems() >= result.getSecondParam().size());
|
Assert.assertTrue(rspInfo.getMsgContent().getTotalItems() >= result.getSecondParam().size());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue