|
@@ -11,7 +11,6 @@ import com.qmth.themis.business.bean.backend.OpenRecordAnswerBean;
|
|
|
import com.qmth.themis.business.bean.backend.OpenRecordNeedMarkBean;
|
|
|
import com.qmth.themis.business.cache.RedisKeyHelper;
|
|
|
import com.qmth.themis.business.cache.bean.ExamPaperCacheBean;
|
|
|
-import com.qmth.themis.business.constant.SystemConstant;
|
|
|
import com.qmth.themis.business.entity.TEExam;
|
|
|
import com.qmth.themis.business.entity.TEExamCourse;
|
|
|
import com.qmth.themis.business.enums.InvigilateMonitorStatusEnum;
|
|
@@ -19,18 +18,22 @@ import com.qmth.themis.business.enums.RecordSelectStrategyEnum;
|
|
|
import com.qmth.themis.business.service.*;
|
|
|
import com.qmth.themis.business.util.OssUtil;
|
|
|
import com.qmth.themis.common.exception.BusinessException;
|
|
|
-import com.qmth.themis.common.util.FileUtil;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.slf4j.Logger;
|
|
|
+import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
-import java.io.File;
|
|
|
+import java.io.IOException;
|
|
|
+import java.nio.charset.StandardCharsets;
|
|
|
import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
@Service
|
|
|
public class TEOpenServiceImpl implements TEOpenService {
|
|
|
|
|
|
+ private final static Logger log = LoggerFactory.getLogger(TEOpenServiceImpl.class);
|
|
|
+
|
|
|
@Resource
|
|
|
TEExamService examService;
|
|
|
|
|
@@ -60,137 +63,124 @@ public class TEOpenServiceImpl implements TEOpenService {
|
|
|
return ret.getRecords();
|
|
|
}
|
|
|
|
|
|
-
|
|
|
@Override
|
|
|
public List<OpenExamCourseBean> examCourseQueryPage(Long examId, String courseCode, Boolean hasPaper,
|
|
|
- int pageNumber, int pageSize) {
|
|
|
+ int pageNumber, int pageSize) {
|
|
|
Page<OpenExamCourseBean> ipage = new Page<>(pageNumber, pageSize);
|
|
|
ipage.addOrder(OrderItem.desc("t.id"));
|
|
|
IPage<OpenExamCourseBean> ret = examCourseService.examCourseQueryForOpen(ipage, examId, courseCode, hasPaper);
|
|
|
return ret.getRecords();
|
|
|
}
|
|
|
|
|
|
-
|
|
|
@Override
|
|
|
- public JSONObject examPaperDetail(Long paperId, String filter) {
|
|
|
- String tempDir = SystemConstant.TEMP_FILES_DIR;
|
|
|
- String dir = tempDir + "/" + uuid() + "/";
|
|
|
- File dfile = new File(dir);
|
|
|
-
|
|
|
- try {
|
|
|
- ExamPaperCacheBean paper = examPaperService.getExamPaperCacheBean(paperId);
|
|
|
- if (paper == null) {
|
|
|
- throw new BusinessException("未找到试卷信息");
|
|
|
- }
|
|
|
- checkExam(paper.getExamId());
|
|
|
- dfile.mkdirs();
|
|
|
- String paperPath = paper.getPaperViewPath();
|
|
|
- String anwserPath = paper.getAnswerPath();
|
|
|
- File paperFile = new File(dir + uuid() + ".json");
|
|
|
- File anwserFile = new File(dir + uuid() + ".json");
|
|
|
- FileUtil.saveUrlAsFile(ossUtil.getAliYunOssPrivateDomain().getPrivateUrl() + "/" + paperPath, paperFile);
|
|
|
- FileUtil.saveUrlAsFile(ossUtil.getAliYunOssPrivateDomain().getPrivateUrl() + "/" + anwserPath, anwserFile);
|
|
|
- JSONObject answerJson = JSONObject.parseObject(FileUtil.readFileContent(anwserFile));
|
|
|
- JSONArray answerdetails = answerJson.getJSONArray("details");
|
|
|
- JSONObject structJson = JSONObject.parseObject(FileUtil.readFileContent(paperFile));
|
|
|
- structJson.put("id", paperId);
|
|
|
- structJson.put("code", paper.getCode());
|
|
|
- JSONArray structdetails = structJson.getJSONArray("details");
|
|
|
- for (int i = 0; i < answerdetails.size(); i++) {
|
|
|
- JSONArray answerdetailquestions = answerdetails.getJSONObject(i).getJSONArray("questions");
|
|
|
- JSONArray structdetailquestions = structdetails.getJSONObject(i).getJSONArray("questions");
|
|
|
- for (int j = 0; j < structdetailquestions.size(); j++) {
|
|
|
- JSONObject answerquestion = answerdetailquestions.getJSONObject(j);
|
|
|
- JSONObject structquestion = structdetailquestions.getJSONObject(j);
|
|
|
- if ("objective".equals(filter)) {
|
|
|
- if (structquestion.getInteger("structType").intValue() == 1
|
|
|
- || structquestion.getInteger("structType").intValue() == 2
|
|
|
- || structquestion.getInteger("structType").intValue() == 3) {
|
|
|
- if (structquestion.getInteger("structType").intValue() == 3) {
|
|
|
- structquestion.put("answer", answerquestion.getBoolean("answer"));
|
|
|
- } else {
|
|
|
- structquestion.put("answer", answerquestion.getJSONArray("answer"));
|
|
|
- }
|
|
|
+ public JSONObject examPaperDetail(Long paperId, String filter) throws IOException {
|
|
|
+ ExamPaperCacheBean paper = examPaperService.getExamPaperCacheBean(paperId);
|
|
|
+ if (paper == null) {
|
|
|
+ throw new BusinessException("未找到试卷信息");
|
|
|
+ }
|
|
|
+ checkExam(paper.getExamId());
|
|
|
+ String paperPath = paper.getPaperViewPath();
|
|
|
+ String anwserPath = paper.getAnswerPath();
|
|
|
+ JSONObject answerJson = JSONObject
|
|
|
+ .parseObject(new String(ossUtil.download(false, anwserPath), StandardCharsets.UTF_8));
|
|
|
+ JSONArray answerdetails = answerJson.getJSONArray("details");
|
|
|
+ JSONObject structJson = JSONObject
|
|
|
+ .parseObject(new String(ossUtil.download(false, paperPath), StandardCharsets.UTF_8));
|
|
|
+ structJson.put("id", paperId);
|
|
|
+ structJson.put("code", paper.getCode());
|
|
|
+ JSONArray structdetails = structJson.getJSONArray("details");
|
|
|
+ for (int i = 0; i < answerdetails.size(); i++) {
|
|
|
+ JSONArray answerdetailquestions = answerdetails.getJSONObject(i).getJSONArray("questions");
|
|
|
+ JSONArray structdetailquestions = structdetails.getJSONObject(i).getJSONArray("questions");
|
|
|
+ for (int j = 0; j < structdetailquestions.size(); j++) {
|
|
|
+ JSONObject answerquestion = answerdetailquestions.getJSONObject(j);
|
|
|
+ JSONObject structquestion = structdetailquestions.getJSONObject(j);
|
|
|
+ if ("objective".equals(filter)) {
|
|
|
+ if (structquestion.getInteger("structType").intValue() == 1
|
|
|
+ || structquestion.getInteger("structType").intValue() == 2
|
|
|
+ || structquestion.getInteger("structType").intValue() == 3) {
|
|
|
+ if (structquestion.getInteger("structType").intValue() == 3) {
|
|
|
+ structquestion.put("answer", answerquestion.getBoolean("answer"));
|
|
|
} else {
|
|
|
- if (structquestion.getInteger("structType").intValue() == 6) {
|
|
|
- JSONArray answersubQuestions = answerquestion.getJSONArray("subQuestions");
|
|
|
- JSONArray structsubQuestions = structquestion.getJSONArray("subQuestions");
|
|
|
- for (int k = 0; k < structsubQuestions.size(); k++) {
|
|
|
- JSONObject answersubquestion = answersubQuestions.getJSONObject(k);
|
|
|
- JSONObject structsubquestion = structsubQuestions.getJSONObject(k);
|
|
|
- if (structsubquestion.getInteger("structType").intValue() == 1
|
|
|
- || structsubquestion.getInteger("structType").intValue() == 2
|
|
|
- || structsubquestion.getInteger("structType").intValue() == 3) {
|
|
|
- if (structsubquestion.getInteger("structType").intValue() == 3) {
|
|
|
- structsubquestion.put("answer", answersubquestion.getBoolean("answer"));
|
|
|
- } else {
|
|
|
- structsubquestion.put("answer", answersubquestion.getJSONArray("answer"));
|
|
|
- }
|
|
|
- } else {
|
|
|
- structsubQuestions.remove(k);
|
|
|
- k--;
|
|
|
- }
|
|
|
- }
|
|
|
- } else {
|
|
|
- structdetailquestions.remove(j);
|
|
|
- j--;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- } else if ("subjective".equals(filter)) {
|
|
|
- if (structquestion.getInteger("structType").intValue() != 1
|
|
|
- && structquestion.getInteger("structType").intValue() != 2
|
|
|
- && structquestion.getInteger("structType").intValue() != 3) {
|
|
|
structquestion.put("answer", answerquestion.getJSONArray("answer"));
|
|
|
- } else {
|
|
|
- if (structquestion.getInteger("structType").intValue() == 6) {
|
|
|
- JSONArray answersubQuestions = answerquestion.getJSONArray("subQuestions");
|
|
|
- JSONArray structsubQuestions = structquestion.getJSONArray("subQuestions");
|
|
|
- for (int k = 0; k < structsubQuestions.size(); k++) {
|
|
|
- JSONObject answersubquestion = answersubQuestions.getJSONObject(k);
|
|
|
- JSONObject structsubquestion = structsubQuestions.getJSONObject(k);
|
|
|
- if (structsubquestion.getInteger("structType").intValue() != 1
|
|
|
- && structsubquestion.getInteger("structType").intValue() != 2
|
|
|
- && structsubquestion.getInteger("structType").intValue() != 3) {
|
|
|
- structsubquestion.put("answer", answersubquestion.getJSONArray("answer"));
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if (structquestion.getInteger("structType").intValue() == 6) {
|
|
|
+ JSONArray answersubQuestions = answerquestion.getJSONArray("subQuestions");
|
|
|
+ JSONArray structsubQuestions = structquestion.getJSONArray("subQuestions");
|
|
|
+ for (int k = 0; k < structsubQuestions.size(); k++) {
|
|
|
+ JSONObject answersubquestion = answersubQuestions.getJSONObject(k);
|
|
|
+ JSONObject structsubquestion = structsubQuestions.getJSONObject(k);
|
|
|
+ if (structsubquestion.getInteger("structType").intValue() == 1
|
|
|
+ || structsubquestion.getInteger("structType").intValue() == 2
|
|
|
+ || structsubquestion.getInteger("structType").intValue() == 3) {
|
|
|
+ if (structsubquestion.getInteger("structType").intValue() == 3) {
|
|
|
+ structsubquestion.put("answer", answersubquestion.getBoolean("answer"));
|
|
|
} else {
|
|
|
- structsubQuestions.remove(k);
|
|
|
- k--;
|
|
|
+ structsubquestion.put("answer", answersubquestion.getJSONArray("answer"));
|
|
|
}
|
|
|
+ } else {
|
|
|
+ structsubQuestions.remove(k);
|
|
|
+ k--;
|
|
|
}
|
|
|
- } else {
|
|
|
- structdetailquestions.remove(j);
|
|
|
- j--;
|
|
|
}
|
|
|
+ } else {
|
|
|
+ structdetailquestions.remove(j);
|
|
|
+ j--;
|
|
|
}
|
|
|
+ }
|
|
|
+
|
|
|
+ } else if ("subjective".equals(filter)) {
|
|
|
+ if (structquestion.getInteger("structType").intValue() != 1
|
|
|
+ && structquestion.getInteger("structType").intValue() != 2
|
|
|
+ && structquestion.getInteger("structType").intValue() != 3) {
|
|
|
+ structquestion.put("answer", answerquestion.getJSONArray("answer"));
|
|
|
} else {
|
|
|
- if (structquestion.getInteger("structType").intValue() != 6) {
|
|
|
- if (structquestion.getInteger("structType").intValue() == 3) {
|
|
|
- structquestion.put("answer", answerquestion.getBoolean("answer"));
|
|
|
- } else {
|
|
|
- structquestion.put("answer", answerquestion.getJSONArray("answer"));
|
|
|
- }
|
|
|
- } else {
|
|
|
+ if (structquestion.getInteger("structType").intValue() == 6) {
|
|
|
JSONArray answersubQuestions = answerquestion.getJSONArray("subQuestions");
|
|
|
JSONArray structsubQuestions = structquestion.getJSONArray("subQuestions");
|
|
|
for (int k = 0; k < structsubQuestions.size(); k++) {
|
|
|
JSONObject answersubquestion = answersubQuestions.getJSONObject(k);
|
|
|
JSONObject structsubquestion = structsubQuestions.getJSONObject(k);
|
|
|
- if (structsubquestion.getInteger("structType").intValue() == 3) {
|
|
|
- structsubquestion.put("answer", answersubquestion.getBoolean("answer"));
|
|
|
- } else {
|
|
|
+ if (structsubquestion.getInteger("structType").intValue() != 1
|
|
|
+ && structsubquestion.getInteger("structType").intValue() != 2
|
|
|
+ && structsubquestion.getInteger("structType").intValue() != 3) {
|
|
|
structsubquestion.put("answer", answersubquestion.getJSONArray("answer"));
|
|
|
+ } else {
|
|
|
+ structsubQuestions.remove(k);
|
|
|
+ k--;
|
|
|
}
|
|
|
}
|
|
|
+ } else {
|
|
|
+ structdetailquestions.remove(j);
|
|
|
+ j--;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if (structquestion.getInteger("structType").intValue() != 6) {
|
|
|
+ if (structquestion.getInteger("structType").intValue() == 3) {
|
|
|
+ structquestion.put("answer", answerquestion.getBoolean("answer"));
|
|
|
+ } else {
|
|
|
+ structquestion.put("answer", answerquestion.getJSONArray("answer"));
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ JSONArray answersubQuestions = answerquestion.getJSONArray("subQuestions");
|
|
|
+ JSONArray structsubQuestions = structquestion.getJSONArray("subQuestions");
|
|
|
+ for (int k = 0; k < structsubQuestions.size(); k++) {
|
|
|
+ JSONObject answersubquestion = answersubQuestions.getJSONObject(k);
|
|
|
+ JSONObject structsubquestion = structsubQuestions.getJSONObject(k);
|
|
|
+ if (structsubquestion.getInteger("structType").intValue() == 3) {
|
|
|
+ structsubquestion.put("answer", answersubquestion.getBoolean("answer"));
|
|
|
+ } else {
|
|
|
+ structsubquestion.put("answer", answersubquestion.getJSONArray("answer"));
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
- return structJson;
|
|
|
- } finally {
|
|
|
- FileUtil.deleteFolder(dir);
|
|
|
}
|
|
|
+ return structJson;
|
|
|
}
|
|
|
|
|
|
private String uuid() {
|
|
@@ -219,10 +209,8 @@ public class TEOpenServiceImpl implements TEOpenService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
@Override
|
|
|
- public JSONArray examRecordNeedMark(Long examId, String courseCode, Long idGt,
|
|
|
- Integer count) {
|
|
|
+ public JSONArray examRecordNeedMark(Long examId, String courseCode, Long idGt, Integer count) {
|
|
|
checkExam(examId);
|
|
|
List<OpenRecordNeedMarkBean> list;
|
|
|
for (; ; ) {
|
|
@@ -243,7 +231,8 @@ public class TEOpenServiceImpl implements TEOpenService {
|
|
|
for (int i = 0; i < answers.size(); i++) {//剔除客观题答案
|
|
|
OpenRecordAnswerBean answer = answers.get(i);
|
|
|
Map<String, Integer> struct = examPaperService.getPaperStructCacheBean(answer.getPaperId());
|
|
|
- Integer type = struct.get(RedisKeyHelper.examAnswerHashKey(answer.getMainNumber(), answer.getSubNumber(), answer.getSubIndex()));
|
|
|
+ Integer type = struct.get(RedisKeyHelper
|
|
|
+ .examAnswerHashKey(answer.getMainNumber(), answer.getSubNumber(), answer.getSubIndex()));
|
|
|
if (type == 1 || type == 2 || type == 3) {
|
|
|
answers.remove(i);
|
|
|
i--;
|
|
@@ -306,7 +295,8 @@ public class TEOpenServiceImpl implements TEOpenService {
|
|
|
TEExam exam = examService.getById(examId);
|
|
|
if (RecordSelectStrategyEnum.HIGHEST_TOTAL_SCORE.equals(exam.getRecordSelectStrategy())) {//全阅
|
|
|
return list;
|
|
|
- } else if (RecordSelectStrategyEnum.HIGHEST_OBJECTIVE_SCORE.equals(exam.getRecordSelectStrategy())) {//客观分最高,相同则都阅
|
|
|
+ } else if (RecordSelectStrategyEnum.HIGHEST_OBJECTIVE_SCORE
|
|
|
+ .equals(exam.getRecordSelectStrategy())) {//客观分最高,相同则都阅
|
|
|
Map<Long, List<OpenRecordNeedMarkBean>> map = new HashMap<>();
|
|
|
for (OpenRecordNeedMarkBean bean : list) {
|
|
|
List<OpenRecordNeedMarkBean> temList = map.get(bean.getExamStudentId());
|
|
@@ -331,6 +321,7 @@ public class TEOpenServiceImpl implements TEOpenService {
|
|
|
}
|
|
|
}
|
|
|
Collections.sort(ret, new Comparator<OpenRecordNeedMarkBean>() {
|
|
|
+
|
|
|
@Override
|
|
|
public int compare(OpenRecordNeedMarkBean o1, OpenRecordNeedMarkBean o2) {
|
|
|
Long c1 = o1.getExamStudentId();
|
|
@@ -356,6 +347,7 @@ public class TEOpenServiceImpl implements TEOpenService {
|
|
|
}
|
|
|
List<OpenRecordNeedMarkBean> ret = map.values().stream().collect(Collectors.toList());
|
|
|
Collections.sort(ret, new Comparator<OpenRecordNeedMarkBean>() {
|
|
|
+
|
|
|
@Override
|
|
|
public int compare(OpenRecordNeedMarkBean o1, OpenRecordNeedMarkBean o2) {
|
|
|
Long c1 = o1.getExamStudentId();
|