From a7fd185889cabe3c05e94017ac8215dcfb9c5e50 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?DESKTOP-9ERGOBP=5C=E4=BB=BB=E7=BB=B4=E7=82=B3?= Date: Mon, 13 Oct 2025 23:39:44 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E6=96=B0=E5=A2=9E=E3=80=91=20?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=88=A0=E9=99=A4=E7=94=A8=E6=88=B7=E6=89=80?= =?UTF-8?q?=E6=9C=89=E4=BB=BB=E5=8A=A1=EF=BC=8C=E6=B7=BB=E5=8A=A0=E6=9F=A5?= =?UTF-8?q?=E8=AF=A2=E5=B7=B2=E7=BB=8F=E5=AD=98=E5=9C=A8ws=E5=88=97?= =?UTF-8?q?=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/autoTools/AutoToolsController.java | 20 +++++++++++++++++++ .../module/judgement/service/TaskManager.java | 9 +++++++++ 2 files changed, 29 insertions(+) diff --git a/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/controller/admin/autoTools/AutoToolsController.java b/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/controller/admin/autoTools/AutoToolsController.java index af34262f..db9df7b3 100644 --- a/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/controller/admin/autoTools/AutoToolsController.java +++ b/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/controller/admin/autoTools/AutoToolsController.java @@ -356,6 +356,20 @@ public class AutoToolsController { return CommonResult.success(true); } + /** + * 停止考试(用户所有) + * + * @return true + */ + @GetMapping("/allStopExam") + public CommonResult 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,"没有找到对应的学生信息"); } + @GetMapping("/taskStatus") + @Operation(summary = "获取WS的任务列表") + public CommonResult> logTaskStatus() { + return CommonResult.success(taskManager.getTasksInfo()); + } + // 时间转换 public static String formatLongDuration(int totalSeconds) { return TaskManager.formatLongDuration(totalSeconds); diff --git a/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/service/TaskManager.java b/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/service/TaskManager.java index 05318d30..19f5c421 100644 --- a/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/service/TaskManager.java +++ b/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/service/TaskManager.java @@ -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.StuTheExamInfo; +import java.util.ArrayList; +import java.util.HashMap; import java.util.Map; import java.util.concurrent.*; import java.util.concurrent.atomic.AtomicInteger; @@ -64,6 +66,13 @@ public class TaskManager { log.info("任务 {} 已启动", userId); } + public Map getTasksInfo() { + Map info = new HashMap<>(); + info.put("totalTasks", tasks.size()); + info.put("activeUserIds", new ArrayList<>(tasks.keySet())); + return info; + } + /** 结束任务 */ public void stopTask(String userId) { ScheduledFuture future = tasks.get(userId);