Compare commits
5 Commits
981fb9b466
...
master
Author | SHA1 | Date | |
---|---|---|---|
![]() |
02bc650c1b | ||
![]() |
ad2b0b510e | ||
![]() |
c708a30443 | ||
4095ef88f9 | |||
![]() |
3889ce1414 |
@@ -64,7 +64,7 @@ public class AppCheckController {
|
||||
// 根据taskId查询下面有多少题型,然后查找对应的软件环境,在新增
|
||||
@GetMapping("/getAppCheckListByTaskId/{taskId}")
|
||||
public CommonResult<Boolean> getAppCheckListByTaskId(@PathVariable("taskId") String taskId){
|
||||
List<AppCheckDO> appCheckDOList = new ArrayList<>();
|
||||
List<AppCheckDO> appCheckDOList = appCheckService.getAppList(taskId);
|
||||
// 根据试卷方案ID查询下面试卷的试题的组成部分
|
||||
List<EducationPaperScheme> list = educationPaperSchemeService.getInfoDataByTaskId(taskId);
|
||||
for (EducationPaperScheme educationPaperScheme : list) {
|
||||
@@ -80,16 +80,19 @@ public class AppCheckController {
|
||||
// 判断是否在数组中存在
|
||||
boolean exists = appCheckDOList.stream()
|
||||
.anyMatch(a -> exams.getRoles().equals(a.getAppName())); // 根据 appName 判断
|
||||
|
||||
if (!exists) {
|
||||
appCheckDOList.add(appCheckDO);
|
||||
// appCheckDOList.add(appCheckDO);
|
||||
// 添加
|
||||
appCheckService.insertAppCheck(appCheckDO);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// 添加
|
||||
for (AppCheckDO appCheckDO : appCheckDOList) {
|
||||
appCheckService.insertAppCheck(appCheckDO);
|
||||
}
|
||||
// for (AppCheckDO appCheckDO : appCheckDOList) {
|
||||
// appCheckService.insertAppCheck(appCheckDO);
|
||||
// }
|
||||
return success(true);
|
||||
}
|
||||
|
||||
|
@@ -3,13 +3,20 @@ package pc.exam.pp.module.exam.controller.admin.paper;
|
||||
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.annotation.security.PermitAll;
|
||||
import org.checkerframework.checker.units.qual.C;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import pc.exam.pp.framework.common.pojo.CommonResult;
|
||||
import pc.exam.pp.framework.tenant.core.aop.TenantIgnore;
|
||||
import pc.exam.pp.module.exam.dal.dataobject.EducationPaperParam;
|
||||
import pc.exam.pp.module.exam.dal.dataobject.ExamWhiteListDO;
|
||||
import pc.exam.pp.module.exam.dal.dataobject.app.AppCheckDO;
|
||||
import pc.exam.pp.module.exam.service.paper.IEducationPaperParamService;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static pc.exam.pp.framework.common.pojo.CommonResult.success;
|
||||
import static pc.exam.pp.module.infra.enums.ErrorCodeConstants.DEMO03_PAPER_SESSION_EXISTS;
|
||||
|
||||
/**
|
||||
@@ -102,5 +109,16 @@ public class EducationPaperParamController {
|
||||
}
|
||||
return CommonResult.success("200");
|
||||
}
|
||||
|
||||
@GetMapping("/getAppWhiteList/{taskId}")
|
||||
@PermitAll
|
||||
@TenantIgnore
|
||||
@Operation(summary = "查看白名单列表", description = "查看白名单列表")
|
||||
public CommonResult<List<String>> getAppWhiteList(@PathVariable("taskId") String taskId){
|
||||
// 使用传入的IP,进行ping,查看是否存在连接,并返回信号的强度
|
||||
System.out.println(educationPaperParamService.getAppWhiteList(taskId));
|
||||
|
||||
return success(educationPaperParamService.getAppWhiteList(taskId));
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -22,6 +22,7 @@ import pc.exam.pp.module.exam.service.paper.IEducationPaperTaskService;
|
||||
|
||||
import static pc.exam.pp.framework.common.exception.enums.GlobalErrorCodeConstants.INTERNAL_SERVER_ERROR;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
@@ -72,6 +73,11 @@ public class EducationPaperTaskController {
|
||||
@GetMapping("/stulist")
|
||||
public CommonResult<PageResult<Map<String, Object>>> stulist(PaperTaskPageVo educationPaperTask) {
|
||||
PageResult<EducationPaperTask> pageResult = educationPaperTaskService.selectEducationPaperTaskListByStu(educationPaperTask);
|
||||
// ✅ 防止 pageResult 或其 list 为空
|
||||
if (pageResult == null || pageResult.getList() == null) {
|
||||
PageResult<Map<String, Object>> emptyPage = new PageResult<>(Collections.emptyList(), 0L);
|
||||
return CommonResult.success(emptyPage);
|
||||
}
|
||||
List<Map<String, Object>> newList = pageResult.getList().stream()
|
||||
.map(task -> {
|
||||
Map<String, Object> map = BeanUtil.beanToMap(task, false, true);
|
||||
|
@@ -0,0 +1,16 @@
|
||||
package pc.exam.pp.module.exam.controller.admin.paper.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class ExamWhiteListSaveReqDTO {
|
||||
private Long examId;
|
||||
private List<WhiteApp> whiteList;
|
||||
|
||||
@Data
|
||||
public static class WhiteApp {
|
||||
private String name;
|
||||
}
|
||||
}
|
@@ -1,14 +1,14 @@
|
||||
package pc.exam.pp.module.exam.dal.dataobject;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
|
||||
import java.sql.Time;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 通用参数对象 education_paper_param
|
||||
@@ -93,5 +93,7 @@ public class EducationPaperParam
|
||||
private String isScoreDetail;
|
||||
// 是否删除考生文件
|
||||
private String isDelete;
|
||||
|
||||
// 白名单
|
||||
@TableField(exist = false)
|
||||
private List<ExamWhiteListDO> whiteList;
|
||||
}
|
||||
|
@@ -0,0 +1,19 @@
|
||||
package pc.exam.pp.module.exam.dal.dataobject;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.KeySequence;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.*;
|
||||
|
||||
@TableName("exam_white_list")
|
||||
@Data
|
||||
@ToString(callSuper = true)
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class ExamWhiteListDO {
|
||||
@TableId
|
||||
private Long id;
|
||||
private String taskId;
|
||||
private String name;
|
||||
}
|
@@ -0,0 +1,19 @@
|
||||
package pc.exam.pp.module.exam.dal.mysql.paper;
|
||||
|
||||
import org.apache.ibatis.annotations.Delete;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import pc.exam.pp.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import pc.exam.pp.module.exam.dal.dataobject.EducationPaperTask;
|
||||
import pc.exam.pp.module.exam.dal.dataobject.ExamWhiteListDO;
|
||||
|
||||
import java.util.List;
|
||||
@Mapper
|
||||
public interface ExamWhiteListMapper extends BaseMapperX<ExamWhiteListDO> {
|
||||
|
||||
List<ExamWhiteListDO> selectByTaskId(String taskId);
|
||||
|
||||
void deleteByTaskId(String taskId);
|
||||
|
||||
List<String> selectNameByTaskId(String taskId);
|
||||
}
|
@@ -480,7 +480,13 @@ public class MonitorServiceImpl implements MonitorService {
|
||||
// redis_key
|
||||
String key = "userCache:" + taskId + ":" + stuId;
|
||||
// 获取缓存数据
|
||||
MonitorDO info = JsonUtils.parseObject(stringRedisTemplate.opsForValue().get(key), MonitorDO.class);
|
||||
// MonitorDO info = JsonUtils.parseObject(stringRedisTemplate.opsForValue().get(key), MonitorDO.class);
|
||||
MonitorDO info =monitorMapper.selectOne(
|
||||
new QueryWrapper<MonitorDO>()
|
||||
.eq("task_id", taskId)
|
||||
.eq("stu_id", stuId)
|
||||
);
|
||||
|
||||
// 如果考试状态存在,更新考试状态
|
||||
if (status != null) {
|
||||
if (info != null) {
|
||||
|
@@ -3,10 +3,13 @@ package pc.exam.pp.module.exam.service.paper;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import pc.exam.pp.module.exam.dal.dataobject.ExamWhiteListDO;
|
||||
import pc.exam.pp.module.exam.dal.dataobject.EducationPaperParam;
|
||||
import pc.exam.pp.module.exam.dal.mysql.paper.EducationPaperParamMapper;
|
||||
import pc.exam.pp.module.exam.dal.mysql.paper.EducationPaperTaskMapper;
|
||||
import pc.exam.pp.module.exam.dal.mysql.paper.ExamWhiteListMapper;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -22,6 +25,9 @@ public class EducationPaperParamServiceImpl implements IEducationPaperParamServi
|
||||
private EducationPaperParamMapper educationPaperParamMapper;
|
||||
@Autowired
|
||||
private EducationPaperTaskMapper educationPaperTaskMapper;
|
||||
@Autowired
|
||||
private ExamWhiteListMapper examWhiteListMapper;
|
||||
|
||||
/**
|
||||
* 查询通用参数
|
||||
*
|
||||
@@ -55,6 +61,16 @@ public class EducationPaperParamServiceImpl implements IEducationPaperParamServi
|
||||
@Override
|
||||
public int insertEducationPaperParam(EducationPaperParam educationPaperParam)
|
||||
{
|
||||
List<ExamWhiteListDO> whiteList = educationPaperParam.getWhiteList();
|
||||
String taskId = educationPaperParam.getTaskId();
|
||||
// ✅ 统一赋值
|
||||
if (whiteList != null && !whiteList.isEmpty()) {
|
||||
for (ExamWhiteListDO examWhiteListDO : whiteList) {
|
||||
examWhiteListDO.setTaskId(taskId);
|
||||
examWhiteListDO.setName(examWhiteListDO.getName());
|
||||
}
|
||||
examWhiteListMapper.insertBatch(whiteList);
|
||||
}
|
||||
return educationPaperParamMapper.insertEducationPaperParam(educationPaperParam);
|
||||
}
|
||||
|
||||
@@ -67,6 +83,20 @@ public class EducationPaperParamServiceImpl implements IEducationPaperParamServi
|
||||
@Override
|
||||
public int updateEducationPaperParam(EducationPaperParam educationPaperParam)
|
||||
{
|
||||
List<ExamWhiteListDO> whiteList = educationPaperParam.getWhiteList();
|
||||
String taskId = educationPaperParam.getTaskId();
|
||||
if (taskId!=null){
|
||||
//删除旧白名单
|
||||
examWhiteListMapper.deleteByTaskId(taskId);
|
||||
//插入新白名单
|
||||
if (whiteList != null && !whiteList.isEmpty()) {
|
||||
for (ExamWhiteListDO examWhiteListDO : whiteList) {
|
||||
examWhiteListDO.setTaskId(taskId);
|
||||
examWhiteListDO.setName(examWhiteListDO.getName());
|
||||
}
|
||||
examWhiteListMapper.insertBatch(whiteList);
|
||||
}
|
||||
}
|
||||
return educationPaperParamMapper.updateEducationPaperParam(educationPaperParam);
|
||||
}
|
||||
|
||||
@@ -96,7 +126,19 @@ public class EducationPaperParamServiceImpl implements IEducationPaperParamServi
|
||||
|
||||
@Override
|
||||
public EducationPaperParam selectEducationPaperParamByTaskId(String taskId) {
|
||||
return educationPaperParamMapper.selectEducationPaperParamByTaskId(taskId);
|
||||
List<ExamWhiteListDO> whiteList = examWhiteListMapper.selectByTaskId(taskId);
|
||||
EducationPaperParam educationPaperParam = educationPaperParamMapper.selectEducationPaperParamByTaskId(taskId);
|
||||
if (whiteList != null && !whiteList.isEmpty()) {
|
||||
educationPaperParam.setWhiteList(whiteList);
|
||||
}
|
||||
return educationPaperParam;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public List<String> getAppWhiteList(String taskId) {
|
||||
return examWhiteListMapper.selectNameByTaskId(taskId);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -81,6 +81,8 @@ public class EducationPaperTaskServiceImpl implements IEducationPaperTaskService
|
||||
private ExamQuestionMapper examQuestionMapper;
|
||||
@Resource
|
||||
AppCheckMapper appCheckMapper;
|
||||
@Autowired
|
||||
private ExamWhiteListMapper examWhiteListMapper;
|
||||
|
||||
/**
|
||||
* 查询试卷任务
|
||||
@@ -190,6 +192,15 @@ public class EducationPaperTaskServiceImpl implements IEducationPaperTaskService
|
||||
} else {
|
||||
educationPaperTask.setIsOne("1");
|
||||
}
|
||||
List<ExamWhiteListDO> whiteList = new ArrayList<>();
|
||||
ExamWhiteListDO examWhiteListDO=new ExamWhiteListDO();
|
||||
examWhiteListDO.setTaskId(uuid);
|
||||
examWhiteListDO.setName("ExamStudent");
|
||||
whiteList.add(examWhiteListDO);
|
||||
examWhiteListMapper.insertBatch(whiteList);
|
||||
|
||||
|
||||
|
||||
// 新增任务参数
|
||||
educationPaperParamMapper.insertEducationPaperParam(educationPaperParam);
|
||||
// 新增任务
|
||||
@@ -539,6 +550,14 @@ public class EducationPaperTaskServiceImpl implements IEducationPaperTaskService
|
||||
educationPaperTask.setTaskName(educationPaperTask.getTaskName() + timeString);
|
||||
educationPaperTask.setCreateTime(now);
|
||||
educationPaperTask.setIsTemplate(1);
|
||||
//白名单
|
||||
List<ExamWhiteListDO> whiteList = examWhiteListMapper.selectByTaskId(taskId);
|
||||
if (whiteList != null && !whiteList.isEmpty()) {
|
||||
for (ExamWhiteListDO examWhiteListDO : whiteList) {
|
||||
examWhiteListDO.setTaskId(newtaskId);
|
||||
}
|
||||
examWhiteListMapper.insertBatch(whiteList);
|
||||
}
|
||||
educationPaperTaskMapper.insertEducationPaperTask(educationPaperTask);
|
||||
|
||||
if (options.contains("1")) {
|
||||
|
@@ -0,0 +1,7 @@
|
||||
package pc.exam.pp.module.exam.service.paper;
|
||||
|
||||
public interface ExamWhiteListService {
|
||||
|
||||
|
||||
|
||||
}
|
@@ -0,0 +1,12 @@
|
||||
package pc.exam.pp.module.exam.service.paper;
|
||||
|
||||
import jakarta.annotation.Resource;
|
||||
import pc.exam.pp.module.exam.dal.mysql.paper.ExamWhiteListMapper;
|
||||
|
||||
public class ExamWhiteListServiceImpl implements ExamWhiteListService {
|
||||
@Resource
|
||||
ExamWhiteListMapper examWhiteListMapper;
|
||||
|
||||
|
||||
|
||||
}
|
@@ -2,6 +2,7 @@ package pc.exam.pp.module.exam.service.paper;
|
||||
|
||||
|
||||
import pc.exam.pp.module.exam.dal.dataobject.EducationPaperParam;
|
||||
import pc.exam.pp.module.exam.dal.dataobject.ExamWhiteListDO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -63,5 +64,6 @@ public interface IEducationPaperParamService
|
||||
|
||||
EducationPaperParam selectEducationPaperParamByTaskId(String taskId);
|
||||
|
||||
List<String> getAppWhiteList(String taskId);
|
||||
}
|
||||
|
||||
|
@@ -0,0 +1,31 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="pc.exam.pp.module.exam.dal.mysql.paper.ExamWhiteListMapper">
|
||||
|
||||
<resultMap type="ExamWhiteListDO" id="ExamWhiteListDOResult">
|
||||
<result property="id" column="id"/>
|
||||
<result property="taskId" column="task_id"/>
|
||||
<result property="name" column="name"/>
|
||||
|
||||
</resultMap>
|
||||
<insert id="insertBatch">
|
||||
INSERT INTO exam_white_list (name,task_id)
|
||||
VALUES
|
||||
<foreach collection="list" item="item" separator=",">
|
||||
(#{item.name}, #{item.taskId})
|
||||
</foreach>
|
||||
</insert>
|
||||
<delete id="deleteByTaskId">
|
||||
DELETE FROM exam_white_list WHERE task_id = #{taskId}
|
||||
</delete>
|
||||
<select id="selectByTaskId" resultMap="ExamWhiteListDOResult">
|
||||
select name from exam_white_list where task_id =#{taskId}
|
||||
</select>
|
||||
<select id="selectNameByTaskId" resultType="java.lang.String">
|
||||
select name from exam_white_list where task_id =#{taskId}
|
||||
</select>
|
||||
|
||||
|
||||
</mapper>
|
@@ -157,11 +157,9 @@ public class AutoToolsController {
|
||||
securityProperties.getTokenHeader(), securityProperties.getTokenParameter());
|
||||
// 获取登录用户
|
||||
LoginUser loginUser = SecurityFrameworkUtils.getLoginUser();
|
||||
// userId 是否存在
|
||||
String wsKey = taskManager.getTaskById(String.valueOf(loginUser.getId()));
|
||||
if (wsKey != null) {
|
||||
// 停止任务
|
||||
taskManager.stopTask(wsKey);
|
||||
// 通过ID 直接停止
|
||||
if (loginUser != null) {
|
||||
taskManager.stopTaskByUserId(String.valueOf(loginUser.getId()));
|
||||
}
|
||||
int startTime = 0;
|
||||
// 查找对应的task
|
||||
@@ -213,7 +211,9 @@ public class AutoToolsController {
|
||||
// 返回数据-网络状态
|
||||
stuTheExamInfo.setNetwork("强");
|
||||
// 创建对应的线程池
|
||||
taskManager.startTask(stuInTheExam, stuTheExamInfo, token, countdown, new AtomicInteger(0), loginUser.getId() + "_" + stuInTheExam.getTaskId() + "_" + stuInTheExam.getPaperId());
|
||||
if (loginUser != null) {
|
||||
taskManager.startTask(loginUser.getId(), stuInTheExam, stuTheExamInfo, token, countdown, new AtomicInteger(0), loginUser.getId() + "_" + stuInTheExam.getTaskId() + "_" + stuInTheExam.getPaperId());
|
||||
}
|
||||
return CommonResult.success(token);
|
||||
}
|
||||
return CommonResult.success("未登录");
|
||||
@@ -261,8 +261,10 @@ public class AutoToolsController {
|
||||
securityProperties.getTokenHeader(), securityProperties.getTokenParameter());
|
||||
ExamRestartPaperVo examRestartPaperVo = new ExamRestartPaperVo();
|
||||
// 如果继续考试,需要关闭之前的,重新开始ws
|
||||
String taskManagerId = loginUser.getId() + "_" + stuInTheExam.getTaskId() + "_" + stuInTheExam.getPaperId();
|
||||
taskManager.stopTask(taskManagerId);
|
||||
// 通过ID 直接停止
|
||||
if (loginUser != null) {
|
||||
taskManager.stopTaskByUserId(String.valueOf(loginUser.getId()));
|
||||
}
|
||||
// 获取试卷详情
|
||||
ExamPaperVo examPaperVo = educationPaperQuService.selectPaperQuListByPaperId(stuInTheExam.getPaperId());
|
||||
// 获取剩余的时间
|
||||
@@ -319,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);
|
||||
@@ -353,6 +355,12 @@ public class AutoToolsController {
|
||||
userId += "_" + taskId + "_" + paperId;
|
||||
// 删除对应的线程池
|
||||
taskManager.stopTask(userId);
|
||||
// 为了确保停止成功,笨办法在请求另一个停止接口
|
||||
try {
|
||||
taskManager.stopTaskByUserId(String.valueOf(userId));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return CommonResult.success(true);
|
||||
}
|
||||
|
||||
@@ -394,6 +402,8 @@ public class AutoToolsController {
|
||||
stringRedisTemplate.opsForValue().set(key, JsonUtils.toJsonString(info));
|
||||
monitorMapper.updateById(info);
|
||||
}
|
||||
// 删除对应任务
|
||||
taskManager.stopTaskByUserId(userId);
|
||||
return CommonResult.success(true);
|
||||
}
|
||||
|
||||
@@ -404,13 +414,9 @@ public class AutoToolsController {
|
||||
* @return true
|
||||
*/
|
||||
@GetMapping("/stopExamForAdmin")
|
||||
public CommonResult<Boolean> stopExamForAdmin(@RequestParam("userId") String userId, @RequestParam("taskId") String taskId, @RequestParam("paperNum") String paperNum) {
|
||||
String paperId = educationPaperService.selectPaperByPaperNum(paperNum);
|
||||
// 将userId 拼接 taskId 作为key
|
||||
// 防止不同试卷ID冲突
|
||||
userId += "_" + taskId + "_" + paperId;
|
||||
public CommonResult<Boolean> stopExamForAdmin(@RequestParam("userId") String userId) {
|
||||
// 删除对应的线程池
|
||||
taskManager.stopTask(userId);
|
||||
taskManager.stopTaskByUserId(userId);
|
||||
return CommonResult.success(true);
|
||||
}
|
||||
|
||||
@@ -495,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);
|
||||
});
|
||||
@@ -93,6 +94,18 @@ public class TaskManager {
|
||||
.orElse(null);
|
||||
}
|
||||
|
||||
/**通过ID结束任务*/
|
||||
public void stopTaskByUserId(String userId) {
|
||||
String taskId = tasks.keySet().stream()
|
||||
.filter(key -> key.startsWith(userId + "_"))
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
if (taskId != null) {
|
||||
stopTask(taskId);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/** 全部停止(可选) */
|
||||
public void stopAll() {
|
||||
tasks.forEach((k, f) -> f.cancel(false));
|
||||
|
@@ -118,7 +118,7 @@ public class CellIng {
|
||||
String formula = cell.getCellFormula();
|
||||
// 转为小写再比较
|
||||
if (formula.toLowerCase().contains(keyWords.toLowerCase())) {
|
||||
return formula; // 包含关键字时返回公式内容
|
||||
return keyWords; // 包含关键字时返回公式内容
|
||||
} else {
|
||||
return "否"; // 不包含关键字
|
||||
}
|
||||
|
@@ -0,0 +1,24 @@
|
||||
package pc.exam.pp.server.config;
|
||||
|
||||
|
||||
import jakarta.annotation.PostConstruct;
|
||||
import jakarta.annotation.Resource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
import pc.exam.pp.module.judgement.service.TaskManager;
|
||||
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
public class TaskToStop {
|
||||
|
||||
@Resource
|
||||
TaskManager taskManager;
|
||||
|
||||
@PostConstruct
|
||||
public void init() {
|
||||
// 清除所有的任务
|
||||
taskManager.stopAll();
|
||||
log.info("✅ 已经清除所有任务ID");
|
||||
}
|
||||
}
|
@@ -293,6 +293,7 @@ exam:
|
||||
- /jmreport/* # 积木报表,无法携带租户编号
|
||||
- /admin-api/mp/open/** # 微信公众号开放平台,微信回调接口,无法携带租户编号
|
||||
- /admin-api/exam/app/getAppCheckList/* # 学生端环境监测
|
||||
- /admin-api/exam/param/getAppWhiteList/* # 学生端环境监测
|
||||
- /admin-api/system/auth/login_config # 学生端判断学生的登录方式
|
||||
- /admin-api/system/auth/refreshLogout # 登出用户
|
||||
ignore-tables:
|
||||
@@ -303,6 +304,7 @@ exam:
|
||||
- exam_knowledge_points
|
||||
- exam_specialty
|
||||
- exam_app_check
|
||||
- exam_white_list
|
||||
- system_tenant
|
||||
- system_tenant_package
|
||||
- system_dict_data
|
||||
|
Reference in New Issue
Block a user