src/main/java/org/springblade/modules/exam/mapper/ExamPaperMapper.java
@@ -167,4 +167,10 @@ * @return */ List<ExamSubjectChoicesVO> queryRandomSubjectList(@Param("list") List<String> list,@Param("number") Integer number); /** * 模拟考试随机抽题,未缴费人员 * @return */ List<ExamSubjectChoicesVO> simulateQueryRandomSubjectList(); } src/main/java/org/springblade/modules/exam/mapper/ExamPaperMapper.xml
@@ -549,6 +549,7 @@ </collection> </resultMap> <!--已缴费人员题目查询--> <select id="queryRandomSubjectList" resultMap="ExamSubjectChoicesInfoMap"> select esc.id,esc.category_id,esc.subject_name,esc.choices_type,esc.score,esc.answer, @@ -578,5 +579,35 @@ esc.id = eso.subject_choices_id </select> <!--模拟考试随机抽题--> <select id="simulateQueryRandomSubjectList" resultMap="ExamSubjectChoicesInfoMap"> SELECT esc.id, esc.category_id, esc.subject_name, esc.choices_type, esc.score, esc.answer, eso.id eso_id, eso.subject_choices_id, eso.option_name, eso.option_content, eso.creator, eso.create_date, eso.modifier, eso.modify_date, eso.del_flag, eso.application_code, eso.tenant_code FROM ( SELECT * FROM ( SELECT * FROM exam_subject_choices WHERE choices_type = 0 ORDER BY RAND( ) LIMIT 25 ) a UNION ALL SELECT * FROM ( SELECT * FROM exam_subject_choices WHERE choices_type = 1 ORDER BY RAND( ) LIMIT 10 ) b UNION ALL SELECT * FROM ( SELECT * FROM exam_subject_choices WHERE choices_type = 2 ORDER BY RAND( ) LIMIT 20 ) c UNION ALL SELECT * FROM ( SELECT * FROM exam_subject_choices WHERE choices_type = 3 ORDER BY RAND( ) LIMIT 5 ) d ) esc LEFT JOIN exam_subject_option eso ON esc.id = eso.subject_choices_id </select> </mapper> src/main/java/org/springblade/modules/exam/service/ExamPaperService.java
@@ -145,4 +145,10 @@ * @return */ List<ExamSubjectChoicesVO> queryRandomSubjectList(List<String> list, int number); /** * 模拟考试随机抽题,未缴费人员 * @return */ List<ExamSubjectChoicesVO> simulateQueryRandomSubjectList(); } src/main/java/org/springblade/modules/exam/service/impl/ExamPaperServiceImpl.java
@@ -378,4 +378,13 @@ public List<ExamSubjectChoicesVO> queryRandomSubjectList(List<String> list, int number) { return baseMapper.queryRandomSubjectList(list,number); } /** * 模拟考试随机抽题,未缴费人员 * @return */ @Override public List<ExamSubjectChoicesVO> simulateQueryRandomSubjectList() { return baseMapper.simulateQueryRandomSubjectList(); } } src/main/java/org/springblade/modules/simulateexam/service/impl/SimulateExamRecordServiceImpl.java
@@ -27,6 +27,7 @@ import org.springblade.modules.system.vo.UserVO; import org.springblade.modules.training.entity.TrainingRegistration; import org.springblade.modules.vip.entity.VipTopic; import org.springblade.modules.vip.service.UserVipService; import org.springblade.modules.vip.service.VipTopicService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -50,6 +51,9 @@ @Autowired private VipTopicService vipTopicService; @Autowired private UserVipService userVipService; @Autowired private IUserService userService; @@ -87,9 +91,10 @@ user.setCardid(simulateExamRecord.getIdCardNo()); List<User> list = userService.list(Condition.getQueryWrapper(user)); List<ExamSubjectChoicesVO> choicesVOList = new ArrayList<>(); boolean status = false; if (list.size()>0){ User user1 = list.get(0); //查询当前人员的考试题库,已缴费id //查询当前人员是否已缴费 VipTopic vipTopic = new VipTopic(); vipTopic.setUserId(user1.getId()); VipTopic topic = vipTopicService.getOne(Condition.getQueryWrapper(vipTopic)); @@ -112,7 +117,10 @@ choicesVOList.addAll(checkboxRandomSubjectList); choicesVOList.addAll(judgeRandomSubjectList); choicesVOList.addAll(sortRandomSubjectList); }else { //未缴费人员从大题库随机抽取60道题目 choicesVOList = examPaperService.simulateQueryRandomSubjectList(); } //取出考试id List<Long> longList = choicesVOList.stream().map(ExamSubjectChoicesVO::getId).collect(Collectors.toList()); //装换为字符串 @@ -129,20 +137,17 @@ //考试中,开始计时 simulateExamRecord.setStatus(1); //新增模拟考试记录信息 boolean status = this.save(simulateExamRecord); status = this.save(simulateExamRecord); ExamSubjectChoices examSubjectChoices = new ExamSubjectChoices(); examSubjectChoices.setId(choicesVOList.get(0).getId()); ExamSubjectChoicesVO examSubjectChoicesVO = examSubjectChoicesService.selectExamSubjectChoicesInfo(examSubjectChoices); // ExamSubjectChoices examSubjectChoices = new ExamSubjectChoices(); // examSubjectChoices.setId(choicesVOList.get(0).getId()); // ExamSubjectChoicesVO examSubjectChoicesVO = examSubjectChoicesService.selectExamSubjectChoicesInfo(examSubjectChoices); if (status){ map.put("simulateExamRecord",simulateExamRecord); map.put("examSubjectInfo",choicesVOList); map.put("examSubjectChoicesVO",examSubjectChoicesVO); // map.put("examSubjectChoicesVO",examSubjectChoicesVO); //返回信息 return map; } }else { throw new ServiceException("未查询到该人员缴费信息"); } }else { throw new ServiceException("未查询到该人员信息");