|
@@ -21,6 +21,7 @@ import cn.com.qmth.examcloud.core.questions.dao.*;
|
|
|
import cn.com.qmth.examcloud.core.questions.dao.entity.*;
|
|
|
import cn.com.qmth.examcloud.core.questions.service.*;
|
|
|
import cn.com.qmth.examcloud.core.questions.service.bean.dto.*;
|
|
|
+import cn.com.qmth.examcloud.core.questions.service.cache.BasePaperCache;
|
|
|
import cn.com.qmth.examcloud.core.questions.service.config.UpYunProperty;
|
|
|
import cn.com.qmth.examcloud.core.questions.service.export.ExportPaperAbstractService;
|
|
|
import cn.com.qmth.examcloud.core.questions.service.rpc.PrintCoursePaperClient;
|
|
@@ -123,6 +124,9 @@ public class PaperServiceImpl implements PaperService {
|
|
|
@Autowired
|
|
|
private CoursePaperCloudService coursePaperCloudService1;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private BasePaperCache basePaperCache;
|
|
|
+
|
|
|
@Autowired
|
|
|
private UpYunProperty upYunProperty;
|
|
|
|
|
@@ -252,7 +256,8 @@ public class PaperServiceImpl implements PaperService {
|
|
|
*/
|
|
|
@SuppressWarnings("unchecked")
|
|
|
public Map<String, Object> savePaper(PaperExp paperExp, User user) {
|
|
|
- Map<String, Object> msgMap = new HashMap<String, Object>();
|
|
|
+ Map<String, Object> msgMap = new HashMap<>();
|
|
|
+
|
|
|
Paper oldPaper = Model.of(paperRepo.findById(paperExp.getId()));
|
|
|
if (oldPaper != null) {
|
|
|
String oldName = oldPaper.getName().trim();
|
|
@@ -276,8 +281,10 @@ public class PaperServiceImpl implements PaperService {
|
|
|
msgMap.put("msg", "success");
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
//删除缓存
|
|
|
redisClient.delete(CACHE_PREFIX_FOR_PAPER + paperExp.getId());
|
|
|
+ basePaperCache.remove(paperExp.getId());
|
|
|
|
|
|
return msgMap;
|
|
|
}
|
|
@@ -442,6 +449,7 @@ public class PaperServiceImpl implements PaperService {
|
|
|
//清除缓存
|
|
|
for (String paperId : paperIds) {
|
|
|
redisClient.delete(CACHE_PREFIX_FOR_PAPER + paperId);
|
|
|
+ basePaperCache.remove(paperId);
|
|
|
}
|
|
|
|
|
|
msg = "success";
|
|
@@ -802,6 +810,7 @@ public class PaperServiceImpl implements PaperService {
|
|
|
|
|
|
//清除缓存
|
|
|
redisClient.delete(CACHE_PREFIX_FOR_PAPER + paper.getId());
|
|
|
+ basePaperCache.remove(paper.getId());
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -893,21 +902,24 @@ public class PaperServiceImpl implements PaperService {
|
|
|
}
|
|
|
|
|
|
@SuppressWarnings("unused")
|
|
|
- public Paper selectQuestionsToPaper(String paperId, String paperDetailId, List<Question> questions,
|
|
|
- User user) {
|
|
|
+ public Paper selectQuestionsToPaper(String paperId, String paperDetailId, List<Question> questions, User user) {
|
|
|
Paper paper = Model.of(paperRepo.findById(paperId));
|
|
|
PaperDetail paperDetail = Model.of(paperDetailRepo.findById(paperDetailId));
|
|
|
PaperDetailUnit paperDetailUnit = paperDetailUnitRepo.findTopByPaperDetailOrderByNumberDesc(paperDetail);
|
|
|
- List<PaperDetailUnit> saveUnits = new ArrayList<PaperDetailUnit>();
|
|
|
+
|
|
|
+ List<PaperDetailUnit> saveUnits = new ArrayList<>();
|
|
|
for (Question ques : questions) {
|
|
|
PaperDetailUnit pdu = new PaperDetailUnit(paper, paperDetail, ques);
|
|
|
+
|
|
|
//如果大题没有小题,取导入的试题分数
|
|
|
if (paperDetailUnit == null) {
|
|
|
pdu.setNumber(1);
|
|
|
} else {
|
|
|
pdu.setNumber(paperDetailUnit.getNumber());//设置为大题中最大的number
|
|
|
}
|
|
|
+
|
|
|
pdu.setScore(ques.getScore() == null ? 0d : ques.getScore());
|
|
|
+
|
|
|
//处理套题
|
|
|
if (pdu.getQuestionType() == QuesStructType.NESTED_ANSWER_QUESTION) {
|
|
|
List<Question> subQuestions = ques.getSubQuestions();
|
|
@@ -919,13 +931,16 @@ public class PaperServiceImpl implements PaperService {
|
|
|
}
|
|
|
pdu.setSubScoreListNew(subScoreList);
|
|
|
}
|
|
|
+
|
|
|
saveUnits.add(pdu);
|
|
|
}
|
|
|
+
|
|
|
paperDetailUnitRepo.saveAll(saveUnits);
|
|
|
|
|
|
//清除缓存
|
|
|
if (paper.getPaperType() == PaperType.GENERATE) {
|
|
|
redisClient.delete(redisPaperPrefix + ":" + paper.getId());
|
|
|
+ basePaperCache.remove(paper.getId());
|
|
|
}
|
|
|
|
|
|
formatPaper(paper, user);
|