|
@@ -1,5 +1,7 @@
|
|
|
package com.keao.edu.user.service.impl;
|
|
|
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.keao.edu.auth.api.client.SysUserFeignService;
|
|
|
import com.keao.edu.auth.api.entity.SysUser;
|
|
@@ -16,6 +18,7 @@ import com.keao.edu.thirdparty.message.provider.JiguangPushPlugin;
|
|
|
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.ExamEvaluationResultEnum;
|
|
|
import com.keao.edu.user.api.enums.StudentExamResultApiDto;
|
|
|
import com.keao.edu.user.dao.ExamReviewDao;
|
|
|
import com.keao.edu.user.dao.ExaminationBasicDao;
|
|
@@ -27,10 +30,7 @@ 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;
|
|
|
-import com.keao.edu.user.service.ExamRoomService;
|
|
|
-import com.keao.edu.user.service.ExamRoomStudentRelationService;
|
|
|
-import com.keao.edu.user.service.OrganizationService;
|
|
|
-import com.keao.edu.user.service.StudentExamResultService;
|
|
|
+import com.keao.edu.user.service.*;
|
|
|
import com.keao.edu.util.collection.MapUtil;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.slf4j.Logger;
|
|
@@ -68,6 +68,8 @@ public class StudentExamResultServiceImpl extends BaseServiceImpl<Long, StudentE
|
|
|
private RedisTemplate<String,String> redisTemplate;
|
|
|
@Autowired
|
|
|
private ExamReviewDao examReviewDao;
|
|
|
+ @Autowired
|
|
|
+ private SysConfigService sysConfigService;
|
|
|
|
|
|
private final static Logger logger = LoggerFactory.getLogger(StudentExamResultServiceImpl.class);
|
|
|
|
|
@@ -173,11 +175,22 @@ public class StudentExamResultServiceImpl extends BaseServiceImpl<Long, StudentE
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public void calculateStudentExamAvgScore(Long examRoomId) {
|
|
|
+ ExamRoom examRoom = examRoomService.get(examRoomId);
|
|
|
+ if(Objects.isNull(examRoom)){
|
|
|
+ return;
|
|
|
+ }
|
|
|
List<StudentExamResult> studentExamResults = studentExamResultDao.getWithExamRoom(examRoomId);
|
|
|
if(CollectionUtils.isEmpty(studentExamResults)){
|
|
|
return;
|
|
|
}
|
|
|
List<ExamReview> examReviews = examReviewDao.getWithExamRoom(examRoomId);
|
|
|
+ String examResultConfigStr = sysConfigService.findConfigValue(SysConfigService.EXAM_SCORE_SECTION, examRoom.getTenantId());
|
|
|
+ JSONArray examResultConfigs;
|
|
|
+ if(StringUtils.isNotBlank(examResultConfigStr)){
|
|
|
+ examResultConfigs = JSON.parseArray(examResultConfigStr);
|
|
|
+ }else{
|
|
|
+ examResultConfigs = new JSONArray();
|
|
|
+ }
|
|
|
Map<Long, List<ExamReview>> registReviewMap = examReviews.stream().collect(Collectors.groupingBy(ExamReview::getExamRegistrationId));
|
|
|
for (StudentExamResult studentExamResult : studentExamResults) {
|
|
|
if(studentExamResult.getIsFinishedExam()==3){
|
|
@@ -191,6 +204,14 @@ public class StudentExamResultServiceImpl extends BaseServiceImpl<Long, StudentE
|
|
|
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());
|
|
|
+ for (Object examResultConfig : examResultConfigs) {
|
|
|
+ Integer startScore = ((JSONObject) examResultConfig).getInteger("startScore");
|
|
|
+ Integer endScore = ((JSONObject) examResultConfig).getInteger("endScore");
|
|
|
+ if(studentExamResult.getAvgScore()>=startScore&&studentExamResult.getAvgScore()<=endScore){
|
|
|
+ String levelName = ((JSONObject) examResultConfig).getString("levelName");
|
|
|
+ studentExamResult.setResult(ExamEvaluationResultEnum.valueOf(levelName));
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
studentExamResultDao.updateRegistAvgScore(studentExamResults);
|
|
|
}
|