|
@@ -11,15 +11,19 @@ import cn.com.qmth.examcloud.core.oe.admin.dao.ExamStatisticRepo;
|
|
import cn.com.qmth.examcloud.core.oe.admin.dao.entity.ExamStatisticEntity;
|
|
import cn.com.qmth.examcloud.core.oe.admin.dao.entity.ExamStatisticEntity;
|
|
import cn.com.qmth.examcloud.core.oe.admin.service.ExamStatisticService;
|
|
import cn.com.qmth.examcloud.core.oe.admin.service.ExamStatisticService;
|
|
import cn.com.qmth.examcloud.core.oe.admin.service.bean.statistic.ExamStatisticInfo;
|
|
import cn.com.qmth.examcloud.core.oe.admin.service.bean.statistic.ExamStatisticInfo;
|
|
|
|
+import cn.com.qmth.examcloud.core.oe.admin.service.bean.statistic.ExamStudentScoreInfo;
|
|
import cn.com.qmth.examcloud.core.oe.admin.service.bean.statistic.OverviewInfo;
|
|
import cn.com.qmth.examcloud.core.oe.admin.service.bean.statistic.OverviewInfo;
|
|
import com.google.common.collect.Lists;
|
|
import com.google.common.collect.Lists;
|
|
import org.apache.commons.collections4.CollectionUtils;
|
|
import org.apache.commons.collections4.CollectionUtils;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.LoggerFactory;
|
|
import org.slf4j.LoggerFactory;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
+import org.springframework.jdbc.core.BeanPropertyRowMapper;
|
|
|
|
+import org.springframework.jdbc.core.JdbcTemplate;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
|
|
+import java.util.Date;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
@@ -38,6 +42,70 @@ public class ExamStatisticServiceImpl implements ExamStatisticService {
|
|
@Autowired
|
|
@Autowired
|
|
private OrgCloudService orgCloudService;
|
|
private OrgCloudService orgCloudService;
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
+ private JdbcTemplate jdbcTemplate;
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void refresh(Long examId, Long courseId) {
|
|
|
|
+ int passScoreLine = 60;
|
|
|
|
+ int goodScoreLine = 90;
|
|
|
|
+
|
|
|
|
+ long start = System.currentTimeMillis();
|
|
|
|
+
|
|
|
|
+ StringBuffer sql = new StringBuffer();
|
|
|
|
+ sql.append(" select es.exam_id,es.course_id,es.org_id,es.exam_student_id,sc.total_score,d.paper_score");
|
|
|
|
+ sql.append(" from ec_oe_exam_student es");
|
|
|
|
+ sql.append(" left join ec_oe_exam_student_final_score sc on sc.exam_student_id = es.exam_student_id");
|
|
|
|
+ sql.append(" left join ec_oe_exam_record_data d on d.id = sc.exam_record_data_id");
|
|
|
|
+ sql.append(" where es.exam_id = ").append(examId);
|
|
|
|
+ sql.append(" and es.course_id = ").append(courseId);
|
|
|
|
+
|
|
|
|
+ List<ExamStudentScoreInfo> list = jdbcTemplate.query(sql.toString(), new BeanPropertyRowMapper(ExamStudentScoreInfo.class));
|
|
|
|
+ if (CollectionUtils.isEmpty(list)) {
|
|
|
|
+ log.warn("ExamStudent is empty! examId:{} courseId:{}", examId, courseId);
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ Map<Long, List<ExamStudentScoreInfo>> orgStatisticMaps = list.stream().collect(Collectors.groupingBy(ExamStudentScoreInfo::getOrgId));
|
|
|
|
+ for (Map.Entry<Long, List<ExamStudentScoreInfo>> e : orgStatisticMaps.entrySet()) {
|
|
|
|
+ int allCount = 0, finishCount = 0, passScoreCount = 0, goodScoreCount = 0;
|
|
|
|
+ for (ExamStudentScoreInfo v : e.getValue()) {
|
|
|
|
+ allCount++;
|
|
|
|
+
|
|
|
|
+ if (v.getTotalScore() == null) {
|
|
|
|
+ // 无成绩,则未完成考试
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ finishCount++;
|
|
|
|
+
|
|
|
|
+ if (v.getTotalScore() >= (v.getPaperScore() * passScoreLine) / 100d) {
|
|
|
|
+ passScoreCount++;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (v.getTotalScore() >= (v.getPaperScore() * goodScoreLine) / 100d) {
|
|
|
|
+ goodScoreCount++;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ ExamStatisticEntity result = examStatisticRepo.findByExamIdAndCourseIdAndOrgId(examId, courseId, e.getKey());
|
|
|
|
+ if (result == null) {
|
|
|
|
+ result = new ExamStatisticEntity();
|
|
|
|
+ result.setExamId(examId);
|
|
|
|
+ result.setCourseId(courseId);
|
|
|
|
+ result.setOrgId(e.getKey());
|
|
|
|
+ }
|
|
|
|
+ result.setAllCount(allCount);
|
|
|
|
+ result.setFinishCount(finishCount);
|
|
|
|
+ result.setPassScoreCount(passScoreCount);
|
|
|
|
+ result.setGoodScoreCount(goodScoreCount);
|
|
|
|
+ result.setUpdateTime(new Date());
|
|
|
|
+ examStatisticRepo.save(result);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ log.warn("refresh ok! examId:{} courseId:{} cost:{}ms", examId, courseId, System.currentTimeMillis() - start);
|
|
|
|
+ }
|
|
|
|
+
|
|
@Override
|
|
@Override
|
|
public OverviewInfo overview(Long examId, Long courseId) {
|
|
public OverviewInfo overview(Long examId, Long courseId) {
|
|
OverviewInfo result = new OverviewInfo();
|
|
OverviewInfo result = new OverviewInfo();
|