From a1004271813eb9b85b9f282371215bfd9892a5fc Mon Sep 17 00:00:00 2001 From: "YOHO\\20373" <2037305722@qq.com> Date: Mon, 9 Jun 2025 10:51:13 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E4=BF=AE=E6=94=B9=E3=80=91=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E5=90=8E=E5=8F=B0api=E6=8E=A5=E5=8F=A3=E6=B3=A8?= =?UTF-8?q?=E9=87=8A=EF=BC=8C=E4=BC=98=E5=8C=96mysql=E5=88=A4=E5=88=86?= =?UTF-8?q?=EF=BC=8C=E7=9F=A5=E8=AF=86=E7=82=B9=E6=94=B9=E4=B8=BA=E5=AD=98?= =?UTF-8?q?=E5=82=A8id=EF=BC=8C=E8=AF=95=E9=A2=98=E5=B7=B2=E4=BD=BF?= =?UTF-8?q?=E7=94=A8=EF=BC=8C=E5=AD=A6=E7=94=9F=E9=99=A4=E5=BE=85=E8=80=83?= =?UTF-8?q?=E5=85=B6=E5=AE=83=E7=8A=B6=E6=80=81=E4=B8=8D=E5=8F=AF=E5=88=A0?= =?UTF-8?q?=E9=99=A4=E3=80=82=E3=80=82=E3=80=82=20=E3=80=90=E6=96=B0?= =?UTF-8?q?=E5=A2=9E=E3=80=91=E8=AF=95=E5=8D=B7=E4=BB=BB=E5=8A=A1=E5=8F=82?= =?UTF-8?q?=E6=95=B0=EF=BC=8C=E5=9C=A8=E5=B7=B2=E6=9C=89=E7=9A=84=E8=AF=95?= =?UTF-8?q?=E5=8D=B7=E9=87=8C=E6=8A=BD=E5=8D=B7=E3=80=82=E3=80=82=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/exception/QueTypeException.java | 8 + .../ExamKnowledgePointsController.java | 10 +- .../admin/paper/EducationPaperController.java | 28 +- .../paper/EducationPaperParamController.java | 9 + .../paper/EducationPaperPersonController.java | 13 + .../paper/EducationPaperQuController.java | 12 + .../paper/EducationPaperSchemeController.java | 10 + .../EducationPaperSessionController.java | 11 + .../paper/EducationPaperTaskController.java | 49 ++- .../admin/paper/dto/PaperQueUpdateDTO.java | 16 + .../admin/paper/dto/PaperSubmitDTO.java | 13 + .../admin/paper/dto/PaperSubmitListDTO.java | 18 + .../controller/admin/paper/vo/SchemeInfo.java | 16 + .../dal/dataobject/EducationPaperParam.java | 8 +- .../dal/dataobject/EducationPaperTask.java | 8 + .../exam/dal/dataobject/ExamQuestion.java | 6 +- .../knowledge/ExamKnowledgePointsMapper.java | 5 + .../exam/dal/mysql/monitor/MonitorMapper.java | 1 + .../mysql/paper/EducationPaperQuMapper.java | 9 + .../paper/EducationPaperSchemeMapper.java | 1 + .../question/ExamQuestionAnswerMapper.java | 5 + .../EducationPaperPersonServiceImpl.java | 53 ++- .../paper/EducationPaperQuServiceImpl.java | 30 ++ .../EducationPaperSchemeServiceImpl.java | 5 + .../paper/EducationPaperServiceImpl.java | 162 +++++++- .../paper/EducationPaperTaskServiceImpl.java | 52 ++- .../paper/IEducationPaperSchemeService.java | 3 + .../service/paper/IEducationPaperService.java | 3 + .../paper/IEducationPaperTaskService.java | 5 + .../question/ExamQuestionServiceImpl.java | 106 ++++- .../mapper/exam/EducationPaperParamMapper.xml | 23 +- .../mapper/exam/EducationPaperQuMapper.xml | 16 + .../exam/EducationPaperSchemeMapper.xml | 3 + .../mapper/exam/ExamQuestionAnswerMapper.xml | 8 + .../knowledge/ExamKnowledgePointsMapper.xml | 7 + .../mapper/monitor/MonitorMapper.xml | 3 + .../infra/enums/ErrorCodeConstants.java | 2 +- .../admin/getpoints/GetPointsController.java | 14 +- .../admin/getpoints/vo/FileNode.java | 14 + .../admin/getpoints/vo/FilePointsVo.java | 16 + .../service/browser/BrowserServericeImpl.java | 8 +- .../service/file/FileServericeImpl.java | 8 +- .../getpoints/ExamGetPointsService.java | 3 +- .../getpoints/ExamGetPointsServiceImpl.java | 59 ++- .../service/mysql/MysqlServericeImpl.java | 371 +++++++++++------- 45 files changed, 1027 insertions(+), 203 deletions(-) create mode 100644 exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/exception/QueTypeException.java create mode 100644 exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/paper/dto/PaperQueUpdateDTO.java create mode 100644 exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/paper/dto/PaperSubmitDTO.java create mode 100644 exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/paper/dto/PaperSubmitListDTO.java create mode 100644 exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/paper/vo/SchemeInfo.java create mode 100644 exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/controller/admin/getpoints/vo/FileNode.java create mode 100644 exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/controller/admin/getpoints/vo/FilePointsVo.java diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/exception/QueTypeException.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/exception/QueTypeException.java new file mode 100644 index 00000000..fd9fa556 --- /dev/null +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/exception/QueTypeException.java @@ -0,0 +1,8 @@ +package pc.exam.pp.module.exam.controller.admin.exception; + +public class QueTypeException extends RuntimeException { + public QueTypeException(String message) { + super(message); + } +} + diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/knowledge/ExamKnowledgePointsController.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/knowledge/ExamKnowledgePointsController.java index 08b2d2ca..8a9d86ea 100644 --- a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/knowledge/ExamKnowledgePointsController.java +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/knowledge/ExamKnowledgePointsController.java @@ -1,5 +1,7 @@ package pc.exam.pp.module.exam.controller.admin.knowledge; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; import jakarta.servlet.http.HttpServletResponse; import lombok.extern.java.Log; import org.springframework.beans.factory.annotation.Autowired; @@ -23,6 +25,7 @@ import java.util.Objects; * @author pengchen * @date 2025-04-02 */ +@Tag(name = "管理后台 - 知识点") @RestController @RequestMapping("/exam/points") public class ExamKnowledgePointsController{ @@ -33,6 +36,7 @@ public class ExamKnowledgePointsController{ /** * 查询知识点列表 */ + @Operation(summary = "查询知识点列表") @GetMapping("/list") public CommonResult list(ExamKnowledgePoints knowledgePoints) { @@ -53,6 +57,7 @@ public class ExamKnowledgePointsController{ /** * 获取知识点详细信息 */ + @Operation(summary = "获取知识点详细信息") @GetMapping(value = "/{spId}") public CommonResult getInfo(@PathVariable("spId") Long spId) { return CommonResult.success(knowledgePointsService.selectKnowledgePointsBySpId(spId)); @@ -61,7 +66,7 @@ public class ExamKnowledgePointsController{ /** * 新增知识点 */ - + @Operation(summary = "新增知识点") @PostMapping public CommonResult add(@RequestBody ExamKnowledgePoints knowledgePoints) { //获取登录用户id @@ -95,6 +100,7 @@ public class ExamKnowledgePointsController{ /** * 修改知识点 */ + @Operation(summary = "修改知识点") @PutMapping public CommonResult edit(@RequestBody ExamKnowledgePoints knowledgePoints) { //判断是否修改的根节点 @@ -113,6 +119,7 @@ public class ExamKnowledgePointsController{ /** * 删除知识点 */ + @Operation(summary = "删除知识点") @DeleteMapping("/{spIds}") public CommonResult remove(@PathVariable Long[] spIds) { //用于判断是否符合删除条件 @@ -150,6 +157,7 @@ public class ExamKnowledgePointsController{ /** * 构建知识点树状结构 */ + @Operation(summary = "构建知识点树状结构") @GetMapping("/tree") public CommonResult listTree(ExamKnowledgePoints knowledgePoints) { //定义List diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/paper/EducationPaperController.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/paper/EducationPaperController.java index 7a516f63..75eff1f0 100644 --- a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/paper/EducationPaperController.java +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/paper/EducationPaperController.java @@ -1,6 +1,8 @@ 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.servlet.http.HttpServletResponse; import lombok.extern.java.Log; import org.checkerframework.checker.units.qual.A; @@ -12,6 +14,7 @@ import pc.exam.pp.framework.common.pojo.PageResult; import pc.exam.pp.framework.common.util.object.BeanUtils; import pc.exam.pp.module.exam.controller.admin.paper.dto.EducationPaperStuDto; import pc.exam.pp.module.exam.controller.admin.paper.dto.PaperQueryRequest; +import pc.exam.pp.module.exam.controller.admin.paper.dto.PaperSubmitDTO; import pc.exam.pp.module.exam.controller.admin.paper.dto.StatusDto; import pc.exam.pp.module.exam.controller.admin.paper.vo.PaperPageVo; import pc.exam.pp.module.exam.dal.dataobject.EducationPaper; @@ -32,6 +35,7 @@ import static pc.exam.pp.framework.security.core.util.SecurityFrameworkUtils.get * @date 2025-04-15 */ @RestController +@Tag(name = "管理后台 - 试卷管理") @RequestMapping("/exam/paper") public class EducationPaperController { @@ -47,6 +51,7 @@ public class EducationPaperController /** * 查询试卷列表 */ + @Operation(summary = "查询试卷列表") @GetMapping("/list") public CommonResult> list(PaperPageVo paperPageVo) { @@ -68,6 +73,7 @@ public class EducationPaperController /** * 获取试卷详细信息 */ + @Operation(summary = "获取试卷详细信息") @GetMapping(value = "/{paperId}") public CommonResult getInfo(@PathVariable("paperId") String paperId) { @@ -77,6 +83,7 @@ public class EducationPaperController /** * 新增试卷 */ + @Operation(summary = "新增试卷") @GetMapping("/add") public CommonResult add(@RequestParam("num") Integer num,@RequestParam("taskid") String taskid,@RequestParam("taskSpecialty") String taskSpecialty) { @@ -87,6 +94,7 @@ public class EducationPaperController /** * 学生端根据任务id返回 考试信息 */ + @Operation(summary = "学生端根据任务id返回 考试信息") @GetMapping("/stuInfoPaper") public CommonResult stuInfoPaper(@RequestParam("taskid") String taskid) { @@ -107,6 +115,7 @@ public class EducationPaperController /** * 修改试卷 */ + @Operation(summary = "修改试卷") @PutMapping public CommonResult edit(@RequestBody EducationPaper educationPaper) { @@ -116,6 +125,7 @@ public class EducationPaperController /** * 删除试卷 */ + @Operation(summary = "删除试卷") @DeleteMapping("/{paperIds}") public CommonResult remove(@PathVariable String[] paperIds) { @@ -125,6 +135,7 @@ public class EducationPaperController /** * 根据方案获取试卷下拉 */ + @Operation(summary = "根据方案获取试卷下拉") @GetMapping(value = "/getPaperByTaskId") public CommonResult getPaperByTaskId(@RequestParam(value = "taskId") String taskId) { @@ -137,6 +148,7 @@ public class EducationPaperController * @param educationPaper * @return */ + @Operation(summary = "抽卷方式调整") @PostMapping("/update") public CommonResult update(@RequestBody EducationPaper educationPaper) { @@ -194,6 +206,7 @@ public class EducationPaperController /** * 根据方案获取已经设置好的试卷 */ + @Operation(summary = "根据方案获取已经设置好的试卷") @PostMapping(value = "/getPaperByTaskIdByType") public CommonResult getPaperByTaskIdByType(@RequestBody PaperQueryRequest requestData) { @@ -205,7 +218,7 @@ public class EducationPaperController * @param statusDto * @return */ - + @Operation(summary = "更改试卷任务状态") @PutMapping("/updatePaperStatus") public CommonResult updateTaskStatus(@RequestBody StatusDto statusDto) { // 改为Integer类型 return CommonResult.success( @@ -219,6 +232,7 @@ public class EducationPaperController * @param paperPageVo * @return */ + @Operation(summary = "学生端 返回试卷任务列表") @GetMapping("/stulist") public CommonResult> stulist(PaperPageVo paperPageVo) { @@ -229,10 +243,11 @@ public class EducationPaperController /** - * 下载试卷 + * 下载笔试试卷 * @param paperIds * @return */ + @Operation(summary = "下载笔试试卷") @GetMapping("/addUpload/{paperIds}") public void downLoad(@PathVariable String[] paperIds, HttpServletResponse response) throws Exception { educationPaperService.downloadWord(paperIds,response); @@ -240,4 +255,13 @@ public class EducationPaperController + @PostMapping("/addPaperBypaper") + public CommonResult submitPaperList(@RequestBody PaperSubmitDTO dto) { + System.out.println(dto); + + educationPaperService.addPaperBypaper(dto); + // 处理逻辑 + return CommonResult.success("新增成功"); + } + } diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/paper/EducationPaperParamController.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/paper/EducationPaperParamController.java index 69e55e53..8d1f1f08 100644 --- a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/paper/EducationPaperParamController.java +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/paper/EducationPaperParamController.java @@ -1,6 +1,8 @@ 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 org.checkerframework.checker.units.qual.C; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; @@ -14,6 +16,7 @@ import static pc.exam.pp.module.infra.enums.ErrorCodeConstants.DEMO03_PAPER_SESS * @author pengchen * @date 2025-04-16 */ +@Tag(name = "管理后台 - 试卷通用参数") @RestController @RequestMapping("/exam/param") public class EducationPaperParamController @@ -28,6 +31,7 @@ public class EducationPaperParamController /** * 获取通用参数详细信息 */ + @Operation(summary = "获取通用参数详细信息") @GetMapping(value = "/getInfo") public CommonResult getInfo(@RequestParam("taskId") String taskId) { @@ -38,6 +42,7 @@ public class EducationPaperParamController /** * 新增通用参数 */ + @Operation(summary = "新增通用参数") @PostMapping public CommonResult add(@RequestBody EducationPaperParam educationPaperParam) { @@ -47,6 +52,7 @@ public class EducationPaperParamController /** * 修改通用参数 */ + @Operation(summary = "修改通用参数") @PutMapping public CommonResult edit(@RequestBody EducationPaperParam educationPaperParam) { @@ -56,6 +62,7 @@ public class EducationPaperParamController /** * 删除通用参数 */ + @Operation(summary = "删除通用参数") @DeleteMapping("/{paramIds}") public CommonResult remove(@PathVariable String[] paramIds) { @@ -67,6 +74,7 @@ public class EducationPaperParamController * @param taskId * @return */ + @Operation(summary = "步骤条 (考场)警告") @GetMapping( "/check-can-enter-step4/{taskId}") public CommonResult ckeckSession(@PathVariable("taskId") String taskId){ EducationPaperParam educationPaperParam = educationPaperParamService.selectEducationPaperParamByTaskId(taskId); @@ -84,6 +92,7 @@ public class EducationPaperParamController * @param taskId * @return */ + @Operation(summary = "步骤条 (考场)无警告") @GetMapping( "/check-can-enter-step4NoMsg/{taskId}") public CommonResult ckeckSessionNoMsg(@PathVariable("taskId") String taskId){ EducationPaperParam educationPaperParam = educationPaperParamService.selectEducationPaperParamByTaskId(taskId); diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/paper/EducationPaperPersonController.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/paper/EducationPaperPersonController.java index 8a02bbc9..d9d0acb1 100644 --- a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/paper/EducationPaperPersonController.java +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/paper/EducationPaperPersonController.java @@ -1,5 +1,7 @@ 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 org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import pc.exam.pp.framework.common.pojo.CommonResult; @@ -25,6 +27,7 @@ import java.util.List; * @author pengchen * @date 2025-04-18 */ +@Tag(name = "管理后台 - 试卷人员分配") @RestController @RequestMapping("/exam/person") public class EducationPaperPersonController @@ -38,6 +41,7 @@ public class EducationPaperPersonController /** * 查询试卷人员分配列表 */ + @Operation(summary = "查询试卷人员分配列表") @GetMapping("/list") public CommonResult list(EducationPaperPerson educationPaperPerson) { @@ -61,6 +65,7 @@ public class EducationPaperPersonController /** * 新增试卷人员分配 */ + @Operation(summary = "新增试卷人员分配") @PostMapping public CommonResult add(@RequestBody EducationPaperPerson educationPaperPerson) { @@ -70,6 +75,7 @@ public class EducationPaperPersonController /** * 修改试卷人员分配 */ + @Operation(summary = "修改试卷人员分配") @PutMapping public CommonResult edit(@RequestBody EducationPaperPerson educationPaperPerson) { @@ -79,6 +85,7 @@ public class EducationPaperPersonController /** * 删除试卷人员分配 */ + @Operation(summary = "删除试卷人员分配") @DeleteMapping("/{taskIds}") public CommonResult remove(@PathVariable String[] taskIds) { @@ -89,6 +96,7 @@ public class EducationPaperPersonController /** * 根据试卷任务获取人员分配列表 */ + @Operation(summary = "根据试卷任务获取人员分配列表") @GetMapping( "/getList") public CommonResult> getInfo(ExamPersonVo examPersonVo) { @@ -98,6 +106,7 @@ public class EducationPaperPersonController /** * 根据试卷场次获取人员分配列表 */ + @Operation(summary = "根据试卷场次获取人员分配列表") @GetMapping(value = "/getSessionStu") public CommonResult> getSessionStu(ExamPersonVo examPersonVo) { PageResult list = educationPaperPersonService.selectEducationPaperPersonBySessionId(examPersonVo); @@ -107,6 +116,7 @@ public class EducationPaperPersonController /** * 根据场次id,学生信息等多个查询条件 获取人员分配列表(获取没有分配场次的人员) */ + @Operation(summary = "根据场次id,学生信息等多个查询条件 获取人员分配列表(获取没有分配场次的人员)") @GetMapping(value = "/getSessionStuBySearch") public CommonResult> getSessionStuBySearch(SessionStuPageReqVO sessionStuPageReqVO) { PageResult list = educationPaperPersonService.selectEducationPaperPersonBySearch(sessionStuPageReqVO); @@ -121,6 +131,7 @@ public class EducationPaperPersonController * @param reqVO 包含学生id,场次id,试卷任务id * @return */ + @Operation(summary = "给任务场次分配学生") @RequestMapping("/setSessionStu") public CommonResult handleStudentSelection(@RequestBody StudentSessionReqVO reqVO) { if (reqVO.getStudentIds()!=null&&reqVO.getStudentIds().size()>0){ @@ -136,6 +147,7 @@ public class EducationPaperPersonController * @param reqVO * @return */ + @Operation(summary = "删除场次学生") @DeleteMapping("/removeSessionStu") public CommonResult removeSessionStu(@RequestBody StudentSessionReqVO reqVO) { return CommonResult.success(educationPaperPersonService.removeSessionStu(reqVO)); @@ -147,6 +159,7 @@ public class EducationPaperPersonController * @param deleteRequestVo * @return */ + @Operation(summary = "删除任务学生") @DeleteMapping("/removeTaskStu") public CommonResult removeTaskStu(@RequestBody DeleteRequestVo deleteRequestVo) { return CommonResult.success(educationPaperPersonService.removeTaskStu(deleteRequestVo)); diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/paper/EducationPaperQuController.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/paper/EducationPaperQuController.java index a604a3c1..6ff0269d 100644 --- a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/paper/EducationPaperQuController.java +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/paper/EducationPaperQuController.java @@ -1,5 +1,7 @@ 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 org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import pc.exam.pp.framework.common.pojo.CommonResult; @@ -15,6 +17,7 @@ import java.util.List; * @author pengchen * @date 2025-04-15 */ +@Tag(name = "管理后台 - 试卷试题") @RestController @RequestMapping("/exam/qu") public class EducationPaperQuController @@ -25,6 +28,7 @@ public class EducationPaperQuController /** * 查询试卷试题列表 */ + @Operation(summary = "查询试卷试题列表") @GetMapping("/list") public CommonResult list(EducationPaperQu educationPaperQu) { @@ -46,6 +50,7 @@ public class EducationPaperQuController /** * 获取试卷试题详细信息 */ + @Operation(summary = "获取试卷试题详细信息") @GetMapping(value = "/{paperId}") public CommonResult getInfo(@PathVariable("paperId") String paperId) { @@ -55,6 +60,7 @@ public class EducationPaperQuController /** * 新增试卷试题 */ + @Operation(summary = "新增试卷试题") @PostMapping public CommonResult add(@RequestBody EducationPaperQu educationPaperQu) { @@ -64,6 +70,7 @@ public class EducationPaperQuController /** * 修改试卷试题 */ + @Operation(summary = "修改试卷试题") @PutMapping public CommonResult edit(@RequestBody EducationPaperQu educationPaperQu) { @@ -73,6 +80,7 @@ public class EducationPaperQuController /** * 删除试卷试题 */ + @Operation(summary = "删除试卷试题") @DeleteMapping("/{paperIds}") public CommonResult remove(@PathVariable String[] paperIds) { @@ -83,6 +91,7 @@ public class EducationPaperQuController /** * 学生端根据id获取试卷 */ + @Operation(summary = "学生端根据id获取试卷") @GetMapping(value = "/getPaper") public CommonResult getPaper(@RequestParam(value = "paperId") String paperId) { @@ -91,6 +100,7 @@ public class EducationPaperQuController /** * 中心端 点击编辑 根据id获取试卷 */ + @Operation(summary = "中心端 点击编辑 根据id获取试卷") @GetMapping(value = "/getPaperCenter") public CommonResult getPaperCenter(@RequestParam(value = "paperId") String paperId) { @@ -104,6 +114,7 @@ public class EducationPaperQuController * @param changePaperQuVo * @return */ + @Operation(summary = "更换试卷试题") @PostMapping("/changePaperQu") public CommonResult changePaperQu(@RequestBody ChangePaperQuVo changePaperQuVo) { @@ -115,6 +126,7 @@ public class EducationPaperQuController * @param changePaperQuVo * @return */ + @Operation(summary = "随机更换试卷试题") @PostMapping("/changePaperQuRandom") public CommonResult changePaperQuRandom(@RequestBody ChangePaperQuVo changePaperQuVo) { diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/paper/EducationPaperSchemeController.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/paper/EducationPaperSchemeController.java index 9c893561..f6dfe20f 100644 --- a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/paper/EducationPaperSchemeController.java +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/paper/EducationPaperSchemeController.java @@ -1,5 +1,7 @@ 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 org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import pc.exam.pp.framework.common.pojo.CommonResult; @@ -23,6 +25,7 @@ import static pc.exam.pp.module.infra.enums.ErrorCodeConstants.DEMO03_PAPER_SCHE * @author pengchen * @date 2025-04-15 */ +@Tag(name = "管理后台 - 试卷方案") @RestController @RequestMapping("/exam/scheme") public class EducationPaperSchemeController @@ -38,6 +41,7 @@ public class EducationPaperSchemeController /** * 查询试卷方案列表 */ + @Operation(summary = "查询试卷方案列表") @GetMapping("/list") public CommonResult list(EducationPaperScheme educationPaperScheme) { @@ -59,6 +63,7 @@ public class EducationPaperSchemeController /** * 获取试卷方案详细信息 */ + @Operation(summary = "获取试卷方案详细信息") @GetMapping(value = "/{schemeId}") public CommonResult getInfo(@PathVariable("schemeId") String schemeId) { @@ -68,6 +73,7 @@ public class EducationPaperSchemeController /** * 新增试卷方案 */ + @Operation(summary = "新增试卷方案") @PostMapping public CommonResult add(@RequestBody EducationPaperScheme educationPaperScheme) { @@ -82,7 +88,9 @@ public class EducationPaperSchemeController return CommonResult.error(DEMO03_PAPER_TASK_ADD_EXISTS); } } + int counts= educationPaperSchemeService.selectEducationPaperSchemeCountsByTaskId(educationPaperScheme.getTaskId()); + educationPaperScheme.setSort(++counts); List educationPaperSchemes = educationPaperSchemeMapper.selectEducationPaperTaskByTaskId(educationPaperScheme.getTaskId()); //判断 方案下 是否有同题型 String spName = educationPaperScheme.getSpName(); @@ -99,6 +107,7 @@ public class EducationPaperSchemeController /** * 修改试卷方案 */ + @Operation(summary = "修改试卷方案") @PutMapping public CommonResult edit(@RequestBody EducationPaperScheme educationPaperScheme) { @@ -108,6 +117,7 @@ public class EducationPaperSchemeController /** * 删除试卷方案 */ + @Operation(summary = "删除试卷方案") @DeleteMapping("/{schemeIds}") public CommonResult remove(@PathVariable String schemeIds) { diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/paper/EducationPaperSessionController.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/paper/EducationPaperSessionController.java index a5ec95d0..10b077cc 100644 --- a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/paper/EducationPaperSessionController.java +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/paper/EducationPaperSessionController.java @@ -1,5 +1,7 @@ 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.servlet.http.HttpServletResponse; import lombok.extern.java.Log; import org.springframework.beans.factory.annotation.Autowired; @@ -24,6 +26,7 @@ import static pc.exam.pp.framework.common.exception.enums.GlobalErrorCodeConstan * @author pengchen * @date 2025-04-17 */ +@Tag(name = "管理后台 - 试卷场次") @RestController @RequestMapping("/exam/session") public class EducationPaperSessionController @@ -34,6 +37,7 @@ public class EducationPaperSessionController /** * 查询试卷场次列表 */ + @Operation(summary = "查询试卷场次列表") @GetMapping("/list") public CommonResult> list(EducationPaperSessionVo educationPaperSessionVo) { @@ -55,6 +59,7 @@ public class EducationPaperSessionController /** * 获取试卷场次详细信息 */ + @Operation(summary = "获取试卷场次详细信息") @GetMapping(value = "/{sessionId}") public CommonResult getInfo(@PathVariable("sessionId") String sessionId) { @@ -64,6 +69,7 @@ public class EducationPaperSessionController /** * 新增试卷场次 */ + @Operation(summary = "新增试卷场次") @PostMapping public CommonResult add(@RequestBody EducationPaperSession educationPaperSession) { @@ -85,6 +91,7 @@ public class EducationPaperSessionController /** * 修改试卷场次 */ + @Operation(summary = "修改试卷场次") @PutMapping public CommonResult edit(@RequestBody EducationPaperSession educationPaperSession) { @@ -104,6 +111,7 @@ public class EducationPaperSessionController /** * 删除试卷场次 */ + @Operation(summary = "删除试卷场次") @DeleteMapping("/{sessionIds}") public CommonResult remove(@PathVariable String[] sessionIds) { @@ -113,6 +121,7 @@ public class EducationPaperSessionController /** * 修改试卷场次详细信息 */ + @Operation(summary = "修改试卷场次详细信息") @PostMapping(value = "/set") public CommonResult set(@RequestBody SessionParamDto param) { List rows = param.getRows(); @@ -138,6 +147,7 @@ public class EducationPaperSessionController * @param statusDto * @return */ + @Operation(summary = "更改状态") @PutMapping("/updateSessionStatus") public CommonResult updateSessionStatus(@RequestBody StatusDto statusDto) { return CommonResult.success( @@ -148,6 +158,7 @@ public class EducationPaperSessionController /** * 获取试卷场次答题时间 */ + @Operation(summary = "获取试卷场次答题时间") @GetMapping(value = "/getTime/{taskId}") public CommonResult getAnswerTime(@PathVariable("taskId") String taskId) { diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/paper/EducationPaperTaskController.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/paper/EducationPaperTaskController.java index 64a4ca5b..a7d7dd08 100644 --- a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/paper/EducationPaperTaskController.java +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/paper/EducationPaperTaskController.java @@ -1,6 +1,8 @@ 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.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; @@ -9,6 +11,7 @@ import pc.exam.pp.framework.common.pojo.PageResult; import pc.exam.pp.framework.common.util.object.BeanUtils; import pc.exam.pp.framework.security.core.util.SecurityFrameworkUtils; import pc.exam.pp.framework.tenant.core.context.TenantContextHolder; +import pc.exam.pp.module.exam.controller.admin.paper.dto.PaperQueUpdateDTO; import pc.exam.pp.module.exam.controller.admin.paper.dto.SchemeParam; import pc.exam.pp.module.exam.controller.admin.paper.dto.StatusDto; import pc.exam.pp.module.exam.controller.admin.paper.dto.TempDto; @@ -25,6 +28,7 @@ import java.util.List; * @author pengchen * @date 2025-04-14 */ +@Tag(name = "管理后台 - 试卷任务") @RestController @RequestMapping("/exam/task") public class EducationPaperTaskController @@ -35,15 +39,25 @@ public class EducationPaperTaskController /** * 查询试卷任务列表(服务器端) */ + @Operation(summary = "查询试卷任务列表(服务器端)") @GetMapping("/list") public CommonResult> list(PaperTaskPageVo educationPaperTask) { PageResult pageResult = educationPaperTaskService.selectEducationPaperTaskList(educationPaperTask); return CommonResult.success(BeanUtils.toBean(pageResult, EducationPaperTask.class)); } + @Operation(summary = "查询试卷任务列表(带试卷)") + @GetMapping("/listPaper") + public CommonResult> taskAndPaperlist(PaperTaskPageVo educationPaperTask) + { + PageResult pageResult = educationPaperTaskService.selectEducationPaperAndTaskList(educationPaperTask); + return CommonResult.success(BeanUtils.toBean(pageResult, EducationPaperTask.class)); + } + /** * 查询试卷任务列表(学生端) */ + @Operation(summary = "查询试卷任务列表(学生端)") @GetMapping("/stulist") public CommonResult> stulist(PaperTaskPageVo educationPaperTask) { @@ -66,6 +80,7 @@ public class EducationPaperTaskController /** * 获取试卷任务详细信息 */ + @Operation(summary = "获取试卷任务详细信息") @GetMapping(value = "/{taskId}") public CommonResult getInfo(@PathVariable("taskId") String taskId) { @@ -75,6 +90,7 @@ public class EducationPaperTaskController /** * 新增试卷任务 */ + @Operation(summary = "新增试卷任务") @PostMapping public CommonResult add(@RequestBody EducationPaperTask educationPaperTask) { @@ -85,6 +101,7 @@ public class EducationPaperTaskController /** * 修改试卷任务 */ + @Operation(summary = "修改试卷任务") @PutMapping public CommonResult edit(@RequestBody EducationPaperTask educationPaperTask) { @@ -94,6 +111,7 @@ public class EducationPaperTaskController /** * 删除试卷任务 */ + @Operation(summary = "删除试卷任务") @DeleteMapping("/del/{taskId}") public CommonResult remove(@PathVariable String taskId ) { @@ -102,6 +120,7 @@ public class EducationPaperTaskController /** * 批量删除试卷任务 */ + @Operation(summary = "批量删除试卷任务") @DeleteMapping("/{taskIds}") public CommonResult removeIds(@PathVariable String[] taskIds ) { @@ -110,6 +129,7 @@ public class EducationPaperTaskController /** * 获取专业列表 */ + @Operation(summary = "获取专业列表") @GetMapping("/getSpeciality") public CommonResult getSpeciality() { @@ -119,6 +139,7 @@ public class EducationPaperTaskController /** * 获取题型列表 */ + @Operation(summary = "获取题型列表") @GetMapping("/getCourse") public CommonResult getCourse() { @@ -128,6 +149,7 @@ public class EducationPaperTaskController /** * 获取关键字 */ + @Operation(summary = "获取关键字") @GetMapping("/getKeywords") public CommonResult getKeywords() { @@ -136,6 +158,7 @@ public class EducationPaperTaskController /** * 获取知识点 */ + @Operation(summary = "获取知识点") @GetMapping("/getPoints") public CommonResult getPoints (@RequestParam(value = "name") String name) { @@ -146,6 +169,7 @@ public class EducationPaperTaskController /* 按照方案返回试题数量 */ + @Operation(summary = "按照方案返回试题数量") @PostMapping("/getQuestionCount") @PermitAll public CommonResult fetchQuestionCount(@RequestBody SchemeParam param) { @@ -160,7 +184,8 @@ public class EducationPaperTaskController * @param tempDto * @return */ - @PostMapping("/submitSelection") + @Operation(summary = "模板库 复制") + @PostMapping("/submitSelection") public CommonResult submitSelection(@RequestBody TempDto tempDto) { System.out.println("接收到的任务ID: " + tempDto.getTaskId()); System.out.println("接收到的选项: " + tempDto.getOptions()); @@ -173,7 +198,6 @@ public class EducationPaperTaskController if (options!=null&&options.size()>0){ educationPaperTaskService.submitSelection(tempDto); - }else { return CommonResult.error(INTERNAL_SERVER_ERROR.getCode(),"请选择复制的参数!"); } @@ -186,6 +210,7 @@ public class EducationPaperTaskController * @param statusDto * @return */ + @Operation(summary = "更改 任务状态") @PutMapping("/updateTaskStatus") public CommonResult updateTaskStatus(@RequestBody StatusDto statusDto) { return CommonResult.success( @@ -195,14 +220,32 @@ public class EducationPaperTaskController /** - * 学生端 根据taskid返回 试卷信息 + * 学生端 根据任务id返回 试卷信息 * @param taskId * @return */ + @Operation(summary = "学生端 根据任务id返回 试卷信息") @GetMapping(value = "/getPaperBytaskId") public CommonResult getPaperBytaskId(@RequestParam(value = "taskId") String taskId) { return CommonResult.success(educationPaperTaskService.selectPaperQuByPaperId(taskId)); } + + @PostMapping("/checkType") + public CommonResult checkType(@RequestBody PaperQueUpdateDTO dto) { + String taskId = dto.getTaskId(); + List queList = dto.getQue(); + try { + educationPaperTaskService.checkType(dto); + return CommonResult.success("题型更新成功"); + } catch (Exception e) { + return CommonResult.error(9999999,e.getMessage()); + + } + + + } + + } diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/paper/dto/PaperQueUpdateDTO.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/paper/dto/PaperQueUpdateDTO.java new file mode 100644 index 00000000..2a5269ae --- /dev/null +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/paper/dto/PaperQueUpdateDTO.java @@ -0,0 +1,16 @@ +package pc.exam.pp.module.exam.controller.admin.paper.dto; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +@Data +@AllArgsConstructor +@NoArgsConstructor +public class PaperQueUpdateDTO { + private String taskId; + private List que; +} + diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/paper/dto/PaperSubmitDTO.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/paper/dto/PaperSubmitDTO.java new file mode 100644 index 00000000..431c4b1a --- /dev/null +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/paper/dto/PaperSubmitDTO.java @@ -0,0 +1,13 @@ +package pc.exam.pp.module.exam.controller.admin.paper.dto; + +import lombok.Data; +import pc.exam.pp.module.exam.dal.dataobject.EducationPaper; + +import java.util.List; + +@Data +public class PaperSubmitDTO { + private String num; + private String taskId; + private List paperList; +} diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/paper/dto/PaperSubmitListDTO.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/paper/dto/PaperSubmitListDTO.java new file mode 100644 index 00000000..29019dd1 --- /dev/null +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/paper/dto/PaperSubmitListDTO.java @@ -0,0 +1,18 @@ +package pc.exam.pp.module.exam.controller.admin.paper.dto; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@AllArgsConstructor +@NoArgsConstructor +public class PaperSubmitListDTO { + private String id; + private String label; + private String num; + private String que; + private String taskName; + private String taskType; + +} diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/paper/vo/SchemeInfo.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/paper/vo/SchemeInfo.java new file mode 100644 index 00000000..342edcc3 --- /dev/null +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/paper/vo/SchemeInfo.java @@ -0,0 +1,16 @@ +package pc.exam.pp.module.exam.controller.admin.paper.vo; + + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Map; +import java.util.Set; +@Data +@AllArgsConstructor +@NoArgsConstructor +public class SchemeInfo { + private Integer count; + private Map> schemeToQuestion; +} diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/dataobject/EducationPaperParam.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/dataobject/EducationPaperParam.java index 628e5ba3..f08aa350 100644 --- a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/dataobject/EducationPaperParam.java +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/dataobject/EducationPaperParam.java @@ -65,9 +65,9 @@ public class EducationPaperParam // @Excel(name = "考试的模式下定时上传考试目录,每{x}分钟传一次") private String uploadTime; - /** 完成考试后是否删除考试目录(0是1否) */ + /** 是否允许复制题干(0是1否) */ // @Excel(name = "完成考试后是否删除考试目录", readConverterExp = "0=是1否") - private String isDel; + private String isCopy; //是否显示重答按钮 private String isRepeat; @@ -93,5 +93,9 @@ public class EducationPaperParam private String isNet; //禁止截屏 private String isScreen; + //是否显示成绩 + private String isScore; + //是否显示成绩明细 + private String isScoreDetail; } diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/dataobject/EducationPaperTask.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/dataobject/EducationPaperTask.java index 3668b19f..168829df 100644 --- a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/dataobject/EducationPaperTask.java +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/dataobject/EducationPaperTask.java @@ -11,6 +11,8 @@ import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringStyle; import pc.exam.pp.framework.tenant.core.db.TenantBaseDO; +import java.util.List; + /** * 试卷任务对象 education_paper_task * @@ -61,4 +63,10 @@ public class EducationPaperTask extends TenantBaseDO @TableField(exist = false) private String score; + + @TableField(exist = false) + private List educationPaperSchemeList; + + @TableField(exist = false) + private List educationPaperList; } diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/dataobject/ExamQuestion.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/dataobject/ExamQuestion.java index 8ce60e89..1b701feb 100644 --- a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/dataobject/ExamQuestion.java +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/dataobject/ExamQuestion.java @@ -43,13 +43,15 @@ public class ExamQuestion extends TenantBaseDO { // @Excel(name = "章节名称") private String chapteridDictText; + @TableField(exist = false) + private String chapteridDictTextVo; /** 题型名称 */ // @Excel(name = "题型名称") private String subjectName; /** 题型难度(0:简单,1:一般,2:困难) */ // @Excel(name = "题型难度(0:简单,1:一般,2:困难)") - private String quLevel; + private Integer quLevel; /** 试题内容(带样式:

下列表格123

\n\n\n\n\) */ // @Excel(name = "试题内容") @@ -67,6 +69,8 @@ public class ExamQuestion extends TenantBaseDO { // @Excel(name = "知识点") private String pointNames; + @TableField(exist = false) + private String pointNamesVo; /** 关键字 */ // @Excel(name = "关键字") private String keywords; diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/mysql/knowledge/ExamKnowledgePointsMapper.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/mysql/knowledge/ExamKnowledgePointsMapper.java index e3f01414..1898e034 100644 --- a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/mysql/knowledge/ExamKnowledgePointsMapper.java +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/mysql/knowledge/ExamKnowledgePointsMapper.java @@ -52,4 +52,9 @@ public interface ExamKnowledgePointsMapper extends BaseMapperX selectKnowledgePointsListPage(@Param("knowledgePoints")ExamKnowledgePoints knowledgePoints); + String selectKnowledgeNameBySpId(String spId); + + List selectKnowledgePoints(); + + } diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/mysql/monitor/MonitorMapper.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/mysql/monitor/MonitorMapper.java index 14134df0..11c58e2b 100644 --- a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/mysql/monitor/MonitorMapper.java +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/mysql/monitor/MonitorMapper.java @@ -57,4 +57,5 @@ return selectPage(reqVO, new LambdaQueryWrapperX() List selectByStuIdAndTaskId(Long stuId); + List selectStuIdByTaskId(String taskId); } \ No newline at end of file diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/mysql/paper/EducationPaperQuMapper.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/mysql/paper/EducationPaperQuMapper.java index 6bc7ae6f..2102be62 100644 --- a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/mysql/paper/EducationPaperQuMapper.java +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/mysql/paper/EducationPaperQuMapper.java @@ -99,5 +99,14 @@ public interface EducationPaperQuMapper String selectRamdomQuId(ChangePaperQuVo changePaperQuVo); + List selectUsedQuestionIds(String[] ids); + + /** + * 根据试卷id和题型名称,找出该试卷的符合试题 + * @param paperId + * @param spName + * @return + */ + List selectByPaperIdAndType(String paperId, String spName); } diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/mysql/paper/EducationPaperSchemeMapper.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/mysql/paper/EducationPaperSchemeMapper.java index ab5c623b..dcc22723 100644 --- a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/mysql/paper/EducationPaperSchemeMapper.java +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/mysql/paper/EducationPaperSchemeMapper.java @@ -77,4 +77,5 @@ public interface EducationPaperSchemeMapper */ void insertEducationPaperSchemeList(List educationPaperSchemeList); + int selectEducationPaperSchemeCountsByTaskId(String taskId); } diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/mysql/question/ExamQuestionAnswerMapper.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/mysql/question/ExamQuestionAnswerMapper.java index cf4accab..2f5c4088 100644 --- a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/mysql/question/ExamQuestionAnswerMapper.java +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/mysql/question/ExamQuestionAnswerMapper.java @@ -77,4 +77,9 @@ public interface ExamQuestionAnswerMapper extends BaseMapperX studentIds = reqVO.getStudentIds(); - for (String studentId : studentIds) { - String key = "userCache:" + reqVO.getTaskId()+":"+studentId; - redisTemplate.delete(key); + if (studentIds == null || studentIds.isEmpty()) { + return 0; // 无操作 } + + //筛选出当前任务中状态为"代考"的学生ID(只允许删除这些学生) + List proxyStuIds = monitorMapper.selectStuIdByTaskId(reqVO.getTaskId()); + List intersection = studentIds.stream() + .filter(proxyStuIds::contains) + .collect(Collectors.toList()); + + if (intersection.isEmpty()) { + return 0; // 无符合条件的学生 + } + //删除监控管理学生 DeleteRequestVo deleteRequestVo=new DeleteRequestVo(); - deleteRequestVo.setStudentIds(reqVO.getStudentIds()); + deleteRequestVo.setStudentIds(intersection); deleteRequestVo.setTaskId(reqVO.getTaskId()); monitorMapper.removeMonitorByStuIdAndTaskId(deleteRequestVo); + + // 再清理Redis缓存(仅删除代考学生的缓存) + for (String studentId : intersection) { + String key = "userCache:" + reqVO.getTaskId() + ":" + studentId; + redisTemplate.delete(key); + } + //删除考场学生 + reqVO.setStudentIds(intersection); return educationPaperPersonMapper.removeSessionStu(reqVO); } @Override + @Transactional(rollbackFor = Exception.class) // 所有异常都回滚 public int removeTaskStu(DeleteRequestVo deleteRequestVo) { + //获取前端传入的学生ID列表 List studentIds = deleteRequestVo.getStudentIds(); - for (String studentId : studentIds) { + if (studentIds == null || studentIds.isEmpty()) { + return 0; // 无操作 + } + //筛选出当前任务中状态为"代考"的学生ID(只允许删除这些学生) + List proxyStuIds = monitorMapper.selectStuIdByTaskId(deleteRequestVo.getTaskId()); + + List intersection = studentIds.stream() + .filter(proxyStuIds::contains) + .collect(Collectors.toList()); + + if (intersection.isEmpty()) { + return 0; // 无符合条件的学生 + } + + + deleteRequestVo.setStudentIds(intersection); + monitorMapper.removeMonitorByStuIdAndTaskId(deleteRequestVo); + for (String studentId : intersection) { String key = "userCache:" + deleteRequestVo.getTaskId()+":"+studentId; redisTemplate.delete(key); } - monitorMapper.removeMonitorByStuIdAndTaskId(deleteRequestVo); - return educationPaperPersonMapper.removeTaskStu(deleteRequestVo); } diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/paper/EducationPaperQuServiceImpl.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/paper/EducationPaperQuServiceImpl.java index b33e53d8..6eb0e010 100644 --- a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/paper/EducationPaperQuServiceImpl.java +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/paper/EducationPaperQuServiceImpl.java @@ -9,6 +9,8 @@ import pc.exam.pp.module.exam.controller.admin.paper.vo.ChangePaperQuVo; import pc.exam.pp.module.exam.controller.admin.paper.vo.ExamPaperVo; import pc.exam.pp.module.exam.controller.admin.paper.vo.StuInfoPaper; import pc.exam.pp.module.exam.dal.dataobject.*; +import pc.exam.pp.module.exam.dal.dataobject.knowledge.ExamKnowledgePoints; +import pc.exam.pp.module.exam.dal.mysql.knowledge.ExamKnowledgePointsMapper; import pc.exam.pp.module.exam.dal.mysql.paper.*; import pc.exam.pp.module.exam.dal.mysql.question.ExamQuestionMapper; import pc.exam.pp.module.exam.dal.mysql.question.SysFileMapper; @@ -50,6 +52,8 @@ public class EducationPaperQuServiceImpl implements IEducationPaperQuService private EducationPaperTaskMapper educationPaperTaskMapper; @Autowired private IExamQuestionService examQuestionService; + @Autowired + private ExamKnowledgePointsMapper knowledgePointsMapper; /** * 查询试卷试题 * @@ -251,7 +255,33 @@ public class EducationPaperQuServiceImpl implements IEducationPaperQuService String taskid=educationPaperMapper.selectTaskIdByPaperId(paperId); List educationPaperSchemeList= educationPaperSchemeMapper.selectEducationPaperTaskByTaskId(taskid); + List examKnowledgePoints = knowledgePointsMapper.selectKnowledgePoints(); + // 构造 ID → 名称映射 + Map idNameMap = examKnowledgePoints.stream() + .collect(Collectors.toMap(ExamKnowledgePoints::getSpId, ExamKnowledgePoints::getSpName)); + //赋值 章节知识点 + for (ExamQuestion examQuestion : examQuestionList) { + String pointIdStr = examQuestion.getPointNames(); + String chapterIdStr = examQuestion.getChapteridDictText(); + try { + if (pointIdStr != null) { + Long pointId = Long.valueOf(pointIdStr); + if (idNameMap.containsKey(pointId)) { + examQuestion.setPointNamesVo(idNameMap.get(pointId)); + } + } + if (chapterIdStr != null) { + Long chapterId = Long.valueOf(chapterIdStr); + if (idNameMap.containsKey(chapterId)) { + examQuestion.setChapteridDictTextVo(idNameMap.get(chapterId)); + } + } + }catch (NumberFormatException e) { + // 日志记录或跳过处理 + System.err.println("ID格式错误:" + e.getMessage()); + } + } ExamPaperVo examPaperVo=new ExamPaperVo(); examPaperVo.setPaperId(paperId); examPaperVo.setExamQuestionList(examQuestionList); diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/paper/EducationPaperSchemeServiceImpl.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/paper/EducationPaperSchemeServiceImpl.java index da177f78..54779f9f 100644 --- a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/paper/EducationPaperSchemeServiceImpl.java +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/paper/EducationPaperSchemeServiceImpl.java @@ -126,5 +126,10 @@ public class EducationPaperSchemeServiceImpl implements IEducationPaperSchemeSer { return educationPaperSchemeMapper.deleteEducationPaperSchemeBySchemeId(schemeId); } + + @Override + public int selectEducationPaperSchemeCountsByTaskId(String taskId) { + return educationPaperSchemeMapper.selectEducationPaperSchemeCountsByTaskId(taskId); + } } diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/paper/EducationPaperServiceImpl.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/paper/EducationPaperServiceImpl.java index 7d688845..d8d43570 100644 --- a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/paper/EducationPaperServiceImpl.java +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/paper/EducationPaperServiceImpl.java @@ -18,16 +18,15 @@ import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTTcPr; import org.openxmlformats.schemas.wordprocessingml.x2006.main.STTblWidth; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; import pc.exam.pp.framework.common.pojo.PageResult; import pc.exam.pp.framework.security.core.util.SecurityFrameworkUtils; import pc.exam.pp.framework.tenant.core.aop.TenantIgnore; import pc.exam.pp.framework.tenant.core.context.TenantContextHolder; -import pc.exam.pp.module.exam.controller.admin.paper.dto.EducationPaperStuDto; -import pc.exam.pp.module.exam.controller.admin.paper.dto.PaperIdAndNum; -import pc.exam.pp.module.exam.controller.admin.paper.dto.PaperQueWordDto; -import pc.exam.pp.module.exam.controller.admin.paper.dto.PaperWordDto; +import pc.exam.pp.module.exam.controller.admin.paper.dto.*; import pc.exam.pp.module.exam.controller.admin.paper.vo.ExamPaperVo; import pc.exam.pp.module.exam.controller.admin.paper.vo.PaperPageVo; +import pc.exam.pp.module.exam.controller.admin.paper.vo.SchemeInfo; import pc.exam.pp.module.exam.controller.admin.paper.vo.StuInfoPaper; import pc.exam.pp.module.exam.dal.dataobject.*; import pc.exam.pp.module.exam.dal.mysql.paper.*; @@ -133,6 +132,7 @@ public class EducationPaperServiceImpl implements IEducationPaperService * @return 结果 */ @Override + @Transactional(rollbackFor = Exception.class) // 所有异常都回滚 public int deleteEducationPaperByPaperIds(String[] paperIds) { @@ -793,5 +793,159 @@ public class EducationPaperServiceImpl implements IEducationPaperService } } + + @Override + public void addPaperBypaper(PaperSubmitDTO dto) { + String num = dto.getNum(); + int numInt = Integer.parseInt(num); + List paperList = dto.getPaperList(); + String taskId = dto.getTaskId(); + //此试卷任务的 方案规则 + List educationPaperSchemes = educationPaperSchemeMapper.selectEducationPaperTaskByTaskId(taskId); + //构建 方案和 试题id的键值对,String,List + List schemeInfoList=new ArrayList<>(); + int totalScore = 0; + for (EducationPaperScheme educationPaperScheme : educationPaperSchemes) { + + try { + totalScore += Integer.parseInt(educationPaperScheme.getSubtotalScore()); + } catch (NumberFormatException e) { + // 非数字按 0 处理 + totalScore += 0; + // 可选:记录日志(避免静默忽略) + throw new RuntimeException("非数字 subtotal_score: {}"+ educationPaperScheme.getSubtotalScore()); + } + + //设置 试题个数 + SchemeInfo schemeInfo=new SchemeInfo(); + schemeInfo.setCount(educationPaperScheme.getQuNumbers()); + //设置 试题题型和id集合 + String spName = educationPaperScheme.getSpName(); + Map> schemeToQuestionIds = new HashMap<>(); + schemeToQuestionIds.put(spName,new HashSet<>()); + schemeInfo.setSchemeToQuestion(schemeToQuestionIds); + schemeInfoList.add(schemeInfo); + } + + for (int i = 0; i > schemeToQuestionIds = schemeInfo.getSchemeToQuestion(); + for (String spName : schemeToQuestionIds.keySet()) { + // 根据试卷id和题型名称,找出该试卷的符合试题 + List quIds = educationPaperQuMapper.selectByPaperIdAndType(paperId, spName); + Set questionIds = schemeToQuestionIds.get(spName); + if (quIds != null && !quIds.isEmpty()) { + questionIds.addAll(quIds); + } + } + + } + + } + else { + // 拆分字符串,得到字符串数组 + String[] queArray = que.split(","); + // 转成 List + List queList = Arrays.asList(queArray); + for (String spName : queList) { + // 根据试卷id和题型名称,找出该试卷的符合试题 + List quIds = educationPaperQuMapper.selectByPaperIdAndType(paperId, spName); + for (SchemeInfo schemeInfo : schemeInfoList) { + // 获取当前方案的题型映射 + Map> schemeToQuestionIds = schemeInfo.getSchemeToQuestion(); + + // 取出对应 spName 的 Set + Set questionIds = schemeToQuestionIds.get(spName); + if (questionIds != null && quIds != null && !quIds.isEmpty()) { + questionIds.addAll(quIds); + } + } + } + } + + } + System.out.println(schemeInfoList); + List examQuestionIds = new ArrayList<>(); + for (SchemeInfo schemeInfo : schemeInfoList) { + Integer count = schemeInfo.getCount(); // 每个方案要取的题数 + Map> schemeToQuestion = schemeInfo.getSchemeToQuestion(); + + Random random = new Random(); + + for (Map.Entry> entry : schemeToQuestion.entrySet()) { + Set questionSet = entry.getValue(); + + if (questionSet == null || questionSet.isEmpty()) { + continue; + } + + List questionList = new ArrayList<>(questionSet); + + // 随机选 count 个题目,count 不能超过 questionList 大小 + int takeCount = Math.min(count, questionList.size()); + + // Fisher-Yates 洗牌 + 取前 takeCount 个 + for (int k = questionList.size() - 1; k > 0;k--) { + int j = random.nextInt(k + 1); + String temp = questionList.get(k); + questionList.set(k, questionList.get(j)); + questionList.set(j, temp); + } + + List randomSelected = questionList.subList(0, takeCount); + + examQuestionIds.addAll(randomSelected); + } + + // 这里 selectedQuestions 就是从该方案的所有题型集合里随机抽出的题目集合 + // 你可以根据需求进一步处理它,比如返回、保存等 + } + int number=educationPaperMapper.selectCountPaperList(); + + + + // 格式化为8位,不足前面补0 + String formattedNumber = String.format("%08d", ++number); + + + System.out.println(examQuestionIds); + //构建试卷 + EducationPaper educationPaper =new EducationPaper(); + String uuid = IdUtils.simpleUUID(); + educationPaper.setPaperId(uuid); + educationPaper.setPaperScore(String.valueOf(totalScore)); + educationPaper.setTaskId(taskId); + educationPaper.setNum(formattedNumber); + educationPaper.setTenantId(TenantContextHolder.getRequiredTenantId()); + educationPaperMapper.insertEducationPaper(educationPaper); + + + //构建试卷试题对象 + List educationPaperQus=new ArrayList<>(); + if (examQuestionIds!=null&& examQuestionIds.size()>0){ + int sort = 1; // 从1开始 + for (String examQuestionId : examQuestionIds) { + EducationPaperQu educationPaperQu=new EducationPaperQu(); + educationPaperQu.setPaperId(uuid); + educationPaperQu.setQuId(examQuestionId); + educationPaperQu.setSort(sort++); + educationPaperQus.add(educationPaperQu); + } + educationPaperQuMapper.insertEducationPaperQuList(educationPaperQus); + } + + } + } + } diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/paper/EducationPaperTaskServiceImpl.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/paper/EducationPaperTaskServiceImpl.java index 58ad0efe..84b3ed14 100644 --- a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/paper/EducationPaperTaskServiceImpl.java +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/paper/EducationPaperTaskServiceImpl.java @@ -10,6 +10,8 @@ import pc.exam.pp.framework.common.pojo.PageResult; import pc.exam.pp.framework.security.core.util.SecurityFrameworkUtils; import pc.exam.pp.framework.tenant.core.aop.TenantIgnore; import pc.exam.pp.framework.tenant.core.context.TenantContextHolder; +import pc.exam.pp.module.exam.controller.admin.exception.QueTypeException; +import pc.exam.pp.module.exam.controller.admin.paper.dto.PaperQueUpdateDTO; import pc.exam.pp.module.exam.controller.admin.paper.dto.SchemeParam; import pc.exam.pp.module.exam.controller.admin.paper.dto.TempDto; import pc.exam.pp.module.exam.controller.admin.paper.vo.ExamPaperVo; @@ -139,7 +141,7 @@ public class EducationPaperTaskServiceImpl implements IEducationPaperTaskService educationPaperParam.setIsTime("0"); educationPaperParam.setDirectory("KSWJ"); educationPaperParam.setUploadTime("5"); - educationPaperParam.setIsDel("0"); + educationPaperParam.setIsCopy("1"); educationPaperParam.setIsSession("1"); educationPaperParam.setIsFile("1"); educationPaperParam.setIsNet("1"); @@ -151,10 +153,14 @@ public class EducationPaperTaskServiceImpl implements IEducationPaperTaskService educationPaperParam.setIsAnswer("1"); educationPaperParam.setIsLook("1"); educationPaperParam.setIsConnect("30"); + educationPaperParam.setIsScore("1"); + educationPaperParam.setIsScoreDetail("1"); }else { educationPaperParam.setIsRepeat("0"); educationPaperParam.setIsAnswer("0"); educationPaperParam.setIsLook("0"); + educationPaperParam.setIsScore("0"); + educationPaperParam.setIsScoreDetail("0"); } if ("0".equals(educationPaperTask.getTaskType())||"1".equals(educationPaperTask.getTaskType())||"3".equals(educationPaperTask.getTaskType())){ educationPaperTask.setIsOne("0"); @@ -556,4 +562,48 @@ public class EducationPaperTaskServiceImpl implements IEducationPaperTaskService return null; } } + + @Override + public PageResult selectEducationPaperAndTaskList(PaperTaskPageVo educationPaperTask) { + PageResult educationPaperTasks = educationPaperTaskMapper.selectEducationPaperTaskList(educationPaperTask); + List list = educationPaperTasks.getList(); + for (EducationPaperTask paperTask : list) { + String taskId = paperTask.getTaskId(); + List educationPapers = educationPaperMapper.selectPaperListByTaskId(taskId); + List educationPaperSchemeList=educationPaperSchemeMapper.selectEducationPaperTaskByTaskId(taskId); + paperTask.setEducationPaperList(educationPapers); + paperTask.setEducationPaperSchemeList(educationPaperSchemeList); + } + return educationPaperTasks; + } + + @Override + public void checkType(PaperQueUpdateDTO dto) { + if (dto.getQue() == null || dto.getQue().isEmpty()) { + throw new QueTypeException("题型参数不能为空"); + } + + List educationPaperSchemeList=educationPaperSchemeMapper.selectEducationPaperTaskByTaskId(dto.getTaskId()); + if (educationPaperSchemeList == null) { + educationPaperSchemeList = new ArrayList<>(); + } + + // 查询数据库中已有的 spName + List existingSpNames = educationPaperSchemeList.stream() + .map(EducationPaperScheme::getSpName) + .collect(Collectors.toList()); + + // 获取前端传来的 que + List submittedQue = dto.getQue(); + // 找出 submittedQue 中比数据库多出来的(即数据库中没有的) + List extraQue = submittedQue.stream() + .filter(q -> !existingSpNames.contains(q)) + .collect(Collectors.toList()); + + if (extraQue.size()>0){ + throw new QueTypeException("当前任务方案中不存在以下题型:" + String.join(",", extraQue)); + + } + + } } diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/paper/IEducationPaperSchemeService.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/paper/IEducationPaperSchemeService.java index 979829ac..0b3aaed7 100644 --- a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/paper/IEducationPaperSchemeService.java +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/paper/IEducationPaperSchemeService.java @@ -60,5 +60,8 @@ public interface IEducationPaperSchemeService * @return 结果 */ public int deleteEducationPaperSchemeBySchemeId(String schemeId); + + int selectEducationPaperSchemeCountsByTaskId(String taskId); + } diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/paper/IEducationPaperService.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/paper/IEducationPaperService.java index 4a41de1a..16868ba3 100644 --- a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/paper/IEducationPaperService.java +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/paper/IEducationPaperService.java @@ -5,6 +5,7 @@ import jakarta.servlet.http.HttpServletResponse; import pc.exam.pp.framework.common.pojo.PageResult; import pc.exam.pp.module.exam.controller.admin.paper.dto.EducationPaperStuDto; import pc.exam.pp.module.exam.controller.admin.paper.dto.PaperIdAndNum; +import pc.exam.pp.module.exam.controller.admin.paper.dto.PaperSubmitDTO; import pc.exam.pp.module.exam.controller.admin.paper.vo.ExamPaperVo; import pc.exam.pp.module.exam.controller.admin.paper.vo.PaperPageVo; import pc.exam.pp.module.exam.dal.dataobject.PaperListResponseVo; @@ -127,5 +128,7 @@ public interface IEducationPaperService */ List selectPaperIdAndNumByTaskId(String taskId); + void addPaperBypaper(PaperSubmitDTO dto); + } diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/paper/IEducationPaperTaskService.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/paper/IEducationPaperTaskService.java index 06b6972b..798ad29f 100644 --- a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/paper/IEducationPaperTaskService.java +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/paper/IEducationPaperTaskService.java @@ -2,6 +2,7 @@ package pc.exam.pp.module.exam.service.paper; import pc.exam.pp.framework.common.pojo.PageResult; +import pc.exam.pp.module.exam.controller.admin.paper.dto.PaperQueUpdateDTO; import pc.exam.pp.module.exam.controller.admin.paper.dto.SchemeParam; import pc.exam.pp.module.exam.controller.admin.paper.dto.TempDto; import pc.exam.pp.module.exam.controller.admin.paper.vo.ExamPaperVo; @@ -114,5 +115,9 @@ public interface IEducationPaperTaskService */ PageResult selectEducationPaperTaskListByStu(PaperTaskPageVo educationPaperTask); + PageResult selectEducationPaperAndTaskList(PaperTaskPageVo educationPaperTask); + + void checkType(PaperQueUpdateDTO dto); + } diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/question/ExamQuestionServiceImpl.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/question/ExamQuestionServiceImpl.java index 4a154379..6449582c 100644 --- a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/question/ExamQuestionServiceImpl.java +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/question/ExamQuestionServiceImpl.java @@ -22,8 +22,11 @@ import pc.exam.pp.module.exam.controller.admin.question.vo.*; import pc.exam.pp.module.exam.controller.admin.questionexamine.vo.QuestionExaminePageReqVO; import pc.exam.pp.module.exam.controller.admin.rabbitmq.vo.RabbitMQSendInfoVO; import pc.exam.pp.module.exam.dal.dataobject.*; +import pc.exam.pp.module.exam.dal.dataobject.knowledge.ExamKnowledgePoints; import pc.exam.pp.module.exam.dal.dataobject.specialty.ExamSpecialty; +import pc.exam.pp.module.exam.dal.mysql.knowledge.ExamKnowledgePointsMapper; import pc.exam.pp.module.exam.dal.mysql.mysqlkeyword.MysqlKeywordMapper; +import pc.exam.pp.module.exam.dal.mysql.paper.EducationPaperQuMapper; import pc.exam.pp.module.exam.dal.mysql.question.*; import pc.exam.pp.module.exam.dal.mysql.questionexamine.QuestionExamineMapper; import pc.exam.pp.module.exam.dal.mysql.specialty.ExamSpecialtyMapper; @@ -34,6 +37,7 @@ import pc.exam.pp.module.exam.utils.uuid.IdUtils; import java.time.LocalDateTime; import java.util.*; +import java.util.stream.Collectors; import static pc.exam.pp.framework.common.exception.util.ServiceExceptionUtil.exception; import static pc.exam.pp.module.system.enums.ErrorCodeConstants.*; @@ -67,6 +71,10 @@ public class ExamQuestionServiceImpl implements IExamQuestionService private RabbitmqUtils rabbitMqService; @Autowired private MysqlKeywordMapper mysqlKeywordMapper; + @Autowired + private ExamKnowledgePointsMapper knowledgePointsMapper; + @Autowired + private EducationPaperQuMapper educationPaperQuMapper; /** * 查询试题(hyc) * @@ -101,6 +109,12 @@ public class ExamQuestionServiceImpl implements IExamQuestionService } } + String chapteridDictText = examQuestion.getChapteridDictText(); + String pointNames = examQuestion.getPointNames(); + String point= knowledgePointsMapper.selectKnowledgeNameBySpId(pointNames); + String chapterText= knowledgePointsMapper.selectKnowledgeNameBySpId(chapteridDictText); + examQuestion.setPointNamesVo(point); + examQuestion.setChapteridDictTextVo(chapterText); return examQuestion; } @@ -317,19 +331,32 @@ public class ExamQuestionServiceImpl implements IExamQuestionService * @return 结果 */ @Override + @Transactional(rollbackFor = Exception.class) // 所有异常都回滚 public int deleteExamQuestionByQuIds(String[] ids) { - if (ids != null && ids.length > 0) { - //删除试题答案 - examQuestionAnswerMapper.deleteExamQuestionAnswerByQuesIds(ids); - //删除试题文件 - sysFileMapper.deleteSysFileByQuesIds(ids); - //删除试题的判分 - examQuestionScoreMapper.deleteExamQuestionScoreByQuesIds(ids); - //删除试题关键字 - examQuestionKeywordMapper.deleteExamQuestionScoreByQuesIds(ids); + // 查询出被使用的题目ID + List usedIds = educationPaperQuMapper.selectUsedQuestionIds(ids); + Set usedIdSet = new HashSet<>(usedIds); + + // 找出未被使用的题目ID + List canDeleteIds = Arrays.stream(ids) + .filter(id -> !usedIdSet.contains(id)) + .collect(Collectors.toList()); + if (canDeleteIds.isEmpty()) { + // 全部试题都已被引用,不能删除 + return 0; } - return examQuestionMapper.deleteExamQuestionByQuIds(ids); + String[] deleteIds = canDeleteIds.toArray(new String[0]); + //删除试题答案 + examQuestionAnswerMapper.deleteExamQuestionAnswerByQuesIds(deleteIds); + //删除试题文件 + sysFileMapper.deleteSysFileByQuesIds(deleteIds); + //删除试题的判分 + examQuestionScoreMapper.deleteExamQuestionScoreByQuesIds(deleteIds); + //删除试题关键字 + examQuestionKeywordMapper.deleteExamQuestionScoreByQuesIds(deleteIds); + + return examQuestionMapper.deleteExamQuestionByQuIds(deleteIds); } /** @@ -348,7 +375,35 @@ public class ExamQuestionServiceImpl implements IExamQuestionService @Override public PageResult selectExamQuestionList(QuestionVo questionVo) { - return examQuestionMapper.selectExamQuestionList(questionVo); + PageResult examQuestionPageResult = examQuestionMapper.selectExamQuestionList(questionVo); + List list = examQuestionPageResult.getList(); + List examKnowledgePoints = knowledgePointsMapper.selectKnowledgePoints(); + // 构造 ID → 名称映射 + Map idNameMap = examKnowledgePoints.stream() + .collect(Collectors.toMap(ExamKnowledgePoints::getSpId, ExamKnowledgePoints::getSpName)); + for (ExamQuestion examQuestion : list) { + String pointIdStr = examQuestion.getPointNames(); + String chapterIdStr = examQuestion.getChapteridDictText(); + try { + if (pointIdStr != null) { + Long pointId = Long.valueOf(pointIdStr); + if (idNameMap.containsKey(pointId)) { + examQuestion.setPointNamesVo(idNameMap.get(pointId)); + } + } + + if (chapterIdStr != null) { + Long chapterId = Long.valueOf(chapterIdStr); + if (idNameMap.containsKey(chapterId)) { + examQuestion.setChapteridDictTextVo(idNameMap.get(chapterId)); + } + } + } catch (NumberFormatException e) { + // 日志记录或跳过处理 + System.err.println("ID格式错误:" + e.getMessage()); + } + } + return examQuestionPageResult; } @@ -707,7 +762,7 @@ public class ExamQuestionServiceImpl implements IExamQuestionService examQuestion.setSpecialtyName(importUser.getSpecialtyName()); examQuestion.setCourseName(importUser.getCourseName()); examQuestion.setSubjectName(importUser.getSubjectName()); - examQuestion.setQuLevel(importUser.getQuLevel()); + examQuestion.setQuLevel(Integer.valueOf(importUser.getQuLevel())); examQuestion.setContent(importUser.getContent()); examQuestion.setAnalysis(importUser.getAnalysis()); examQuestion.setPointNames(importUser.getPointNames()); @@ -767,7 +822,7 @@ public class ExamQuestionServiceImpl implements IExamQuestionService examQuestion.setSpecialtyName(importUser.getSpecialtyName()); examQuestion.setCourseName(importUser.getCourseName()); examQuestion.setSubjectName(importUser.getSubjectName()); - examQuestion.setQuLevel(importUser.getQuLevel()); + examQuestion.setQuLevel(Integer.valueOf(importUser.getQuLevel())); examQuestion.setContent(importUser.getContent()); examQuestion.setAnalysis(importUser.getAnalysis()); examQuestion.setPointNames(importUser.getPointNames()); @@ -831,11 +886,36 @@ public class ExamQuestionServiceImpl implements IExamQuestionService public PageResult selectExamQuestionListAnswer(QuestionVo questionVo) { PageResult examQuestionPageResult = examQuestionMapper.selectExamQuestionList(questionVo); List list = examQuestionPageResult.getList(); + List examKnowledgePoints = knowledgePointsMapper.selectKnowledgePoints(); + // 构造 ID → 名称映射 + Map idNameMap = examKnowledgePoints.stream() + .collect(Collectors.toMap(ExamKnowledgePoints::getSpId, ExamKnowledgePoints::getSpName)); + if (list != null && !list.isEmpty()) { for (ExamQuestion examQuestion : list) { String quId = examQuestion.getQuId(); List examQuestionAnswers = examQuestionAnswerMapper.selectExamQuestionAnswerByQuId(quId); examQuestion.setAnswerList(examQuestionAnswers); + String pointIdStr = examQuestion.getPointNames(); + String chapterIdStr = examQuestion.getChapteridDictText(); + try { + if (pointIdStr != null) { + Long pointId = Long.valueOf(pointIdStr); + if (idNameMap.containsKey(pointId)) { + examQuestion.setPointNamesVo(idNameMap.get(pointId)); + } + } + + if (chapterIdStr != null) { + Long chapterId = Long.valueOf(chapterIdStr); + if (idNameMap.containsKey(chapterId)) { + examQuestion.setChapteridDictTextVo(idNameMap.get(chapterId)); + } + } + }catch (NumberFormatException e) { + // 日志记录或跳过处理 + System.err.println("ID格式错误:" + e.getMessage()); + } } } return examQuestionPageResult; diff --git a/exam-module-exam/exam-module-exam-biz/src/main/resources/mapper/exam/EducationPaperParamMapper.xml b/exam-module-exam/exam-module-exam-biz/src/main/resources/mapper/exam/EducationPaperParamMapper.xml index fdb1b247..96f34524 100644 --- a/exam-module-exam/exam-module-exam-biz/src/main/resources/mapper/exam/EducationPaperParamMapper.xml +++ b/exam-module-exam/exam-module-exam-biz/src/main/resources/mapper/exam/EducationPaperParamMapper.xml @@ -19,7 +19,7 @@ - + @@ -29,12 +29,14 @@ - + + - select param_id, task_id, is_number,is_content,is_answer_id,is_exam_password, exam_password, usb, save_grades, driver, directory, upload_time, is_time,exam_time,is_del,is_repeat ,is_answer,is_look,is_connect,is_session,warn,is_file,is_net,is_screen from education_paper_param + select param_id, task_id, is_number,is_content,is_answer_id,is_exam_password, exam_password, usb, save_grades, driver, directory, upload_time, + is_time,exam_time,is_copy,is_repeat ,is_answer,is_look,is_connect,is_session,warn,is_file,is_net,is_screen,is_score,is_score_detail from education_paper_param @@ -78,7 +79,7 @@ upload_time, is_time, exam_time, - is_del, + is_copy, is_repeat, is_answer, is_look, @@ -88,6 +89,10 @@ is_file, is_net, is_screen, + + is_score, + is_score_detail, + #{paramId}, @@ -104,7 +109,7 @@ #{uploadTime}, #{isTime}, #{examTime}, - #{isDel}, + #{isCopy}, #{isRepeat}, #{isAnswer}, #{isLook}, @@ -114,6 +119,8 @@ #{isFile}, #{isNet}, #{isScreen}, + #{isScore}, + #{isScoreDetail}, @@ -133,7 +140,7 @@ upload_time = #{uploadTime}, is_time = #{isTime}, exam_time = #{examTime}, - is_del = #{isDel}, + is_copy = #{isCopy}, is_repeat = #{isRepeat}, is_answer = #{isAnswer}, is_look = #{isLook}, @@ -143,6 +150,8 @@ is_file = #{isFile}, is_net = #{isNet}, is_screen = #{isScreen}, + is_score = #{isScore}, + is_score_detail = #{isScoreDetail}, where param_id = #{paramId} diff --git a/exam-module-exam/exam-module-exam-biz/src/main/resources/mapper/exam/EducationPaperQuMapper.xml b/exam-module-exam/exam-module-exam-biz/src/main/resources/mapper/exam/EducationPaperQuMapper.xml index 487e5043..0ae24d7b 100644 --- a/exam-module-exam/exam-module-exam-biz/src/main/resources/mapper/exam/EducationPaperQuMapper.xml +++ b/exam-module-exam/exam-module-exam-biz/src/main/resources/mapper/exam/EducationPaperQuMapper.xml @@ -39,6 +39,22 @@ (select qu_id from education_paper_qu where paper_id =#{paperId})ORDER BY RAND() LIMIT 1; + + diff --git a/exam-module-exam/exam-module-exam-biz/src/main/resources/mapper/exam/EducationPaperSchemeMapper.xml b/exam-module-exam/exam-module-exam-biz/src/main/resources/mapper/exam/EducationPaperSchemeMapper.xml index b650a959..0e67069e 100644 --- a/exam-module-exam/exam-module-exam-biz/src/main/resources/mapper/exam/EducationPaperSchemeMapper.xml +++ b/exam-module-exam/exam-module-exam-biz/src/main/resources/mapper/exam/EducationPaperSchemeMapper.xml @@ -44,6 +44,9 @@ + insert into education_paper_scheme diff --git a/exam-module-exam/exam-module-exam-biz/src/main/resources/mapper/exam/ExamQuestionAnswerMapper.xml b/exam-module-exam/exam-module-exam-biz/src/main/resources/mapper/exam/ExamQuestionAnswerMapper.xml index 2e2d47b6..5bee46f1 100644 --- a/exam-module-exam/exam-module-exam-biz/src/main/resources/mapper/exam/ExamQuestionAnswerMapper.xml +++ b/exam-module-exam/exam-module-exam-biz/src/main/resources/mapper/exam/ExamQuestionAnswerMapper.xml @@ -95,6 +95,14 @@ + + insert into exam_question_answer (answer_id, qu_id, is_right, image, content,contentIn,score_rate,sort) diff --git a/exam-module-exam/exam-module-exam-biz/src/main/resources/mapper/knowledge/ExamKnowledgePointsMapper.xml b/exam-module-exam/exam-module-exam-biz/src/main/resources/mapper/knowledge/ExamKnowledgePointsMapper.xml index 3a7899fb..88b12c74 100644 --- a/exam-module-exam/exam-module-exam-biz/src/main/resources/mapper/knowledge/ExamKnowledgePointsMapper.xml +++ b/exam-module-exam/exam-module-exam-biz/src/main/resources/mapper/knowledge/ExamKnowledgePointsMapper.xml @@ -44,6 +44,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" and deleted = 0 + + + update exam_knowledge_points diff --git a/exam-module-exam/exam-module-exam-biz/src/main/resources/mapper/monitor/MonitorMapper.xml b/exam-module-exam/exam-module-exam-biz/src/main/resources/mapper/monitor/MonitorMapper.xml index 0916ca83..ce563c68 100644 --- a/exam-module-exam/exam-module-exam-biz/src/main/resources/mapper/monitor/MonitorMapper.xml +++ b/exam-module-exam/exam-module-exam-biz/src/main/resources/mapper/monitor/MonitorMapper.xml @@ -15,4 +15,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + diff --git a/exam-module-infra/exam-module-infra-api/src/main/java/pc/exam/pp/module/infra/enums/ErrorCodeConstants.java b/exam-module-infra/exam-module-infra-api/src/main/java/pc/exam/pp/module/infra/enums/ErrorCodeConstants.java index 1723caf7..53333f63 100644 --- a/exam-module-infra/exam-module-infra-api/src/main/java/pc/exam/pp/module/infra/enums/ErrorCodeConstants.java +++ b/exam-module-infra/exam-module-infra-api/src/main/java/pc/exam/pp/module/infra/enums/ErrorCodeConstants.java @@ -70,7 +70,7 @@ public interface ErrorCodeConstants { // ========== 试卷人员 1-001-301-000 ========== ErrorCode DEMO03_PAPER_STUDENT_EXISTS = new ErrorCode(1_001_301_001, "请选择学生"); - + // ========== 试卷参数 1-001-401-000 ========== ErrorCode DEMO03_PAPER_SESSION_EXISTS = new ErrorCode(1_001_401_001, "请开启考场设置!"); diff --git a/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/controller/admin/getpoints/GetPointsController.java b/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/controller/admin/getpoints/GetPointsController.java index 3a5d8060..ee6e3afc 100644 --- a/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/controller/admin/getpoints/GetPointsController.java +++ b/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/controller/admin/getpoints/GetPointsController.java @@ -1,5 +1,7 @@ package pc.exam.pp.module.judgement.controller.admin.getpoints; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import pc.exam.pp.framework.common.pojo.CommonResult; @@ -11,7 +13,7 @@ import pc.exam.pp.module.judgement.controller.service.getpoints.ExamGetPointsSer import java.io.IOException; import java.util.List; - +@Tag(name = "管理后台 - 考点操作") @RestController @RequestMapping("/exam/getPoints") public class GetPointsController { @@ -23,6 +25,7 @@ public class GetPointsController { * 得出文件操作考点 * @return 得分 */ + @Operation(summary = "得出文件操作考点") @PostMapping("/get_filePoint") @TenantIgnore public CommonResult get_file_point(@RequestBody PointsVo pointsVo) throws IOException { @@ -32,6 +35,7 @@ public class GetPointsController { * 文件得出MYSQL操作考点 * @return 得分 */ + @Operation(summary = "文件得出MYSQL操作考点") @PostMapping("/get_mysql_point") @TenantIgnore public CommonResult get_mysql_point(@RequestBody PointsVo pointsVo) throws IOException { @@ -49,24 +53,26 @@ public class GetPointsController { * 新增/更新MYSQL操作考点 * @return 得分 */ + @Operation(summary = "新增/更新MYSQL操作考点") @PostMapping("/update_mysql_point") @TenantIgnore public CommonResult update_mysql_point(@RequestBody Points points) { return CommonResult.success(examGetPointsService.update_mysql_point(points)); } - + @Operation(summary = "获取考点详情") @GetMapping("/get_Point_id/{quId}") @TenantIgnore public CommonResult getPointById(@PathVariable("quId") String quId) { return CommonResult.success(examGetPointsService.getPointById(quId)); } /** - * 新增修改浏览器操作考点 + * 新增/修改浏览器操作考点 * @return 得分 */ + @Operation(summary = "新增/修改浏览器操作考点") @PostMapping("/set_browser_point") @TenantIgnore - //todo 老师自己设置,不读文件 + //老师自己设置,不读文件 public CommonResult get_browser_point(@RequestBody Points points) { return CommonResult.success(examGetPointsService.get_browser_point(points)); } diff --git a/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/controller/admin/getpoints/vo/FileNode.java b/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/controller/admin/getpoints/vo/FileNode.java new file mode 100644 index 00000000..86e72866 --- /dev/null +++ b/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/controller/admin/getpoints/vo/FileNode.java @@ -0,0 +1,14 @@ +package pc.exam.pp.module.judgement.controller.admin.getpoints.vo; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@AllArgsConstructor +@NoArgsConstructor +public class FileNode { + private Long id; + private String name; + private Long parentId; +} diff --git a/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/controller/admin/getpoints/vo/FilePointsVo.java b/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/controller/admin/getpoints/vo/FilePointsVo.java new file mode 100644 index 00000000..0d8647ff --- /dev/null +++ b/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/controller/admin/getpoints/vo/FilePointsVo.java @@ -0,0 +1,16 @@ +package pc.exam.pp.module.judgement.controller.admin.getpoints.vo; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; +import pc.exam.pp.module.exam.dal.dataobject.ExamQuestionAnswer; + +import java.util.List; + +@Data +@AllArgsConstructor +@NoArgsConstructor +public class FilePointsVo { + List nodeList; + List examQuestionAnswerList; +} diff --git a/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/controller/service/browser/BrowserServericeImpl.java b/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/controller/service/browser/BrowserServericeImpl.java index d4d4aef6..4725e9c0 100644 --- a/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/controller/service/browser/BrowserServericeImpl.java +++ b/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/controller/service/browser/BrowserServericeImpl.java @@ -14,6 +14,8 @@ import java.io.File; import java.io.FileWriter; import java.io.IOException; import java.nio.file.Paths; +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; import java.util.ArrayList; import java.util.List; import java.util.Map; @@ -24,6 +26,8 @@ public class BrowserServericeImpl implements IBrowserServerice { static String answerLogPath ; // 文件路径 @Resource private ExamQuestionAnswerMapper examQuestionAnswerMapper; + private static final DateTimeFormatter formatter = + DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); //考生试题文件夹 // static final String BASE_DIR = "D:/exam/4/"; //谷歌浏览器 @@ -149,7 +153,9 @@ public class BrowserServericeImpl implements IBrowserServerice { */ public static void appendToFile(String filePath, String content) { try (BufferedWriter writer = new BufferedWriter(new FileWriter(filePath, true))) { - writer.write(content); + String timestamp = LocalDateTime.now().format(formatter); + String logLine = String.format("[%s] %s", timestamp, content); + writer.write(logLine); writer.newLine(); // 可选:添加换行符 } catch (IOException e) { e.printStackTrace(); diff --git a/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/controller/service/file/FileServericeImpl.java b/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/controller/service/file/FileServericeImpl.java index 05fa0fd1..9a94edd8 100644 --- a/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/controller/service/file/FileServericeImpl.java +++ b/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/controller/service/file/FileServericeImpl.java @@ -12,6 +12,8 @@ import java.io.File; import java.io.FileWriter; import java.io.IOException; import java.nio.file.Paths; +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; import java.util.ArrayList; import java.util.Comparator; import java.util.List; @@ -23,6 +25,8 @@ public class FileServericeImpl implements IFileServerice { static String answerLogPath ; // 文件路径 @Resource private ExamQuestionAnswerMapper examQuestionAnswerMapper; + private static final DateTimeFormatter formatter = + DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); @Override public double run_file_point(double score,File file, ExamQuestion question) throws IOException { @@ -116,7 +120,9 @@ public class FileServericeImpl implements IFileServerice { */ public static void appendToFile(String filePath, String content) { try (BufferedWriter writer = new BufferedWriter(new FileWriter(filePath, true))) { - writer.write(content); + String timestamp = LocalDateTime.now().format(formatter); + String logLine = String.format("[%s] %s", timestamp, content); + writer.write(logLine); writer.newLine(); // 可选:添加换行符 } catch (IOException e) { e.printStackTrace(); diff --git a/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/controller/service/getpoints/ExamGetPointsService.java b/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/controller/service/getpoints/ExamGetPointsService.java index a571f147..b3ff5861 100644 --- a/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/controller/service/getpoints/ExamGetPointsService.java +++ b/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/controller/service/getpoints/ExamGetPointsService.java @@ -1,6 +1,7 @@ package pc.exam.pp.module.judgement.controller.service.getpoints; import pc.exam.pp.module.exam.dal.dataobject.ExamQuestionAnswer; +import pc.exam.pp.module.judgement.controller.admin.getpoints.vo.FilePointsVo; import pc.exam.pp.module.judgement.controller.admin.getpoints.vo.Points; import pc.exam.pp.module.judgement.controller.admin.getpoints.vo.PointsVo; @@ -11,7 +12,7 @@ public interface ExamGetPointsService { - List get_file_point(PointsVo pointsVo) throws IOException; + FilePointsVo get_file_point(PointsVo pointsVo) throws IOException; List get_mysql_point(PointsVo pointsVo) throws IOException; diff --git a/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/controller/service/getpoints/ExamGetPointsServiceImpl.java b/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/controller/service/getpoints/ExamGetPointsServiceImpl.java index 40016d2c..3559e11b 100644 --- a/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/controller/service/getpoints/ExamGetPointsServiceImpl.java +++ b/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/controller/service/getpoints/ExamGetPointsServiceImpl.java @@ -15,6 +15,8 @@ import pc.exam.pp.module.exam.utils.file.GetDifferencesBetweenFolders; import pc.exam.pp.module.exam.utils.uuid.IdUtils; import pc.exam.pp.module.infra.dal.dataobject.config.ConfigDO; import pc.exam.pp.module.infra.service.config.ConfigService; +import pc.exam.pp.module.judgement.controller.admin.getpoints.vo.FileNode; +import pc.exam.pp.module.judgement.controller.admin.getpoints.vo.FilePointsVo; import pc.exam.pp.module.judgement.controller.admin.getpoints.vo.Points; import pc.exam.pp.module.judgement.controller.admin.getpoints.vo.PointsVo; import pc.exam.pp.module.judgement.controller.utils.zip.ZipUtil; @@ -27,6 +29,7 @@ import java.nio.file.Files; import java.nio.file.Paths; import java.util.*; import java.util.concurrent.atomic.AtomicInteger; +import java.util.concurrent.atomic.AtomicLong; import java.util.stream.Collectors; @Service @@ -34,6 +37,7 @@ import java.util.stream.Collectors; public class ExamGetPointsServiceImpl implements ExamGetPointsService{ @Resource ConfigService configService; + private static final AtomicLong ID_GENERATOR = new AtomicLong(1); // 自增 ID @Resource MysqlKeywordMapper mysqlKeywordMapper; @@ -42,7 +46,7 @@ public class ExamGetPointsServiceImpl implements ExamGetPointsService{ @Override - public List get_file_point(PointsVo pointsVo) throws IOException { + public FilePointsVo get_file_point(PointsVo pointsVo) throws IOException { // 获取平台文件参数 ConfigDO config = configService.getConfigByKey("file_down_path"); @@ -59,10 +63,10 @@ public class ExamGetPointsServiceImpl implements ExamGetPointsService{ //解压之后得文件获取文件夹和文件 File folderStu = new File(stuFilePath); - File folderAnswer = new File(stuFilePath); - - + File folderAnswer = new File(answerFilePath); + List nodeList = ExamGetPointsServiceImpl.buildFileNodeTree(folderAnswer); + System.out.println(nodeList); List answerList = new ArrayList<>(); AtomicInteger sortCounter = new AtomicInteger(1); // 计数器 @@ -96,13 +100,56 @@ public class ExamGetPointsServiceImpl implements ExamGetPointsService{ zip_file_answer.delete(); deleteFolder(folderStu); deleteFolder(folderAnswer); - return answerList; + + FilePointsVo filePointsVo=new FilePointsVo(); + filePointsVo.setNodeList(nodeList); + filePointsVo.setExamQuestionAnswerList(answerList); + return filePointsVo; } + + + public static List buildFileNodeTree(File root) { + List result = new ArrayList<>(); + + if (root != null && root.exists() && root.isDirectory()) { + File[] children = root.listFiles(); + if (children != null) { + for (File child : children) { + buildRecursive(child, null, result); // 从子文件夹开始构建,跳过 root + } + } + } + + return result; + } + + private static void buildRecursive(File file, Long parentId, List list) { + Long currentId = ID_GENERATOR.getAndIncrement(); + + FileNode node = new FileNode(); + node.setId(currentId); + node.setName(file.getName()); + node.setParentId(parentId); + list.add(node); + + if (file.isDirectory()) { + File[] children = file.listFiles(); + if (children != null) { + for (File child : children) { + buildRecursive(child, currentId, list); + } + } + } + } + + + + + @Override public List get_mysql_point(PointsVo pointsVo) throws IOException { - String answerPath = pointsVo.getAnswerPath(); // 获取平台文件参数 ConfigDO config = configService.getConfigByKey("file_down_path"); diff --git a/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/controller/service/mysql/MysqlServericeImpl.java b/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/controller/service/mysql/MysqlServericeImpl.java index 9b473dfe..07879445 100644 --- a/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/controller/service/mysql/MysqlServericeImpl.java +++ b/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/controller/service/mysql/MysqlServericeImpl.java @@ -20,12 +20,16 @@ import pc.exam.pp.module.judgement.utils.EndStuMonitorUtils; import java.awt.*; import java.io.*; +import java.math.BigDecimal; +import java.math.RoundingMode; import java.nio.charset.StandardCharsets; import java.nio.file.DirectoryStream; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; import java.sql.*; +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; import java.util.*; import java.util.List; import java.util.concurrent.atomic.AtomicBoolean; @@ -41,15 +45,16 @@ public class MysqlServericeImpl implements IMysqlServerice { static String databaseName; static String databaseNameStu; static String answerLogPath; // 文件路径 - + private static final DateTimeFormatter formatter = + DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); @Resource private ExamMysqlKeywordMapper examMysqlKeywordMapper; @Resource - private ExamQuestionAnswerMapper examQuestionAnswerMapper; + private ExamQuestionAnswerMapper examQuestionAnswerMapper; @Override public double Judgement(double score,File filepath, ExamQuestion examQuestion) throws IOException, SQLException { - + double scoreTotal =0.0; String fileUrl= examQuestionAnswerMapper.selectAnswerFile(examQuestion.getQuId()); String path = ZipUtil.downloadStudentFile(fileUrl, "data"); // 4、获取到得是zip文件,需要解压 @@ -61,18 +66,20 @@ public class MysqlServericeImpl implements IMysqlServerice { // 5.2、查询试题ID - List examQuestionAnswers = examQuestionAnswerMapper.selectExamQuestionAnswerByQuId(examQuestion.getQuId()); String totalKeyScore ="0"; - if (examQuestionAnswers!=null&&examQuestionAnswers.size()>0){ - List answerIdList = examQuestionAnswers.stream() - .map(ExamQuestionAnswer::getAnswerId) // 提取每个对象的 answerId - .collect(Collectors.toList()); - //得到总计得分点 - System.out.println(answerIdList); - totalKeyScore=examMysqlKeywordMapper.selectByAnswerIds(answerIdList); + //得出 这个题总共的权值点 + totalKeyScore=examQuestionAnswerMapper.selectCountPointByQuId(examQuestion.getQuId()); - } +// if (examQuestionAnswers!=null&&examQuestionAnswers.size()>0){ +// List answerIdList = examQuestionAnswers.stream() +// .map(ExamQuestionAnswer::getAnswerId) // 提取每个对象的 answerId +// .collect(Collectors.toList()); +// //得到总计得分点 +// System.out.println(answerIdList); +// totalKeyScore=examMysqlKeywordMapper.selectByAnswerIds(answerIdList); +// +// } answerLogPath = filepath.getParent() + File.separator + "log.txt"; AtomicInteger total = new AtomicInteger(); @@ -223,12 +230,13 @@ public class MysqlServericeImpl implements IMysqlServerice { if (entry.getValue().trim().toUpperCase().startsWith("CREATE TABLE")) { List examMysqlKeywordList =new ArrayList<>(); appendToFile(answerLogPath, "==================建表语句=================="); + String answerId = null; for (ExamQuestionAnswer examQuestionAnswer : examQuestionAnswers) { if (normalize(examQuestionAnswer.getContent()).equals(normalize(entry.getValue()))) { // 匹配成功 - String answerId = examQuestionAnswer.getAnswerId(); + answerId = examQuestionAnswer.getAnswerId(); examMysqlKeywordList= examMysqlKeywordMapper.selectListByAnswerId(answerId); - + break; } } @@ -242,35 +250,57 @@ public class MysqlServericeImpl implements IMysqlServerice { // 查询建表语句 String showCreateTableSql = "SHOW CREATE TABLE " + tableName; + String sql = "SELECT COLUMN_NAME, COLUMN_TYPE, IS_NULLABLE, COLUMN_KEY, EXTRA " + + "FROM INFORMATION_SCHEMA.COLUMNS " + + "WHERE TABLE_NAME = '" + tableName + "' AND TABLE_SCHEMA = '" + databaseName + "'"; + String sql2 = "SELECT COLUMN_NAME, COLUMN_TYPE, IS_NULLABLE, COLUMN_KEY, EXTRA " + + "FROM INFORMATION_SCHEMA.COLUMNS " + + "WHERE TABLE_NAME = '" + tableName + "' AND TABLE_SCHEMA = '" + databaseNameStu + "'"; - try (ResultSet rs = stmt.executeQuery(showCreateTableSql)) { - if (rs.next()) { - String createTableSql = rs.getString("Create Table"); - // 替换 result 中的值 - entry.setValue(createTableSql); - String sql1 = result.get(entry.getKey()); - String sql2 = resultStu.get(entry.getKey()); - String normalizedSql1 = simplifyCreateTableSql(sql1); - - String normalizedSql2 = simplifyCreateTableSql(sql2); - - if (normalizedSql1.equals(normalizedSql2)) { - // - accumulateScoreAndLog(examMysqlKeywordList,total,answerLogPath,sql2,totalKeyScore,score); - } else { - int scoreAnswerNotAllTrue =calculateTotalScoreRate(sql2, examMysqlKeywordList,totalKeyScore,score); - total.addAndGet(scoreAnswerNotAllTrue); - - } - + // 获取主库字段信息 + Set> table1Columns = new HashSet<>(); + try (ResultSet rs = stmt.executeQuery(sql)) { + while (rs.next()) { + Map column = new HashMap<>(); + column.put("COLUMN_NAME", rs.getString("COLUMN_NAME")); + column.put("COLUMN_TYPE", rs.getString("COLUMN_TYPE")); + column.put("IS_NULLABLE", rs.getString("IS_NULLABLE")); + column.put("COLUMN_KEY", rs.getString("COLUMN_KEY")); + column.put("EXTRA", rs.getString("EXTRA")); + table1Columns.add(column); } - }catch (SQLException e) { - appendToFile(answerLogPath, "执行验证 SQL 出错!"); - e.printStackTrace(); + appendToFile(answerLogPath, "标准答案建表键值对:"+table1Columns); + + } + // 获取学生库字段信息 + Set> table2Columns = new HashSet<>(); + try (Connection connstu = DriverManager.getConnection(stuDbUrl, user, password); + Statement stmtstu = connstu.createStatement()) { + try (ResultSet rsstu = stmtstu.executeQuery(sql2)) { + while (rsstu.next()) { + Map column = new HashMap<>(); + column.put("COLUMN_NAME", rsstu.getString("COLUMN_NAME")); + column.put("COLUMN_TYPE", rsstu.getString("COLUMN_TYPE")); + column.put("IS_NULLABLE", rsstu.getString("IS_NULLABLE")); + column.put("COLUMN_KEY", rsstu.getString("COLUMN_KEY")); + column.put("EXTRA", rsstu.getString("EXTRA")); + table2Columns.add(column); + } + appendToFile(answerLogPath, "学生答案建表键值对:"+table2Columns); - + } + } + String sql3 = resultStu.get(entry.getKey()); + if (table1Columns.equals(table2Columns)) { + // + double sr= accumulateScoreAndLog(examMysqlKeywordList,total,answerLogPath,sql3,totalKeyScore,score,answerId,scoreTotal); + scoreTotal+=sr; + } else { + double sw= calculateTotalScoreRate(sql3, examMysqlKeywordList,totalKeyScore,score,answerId,scoreTotal); + scoreTotal+=sw; + } } } @@ -284,12 +314,13 @@ public class MysqlServericeImpl implements IMysqlServerice { if (matcher.find()) { String tableName = matcher.group(1).replace("`", ""); // 获取表名 + String answerId=null; for (ExamQuestionAnswer examQuestionAnswer : examQuestionAnswers) { if (normalize(examQuestionAnswer.getContent()).equals(normalize(entry.getValue()))) { // 匹配成功 - String answerId = examQuestionAnswer.getAnswerId(); + answerId = examQuestionAnswer.getAnswerId(); examMysqlKeywordList= examMysqlKeywordMapper.selectListByAnswerId(answerId); - + break; } } @@ -302,12 +333,11 @@ public class MysqlServericeImpl implements IMysqlServerice { boolean equals = sql1.equals(sql2); if (equals) { - accumulateScoreAndLog(examMysqlKeywordList,total,answerLogPath,sql2,totalKeyScore,score); - + double sr=accumulateScoreAndLog(examMysqlKeywordList,total,answerLogPath,sql2,totalKeyScore,score,answerId,scoreTotal); + scoreTotal+=sr; } else { - int scoreAnswerNotAllTrue =calculateTotalScoreRate(sql2, examMysqlKeywordList,totalKeyScore,score); - total.addAndGet(scoreAnswerNotAllTrue); - + double sw= calculateTotalScoreRate(sql2, examMysqlKeywordList,totalKeyScore,score,answerId,scoreTotal); + scoreTotal+=sw; } @@ -321,7 +351,7 @@ public class MysqlServericeImpl implements IMysqlServerice { List examMysqlKeywordList =new ArrayList<>(); String delStatement = entry.getValue(); delStatement = delStatement.trim().replaceAll(";+\\s*$", ""); - + String answerId =null; String sql2 = resultStu.get(entry.getKey()); // 正则提取表名和 WHERE 条件 Pattern pattern = Pattern.compile("DELETE\\s+FROM\\s+(\\w+)\\s+WHERE\\s+(.+)", Pattern.CASE_INSENSITIVE); @@ -329,9 +359,9 @@ public class MysqlServericeImpl implements IMysqlServerice { for (ExamQuestionAnswer examQuestionAnswer : examQuestionAnswers) { if (normalize(examQuestionAnswer.getContent()).equals(normalize(entry.getValue()))) { // 匹配成功 - String answerId = examQuestionAnswer.getAnswerId(); + answerId = examQuestionAnswer.getAnswerId(); examMysqlKeywordList= examMysqlKeywordMapper.selectListByAnswerId(answerId); - + break; } } @@ -360,13 +390,11 @@ public class MysqlServericeImpl implements IMysqlServerice { //累加删除语句的所有权值 examQuestionKeywords累加scorerate appendToFile(answerLogPath, "验证通过:符合 DELETE 条件的记录已删除。"); - accumulateScoreAndLog(examMysqlKeywordList,total,answerLogPath,sql2,totalKeyScore,score); - + double sr= accumulateScoreAndLog(examMysqlKeywordList,total,answerLogPath,sql2,totalKeyScore,score,answerId,scoreTotal); + scoreTotal+=sr; } else { - - int scoreAnswerNotAllTrue =calculateTotalScoreRate(sql2, examMysqlKeywordList,totalKeyScore,score); - total.addAndGet(scoreAnswerNotAllTrue); - + double sw= calculateTotalScoreRate(sql2, examMysqlKeywordList,totalKeyScore,score,answerId,scoreTotal); + scoreTotal+=sw; } } }catch (SQLException e) { @@ -394,12 +422,13 @@ public class MysqlServericeImpl implements IMysqlServerice { appendToFile(answerLogPath, "==================更新语句=================="); List examMysqlKeywordList =new ArrayList<>(); String sql1 = entry.getValue(); + String answerId=null; for (ExamQuestionAnswer examQuestionAnswer : examQuestionAnswers) { if (normalize(examQuestionAnswer.getContent()).equals(normalize(entry.getValue()))) { // 匹配成功 - String answerId = examQuestionAnswer.getAnswerId(); + answerId = examQuestionAnswer.getAnswerId(); examMysqlKeywordList= examMysqlKeywordMapper.selectListByAnswerId(answerId); - + break; } } @@ -413,11 +442,11 @@ public class MysqlServericeImpl implements IMysqlServerice { // if (b) { - accumulateScoreAndLog(examMysqlKeywordList,total,answerLogPath,sql2,totalKeyScore,score); + double sr= accumulateScoreAndLog(examMysqlKeywordList,total,answerLogPath,sql2,totalKeyScore,score,answerId,scoreTotal); + scoreTotal+=sr; } else { - int scoreAnswerNotAllTrue =calculateTotalScoreRate(sql2, examMysqlKeywordList,totalKeyScore,score); - total.addAndGet(scoreAnswerNotAllTrue); -// appendToFile(answerLogPath,"语句"+sql2+"不正确,关键得分:"+scoreAnswerNotAllTrue+ "❌"); + double sw= calculateTotalScoreRate(sql2, examMysqlKeywordList,totalKeyScore,score,answerId,scoreTotal); + scoreTotal+=sw; } @@ -426,12 +455,13 @@ public class MysqlServericeImpl implements IMysqlServerice { if (entry.getValue().trim().toUpperCase().startsWith("SELECT")) { appendToFile(answerLogPath, "==================查找语句=================="); List examMysqlKeywordList =new ArrayList<>(); + String answerId =null; for (ExamQuestionAnswer examQuestionAnswer : examQuestionAnswers) { if (normalize(examQuestionAnswer.getContent()).equals(normalize(entry.getValue()))) { // 匹配成功 - String answerId = examQuestionAnswer.getAnswerId(); + answerId = examQuestionAnswer.getAnswerId(); examMysqlKeywordList= examMysqlKeywordMapper.selectListByAnswerId(answerId); - + break; } } @@ -446,6 +476,7 @@ public class MysqlServericeImpl implements IMysqlServerice { Statement stmtan = connanswer.createStatement()) { try (ResultSet answer = stmtan.executeQuery(sql1)) { answerList = getAnswerList(answer); + appendToFile(answerLogPath, "查找语句标准答案"); printResult(answerList); }catch (SQLException e) { appendToFile(answerLogPath, "执行验证语句"+sql1+"时发生错误: " + e.getMessage()); @@ -456,9 +487,10 @@ public class MysqlServericeImpl implements IMysqlServerice { Statement stmtstu = connstu.createStatement()) { try (ResultSet answer = stmtstu.executeQuery(sql2)) { answerListStu = getAnswerList(answer); + appendToFile(answerLogPath, "学生语句答案"); printResult(answerListStu); } catch (SQLException e) { - appendToFile(answerLogPath, "执行学生库语句"+sql2+"时发生错误: " + e.getMessage()+"得分:0 ❌"); + appendToFile(answerLogPath, "执行学生库语句"+sql2+"时发生错误: " + e.getMessage()); } @@ -471,13 +503,12 @@ public class MysqlServericeImpl implements IMysqlServerice { if (isEquivalent) { //todo 得分 - accumulateScoreAndLog(examMysqlKeywordList,total,answerLogPath,sql2,totalKeyScore,score); - + double sr= accumulateScoreAndLog(examMysqlKeywordList,total,answerLogPath,sql2,totalKeyScore,score,answerId,scoreTotal); + scoreTotal+=sr; } else { - int scoreAnswerNotAllTrue =calculateTotalScoreRate(sql2, examMysqlKeywordList,totalKeyScore,score); - total.addAndGet(scoreAnswerNotAllTrue); -// appendToFile(answerLogPath,"语句"+sql2+"不正确,关键得分:"+scoreAnswerNotAllTrue+ "❌"); + double sw= calculateTotalScoreRate(sql2, examMysqlKeywordList,totalKeyScore,score,answerId,scoreTotal); + scoreTotal+=sw; } @@ -488,12 +519,13 @@ public class MysqlServericeImpl implements IMysqlServerice { if (entry.getValue().trim().replaceAll("\\s+", " ").matches("(?i)^CREATE( OR REPLACE)?( ALGORITHM\\s*=\\s*\\w+)?( DEFINER\\s*=\\s*[`\"'\\w@%\\.]+)?( SQL SECURITY \\w+)? VIEW\\b.*")) { appendToFile(answerLogPath, "==================视图语句=================="); List examMysqlKeywordList =new ArrayList<>(); + String answerId=null; for (ExamQuestionAnswer examQuestionAnswer : examQuestionAnswers) { if (normalize(examQuestionAnswer.getContent()).equals(normalize(entry.getValue()))) { // 匹配成功 - String answerId = examQuestionAnswer.getAnswerId(); + answerId = examQuestionAnswer.getAnswerId(); examMysqlKeywordList= examMysqlKeywordMapper.selectListByAnswerId(answerId); - + break; } } @@ -526,12 +558,13 @@ public class MysqlServericeImpl implements IMysqlServerice { // 执行 CREATE VIEW 语句,创建视图 stmt.execute(createView1); - + boolean hasError = false; // 添加标志变量 try { stmt.execute(createView2); } catch (SQLException e) { - appendToFile(answerLogPath, "执行学生库语句"+createView2+"时发生错误: " + e.getMessage()+"得分:0 ❌"); + appendToFile(answerLogPath, "执行学生库语句"+createView2+"时发生错误: " + e.getMessage()); + hasError = true; // 发生异常,设为 true } // 执行查询,获取视图1的结果 @@ -546,7 +579,7 @@ public class MysqlServericeImpl implements IMysqlServerice { printResult(result2); // 比较两个视图的结果 - boolean isEquivalent = compareResults(result1, result2); + boolean isEquivalent = !hasError &&compareResults(result1, result2); appendToFile(answerLogPath, "\n是否结果等价: " + isEquivalent); // 删除视图 @@ -554,12 +587,11 @@ public class MysqlServericeImpl implements IMysqlServerice { stmt.execute("DROP VIEW IF EXISTS " + viewName1); stmt.execute("DROP VIEW IF EXISTS " + viewName2); if (isEquivalent) { - accumulateScoreAndLog(examMysqlKeywordList,total,answerLogPath,sql2,totalKeyScore,score); - + double sr= accumulateScoreAndLog(examMysqlKeywordList,total,answerLogPath,sql2,totalKeyScore,score,answerId,scoreTotal); + scoreTotal+=sr; } else { - int scoreAnswerNotAllTrue =calculateTotalScoreRate(sql2, examMysqlKeywordList,totalKeyScore,score); - total.addAndGet(scoreAnswerNotAllTrue); - + double sw= calculateTotalScoreRate(sql2, examMysqlKeywordList,totalKeyScore,score,answerId,scoreTotal); + scoreTotal+=sw; } // } @@ -569,13 +601,14 @@ public class MysqlServericeImpl implements IMysqlServerice { //存储过程 if (entry.getValue().trim().toUpperCase().toUpperCase().contains("PROCEDURE")) { + String answerId=null; List examMysqlKeywordList =new ArrayList<>(); for (ExamQuestionAnswer examQuestionAnswer : examQuestionAnswers) { if (normalize(examQuestionAnswer.getContent()).equals(normalize(entry.getValue()))) { // 匹配成功 - String answerId = examQuestionAnswer.getAnswerId(); + answerId = examQuestionAnswer.getAnswerId(); examMysqlKeywordList= examMysqlKeywordMapper.selectListByAnswerId(answerId); - + break; } } @@ -603,7 +636,7 @@ public class MysqlServericeImpl implements IMysqlServerice { } catch (SQLException e) { appendToFile(answerLogPath, "执行标准库 SQL CALL 语句时发生错误: " + e.getMessage()); } - + boolean hasError = false; // 添加标志变量 try (Connection connstu = DriverManager.getConnection(stuDbUrl, user, password); Statement stmtstu = connstu.createStatement()) { @@ -616,26 +649,31 @@ public class MysqlServericeImpl implements IMysqlServerice { stuResults.addAll(extractResults(oldResult)); } catch (SQLException e) { appendToFile(answerLogPath, "执行学生库 SQL CALL 语句时发生错误: " + e.getMessage()); + hasError = true; // 发生异常,设为 true } - // 比较结果 - boolean flag = compareExtractResults(anwerResults, stuResults); - if (flag) { - //todo 得分 - accumulateScoreAndLog(examMysqlKeywordList,total,answerLogPath,sql2,totalKeyScore,score); - - } else { - //得分 - int scoreAnswerNotAllTrue =calculateTotalScoreRate(sql2, examMysqlKeywordList,totalKeyScore,score); - total.addAndGet(scoreAnswerNotAllTrue); - - - } } catch (SQLException e) { - appendToFile(answerLogPath, "执行学生库语句"+sql2+"时发生错误: " + e.getMessage()+"得分:0 ❌"); + appendToFile(answerLogPath, "执行学生库语句"+sql2+"时发生错误: " + e.getMessage()); + hasError = true; // 发生异常,设为 true + } + + + + // 比较结果(如果发生异常,可以认为比较失败) + boolean flag = !hasError && compareExtractResults(anwerResults, stuResults); + + if (flag) { + //todo 得分 + double sr= accumulateScoreAndLog(examMysqlKeywordList,total,answerLogPath,sql2,totalKeyScore,score,answerId,scoreTotal); + scoreTotal+=sr; + } else { + //得分 + double sw = calculateTotalScoreRate(sql2, examMysqlKeywordList, totalKeyScore, score, answerId, scoreTotal); + scoreTotal+=sw; + } } @@ -646,12 +684,13 @@ public class MysqlServericeImpl implements IMysqlServerice { if (entry.getValue().trim().toUpperCase().toUpperCase().contains("TRIGGER")) { appendToFile(answerLogPath, "==================触发器=================="); List examMysqlKeywordList =new ArrayList<>(); + String answerId=null; for (ExamQuestionAnswer examQuestionAnswer : examQuestionAnswers) { if (normalize(examQuestionAnswer.getContent()).equals(normalize(entry.getValue()))) { // 匹配成功 - String answerId = examQuestionAnswer.getAnswerId(); + answerId = examQuestionAnswer.getAnswerId(); examMysqlKeywordList= examMysqlKeywordMapper.selectListByAnswerId(answerId); - + break; } } @@ -675,10 +714,12 @@ public class MysqlServericeImpl implements IMysqlServerice { boolean equals = normalizedTriggerSql1.equals(normalizedTriggerSql2); if (equals) { //todo 得分 - accumulateScoreAndLog(examMysqlKeywordList,total,answerLogPath,sql2,totalKeyScore,score); + double sr= accumulateScoreAndLog(examMysqlKeywordList, total, answerLogPath, sql2, totalKeyScore, score, answerId, scoreTotal); + scoreTotal+=sr; } else { - int scoreAnswerNotAllTrue =calculateTotalScoreRate(sql2, examMysqlKeywordList,totalKeyScore,score); - total.addAndGet(scoreAnswerNotAllTrue); + double sw = calculateTotalScoreRate(sql2, examMysqlKeywordList, totalKeyScore, score, answerId, scoreTotal); + scoreTotal+=sw; + } @@ -698,25 +739,11 @@ public class MysqlServericeImpl implements IMysqlServerice { } } double roundedResult =0.0; - try { - int totalKeyScoreInt = Integer.parseInt(totalKeyScore.trim()); - if (totalKeyScoreInt != 0) { - double result = (total.get() * 1.0 / totalKeyScoreInt) * score; - // 保留两位小数 - // 保留两位小数的 double(四舍五入) - roundedResult = Math.round(result * 100.0) / 100.0; - System.out.println("最终结果是:" + roundedResult); - } else { - System.out.println("除数不能为 0"); - } - } catch (NumberFormatException e) { - System.out.println("无效的 totalKeyScore 值:" + totalKeyScore); - } - appendToFile(answerLogPath, "共得分:"+roundedResult); + appendToFile(answerLogPath, "共得分:"+scoreTotal); folderzip.delete(); deleteFolder(folder); - return roundedResult; + return scoreTotal; } @@ -731,34 +758,66 @@ public class MysqlServericeImpl implements IMysqlServerice { } folder.delete(); // 删除空文件夹或文件 } + //如果这个小题对了,直接累加对应的权值分 + private double accumulateScoreAndLog(List examMysqlKeywordList, AtomicInteger total, String answerLogPath, String sql2, String totalKeyScore, double score,String answerId,double scoreTotal) { + //用answerid查对应答案的权值 。除以总权值 + String scoreRateStr= examQuestionAnswerMapper.selectExamQuestionAnswerScoreByAnswerId(answerId); - private static void accumulateScoreAndLog(List examMysqlKeywordList, AtomicInteger total, String answerLogPath, String sql2, String totalKeyScore, double score) { - AtomicInteger singleTotal = new AtomicInteger(); // 单独累加 scoreRateStr 的总和 - for (ExamMysqlKeyword examMysqlKeyword : examMysqlKeywordList) { - String scoreRateStr = examMysqlKeyword.getScoreRate(); - if (scoreRateStr != null && !scoreRateStr.trim().isEmpty()) { - try { - int scoreAnswerAllTrue = Integer.parseInt(scoreRateStr.trim()); - total.addAndGet(scoreAnswerAllTrue); - - singleTotal.addAndGet(scoreAnswerAllTrue); // 单独累加 - } catch (NumberFormatException e) { - System.err.println("无效的scoreRate值:" + scoreRateStr); - } - } - } + // 解析权值 + double scoreRate = 0.0; + double totalKey = 0.0; + double singleScore = 0.0; try { - int totalKeyScoreInt = Integer.parseInt(totalKeyScore.trim()); - double finalScore = ((double) singleTotal.get() / totalKeyScoreInt) * score; - String formattedScore = String.format("%.1f", finalScore); - appendToFile(answerLogPath, "✅语句" + sql2 + "正确,关键得分权值:" + singleTotal.get() + ",得分" + formattedScore); + scoreRate = Double.parseDouble(scoreRateStr); + totalKey = Double.parseDouble(totalKeyScore); + // 计算该答案对应的得分 + + if (totalKey > 0) { + singleScore = (scoreRate / totalKey) * score; + singleScore = Math.round(singleScore * 100.0) / 100.0; + System.out.println(scoreTotal); + System.out.println(singleScore); + + System.out.println(scoreTotal); + + } + + appendToFile(answerLogPath, "✅语句" + sql2 + "正确,语句得分权值:" + scoreRateStr + ",得分" + singleScore); } catch (NumberFormatException e) { System.err.println("无效的totalKeyScore值:" + totalKeyScore); } + return singleScore; + } - public static int calculateTotalScoreRate(String sql, List examQuestionKeywords, String totalKeyScore, double score) { + public double calculateTotalScoreRate(String sql, List examQuestionKeywords, String totalKeyScore, double score,String answerId,double scoreTotal) { + //用answerid查对应答案的权值 。除以总权值 + String scoreRateStr= examQuestionAnswerMapper.selectExamQuestionAnswerScoreByAnswerId(answerId); + + + + // 解析权值 + double scoreRate = 0.0; + double totalKey = 0.0; + // 计算该答案对应的得分 + double singleScore = 0.0; + try { + scoreRate = Double.parseDouble(scoreRateStr); + totalKey = Double.parseDouble(totalKeyScore); + + if (totalKey > 0) { + singleScore = (scoreRate / totalKey) * score; + singleScore = Math.round(singleScore * 100.0) / 100.0; + } + + + + } catch (NumberFormatException e) { + System.err.println("无效的totalKeyScore值:" + totalKeyScore); + } + + int totalScoreRate = 0; Set matchedKeywords = new HashSet<>(); for (ExamMysqlKeyword keyword : examQuestionKeywords) { @@ -777,11 +836,20 @@ public class MysqlServericeImpl implements IMysqlServerice { } } } - int totalKeyScoreInt = Integer.parseInt(totalKeyScore.trim()); - double finalScore = ((double) totalScoreRate / totalKeyScoreInt) * score; - String formattedScore = String.format("%.1f", finalScore); - appendToFile(answerLogPath,"❌语句"+sql+"不正确,答对得分点为:"+matchedKeywords+"关键得分权值"+ totalScoreRate+ ",得分" + formattedScore); - return totalScoreRate; + //累加答案关键字的所有权值 + int totalKeyScoreInt = examQuestionKeywords.stream() + .map(ExamMysqlKeyword::getScoreRate) + .filter(s -> s != null && !s.isEmpty()) + .mapToInt(Integer::parseInt) + .sum(); + + //乘以 对了多少个 关键字 权值 + double finalRoundedScore = new BigDecimal( + ((double) totalScoreRate / totalKeyScoreInt) * singleScore + ).setScale(2, RoundingMode.HALF_UP).doubleValue(); + + appendToFile(answerLogPath,"❌语句"+sql+"不正确,语句权值:"+scoreRateStr+",关键权值:"+totalKeyScoreInt+",答对得分点为:"+matchedKeywords+",答对关键得分权值"+ totalScoreRate+ ",得分" + finalRoundedScore); + return finalRoundedScore; } // 预处理函数:去除空格和换行并转为大写 @@ -1033,21 +1101,26 @@ public class MysqlServericeImpl implements IMysqlServerice { */ private static void printResult(List> result) { if (result.isEmpty()) { - appendToFile(answerLogPath,"查询结果为空"); + appendToFile(answerLogPath, "查询结果为空"); } else { - // 打印每一行数据 for (int i = 0; i < result.size(); i++) { List row = result.get(i); - if (i == 0) { // 打印列名 - appendToFile(answerLogPath,"列名:"); + StringBuilder sb = new StringBuilder(); + + if (i == 0) { + sb.append("列名:"); } + for (String value : row) { - appendToFile(answerLogPath,value + "\t"); + sb.append(value).append("\t"); } - System.out.println(); + + // 输出整行 + appendToFile(answerLogPath, sb.toString()); } } } + /** * 使用提供的正则表达式模式从给定的 SQL 语句中提取视图名称。 */ @@ -1250,7 +1323,9 @@ public class MysqlServericeImpl implements IMysqlServerice { */ public static void appendToFile(String filePath, String content) { try (BufferedWriter writer = new BufferedWriter(new FileWriter(filePath, true))) { - writer.write(content); + String timestamp = LocalDateTime.now().format(formatter); + String logLine = String.format("[%s] %s", timestamp, content); + writer.write(logLine); writer.newLine(); // 可选:添加换行符 } catch (IOException e) { e.printStackTrace();
1