|
@@ -326,23 +326,40 @@ public class StudentScoreServiceImpl extends ServiceImpl<StudentScoreDao, Studen
|
|
|
|
|
|
@Transactional
|
|
|
@Override
|
|
|
- public List<StudentScoreEntity> add(StudentEntity student, Map<Long, QuestionEntity> quetions) {
|
|
|
+ public void add(StudentEntity student, Map<Long, QuestionEntity> quetions,
|
|
|
+ List<StudentScoreEntity> oldscores) {
|
|
|
List<StudentScoreEntity> adds = new ArrayList<>();
|
|
|
for (QuestionEntity q : quetions.values()) {
|
|
|
- StudentScoreEntity s = new StudentScoreEntity();
|
|
|
- adds.add(s);
|
|
|
- s.setQuestionId(q.getId());
|
|
|
- s.setExamId(student.getExamId());
|
|
|
- s.setAnswerStatus(DataStatus.WAITING);
|
|
|
- s.setMainNumber(q.getMainNumber());
|
|
|
- s.setScoreStatus(DataStatus.WAITING);
|
|
|
- s.setStudentCode(student.getStudentCode());
|
|
|
- s.setStudentId(student.getId());
|
|
|
- s.setSubjectCode(student.getSubjectCode());
|
|
|
- s.setSubNumber(q.getSubNumber());
|
|
|
- }
|
|
|
- this.saveBatch(adds);
|
|
|
- return adds;
|
|
|
+ if (!exists(q, oldscores)) {
|
|
|
+ StudentScoreEntity s = new StudentScoreEntity();
|
|
|
+ adds.add(s);
|
|
|
+ s.setQuestionId(q.getId());
|
|
|
+ s.setExamId(student.getExamId());
|
|
|
+ s.setAnswerStatus(DataStatus.WAITING);
|
|
|
+ s.setMainNumber(q.getMainNumber());
|
|
|
+ s.setScoreStatus(DataStatus.WAITING);
|
|
|
+ s.setStudentCode(student.getStudentCode());
|
|
|
+ s.setStudentId(student.getId());
|
|
|
+ s.setSubjectCode(student.getSubjectCode());
|
|
|
+ s.setSubNumber(q.getSubNumber());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(CollectionUtils.isNotEmpty(adds)) {
|
|
|
+ this.saveBatch(adds);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private boolean exists(QuestionEntity q, List<StudentScoreEntity> oldscores) {
|
|
|
+ if(CollectionUtils.isEmpty(oldscores)) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ for (StudentScoreEntity s : oldscores) {
|
|
|
+ if (s.getExamId().equals(q.getExamId()) && s.getSubjectCode().equals(q.getSubjectCode())
|
|
|
+ && s.getMainNumber().equals(q.getMainNumber()) && s.getSubNumber().equals(q.getSubNumber())) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return false;
|
|
|
}
|
|
|
|
|
|
@Transactional
|
|
@@ -607,7 +624,7 @@ public class StudentScoreServiceImpl extends ServiceImpl<StudentScoreDao, Studen
|
|
|
if (q == null) {
|
|
|
throw new StatusException("未找到试题信息");
|
|
|
}
|
|
|
- if(CollectionUtils.isEmpty(q.getAnswer())) {
|
|
|
+ if (CollectionUtils.isEmpty(q.getAnswer())) {
|
|
|
return;
|
|
|
}
|
|
|
AutoScoreRequest req = new AutoScoreRequest();
|
|
@@ -767,7 +784,7 @@ public class StudentScoreServiceImpl extends ServiceImpl<StudentScoreDao, Studen
|
|
|
|
|
|
@Override
|
|
|
public List<StudentScoreEntity> findBy(Long examId, String subjectCode, Integer mainNumber, String subNumber,
|
|
|
- Boolean exZero,Integer count,Integer score) {
|
|
|
+ Boolean exZero, Integer count, Integer score) {
|
|
|
QueryWrapper<StudentScoreEntity> wrapper = new QueryWrapper<>();
|
|
|
LambdaQueryWrapper<StudentScoreEntity> lw = wrapper.lambda();
|
|
|
lw.eq(StudentScoreEntity::getExamId, examId);
|
|
@@ -775,32 +792,32 @@ public class StudentScoreServiceImpl extends ServiceImpl<StudentScoreDao, Studen
|
|
|
lw.eq(StudentScoreEntity::getMainNumber, mainNumber);
|
|
|
lw.eq(StudentScoreEntity::getSubNumber, subNumber);
|
|
|
lw.and(wq -> {
|
|
|
- wq.or(wq1 -> wq1.isNull(StudentScoreEntity::getScoreNone));
|
|
|
- wq.or(wq2 -> wq2.eq(StudentScoreEntity::getScoreNone, false));
|
|
|
- });
|
|
|
- if(exZero!=null&&exZero) {
|
|
|
+ wq.or(wq1 -> wq1.isNull(StudentScoreEntity::getScoreNone));
|
|
|
+ wq.or(wq2 -> wq2.eq(StudentScoreEntity::getScoreNone, false));
|
|
|
+ });
|
|
|
+ if (exZero != null && exZero) {
|
|
|
lw.and(wq -> {
|
|
|
- wq.or(wq1 -> wq1.ne(StudentScoreEntity::getAiScore, 0));
|
|
|
- wq.or(wq2 -> wq2.eq(StudentScoreEntity::getMarkingScore, 0));
|
|
|
- });
|
|
|
+ wq.or(wq1 -> wq1.ne(StudentScoreEntity::getAiScore, 0));
|
|
|
+ wq.or(wq2 -> wq2.eq(StudentScoreEntity::getMarkingScore, 0));
|
|
|
+ });
|
|
|
}
|
|
|
- List<StudentScoreEntity> ret=this.list(wrapper);
|
|
|
- if(CollectionUtils.isEmpty(ret)) {
|
|
|
+ List<StudentScoreEntity> ret = this.list(wrapper);
|
|
|
+ if (CollectionUtils.isEmpty(ret)) {
|
|
|
return ret;
|
|
|
}
|
|
|
- if(score!=null) {
|
|
|
- List<StudentScoreEntity> tem=new ArrayList<>();
|
|
|
- for(StudentScoreEntity s:ret) {
|
|
|
- if(getSubtract(s.getAiScore(), s.getMarkingScore())<=score) {
|
|
|
+ if (score != null) {
|
|
|
+ List<StudentScoreEntity> tem = new ArrayList<>();
|
|
|
+ for (StudentScoreEntity s : ret) {
|
|
|
+ if (getSubtract(s.getAiScore(), s.getMarkingScore()) <= score) {
|
|
|
tem.add(s);
|
|
|
}
|
|
|
}
|
|
|
- ret=tem;
|
|
|
+ ret = tem;
|
|
|
}
|
|
|
- if(CollectionUtils.isEmpty(ret)) {
|
|
|
+ if (CollectionUtils.isEmpty(ret)) {
|
|
|
return ret;
|
|
|
}
|
|
|
- if(count!=null) {
|
|
|
+ if (count != null) {
|
|
|
ret.sort(new Comparator<StudentScoreEntity>() {
|
|
|
@Override
|
|
|
public int compare(StudentScoreEntity o1, StudentScoreEntity o2) {
|
|
@@ -809,21 +826,21 @@ public class StudentScoreServiceImpl extends ServiceImpl<StudentScoreDao, Studen
|
|
|
return c1.compareTo(c2);
|
|
|
}
|
|
|
});
|
|
|
- if(ret.size()<=count) {
|
|
|
+ if (ret.size() <= count) {
|
|
|
return ret;
|
|
|
}
|
|
|
return ret.subList(0, count);
|
|
|
}
|
|
|
return ret;
|
|
|
}
|
|
|
-
|
|
|
- private Double getSubtract(Double d1,Double d2) {
|
|
|
- if(d1==null||d2==null) {
|
|
|
+
|
|
|
+ private Double getSubtract(Double d1, Double d2) {
|
|
|
+ if (d1 == null || d2 == null) {
|
|
|
return null;
|
|
|
}
|
|
|
- Double r=d1-d2;
|
|
|
- if(r<0) {
|
|
|
- r=0-r;
|
|
|
+ Double r = d1 - d2;
|
|
|
+ if (r < 0) {
|
|
|
+ r = 0 - r;
|
|
|
}
|
|
|
return r;
|
|
|
}
|