ソースを参照

Merge branch 'master' of http://git.dayaedu.com/yonge/edu-saas

zouxuan 5 年 前
コミット
457875f1df

+ 2 - 0
edu-user/edu-user-biz/src/main/java/com/keao/edu/user/service/SysConfigService.java

@@ -10,6 +10,8 @@ public interface SysConfigService extends BaseService<Long, SysConfig> {
 
     String BASE_H5_URL = "base_h5_url";
 
+    String EXAM_SCORE_SECTION = "exam_score_section";
+
     /**
      * @return com.keao.edu.biz.dal.entity.SysConfig
      * @params paramName

+ 25 - 4
edu-user/edu-user-biz/src/main/java/com/keao/edu/user/service/impl/StudentExamResultServiceImpl.java

@@ -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);
 	}

+ 4 - 1
edu-user/edu-user-biz/src/main/resources/config/mybatis/StudentExamResultMapper.xml

@@ -120,7 +120,10 @@
 
 	<update id="updateRegistAvgScore" parameterType="com.keao.edu.user.entity.StudentExamResult">
 		<foreach collection="results" item="result" separator=";">
-			UPDATE student_exam_result SET avg_score_=#{result.avgScore},update_time_=NOW()
+			UPDATE student_exam_result
+			SET avg_score_=#{result.avgScore},
+			result_=#{result.result,typeHandler=com.keao.edu.common.dal.CustomEnumTypeHandler},
+			update_time_=NOW()
 			WHERE exam_registration_id_ = #{result.examRegistrationId}
 		</foreach>
 	</update>

+ 2 - 1
edu-user/edu-user-client-api/src/main/java/com/keao/edu/user/api/enums/ExamEvaluationResultEnum.java

@@ -37,4 +37,5 @@ public enum ExamEvaluationResultEnum implements BaseEnum<String, ExamEvaluationR
 
     public void setMsg(String msg) {
         this.msg = msg;
-    }}
+    }
+}