|
|
@@ -51,54 +51,69 @@ public class QuestionSimulateServiceImpl extends ServiceImpl<QuestionSimulateMap
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public QuestionSimulateVo queryByBankId(Long simulateId) {
|
|
|
+ public Map<String,Object> queryByBankId(Long bandId,Long userId) {
|
|
|
Map<String,Object> param = new HashMap<>();
|
|
|
- Long bandId = 2L;
|
|
|
param.put("bandId",bandId);
|
|
|
ExamConfigVo vo = examConfigMapper.selectBankExamConfig(param);
|
|
|
if(vo==null){
|
|
|
throw new CustomException("该题库暂不支持模拟考试");
|
|
|
}
|
|
|
- Long bank_section_id = 9L;
|
|
|
//抽选单选题
|
|
|
Map<String,Object> param1 = new HashMap<>();
|
|
|
- param1.put("bankSectionId",bank_section_id);
|
|
|
+ param1.put("bankId",bandId);
|
|
|
param1.put("type",1);
|
|
|
param1.put("num",vo.getSingleChoiceNum());
|
|
|
+ List<QuestionVo> listToatl = new ArrayList<>();
|
|
|
List<QuestionVo> list1 = questionMapper.selectQuestionSimulateList(param1);
|
|
|
String type1_ids ="";
|
|
|
+ if(list1.size()<vo.getSingleChoiceNum()){
|
|
|
+ throw new CustomException("题库单选题数不足");
|
|
|
+ }
|
|
|
for (QuestionVo s : list1) {
|
|
|
type1_ids += s.getQuestionId()+",";
|
|
|
+ listToatl.add(s);
|
|
|
}
|
|
|
//抽选多选题
|
|
|
Map<String,Object> param2 = new HashMap<>();
|
|
|
- param2.put("bankSectionId",bank_section_id);
|
|
|
+ param2.put("bankId",bandId);
|
|
|
param2.put("type",2);
|
|
|
- param2.put("num",vo.getSingleChoiceNum());
|
|
|
+ param2.put("num",vo.getMultipleChoiceNum());
|
|
|
List<QuestionVo> list2 = questionMapper.selectQuestionSimulateList(param2);
|
|
|
String type2_ids ="";
|
|
|
+ if(list2.size()<vo.getMultipleChoiceNum()){
|
|
|
+ throw new CustomException("题库多选题数不足");
|
|
|
+ }
|
|
|
for (QuestionVo s : list2) {
|
|
|
type2_ids += s.getQuestionId()+",";
|
|
|
+ listToatl.add(s);
|
|
|
}
|
|
|
//抽选判断题
|
|
|
Map<String,Object> param3 = new HashMap<>();
|
|
|
- param3.put("bankSectionId",bank_section_id);
|
|
|
+ param3.put("bankId",bandId);
|
|
|
param3.put("type",3);
|
|
|
- param3.put("num",vo.getSingleChoiceNum());
|
|
|
+ param3.put("num",vo.getJudgmentNum());
|
|
|
List<QuestionVo> list3 = questionMapper.selectQuestionSimulateList(param3);
|
|
|
String type3_ids ="";
|
|
|
+ if(list3.size()<vo.getJudgmentNum()){
|
|
|
+ throw new CustomException("题库判断题数不足");
|
|
|
+ }
|
|
|
for (QuestionVo s : list3) {
|
|
|
type3_ids += s.getQuestionId()+",";
|
|
|
+ listToatl.add(s);
|
|
|
}
|
|
|
//抽选案例题
|
|
|
Map<String,Object> param4 = new HashMap<>();
|
|
|
- param4.put("bankSectionId",bank_section_id);
|
|
|
+ param4.put("bankId",bandId);
|
|
|
param4.put("type",4);
|
|
|
- param4.put("num",vo.getSingleChoiceNum());
|
|
|
+ param4.put("num",vo.getCaseNum());
|
|
|
List<QuestionVo> list4 = questionMapper.selectQuestionSimulateList(param4);
|
|
|
String type4_ids ="";
|
|
|
+ if(list4.size()<vo.getCaseNum()){
|
|
|
+ throw new CustomException("题库案例题数不足");
|
|
|
+ }
|
|
|
for (QuestionVo s : list4) {
|
|
|
type4_ids += s.getQuestionId()+",";
|
|
|
+ listToatl.add(s);
|
|
|
}
|
|
|
QuestionSimulateAddBo bo = new QuestionSimulateAddBo();
|
|
|
bo.setBankId(bandId);
|
|
|
@@ -106,8 +121,20 @@ public class QuestionSimulateServiceImpl extends ServiceImpl<QuestionSimulateMap
|
|
|
bo.setType2Ids(type2_ids);
|
|
|
bo.setType3Ids(type3_ids);
|
|
|
bo.setType4Ids(type4_ids);
|
|
|
+ bo.setUserId(userId);
|
|
|
+ bo.setExamConfigId(vo.getId());
|
|
|
this.insertByAddBo(bo);
|
|
|
- return null;
|
|
|
+ QuestionSimulate add = BeanUtil.toBean(bo, QuestionSimulate.class);
|
|
|
+ validEntityBeforeSave(add);
|
|
|
+ add.setCreateTime(DateUtils.getNowTime());
|
|
|
+ add.setUpdateTime(DateUtils.getNowTime());
|
|
|
+ if(!this.save(add)){
|
|
|
+ throw new CustomException("模拟试卷创建失败");
|
|
|
+ }
|
|
|
+ Map<String,Object> result = new HashMap<>();
|
|
|
+ result.put("simulateId",add.getSimulateId());
|
|
|
+ result.put("list",listToatl);
|
|
|
+ return result;
|
|
|
}
|
|
|
|
|
|
@Override
|