|
@@ -1,32 +1,5 @@
|
|
package cn.com.qmth.examcloud.core.questions.service.impl;
|
|
package cn.com.qmth.examcloud.core.questions.service.impl;
|
|
|
|
|
|
-import java.math.BigDecimal;
|
|
|
|
-import java.util.ArrayList;
|
|
|
|
-import java.util.Collections;
|
|
|
|
-import java.util.HashMap;
|
|
|
|
-import java.util.Iterator;
|
|
|
|
-import java.util.List;
|
|
|
|
-import java.util.Map;
|
|
|
|
-import java.util.stream.Collectors;
|
|
|
|
-
|
|
|
|
-import javax.annotation.Resource;
|
|
|
|
-
|
|
|
|
-import org.apache.commons.collections4.CollectionUtils;
|
|
|
|
-import org.apache.commons.lang3.StringUtils;
|
|
|
|
-import org.bson.types.ObjectId;
|
|
|
|
-import org.slf4j.Logger;
|
|
|
|
-import org.slf4j.LoggerFactory;
|
|
|
|
-import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
-import org.springframework.data.domain.Page;
|
|
|
|
-import org.springframework.data.domain.PageImpl;
|
|
|
|
-import org.springframework.data.domain.PageRequest;
|
|
|
|
-import org.springframework.data.domain.Sort;
|
|
|
|
-import org.springframework.data.mongodb.core.MongoTemplate;
|
|
|
|
-import org.springframework.data.mongodb.core.query.Criteria;
|
|
|
|
-import org.springframework.data.mongodb.core.query.Query;
|
|
|
|
-import org.springframework.stereotype.Service;
|
|
|
|
-import org.springframework.transaction.annotation.Transactional;
|
|
|
|
-
|
|
|
|
import cn.com.qmth.examcloud.api.commons.security.bean.User;
|
|
import cn.com.qmth.examcloud.api.commons.security.bean.User;
|
|
import cn.com.qmth.examcloud.commons.exception.StatusException;
|
|
import cn.com.qmth.examcloud.commons.exception.StatusException;
|
|
import cn.com.qmth.examcloud.core.basic.api.UserCloudService;
|
|
import cn.com.qmth.examcloud.core.basic.api.UserCloudService;
|
|
@@ -44,30 +17,12 @@ import cn.com.qmth.examcloud.core.questions.dao.PaperStructRepo;
|
|
import cn.com.qmth.examcloud.core.questions.dao.PropertyRepo;
|
|
import cn.com.qmth.examcloud.core.questions.dao.PropertyRepo;
|
|
import cn.com.qmth.examcloud.core.questions.dao.RandomPaperQuestionRepo;
|
|
import cn.com.qmth.examcloud.core.questions.dao.RandomPaperQuestionRepo;
|
|
import cn.com.qmth.examcloud.core.questions.dao.RandomPaperRepo;
|
|
import cn.com.qmth.examcloud.core.questions.dao.RandomPaperRepo;
|
|
-import cn.com.qmth.examcloud.core.questions.dao.entity.PaperDetailStruct;
|
|
|
|
-import cn.com.qmth.examcloud.core.questions.dao.entity.PaperStruct;
|
|
|
|
-import cn.com.qmth.examcloud.core.questions.dao.entity.Property;
|
|
|
|
-import cn.com.qmth.examcloud.core.questions.dao.entity.QuesProperty;
|
|
|
|
-import cn.com.qmth.examcloud.core.questions.dao.entity.RandomPaper;
|
|
|
|
-import cn.com.qmth.examcloud.core.questions.dao.entity.RandomPaperQuestion;
|
|
|
|
|
|
+import cn.com.qmth.examcloud.core.questions.dao.entity.*;
|
|
import cn.com.qmth.examcloud.core.questions.dao.entity.dto.CoursePropertyNumberDto;
|
|
import cn.com.qmth.examcloud.core.questions.dao.entity.dto.CoursePropertyNumberDto;
|
|
import cn.com.qmth.examcloud.core.questions.dao.entity.dto.PaperDetailUnitStructDto;
|
|
import cn.com.qmth.examcloud.core.questions.dao.entity.dto.PaperDetailUnitStructDto;
|
|
import cn.com.qmth.examcloud.core.questions.service.PaperStructService;
|
|
import cn.com.qmth.examcloud.core.questions.service.PaperStructService;
|
|
import cn.com.qmth.examcloud.core.questions.service.RandomPaperService;
|
|
import cn.com.qmth.examcloud.core.questions.service.RandomPaperService;
|
|
-import cn.com.qmth.examcloud.core.questions.service.bean.randompaper.CreateDefaultPaperParam;
|
|
|
|
-import cn.com.qmth.examcloud.core.questions.service.bean.randompaper.PaperDetailDto;
|
|
|
|
-import cn.com.qmth.examcloud.core.questions.service.bean.randompaper.PaperDetailUnitDto;
|
|
|
|
-import cn.com.qmth.examcloud.core.questions.service.bean.randompaper.PaperQuestionViewQuery;
|
|
|
|
-import cn.com.qmth.examcloud.core.questions.service.bean.randompaper.PaperVo;
|
|
|
|
-import cn.com.qmth.examcloud.core.questions.service.bean.randompaper.QuestionDto;
|
|
|
|
-import cn.com.qmth.examcloud.core.questions.service.bean.randompaper.RandomPaperDomain;
|
|
|
|
-import cn.com.qmth.examcloud.core.questions.service.bean.randompaper.RandomPaperListVo;
|
|
|
|
-import cn.com.qmth.examcloud.core.questions.service.bean.randompaper.RandomPaperQuery;
|
|
|
|
-import cn.com.qmth.examcloud.core.questions.service.bean.randompaper.RandomPaperQuestionDto;
|
|
|
|
-import cn.com.qmth.examcloud.core.questions.service.bean.randompaper.StructInfo;
|
|
|
|
-import cn.com.qmth.examcloud.core.questions.service.bean.randompaper.StructQuestionCheckDto;
|
|
|
|
-import cn.com.qmth.examcloud.core.questions.service.bean.randompaper.StructQuestionCountInfo;
|
|
|
|
-import cn.com.qmth.examcloud.core.questions.service.bean.randompaper.StructQuestionInfo;
|
|
|
|
|
|
+import cn.com.qmth.examcloud.core.questions.service.bean.randompaper.*;
|
|
import cn.com.qmth.examcloud.core.questions.service.cache.PaperDetailStructCache;
|
|
import cn.com.qmth.examcloud.core.questions.service.cache.PaperDetailStructCache;
|
|
import cn.com.qmth.examcloud.core.questions.service.cache.PaperStructCache;
|
|
import cn.com.qmth.examcloud.core.questions.service.cache.PaperStructCache;
|
|
import cn.com.qmth.examcloud.core.questions.service.cache.RandomPaperCache;
|
|
import cn.com.qmth.examcloud.core.questions.service.cache.RandomPaperCache;
|
|
@@ -83,13 +38,36 @@ import cn.com.qmth.examcloud.support.CacheConstants;
|
|
import cn.com.qmth.examcloud.support.cache.CacheHelper;
|
|
import cn.com.qmth.examcloud.support.cache.CacheHelper;
|
|
import cn.com.qmth.examcloud.support.cache.bean.CourseCacheBean;
|
|
import cn.com.qmth.examcloud.support.cache.bean.CourseCacheBean;
|
|
import cn.com.qmth.examcloud.web.redis.RedisClient;
|
|
import cn.com.qmth.examcloud.web.redis.RedisClient;
|
|
|
|
+import com.google.common.cache.Cache;
|
|
|
|
+import com.google.common.cache.CacheBuilder;
|
|
|
|
+import org.apache.commons.collections4.CollectionUtils;
|
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
|
+import org.bson.types.ObjectId;
|
|
|
|
+import org.slf4j.Logger;
|
|
|
|
+import org.slf4j.LoggerFactory;
|
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
+import org.springframework.data.domain.Page;
|
|
|
|
+import org.springframework.data.domain.PageImpl;
|
|
|
|
+import org.springframework.data.domain.PageRequest;
|
|
|
|
+import org.springframework.data.domain.Sort;
|
|
|
|
+import org.springframework.data.mongodb.core.MongoTemplate;
|
|
|
|
+import org.springframework.data.mongodb.core.query.Criteria;
|
|
|
|
+import org.springframework.data.mongodb.core.query.Query;
|
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
|
+
|
|
|
|
+import javax.annotation.Resource;
|
|
|
|
+import java.math.BigDecimal;
|
|
|
|
+import java.util.*;
|
|
|
|
+import java.util.concurrent.TimeUnit;
|
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
@Service
|
|
@Service
|
|
public class RandomPaperServiceImpl implements RandomPaperService {
|
|
public class RandomPaperServiceImpl implements RandomPaperService {
|
|
|
|
|
|
private static final Logger log = LoggerFactory.getLogger(RandomPaperServiceImpl.class);
|
|
private static final Logger log = LoggerFactory.getLogger(RandomPaperServiceImpl.class);
|
|
|
|
|
|
-// private static Cache<String, RandomPaperCache> localRandomPaperCache = CacheBuilder.newBuilder().expireAfterWrite(3, TimeUnit.MINUTES).build();
|
|
|
|
|
|
+ private static Cache<String, RandomPaperCache> localRandomPaperCache = CacheBuilder.newBuilder().expireAfterWrite(3, TimeUnit.MINUTES).build();
|
|
|
|
|
|
private static int cacheTimeOut = 2 * 60 * 60;
|
|
private static int cacheTimeOut = 2 * 60 * 60;
|
|
|
|
|
|
@@ -508,14 +486,14 @@ public class RandomPaperServiceImpl implements RandomPaperService {
|
|
if (us.getNoPublicDifficulty() > 0) {
|
|
if (us.getNoPublicDifficulty() > 0) {
|
|
cd.setSi(sqinfo.getHardInfo());
|
|
cd.setSi(sqinfo.getHardInfo());
|
|
cd.setPub(false);
|
|
cd.setPub(false);
|
|
- cd.setDifficulty(QuestionDifficulty.HARD);
|
|
|
|
|
|
+ cd.setDifficulty(QuestionDifficulty.HARD.getName());
|
|
cd.setNeedCount(us.getNoPublicDifficulty());
|
|
cd.setNeedCount(us.getNoPublicDifficulty());
|
|
setQuestionInfoByExactItem(cd);
|
|
setQuestionInfoByExactItem(cd);
|
|
}
|
|
}
|
|
if (us.getPublicDifficulty() > 0) {
|
|
if (us.getPublicDifficulty() > 0) {
|
|
cd.setSi(sqinfo.getHardInfo());
|
|
cd.setSi(sqinfo.getHardInfo());
|
|
cd.setPub(true);
|
|
cd.setPub(true);
|
|
- cd.setDifficulty(QuestionDifficulty.HARD);
|
|
|
|
|
|
+ cd.setDifficulty(QuestionDifficulty.HARD.getName());
|
|
cd.setNeedCount(us.getPublicDifficulty());
|
|
cd.setNeedCount(us.getPublicDifficulty());
|
|
setQuestionInfoByExactItem(cd);
|
|
setQuestionInfoByExactItem(cd);
|
|
}
|
|
}
|
|
@@ -523,28 +501,28 @@ public class RandomPaperServiceImpl implements RandomPaperService {
|
|
if (us.getNoPublicMedium() > 0) {
|
|
if (us.getNoPublicMedium() > 0) {
|
|
cd.setSi(sqinfo.getMediumInfo());
|
|
cd.setSi(sqinfo.getMediumInfo());
|
|
cd.setPub(false);
|
|
cd.setPub(false);
|
|
- cd.setDifficulty(QuestionDifficulty.MEDIUM);
|
|
|
|
|
|
+ cd.setDifficulty(QuestionDifficulty.MEDIUM.getName());
|
|
cd.setNeedCount(us.getNoPublicMedium());
|
|
cd.setNeedCount(us.getNoPublicMedium());
|
|
setQuestionInfoByExactItem(cd);
|
|
setQuestionInfoByExactItem(cd);
|
|
}
|
|
}
|
|
if (us.getPublicMedium() > 0) {
|
|
if (us.getPublicMedium() > 0) {
|
|
cd.setSi(sqinfo.getMediumInfo());
|
|
cd.setSi(sqinfo.getMediumInfo());
|
|
cd.setPub(true);
|
|
cd.setPub(true);
|
|
- cd.setDifficulty(QuestionDifficulty.MEDIUM);
|
|
|
|
|
|
+ cd.setDifficulty(QuestionDifficulty.MEDIUM.getName());
|
|
cd.setNeedCount(us.getPublicMedium());
|
|
cd.setNeedCount(us.getPublicMedium());
|
|
setQuestionInfoByExactItem(cd);
|
|
setQuestionInfoByExactItem(cd);
|
|
}
|
|
}
|
|
if (us.getNoPublicSimple() > 0) {
|
|
if (us.getNoPublicSimple() > 0) {
|
|
cd.setSi(sqinfo.getEasyInfo());
|
|
cd.setSi(sqinfo.getEasyInfo());
|
|
cd.setPub(false);
|
|
cd.setPub(false);
|
|
- cd.setDifficulty(QuestionDifficulty.EASY);
|
|
|
|
|
|
+ cd.setDifficulty(QuestionDifficulty.EASY.getName());
|
|
cd.setNeedCount(us.getNoPublicSimple());
|
|
cd.setNeedCount(us.getNoPublicSimple());
|
|
setQuestionInfoByExactItem(cd);
|
|
setQuestionInfoByExactItem(cd);
|
|
}
|
|
}
|
|
if (us.getPublicSimple() > 0) {
|
|
if (us.getPublicSimple() > 0) {
|
|
cd.setSi(sqinfo.getEasyInfo());
|
|
cd.setSi(sqinfo.getEasyInfo());
|
|
cd.setPub(true);
|
|
cd.setPub(true);
|
|
- cd.setDifficulty(QuestionDifficulty.EASY);
|
|
|
|
|
|
+ cd.setDifficulty(QuestionDifficulty.EASY.getName());
|
|
cd.setNeedCount(us.getPublicSimple());
|
|
cd.setNeedCount(us.getPublicSimple());
|
|
setQuestionInfoByExactItem(cd);
|
|
setQuestionInfoByExactItem(cd);
|
|
}
|
|
}
|
|
@@ -555,7 +533,7 @@ public class RandomPaperServiceImpl implements RandomPaperService {
|
|
RandomPaperQuestionDto rq = new RandomPaperQuestionDto();
|
|
RandomPaperQuestionDto rq = new RandomPaperQuestionDto();
|
|
rq.setUnitScore(cd.getUnitScore());
|
|
rq.setUnitScore(cd.getUnitScore());
|
|
rq.setDetailNumber(cd.getDetailNumber());
|
|
rq.setDetailNumber(cd.getDetailNumber());
|
|
- rq.setKey(cd.getIndex() + "-" + cd.getPub() + "-" + cd.getDifficulty().name());
|
|
|
|
|
|
+ rq.setKey(cd.getIndex() + "-" + cd.getPub() + "-" + cd.getDifficulty());
|
|
si.getQuestionInfo().add(rq);
|
|
si.getQuestionInfo().add(rq);
|
|
if (CollectionUtils.isNotEmpty(cd.getQuestionList())) {
|
|
if (CollectionUtils.isNotEmpty(cd.getQuestionList())) {
|
|
Iterator<QuestionDto> it = cd.getQuestionList().iterator();
|
|
Iterator<QuestionDto> it = cd.getQuestionList().iterator();
|
|
@@ -586,14 +564,14 @@ public class RandomPaperServiceImpl implements RandomPaperService {
|
|
if (cp.getNoPublicDifficulty() > 0) {
|
|
if (cp.getNoPublicDifficulty() > 0) {
|
|
cd.setSi(sqinfo.getHardInfo());
|
|
cd.setSi(sqinfo.getHardInfo());
|
|
cd.setPub(false);
|
|
cd.setPub(false);
|
|
- cd.setDifficulty(QuestionDifficulty.HARD);
|
|
|
|
|
|
+ cd.setDifficulty(QuestionDifficulty.HARD.getName());
|
|
cd.setNeedCount(cp.getNoPublicDifficulty());
|
|
cd.setNeedCount(cp.getNoPublicDifficulty());
|
|
setQuestionInfoByBlueProp(cd);
|
|
setQuestionInfoByBlueProp(cd);
|
|
}
|
|
}
|
|
if (cp.getPublicDifficulty() > 0) {
|
|
if (cp.getPublicDifficulty() > 0) {
|
|
cd.setSi(sqinfo.getHardInfo());
|
|
cd.setSi(sqinfo.getHardInfo());
|
|
cd.setPub(true);
|
|
cd.setPub(true);
|
|
- cd.setDifficulty(QuestionDifficulty.HARD);
|
|
|
|
|
|
+ cd.setDifficulty(QuestionDifficulty.HARD.getName());
|
|
cd.setNeedCount(cp.getPublicDifficulty());
|
|
cd.setNeedCount(cp.getPublicDifficulty());
|
|
setQuestionInfoByBlueProp(cd);
|
|
setQuestionInfoByBlueProp(cd);
|
|
}
|
|
}
|
|
@@ -601,28 +579,28 @@ public class RandomPaperServiceImpl implements RandomPaperService {
|
|
if (cp.getNoPublicMedium() > 0) {
|
|
if (cp.getNoPublicMedium() > 0) {
|
|
cd.setSi(sqinfo.getMediumInfo());
|
|
cd.setSi(sqinfo.getMediumInfo());
|
|
cd.setPub(false);
|
|
cd.setPub(false);
|
|
- cd.setDifficulty(QuestionDifficulty.MEDIUM);
|
|
|
|
|
|
+ cd.setDifficulty(QuestionDifficulty.MEDIUM.getName());
|
|
cd.setNeedCount(cp.getNoPublicMedium());
|
|
cd.setNeedCount(cp.getNoPublicMedium());
|
|
setQuestionInfoByBlueProp(cd);
|
|
setQuestionInfoByBlueProp(cd);
|
|
}
|
|
}
|
|
if (cp.getPublicMedium() > 0) {
|
|
if (cp.getPublicMedium() > 0) {
|
|
cd.setSi(sqinfo.getMediumInfo());
|
|
cd.setSi(sqinfo.getMediumInfo());
|
|
cd.setPub(true);
|
|
cd.setPub(true);
|
|
- cd.setDifficulty(QuestionDifficulty.MEDIUM);
|
|
|
|
|
|
+ cd.setDifficulty(QuestionDifficulty.MEDIUM.getName());
|
|
cd.setNeedCount(cp.getPublicMedium());
|
|
cd.setNeedCount(cp.getPublicMedium());
|
|
setQuestionInfoByBlueProp(cd);
|
|
setQuestionInfoByBlueProp(cd);
|
|
}
|
|
}
|
|
if (cp.getNoPublicSimple() > 0) {
|
|
if (cp.getNoPublicSimple() > 0) {
|
|
cd.setSi(sqinfo.getEasyInfo());
|
|
cd.setSi(sqinfo.getEasyInfo());
|
|
cd.setPub(false);
|
|
cd.setPub(false);
|
|
- cd.setDifficulty(QuestionDifficulty.EASY);
|
|
|
|
|
|
+ cd.setDifficulty(QuestionDifficulty.EASY.getName());
|
|
cd.setNeedCount(cp.getNoPublicSimple());
|
|
cd.setNeedCount(cp.getNoPublicSimple());
|
|
setQuestionInfoByBlueProp(cd);
|
|
setQuestionInfoByBlueProp(cd);
|
|
}
|
|
}
|
|
if (cp.getPublicSimple() > 0) {
|
|
if (cp.getPublicSimple() > 0) {
|
|
cd.setSi(sqinfo.getEasyInfo());
|
|
cd.setSi(sqinfo.getEasyInfo());
|
|
cd.setPub(true);
|
|
cd.setPub(true);
|
|
- cd.setDifficulty(QuestionDifficulty.EASY);
|
|
|
|
|
|
+ cd.setDifficulty(QuestionDifficulty.EASY.getName());
|
|
cd.setNeedCount(cp.getPublicSimple());
|
|
cd.setNeedCount(cp.getPublicSimple());
|
|
setQuestionInfoByBlueProp(cd);
|
|
setQuestionInfoByBlueProp(cd);
|
|
}
|
|
}
|
|
@@ -659,17 +637,17 @@ public class RandomPaperServiceImpl implements RandomPaperService {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- private String getExactErrmsg(Integer index, Integer detailNumber, Boolean pub, QuestionDifficulty difficulty) {
|
|
|
|
|
|
+ private String getExactErrmsg(Integer index, Integer detailNumber, Boolean pub, String difficulty) {
|
|
String pubstr;
|
|
String pubstr;
|
|
if (pub) {
|
|
if (pub) {
|
|
pubstr = "公开";
|
|
pubstr = "公开";
|
|
} else {
|
|
} else {
|
|
pubstr = "非公开";
|
|
pubstr = "非公开";
|
|
}
|
|
}
|
|
- return "第" + detailNumber + "大题 " + "第" + index + "题型结构 " + pubstr + "-" + difficulty.getName() + "题源数量不满足";
|
|
|
|
|
|
+ return "第" + detailNumber + "大题 " + "第" + index + "题型结构 " + pubstr + "-" + difficulty + "题源数量不满足";
|
|
}
|
|
}
|
|
|
|
|
|
- private String getBlueErrmsg(Integer detailNumber, String pproid, String proid, Boolean pub, QuestionDifficulty difficulty) {
|
|
|
|
|
|
+ private String getBlueErrmsg(Integer detailNumber, String pproid, String proid, Boolean pub, String difficulty) {
|
|
String pubstr;
|
|
String pubstr;
|
|
if (pub) {
|
|
if (pub) {
|
|
pubstr = "公开";
|
|
pubstr = "公开";
|
|
@@ -680,20 +658,20 @@ public class RandomPaperServiceImpl implements RandomPaperService {
|
|
// 有一级 和 二级
|
|
// 有一级 和 二级
|
|
Property fp = Model.of(propertyRepo.findById(pproid));
|
|
Property fp = Model.of(propertyRepo.findById(pproid));
|
|
Property sp = Model.of(propertyRepo.findById(proid));
|
|
Property sp = Model.of(propertyRepo.findById(proid));
|
|
- return "第" + detailNumber + "大题 " + fp.getName() + "-" + sp.getName() + "-" + pubstr + "-" + difficulty.getName()
|
|
|
|
|
|
+ return "第" + detailNumber + "大题 " + fp.getName() + "-" + sp.getName() + "-" + pubstr + "-" + difficulty
|
|
+ "题源数量不满足";
|
|
+ "题源数量不满足";
|
|
} else {
|
|
} else {
|
|
// 有一级 无 二级
|
|
// 有一级 无 二级
|
|
Property fp = Model.of(propertyRepo.findById(proid));
|
|
Property fp = Model.of(propertyRepo.findById(proid));
|
|
- return "第" + detailNumber + "大题 " + fp.getName() + "-" + pubstr + "-" + difficulty.getName() + "题源数量不满足";
|
|
|
|
|
|
+ return "第" + detailNumber + "大题 " + fp.getName() + "-" + pubstr + "-" + difficulty + "题源数量不满足";
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- private boolean checkExactQuesType(List<String> quesNames, QuesStructType st, Boolean pub, QuestionDifficulty difficulty,
|
|
|
|
|
|
+ private boolean checkExactQuesType(List<String> quesNames, QuesStructType st, Boolean pub, String difficulty,
|
|
QuestionDto question) {
|
|
QuestionDto question) {
|
|
if (CollectionUtils.isNotEmpty(quesNames)) {
|
|
if (CollectionUtils.isNotEmpty(quesNames)) {
|
|
if (quesNames.contains(question.getQuesName()) && st.equals(question.getQuestionType())) {
|
|
if (quesNames.contains(question.getQuesName()) && st.equals(question.getQuestionType())) {
|
|
- if (question.getPublicity().equals(pub) && QuestionDifficulty.getByName(question.getDifficulty()).equals(difficulty)) {
|
|
|
|
|
|
+ if (question.getPublicity().equals(pub) && question.getDifficulty().equals(difficulty)) {
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -730,15 +708,15 @@ public class RandomPaperServiceImpl implements RandomPaperService {
|
|
return units;
|
|
return units;
|
|
}
|
|
}
|
|
|
|
|
|
- private String bulidPropertyGroupByBlueStruct(String pproid, String proid, Boolean pub, QuestionDifficulty difficulty) {
|
|
|
|
|
|
+ private String bulidPropertyGroupByBlueStruct(String pproid, String proid, Boolean pub, String difficulty) {
|
|
String propertyGroup = null;
|
|
String propertyGroup = null;
|
|
// 获取试题关联的多组属性
|
|
// 获取试题关联的多组属性
|
|
if (StringUtils.isNotBlank(pproid) && !"0".equals(pproid)) {
|
|
if (StringUtils.isNotBlank(pproid) && !"0".equals(pproid)) {
|
|
// 有一级 和 二级
|
|
// 有一级 和 二级
|
|
- propertyGroup = pproid + "-" + proid + "-" + pub + "-" + difficulty.name();
|
|
|
|
|
|
+ propertyGroup = pproid + "-" + proid + "-" + pub + "-" + difficulty;
|
|
} else {
|
|
} else {
|
|
// 有一级 无 二级
|
|
// 有一级 无 二级
|
|
- propertyGroup = proid + "-" + pub + "-" + difficulty.name();
|
|
|
|
|
|
+ propertyGroup = proid + "-" + pub + "-" + difficulty;
|
|
}
|
|
}
|
|
return propertyGroup;
|
|
return propertyGroup;
|
|
}
|
|
}
|
|
@@ -755,17 +733,17 @@ public class RandomPaperServiceImpl implements RandomPaperService {
|
|
if (quesProperty.getSecondProperty().getId() == null
|
|
if (quesProperty.getSecondProperty().getId() == null
|
|
|| StringUtils.isBlank(String.valueOf(quesProperty.getSecondProperty().getId()))) {
|
|
|| StringUtils.isBlank(String.valueOf(quesProperty.getSecondProperty().getId()))) {
|
|
propertyGroup = String.valueOf(quesProperty.getFirstProperty().getId()) + "-"
|
|
propertyGroup = String.valueOf(quesProperty.getFirstProperty().getId()) + "-"
|
|
- + String.valueOf(question.getPublicity()) + "-" + QuestionDifficulty.getByName(question.getDifficulty()).name();
|
|
|
|
|
|
+ + String.valueOf(question.getPublicity()) + "-" + question.getDifficulty();
|
|
} else {
|
|
} else {
|
|
propertyGroup = String.valueOf(quesProperty.getFirstProperty().getId()) + "-"
|
|
propertyGroup = String.valueOf(quesProperty.getFirstProperty().getId()) + "-"
|
|
+ String.valueOf(quesProperty.getSecondProperty().getId()) + "-"
|
|
+ String.valueOf(quesProperty.getSecondProperty().getId()) + "-"
|
|
- + String.valueOf(question.getPublicity()) + "-" + QuestionDifficulty.getByName(question.getDifficulty()).name();
|
|
|
|
|
|
+ + String.valueOf(question.getPublicity()) + "-" + question.getDifficulty();
|
|
}
|
|
}
|
|
propertyGroups.add(propertyGroup);
|
|
propertyGroups.add(propertyGroup);
|
|
} else {
|
|
} else {
|
|
// 有一级 无 二级
|
|
// 有一级 无 二级
|
|
propertyGroup = String.valueOf(quesProperty.getFirstProperty().getId()) + "-"
|
|
propertyGroup = String.valueOf(quesProperty.getFirstProperty().getId()) + "-"
|
|
- + String.valueOf(question.getPublicity()) + "-" + QuestionDifficulty.getByName(question.getDifficulty()).name();
|
|
|
|
|
|
+ + String.valueOf(question.getPublicity()) + "-" + question.getDifficulty();
|
|
propertyGroups.add(propertyGroup);
|
|
propertyGroups.add(propertyGroup);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -832,8 +810,6 @@ public class RandomPaperServiceImpl implements RandomPaperService {
|
|
randomPaperQuestionRepo.saveAll(rqs);
|
|
randomPaperQuestionRepo.saveAll(rqs);
|
|
String key = CacheConstants.CACHE_Q_RANDOM_PAPER + e.getId();
|
|
String key = CacheConstants.CACHE_Q_RANDOM_PAPER + e.getId();
|
|
redisClient.delete(key);
|
|
redisClient.delete(key);
|
|
- String questionKey = CacheConstants.CACHE_Q_RANDOM_PAPER_QUESTION + e.getId();
|
|
|
|
- redisClient.delete(questionKey);
|
|
|
|
}
|
|
}
|
|
clearQuestionIds(ret);
|
|
clearQuestionIds(ret);
|
|
return ret;
|
|
return ret;
|
|
@@ -1044,14 +1020,14 @@ public class RandomPaperServiceImpl implements RandomPaperService {
|
|
CoursePropertyNumberDto cp = param.getCp();
|
|
CoursePropertyNumberDto cp = param.getCp();
|
|
if (cp.getNoPublicDifficulty() > 0) {
|
|
if (cp.getNoPublicDifficulty() > 0) {
|
|
String key = param.getDetailNumber() + "-" + bulidPropertyGroupByBlueStruct(cp.getPropertyParentId(),
|
|
String key = param.getDetailNumber() + "-" + bulidPropertyGroupByBlueStruct(cp.getPropertyParentId(),
|
|
- cp.getPropertyId(), false, QuestionDifficulty.HARD);
|
|
|
|
|
|
+ cp.getPropertyId(), false, QuestionDifficulty.HARD.getName());
|
|
param.setKey(key);
|
|
param.setKey(key);
|
|
param.setUnitCount(cp.getNoPublicDifficulty());
|
|
param.setUnitCount(cp.getNoPublicDifficulty());
|
|
createUnit(param);
|
|
createUnit(param);
|
|
}
|
|
}
|
|
if (cp.getPublicDifficulty() > 0) {
|
|
if (cp.getPublicDifficulty() > 0) {
|
|
String key = param.getDetailNumber() + "-" + bulidPropertyGroupByBlueStruct(cp.getPropertyParentId(),
|
|
String key = param.getDetailNumber() + "-" + bulidPropertyGroupByBlueStruct(cp.getPropertyParentId(),
|
|
- cp.getPropertyId(), true, QuestionDifficulty.HARD);
|
|
|
|
|
|
+ cp.getPropertyId(), true, QuestionDifficulty.HARD.getName());
|
|
param.setKey(key);
|
|
param.setKey(key);
|
|
param.setUnitCount(cp.getPublicDifficulty());
|
|
param.setUnitCount(cp.getPublicDifficulty());
|
|
createUnit(param);
|
|
createUnit(param);
|
|
@@ -1059,48 +1035,39 @@ public class RandomPaperServiceImpl implements RandomPaperService {
|
|
|
|
|
|
if (cp.getNoPublicMedium() > 0) {
|
|
if (cp.getNoPublicMedium() > 0) {
|
|
String key = param.getDetailNumber() + "-" + bulidPropertyGroupByBlueStruct(cp.getPropertyParentId(),
|
|
String key = param.getDetailNumber() + "-" + bulidPropertyGroupByBlueStruct(cp.getPropertyParentId(),
|
|
- cp.getPropertyId(), false, QuestionDifficulty.MEDIUM);
|
|
|
|
|
|
+ cp.getPropertyId(), false, QuestionDifficulty.MEDIUM.getName());
|
|
param.setKey(key);
|
|
param.setKey(key);
|
|
param.setUnitCount(cp.getNoPublicMedium());
|
|
param.setUnitCount(cp.getNoPublicMedium());
|
|
createUnit(param);
|
|
createUnit(param);
|
|
}
|
|
}
|
|
if (cp.getPublicMedium() > 0) {
|
|
if (cp.getPublicMedium() > 0) {
|
|
String key = param.getDetailNumber() + "-" + bulidPropertyGroupByBlueStruct(cp.getPropertyParentId(),
|
|
String key = param.getDetailNumber() + "-" + bulidPropertyGroupByBlueStruct(cp.getPropertyParentId(),
|
|
- cp.getPropertyId(), true, QuestionDifficulty.MEDIUM);
|
|
|
|
|
|
+ cp.getPropertyId(), true, QuestionDifficulty.MEDIUM.getName());
|
|
param.setKey(key);
|
|
param.setKey(key);
|
|
param.setUnitCount(cp.getPublicMedium());
|
|
param.setUnitCount(cp.getPublicMedium());
|
|
createUnit(param);
|
|
createUnit(param);
|
|
}
|
|
}
|
|
if (cp.getNoPublicSimple() > 0) {
|
|
if (cp.getNoPublicSimple() > 0) {
|
|
String key = param.getDetailNumber() + "-" + bulidPropertyGroupByBlueStruct(cp.getPropertyParentId(),
|
|
String key = param.getDetailNumber() + "-" + bulidPropertyGroupByBlueStruct(cp.getPropertyParentId(),
|
|
- cp.getPropertyId(), false, QuestionDifficulty.EASY);
|
|
|
|
|
|
+ cp.getPropertyId(), false, QuestionDifficulty.EASY.getName());
|
|
param.setKey(key);
|
|
param.setKey(key);
|
|
param.setUnitCount(cp.getNoPublicSimple());
|
|
param.setUnitCount(cp.getNoPublicSimple());
|
|
createUnit(param);
|
|
createUnit(param);
|
|
}
|
|
}
|
|
if (cp.getPublicSimple() > 0) {
|
|
if (cp.getPublicSimple() > 0) {
|
|
String key = param.getDetailNumber() + "-" + bulidPropertyGroupByBlueStruct(cp.getPropertyParentId(),
|
|
String key = param.getDetailNumber() + "-" + bulidPropertyGroupByBlueStruct(cp.getPropertyParentId(),
|
|
- cp.getPropertyId(), true, QuestionDifficulty.EASY);
|
|
|
|
|
|
+ cp.getPropertyId(), true, QuestionDifficulty.EASY.getName());
|
|
param.setKey(key);
|
|
param.setKey(key);
|
|
param.setUnitCount(cp.getPublicSimple());
|
|
param.setUnitCount(cp.getPublicSimple());
|
|
createUnit(param);
|
|
createUnit(param);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
- private List<Integer> getIndexList(Integer count){
|
|
|
|
- List<Integer> ret=new ArrayList<>();
|
|
|
|
- for (int i = 0; i < count; i++) {
|
|
|
|
- ret.add(count);
|
|
|
|
- }
|
|
|
|
- return ret;
|
|
|
|
- }
|
|
|
|
|
|
|
|
private void createUnit(CreateDefaultPaperParam param) {
|
|
private void createUnit(CreateDefaultPaperParam param) {
|
|
- Integer count = param.getRp().getQuestionMap().get(param.getKey());
|
|
|
|
- List<Integer> list=getIndexList(count);
|
|
|
|
- Collections.shuffle(list);
|
|
|
|
|
|
+ List<RandomPaperQuestion> rpqs = param.getRp().getQuestionMap().get(param.getKey());
|
|
|
|
+ Collections.shuffle(rpqs);
|
|
for (int i = 0; i < param.getUnitCount(); i++) {
|
|
for (int i = 0; i < param.getUnitCount(); i++) {
|
|
- RandomPaperQuestion rpq = getRandomPaperQuestionCacheById(param.getRp().getId(), param.getKey(), list.get(i));
|
|
|
|
|
|
+ RandomPaperQuestion rpq = rpqs.get(i);
|
|
DefaultQuestionStructureWrapper qw = new DefaultQuestionStructureWrapper();
|
|
DefaultQuestionStructureWrapper qw = new DefaultQuestionStructureWrapper();
|
|
param.getUnits().add(qw);
|
|
param.getUnits().add(qw);
|
|
qw.setLimitedPlayTimes(param.getPlayTime());
|
|
qw.setLimitedPlayTimes(param.getPlayTime());
|
|
@@ -1168,18 +1135,16 @@ public class RandomPaperServiceImpl implements RandomPaperService {
|
|
private RandomPaperCache getRandomPaperTemplateCacheById(String randomPaperId) {
|
|
private RandomPaperCache getRandomPaperTemplateCacheById(String randomPaperId) {
|
|
// 抽卷模板 优先从本地缓存中获取
|
|
// 抽卷模板 优先从本地缓存中获取
|
|
String key = CacheConstants.CACHE_Q_RANDOM_PAPER + randomPaperId;
|
|
String key = CacheConstants.CACHE_Q_RANDOM_PAPER + randomPaperId;
|
|
-// RandomPaperCache rp = localRandomPaperCache.getIfPresent(key);
|
|
|
|
-// if (rp != null) {
|
|
|
|
-// log.warn("从【本地缓存】中获取抽卷模板! key:{}", key);
|
|
|
|
-// return rp;
|
|
|
|
-// }
|
|
|
|
|
|
+ RandomPaperCache rp = localRandomPaperCache.getIfPresent(key);
|
|
|
|
+ if (rp != null) {
|
|
|
|
+ log.warn("从【本地缓存】中获取抽卷模板! key:{}", key);
|
|
|
|
+ return rp;
|
|
|
|
+ }
|
|
|
|
|
|
// 从redis缓存中获取
|
|
// 从redis缓存中获取
|
|
- RandomPaperCache rp = redisClient.get(key, RandomPaperCache.class, cacheTimeOut);
|
|
|
|
|
|
+ rp = redisClient.get(key, RandomPaperCache.class, cacheTimeOut);
|
|
if (rp != null) {
|
|
if (rp != null) {
|
|
- String questionKey = CacheConstants.CACHE_Q_RANDOM_PAPER_QUESTION + randomPaperId;
|
|
|
|
- redisClient.expire(questionKey, cacheTimeOut);
|
|
|
|
-// localRandomPaperCache.put(key, rp);
|
|
|
|
|
|
+ localRandomPaperCache.put(key, rp);
|
|
log.warn("从【Redis缓存】中获取抽卷模板! key:{}", key);
|
|
log.warn("从【Redis缓存】中获取抽卷模板! key:{}", key);
|
|
return rp;
|
|
return rp;
|
|
}
|
|
}
|
|
@@ -1197,60 +1162,22 @@ public class RandomPaperServiceImpl implements RandomPaperService {
|
|
|
|
|
|
log.warn("从【数据库】中获取抽卷模板! key:{}", key);
|
|
log.warn("从【数据库】中获取抽卷模板! key:{}", key);
|
|
rp = new RandomPaperCache();
|
|
rp = new RandomPaperCache();
|
|
- rp.setId(entity.getId());
|
|
|
|
rp.setName(entity.getName());
|
|
rp.setName(entity.getName());
|
|
rp.setPaperStructId(entity.getPaperStructId());
|
|
rp.setPaperStructId(entity.getPaperStructId());
|
|
|
|
|
|
- Map<String, Integer> map = new HashMap<>();
|
|
|
|
- String questionKey = CacheConstants.CACHE_Q_RANDOM_PAPER_QUESTION + randomPaperId;
|
|
|
|
|
|
+ Map<String, List<RandomPaperQuestion>> map = new HashMap<>();
|
|
for (RandomPaperQuestion rpq : rpQuestions) {
|
|
for (RandomPaperQuestion rpq : rpQuestions) {
|
|
- Integer count = map.get(rpq.getKey());
|
|
|
|
- if (count == null) {
|
|
|
|
- count = 0;
|
|
|
|
|
|
+ List<RandomPaperQuestion> list = map.get(rpq.getKey());
|
|
|
|
+ if (list == null) {
|
|
|
|
+ list = new ArrayList<>();
|
|
|
|
+ map.put(rpq.getKey(), list);
|
|
}
|
|
}
|
|
- map.put(rpq.getKey(), count+1);
|
|
|
|
- redisClient.set(questionKey,rpq.getKey()+"_"+count, rpq, cacheTimeOut);
|
|
|
|
|
|
+ list.add(rpq);
|
|
}
|
|
}
|
|
rp.setQuestionMap(map);
|
|
rp.setQuestionMap(map);
|
|
|
|
|
|
redisClient.set(key, rp, cacheTimeOut);
|
|
redisClient.set(key, rp, cacheTimeOut);
|
|
-// localRandomPaperCache.put(key, rp);
|
|
|
|
- return rp;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- private RandomPaperQuestion getRandomPaperQuestionCacheById(String randomPaperId,String ckey,Integer index) {
|
|
|
|
- String questionKey = CacheConstants.CACHE_Q_RANDOM_PAPER_QUESTION + randomPaperId;
|
|
|
|
- String subKey=ckey+"_"+index;
|
|
|
|
- // 从redis缓存中获取
|
|
|
|
- RandomPaperQuestion rp = redisClient.get(questionKey,subKey, RandomPaperQuestion.class);
|
|
|
|
- if (rp != null) {
|
|
|
|
- log.warn("从【Redis缓存】中获取抽卷小题! key:{},subKey:{}", questionKey,subKey);
|
|
|
|
- return rp;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- // 从数据库中获取
|
|
|
|
- List<RandomPaperQuestion> rpQuestions = randomPaperQuestionRepo.findByRandomPaperId(randomPaperId);
|
|
|
|
- if (CollectionUtils.isEmpty(rpQuestions)) {
|
|
|
|
- throw new StatusException("随机模板试题库为空:" + randomPaperId);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- log.warn("从【数据库】中获取抽卷小题! key:{}", questionKey);
|
|
|
|
-
|
|
|
|
- Map<String, Integer> map = new HashMap<>();
|
|
|
|
- for (RandomPaperQuestion rpq : rpQuestions) {
|
|
|
|
- Integer count = map.get(rpq.getKey());
|
|
|
|
- if (count == null) {
|
|
|
|
- count = 0;
|
|
|
|
- }
|
|
|
|
- map.put(rpq.getKey(), count+1);
|
|
|
|
- redisClient.set(questionKey,rpq.getKey()+"_"+count, rpq, cacheTimeOut);
|
|
|
|
- if(subKey.equals(rpq.getKey()+"_"+count)) {
|
|
|
|
- rp=rpq;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- if (rp == null) {
|
|
|
|
- throw new StatusException("随机模板试题库信息异常,未找到小题信息. key:"+questionKey+",subKey:"+subKey);
|
|
|
|
- }
|
|
|
|
|
|
+ localRandomPaperCache.put(key, rp);
|
|
return rp;
|
|
return rp;
|
|
}
|
|
}
|
|
|
|
|