|
@@ -17,15 +17,13 @@ import com.keao.edu.user.api.entity.ExamRoom;
|
|
|
import com.keao.edu.user.api.entity.ExamRoomStudentRelation;
|
|
|
import com.keao.edu.user.api.entity.Student;
|
|
|
import com.keao.edu.user.api.enums.StudentExamResultApiDto;
|
|
|
+import com.keao.edu.user.dao.ExamReviewDao;
|
|
|
import com.keao.edu.user.dao.ExaminationBasicDao;
|
|
|
import com.keao.edu.user.dao.StudentExamResultDao;
|
|
|
import com.keao.edu.user.dto.ExaminationBasicDto;
|
|
|
import com.keao.edu.user.dto.RecordNotify;
|
|
|
import com.keao.edu.user.dto.StudentExamResultStatisticsDto;
|
|
|
-import com.keao.edu.user.entity.ExaminationBasic;
|
|
|
-import com.keao.edu.user.entity.Organization;
|
|
|
-import com.keao.edu.user.entity.StudentExamResult;
|
|
|
-import com.keao.edu.user.entity.Subject;
|
|
|
+import com.keao.edu.user.entity.*;
|
|
|
import com.keao.edu.user.enums.ExamStatusEnum;
|
|
|
import com.keao.edu.user.enums.LevelEnum;
|
|
|
import com.keao.edu.user.page.StudentExamResultQueryInfo;
|
|
@@ -41,7 +39,9 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.data.redis.core.RedisTemplate;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
+import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
+import java.math.BigDecimal;
|
|
|
import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
@@ -66,6 +66,8 @@ public class StudentExamResultServiceImpl extends BaseServiceImpl<Long, StudentE
|
|
|
private ExamRoomService examRoomService;
|
|
|
@Autowired
|
|
|
private RedisTemplate<String,String> redisTemplate;
|
|
|
+ @Autowired
|
|
|
+ private ExamReviewDao examReviewDao;
|
|
|
|
|
|
private final static Logger logger = LoggerFactory.getLogger(StudentExamResultServiceImpl.class);
|
|
|
|
|
@@ -163,6 +165,27 @@ public class StudentExamResultServiceImpl extends BaseServiceImpl<Long, StudentE
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public void calculateStudentExamAvgScore(Long examRoomId) {
|
|
|
+ List<ExamReview> examReviews = examReviewDao.getWithExamRoom(examRoomId);
|
|
|
+ if(CollectionUtils.isEmpty(examReviews)){
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ Map<Long, List<ExamReview>> registReviewMap = examReviews.stream().collect(Collectors.groupingBy(ExamReview::getExamRegistrationId));
|
|
|
+ List<StudentExamResult> needUpdateStudentExamResult = new ArrayList<>();
|
|
|
+ for (Map.Entry<Long, List<ExamReview>> registReviewEntry : registReviewMap.entrySet()) {
|
|
|
+ StudentExamResult studentExamResult=new StudentExamResult();
|
|
|
+ studentExamResult.setExamRegistrationId(registReviewEntry.getKey());
|
|
|
+ List<ExamReview> reviews = registReviewEntry.getValue();
|
|
|
+ long totalScore = reviews.stream().mapToLong(ExamReview::getEvaluationResult).sum();
|
|
|
+ BigDecimal avgScore = new BigDecimal(totalScore).divide(new BigDecimal(reviews.size()), 2, BigDecimal.ROUND_CEILING);
|
|
|
+ studentExamResult.setAvgScore(avgScore.floatValue());
|
|
|
+ needUpdateStudentExamResult.add(studentExamResult);
|
|
|
+ }
|
|
|
+ studentExamResultDao.updateRegistAvgScore(needUpdateStudentExamResult);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
public StudentExamResultStatisticsDto getStudentExamResultStatisticsInfo(Integer organId, Integer examId) {
|
|
|
if(Objects.isNull(examId)){
|
|
|
throw new BizException("请指定考级项目");
|