【新增】 添加删除用户所有任务,添加查询已经存在ws列表
This commit is contained in:
@@ -356,6 +356,20 @@ public class AutoToolsController {
|
|||||||
return CommonResult.success(true);
|
return CommonResult.success(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 停止考试(用户所有)
|
||||||
|
*
|
||||||
|
* @return true
|
||||||
|
*/
|
||||||
|
@GetMapping("/allStopExam")
|
||||||
|
public CommonResult<Boolean> stopExam() {
|
||||||
|
String userId = null;
|
||||||
|
userId = String.valueOf(SecurityFrameworkUtils.getLoginUserId());
|
||||||
|
// 删除该用户对应的线程池
|
||||||
|
taskManager.stopTask(userId);
|
||||||
|
return CommonResult.success(true);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 停止考试
|
* 停止考试
|
||||||
*
|
*
|
||||||
@@ -502,6 +516,12 @@ public class AutoToolsController {
|
|||||||
return CommonResult.error(1_0001_002,"没有找到对应的学生信息");
|
return CommonResult.error(1_0001_002,"没有找到对应的学生信息");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GetMapping("/taskStatus")
|
||||||
|
@Operation(summary = "获取WS的任务列表")
|
||||||
|
public CommonResult<Map<String, Object>> logTaskStatus() {
|
||||||
|
return CommonResult.success(taskManager.getTasksInfo());
|
||||||
|
}
|
||||||
|
|
||||||
// 时间转换
|
// 时间转换
|
||||||
public static String formatLongDuration(int totalSeconds) {
|
public static String formatLongDuration(int totalSeconds) {
|
||||||
return TaskManager.formatLongDuration(totalSeconds);
|
return TaskManager.formatLongDuration(totalSeconds);
|
||||||
|
@@ -13,6 +13,8 @@ import pc.exam.pp.module.infra.api.websocket.WebSocketSenderApi;
|
|||||||
import pc.exam.pp.module.judgement.controller.admin.autoTools.vo.StuInTheExam;
|
import pc.exam.pp.module.judgement.controller.admin.autoTools.vo.StuInTheExam;
|
||||||
import pc.exam.pp.module.judgement.controller.admin.autoTools.vo.StuTheExamInfo;
|
import pc.exam.pp.module.judgement.controller.admin.autoTools.vo.StuTheExamInfo;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.concurrent.*;
|
import java.util.concurrent.*;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
@@ -64,6 +66,13 @@ public class TaskManager {
|
|||||||
log.info("任务 {} 已启动", userId);
|
log.info("任务 {} 已启动", userId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Map<String, Object> getTasksInfo() {
|
||||||
|
Map<String, Object> info = new HashMap<>();
|
||||||
|
info.put("totalTasks", tasks.size());
|
||||||
|
info.put("activeUserIds", new ArrayList<>(tasks.keySet()));
|
||||||
|
return info;
|
||||||
|
}
|
||||||
|
|
||||||
/** 结束任务 */
|
/** 结束任务 */
|
||||||
public void stopTask(String userId) {
|
public void stopTask(String userId) {
|
||||||
ScheduledFuture<?> future = tasks.get(userId);
|
ScheduledFuture<?> future = tasks.get(userId);
|
||||||
|
Reference in New Issue
Block a user