From cb2097ed204858c4f3486c1a6949a5678e6f9b06 Mon Sep 17 00:00:00 2001 From: "YOHO\\20373" <2037305722@qq.com> Date: Tue, 10 Jun 2025 17:16:34 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E4=BF=AE=E6=94=B9=E3=80=91=E8=AF=95?= =?UTF-8?q?=E9=A2=98=E5=AF=BC=E5=85=A5=E7=94=B1=E5=90=8D=E7=A7=B0=E6=94=B9?= =?UTF-8?q?=E4=B8=BAid?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../question/ExamQuestionController.java | 7 +- .../admin/question/dto/TenantDto.java | 2 + .../mysql/question/ExamQuestionMapper.java | 74 +++++++++++++++++-- .../mysql/specialty/ExamSpecialtyMapper.java | 6 ++ .../question/ExamQuestionServiceImpl.java | 33 +++++++-- .../mapper/specialty/ExamSpecialtyMapper.xml | 27 ++++++- .../system/enums/ErrorCodeConstants.java | 1 + 7 files changed, 132 insertions(+), 18 deletions(-) diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/question/ExamQuestionController.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/question/ExamQuestionController.java index 87621940..b14655d1 100644 --- a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/question/ExamQuestionController.java +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/question/ExamQuestionController.java @@ -188,7 +188,7 @@ public class ExamQuestionController public CommonResult importExcel(@RequestParam("file") MultipartFile file, @RequestParam(value = "updateSupport", required = false, defaultValue = "false") Boolean updateSupport) throws Exception { List list = ExcelUtils.read(file, QuemportExcelVO.class); - System.out.println(list); +// System.out.println(list); return success(examQuestionService.importUserList(list, updateSupport)); } @@ -197,10 +197,9 @@ public class ExamQuestionController public void importTemplate(HttpServletResponse response) throws IOException { // 手动创建导出 demo List list = Arrays.asList( - QuemportExcelVO.builder().chapteridDictText("章节一").specialtyName("计算机专业").courseName("计算机基础") + QuemportExcelVO.builder().specialtyName("计算机专业").courseName("计算机基础") .subjectName("选择题").quLevel("0、简单 1、一般 2、困难").analysis("解析").content("试题内容") - .pointNames("知识点").keywords("").a("内容").b("内容").c("内容").d("内容").answer("A").build() - ); + .chapteridDictText("第一章").pointNames("知识点").keywords("").a("内容").b("内容").c("内容").d("内容").answer("A").build()); // 输出 ExcelUtils.write(response, "试题导入模板.xls", "试题列表", QuemportExcelVO.class, list); } diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/question/dto/TenantDto.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/question/dto/TenantDto.java index 0af029ef..0e5ab9f4 100644 --- a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/question/dto/TenantDto.java +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/question/dto/TenantDto.java @@ -30,6 +30,8 @@ public class TenantDto { @Min(value = 1, message = "每页条数最小值为 1") @Max(value = 100, message = "每页条数最大值为 100") private Integer pageSize = PAGE_SIZE; + private Integer offset; + public Integer getOffset() { return (this.pageNo - 1) * this.pageSize; } diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/mysql/question/ExamQuestionMapper.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/mysql/question/ExamQuestionMapper.java index 4cd277ac..b030dba1 100644 --- a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/mysql/question/ExamQuestionMapper.java +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/mysql/question/ExamQuestionMapper.java @@ -102,46 +102,108 @@ public interface ExamQuestionMapper extends BaseMapperX */ public int deleteExamQuestionByQuIds(@Param("ids") String[] ids); + /** + * 批量查找试题 + * @param quIds + * @return + */ List selectExamQuestionListByQuIds(List quIds); + /** + * 批量审核试题 + * @param quIds + */ void setQuestionAuditByids(@Param("quIds")List quIds); - + /** + * 查找学校集合(带分页) + * @return + */ List getSchoolName(TenantDto tenantDto); long getSchoolNameTotal(TenantDto tenantDto); int auditQueByIds(@Param("quIds")List quIds,@Param("updater") String loginUserNickname); - + /** + * 批量审核试题 + * @param quIds + */ int noAuditQue(@Param("quIds")List quIds); - + /** + * 根据试题id和租户id查找 试题 + * @param quId + * @param source + * @return + */ ExamQuestion selectExamQuestionByQuIdAndTenantId(@Param("quId") String quId, @Param("source")Long source); + /** + * 查找所有的mqtt通道 + * @return + */ List seleAllQueueName(); - + /** + * 更改试题审核的审核人和审核时间 + * @param loginUserNickname + * @param quIds + */ void updateExamQuestionByIds(@Param("updater") String loginUserNickname, @Param("quIds") List quIds); + /** + * 根据id查找试题 + * @param quId + * @return + */ ExamQuestion selectExamQuestionCountByQuId(String quId); + /** + * 查找学校集合 + * @return + */ List getSchoolNameNaPage(); long selectTenantId(); - + /** + * 根据专业、课程、题型、试题内容查找 相同的试题 + * @param specialtyName 专业 + * @param courseName 课程 + * @param subjectName 题型 + * @param content 试题内容 + * @return + */ ExamQuestion selectByTypes(@Param("specialtyName")String specialtyName ,@Param("courseName") String courseName ,@Param("subjectName") String subjectName ,@Param("content") String content); + /** + * 根据id查询学校名称 + * @param loginTenantId + * @return + */ String selectSchoolnameBytId(Long loginTenantId); + /** + * 批量插入或更新试题 + * @param examQuestions + */ void insertOrUpdateList(List examQuestions); - + /** + * 更改试题状态 + * @param quId + * @param status + * @return + */ boolean changeStatus(@Param("quId") String quId ,@Param("status") String status); + /** + * 查找试题表的试题数量 + * @return + */ int selectCountQu(); } diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/mysql/specialty/ExamSpecialtyMapper.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/mysql/specialty/ExamSpecialtyMapper.java index ea770423..d08a359a 100644 --- a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/mysql/specialty/ExamSpecialtyMapper.java +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/mysql/specialty/ExamSpecialtyMapper.java @@ -4,6 +4,7 @@ import org.apache.ibatis.annotations.Param; import pc.exam.pp.framework.mybatis.core.mapper.BaseMapperX; import pc.exam.pp.module.exam.controller.admin.specialty.vo.SpecialtListReqVo; import pc.exam.pp.module.exam.controller.admin.specialty.vo.SpecialtyQueryVo; +import pc.exam.pp.module.exam.dal.dataobject.knowledge.ExamKnowledgePoints; import pc.exam.pp.module.exam.dal.dataobject.specialty.ExamSpecialty; import java.util.List; @@ -108,4 +109,9 @@ public interface ExamSpecialtyMapper extends BaseMapperX ExamSpecialty selectBySpecCourseSub(@Param("specialtyName") String specialtyName ,@Param("courseName") String courseName ,@Param("subjectName") String subjectName); + + ExamKnowledgePoints selectByPointsSub(@Param("specialtyName") String specialtyName + , @Param("chapteridDictText")String chapteridDictText + , @Param("pointNames") String pointNames); + } 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 8e1ff240..4d5163db 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 @@ -219,6 +219,7 @@ public class ExamQuestionServiceImpl implements IExamQuestionService * @return 结果 */ @Override + @Transactional(rollbackFor = Exception.class) // 所有异常都回滚 public int updateExamQuestion(ExamQuestion examQuestion) { @@ -229,9 +230,9 @@ public class ExamQuestionServiceImpl implements IExamQuestionService List excludedSubjects = Arrays.asList("程序设计", "网络题", "文件处理"); //这三种题型的考点,在考点设置就已经做好,不需要在题目层更新 if (!excludedSubjects.contains(examQuestion.getSubjectName())) { + //先删除试题的答案 + examQuestionAnswerMapper.deleteExamQuestionAnswerByQuesId(examQuestion.getQuId()); if (answerList!=null&&answerList.size()>0){ - //先删除试题的答案 - examQuestionAnswerMapper.deleteExamQuestionAnswerByQuesId(examQuestion.getQuId()); //赋值 answerList.replaceAll(answer -> { answer.setAnswerId(IdUtils.simpleUUID()); @@ -243,10 +244,10 @@ public class ExamQuestionServiceImpl implements IExamQuestionService } } - + //先删除试题的文件 + sysFileMapper.deleteSysFileByQuesId(examQuestion.getQuId()); if (fileUploads!=null&&fileUploads.size()>0){ - //先删除试题的答案 - sysFileMapper.deleteSysFileByQuesId(examQuestion.getQuId()); + //赋值 fileUploads.replaceAll(fileUpload -> { // 设置文件名(如果文件名为空) @@ -284,9 +285,9 @@ public class ExamQuestionServiceImpl implements IExamQuestionService questionScore.setQuId(examQuestion.getQuId()); examQuestionScoreMapper.insertExamQuestionScore(questionScore); } + //先删除试题的判分 + examQuestionKeywordMapper.deleteExamQuestionScoreByQuesId(examQuestion.getQuId()); if (examQuestionKeywords!=null&&examQuestionKeywords.size()>0){ - //先删除试题的判分 - examQuestionKeywordMapper.deleteExamQuestionScoreByQuesId(examQuestion.getQuId()); //赋值 examQuestionKeywords.replaceAll(examQuestionKeyword -> { examQuestionKeyword.setKeywordId(IdUtils.simpleUUID()); @@ -543,6 +544,7 @@ public class ExamQuestionServiceImpl implements IExamQuestionService @Override public PageResult getSchoolName(TenantDto tenantDto) { + tenantDto.setOffset(tenantDto.getOffset()); List schoolName = examQuestionMapper.getSchoolName(tenantDto); long total = examQuestionMapper.getSchoolNameTotal(tenantDto); PageResult pageResult=new PageResult<>(); @@ -760,6 +762,8 @@ public class ExamQuestionServiceImpl implements IExamQuestionService try { //校验 是否有 专业课程题型 validateQueForCreateOrUpdate(importUser.getSpecialtyName(), importUser.getCourseName(),importUser.getSubjectName()); + //检验是否有章节 知识点 + validatePointsForCreateOrUpdate(importUser.getSpecialtyName(),importUser.getChapteridDictText(),importUser.getPointNames(),importUser); //校验 选项 validateChoice(importUser.getA(),importUser.getB(),importUser.getC(),importUser.getD(),importUser.getAnswer()); @@ -988,6 +992,21 @@ public class ExamQuestionServiceImpl implements IExamQuestionService } + private void validatePointsForCreateOrUpdate(String specialtyName,String chapteridDictText, String pointNames,QuemportExcelVO quemportExcelVO) { + validateSpecPointsSub(specialtyName,chapteridDictText,pointNames,quemportExcelVO); + } + + @VisibleForTesting + void validateSpecPointsSub(String specialtyName,String chapteridDictText, String pointNames,QuemportExcelVO quemportExcelVO) { + + ExamKnowledgePoints examKnowledgePoints= examSpecialtyMapper.selectByPointsSub(specialtyName,chapteridDictText,pointNames); + if (examKnowledgePoints==null){ + throw exception(QESESTION_TYPE_POINTS_ERROR); + }else { + quemportExcelVO.setPointNames(String.valueOf(examKnowledgePoints.getSpId())); + quemportExcelVO.setChapteridDictText(String.valueOf(examKnowledgePoints.getParentId())); + } + } @VisibleForTesting void validateSpecCourseSub(String specialtyName, String courseName, String subjectName) { diff --git a/exam-module-exam/exam-module-exam-biz/src/main/resources/mapper/specialty/ExamSpecialtyMapper.xml b/exam-module-exam/exam-module-exam-biz/src/main/resources/mapper/specialty/ExamSpecialtyMapper.xml index 45016730..2e8b3379 100644 --- a/exam-module-exam/exam-module-exam-biz/src/main/resources/mapper/specialty/ExamSpecialtyMapper.xml +++ b/exam-module-exam/exam-module-exam-biz/src/main/resources/mapper/specialty/ExamSpecialtyMapper.xml @@ -16,6 +16,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + + + + + + + + + select sp_id, parent_id, ancestors, sp_name, order_num, status, creator, create_time, updater, update_time, unite, tree_num, roles,tenant_id from exam_specialty @@ -111,8 +120,24 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" AND q3.sp_name = #{subjectName} AND q1.deleted = '0' AND q2.deleted = '0' - AND q3.deleted = '0'; + AND q3.deleted = '0' + LIMIT 1; + + update exam_specialty diff --git a/exam-module-system/exam-module-system-api/src/main/java/pc/exam/pp/module/system/enums/ErrorCodeConstants.java b/exam-module-system/exam-module-system-api/src/main/java/pc/exam/pp/module/system/enums/ErrorCodeConstants.java index e3db8368..51b9c7f6 100644 --- a/exam-module-system/exam-module-system-api/src/main/java/pc/exam/pp/module/system/enums/ErrorCodeConstants.java +++ b/exam-module-system/exam-module-system-api/src/main/java/pc/exam/pp/module/system/enums/ErrorCodeConstants.java @@ -210,6 +210,7 @@ public interface ErrorCodeConstants { ErrorCode QESESTION_NOT_NULL = new ErrorCode(1_008_008_012, "审核试题不能为空"); ErrorCode QESESTION_AUDIT_ERROR = new ErrorCode(1_008_008_022, "操作试题失败"); ErrorCode QESESTION_TYPE_ERROR = new ErrorCode(1_008_009_023, "没有对应的专业课程题型"); + ErrorCode QESESTION_TYPE_POINTS_ERROR = new ErrorCode(1_008_009_023, "没有对应的章节知识点"); ErrorCode QESESTION_CHOICEAB_ERROR = new ErrorCode(1_008_010_024, "选项 A 和 B 为必填项"); ErrorCode QESESTION_CHOICE_ERROR = new ErrorCode(1_008_010_024, "答案不在有效选项范围内"); // ========== rabbit ==========