| | |
| | | import org.redisson.misc.Hash; |
| | | import org.springblade.core.log.exception.ServiceException; |
| | | import org.springblade.core.mp.support.Condition; |
| | | import org.springblade.modules.apply.entity.Apply; |
| | | import org.springblade.modules.exam.entity.ExamAnswerRecord; |
| | | import org.springblade.modules.exam.entity.ExamPaper; |
| | | import org.springblade.modules.exam.entity.ExamScore; |
| | | import org.springblade.modules.exam.entity.ExamSubjectChoices; |
| | | import org.springblade.modules.exam.service.ExamPaperService; |
| | | import org.springblade.modules.exam.service.ExamSubjectChoicesService; |
| | | import org.springblade.modules.exam.vo.ExamResultVO; |
| | | import org.springblade.modules.exam.vo.ExamSubjectChoicesVO; |
| | | import org.springblade.modules.simulateexam.entity.SimulateExamAnswerRecord; |
| | | import org.springblade.modules.simulateexam.entity.SimulateExamRecord; |
| | |
| | | import org.springblade.modules.simulateexam.service.SimulateExamAnswerRecordService; |
| | | import org.springblade.modules.simulateexam.service.SimulateExamRecordService; |
| | | import org.springblade.modules.simulateexam.vo.SimulateExamRecordVO; |
| | | import org.springblade.modules.simulateexam.vo.SimulateExamScoreVO; |
| | | import org.springblade.modules.system.entity.User; |
| | | import org.springblade.modules.system.service.IUserService; |
| | | 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; |
| | | |
| | | import java.lang.reflect.Array; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | |
| | | |
| | | @Autowired |
| | | private VipTopicService vipTopicService; |
| | | |
| | | @Autowired |
| | | private UserVipService userVipService; |
| | | |
| | | @Autowired |
| | | private IUserService userService; |
| | |
| | | return page.setRecords(baseMapper.selectSimulateExamRecordPage(page, simulateExamRecord)); |
| | | } |
| | | |
| | | // /** |
| | | // * 首次点击开始考试,创建模拟考试,并返回考试 |
| | | // * @param simulateExamRecord 模拟考试记录对象信息 |
| | | // * @return |
| | | // */ |
| | | // @Override |
| | | // public Object insertSimulateExamRecord(SimulateExamRecord simulateExamRecord) { |
| | | // //创建返回信息map |
| | | // Map<String, Object> map = new HashMap<>(); |
| | | // //使用身份证号码匹配人员信息(user_id) |
| | | // User user = new User(); |
| | | // user.setIsDeleted(0); |
| | | // user.setStatus(1); |
| | | // 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); |
| | | // //查询当前人员是否已缴费 |
| | | // VipTopic vipTopic = new VipTopic(); |
| | | // vipTopic.setUserId(user1.getId()); |
| | | // VipTopic topic = vipTopicService.getOne(Condition.getQueryWrapper(vipTopic)); |
| | | // //从当前人员考试题库随机取60题存入 |
| | | // if (null!=topic){ |
| | | // List<String> list1 = Arrays.asList(topic.getTopicIds().split(",")); |
| | | // //获取随机的题目 |
| | | // List<String> radio = list1.subList(0, 49); |
| | | // List<String> checkbox = list1.subList(50, 69); |
| | | // List<String> judge = list1.subList(70, 109); |
| | | // List<String> sort = list1.subList(110, 119); |
| | | // //随机题目 |
| | | // List<ExamSubjectChoicesVO> radioRandomSubjectList = examPaperService.queryRandomSubjectList(radio,25); |
| | | // List<ExamSubjectChoicesVO> checkboxRandomSubjectList = examPaperService.queryRandomSubjectList(checkbox,10); |
| | | // List<ExamSubjectChoicesVO> judgeRandomSubjectList = examPaperService.queryRandomSubjectList(judge,20); |
| | | // List<ExamSubjectChoicesVO> sortRandomSubjectList = examPaperService.queryRandomSubjectList(sort,5); |
| | | // |
| | | // //合并集合数据 |
| | | // choicesVOList.addAll(radioRandomSubjectList); |
| | | // choicesVOList.addAll(checkboxRandomSubjectList); |
| | | // choicesVOList.addAll(judgeRandomSubjectList); |
| | | // choicesVOList.addAll(sortRandomSubjectList); |
| | | // }else { |
| | | // //未缴费人员从大题库随机抽取100道题目 |
| | | // choicesVOList = examPaperService.simulateQueryRandomSubjectList(); |
| | | // } |
| | | // //取出考试id |
| | | // List<Long> longList = choicesVOList.stream().map(ExamSubjectChoicesVO::getId).collect(Collectors.toList()); |
| | | // //装换为字符串 |
| | | // List<String> list2 = new ArrayList<>(); |
| | | // for (Long aLong : longList) { |
| | | // list2.add(aLong.toString()); |
| | | // } |
| | | // String collect = list2.stream().collect(Collectors.joining(",")); |
| | | // //设置题目信息 |
| | | // simulateExamRecord.setSubjectIds(collect); |
| | | // simulateExamRecord.setStartTime(new Date()); |
| | | // //考试剩余时长初始值为90分钟 |
| | | // simulateExamRecord.setAnswerTime(90*60*1000L); |
| | | // //考试中,开始计时 |
| | | // simulateExamRecord.setStatus(1); |
| | | // //新增模拟考试记录信息 |
| | | // status = this.save(simulateExamRecord); |
| | | // |
| | | //// 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); |
| | | // //返回信息 |
| | | // return map; |
| | | // } |
| | | // }else { |
| | | // throw new ServiceException("未查询到该人员信息"); |
| | | // } |
| | | // //返回数据 |
| | | // return map; |
| | | // } |
| | | |
| | | |
| | | /** |
| | | * 首次点击开始考试,创建模拟考试,并返回考试 |
| | | * @param simulateExamRecord 模拟考试记录对象信息 |
| | |
| | | */ |
| | | @Override |
| | | public Object insertSimulateExamRecord(SimulateExamRecord simulateExamRecord) { |
| | | //创建返回信息map |
| | | // //创建返回信息map |
| | | Map<String, Object> map = new HashMap<>(); |
| | | //使用身份证号码匹配人员信息(user_id) |
| | | User user = new User(); |
| | | user.setIsDeleted(0); |
| | | user.setStatus(1); |
| | | user.setCardid(simulateExamRecord.getIdCardNo()); |
| | | List<User> list = userService.list(Condition.getQueryWrapper(user)); |
| | | // //使用身份证号码匹配人员信息(user_id) |
| | | // User user = new User(); |
| | | // user.setIsDeleted(0); |
| | | // user.setStatus(1); |
| | | // user.setCardid(simulateExamRecord.getIdCardNo()); |
| | | // List<User> list = userService.list(Condition.getQueryWrapper(user)); |
| | | List<ExamSubjectChoicesVO> choicesVOList = new ArrayList<>(); |
| | | 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)); |
| | | //从当前人员考试题库随机取60题存入 |
| | | if (null!=topic){ |
| | | List<String> list1 = Arrays.asList(topic.getTopicIds().split(",")); |
| | | //获取随机的题目 |
| | | List<String> radio = list1.subList(0, 49); |
| | | List<String> checkbox = list1.subList(50, 69); |
| | | List<String> judge = list1.subList(70, 109); |
| | | List<String> sort = list1.subList(110, 119); |
| | | //随机题目 |
| | | List<ExamSubjectChoicesVO> radioRandomSubjectList = examPaperService.queryRandomSubjectList(radio,25); |
| | | List<ExamSubjectChoicesVO> checkboxRandomSubjectList = examPaperService.queryRandomSubjectList(checkbox,10); |
| | | List<ExamSubjectChoicesVO> judgeRandomSubjectList = examPaperService.queryRandomSubjectList(judge,20); |
| | | List<ExamSubjectChoicesVO> sortRandomSubjectList = examPaperService.queryRandomSubjectList(sort,5); |
| | | |
| | | //合并集合数据 |
| | | choicesVOList.addAll(radioRandomSubjectList); |
| | | choicesVOList.addAll(checkboxRandomSubjectList); |
| | | choicesVOList.addAll(judgeRandomSubjectList); |
| | | choicesVOList.addAll(sortRandomSubjectList); |
| | | |
| | | //取出考试id |
| | | List<Long> longList = choicesVOList.stream().map(ExamSubjectChoicesVO::getId).collect(Collectors.toList()); |
| | | //装换为字符串 |
| | | List<String> list2 = new ArrayList<>(); |
| | | for (Long aLong : longList) { |
| | | list2.add(aLong.toString()); |
| | | } |
| | | String collect = list2.stream().collect(Collectors.joining(",")); |
| | | //设置题目信息 |
| | | simulateExamRecord.setSubjectIds(collect); |
| | | simulateExamRecord.setStartTime(new Date()); |
| | | //考试剩余时长初始值为60分钟 |
| | | simulateExamRecord.setAnswerTime(60*60*1000L); |
| | | //考试中,开始计时 |
| | | simulateExamRecord.setStatus(1); |
| | | //新增模拟考试记录信息 |
| | | boolean status = this.save(simulateExamRecord); |
| | | if (status){ |
| | | map.put("simulateExamRecord",simulateExamRecord); |
| | | map.put("examSubjectInfo",choicesVOList); |
| | | //返回信息 |
| | | return map; |
| | | } |
| | | }else { |
| | | throw new ServiceException("未查询到该人员缴费信息"); |
| | | boolean status = false; |
| | | // if (list.size()>0){ |
| | | // User user1 = list.get(0); |
| | | //从大题库随机抽取100道题目 |
| | | choicesVOList = examPaperService.simulateQueryRandomSubjectList(); |
| | | //取出考试id |
| | | List<Long> longList = choicesVOList.stream().map(ExamSubjectChoicesVO::getId).collect(Collectors.toList()); |
| | | //装换为字符串 |
| | | List<String> list2 = new ArrayList<>(); |
| | | for (Long aLong : longList) { |
| | | list2.add(aLong.toString()); |
| | | } |
| | | }else { |
| | | throw new ServiceException("未查询到该人员信息"); |
| | | } |
| | | String collect = list2.stream().collect(Collectors.joining(",")); |
| | | //设置题目信息 |
| | | simulateExamRecord.setSubjectIds(collect); |
| | | simulateExamRecord.setStartTime(new Date()); |
| | | //考试剩余时长初始值为90分钟 |
| | | simulateExamRecord.setAnswerTime(90*60*1000L); |
| | | //考试中,开始计时 |
| | | simulateExamRecord.setStatus(1); |
| | | //新增模拟考试记录信息 |
| | | status = this.save(simulateExamRecord); |
| | | |
| | | if (status){ |
| | | map.put("simulateExamRecord",simulateExamRecord); |
| | | map.put("examSubjectInfo",choicesVOList); |
| | | // map.put("examSubjectChoicesVO",examSubjectChoicesVO); |
| | | //返回信息 |
| | | return map; |
| | | } |
| | | // }else { |
| | | // throw new ServiceException("未查询到该人员信息"); |
| | | // } |
| | | //返回数据 |
| | | return map; |
| | | } |
| | |
| | | |
| | | /** |
| | | * 考试暂停后继续,1查询所有的答题信息,2查询所有的已答信息 3其他信息 |
| | | * @param simulateExamRecord 必须包含 模拟考试id,id_card_no, type 1: 继续考试 2: 放弃之前的考试,重新生成题目考试 |
| | | * @param simulateExamRecord 必须包含 模拟考试id,, type 1: 继续考试 2: 放弃之前的考试,重新生成题目考试 |
| | | * @return |
| | | */ |
| | | @Override |
| | |
| | | //去获取题目 |
| | | return insertSimulateExamRecord(simulateExamRecord1); |
| | | } |
| | | |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * 提交考试 |
| | | * @param simulateExamScore 模拟考试成绩信息对象 |
| | | * @return |
| | | */ |
| | | @Override |
| | | public Object saveSimulateExam(SimulateExamScoreVO simulateExamScore) { |
| | | //取出考试结果 |
| | | if (simulateExamScore.getExamResultVOS().size() > 0) { |
| | | List<ExamResultVO> examResultVOS = simulateExamScore.getExamResultVOS(); |
| | | //查询模拟考试信息 |
| | | SimulateExamRecord simulateExamRecord = this.getById(simulateExamScore.getSimulateExamId()); |
| | | int count = 0; |
| | | //计算考试得分,并存入考试答题记录 |
| | | for (ExamResultVO examResultVO : examResultVOS) { |
| | | SimulateExamAnswerRecord answerRecord = new SimulateExamAnswerRecord(); |
| | | answerRecord.setSimulateExamId(simulateExamScore.getSimulateExamId()); |
| | | answerRecord.setSubjectChoicesId(examResultVO.getSubjectChoicesId()); |
| | | answerRecord.setAnswerOption(examResultVO.getValue()); |
| | | answerRecord.setAnswerScore(examResultVO.getGrade()); |
| | | if (examResultVO.getGrade() > 0) { |
| | | answerRecord.setAnswerResult(1); |
| | | } else { |
| | | answerRecord.setAnswerResult(2); |
| | | } |
| | | count = count + examResultVO.getGrade(); |
| | | answerRecord.setAnswerTime(new Date()); |
| | | //新增 |
| | | simulateExamAnswerRecordService.save(answerRecord); |
| | | } |
| | | //设置总分 |
| | | simulateExamRecord.setScore(count); |
| | | // 考试完成 |
| | | simulateExamRecord.setStatus(3); |
| | | simulateExamRecord.setEndTime(new Date()); |
| | | //更新模拟考试信息 |
| | | this.updateById(simulateExamRecord); |
| | | //返回 |
| | | return true; |
| | | } |
| | | //返回结果 |
| | | return false; |
| | | } |
| | | } |