From 9d302111702046f508c45080b5fcb3b8fd54e247 Mon Sep 17 00:00:00 2001
From: Administrator <admin>
Date: Wed, 09 Mar 2022 13:42:45 +0800
Subject: [PATCH] 开始模拟考试,根据人员是否缴费来判断加载考试的题库

---
 src/main/java/org/springblade/modules/simulateexam/service/impl/SimulateExamRecordServiceImpl.java |   67 ++++++++++++++++++---------------
 1 files changed, 36 insertions(+), 31 deletions(-)

diff --git a/src/main/java/org/springblade/modules/simulateexam/service/impl/SimulateExamRecordServiceImpl.java b/src/main/java/org/springblade/modules/simulateexam/service/impl/SimulateExamRecordServiceImpl.java
index 55d4293..936640a 100644
--- a/src/main/java/org/springblade/modules/simulateexam/service/impl/SimulateExamRecordServiceImpl.java
+++ b/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,37 +117,37 @@
 				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);
-
-				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("未查询到该人员缴费信息");
+				//未缴费人员从大题库随机抽取60道题目
+				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());
+			//考试剩余时长初始值为60分钟
+			simulateExamRecord.setAnswerTime(60*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("未查询到该人员信息");

--
Gitblit v1.9.3