REM:
1. 增加处置设备列表接口的入参判断
2. 增加获取节点处置任务接口的入参判断
This commit is contained in:
chenlinghy 2020-05-28 14:27:09 +08:00
parent 8fb5fc6a43
commit 8e11ed64dc
2 changed files with 32 additions and 21 deletions

View File

@ -459,9 +459,6 @@ public class DisposeNodeInfoController {
public ProtocolRespDTO getDisposeNodeList(@RequestBody ProtocolReqDTO mr,
@RequestHeader HttpHeaders headers)
throws JsonProcessingException {
boolean isGetAllNode = false;
IDArrayReq reqInfo = null;
ErrorCode err = mr.verifyRequest(headers);
if (err != ErrorCode.ERR_OK) {
@ -469,20 +466,23 @@ public class DisposeNodeInfoController {
return ProtocolRespDTO.result(err);
}
if (mr.getMsgContent() == null || mr.getMsgContent()
.length() == 0) {
isGetAllNode = true;
} else {
reqInfo = mr.getRequestObject(IDArrayReq.class);
if (reqInfo == null || reqInfo.getId() == null || reqInfo.getId().length == 0) {
isGetAllNode = true;
}
if (mr.getMsgContent() == null || mr.getMsgContent().length() == 0) {
log.error("ProtocolReqDTO msgContent error");
return ProtocolRespDTO.result(ErrorCode.ERR_PARAMS);
}
IDArrayReq reqInfo = mr.getRequestObject(IDArrayReq.class);
DisposeNodeListRsp rspInfo = new DisposeNodeListRsp();
rspInfo.setItems(new ArrayList<>());
if (isGetAllNode) {
for (String deviceId : reqInfo.getId()
) {
if (deviceId == null || deviceId.length() == 0) {
return ProtocolRespDTO.result(ErrorCode.ERR_PARAMS);
}
}
if (reqInfo.getId().length == 0) {
List<DisposeDevice> devList = disposeNodeManager.getAllDisposeDevice();
if (devList != null && devList.size() > 0) {

View File

@ -158,20 +158,20 @@ public class DisposeTaskController {
rspInfo.getItems().add(taskData);
} else {
ret.forEach(k -> {
if(k.getFirstParam() == ErrorCode.ERR_OK){
if (k.getFirstParam() == ErrorCode.ERR_OK) {
ErrorCode retError = k.getFirstParam();
TaskInfoDetail taskInfo = k.getSecondParam();
taskData.setId(String.valueOf(taskInfo.getDeviceId()));
taskData.setTaskId(String.valueOf(taskInfo.getId()));
taskData.setType(taskInfo.getType());
taskData.setDisposeIp(taskInfo.getDisposeIp());
taskData.setLeftTime(Math.abs(Helper.getTimestampDiffNow(taskInfo.getPlanEndTime()))/ 60);
taskData.setLeftTime(Math.abs(Helper.getTimestampDiffNow(taskInfo.getPlanEndTime())) / 60);
taskData.setStatus(retError.getCode());
taskData.setMessage(retError.getMsg());
rspInfo.getItems().add(taskData);
}else{
} else {
log.error("Stop task: taskId:{}, error:{}", v, k.getFirstParam().getMsg());
taskData.setStatus(k.getFirstParam().getCode());
taskData.setMessage(k.getFirstParam().getMsg());
@ -227,7 +227,7 @@ public class DisposeTaskController {
taskData.setTaskId(String.valueOf(taskInfo.getId()));
taskData.setType(taskInfo.getType());
taskData.setDisposeIp(taskInfo.getDisposeIp());
taskData.setLeftTime(Math.abs(Helper.getTimestampDiffNow(taskInfo.getPlanEndTime()))/ 60);
taskData.setLeftTime(Math.abs(Helper.getTimestampDiffNow(taskInfo.getPlanEndTime())) / 60);
taskData.setStatus(retError.getCode());
taskData.setMessage(retError.getMsg());
@ -289,13 +289,13 @@ public class DisposeTaskController {
taskData.setTaskId(String.valueOf(taskInfo.getId()));
taskData.setType(taskInfo.getType());
taskData.setDisposeIp(taskInfo.getDisposeIp());
taskData.setLeftTime(Math.abs(Helper.getTimestampDiffNow(taskInfo.getPlanEndTime()))/ 60);
taskData.setLeftTime(Math.abs(Helper.getTimestampDiffNow(taskInfo.getPlanEndTime())) / 60);
taskData.setStatus(retError.getCode());
taskData.setMessage(retError.getMsg());
rspInfo.getItems().add(taskData);
}else{
} else {
log.error("Stop task: deviceId:{}, type:{}, error:{}", v.getId(),
v.getType(), k.getFirstParam().getMsg());
TaskInfoData taskData = TaskInfoData.builder().type(v.getType()).build();
@ -344,7 +344,7 @@ public class DisposeTaskController {
rspInfo.getItems().add(taskData);
} else {
ret.forEach(k -> {
if(k.getFirstParam() == ErrorCode.ERR_OK){
if (k.getFirstParam() == ErrorCode.ERR_OK) {
TaskInfoData taskData = TaskInfoData.builder().type(reqInfo.getType()).build();
ErrorCode retError = k.getFirstParam();
TaskInfoDetail taskInfo = k.getSecondParam();
@ -352,13 +352,13 @@ public class DisposeTaskController {
taskData.setTaskId(String.valueOf(taskInfo.getId()));
taskData.setType(taskInfo.getType());
taskData.setDisposeIp(taskInfo.getDisposeIp());
taskData.setLeftTime(Math.abs(Helper.getTimestampDiffNow(taskInfo.getPlanEndTime()))/ 60);
taskData.setLeftTime(Math.abs(Helper.getTimestampDiffNow(taskInfo.getPlanEndTime())) / 60);
taskData.setStatus(retError.getCode());
taskData.setMessage(retError.getMsg());
rspInfo.getItems().add(taskData);
}else{
} else {
log.error("No task to stop: error:{}", k.getFirstParam().getMsg());
TaskInfoData taskData = TaskInfoData.builder().type(reqInfo.getType()).build();
taskData.setStatus(k.getFirstParam().getCode());
@ -394,6 +394,17 @@ public class DisposeTaskController {
GetTaskReq reqInfo = mr.getRequestObject(GetTaskReq.class);
NodeTaskRsp rspInfo = new NodeTaskRsp();
if (reqInfo.getId().length == 0 || reqInfo.getId() == null || reqInfo.getType() == null) {
return ProtocolRespDTO.result(ErrorCode.ERR_PARAMS);
}
for (String deviceId : reqInfo.getId()
) {
if (deviceId.length() == 0) {
return ProtocolRespDTO.result(ErrorCode.ERR_PARAMS);
}
}
List<DisposeDevice> valuableData = disposeNodeManager.getAllDisposeDevice()
.stream()
.filter(v -> reqInfo.getId().length == 0