REM:
1. 还原处置任务状态枚举取值
2. 增加停止任务对任务状态的检测
This commit is contained in:
HuangXin 2020-09-01 09:22:29 +08:00
parent 9c1007b470
commit e1d0790b80
5 changed files with 46 additions and 10 deletions

View File

@ -10,19 +10,19 @@ public enum DisposeCapacityType implements BaseEnum {
/**
* The Cleanup.
*/
CLEANUP(1, "清洗能力"),
CLEANUP(0, "清洗能力"),
/**
* Blackhool dispose capacity type.
*/
BLACKHOOL(2, "压制能力"),
BLACKHOOL(1, "压制能力"),
/**
* The Hidepend.
*/
HIDEPEND(3, "高防能力"),
HIDEPEND(2, "高防能力"),
/**
* The Detecive.
*/
DETECIVE(4, "检测能力"),
DETECTIVE(3, "检测能力"),
;
/**

View File

@ -1,7 +1,7 @@
package com.dispose.common;
/**
* The enum Task status.
* The enum Dispose task status.
*
* @author <huangxin@cmhi.chinamoblie.com>
*/
@ -22,9 +22,8 @@ public enum DisposeTaskStatus implements BaseEnum {
* The Task finished.
*/
TASK_FINISHED(3, "结束"),
/**
* Task canceled task status.
* The Task canceled.
*/
TASK_CANCELED(4, "用户中止"),
/**
@ -43,7 +42,7 @@ public enum DisposeTaskStatus implements BaseEnum {
private final String readme;
/**
* Instantiates a new Task status.
* Instantiates a new Dispose task status.
*
* @param code the code
* @param readme the readme
@ -72,4 +71,16 @@ public enum DisposeTaskStatus implements BaseEnum {
public String getDescription() {
return this.readme;
}
/**
* Task is running boolean.
*
* @return the boolean
*/
public boolean taskIsRunning() {
return (DisposeTaskStatus.TASK_NEW.getValue().equals(this.code)
|| DisposeTaskStatus.TASK_STARTED.getValue().equals(this.code)
|| DisposeTaskStatus.TASK_STARTING.getValue().equals(this.code));
}
}

View File

@ -33,8 +33,8 @@ public class TaskStartReq {
* The Type.
*/
@NotNull(message = "type 处置类型不能为空", groups = ValidGroups.TaskStartReqValid.class)
@Range(min = 1, max = 4,
message = "type 字段取值为 [1, 4]",
@Range(min = 0, max = 3,
message = "type 字段取值为 [0, 3]",
groups = ValidGroups.TaskStartReqValid.class)
private Integer type;
/**

View File

@ -26,4 +26,13 @@ public interface DisposeTaskService {
* @return the mul return type
*/
MulReturnType<ErrorCode, DisposeTask> stopTask(Long taskId);
/**
* Gets dispose task.
*
* @param taskId the task id
* @return the dispose task
*/
DisposeTask getDisposeTask(Long taskId);
}

View File

@ -55,10 +55,26 @@ public class DisposeTaskServiceImpl implements DisposeTaskService {
return new MulReturnType<>(ErrorCode.ERR_NOSUCHTASK, null);
}
if (!task.getCurrentStatus().taskIsRunning()) {
return new MulReturnType<>(ErrorCode.ERR_TASKNOTRUNNING, null);
}
if (!disposeTaskManager.changeDisposeTaskStatus(taskId, DisposeTaskStatus.TASK_CANCELED)) {
return new MulReturnType<>(ErrorCode.ERR_DATABASE, null);
}
return new MulReturnType<>(ErrorCode.ERR_OK, task);
}
/**
* Gets dispose task.
*
* @param taskId the task id
* @return the dispose task
*/
@Override
public DisposeTask getDisposeTask(Long taskId) {
return disposeTaskManager.getDisposeTaskById(taskId);
}
}