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 b14655d1..165b5c94 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 @@ -24,10 +24,7 @@ import pc.exam.pp.module.exam.controller.admin.paper.dto.StatusDto; import pc.exam.pp.module.exam.controller.admin.question.dto.ExamQuestionDto; import pc.exam.pp.module.exam.controller.admin.question.dto.QuStatusDto; import pc.exam.pp.module.exam.controller.admin.question.dto.TenantDto; -import pc.exam.pp.module.exam.controller.admin.question.vo.QueImportRespVO; -import pc.exam.pp.module.exam.controller.admin.question.vo.QuemportExcelVO; -import pc.exam.pp.module.exam.controller.admin.question.vo.QuestionVo; -import pc.exam.pp.module.exam.controller.admin.question.vo.TenantVo; +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.dal.dataobject.EducationPaperTask; import pc.exam.pp.module.exam.dal.dataobject.ExamQuestion; @@ -45,16 +42,15 @@ import static pc.exam.pp.module.system.enums.ErrorCodeConstants.QESESTION_AUDIT_ /** * 试题(hyc)Controller - * + * * @author pengchen * @date 2025-03-13 */ @RestController @RequestMapping("/exam/question") -@Tag( name = "试题管理接口") +@Tag(name = "试题管理接口") @Validated -public class ExamQuestionController -{ +public class ExamQuestionController { @Resource private IExamQuestionService examQuestionService; @@ -63,30 +59,30 @@ public class ExamQuestionController */ //@PreAuthorize("@ss.hasPermi('system:question:list')") @GetMapping("/list") - public CommonResult> list(QuestionVo questionVo) - { + public CommonResult> list(QuestionVo questionVo) { PageResult pageResult = examQuestionService.selectExamQuestionList(questionVo); return success(pageResult); } + @GetMapping("/listAnswer") - public CommonResult> listAnswer(QuestionVo questionVo) - { + public CommonResult> listAnswer(QuestionVo questionVo) { PageResult pageResult = examQuestionService.selectExamQuestionListAnswer(questionVo); return success(pageResult); } + /** * 查询除了审核状态通过的其他状态的试题(试题推送) + * * @param questionVo * @return */ @GetMapping("/sendList") - public CommonResult> sendList(QuestionVo questionVo) - { + public CommonResult> sendList(QuestionVo questionVo) { PageResult pageResult; - if (StringUtils.isNotBlank(questionVo.getAudit())){ - pageResult= examQuestionService.selectExamQuestionList(questionVo); - }else { - pageResult = examQuestionService.selectExamQuestionListSend(questionVo); + if (StringUtils.isNotBlank(questionVo.getAudit())) { + pageResult = examQuestionService.selectExamQuestionList(questionVo); + } else { + pageResult = examQuestionService.selectExamQuestionListSend(questionVo); } return success(pageResult); @@ -94,14 +90,14 @@ public class ExamQuestionController /** * 查询试题(试题审核) + * * @return */ @GetMapping("/auditList") @TenantIgnore - public CommonResult> auditList(@Valid QuestionExaminePageReqVO pageReqVO) - { + public CommonResult> auditList(@Valid QuestionExaminePageReqVO pageReqVO) { - PageResult pageResult= examQuestionService.selectExamQuestionListNoAudit(pageReqVO); + PageResult pageResult = examQuestionService.selectExamQuestionListNoAudit(pageReqVO); // pageResult= examQuestionService.selectExamQuestionListAudit(pageReqVO); @@ -126,27 +122,26 @@ public class ExamQuestionController */ //@PreAuthorize("@ss.hasPermi('system:question:query')") @GetMapping(value = "/{quId}") - public CommonResult getInfo(@PathVariable("quId") String quId) - { + public CommonResult getInfo(@PathVariable("quId") String quId) { return success(examQuestionService.selectExamQuestionByQuId(quId)); } + /** * 获取试题(hyc)详细信息 无租户id */ //@PreAu @GetMapping(value = "/notId/{quId}") @TenantIgnore - public CommonResult getInfoNotId(@PathVariable("quId") String quId) - { + public CommonResult getInfoNotId(@PathVariable("quId") String quId) { return success(examQuestionService.selectExamQuestionByQuId(quId)); } + /** * 新增试题(hyc) */ //@PreAuthorize("@ss.hasPermi('system:question:add')") @PostMapping - public CommonResult add(@RequestBody ExamQuestion examQuestion) - { + public CommonResult add(@RequestBody ExamQuestion examQuestion) { return success(examQuestionService.insertExamQuestion(examQuestion)); } @@ -155,9 +150,8 @@ public class ExamQuestionController * 修改试题(hyc) */ @PutMapping - public CommonResult edit(@RequestBody ExamQuestion examQuestion) - { - return success(examQuestionService.updateExamQuestion(examQuestion)); + public CommonResult edit(@RequestBody ExamQuestion examQuestion) { + return success(examQuestionService.updateExamQuestion(examQuestion)); } @@ -166,16 +160,15 @@ public class ExamQuestionController */ @PutMapping("/NoAudit") @TenantIgnore - public CommonResult editNoAudit(@RequestBody ExamQuestion examQuestion) - { + public CommonResult editNoAudit(@RequestBody ExamQuestion examQuestion) { return success(examQuestionService.updateExamQuestion(examQuestion)); } + /** * 删除试题(hyc) */ @DeleteMapping("/{ids}") - public CommonResult remove(@PathVariable String[] ids) - { + public CommonResult remove(@PathVariable String[] ids) { return success(examQuestionService.deleteExamQuestionByQuIds(ids)); } @@ -206,28 +199,30 @@ public class ExamQuestionController /** - *获得学校分页列表 + * 获得学校分页列表 + * * @return */ @GetMapping("/getSchoolName") @TenantIgnore - public CommonResult> getSchoolName(TenantDto tenantDto) - { + public CommonResult> getSchoolName(TenantDto tenantDto) { return success(examQuestionService.getSchoolName(tenantDto)); } + /** - *获得学校分页列表(不分页) + * 获得学校分页列表(不分页) + * * @return */ @GetMapping("/getSchoolNameNopage") @TenantIgnore - public CommonResult> getSchoolNameNaPage() - { + public CommonResult> getSchoolNameNaPage() { return success(examQuestionService.getSchoolNameNaPage()); } /** * 服务端审核通过试题 + * * @param quIds * @return */ @@ -238,17 +233,18 @@ public class ExamQuestionController return CommonResult.error(QESESTION_NOT_NULL); } int b = examQuestionService.auditQueByIds(quIds); - if (b>0){ + if (b > 0) { return success("审核成功"); - } - else { + } else { return error(QESESTION_AUDIT_ERROR); } } + /** * 服务端审核不通过试题 + * * @param quIds * @return */ @@ -259,16 +255,17 @@ public class ExamQuestionController return CommonResult.error(QESESTION_NOT_NULL); } int b = examQuestionService.noAuditQue(quIds); - if (b>0){ + if (b > 0) { return success("操作成功"); - }else { + } else { return error(QESESTION_AUDIT_ERROR); } } /** * 更改试题状态 + * * @param quStatusDto * @return */ @@ -280,7 +277,13 @@ public class ExamQuestionController } - + /** + * 审核试题 + */ + @PostMapping("/auditQuestion") + public CommonResult audit(@RequestBody AudioQuestionVo audioQuestionVo) { + return CommonResult.success(examQuestionService.auditQuestion(audioQuestionVo)); + } } diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/question/vo/AudioQuestionVo.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/question/vo/AudioQuestionVo.java new file mode 100644 index 00000000..0fdcf8e0 --- /dev/null +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/question/vo/AudioQuestionVo.java @@ -0,0 +1,11 @@ +package pc.exam.pp.module.exam.controller.admin.question.vo; + +import lombok.Data; + +import java.util.List; + +@Data +public class AudioQuestionVo{ + private String type; + private List quIds; +} diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/rabbitmq/RabbitMQController.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/rabbitmq/RabbitMQController.java index d166deaf..3a35a1a9 100644 --- a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/rabbitmq/RabbitMQController.java +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/rabbitmq/RabbitMQController.java @@ -10,6 +10,7 @@ import pc.exam.pp.framework.common.pojo.CommonResult; 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.service.TenantFrameworkService; +import pc.exam.pp.module.exam.controller.admin.rabbitmq.vo.PushAudioRequestVo; import pc.exam.pp.module.exam.controller.admin.rabbitmq.vo.PushRequestVo; import pc.exam.pp.module.exam.controller.admin.rabbitmq.vo.RabbitMQSendInfoVO; import pc.exam.pp.module.exam.dal.dataobject.ExamQuestion; @@ -26,7 +27,7 @@ import static pc.exam.pp.module.system.enums.ErrorCodeConstants.RABBITMQ_CONNECT @RestController @RequestMapping("/rabbitmq") -@Tag( name = "rabbitmq 消息队列") +@Tag(name = "rabbitmq 消息队列") public class RabbitMQController { @Resource @@ -37,26 +38,28 @@ public class RabbitMQController { /** * 连接Rabbitmq + * * @return 连接状态 */ @PostMapping("/connect") // public String connect(@RequestParam String queueName) { - public CommonResult connect() { + public CommonResult connect() { String queueName = SecurityFrameworkUtils.getLoginQueueName(); int connect = rabbitMqService.connect(queueName); - if (connect == 0 ){ + if (connect == 0) { return CommonResult.success("已经连接"); } - if (connect ==1){ + if (connect == 1) { return CommonResult.success("连接成功"); } - return CommonResult.error(RABBITMQ_CONNECT_EXISTS); + return CommonResult.error(RABBITMQ_CONNECT_EXISTS); } /** * 判断是否连接 + * * @return 连接状态 */ @GetMapping("/isConnected") @@ -65,34 +68,43 @@ public class RabbitMQController { } /** - * 发送消息 - * @param rabbitMQSendInfoVO 对象 + * 发送消息(考点服务器-中心服务器审核试题) + * + * @param request 对象 * @return 发送状态 */ - @PostMapping("/send") - public int sendMessage(@RequestBody RabbitMQSendInfoVO rabbitMQSendInfoVO) { - rabbitMQSendInfoVO.setQueueName(SecurityFrameworkUtils.getLoginQueueName()); - return examQuestionService.uploadExamQuestionToRabbitMQ(rabbitMQSendInfoVO); + @PostMapping("/sendAudio") + public CommonResult sendMessage(@RequestBody PushAudioRequestVo request) { + String queueNames = request.getQueueNames(); + List questionIds = request.getQuestionIds(); + RabbitMQSendInfoVO rabbitMQSendInfoVO = new RabbitMQSendInfoVO(); + rabbitMQSendInfoVO.setType(request.getType()); + rabbitMQSendInfoVO.setQuIds(questionIds); + rabbitMQSendInfoVO.setQueueName(queueNames); + examQuestionService.uploadExamQuestionToRabbitMQBySource(rabbitMQSendInfoVO); + return CommonResult.success("推送成功"); } /** * 全部接收消息(学校中心或服务器接收中心服务器推送的试题) - 队列名称-客户端代码 + * 队列名称-客户端代码 + * * @return 接收结果 */ @GetMapping("/receiveAll") public CommonResult receiveMessage() { String queueName = SecurityFrameworkUtils.getLoginQueueName(); boolean examQuestionToRabbitMQ = examQuestionService.getExamQuestionToRabbitMQInsertData(queueName); - if (examQuestionToRabbitMQ){ + if (examQuestionToRabbitMQ) { return CommonResult.success("接收成功"); - }else { + } else { return CommonResult.error(RABBITMQ_NOT_EXISTS); } } /** * 服务器连接学校 + * * @param queueNames * @return */ @@ -104,7 +116,7 @@ public class RabbitMQController { List failedQueues = new ArrayList<>(); for (String queueName : queueNames) { - boolean examQuestionToRabbitMQ = rabbitMqService.connectSchool(queueName); + boolean examQuestionToRabbitMQ = rabbitMqService.connectSchool(queueName); if (!examQuestionToRabbitMQ) { failedQueues.add(queueName); } @@ -113,12 +125,14 @@ public class RabbitMQController { if (failedQueues.isEmpty()) { return CommonResult.success("全部连接成功"); } else { - return CommonResult.error(1_005_005_023,"以下学校全部连接失败:" + String.join(", ", failedQueues)); + return CommonResult.error(1_005_005_023, "以下学校全部连接失败:" + String.join(", ", failedQueues)); } } + /** * 接收学校的试题 + * * @param queueNames * @return */ @@ -139,7 +153,7 @@ public class RabbitMQController { if (failedQueues.isEmpty()) { return CommonResult.success("全部接收成功"); } else { - return CommonResult.error(1_005_005_023,"以下学校接收失败:" + String.join(", ", failedQueues)); + return CommonResult.error(1_005_005_023, "以下学校接收失败:" + String.join(", ", failedQueues)); } @@ -147,6 +161,7 @@ public class RabbitMQController { /** * 服务器推送学校试题 到mqtt + * * @param request * @return */ @@ -155,22 +170,20 @@ public class RabbitMQController { public CommonResult doPush(@RequestBody PushRequestVo request) { List queueNames = request.getQueueNames(); List questionIds = request.getQuestionIds(); - System.out.println(queueNames); - System.out.println(questionIds); for (String queueName : queueNames) { - RabbitMQSendInfoVO rabbitMQSendInfoVO=new RabbitMQSendInfoVO(); + RabbitMQSendInfoVO rabbitMQSendInfoVO = new RabbitMQSendInfoVO(); rabbitMQSendInfoVO.setType("0"); rabbitMQSendInfoVO.setQuIds(questionIds); rabbitMQSendInfoVO.setQueueName(queueName); - examQuestionService.uploadExamQuestionToRabbitMQBySource(rabbitMQSendInfoVO); + examQuestionService.uploadExamQuestionToRabbitMQBySource(rabbitMQSendInfoVO); } - return CommonResult.success("推送成功"); } /** * 关闭 + * * @return 关闭结果 */ @GetMapping("/disconnect") diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/rabbitmq/vo/PushAudioRequestVo.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/rabbitmq/vo/PushAudioRequestVo.java new file mode 100644 index 00000000..467d170a --- /dev/null +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/rabbitmq/vo/PushAudioRequestVo.java @@ -0,0 +1,13 @@ +package pc.exam.pp.module.exam.controller.admin.rabbitmq.vo; + +import lombok.Data; + +import java.util.List; + +@Data +public class PushAudioRequestVo { + // 类型 + private String type; + private String queueNames; + private List questionIds; +} diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/rabbitmq/vo/PushRequestVo.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/rabbitmq/vo/PushRequestVo.java index b62e47c0..08683aab 100644 --- a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/rabbitmq/vo/PushRequestVo.java +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/rabbitmq/vo/PushRequestVo.java @@ -6,6 +6,8 @@ import java.util.List; @Data public class PushRequestVo { + // 类型 + private String type; private List queueNames; private List questionIds; } 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 aecc2a3c..9e5ddf39 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 @@ -12,7 +12,7 @@ import java.util.List; /** * 试题(hyc)对象 exam_question - * + * * @author pengchen * @date 2025-03-13 */ @@ -24,99 +24,143 @@ import java.util.List; public class ExamQuestion extends TenantBaseDO { - /** 试题id */ + /** + * 试题id + */ @TableId private String quId; - /** 题库id */ + /** + * 题库id + */ // @Excel(name = "题库id") - private String quBankId; + private String quBankId; - /** 题库名称 */ + /** + * 题库名称 + */ // @Excel(name = "题库名称") private String quBankName; - private String quNum; + private String quNum; - /** 章节名称 */ + /** + * 章节名称 + */ // @Excel(name = "章节名称") private String chapteridDictText; @TableField(exist = false) private String chapteridDictTextVo; - /** 题型名称 */ + /** + * 题型名称 + */ // @Excel(name = "题型名称") private String subjectName; - /** 题型难度(0:简单,1:一般,2:困难) */ + /** + * 题型难度(0:简单,1:一般,2:困难) + */ // @Excel(name = "题型难度(0:简单,1:一般,2:困难)") private Integer quLevel; - /** 试题内容(带样式:

下列表格123

\n\n\n\n\) */ + /** + * 试题内容(带样式:

下列表格123

\n
1
\n\n\n\) + */ // @Excel(name = "试题内容") private String content; - /** 试题内容(纯文本) */ + /** + * 试题内容(纯文本) + */ // @Excel(name = "试题内容(纯文本)") private String contentText; - /** 解析(带样式) */ + /** + * 解析(带样式) + */ // @Excel(name = "解析(带样式)") private String analysis; - /**c语言参考答案*/ - private String answer; + /** + * c语言参考答案 + */ + private String answer; - /** 知识点 */ + /** + * 知识点 + */ // @Excel(name = "知识点") private String pointNames; @TableField(exist = false) private String pointNamesVo; - /** 关键字 */ + /** + * 关键字 + */ // @Excel(name = "关键字") private String keywords; - /** 是否人工(0否1是,简答题专用) */ + /** + * 是否人工(0否1是,简答题专用) + */ // @Excel(name = "是否人工,0=否1是,简答题专用") private String manual; - /** 状态(0启用,1禁用) */ + /** + * 状态(0启用,1禁用) + */ // @Excel(name = "状态(0启用,1禁用)") - private String status; + private String status; - /** 审核 */ + /** + * 审核 + */ // @Excel(name = "审核") - private String audit; + private String audit; - /** 课程类别 */ + /** + * 课程类别 + */ // @Excel(name = "课程类别") private String courseName; - /** 专业分类 */ + /** + * 专业分类 + */ // @Excel(name = "专业分类") - private String specialtyName; - /** 数据库名 */ + private String specialtyName; + /** + * 数据库名 + */ private String tname; - /** 试题答案 */ + /** + * 试题答案 + */ // @Excel(name = "试题答案") @TableField(exist = false) - private List answerList; - - /** 试题文件 */ + private List answerList; + + /** + * 试题文件 + */ // @Excel(name = "试题文件") @TableField(exist = false) - private List fileUploads; - - /** 试题判分 */ + private List fileUploads; + + /** + * 试题判分 + */ // @Excel(name = "试题判分") @TableField(exist = false) private ExamQuestionScore questionScores; - /** 试题关键字 */ + /** + * 试题关键字 + */ // @Excel(name = "试题关键字") @TableField(exist = false) private List questionKeywords; @@ -129,14 +173,27 @@ public class ExamQuestion extends TenantBaseDO { @TableField(exist = false) private String type; + @TableField(exist = false) private String schoolName; - /** 每题分数 */ + /** + * 每题分数 + */ @TableField(exist = false) private String quScores; - /** 排序 */ + /** + * 排序 + */ @TableField(exist = false) private int sort; + // 学校ID + private String schoolId; + + /** + * 推送试题类型(0:中心服务器-考点服务器:试题无需审核、1:考点服务器-中心服务器:试题审核) + */ + @TableField(exist = false) + private String questionType; } 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 7463c4d2..0a9a0091 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 @@ -5,29 +5,24 @@ import org.apache.ibatis.annotations.Param; import pc.exam.pp.framework.common.pojo.PageResult; import pc.exam.pp.framework.mybatis.core.mapper.BaseMapperX; import pc.exam.pp.framework.mybatis.core.query.LambdaQueryWrapperX; -import pc.exam.pp.module.exam.controller.admin.paper.vo.PaperTaskPageVo; -import pc.exam.pp.module.exam.controller.admin.question.dto.ExamQuestionDto; import pc.exam.pp.module.exam.controller.admin.question.dto.TenantDto; import pc.exam.pp.module.exam.controller.admin.question.vo.QuestionVo; import pc.exam.pp.module.exam.controller.admin.question.vo.TenantVo; -import pc.exam.pp.module.exam.dal.dataobject.EducationPaperTask; import pc.exam.pp.module.exam.dal.dataobject.ExamQuestion; -import pc.exam.pp.module.exam.dal.dataobject.monitor.MonitorDO; import java.util.List; /** * 试题(hyc)Mapper接口 - * + * * @author pengchen * @date 2025-03-13 */ @Mapper -public interface ExamQuestionMapper extends BaseMapperX -{ +public interface ExamQuestionMapper extends BaseMapperX { /** * 查询试题(hyc) - * + * * @param quId 试题(hyc)主键 * @return 试题(hyc) */ @@ -35,20 +30,20 @@ public interface ExamQuestionMapper extends BaseMapperX /** * 查询试题(hyc)列表 - * + * * @return 试题(hyc)集合 */ default PageResult selectExamQuestionList(QuestionVo questionVo) { return selectPage(questionVo, new LambdaQueryWrapperX() .likeIfPresent(ExamQuestion::getQuNum, questionVo.getQuNum()) .likeIfPresent(ExamQuestion::getContent, questionVo.getContent()) - .likeIfPresent(ExamQuestion::getQuId,questionVo.getQuId()) - .likeIfPresent(ExamQuestion::getKeywords,questionVo.getKeywords()) + .likeIfPresent(ExamQuestion::getQuId, questionVo.getQuId()) + .likeIfPresent(ExamQuestion::getKeywords, questionVo.getKeywords()) .likeIfPresent(ExamQuestion::getQuLevel, questionVo.getQuLevel()) - .likeIfPresent(ExamQuestion::getCourseName , questionVo.getCourseName()) - .likeIfPresent(ExamQuestion::getPointNames , questionVo.getPointNames()) - .likeIfPresent(ExamQuestion::getSpecialtyName , questionVo.getSpecialtyName()) - .likeIfPresent(ExamQuestion::getSubjectName , questionVo.getSubjectName()) + .likeIfPresent(ExamQuestion::getCourseName, questionVo.getCourseName()) + .likeIfPresent(ExamQuestion::getPointNames, questionVo.getPointNames()) + .likeIfPresent(ExamQuestion::getSpecialtyName, questionVo.getSpecialtyName()) + .likeIfPresent(ExamQuestion::getSubjectName, questionVo.getSubjectName()) .likeIfPresent(ExamQuestion::getStatus, questionVo.getStatus()) .likeIfPresent(ExamQuestion::getAudit, questionVo.getAudit()) .orderByDesc(ExamQuestion::getCreateTime) @@ -57,6 +52,7 @@ public interface ExamQuestionMapper extends BaseMapperX /** * 查询除了审核状态为通过的其他试题 + * * @param questionVo * @return */ @@ -74,7 +70,7 @@ public interface ExamQuestionMapper extends BaseMapperX /** * 新增试题(hyc) - * + * * @param examQuestion 试题(hyc) * @return 结果 */ @@ -82,7 +78,7 @@ public interface ExamQuestionMapper extends BaseMapperX /** * 修改试题(hyc) - * + * * @param examQuestion 试题(hyc) * @return 结果 */ @@ -90,7 +86,7 @@ public interface ExamQuestionMapper extends BaseMapperX /** * 删除试题(hyc) - * + * * @param quId 试题(hyc)主键 * @return 结果 */ @@ -98,7 +94,7 @@ public interface ExamQuestionMapper extends BaseMapperX /** * 批量删除试题(hyc) - * + * * @param ids 需要删除的数据主键集合 * @return 结果 */ @@ -106,6 +102,7 @@ public interface ExamQuestionMapper extends BaseMapperX /** * 批量查找试题 + * * @param quIds * @return */ @@ -113,41 +110,54 @@ public interface ExamQuestionMapper extends BaseMapperX /** * 批量审核试题 + * * @param quIds */ - void setQuestionAuditByids(@Param("quIds")List quIds); + void setQuestionAuditByids(@Param("quIds") List quIds); + /** * 查找学校集合(带分页) + * * @return */ List getSchoolName(TenantDto tenantDto); + /** + * 通过ID查找学校名称发 + */ + TenantVo getSchoolNameById(@Param("id") String id); - long getSchoolNameTotal(TenantDto tenantDto); - int auditQueByIds(@Param("quIds")List quIds,@Param("updater") String loginUserNickname); + long getSchoolNameTotal(TenantDto tenantDto); + + int auditQueByIds(@Param("quIds") List quIds, @Param("updater") String loginUserNickname); + /** * 批量审核试题 + * * @param quIds */ - int noAuditQue(@Param("quIds")List quIds); + int noAuditQue(@Param("quIds") List quIds); /** * 根据试题id和租户id查找 试题 + * * @param quId * @param source * @return */ - ExamQuestion selectExamQuestionByQuIdAndTenantId(@Param("quId") String quId, @Param("source")Long source); + ExamQuestion selectExamQuestionByQuIdAndTenantId(@Param("quId") String quId, @Param("source") Long source); /** * 查找所有的mqtt通道 + * * @return */ List seleAllQueueName(); /** * 更改试题审核的审核人和审核时间 + * * @param loginUserNickname * @param quIds */ @@ -155,6 +165,7 @@ public interface ExamQuestionMapper extends BaseMapperX /** * 根据id查找试题 + * * @param quId * @return */ @@ -162,6 +173,7 @@ public interface ExamQuestionMapper extends BaseMapperX /** * 查找学校集合 + * * @return */ List getSchoolNameNaPage(); @@ -170,19 +182,21 @@ public interface ExamQuestionMapper extends BaseMapperX /** * 根据专业、课程、题型、试题内容查找 相同的试题 + * * @param specialtyName 专业 - * @param courseName 课程 - * @param subjectName 题型 - * @param content 试题内容 + * @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); + ExamQuestion selectByTypes(@Param("specialtyName") String specialtyName + , @Param("courseName") String courseName + , @Param("subjectName") String subjectName + , @Param("content") String content); /** * 根据id查询学校名称 + * * @param loginTenantId * @return */ @@ -190,27 +204,31 @@ public interface ExamQuestionMapper extends BaseMapperX /** * 批量插入或更新试题 + * * @param examQuestions */ void insertOrUpdateList(List examQuestions); /** * 更改试题状态 + * * @param quId * @param status * @return */ boolean changeStatus(@Param("quId") String quId - ,@Param("status") String status); + , @Param("status") String status); /** * 查找试题表的试题数量 + * * @return */ int selectCountQu(); /** * 根据试题id找试题编号 + * * @param cannotDeleteIds * @return */ diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/mysql/questionexamine/QuestionExamineMapper.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/mysql/questionexamine/QuestionExamineMapper.java index e018e032..315e6b95 100644 --- a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/mysql/questionexamine/QuestionExamineMapper.java +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/mysql/questionexamine/QuestionExamineMapper.java @@ -11,22 +11,22 @@ import pc.exam.pp.module.exam.controller.admin.questionexamine.vo.QuestionExamin import pc.exam.pp.module.exam.dal.dataobject.QuestionExamineDO; /** -* 试题交互中间 Mapper -* -* @author 管理员 -*/ + * 试题交互中间 Mapper + * + * @author 管理员 + */ @Mapper public interface QuestionExamineMapper extends BaseMapperX { -default PageResult selectPage(QuestionExaminePageReqVO reqVO) { -return selectPage(reqVO, new LambdaQueryWrapperX() -.eqIfPresent(QuestionExamineDO::getQuId, reqVO.getQuId()) -.eqIfPresent(QuestionExamineDO::getSource, reqVO.getSource()) -.eqIfPresent(QuestionExamineDO::getCreateTeacher, reqVO.getCreateTeacher()) -.eqIfPresent(QuestionExamineDO::getType, reqVO.getType()) -.betweenIfPresent(QuestionExamineDO::getCreateTime, reqVO.getCreateTime()) -.orderByDesc(QuestionExamineDO::getCreateTime)); -} + default PageResult selectPage(QuestionExaminePageReqVO reqVO) { + return selectPage(reqVO, new LambdaQueryWrapperX() + .eqIfPresent(QuestionExamineDO::getQuId, reqVO.getQuId()) + .eqIfPresent(QuestionExamineDO::getSource, reqVO.getSource()) + .eqIfPresent(QuestionExamineDO::getCreateTeacher, reqVO.getCreateTeacher()) + .eqIfPresent(QuestionExamineDO::getType, reqVO.getType()) + .betweenIfPresent(QuestionExamineDO::getCreateTime, reqVO.getCreateTime()) + .orderByDesc(QuestionExamineDO::getCreateTime)); + } void insertOrUpdateList(List questionExamineDOS); 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 64c1fae2..e2c4cbc0 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 @@ -4,6 +4,7 @@ import cn.hutool.core.collection.CollUtil; import com.alibaba.excel.util.StringUtils; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.google.common.annotations.VisibleForTesting; +import jakarta.annotation.Resource; import org.apache.commons.collections4.CollectionUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -30,6 +31,7 @@ import pc.exam.pp.module.exam.utils.rabbitmq.RabbitmqUtils; import pc.exam.pp.module.exam.utils.uuid.IdUtils; import pc.exam.pp.module.infra.api.config.ConfigApi; +import java.time.LocalDateTime; import java.util.*; import java.util.stream.Collectors; @@ -72,7 +74,6 @@ public class ExamQuestionServiceImpl implements IExamQuestionService { private IExamQuestionService examQuestionService; @Autowired private ConfigApi configApi; - /** * 查询试题(hyc) * @@ -389,6 +390,24 @@ public class ExamQuestionServiceImpl implements IExamQuestionService { for (ExamQuestion examQuestion : list) { String pointIdStr = examQuestion.getPointNames(); String chapterIdStr = examQuestion.getChapteridDictText(); + // 试题归属 + if (examQuestion.getSchoolId() == null || examQuestion.getSchoolId().isEmpty()) { + // 说明是中心服务器的数据 + examQuestion.setSchoolName("中心服务器"); + } else { + String schoolId = examQuestion.getSchoolId(); + String schoolName = null; + if (!schoolId.equals("1")) { + // 通过ID查询学校名称,存放在数据中,返回页面使用 + TenantVo schoolInfo = examQuestionMapper.getSchoolNameById(schoolId); + schoolName = schoolInfo.getName(); + } else { + schoolName = "中心服务器"; + } + examQuestion.setSchoolName(schoolName); + } + // 试题创建人 + examQuestion.setCreateTeacher(examQuestion.getCreator()); try { if (pointIdStr != null) { Long pointId = Long.valueOf(pointIdStr); @@ -431,7 +450,6 @@ public class ExamQuestionServiceImpl implements IExamQuestionService { examQuestion_obj.setType(rabbitMQSendInfoVO.getType()); examQuestion_obj.setSource(SecurityFrameworkUtils.getLoginTenantId()); examQuestion_obj.setCreateTeacher(examQuestion_obj.getCreator()); - System.out.println(rabbitMQSendInfoVO.getQueueName()); // 3、上传至Rabbitmq rabbitMqService.sendMessage(rabbitMQSendInfoVO.getQueueName(), examQuestion_obj); } @@ -580,6 +598,7 @@ public class ExamQuestionServiceImpl implements IExamQuestionService { // TODO 1、拉取数据,保存至数据库 2、回调服务器是否拉取成功(中心服务器) // 1、获取上传的rabbit的试题数组 List examQuestions = null; + List insertExam = new ArrayList<>(); try { examQuestions = rabbitMqService.receiveAllMessages(queueName); } catch (Exception e) { @@ -587,12 +606,27 @@ public class ExamQuestionServiceImpl implements IExamQuestionService { } if (examQuestions != null && examQuestions.size() > 0) { for (ExamQuestion examQuestion : examQuestions) { - ExamQuestion question = examQuestionMapper.selectExamQuestionCountByQuId(examQuestion.getQuBankId()); if (question == null) { //如果没有,就是新增 String quId = IdUtils.simpleUUID(); examQuestion.setQuId(quId); + // 判断试题归属于中心服务器还是考点服务器 + if (examQuestion.getSchoolId() == null || examQuestion.getSchoolId().isEmpty()) { + examQuestion.setSchoolId("1"); + } else { + examQuestion.setSchoolId(examQuestion.getSchoolId()); + } + examQuestion.setCreator(examQuestion.getCreator()); + examQuestion.setCreateTime(LocalDateTime.now()); + examQuestion.setUpdateTime(LocalDateTime.now()); + // 判断上传的试题类型是需要审核还是不需要审核的 + if (queueName.split("_")[0].equals("1")) { + // 中心服務器推送到考點服務器,默認審核是通過的 + examQuestion.setAudit(String.valueOf(0)); + } else { + examQuestion.setAudit(String.valueOf(1)); + } Long loginTenantId = SecurityFrameworkUtils.getLoginTenantId(); int count = examQuestionMapper.selectCountQu(); // 读取系统创建试题位数设置 @@ -601,7 +635,6 @@ public class ExamQuestionServiceImpl implements IExamQuestionService { String formattedNumber = String.format("%0" + number + "d", ++count); String quNum = loginTenantId + "-" + formattedNumber; examQuestion.setQuNum(quNum); - //新增 List answerList = examQuestion.getAnswerList(); List fileUploads = examQuestion.getFileUploads(); @@ -643,19 +676,22 @@ public class ExamQuestionServiceImpl implements IExamQuestionService { }); examQuestionKeywordMapper.insertExamQuestionKeywordList(questionKeywords); } - + examQuestionMapper.insert(insertExam); } //有就是覆盖 else { examQuestion.setQuId(question.getQuId()); examQuestion.setQuNum(question.getQuNum()); + examQuestion.setSchoolId(question.getSchoolId()); + // 更新的时候只更新更新人,不更新创建人 + examQuestion.setCreator(examQuestion.getCreator()); + examQuestion.setUpdater(examQuestion.getCreator()); + examQuestion.setUpdateTime(LocalDateTime.now()); String quId = question.getQuId(); examQuestionAnswerMapper.deleteExamQuestionAnswerByQuesId(quId); sysFileMapper.deleteSysFileByQuesId(quId); examQuestionScoreMapper.deleteExamQuestionScoreByQuesId(quId); examQuestionKeywordMapper.deleteExamQuestionScoreByQuesId(quId); - - //新增 List answerList = examQuestion.getAnswerList(); List fileUploads = examQuestion.getFileUploads(); @@ -697,14 +733,11 @@ public class ExamQuestionServiceImpl implements IExamQuestionService { }); examQuestionKeywordMapper.insertExamQuestionKeywordList(questionKeywords); } + examQuestionMapper.updateBatch(examQuestion); } - } - examQuestionMapper.insertOrUpdateList(examQuestions); } - return true; - } @@ -714,11 +747,11 @@ public class ExamQuestionServiceImpl implements IExamQuestionService { List quIds = rabbitMQSendInfoVO.getQuIds(); if (quIds != null && quIds.size() > 0) { for (String quId : quIds) { - QuestionExamineDO questionExamineDO = questionExamineMapper.selectById(quId); - +// QuestionExamineDO questionExamineDO = questionExamineMapper.selectById(quId); // 2、根据试题ID和租户查找试题详情 ExamQuestion examQuestion_obj = examQuestionMapper.selectExamQuestionByQuId(quId); - + // 更新創建人 + examQuestion_obj.setCreator(SecurityFrameworkUtils.getLoginUserNickname()); //查找试题答案 List examQuestionAnswers = examQuestionAnswerMapper.selectExamQuestionAnswerByQuId(quId); //查找试题文件 @@ -728,7 +761,6 @@ public class ExamQuestionServiceImpl implements IExamQuestionService { //获取试题关键字 List examQuestionKeywords = examQuestionKeywordMapper.selectExamQuestionKeywordByQuId(quId); - if (examQuestion_obj != null) { if (examQuestionAnswers != null && examQuestionAnswers.size() > 0) { examQuestion_obj.setAnswerList(examQuestionAnswers); @@ -743,10 +775,11 @@ public class ExamQuestionServiceImpl implements IExamQuestionService { examQuestion_obj.setQuestionKeywords(examQuestionKeywords); } } - // examQuestion_obj.setType(rabbitMQSendInfoVO.getType()); // examQuestion_obj.setSource(SecurityFrameworkUtils.getLoginTenantId()); // examQuestion_obj.setCreateTeacher(SecurityFrameworkUtils.getLoginUserNickname()); + // 判断上传的试题类型是需要审核还是不需要审核的 0:不需要 1:需要 + examQuestion_obj.setQuestionType(rabbitMQSendInfoVO.getType()); // 3、上传至Rabbitmq rabbitMqService.sendMessage(rabbitMQSendInfoVO.getQueueName(), examQuestion_obj); } @@ -981,6 +1014,36 @@ public class ExamQuestionServiceImpl implements IExamQuestionService { return examQuestionAnswers; } + @Override + public boolean auditQuestion(AudioQuestionVo audioQuestionVo) { + List examQuestions = new ArrayList<>(); + // 判断是审核通过还是不通过 + for (String quId : audioQuestionVo.getQuIds()) { + // 更新字段 + // 通过ID查询数据 + ExamQuestion examQuestion = examQuestionMapper.selectExamQuestionByQuId(quId); + examQuestion.setAudit(audioQuestionVo.getType().equals("True") ? "0" : "3"); + examQuestionMapper.updateExamQuestion(examQuestion); + examQuestions.add(examQuestion); + } + // 通知上报的考点服务器 + for (ExamQuestion examQuestion : examQuestions) { + // 获取试题的归属新校ID,并拼接成通道名称 + if (examQuestion.getSchoolId() != null && !examQuestion.getSchoolId().isEmpty() && !examQuestion.getSchoolId().equals("1")) { + // 非中心服务器试题要同步到对应的考点服务器 + String queueNames = examQuestion.getSchoolId() + "_Queue"; + List questionIds = new ArrayList<>(); + questionIds.add(examQuestion.getQuId()); + RabbitMQSendInfoVO rabbitMQSendInfoVO = new RabbitMQSendInfoVO(); + rabbitMQSendInfoVO.setType("0"); + rabbitMQSendInfoVO.setQuIds(questionIds); + rabbitMQSendInfoVO.setQueueName(queueNames); + uploadExamQuestionToRabbitMQBySource(rabbitMQSendInfoVO); + } + } + return true; + } + private void validateChoice(String a, String b, String c, String d, String answer) { // A 和 B 必须存在 if (StringUtils.isBlank(a) || StringUtils.isBlank(b)) { diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/question/IExamQuestionService.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/question/IExamQuestionService.java index 2b9f4afd..c7b94878 100644 --- a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/question/IExamQuestionService.java +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/question/IExamQuestionService.java @@ -3,10 +3,7 @@ package pc.exam.pp.module.exam.service.question; import pc.exam.pp.framework.common.pojo.PageResult; import pc.exam.pp.module.exam.controller.admin.question.dto.ExamQuestionDto; import pc.exam.pp.module.exam.controller.admin.question.dto.TenantDto; -import pc.exam.pp.module.exam.controller.admin.question.vo.QueImportRespVO; -import pc.exam.pp.module.exam.controller.admin.question.vo.QuemportExcelVO; -import pc.exam.pp.module.exam.controller.admin.question.vo.QuestionVo; -import pc.exam.pp.module.exam.controller.admin.question.vo.TenantVo; +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.EducationPaperTask; @@ -109,4 +106,7 @@ public interface IExamQuestionService PageResult selectExamQuestionListAnswer(QuestionVo questionVo); List getPointById(String quId); + + // 试题审核 + boolean auditQuestion(AudioQuestionVo audioQuestionVo); } diff --git a/exam-module-exam/exam-module-exam-biz/src/main/resources/mapper/exam/ExamQuestionMapper.xml b/exam-module-exam/exam-module-exam-biz/src/main/resources/mapper/exam/ExamQuestionMapper.xml index 79a68b9d..2c0196a9 100644 --- a/exam-module-exam/exam-module-exam-biz/src/main/resources/mapper/exam/ExamQuestionMapper.xml +++ b/exam-module-exam/exam-module-exam-biz/src/main/resources/mapper/exam/ExamQuestionMapper.xml @@ -1,40 +1,41 @@ + PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> - + - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + - + @@ -45,17 +46,40 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - - - + + + - select qu_id, qu_bank_id, qu_num,qu_bank_name, chapterId_dict_text,subject_name, qu_level, - content, content_text, analysis,answer, point_names, keywords, manual, create_time, creator, update_time, updater, deleted ,status,audit ,course_name, specialty_name , tname from exam_question + select qu_id, + qu_bank_id, + qu_num, + qu_bank_name, + chapterId_dict_text, + subject_name, + qu_level, + content, + content_text, + analysis, + answer, + point_names, + keywords, + manual, + create_time, + creator, + update_time, + updater, + deleted, + status, + audit, + course_name, + specialty_name, + tname, + school_id + from exam_question - SELECT - q.*, -- exam_question 表字段 + q.*, -- exam_question 表字段 a.answer_id, a.qu_id AS a_qu_id, a.is_right, @@ -85,12 +109,19 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + + + - where qu_id = #{quId} and tenant_id= #{source} + where qu_id = #{quId} and tenant_id= #{source}
1