|
@@ -43,21 +43,7 @@ public class SpecialReportService {
|
|
|
|
|
|
private static final Logger logger = LoggerFactory.getLogger(SpecialReportService.class);
|
|
|
|
|
|
-// public SpecialResult generate(Long pid, Long uid) {
|
|
|
-// Paper paper = paperService.getOnePaper(pid);
|
|
|
-// if (paper == null) {
|
|
|
-// logger.error("未找到试卷 pid={}", pid);
|
|
|
-// return null;
|
|
|
-// }
|
|
|
-// PaperCommit commit = commitService.getPaperCommit(pid, uid);
|
|
|
-// if (commit == null) {
|
|
|
-// logger.error("用户未提交 pid={},uid={}", pid, uid);
|
|
|
-// return null;
|
|
|
-// }
|
|
|
-// return generate(commit, paper);
|
|
|
-// }
|
|
|
-
|
|
|
- public SpecialResult generate2(Long pid, Long uid) {
|
|
|
+ public SpecialResult generate(Long pid, Long uid) {
|
|
|
logger.info("正在生成专项诊断报告");
|
|
|
Paper paper = paperService.getOnePaper(pid);
|
|
|
if (paper == null) {
|
|
@@ -69,61 +55,30 @@ public class SpecialReportService {
|
|
|
logger.error("用户未提交 pid={},uid={}", pid, uid);
|
|
|
return null;
|
|
|
}
|
|
|
- return generate2(commit, paper);
|
|
|
+ return generate(commit, paper);
|
|
|
}
|
|
|
|
|
|
- @Transactional(rollbackOn = Exception.class)
|
|
|
- public SpecialResult generate(PaperCommit commit, Paper paper) {
|
|
|
- PaperResult result = paperResultService.findByPidAndUid(commit.getPid(), commit.getUid()).get(0);
|
|
|
- List<SpecialKnowledge> list = specialKnowledgeService.list(paper.getSubjectId(), paper.getGrade());
|
|
|
- //找出叶子节点
|
|
|
- Map<String, SpecialKnowledge> map = list.stream().filter(s -> s.getCode() != null)
|
|
|
- .collect(Collectors.toMap(SpecialKnowledge::getCode, Function.identity()));
|
|
|
- if (CommonUtil.isEmpty(list)) {
|
|
|
- logger.error("未上传专项诊断知识点,subjectId={},grade={}", paper.getSubjectId(), paper.getGrade());
|
|
|
+ public SpecialResult generate(Long resultId) {
|
|
|
+ logger.info("正在生成专项诊断报告");
|
|
|
+ PaperResult result = paperResultService.get(resultId);
|
|
|
+ if (result == null) {
|
|
|
+ logger.error("未找到报告 paperResultId={}", resultId);
|
|
|
return null;
|
|
|
}
|
|
|
- if (result == null) {
|
|
|
- //重新生成PaperResult
|
|
|
- result = (PaperResult) paperResultService.parseResult(commit, paper).getT();
|
|
|
+ Paper paper = paperService.getOnePaper(result.getPid());
|
|
|
+ if (paper == null) {
|
|
|
+ logger.error("未找到试卷 pid={}", result.getPid());
|
|
|
+ return null;
|
|
|
}
|
|
|
- String collect = result.getCollectQuestion();
|
|
|
- //答对的选项
|
|
|
- List<Integer> collects = Arrays.stream(collect.split(","))
|
|
|
- .map(Integer::parseInt).collect(Collectors.toList());
|
|
|
-// String wrong = result.getWrongQuestion();
|
|
|
-// String wrongs[] = wrong.split(",");
|
|
|
- List<Question> questions = paper.getQuestions();
|
|
|
- Map<String, List<Question>> group = questions.stream().collect(Collectors.groupingBy(Question::getTag));
|
|
|
- for (Map.Entry<String, List<Question>> entry : group.entrySet()) {
|
|
|
- String code = entry.getKey();
|
|
|
- List<Question> qs = entry.getValue();
|
|
|
- SpecialKnowledge knowledge = map.get(code);
|
|
|
- if (knowledge == null) {
|
|
|
- continue;
|
|
|
- }
|
|
|
- knowledge.setQuestionNum(qs.size());
|
|
|
- knowledge.setCollectNum(getCount(qs, collects));
|
|
|
+ PaperCommit commit = commitService.findByCommit(result.getCid());
|
|
|
+ if (commit == null) {
|
|
|
+ logger.error("用户未提交 pid={},uid={}", result.getPid(), result.getUid());
|
|
|
+ return null;
|
|
|
}
|
|
|
-
|
|
|
- List<SpecialKnowledge> tree = specialKnowledgeService.toTree(list);
|
|
|
- //统计结果并且剪枝,剪掉>3的层级
|
|
|
- specialKnowledgeService.calcCount(list);
|
|
|
-
|
|
|
- logger.info(tree.toString());
|
|
|
- SpecialResult r = new SpecialResult();
|
|
|
- r.setCode(paper.getCode());
|
|
|
- r.setCollectQuestion(collect);
|
|
|
- r.setWrongQuestion(result.getWrongQuestion());
|
|
|
- r.setScore(result.getScore());
|
|
|
- r.setTotalScore(result.getTotalScore());
|
|
|
- r.setPid(result.getPid());
|
|
|
- r.setUid(result.getUid());
|
|
|
- r.setKnowledges(tree);
|
|
|
- return r;
|
|
|
+ return generate(commit, paper);
|
|
|
}
|
|
|
|
|
|
- public SpecialResult generate2(PaperCommit commit, Paper paper) {
|
|
|
+ public SpecialResult generate(PaperCommit commit, Paper paper) {
|
|
|
PaperResult result = paperResultService.findByPidAndUid(commit.getPid(), commit.getUid()).get(0);
|
|
|
List<SpecialKnowledge> list = specialKnowledgeService.listByPid(paper.getId());
|
|
|
|
|
@@ -183,20 +138,6 @@ public class SpecialReportService {
|
|
|
return r;
|
|
|
}
|
|
|
|
|
|
- private void calcMind(List<SpecialMind> list) {
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- private Integer getCount(List<Question> qs, List<Integer> collects) {
|
|
|
- int count = 0;
|
|
|
- for (Question q : qs) {
|
|
|
- if (collects.contains(q.getNumber())) {
|
|
|
- count++;
|
|
|
- }
|
|
|
- }
|
|
|
- return count;
|
|
|
- }
|
|
|
-
|
|
|
public List<SpecialMindVo> generateMind(Long pid, Long uid) {
|
|
|
logger.info("正在生成专项诊断报告");
|
|
|
Paper paper = paperService.getOnePaper(pid);
|
|
@@ -212,6 +153,26 @@ public class SpecialReportService {
|
|
|
return generateMind(commit, paper);
|
|
|
}
|
|
|
|
|
|
+ public List<SpecialMindVo> generateMind(Long resultId) {
|
|
|
+ logger.info("正在生成专项诊断报告");
|
|
|
+ PaperResult result = paperResultService.get(resultId);
|
|
|
+ if (result == null) {
|
|
|
+ logger.error("未找到报告 paperResultId={}", resultId);
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ Paper paper = paperService.getOnePaper(result.getPid());
|
|
|
+ if (paper == null) {
|
|
|
+ logger.error("未找到试卷 pid={}", result.getPid());
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ PaperCommit commit = commitService.findByCommit(result.getCid());
|
|
|
+ if (commit == null) {
|
|
|
+ logger.error("用户未提交 pid={},uid={}", result.getPid(), result.getUid());
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ return generateMind(commit, paper);
|
|
|
+ }
|
|
|
+
|
|
|
public List<SpecialMindVo> generateMind(PaperCommit commit, Paper paper) {
|
|
|
PaperResult result = paperResultService.findByPidAndUid(commit.getPid(), commit.getUid()).get(0);
|
|
|
List<SpecialMind> list = specialMindService.findByPid(paper.getId());
|