【修改】 1、新增项目启动清除所有的任务ID;2、修改ws send方法参数
This commit is contained in:
@@ -212,7 +212,7 @@ public class AutoToolsController {
|
||||
stuTheExamInfo.setNetwork("强");
|
||||
// 创建对应的线程池
|
||||
if (loginUser != null) {
|
||||
taskManager.startTask(stuInTheExam, stuTheExamInfo, token, countdown, new AtomicInteger(0), loginUser.getId() + "_" + stuInTheExam.getTaskId() + "_" + stuInTheExam.getPaperId());
|
||||
taskManager.startTask(loginUser.getId(), stuInTheExam, stuTheExamInfo, token, countdown, new AtomicInteger(0), loginUser.getId() + "_" + stuInTheExam.getTaskId() + "_" + stuInTheExam.getPaperId());
|
||||
}
|
||||
return CommonResult.success(token);
|
||||
}
|
||||
@@ -321,7 +321,7 @@ public class AutoToolsController {
|
||||
stuTheExamInfo.setEndStatus(1);
|
||||
// 返回数据-网络状态
|
||||
stuTheExamInfo.setNetwork("强");
|
||||
taskManager.startTask(stuInTheExam, stuTheExamInfo, token, countdown, new AtomicInteger(0), loginUser.getId() + "_" + stuInTheExam.getTaskId() + "_" + stuInTheExam.getPaperId());
|
||||
taskManager.startTask(loginUser.getId(), stuInTheExam, stuTheExamInfo, token, countdown, new AtomicInteger(0), loginUser.getId() + "_" + stuInTheExam.getTaskId() + "_" + stuInTheExam.getPaperId());
|
||||
// 将数组的值进行复制
|
||||
BeanUtils.copyProperties(examPaperVo, examRestartPaperVo);
|
||||
examRestartPaperVo.setWsToken(token);
|
||||
@@ -501,7 +501,7 @@ public class AutoToolsController {
|
||||
stuTheExamInfo.setEndStatus(1);
|
||||
// 返回数据-网络状态
|
||||
stuTheExamInfo.setNetwork("强");
|
||||
taskManager.startTask(stuInTheExam, stuTheExamInfo, token, countdown, new AtomicInteger(0), stuId + "_" + stuInTheExam.getTaskId() + "_" + paperId);
|
||||
taskManager.startTask(Long.valueOf(stuId), stuInTheExam, stuTheExamInfo, token, countdown, new AtomicInteger(0), stuId + "_" + stuInTheExam.getTaskId() + "_" + paperId);
|
||||
// 将数组的值进行复制
|
||||
BeanUtils.copyProperties(examPaperVo, examRestartPaperVo);
|
||||
examRestartPaperVo.setWsToken(token);
|
||||
|
@@ -29,7 +29,7 @@ public class TaskManager {
|
||||
private final Map<String, ScheduledFuture<?>> tasks = new ConcurrentHashMap<>();
|
||||
|
||||
/** 开始任务(每秒执行一次) */
|
||||
public void startTask(StuInTheExam stuInTheExam, StuTheExamInfo stuTheExamInfo, String token, AtomicInteger countdown, AtomicInteger counter, String userId) {
|
||||
public void startTask(Long userIds, StuInTheExam stuInTheExam, StuTheExamInfo stuTheExamInfo, String token, AtomicInteger countdown, AtomicInteger counter, String userId) {
|
||||
// 判断 token 的线程是否存在,存在则不进行任何动作
|
||||
if (tasks.containsKey(userId)) {
|
||||
log.info("任务 {} 已存在,未重复启动", userId);
|
||||
@@ -59,7 +59,8 @@ public class TaskManager {
|
||||
}
|
||||
}
|
||||
stuTheExamInfo.setTime(formatLongDuration(remaining));
|
||||
webSocketSenderApi.sendObject(UserTypeEnum.ADMIN.getValue(), "InTheExam", stuTheExamInfo);
|
||||
webSocketSenderApi.sendObject(UserTypeEnum.ADMIN.getValue(), userIds, "InTheExam", stuTheExamInfo);
|
||||
// webSocketSenderApi.sendObject(UserTypeEnum.ADMIN.getValue(), "InTheExam", stuTheExamInfo);
|
||||
});
|
||||
return scheduler.scheduleAtFixedRate(task, 0, 1, TimeUnit.SECONDS);
|
||||
});
|
||||
|
Reference in New Issue
Block a user