|
@@ -1,22 +1,14 @@
|
|
|
package cn.com.qmth.am.service.impl;
|
|
|
|
|
|
-import java.io.File;
|
|
|
-import java.io.FileInputStream;
|
|
|
-import java.io.FileNotFoundException;
|
|
|
-import java.io.IOException;
|
|
|
-import java.io.InputStream;
|
|
|
-import java.nio.charset.StandardCharsets;
|
|
|
import java.util.ArrayList;
|
|
|
-import java.util.Arrays;
|
|
|
import java.util.Comparator;
|
|
|
-import java.util.HashMap;
|
|
|
import java.util.HashSet;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
import java.util.Set;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
import org.apache.commons.collections4.CollectionUtils;
|
|
|
-import org.apache.commons.io.FileUtils;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
@@ -33,18 +25,12 @@ import com.qmth.boot.core.exception.StatusException;
|
|
|
import com.qmth.boot.core.retrofit.exception.RetrofitResponseError;
|
|
|
import com.qmth.boot.core.solar.model.OrgInfo;
|
|
|
import com.qmth.boot.core.solar.service.SolarService;
|
|
|
-import com.qmth.boot.tools.excel.ExcelReader;
|
|
|
-import com.qmth.boot.tools.excel.enums.ExcelType;
|
|
|
-import com.qmth.boot.tools.excel.model.DataMap;
|
|
|
import com.qmth.boot.tools.models.ByteArray;
|
|
|
|
|
|
import cn.com.qmth.am.bean.AiMarkingDto;
|
|
|
import cn.com.qmth.am.bean.AnswerImageDto;
|
|
|
import cn.com.qmth.am.bean.AutoScoreEnRequest;
|
|
|
import cn.com.qmth.am.bean.ImageSlice;
|
|
|
-import cn.com.qmth.am.bean.ImportResult;
|
|
|
-import cn.com.qmth.am.bean.StudentInfo;
|
|
|
-import cn.com.qmth.am.bean.StudentScoreDto;
|
|
|
import cn.com.qmth.am.bean.StudentScoreImageDto;
|
|
|
import cn.com.qmth.am.bean.StudentScoreInfo;
|
|
|
import cn.com.qmth.am.bean.ds.AutoScoreResult;
|
|
@@ -53,8 +39,6 @@ import cn.com.qmth.am.dao.local.StudentScoreDao;
|
|
|
import cn.com.qmth.am.entity.QuestionEntity;
|
|
|
import cn.com.qmth.am.entity.StudentScoreEntity;
|
|
|
import cn.com.qmth.am.enums.DataStatus;
|
|
|
-import cn.com.qmth.am.enums.DataType;
|
|
|
-import cn.com.qmth.am.enums.ImportFileName;
|
|
|
import cn.com.qmth.am.service.DsMarkingService;
|
|
|
import cn.com.qmth.am.service.QuestionService;
|
|
|
import cn.com.qmth.am.service.StudentScoreService;
|
|
@@ -68,10 +52,6 @@ public class StudentScoreServiceImpl extends ServiceImpl<StudentScoreDao, Studen
|
|
|
|
|
|
private static final Logger log = LoggerFactory.getLogger(StudentScoreService.class);
|
|
|
|
|
|
- // private static BlockingQueue<StudentScoreImageDto> queue;
|
|
|
-
|
|
|
- private static final String[] EXCEL_HEADER = new String[] { "考试ID", "科目代码", "考生编号", "大题号", "小题号", "评分" };
|
|
|
-
|
|
|
@Autowired
|
|
|
private SysProperty sysProperty;
|
|
|
|
|
@@ -83,287 +63,29 @@ public class StudentScoreServiceImpl extends ServiceImpl<StudentScoreDao, Studen
|
|
|
|
|
|
@Autowired
|
|
|
private QuestionService questionService;
|
|
|
- // static {
|
|
|
- // int threadCount = Runtime.getRuntime().availableProcessors();
|
|
|
- // queue = new ArrayBlockingQueue<>(threadCount * 2);
|
|
|
- // }
|
|
|
-
|
|
|
- @Override
|
|
|
- public void importScore() {
|
|
|
- File dir = new File(sysProperty.getDataDir());
|
|
|
- File[] fs = dir.listFiles();
|
|
|
- if (fs == null || fs.length == 0) {
|
|
|
- return;
|
|
|
- }
|
|
|
- for (File file : fs) {
|
|
|
- if (!file.isFile() || !file.getName().equals(ImportFileName.SCORE_IMPORT.getName())) {
|
|
|
- continue;
|
|
|
- }
|
|
|
- InputStream inputStream = null;
|
|
|
- ImportResult ret = null;
|
|
|
- try {
|
|
|
- inputStream = new FileInputStream(file);
|
|
|
- ret = disposeFile(inputStream);
|
|
|
- } catch (Exception e) {
|
|
|
- String errMsg;
|
|
|
- if (e instanceof FileNotFoundException) {
|
|
|
- errMsg = "未找到文件:" + file.getAbsolutePath();
|
|
|
- } else {
|
|
|
- errMsg = "系统错误:" + e.getMessage();
|
|
|
- log.error("系统错误", e);
|
|
|
- }
|
|
|
- ret = new ImportResult(errMsg);
|
|
|
- } finally {
|
|
|
- if (inputStream != null) {
|
|
|
- try {
|
|
|
- inputStream.close();
|
|
|
- } catch (IOException e) {
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- moveFile(dir, file, ret);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- private void moveFile(File dir, File file, ImportResult ret) {
|
|
|
- try {
|
|
|
- boolean succss = CollectionUtils.isEmpty(ret.getErrMsg());
|
|
|
- if (succss) {
|
|
|
- File sucDir = new File(dir.getAbsoluteFile() + "/success/");
|
|
|
- if (!sucDir.exists()) {
|
|
|
- sucDir.mkdir();
|
|
|
- }
|
|
|
- File targetFile = new File(sucDir.getAbsoluteFile() + "/" + file.getName());
|
|
|
- if (targetFile.exists()) {
|
|
|
- targetFile.delete();
|
|
|
- }
|
|
|
- FileUtils.copyFile(file, targetFile);
|
|
|
- file.delete();
|
|
|
- String fname = file.getName().substring(0, file.getName().lastIndexOf("."));
|
|
|
- File msgFile = new File(sucDir.getAbsoluteFile() + "/" + fname + "_info.txt");
|
|
|
- if (msgFile.exists()) {
|
|
|
- msgFile.delete();
|
|
|
- }
|
|
|
- FileUtils.write(msgFile, ret.getCountInfo(), "utf-8");
|
|
|
- } else {
|
|
|
- File sucDir = new File(dir.getAbsoluteFile() + "/failed/");
|
|
|
- if (!sucDir.exists()) {
|
|
|
- sucDir.mkdir();
|
|
|
- }
|
|
|
- File targetFile = new File(sucDir.getAbsoluteFile() + "/" + file.getName());
|
|
|
- if (targetFile.exists()) {
|
|
|
- targetFile.delete();
|
|
|
- }
|
|
|
- FileUtils.copyFile(file, targetFile);
|
|
|
- file.delete();
|
|
|
- String fname = file.getName().substring(0, file.getName().lastIndexOf("."));
|
|
|
- File msgFile = new File(sucDir.getAbsoluteFile() + "/" + fname + "_info.txt");
|
|
|
- if (msgFile.exists()) {
|
|
|
- msgFile.delete();
|
|
|
- }
|
|
|
- FileUtils.writeLines(msgFile, StandardCharsets.UTF_8.name(), ret.getErrMsg());
|
|
|
- }
|
|
|
- } catch (IOException e) {
|
|
|
- throw new StatusException("文件处理出错", e);
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- private String errorMsg(int lineNum, String msg) {
|
|
|
- return "第" + lineNum + "行 " + msg;
|
|
|
- }
|
|
|
-
|
|
|
- private String trimAndNullIfBlank(String s) {
|
|
|
- if (StringUtils.isBlank(s)) {
|
|
|
- return null;
|
|
|
- }
|
|
|
- return s.trim();
|
|
|
- }
|
|
|
-
|
|
|
- @SuppressWarnings("deprecation")
|
|
|
- private ImportResult disposeFile(InputStream inputStream) {
|
|
|
- List<DataMap> lineList = null;
|
|
|
- ExcelReader reader = ExcelReader.create(ExcelType.XLSX, inputStream, 0);
|
|
|
- try {
|
|
|
- lineList = reader.getDataMapList();
|
|
|
- } catch (Exception e) {
|
|
|
- throw new StatusException("Excel 解析失败");
|
|
|
- }
|
|
|
- if (!Arrays.equals(EXCEL_HEADER, reader.getColumnNames())) {
|
|
|
- throw new StatusException("Excel表头错误");
|
|
|
- }
|
|
|
- if (CollectionUtils.isEmpty(lineList)) {
|
|
|
- throw new StatusException("Excel无内容");
|
|
|
- }
|
|
|
- if (100001 < lineList.size()) {
|
|
|
- throw new StatusException("数据行数不能超过100000");
|
|
|
- }
|
|
|
- List<StudentScoreDto> ss = new ArrayList<>();
|
|
|
- ImportResult ret = new ImportResult();
|
|
|
- List<String> failRecords = new ArrayList<>();
|
|
|
- ret.setErrMsg(failRecords);
|
|
|
- for (int i = 0; i < lineList.size(); i++) {
|
|
|
- DataMap line = lineList.get(i);
|
|
|
-
|
|
|
- StringBuilder msg = new StringBuilder();
|
|
|
-
|
|
|
- StudentScoreDto imp = new StudentScoreDto();
|
|
|
- String examId = trimAndNullIfBlank(line.get(EXCEL_HEADER[0]));
|
|
|
- if (StringUtils.isBlank(examId)) {
|
|
|
- msg.append(" 考试ID不能为空");
|
|
|
- } else if (examId.length() > 20) {
|
|
|
- msg.append(" 考试ID不能超过20个字符");
|
|
|
- } else {
|
|
|
- try {
|
|
|
- Long examIdVal = Long.parseLong(examId);
|
|
|
- imp.setExamId(examIdVal);
|
|
|
- } catch (NumberFormatException e) {
|
|
|
- msg.append(" 考试ID只能是数字");
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- String subjectCode = trimAndNullIfBlank(line.get(EXCEL_HEADER[1]));
|
|
|
- if (StringUtils.isBlank(subjectCode)) {
|
|
|
- msg.append(" 科目代码不能为空");
|
|
|
- } else if (subjectCode.length() > 100) {
|
|
|
- msg.append(" 科目代码不能超过100个字符");
|
|
|
- }
|
|
|
- imp.setSubjectCode(subjectCode);
|
|
|
-
|
|
|
- String studentCode = trimAndNullIfBlank(line.get(EXCEL_HEADER[2]));
|
|
|
- if (StringUtils.isBlank(studentCode)) {
|
|
|
- msg.append(" 考生编号不能为空");
|
|
|
- } else if (studentCode.length() > 100) {
|
|
|
- msg.append(" 考生编号不能超过100个字符");
|
|
|
- }
|
|
|
- imp.setStudentCode(studentCode);
|
|
|
-
|
|
|
- String mainNum = trimAndNullIfBlank(line.get(EXCEL_HEADER[3]));
|
|
|
- if (StringUtils.isBlank(mainNum)) {
|
|
|
- msg.append(" 大题号不能为空");
|
|
|
- } else if (mainNum.length() > 10) {
|
|
|
- msg.append(" 大题号不能超过10个字符");
|
|
|
- } else {
|
|
|
- try {
|
|
|
- Integer mainNumVal = Integer.parseInt(mainNum);
|
|
|
- if (mainNumVal <= 0) {
|
|
|
- msg.append(" 大题号必须大于0");
|
|
|
- }
|
|
|
- imp.setMainNumber(mainNumVal);
|
|
|
- } catch (NumberFormatException e) {
|
|
|
- msg.append(" 大题号格式错误");
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- String subNum = trimAndNullIfBlank(line.get(EXCEL_HEADER[4]));
|
|
|
- if (StringUtils.isBlank(subNum)) {
|
|
|
- msg.append(" 小题号不能为空");
|
|
|
- } else if (subNum.length() > 10) {
|
|
|
- msg.append(" 小题号不能超过10个字符");
|
|
|
- }
|
|
|
- imp.setSubNumber(subNum);
|
|
|
-
|
|
|
- String score = trimAndNullIfBlank(line.get(EXCEL_HEADER[5]));
|
|
|
- if (StringUtils.isBlank(score)) {
|
|
|
- msg.append(" 评分不能为空");
|
|
|
- } else if (score.length() > 10) {
|
|
|
- msg.append(" 评分不能超过10个字符");
|
|
|
- } else {
|
|
|
- try {
|
|
|
- Double scoreVal = Double.parseDouble(score);
|
|
|
- imp.setMarkingScore(scoreVal);
|
|
|
- } catch (NumberFormatException e) {
|
|
|
- msg.append(" 评分格式错误");
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- if (msg.length() > 0) {
|
|
|
- failRecords.add(errorMsg(i + 2, msg.toString()));
|
|
|
- } else {
|
|
|
- ss.add(imp);
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- if (CollectionUtils.isNotEmpty(failRecords)) {
|
|
|
- return ret;
|
|
|
- }
|
|
|
- try {
|
|
|
- updateScoreBatch(ret, ss);
|
|
|
- } catch (Exception e) {
|
|
|
- failRecords.add("系统错误:" + e.getMessage());
|
|
|
- }
|
|
|
- return ret;
|
|
|
- }
|
|
|
-
|
|
|
- private void updateScoreBatch(ImportResult ret, List<StudentScoreDto> ss) {
|
|
|
- if (CollectionUtils.isEmpty(ss)) {
|
|
|
- ret.setCountInfo("更新数量:0");
|
|
|
- return;
|
|
|
- }
|
|
|
- int count = 0;
|
|
|
- for (StudentScoreDto s : ss) {
|
|
|
- count = count + updateScore(s);
|
|
|
- }
|
|
|
- ret.setCountInfo("更新数量:" + count);
|
|
|
- }
|
|
|
-
|
|
|
- private int updateScore(StudentScoreDto dto) {
|
|
|
- UpdateWrapper<StudentScoreEntity> wrapper = new UpdateWrapper<>();
|
|
|
- LambdaUpdateWrapper<StudentScoreEntity> lw = wrapper.lambda();
|
|
|
- lw.set(StudentScoreEntity::getMarkingScore, dto.getMarkingScore());
|
|
|
- lw.eq(StudentScoreEntity::getExamId, dto.getExamId());
|
|
|
- lw.eq(StudentScoreEntity::getSubjectCode, dto.getSubjectCode());
|
|
|
- lw.eq(StudentScoreEntity::getStudentCode, dto.getStudentCode());
|
|
|
- lw.eq(StudentScoreEntity::getMainNumber, dto.getMainNumber());
|
|
|
- lw.eq(StudentScoreEntity::getSubNumber, dto.getSubNumber());
|
|
|
- return this.update(wrapper) ? 1 : 0;
|
|
|
- }
|
|
|
|
|
|
@Transactional
|
|
|
@Override
|
|
|
- public void addStudentScore(List<StudentInfo> ss) {
|
|
|
- List<QuestionEntity> qs = questionService.list();
|
|
|
- if (CollectionUtils.isEmpty(qs)) {
|
|
|
+ public void saveByQuestion(QuestionEntity q, List<StudentScoreEntity> ss) {
|
|
|
+ if (q == null) {
|
|
|
throw new StatusException("试题信息为空");
|
|
|
}
|
|
|
- Map<String, List<QuestionEntity>> qmap = new HashMap<>();
|
|
|
- for (QuestionEntity q : qs) {
|
|
|
- String key = q.getExamId() + "-" + q.getSubjectCode();
|
|
|
- List<QuestionEntity> tem = qmap.get(key);
|
|
|
- if (tem == null) {
|
|
|
- tem = new ArrayList<>();
|
|
|
- qmap.put(key, tem);
|
|
|
- }
|
|
|
- tem.add(q);
|
|
|
- }
|
|
|
Set<String> allStudent = getAllStudent();
|
|
|
|
|
|
- BatchSetDataUtil<StudentInfo> bs = new BatchSetDataUtil<StudentInfo>() {
|
|
|
+ BatchSetDataUtil<StudentScoreEntity> bs = new BatchSetDataUtil<StudentScoreEntity>() {
|
|
|
|
|
|
@Override
|
|
|
- protected void setData(List<StudentInfo> dataList) {
|
|
|
+ protected void setData(List<StudentScoreEntity> dataList) {
|
|
|
List<StudentScoreEntity> adds = new ArrayList<>();
|
|
|
- for (StudentInfo stu : dataList) {
|
|
|
- String key = stu.getExamId() + "-" + stu.getSubjectCode();
|
|
|
- if (qmap.get(key) == null) {
|
|
|
- throw new StatusException("试题信息为空:" + key);
|
|
|
- }
|
|
|
- for (QuestionEntity q : qmap.get(key)) {
|
|
|
- String scorekey = q.getId() + "-" + stu.getStudentCode();
|
|
|
- if (!allStudent.contains(scorekey)) {
|
|
|
- StudentScoreEntity s = new StudentScoreEntity();
|
|
|
- adds.add(s);
|
|
|
- allStudent.add(scorekey);
|
|
|
- s.setQuestionId(q.getId());
|
|
|
- s.setExamId(stu.getExamId());
|
|
|
- s.setAnswerStatus(DataStatus.WAITING);
|
|
|
- s.setMainNumber(q.getMainNumber());
|
|
|
- s.setScoreStatus(DataStatus.WAITING);
|
|
|
- s.setStudentCode(stu.getStudentCode());
|
|
|
- s.setSubjectCode(stu.getSubjectCode());
|
|
|
- s.setSubNumber(q.getSubNumber());
|
|
|
- }
|
|
|
+ for (StudentScoreEntity stu : dataList) {
|
|
|
+ String scorekey = q.getId() + "-" + stu.getExamNumber();
|
|
|
+ if (!allStudent.contains(scorekey)) {
|
|
|
+ adds.add(stu);
|
|
|
+ allStudent.add(scorekey);
|
|
|
+ stu.setQuestionId(q.getId());
|
|
|
+ stu.setAnswerStatus(DataStatus.WAITING);
|
|
|
+ stu.setScoreStatus(DataStatus.WAITING);
|
|
|
+ stu.setExamNumber(stu.getExamNumber());
|
|
|
}
|
|
|
}
|
|
|
if (CollectionUtils.isNotEmpty(adds)) {
|
|
@@ -382,7 +104,7 @@ public class StudentScoreServiceImpl extends ServiceImpl<StudentScoreDao, Studen
|
|
|
return ret;
|
|
|
}
|
|
|
for (StudentScoreInfo s : list) {
|
|
|
- ret.add(s.getQuestionId() + "-" + s.getStudentCode());
|
|
|
+ ret.add(s.getQuestionId() + "-" + s.getExamNUmber());
|
|
|
}
|
|
|
return ret;
|
|
|
}
|
|
@@ -501,38 +223,18 @@ public class StudentScoreServiceImpl extends ServiceImpl<StudentScoreDao, Studen
|
|
|
// }
|
|
|
|
|
|
private String getImageUrl(StudentScoreEntity score, QuestionEntity q, Integer pageIndex) {
|
|
|
- if (DataType.MARKING_CLOUD.equals(sysProperty.getDataType())) {
|
|
|
- return getImageUrlFromMarkingCloud(score, pageIndex);
|
|
|
- } else if (DataType.TEACH_CLOUD.equals(sysProperty.getDataType())) {
|
|
|
- return getImageUrlFromTeachCloud(score, q, pageIndex);
|
|
|
- } else {
|
|
|
- throw new StatusException("数据类型错误");
|
|
|
- }
|
|
|
+ return getImageUrlFromMarkingCloud(score, q, pageIndex);
|
|
|
}
|
|
|
|
|
|
- private String getImageUrlFromMarkingCloud(StudentScoreEntity score, Integer pageIndex) {
|
|
|
- return sysProperty.getImageServer() + "/" + getMarkingCloudPath(score.getExamId(),
|
|
|
- getSuffix(score.getStudentCode()), score.getStudentCode(), pageIndex, "jpg");
|
|
|
+ private String getImageUrlFromMarkingCloud(StudentScoreEntity score, QuestionEntity q, Integer pageIndex) {
|
|
|
+ return sysProperty.getImageServer() + "/" + getMarkingCloudPath(q.getExamId(), getSuffix(score.getExamNumber()),
|
|
|
+ score.getExamNumber(), pageIndex, "jpg");
|
|
|
}
|
|
|
|
|
|
private static String getSuffix(String input) {
|
|
|
return StringUtils.trimToEmpty(input).substring(Math.max(0, input.length() - 3));
|
|
|
}
|
|
|
|
|
|
- private String getImageUrlFromTeachCloud(StudentScoreEntity score, QuestionEntity q, Integer pageIndex) {
|
|
|
- int paperNum = (pageIndex + 1) / 2;
|
|
|
- int page = 1;
|
|
|
- if (pageIndex % 2 == 0) {
|
|
|
- page = 2;
|
|
|
- }
|
|
|
- return sysProperty.getImageServer() + "/" + getTeachCloudPath(score.getExamId(), score.getSubjectCode(),
|
|
|
- score.getStudentCode(), paperNum, page, "jpg");
|
|
|
- }
|
|
|
-
|
|
|
- private String getTeachCloudPath(Object... param) {
|
|
|
- return String.format("sheet/%d/%s/%s/%d-%d.%s", param);
|
|
|
- }
|
|
|
-
|
|
|
private static String getMarkingCloudPath(Object... param) {
|
|
|
return String.format("sheet/%d/%s/%s-%d.%s", param);
|
|
|
}
|
|
@@ -781,47 +483,55 @@ public class StudentScoreServiceImpl extends ServiceImpl<StudentScoreDao, Studen
|
|
|
|
|
|
@Override
|
|
|
public int countBy(Long examId, DataStatus status) {
|
|
|
+ List<QuestionEntity> qs = questionService.findByExamIdAndSubject(examId, null);
|
|
|
+ if (CollectionUtils.isEmpty(qs)) {
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ List<Long> qids = qs.stream().map(e -> e.getId()).collect(Collectors.toList());
|
|
|
QueryWrapper<StudentScoreEntity> wrapper = new QueryWrapper<>();
|
|
|
LambdaQueryWrapper<StudentScoreEntity> lw = wrapper.lambda();
|
|
|
if (status != null) {
|
|
|
lw.eq(StudentScoreEntity::getScoreStatus, status);
|
|
|
}
|
|
|
- lw.eq(StudentScoreEntity::getExamId, examId);
|
|
|
+ lw.in(StudentScoreEntity::getQuestionId, qids);
|
|
|
return this.count(wrapper);
|
|
|
}
|
|
|
|
|
|
@Transactional
|
|
|
@Override
|
|
|
public void removeBy(Long examId, String subjectCode) {
|
|
|
+ List<QuestionEntity> qs = questionService.findByExamIdAndSubject(examId, subjectCode);
|
|
|
+ if (CollectionUtils.isEmpty(qs)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ List<Long> qids = qs.stream().map(e -> e.getId()).collect(Collectors.toList());
|
|
|
QueryWrapper<StudentScoreEntity> wrapper = new QueryWrapper<>();
|
|
|
LambdaQueryWrapper<StudentScoreEntity> lw = wrapper.lambda();
|
|
|
- if (subjectCode != null) {
|
|
|
- lw.eq(StudentScoreEntity::getSubjectCode, subjectCode);
|
|
|
- }
|
|
|
- lw.eq(StudentScoreEntity::getExamId, examId);
|
|
|
+ lw.in(StudentScoreEntity::getQuestionId, qids);
|
|
|
this.remove(wrapper);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public int countOcrBy(Long examId, DataStatus status) {
|
|
|
+ List<QuestionEntity> qs = questionService.findByExamIdAndSubject(examId, null);
|
|
|
+ if (CollectionUtils.isEmpty(qs)) {
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ List<Long> qids = qs.stream().map(e -> e.getId()).collect(Collectors.toList());
|
|
|
QueryWrapper<StudentScoreEntity> wrapper = new QueryWrapper<>();
|
|
|
LambdaQueryWrapper<StudentScoreEntity> lw = wrapper.lambda();
|
|
|
if (status != null) {
|
|
|
lw.eq(StudentScoreEntity::getAnswerStatus, status);
|
|
|
}
|
|
|
- lw.eq(StudentScoreEntity::getExamId, examId);
|
|
|
+ lw.in(StudentScoreEntity::getQuestionId, qids);
|
|
|
return this.count(wrapper);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public List<StudentScoreEntity> findBy(Long examId, String subjectCode, Integer mainNumber, String subNumber,
|
|
|
- Boolean exZero, Integer count, Integer score) {
|
|
|
+ public List<StudentScoreEntity> findBy(Long questionId, Boolean exZero, Integer count, Integer score) {
|
|
|
QueryWrapper<StudentScoreEntity> wrapper = new QueryWrapper<>();
|
|
|
LambdaQueryWrapper<StudentScoreEntity> lw = wrapper.lambda();
|
|
|
- lw.eq(StudentScoreEntity::getExamId, examId);
|
|
|
- lw.eq(StudentScoreEntity::getSubjectCode, subjectCode);
|
|
|
- lw.eq(StudentScoreEntity::getMainNumber, mainNumber);
|
|
|
- lw.eq(StudentScoreEntity::getSubNumber, subNumber);
|
|
|
+ lw.eq(StudentScoreEntity::getQuestionId, questionId);
|
|
|
lw.isNotNull(StudentScoreEntity::getAiScore);
|
|
|
lw.isNotNull(StudentScoreEntity::getMarkingScore);
|
|
|
lw.and(wq -> {
|
|
@@ -855,8 +565,8 @@ public class StudentScoreServiceImpl extends ServiceImpl<StudentScoreDao, Studen
|
|
|
|
|
|
@Override
|
|
|
public int compare(StudentScoreEntity o1, StudentScoreEntity o2) {
|
|
|
- String c1 = o1.getStudentCode();
|
|
|
- String c2 = o2.getStudentCode();
|
|
|
+ String c1 = o1.getExamNumber();
|
|
|
+ String c2 = o2.getExamNumber();
|
|
|
return c1.compareTo(c2);
|
|
|
}
|
|
|
});
|