【修改】 任务编号:添加逻辑为年月日+任务数量+1

This commit is contained in:
dlaren
2025-08-17 21:55:35 +08:00
parent 1c0ba2b8a0
commit 0175ccef67
4 changed files with 154 additions and 144 deletions

View File

@@ -18,7 +18,9 @@ import pc.exam.pp.module.exam.controller.admin.paper.dto.TempDto;
import pc.exam.pp.module.exam.controller.admin.paper.vo.PaperTaskPageVo; import pc.exam.pp.module.exam.controller.admin.paper.vo.PaperTaskPageVo;
import pc.exam.pp.module.exam.dal.dataobject.EducationPaperTask; import pc.exam.pp.module.exam.dal.dataobject.EducationPaperTask;
import pc.exam.pp.module.exam.service.paper.IEducationPaperTaskService; import pc.exam.pp.module.exam.service.paper.IEducationPaperTaskService;
import static pc.exam.pp.framework.common.exception.enums.GlobalErrorCodeConstants.INTERNAL_SERVER_ERROR; import static pc.exam.pp.framework.common.exception.enums.GlobalErrorCodeConstants.INTERNAL_SERVER_ERROR;
import java.util.List; import java.util.List;
@@ -31,8 +33,7 @@ import java.util.List;
@Tag(name = "管理后台 - 试卷任务") @Tag(name = "管理后台 - 试卷任务")
@RestController @RestController
@RequestMapping("/exam/task") @RequestMapping("/exam/task")
public class EducationPaperTaskController public class EducationPaperTaskController {
{
@Autowired @Autowired
private IEducationPaperTaskService educationPaperTaskService; private IEducationPaperTaskService educationPaperTaskService;
@@ -41,15 +42,14 @@ public class EducationPaperTaskController
*/ */
@Operation(summary = "查询试卷任务列表(服务器端)") @Operation(summary = "查询试卷任务列表(服务器端)")
@GetMapping("/list") @GetMapping("/list")
public CommonResult<PageResult<EducationPaperTask>> list(PaperTaskPageVo educationPaperTask) public CommonResult<PageResult<EducationPaperTask>> list(PaperTaskPageVo educationPaperTask) {
{
PageResult<EducationPaperTask> pageResult = educationPaperTaskService.selectEducationPaperTaskList(educationPaperTask); PageResult<EducationPaperTask> pageResult = educationPaperTaskService.selectEducationPaperTaskList(educationPaperTask);
return CommonResult.success(BeanUtils.toBean(pageResult, EducationPaperTask.class)); return CommonResult.success(BeanUtils.toBean(pageResult, EducationPaperTask.class));
} }
@Operation(summary = "查询试卷任务列表(带试卷)") @Operation(summary = "查询试卷任务列表(带试卷)")
@GetMapping("/listPaper") @GetMapping("/listPaper")
public CommonResult<PageResult<EducationPaperTask>> taskAndPaperlist(PaperTaskPageVo educationPaperTask) public CommonResult<PageResult<EducationPaperTask>> taskAndPaperlist(PaperTaskPageVo educationPaperTask) {
{
PageResult<EducationPaperTask> pageResult = educationPaperTaskService.selectEducationPaperAndTaskList(educationPaperTask); PageResult<EducationPaperTask> pageResult = educationPaperTaskService.selectEducationPaperAndTaskList(educationPaperTask);
return CommonResult.success(BeanUtils.toBean(pageResult, EducationPaperTask.class)); return CommonResult.success(BeanUtils.toBean(pageResult, EducationPaperTask.class));
} }
@@ -59,9 +59,8 @@ public class EducationPaperTaskController
*/ */
@Operation(summary = "查询试卷任务列表(学生端)") @Operation(summary = "查询试卷任务列表(学生端)")
@GetMapping("/stulist") @GetMapping("/stulist")
public CommonResult<PageResult<EducationPaperTask>> stulist(PaperTaskPageVo educationPaperTask) public CommonResult<PageResult<EducationPaperTask>> stulist(PaperTaskPageVo educationPaperTask) {
{ PageResult<EducationPaperTask> pageResult = educationPaperTaskService.selectEducationPaperTaskListByStu(educationPaperTask);
PageResult<EducationPaperTask> pageResult =educationPaperTaskService.selectEducationPaperTaskListByStu(educationPaperTask);
return CommonResult.success(BeanUtils.toBean(pageResult, EducationPaperTask.class)); return CommonResult.success(BeanUtils.toBean(pageResult, EducationPaperTask.class));
} }
@@ -82,8 +81,7 @@ public class EducationPaperTaskController
*/ */
@Operation(summary = "获取试卷任务详细信息") @Operation(summary = "获取试卷任务详细信息")
@GetMapping(value = "/{taskId}") @GetMapping(value = "/{taskId}")
public CommonResult getInfo(@PathVariable("taskId") String taskId) public CommonResult getInfo(@PathVariable("taskId") String taskId) {
{
return CommonResult.success(educationPaperTaskService.selectEducationPaperTaskByTaskId(taskId)); return CommonResult.success(educationPaperTaskService.selectEducationPaperTaskByTaskId(taskId));
} }
@@ -92,8 +90,7 @@ public class EducationPaperTaskController
*/ */
@Operation(summary = "新增试卷任务") @Operation(summary = "新增试卷任务")
@PostMapping @PostMapping
public CommonResult add(@RequestBody EducationPaperTask educationPaperTask) public CommonResult add(@RequestBody EducationPaperTask educationPaperTask) {
{
return CommonResult.success(educationPaperTaskService.insertEducationPaperTask(educationPaperTask)); return CommonResult.success(educationPaperTaskService.insertEducationPaperTask(educationPaperTask));
} }
@@ -103,8 +100,7 @@ public class EducationPaperTaskController
*/ */
@Operation(summary = "修改试卷任务") @Operation(summary = "修改试卷任务")
@PutMapping @PutMapping
public CommonResult edit(@RequestBody EducationPaperTask educationPaperTask) public CommonResult edit(@RequestBody EducationPaperTask educationPaperTask) {
{
return CommonResult.success(educationPaperTaskService.updateEducationPaperTask(educationPaperTask)); return CommonResult.success(educationPaperTaskService.updateEducationPaperTask(educationPaperTask));
} }
@@ -113,26 +109,25 @@ public class EducationPaperTaskController
*/ */
@Operation(summary = "删除试卷任务") @Operation(summary = "删除试卷任务")
@DeleteMapping("/del/{taskId}") @DeleteMapping("/del/{taskId}")
public CommonResult remove(@PathVariable String taskId ) public CommonResult remove(@PathVariable String taskId) {
{
return CommonResult.success(educationPaperTaskService.deleteEducationPaperTaskByTaskId(taskId)); return CommonResult.success(educationPaperTaskService.deleteEducationPaperTaskByTaskId(taskId));
} }
/** /**
* 批量删除试卷任务 * 批量删除试卷任务
*/ */
@Operation(summary = "批量删除试卷任务") @Operation(summary = "批量删除试卷任务")
@DeleteMapping("/{taskIds}") @DeleteMapping("/{taskIds}")
public CommonResult removeIds(@PathVariable String[] taskIds ) public CommonResult removeIds(@PathVariable String[] taskIds) {
{
return CommonResult.success(educationPaperTaskService.deleteEducationPaperTaskByTaskIds(taskIds)); return CommonResult.success(educationPaperTaskService.deleteEducationPaperTaskByTaskIds(taskIds));
} }
/** /**
* 获取专业列表 * 获取专业列表
*/ */
@Operation(summary = "获取专业列表") @Operation(summary = "获取专业列表")
@GetMapping("/getSpeciality") @GetMapping("/getSpeciality")
public CommonResult getSpeciality() public CommonResult getSpeciality() {
{
return CommonResult.success(educationPaperTaskService.getSpecialityList()); return CommonResult.success(educationPaperTaskService.getSpecialityList());
} }
@@ -141,8 +136,7 @@ public class EducationPaperTaskController
*/ */
@Operation(summary = "获取题型列表") @Operation(summary = "获取题型列表")
@GetMapping("/getCourse") @GetMapping("/getCourse")
public CommonResult getCourse() public CommonResult getCourse() {
{
return CommonResult.success(educationPaperTaskService.getCourseList()); return CommonResult.success(educationPaperTaskService.getCourseList());
} }
@@ -151,17 +145,16 @@ public class EducationPaperTaskController
*/ */
@Operation(summary = "获取关键字") @Operation(summary = "获取关键字")
@GetMapping("/getKeywords") @GetMapping("/getKeywords")
public CommonResult getKeywords() public CommonResult getKeywords() {
{
return CommonResult.success(educationPaperTaskService.getKeywords()); return CommonResult.success(educationPaperTaskService.getKeywords());
} }
/** /**
* 获取知识点 * 获取知识点
*/ */
@Operation(summary = "获取知识点") @Operation(summary = "获取知识点")
@GetMapping("/getPoints") @GetMapping("/getPoints")
public CommonResult getPoints (@RequestParam(value = "name") String name) public CommonResult getPoints(@RequestParam(value = "name") String name) {
{
return CommonResult.success(educationPaperTaskService.getPoints(name)); return CommonResult.success(educationPaperTaskService.getPoints(name));
} }
@@ -174,13 +167,14 @@ public class EducationPaperTaskController
@PermitAll @PermitAll
public CommonResult fetchQuestionCount(@RequestBody SchemeParam param) { public CommonResult fetchQuestionCount(@RequestBody SchemeParam param) {
Integer count= educationPaperTaskService.getQuCount(param); Integer count = educationPaperTaskService.getQuCount(param);
return CommonResult.success(count); return CommonResult.success(count);
} }
/** /**
* 模板库 复制 * 模板库 复制
*
* @param tempDto * @param tempDto
* @return * @return
*/ */
@@ -191,15 +185,15 @@ public class EducationPaperTaskController
System.out.println("接收到的选项: " + tempDto.getOptions()); System.out.println("接收到的选项: " + tempDto.getOptions());
String taskId = tempDto.getTaskId(); String taskId = tempDto.getTaskId();
if (taskId == null || taskId.trim().isEmpty()) { if (taskId == null || taskId.trim().isEmpty()) {
return CommonResult.error(INTERNAL_SERVER_ERROR.getCode(),"缺失模板方案参数Id!"); return CommonResult.error(INTERNAL_SERVER_ERROR.getCode(), "缺失模板方案参数Id!");
} }
List<String> options = tempDto.getOptions(); List<String> options = tempDto.getOptions();
if (options!=null&&options.size()>0){ if (options != null && options.size() > 0) {
educationPaperTaskService.submitSelection(tempDto); educationPaperTaskService.submitSelection(tempDto);
}else { } else {
return CommonResult.error(INTERNAL_SERVER_ERROR.getCode(),"请选择复制的参数!"); return CommonResult.error(INTERNAL_SERVER_ERROR.getCode(), "请选择复制的参数!");
} }
return CommonResult.success("复制成功"); return CommonResult.success("复制成功");
@@ -207,6 +201,7 @@ public class EducationPaperTaskController
/** /**
* 更改 任务状态 * 更改 任务状态
*
* @param statusDto * @param statusDto
* @return * @return
*/ */
@@ -221,13 +216,13 @@ public class EducationPaperTaskController
/** /**
* 学生端 根据任务id返回 试卷信息 * 学生端 根据任务id返回 试卷信息
*
* @param taskId * @param taskId
* @return * @return
*/ */
@Operation(summary = "学生端 根据任务id返回 试卷信息") @Operation(summary = "学生端 根据任务id返回 试卷信息")
@GetMapping(value = "/getPaperBytaskId") @GetMapping(value = "/getPaperBytaskId")
public CommonResult getPaperBytaskId(@RequestParam(value = "taskId") String taskId) public CommonResult getPaperBytaskId(@RequestParam(value = "taskId") String taskId) {
{
return CommonResult.success(educationPaperTaskService.selectPaperQuByPaperId(taskId)); return CommonResult.success(educationPaperTaskService.selectPaperQuByPaperId(taskId));
} }
@@ -240,7 +235,7 @@ public class EducationPaperTaskController
educationPaperTaskService.checkType(dto); educationPaperTaskService.checkType(dto);
return CommonResult.success("题型更新成功"); return CommonResult.success("题型更新成功");
} catch (Exception e) { } catch (Exception e) {
return CommonResult.error(9999999,e.getMessage()); return CommonResult.error(9999999, e.getMessage());
} }

View File

@@ -24,6 +24,7 @@ import pc.exam.pp.module.exam.dal.mysql.question.ExamQuestionFileMapper;
import pc.exam.pp.module.exam.utils.date.DateUtils; import pc.exam.pp.module.exam.utils.date.DateUtils;
import pc.exam.pp.module.exam.utils.uuid.IdUtils; import pc.exam.pp.module.exam.utils.uuid.IdUtils;
import java.time.LocalDate;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.util.*; import java.util.*;
@@ -89,11 +90,11 @@ public class EducationPaperTaskServiceImpl implements IEducationPaperTaskService
public PageResult<EducationPaperTask> selectEducationPaperTaskList(PaperTaskPageVo educationPaperTask) { public PageResult<EducationPaperTask> selectEducationPaperTaskList(PaperTaskPageVo educationPaperTask) {
PageResult<EducationPaperTask> educationPaperTasks = educationPaperTaskMapper.selectEducationPaperTaskList(educationPaperTask); PageResult<EducationPaperTask> educationPaperTasks = educationPaperTaskMapper.selectEducationPaperTaskList(educationPaperTask);
List<EducationPaperTask> list = educationPaperTasks.getList(); List<EducationPaperTask> list = educationPaperTasks.getList();
if (list!=null&&list.size()>0){ if (list != null && list.size() > 0) {
for (EducationPaperTask paperTask : list) { for (EducationPaperTask paperTask : list) {
int count=0; int count = 0;
List<EducationPaper> educationPapers = educationPaperMapper.selectPaperListByTaskId(paperTask.getTaskId()); List<EducationPaper> educationPapers = educationPaperMapper.selectPaperListByTaskId(paperTask.getTaskId());
if (educationPapers!=null&&educationPapers.size()>0){ if (educationPapers != null && educationPapers.size() > 0) {
for (EducationPaper educationPaper : educationPapers) { for (EducationPaper educationPaper : educationPapers) {
try { try {
count += Integer.parseInt(educationPaper.getCounts()); count += Integer.parseInt(educationPaper.getCounts());
@@ -106,13 +107,12 @@ public class EducationPaperTaskServiceImpl implements IEducationPaperTaskService
} }
paperTask.setCount(String.valueOf(count)); paperTask.setCount(String.valueOf(count));
EducationPaperParam educationPaperParam = educationPaperParamMapper.selectEducationPaperParamByTaskId(paperTask.getTaskId()); EducationPaperParam educationPaperParam = educationPaperParamMapper.selectEducationPaperParamByTaskId(paperTask.getTaskId());
paperTask.setEducationPaperParam(educationPaperParam); paperTask.setEducationPaperParam(educationPaperParam);
} }
} }
return educationPaperTasks ; return educationPaperTasks;
} }
/** /**
@@ -126,6 +126,13 @@ public class EducationPaperTaskServiceImpl implements IEducationPaperTaskService
String uuid = IdUtils.simpleUUID(); String uuid = IdUtils.simpleUUID();
educationPaperTask.setTaskId(uuid); educationPaperTask.setTaskId(uuid);
educationPaperTask.setCreateTime(DateUtils.getNowLocalDateTime()); educationPaperTask.setCreateTime(DateUtils.getNowLocalDateTime());
// 添加任务编号
// 查询存在的任务数量
Long count = educationPaperTaskMapper.selectCount();
DateTimeFormatter formatter = DateTimeFormatter.BASIC_ISO_DATE;
String currentDate = LocalDate.now().format(formatter);
String taskNum = currentDate + String.valueOf(count + 1);
educationPaperTask.setTaskNum(taskNum);
EducationPaperParam educationPaperParam = new EducationPaperParam(); EducationPaperParam educationPaperParam = new EducationPaperParam();
educationPaperParam.setParamId(IdUtils.simpleUUID()); educationPaperParam.setParamId(IdUtils.simpleUUID());
educationPaperParam.setTaskId(uuid); educationPaperParam.setTaskId(uuid);
@@ -146,28 +153,28 @@ public class EducationPaperTaskServiceImpl implements IEducationPaperTaskService
educationPaperParam.setIsScreen("1"); educationPaperParam.setIsScreen("1");
educationPaperParam.setWarn("<p style=\"line-height: 3;\"><span style=\"font-size: 22px;\">&gt;&gt;请仔细核对考试信息,并认真阅读本注意事项确认无误后点【开始考试】按钮进入考试系统。</span></p><p style=\"line-height: 3;\"><span style=\"font-size: 22px;\">&gt;&gt;进入考试系统后系统自动计时考试结束前5分钟系统将提示您存盘请根据系统的提示交卷或存盘。</span></p><p style=\"line-height: 3;\"><span style=\"font-size: 22px;\">&gt;&gt;进入考试系统后,须根据系统提示进行操作,任何因为与考试无关的操作造成的成绩错误由考生自行负责。</span></p><p style=\"line-height: 3;\"><span style=\"font-size: 22px;\">&gt;&gt;单选试题操作完后系统会自动保存。</span></p><p style=\"line-height: 3;\"><span style=\"font-size: 22px;\">&gt;&gt;所有操作类科目的试题,必须在相对应的操作环境中完成操作,并在该环境中直接保存文件,不要更改文件保存路径。</span></p><p style=\"line-height: 3;\"><span style=\"font-size: 22px;\">&gt;&gt;Windows和网络操作题考生按照系统提示完成相应的操作即可。</span></p><p style=\"line-height: 3;\"><span style=\"font-size: 22px;\">&gt;&gt;考试时间结束后,系统会自动提交考生答卷到考试服务器。提前完成的考生,选择【交卷】按钮提交试卷,出现【交卷成功】提示后方可离开,不要关闭交卷成功窗口,否则后果自负。</span></p><p style=\"line-height: 3;\"><span style=\"font-size: 22px;\">&gt;&gt;如在考试过程中有任何疑问请举手与监考老师联系。</span></p><p><br></p>"); educationPaperParam.setWarn("<p style=\"line-height: 3;\"><span style=\"font-size: 22px;\">&gt;&gt;请仔细核对考试信息,并认真阅读本注意事项确认无误后点【开始考试】按钮进入考试系统。</span></p><p style=\"line-height: 3;\"><span style=\"font-size: 22px;\">&gt;&gt;进入考试系统后系统自动计时考试结束前5分钟系统将提示您存盘请根据系统的提示交卷或存盘。</span></p><p style=\"line-height: 3;\"><span style=\"font-size: 22px;\">&gt;&gt;进入考试系统后,须根据系统提示进行操作,任何因为与考试无关的操作造成的成绩错误由考生自行负责。</span></p><p style=\"line-height: 3;\"><span style=\"font-size: 22px;\">&gt;&gt;单选试题操作完后系统会自动保存。</span></p><p style=\"line-height: 3;\"><span style=\"font-size: 22px;\">&gt;&gt;所有操作类科目的试题,必须在相对应的操作环境中完成操作,并在该环境中直接保存文件,不要更改文件保存路径。</span></p><p style=\"line-height: 3;\"><span style=\"font-size: 22px;\">&gt;&gt;Windows和网络操作题考生按照系统提示完成相应的操作即可。</span></p><p style=\"line-height: 3;\"><span style=\"font-size: 22px;\">&gt;&gt;考试时间结束后,系统会自动提交考生答卷到考试服务器。提前完成的考生,选择【交卷】按钮提交试卷,出现【交卷成功】提示后方可离开,不要关闭交卷成功窗口,否则后果自负。</span></p><p style=\"line-height: 3;\"><span style=\"font-size: 22px;\">&gt;&gt;如在考试过程中有任何疑问请举手与监考老师联系。</span></p><p><br></p>");
educationPaperParam.setIsContent("1"); educationPaperParam.setIsContent("1");
if ("1".equals(educationPaperTask.getTaskType())){ if ("1".equals(educationPaperTask.getTaskType())) {
educationPaperParam.setIsRepeat("1"); educationPaperParam.setIsRepeat("1");
educationPaperParam.setIsAnswer("1"); educationPaperParam.setIsAnswer("1");
educationPaperParam.setIsLook("1"); educationPaperParam.setIsLook("1");
educationPaperParam.setIsConnect("30"); educationPaperParam.setIsConnect("30");
educationPaperParam.setIsScore("1"); educationPaperParam.setIsScore("1");
educationPaperParam.setIsScoreDetail("1"); educationPaperParam.setIsScoreDetail("1");
}else { } else {
educationPaperParam.setIsRepeat("0"); educationPaperParam.setIsRepeat("0");
educationPaperParam.setIsAnswer("0"); educationPaperParam.setIsAnswer("0");
educationPaperParam.setIsLook("0"); educationPaperParam.setIsLook("0");
educationPaperParam.setIsScore("0"); educationPaperParam.setIsScore("0");
educationPaperParam.setIsScoreDetail("0"); educationPaperParam.setIsScoreDetail("0");
} }
if ("0".equals(educationPaperTask.getTaskType())||"1".equals(educationPaperTask.getTaskType())||"3".equals(educationPaperTask.getTaskType())){ if ("0".equals(educationPaperTask.getTaskType()) || "1".equals(educationPaperTask.getTaskType()) || "3".equals(educationPaperTask.getTaskType())) {
educationPaperTask.setIsOne("0"); educationPaperTask.setIsOne("0");
}else{ } else {
educationPaperTask.setIsOne("1"); educationPaperTask.setIsOne("1");
} }
// 新增任务参数
educationPaperParamMapper.insertEducationPaperParam(educationPaperParam); educationPaperParamMapper.insertEducationPaperParam(educationPaperParam);
// 新增任务
return educationPaperTaskMapper.insertEducationPaperTask(educationPaperTask); return educationPaperTaskMapper.insertEducationPaperTask(educationPaperTask);
} }
@@ -201,15 +208,15 @@ public class EducationPaperTaskServiceImpl implements IEducationPaperTaskService
for (String taskId : taskIds) { for (String taskId : taskIds) {
EducationPaperTask educationPaperTask = educationPaperTaskMapper.selectById(taskId); EducationPaperTask educationPaperTask = educationPaperTaskMapper.selectById(taskId);
if (educationPaperTask.getTaskType().equals("0")||educationPaperTask.getTaskType().equals("1")||educationPaperTask.getTaskType().equals("3")){ if (educationPaperTask.getTaskType().equals("0") || educationPaperTask.getTaskType().equals("1") || educationPaperTask.getTaskType().equals("3")) {
// 查询该任务下是否有试卷 // 查询该任务下是否有试卷
int paperCount = educationPaperMapper.countPapersByTaskId(taskId); int paperCount = educationPaperMapper.countPapersByTaskId(taskId);
if (paperCount == 0) { if (paperCount == 0) {
canDeleteTaskIds.add(taskId); canDeleteTaskIds.add(taskId);
}else { } else {
cannotDeleteTaskIds.add(taskId); cannotDeleteTaskIds.add(taskId);
} }
}else { } else {
canDeleteTaskIds.add(taskId); canDeleteTaskIds.add(taskId);
} }
@@ -223,9 +230,9 @@ public class EducationPaperTaskServiceImpl implements IEducationPaperTaskService
educationPaperTaskMapper.deleteEducationPaperTaskByTaskIds( educationPaperTaskMapper.deleteEducationPaperTaskByTaskIds(
canDeleteTaskIds.toArray(new String[0])); canDeleteTaskIds.toArray(new String[0]));
monitorMapper.deleteByTaskIds(canDeleteTaskIds.toArray(new String[0])); monitorMapper.deleteByTaskIds(canDeleteTaskIds.toArray(new String[0]));
if (!cannotDeleteTaskIds.isEmpty()){ if (!cannotDeleteTaskIds.isEmpty()) {
List<String> taskNum= educationPaperMapper.selectTaskNumByids(cannotDeleteTaskIds); List<String> taskNum = educationPaperMapper.selectTaskNumByids(cannotDeleteTaskIds);
return ("以下任务下有试卷:"+taskNum+",不能删除!"); return ("以下任务下有试卷:" + taskNum + ",不能删除!");
} }
@@ -242,7 +249,7 @@ public class EducationPaperTaskServiceImpl implements IEducationPaperTaskService
@Override @Override
public String deleteEducationPaperTaskByTaskId(String taskId) { public String deleteEducationPaperTaskByTaskId(String taskId) {
EducationPaperTask educationPaperTask = educationPaperTaskMapper.selectById(taskId); EducationPaperTask educationPaperTask = educationPaperTaskMapper.selectById(taskId);
if (educationPaperTask.getTaskType().equals("0")||educationPaperTask.getTaskType().equals("1")||educationPaperTask.getTaskType().equals("3")){ if (educationPaperTask.getTaskType().equals("0") || educationPaperTask.getTaskType().equals("1") || educationPaperTask.getTaskType().equals("3")) {
// 1. 找出没有关联试卷的任务ID // 1. 找出没有关联试卷的任务ID
List<String> canDeleteTaskIds = new ArrayList<>(); List<String> canDeleteTaskIds = new ArrayList<>();
List<String> cannotDeleteTaskIds = new ArrayList<>(); List<String> cannotDeleteTaskIds = new ArrayList<>();
@@ -250,7 +257,7 @@ public class EducationPaperTaskServiceImpl implements IEducationPaperTaskService
int paperCount = educationPaperMapper.countPapersByTaskId(taskId); int paperCount = educationPaperMapper.countPapersByTaskId(taskId);
if (paperCount == 0) { if (paperCount == 0) {
canDeleteTaskIds.add(taskId); canDeleteTaskIds.add(taskId);
}else { } else {
cannotDeleteTaskIds.add(taskId); cannotDeleteTaskIds.add(taskId);
} }
@@ -262,14 +269,13 @@ public class EducationPaperTaskServiceImpl implements IEducationPaperTaskService
educationPaperTaskMapper.deleteEducationPaperTaskByTaskIds( educationPaperTaskMapper.deleteEducationPaperTaskByTaskIds(
canDeleteTaskIds.toArray(new String[0])); canDeleteTaskIds.toArray(new String[0]));
monitorMapper.deleteByTaskIds(canDeleteTaskIds.toArray(new String[0])); monitorMapper.deleteByTaskIds(canDeleteTaskIds.toArray(new String[0]));
if (!cannotDeleteTaskIds.isEmpty()){ if (!cannotDeleteTaskIds.isEmpty()) {
List<String> taskNum= educationPaperMapper.selectTaskNumByids(cannotDeleteTaskIds); List<String> taskNum = educationPaperMapper.selectTaskNumByids(cannotDeleteTaskIds);
return ("以下任务下有试卷:"+taskNum+",不能删除!"); return ("以下任务下有试卷:" + taskNum + ",不能删除!");
} }
} }
// monitorMapper.deleteByTaskId(taskId); // monitorMapper.deleteByTaskId(taskId);
// educationPaperTaskMapper.deleteEducationPaperTaskByTaskId(taskId); // educationPaperTaskMapper.deleteEducationPaperTaskByTaskId(taskId);
return "删除成功"; return "删除成功";
@@ -307,7 +313,7 @@ public class EducationPaperTaskServiceImpl implements IEducationPaperTaskService
@Override @Override
public List<ExamPaperKnowledgePoints> getPoints(String name) { public List<ExamPaperKnowledgePoints> getPoints(String name) {
Long id= educationPaperTaskMapper.getPointIdByName(name); Long id = educationPaperTaskMapper.getPointIdByName(name);
return educationPaperTaskMapper.getPoints(id); return educationPaperTaskMapper.getPoints(id);
} }
@@ -340,7 +346,7 @@ public class EducationPaperTaskServiceImpl implements IEducationPaperTaskService
// System.out.println(keywords+"keywords"); // System.out.println(keywords+"keywords");
// System.out.println(quLevel+"quLevel"); // System.out.println(quLevel+"quLevel");
// System.out.println(spName+"spName"); // System.out.println(spName+"spName");
return educationPaperTaskMapper.getQuCount(taskSpecialty, spName, quLevel, pointId, keywords,requiredTenantId); return educationPaperTaskMapper.getQuCount(taskSpecialty, spName, quLevel, pointId, keywords, requiredTenantId);
} }
@Override @Override
@@ -360,7 +366,7 @@ public class EducationPaperTaskServiceImpl implements IEducationPaperTaskService
// 格式化时间为字符串 // 格式化时间为字符串
String timeString = now.format(formatter); String timeString = now.format(formatter);
educationPaperTask.setTaskName(educationPaperTask.getTaskName()+timeString); educationPaperTask.setTaskName(educationPaperTask.getTaskName() + timeString);
educationPaperTask.setIsTemplate(1); educationPaperTask.setIsTemplate(1);
educationPaperTaskMapper.insertEducationPaperTask(educationPaperTask); educationPaperTaskMapper.insertEducationPaperTask(educationPaperTask);
@@ -390,7 +396,7 @@ public class EducationPaperTaskServiceImpl implements IEducationPaperTaskService
//获得 试卷试题 //获得 试卷试题
List<EducationPaperQu> educationPaperQus = educationPaperQuMapper.selectPaperQuListByPaperId(paperId); List<EducationPaperQu> educationPaperQus = educationPaperQuMapper.selectPaperQuListByPaperId(paperId);
int number=educationPaperMapper.selectCountPaperList(); int number = educationPaperMapper.selectCountPaperList();
// 格式化为8位不足前面补0 // 格式化为8位不足前面补0
String formattedNumber = String.format("%08d", ++number); String formattedNumber = String.format("%08d", ++number);
@@ -428,7 +434,7 @@ public class EducationPaperTaskServiceImpl implements IEducationPaperTaskService
//复制考场设置 //复制考场设置
List<EducationPaperSession> educationPaperSessions = educationPaperSessionMapper.selectEducationPaperSessionByTaskId(taskId); List<EducationPaperSession> educationPaperSessions = educationPaperSessionMapper.selectEducationPaperSessionByTaskId(taskId);
if (educationPaperSessions!=null&&educationPaperSessions.size()>0){ if (educationPaperSessions != null && educationPaperSessions.size() > 0) {
educationPaperSessions.forEach(session -> session.setSessionId(IdUtils.simpleUUID())); educationPaperSessions.forEach(session -> session.setSessionId(IdUtils.simpleUUID()));
educationPaperSessions.forEach(session -> session.setPaperId(null)); educationPaperSessions.forEach(session -> session.setPaperId(null));
educationPaperSessions.forEach(session -> session.setTaskId(newtaskId)); educationPaperSessions.forEach(session -> session.setTaskId(newtaskId));
@@ -446,9 +452,9 @@ public class EducationPaperTaskServiceImpl implements IEducationPaperTaskService
// 2. 复制所有试卷建立新旧ID映射 // 2. 复制所有试卷建立新旧ID映射
Map<String, String> paperIdMapping = new HashMap<>(); Map<String, String> paperIdMapping = new HashMap<>();
if (educationPapers!=null&&educationPapers.size()>0){ if (educationPapers != null && educationPapers.size() > 0) {
for (EducationPaper paper : educationPapers) { for (EducationPaper paper : educationPapers) {
int number=educationPaperMapper.selectCountPaperList(); int number = educationPaperMapper.selectCountPaperList();
// 格式化为8位不足前面补0 // 格式化为8位不足前面补0
String formattedNumber = String.format("%08d", ++number); String formattedNumber = String.format("%08d", ++number);
@@ -468,7 +474,7 @@ public class EducationPaperTaskServiceImpl implements IEducationPaperTaskService
} }
} }
if (educationPaperSessions!=null&&educationPaperSessions.size()>0){ if (educationPaperSessions != null && educationPaperSessions.size() > 0) {
// 3. 处理考场分配 // 3. 处理考场分配
for (EducationPaperSession session : educationPaperSessions) { for (EducationPaperSession session : educationPaperSessions) {
session.setSessionId(IdUtils.simpleUUID()); session.setSessionId(IdUtils.simpleUUID());
@@ -495,25 +501,25 @@ public class EducationPaperTaskServiceImpl implements IEducationPaperTaskService
@Override @Override
public boolean changeStatus(String taskId, String status) { public boolean changeStatus(String taskId, String status) {
return educationPaperTaskMapper.changeStatus(taskId,status); return educationPaperTaskMapper.changeStatus(taskId, status);
} }
@Override @Override
public ExamPaperVo selectPaperQuByPaperId(String taskId) { public ExamPaperVo selectPaperQuByPaperId(String taskId) {
EducationPaperParam educationPaperParam = educationPaperParamMapper.selectEducationPaperParamByTaskId(taskId); EducationPaperParam educationPaperParam = educationPaperParamMapper.selectEducationPaperParamByTaskId(taskId);
String paperId= educationPaperTaskMapper.selectPaperQuByPaperId(taskId); String paperId = educationPaperTaskMapper.selectPaperQuByPaperId(taskId);
if (StringUtils.isBlank(paperId)){ if (StringUtils.isBlank(paperId)) {
return null; return null;
} }
List<ExamQuestion> examQuestionList=new ArrayList<>(); List<ExamQuestion> examQuestionList = new ArrayList<>();
List<EducationPaperScheme> educationPaperSchemeList=new ArrayList<>(); List<EducationPaperScheme> educationPaperSchemeList = new ArrayList<>();
List<String> quIds=new ArrayList<>(); List<String> quIds = new ArrayList<>();
if (StringUtils.isNotBlank(paperId)){ if (StringUtils.isNotBlank(paperId)) {
quIds =educationPaperQuMapper.selectPaperQuByPaperId(paperId); quIds = educationPaperQuMapper.selectPaperQuByPaperId(paperId);
if (quIds!=null&&quIds.size()>0){ if (quIds != null && quIds.size() > 0) {
examQuestionList =examQuestionMapper.selectExamQuestionListByQuIds(quIds); examQuestionList = examQuestionMapper.selectExamQuestionListByQuIds(quIds);
if (examQuestionList!=null&&examQuestionList.size()>0){ if (examQuestionList != null && examQuestionList.size() > 0) {
// 根据 quIds 顺序重新排序 examQuestionList // 根据 quIds 顺序重新排序 examQuestionList
Map<String, ExamQuestion> questionMap = examQuestionList.stream() Map<String, ExamQuestion> questionMap = examQuestionList.stream()
@@ -524,21 +530,21 @@ public class EducationPaperTaskServiceImpl implements IEducationPaperTaskService
.collect(Collectors.toList()); .collect(Collectors.toList());
for (ExamQuestion examQuestion : examQuestionList) { for (ExamQuestion examQuestion : examQuestionList) {
//查找原始和素材试题文件 //查找原始和素材试题文件
List<ExamQuestionFile> sysFileUploads =sysFileMapper.selectSysFileByQuidIN(examQuestion.getQuId()); List<ExamQuestionFile> sysFileUploads = sysFileMapper.selectSysFileByQuidIN(examQuestion.getQuId());
examQuestion.setFileUploads(sysFileUploads); examQuestion.setFileUploads(sysFileUploads);
} }
} }
} }
educationPaperSchemeList= educationPaperSchemeMapper.selectEducationPaperTaskByTaskId(taskId); educationPaperSchemeList = educationPaperSchemeMapper.selectEducationPaperTaskByTaskId(taskId);
} }
String nickname = SecurityFrameworkUtils.getLoginUserNickname(); String nickname = SecurityFrameworkUtils.getLoginUserNickname();
Long userId=SecurityFrameworkUtils.getLoginUserId(); Long userId = SecurityFrameworkUtils.getLoginUserId();
EducationPaperTask educationPaperTask = educationPaperTaskMapper.selectEducationPaperTaskByTaskId(taskId); EducationPaperTask educationPaperTask = educationPaperTaskMapper.selectEducationPaperTaskByTaskId(taskId);
EducationPaper educationPaper = educationPaperMapper.selectEducationPaperByPaperId(paperId); EducationPaper educationPaper = educationPaperMapper.selectEducationPaperByPaperId(paperId);
//设置进入试卷 考生考试信息确认参数 //设置进入试卷 考生考试信息确认参数
StuInfoPaper stuInfoPaper=new StuInfoPaper(); StuInfoPaper stuInfoPaper = new StuInfoPaper();
stuInfoPaper.setQueNum(String.valueOf(quIds.size())); stuInfoPaper.setQueNum(String.valueOf(quIds.size()));
stuInfoPaper.setNickName(nickname); stuInfoPaper.setNickName(nickname);
stuInfoPaper.setAnswerTime(educationPaperParam.getExamTime()); stuInfoPaper.setAnswerTime(educationPaperParam.getExamTime());
@@ -546,15 +552,15 @@ public class EducationPaperTaskServiceImpl implements IEducationPaperTaskService
stuInfoPaper.setTaskName(educationPaperTask.getTaskName()); stuInfoPaper.setTaskName(educationPaperTask.getTaskName());
EducationPaperPerson educationPaperPerson = educationPaperPersonMapper.selectByTaskIdAndPersonId(taskId, String.valueOf(userId)); EducationPaperPerson educationPaperPerson = educationPaperPersonMapper.selectByTaskIdAndPersonId(taskId, String.valueOf(userId));
ExamPaperVo examPaperVo=new ExamPaperVo(); ExamPaperVo examPaperVo = new ExamPaperVo();
if (educationPaperPerson!=null){ if (educationPaperPerson != null) {
String sessionId = educationPaperPerson.getSessionId(); String sessionId = educationPaperPerson.getSessionId();
EducationPaperSession educationPaperSession = educationPaperSessionMapper.selectEducationPaperSessionBySessionId(sessionId); EducationPaperSession educationPaperSession = educationPaperSessionMapper.selectEducationPaperSessionBySessionId(sessionId);
examPaperVo.setEducationPaperSession(educationPaperSession); examPaperVo.setEducationPaperSession(educationPaperSession);
stuInfoPaper.setBatch(educationPaperPerson.getBatch()); stuInfoPaper.setBatch(educationPaperPerson.getBatch());
} }
Long loginTenantId = SecurityFrameworkUtils.getLoginTenantId(); Long loginTenantId = SecurityFrameworkUtils.getLoginTenantId();
String schoolName= examQuestionMapper.selectSchoolnameBytId(loginTenantId); String schoolName = examQuestionMapper.selectSchoolnameBytId(loginTenantId);
stuInfoPaper.setUserName(SecurityFrameworkUtils.getLoginUserName()); stuInfoPaper.setUserName(SecurityFrameworkUtils.getLoginUserName());
stuInfoPaper.setSfz(SecurityFrameworkUtils.getLoginUserSFZ()); stuInfoPaper.setSfz(SecurityFrameworkUtils.getLoginUserSFZ());
stuInfoPaper.setSchoolName(schoolName); stuInfoPaper.setSchoolName(schoolName);
@@ -564,7 +570,7 @@ public class EducationPaperTaskServiceImpl implements IEducationPaperTaskService
examPaperVo.setPaperId(paperId); examPaperVo.setPaperId(paperId);
examPaperVo.setEducationPaperParam(educationPaperParam); examPaperVo.setEducationPaperParam(educationPaperParam);
examPaperVo.setStuInfoPaper(stuInfoPaper); examPaperVo.setStuInfoPaper(stuInfoPaper);
if (StringUtils.isNotBlank(educationPaper.getNum())){ if (StringUtils.isNotBlank(educationPaper.getNum())) {
examPaperVo.setPaperNum(educationPaper.getNum()); examPaperVo.setPaperNum(educationPaper.getNum());
} }
return examPaperVo; return examPaperVo;
@@ -575,19 +581,19 @@ public class EducationPaperTaskServiceImpl implements IEducationPaperTaskService
String taskType = educationPaperTask.getTaskType(); String taskType = educationPaperTask.getTaskType();
PageResult<EducationPaperTask> educationPaperTasks = educationPaperTaskMapper.selectEducationPaperTaskList(educationPaperTask); PageResult<EducationPaperTask> educationPaperTasks = educationPaperTaskMapper.selectEducationPaperTaskList(educationPaperTask);
Long stuId= SecurityFrameworkUtils.getLoginUserId(); Long stuId = SecurityFrameworkUtils.getLoginUserId();
List<EducationPaperTask> list = educationPaperTasks.getList(); List<EducationPaperTask> list = educationPaperTasks.getList();
List<String > taskIds= educationPaperPersonMapper.selectTaskIdByStuid(stuId); List<String> taskIds = educationPaperPersonMapper.selectTaskIdByStuid(stuId);
if (list!=null&&list.size()>0&&taskIds!=null&&taskIds.size()>0){ if (list != null && list.size() > 0 && taskIds != null && taskIds.size() > 0) {
list = list.stream() list = list.stream()
.filter(task -> taskIds.contains(task.getTaskId())) .filter(task -> taskIds.contains(task.getTaskId()))
.collect(Collectors.toList()); .collect(Collectors.toList());
if ("0".equals(taskType)){ if ("0".equals(taskType)) {
for (EducationPaperTask paperTask : list) { for (EducationPaperTask paperTask : list) {
String taskId = paperTask.getTaskId(); String taskId = paperTask.getTaskId();
int count=0; int count = 0;
List<EducationPaper> educationPapers = educationPaperMapper.selectPaperListByTaskId(paperTask.getTaskId()); List<EducationPaper> educationPapers = educationPaperMapper.selectPaperListByTaskId(paperTask.getTaskId());
if (educationPapers!=null&&educationPapers.size()>0){ if (educationPapers != null && educationPapers.size() > 0) {
for (EducationPaper educationPaper : educationPapers) { for (EducationPaper educationPaper : educationPapers) {
try { try {
count += Integer.parseInt(educationPaper.getCounts()); count += Integer.parseInt(educationPaper.getCounts());
@@ -603,19 +609,19 @@ public class EducationPaperTaskServiceImpl implements IEducationPaperTaskService
EducationPaperParam educationPaperParam = educationPaperParamMapper.selectEducationPaperParamByTaskId(taskId); EducationPaperParam educationPaperParam = educationPaperParamMapper.selectEducationPaperParamByTaskId(taskId);
//最高成绩 //最高成绩
if ("0".equals(educationPaperParam.getSaveGrades())){ if ("0".equals(educationPaperParam.getSaveGrades())) {
String score= monitorMapper.selectByStuIdAndTaskIdTop(stuId,taskId); String score = monitorMapper.selectByStuIdAndTaskIdTop(stuId, taskId);
if (StringUtils.isNotBlank(score)){ if (StringUtils.isNotBlank(score)) {
paperTask.setScore(score); paperTask.setScore(score);
}else { } else {
paperTask.setScore("0.0"); paperTask.setScore("0.0");
} }
}else { } else {
String score= monitorMapper.selectByStuIdAndTaskIdNew(stuId,taskId); String score = monitorMapper.selectByStuIdAndTaskIdNew(stuId, taskId);
if (StringUtils.isNotBlank(score)){ if (StringUtils.isNotBlank(score)) {
paperTask.setScore(score); paperTask.setScore(score);
}else { } else {
paperTask.setScore("0.0"); paperTask.setScore("0.0");
} }
} }
@@ -624,10 +630,10 @@ public class EducationPaperTaskServiceImpl implements IEducationPaperTaskService
} }
//查找 考试状态还没结束的 任务id ,取 交集 //查找 考试状态还没结束的 任务id ,取 交集
List<String > taskNoEndIds= monitorMapper.selectByStuIdAndTaskId(stuId); List<String> taskNoEndIds = monitorMapper.selectByStuIdAndTaskId(stuId);
if(taskType.equals("1")){ if (taskType.equals("1")) {
if (list!=null&&list.size()>0&&taskNoEndIds!=null&&taskNoEndIds.size()>0){ if (list != null && list.size() > 0 && taskNoEndIds != null && taskNoEndIds.size() > 0) {
list = list.stream() list = list.stream()
.filter(task -> taskNoEndIds.contains(task.getTaskId())) .filter(task -> taskNoEndIds.contains(task.getTaskId()))
.collect(Collectors.toList()); .collect(Collectors.toList());
@@ -636,7 +642,7 @@ public class EducationPaperTaskServiceImpl implements IEducationPaperTaskService
educationPaperTasks.setList(list); educationPaperTasks.setList(list);
return educationPaperTasks; return educationPaperTasks;
}else { } else {
return null; return null;
} }
} }
@@ -648,7 +654,7 @@ public class EducationPaperTaskServiceImpl implements IEducationPaperTaskService
for (EducationPaperTask paperTask : list) { for (EducationPaperTask paperTask : list) {
String taskId = paperTask.getTaskId(); String taskId = paperTask.getTaskId();
List<EducationPaper> educationPapers = educationPaperMapper.selectPaperListByTaskId(taskId); List<EducationPaper> educationPapers = educationPaperMapper.selectPaperListByTaskId(taskId);
List<EducationPaperScheme> educationPaperSchemeList=educationPaperSchemeMapper.selectEducationPaperTaskByTaskId(taskId); List<EducationPaperScheme> educationPaperSchemeList = educationPaperSchemeMapper.selectEducationPaperTaskByTaskId(taskId);
paperTask.setEducationPaperList(educationPapers); paperTask.setEducationPaperList(educationPapers);
paperTask.setEducationPaperSchemeList(educationPaperSchemeList); paperTask.setEducationPaperSchemeList(educationPaperSchemeList);
} }
@@ -661,7 +667,7 @@ public class EducationPaperTaskServiceImpl implements IEducationPaperTaskService
throw new QueTypeException("题型参数不能为空"); throw new QueTypeException("题型参数不能为空");
} }
List<EducationPaperScheme> educationPaperSchemeList=educationPaperSchemeMapper.selectEducationPaperTaskByTaskId(dto.getTaskId()); List<EducationPaperScheme> educationPaperSchemeList = educationPaperSchemeMapper.selectEducationPaperTaskByTaskId(dto.getTaskId());
if (educationPaperSchemeList == null) { if (educationPaperSchemeList == null) {
educationPaperSchemeList = new ArrayList<>(); educationPaperSchemeList = new ArrayList<>();
} }
@@ -678,7 +684,7 @@ public class EducationPaperTaskServiceImpl implements IEducationPaperTaskService
.filter(q -> !existingSpNames.contains(q)) .filter(q -> !existingSpNames.contains(q))
.collect(Collectors.toList()); .collect(Collectors.toList());
if (extraQue.size()>0){ if (extraQue.size() > 0) {
throw new QueTypeException("当前任务方案中不存在以下题型:" + String.join(",", extraQue)); throw new QueTypeException("当前任务方案中不存在以下题型:" + String.join(",", extraQue));
} }

View File

@@ -4,8 +4,10 @@ import jakarta.annotation.Resource;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import pc.exam.pp.module.exam.dal.dataobject.EducationPaper; import pc.exam.pp.module.exam.dal.dataobject.EducationPaper;
import pc.exam.pp.module.exam.dal.dataobject.EducationPaperTask;
import pc.exam.pp.module.exam.dal.dataobject.student.StuPaperScoreDO; import pc.exam.pp.module.exam.dal.dataobject.student.StuPaperScoreDO;
import pc.exam.pp.module.exam.dal.mysql.paper.EducationPaperMapper; import pc.exam.pp.module.exam.dal.mysql.paper.EducationPaperMapper;
import pc.exam.pp.module.exam.dal.mysql.paper.EducationPaperTaskMapper;
import pc.exam.pp.module.exam.dal.mysql.student.StuPaperScoreMapper; import pc.exam.pp.module.exam.dal.mysql.student.StuPaperScoreMapper;
import pc.exam.pp.module.exam.dal.mysql.student.StuScoreVo; import pc.exam.pp.module.exam.dal.mysql.student.StuScoreVo;
@@ -25,6 +27,8 @@ public class StuPaperScoreServiceImpl implements StuPaperScoreService {
private StuPaperScoreMapper stuPaperScoreMapper; private StuPaperScoreMapper stuPaperScoreMapper;
@Resource @Resource
private EducationPaperMapper educationPaperMapper; private EducationPaperMapper educationPaperMapper;
@Resource
private EducationPaperTaskMapper educationPaperTaskMapper;
@Override @Override
public List<StuPaperScoreDO> findByStuIDAndPaperId(Long stuId, String paperId, String temporaryId) { public List<StuPaperScoreDO> findByStuIDAndPaperId(Long stuId, String paperId, String temporaryId) {
@@ -50,7 +54,6 @@ public class StuPaperScoreServiceImpl implements StuPaperScoreService {
BigDecimal trueScore = new BigDecimal(0); BigDecimal trueScore = new BigDecimal(0);
String stuNumber = ""; String stuNumber = "";
String nickName = ""; String nickName = "";
String taskId = "";
String picUrl = ""; String picUrl = "";
List<StuScoreVo> stuScoreVos = stuPaperScoreMapper.getStuScore(stuId, paperId, temporaryId); List<StuScoreVo> stuScoreVos = stuPaperScoreMapper.getStuScore(stuId, paperId, temporaryId);
for (StuScoreVo scoreVo : stuScoreVos) { for (StuScoreVo scoreVo : stuScoreVos) {
@@ -68,7 +71,10 @@ public class StuPaperScoreServiceImpl implements StuPaperScoreService {
stuScoreVo.setPicUrl(picUrl); stuScoreVo.setPicUrl(picUrl);
// 4、通过paperId查询任务编号 // 4、通过paperId查询任务编号
EducationPaper educationPaper = educationPaperMapper.selectEducationPaperByPaperId(paperId); EducationPaper educationPaper = educationPaperMapper.selectEducationPaperByPaperId(paperId);
stuScoreVo.setTaskId(educationPaper.getTaskId()); // 5、通过任务编号查询任务信息
EducationPaperTask educationPaperTask = educationPaperTaskMapper.selectEducationPaperTaskByTaskId(educationPaper.getTaskId());
// 6、将任务编号放入对象中
stuScoreVo.setTaskId(educationPaperTask.getTaskNum());
return stuScoreVo; return stuScoreVo;
} }

View File

@@ -46,7 +46,7 @@ import java.util.stream.Collectors;
*/ */
@RestController @RestController
@RequestMapping("/tool") @RequestMapping("/tool")
@Tag( name = "测试判分") @Tag(name = "测试判分")
@Validated @Validated
public class AutoToolsController { public class AutoToolsController {
@Resource @Resource
@@ -70,14 +70,14 @@ public class AutoToolsController {
@GetMapping("/getStuScoreInfo") @GetMapping("/getStuScoreInfo")
@Operation(summary = "通过学生ID、试卷ID获取") @Operation(summary = "通过学生ID、试卷ID获取")
public CommonResult<StuPaperScoreInfoVo> getStuScore(StuPaperReqVo stuPaperReqVo){ public CommonResult<StuPaperScoreInfoVo> getStuScore(StuPaperReqVo stuPaperReqVo) {
// 1、创建对象 // 1、创建对象
StuPaperScoreInfoVo stuPaperScoreInfoVos = new StuPaperScoreInfoVo(); StuPaperScoreInfoVo stuPaperScoreInfoVos = new StuPaperScoreInfoVo();
// 2、查询学生试卷信息 // 2、查询学生试卷信息
StuScoreVo stuScoreVo = stuPaperScoreService.getStuScore(stuPaperReqVo.getStuId(),stuPaperReqVo.getPaperId(), stuPaperReqVo.getTemporaryId()); StuScoreVo stuScoreVo = stuPaperScoreService.getStuScore(stuPaperReqVo.getStuId(), stuPaperReqVo.getPaperId(), stuPaperReqVo.getTemporaryId());
stuPaperScoreInfoVos.setStuInfoReqVo(stuScoreVo); stuPaperScoreInfoVos.setStuInfoReqVo(stuScoreVo);
// 3、查询学生试卷得分信息 // 3、查询学生试卷得分信息
stuPaperScoreInfoVos.setStuPaperScoreDOList(stuPaperScoreService.findByStuIDAndPaperId(stuPaperReqVo.getStuId(),stuPaperReqVo.getPaperId(), stuPaperReqVo.getTemporaryId())); stuPaperScoreInfoVos.setStuPaperScoreDOList(stuPaperScoreService.findByStuIDAndPaperId(stuPaperReqVo.getStuId(), stuPaperReqVo.getPaperId(), stuPaperReqVo.getTemporaryId()));
// 4、查询学生试卷内容信息 // 4、查询学生试卷内容信息
List<String> quIds = educationPaperQuMapper.selectPaperQuByPaperId(stuPaperReqVo.getPaperId()); List<String> quIds = educationPaperQuMapper.selectPaperQuByPaperId(stuPaperReqVo.getPaperId());
List<ExamQuestion> examQuestionList = examQuestionMapper.selectExamQuestionListByQuIds(quIds); List<ExamQuestion> examQuestionList = examQuestionMapper.selectExamQuestionListByQuIds(quIds);
@@ -90,7 +90,7 @@ public class AutoToolsController {
// 一条一条进行查询试题,防止顺序错乱 // 一条一条进行查询试题,防止顺序错乱
stuPaperScoreInfoVos.setExamQuestionList(examQuestionList); stuPaperScoreInfoVos.setExamQuestionList(examQuestionList);
// 5、查询学生试卷分析 // 5、查询学生试卷分析
List<StuPaperScoreDO> scoreDOS = stuPaperScoreService.findByStuIDAndPaperId(stuPaperReqVo.getStuId(),stuPaperReqVo.getPaperId(), stuPaperReqVo.getTemporaryId()); List<StuPaperScoreDO> scoreDOS = stuPaperScoreService.findByStuIDAndPaperId(stuPaperReqVo.getStuId(), stuPaperReqVo.getPaperId(), stuPaperReqVo.getTemporaryId());
String judgementStr = "<p>试卷分析</p>"; String judgementStr = "<p>试卷分析</p>";
for (StuPaperScoreDO scoreDO : scoreDOS) { for (StuPaperScoreDO scoreDO : scoreDOS) {
judgementStr += "<p>---------------------------------------</p>"; judgementStr += "<p>---------------------------------------</p>";
@@ -102,6 +102,7 @@ public class AutoToolsController {
/** /**
* 开始考试 通过websocket进行传输时间 * 开始考试 通过websocket进行传输时间
*
* @param stuInTheExam 信息 * @param stuInTheExam 信息
* @return true * @return true
*/ */
@@ -116,7 +117,7 @@ public class AutoToolsController {
// 获取登录用户 // 获取登录用户
LoginUser loginUser = SecurityFrameworkUtils.getLoginUser(); LoginUser loginUser = SecurityFrameworkUtils.getLoginUser();
// 通过token获取用户redis信息获取refreshToken // 通过token获取用户redis信息获取refreshToken
OAuth2AccessTokenDO oAuth2AccessTokenDO = JsonUtils.parseObject(stringRedisTemplate.opsForValue().get("oauth2_access_token:"+token), OAuth2AccessTokenDO.class); OAuth2AccessTokenDO oAuth2AccessTokenDO = JsonUtils.parseObject(stringRedisTemplate.opsForValue().get("oauth2_access_token:" + token), OAuth2AccessTokenDO.class);
int startTime = 0; int startTime = 0;
if (oAuth2AccessTokenDO != null) { if (oAuth2AccessTokenDO != null) {
String refreshToken = oAuth2AccessTokenDO.getRefreshToken(); String refreshToken = oAuth2AccessTokenDO.getRefreshToken();
@@ -178,6 +179,7 @@ public class AutoToolsController {
/** /**
* 停止考试 * 停止考试
*
* @return true * @return true
*/ */
@GetMapping("/stopExam") @GetMapping("/stopExam")
@@ -187,7 +189,7 @@ public class AutoToolsController {
if (request != null) { if (request != null) {
token = SecurityFrameworkUtils.obtainAuthorization(request, token = SecurityFrameworkUtils.obtainAuthorization(request,
securityProperties.getTokenHeader(), securityProperties.getTokenParameter()); securityProperties.getTokenHeader(), securityProperties.getTokenParameter());
OAuth2AccessTokenDO oAuth2AccessTokenDO = JsonUtils.parseObject(stringRedisTemplate.opsForValue().get("oauth2_access_token:"+token), OAuth2AccessTokenDO.class); OAuth2AccessTokenDO oAuth2AccessTokenDO = JsonUtils.parseObject(stringRedisTemplate.opsForValue().get("oauth2_access_token:" + token), OAuth2AccessTokenDO.class);
if (oAuth2AccessTokenDO != null) { if (oAuth2AccessTokenDO != null) {
// 删除对应的线程池 // 删除对应的线程池
String refreshToken = oAuth2AccessTokenDO.getRefreshToken(); String refreshToken = oAuth2AccessTokenDO.getRefreshToken();
@@ -198,6 +200,7 @@ public class AutoToolsController {
return CommonResult.success(false); return CommonResult.success(false);
} }
// 时间转换
public static String formatLongDuration(int totalSeconds) { public static String formatLongDuration(int totalSeconds) {
int hours = totalSeconds / 3600; int hours = totalSeconds / 3600;
int minutes = (totalSeconds % 3600) / 60; int minutes = (totalSeconds % 3600) / 60;