|
@@ -10,12 +10,14 @@ import com.qmth.teachcloud.common.util.ServletUtil;
|
|
|
import com.qmth.teachcloud.report.business.bean.result.*;
|
|
|
import com.qmth.teachcloud.report.business.entity.TAExamCourse;
|
|
|
import com.qmth.teachcloud.report.business.entity.TAExamCourseRecord;
|
|
|
+import com.qmth.teachcloud.report.business.entity.TBPaper;
|
|
|
import com.qmth.teachcloud.report.business.enums.PublishStatusEnum;
|
|
|
import com.qmth.teachcloud.report.business.enums.SemesterEnum;
|
|
|
import com.qmth.teachcloud.report.business.mapper.TAExamCourseMapper;
|
|
|
import com.qmth.teachcloud.report.business.mapper.TAExamCourseRecordMapper;
|
|
|
import com.qmth.teachcloud.report.business.service.ReportCommonService;
|
|
|
import com.qmth.teachcloud.report.business.service.TAExamCourseService;
|
|
|
+import com.qmth.teachcloud.report.business.service.TBPaperService;
|
|
|
import com.qmth.teachcloud.report.business.service.TBPaperStructService;
|
|
|
import org.springframework.cache.annotation.Cacheable;
|
|
|
import org.springframework.stereotype.Service;
|
|
@@ -23,6 +25,7 @@ import org.springframework.stereotype.Service;
|
|
|
import javax.annotation.Resource;
|
|
|
import java.math.BigDecimal;
|
|
|
import java.util.*;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* <p>
|
|
@@ -47,6 +50,9 @@ public class TAExamCourseServiceImpl extends ServiceImpl<TAExamCourseMapper, TAE
|
|
|
@Resource
|
|
|
ReportCommonService reportCommonService;
|
|
|
|
|
|
+ @Resource
|
|
|
+ TBPaperService tbPaperService;
|
|
|
+
|
|
|
/**
|
|
|
* 开课课程考试总览列表接口
|
|
|
*
|
|
@@ -239,66 +245,80 @@ public class TAExamCourseServiceImpl extends ServiceImpl<TAExamCourseMapper, TAE
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public TrialCalculationResult trialCalculate(Long examId, String courseCode) {
|
|
|
- List<String> courseCodeList = new ArrayList<>();
|
|
|
- courseCodeList.add(courseCode);
|
|
|
+ public TrialCalculationResult trialCalculate(Long examId, String courseCode, BigDecimal coefficient) {
|
|
|
+ // 试卷分数设置
|
|
|
+ List<TBPaper> tbPaperList = tbPaperService.list(new QueryWrapper<TBPaper>().lambda().eq(TBPaper::getExamId,examId).eq(TBPaper::getCourseCode,courseCode));
|
|
|
+ if (tbPaperList.size() == 0){
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("该课程不存在");
|
|
|
+ }
|
|
|
+ TBPaper tbPaper = tbPaperList.get(0);
|
|
|
+ BigDecimal fullScore = tbPaper.getTotalScore();
|
|
|
+ BigDecimal passScore = tbPaper.getPassScore();
|
|
|
+ // 参考的考生数据
|
|
|
+ List<TAExamCourseRecord> taExamCourseRecordList = taExamCourseRecordMapper.selectList(new QueryWrapper<TAExamCourseRecord>().lambda()
|
|
|
+ .eq(TAExamCourseRecord::getExamId,examId)
|
|
|
+ .eq(TAExamCourseRecord::getCourseCode,courseCode)
|
|
|
+ .eq(TAExamCourseRecord::getAbsent,false));
|
|
|
+ for (TAExamCourseRecord taExamCourseRecord : taExamCourseRecordList) {
|
|
|
+ BigDecimal paperScore = taExamCourseRecord.getTotalScore();
|
|
|
+ BigDecimal assignScore = paperScore.add((fullScore.subtract(paperScore)).divide(coefficient, 4, BigDecimal.ROUND_HALF_UP));
|
|
|
+ assignScore = assignScore.setScale(0,BigDecimal.ROUND_HALF_UP);
|
|
|
+ taExamCourseRecord.setAssignedScore(assignScore);
|
|
|
+ }
|
|
|
+ int totalCount = taExamCourseRecordList.size();
|
|
|
+ int currentCount = (int) taExamCourseRecordList.stream().filter(TAExamCourseRecord::getStudentCurrent).count();
|
|
|
+
|
|
|
+ // 查找卷面数据
|
|
|
+ // 总体
|
|
|
+ List<Double> paperTotalScoreList = taExamCourseRecordList.stream().map(e -> e.getTotalScore().doubleValue()).collect(Collectors.toList());
|
|
|
+ DoubleSummaryStatistics paperTotalStatistics = paperTotalScoreList.stream().collect(Collectors.summarizingDouble(e -> e));
|
|
|
+ double paperTotalAvgScore = paperTotalStatistics.getAverage();
|
|
|
+ long paperTotalFailCount = paperTotalScoreList.stream().filter(e -> e < passScore.doubleValue()).count();
|
|
|
+ BigDecimal paperTotalFailRate = BigDecimal.valueOf(paperTotalFailCount).divide(BigDecimal.valueOf(paperTotalScoreList.size()), 4, BigDecimal.ROUND_HALF_UP);
|
|
|
+
|
|
|
+ // 应届
|
|
|
+ List<Double> paperCurrentScoreList = taExamCourseRecordList.stream().filter(TAExamCourseRecord::getStudentCurrent).map(e -> e.getTotalScore().doubleValue()).collect(Collectors.toList());
|
|
|
+ DoubleSummaryStatistics paperCurrentStatistics = paperCurrentScoreList.stream().collect(Collectors.summarizingDouble(e -> e));
|
|
|
+ double paperCurrentAvgScore = paperCurrentStatistics.getAverage();
|
|
|
+ long paperCurrentFailCount = paperCurrentScoreList.stream().filter(e -> e < passScore.doubleValue()).count();
|
|
|
+ BigDecimal paperCurrentFailRate = BigDecimal.valueOf(paperCurrentFailCount).divide(BigDecimal.valueOf(paperCurrentScoreList.size()), 4, BigDecimal.ROUND_HALF_UP);
|
|
|
+
|
|
|
+ // 查找赋分试算后数据
|
|
|
+ // 总体
|
|
|
+ List<Double> totalScoreList = taExamCourseRecordList.stream().map(e -> e.getAssignedScore().doubleValue()).collect(Collectors.toList());
|
|
|
+ DoubleSummaryStatistics totalStatistics = totalScoreList.stream().collect(Collectors.summarizingDouble(e -> e));
|
|
|
+ double totalAvgScore = totalStatistics.getAverage();
|
|
|
+ long totalFailCount = totalScoreList.stream().filter(e -> e < passScore.doubleValue()).count();
|
|
|
+ BigDecimal totalFailRate = BigDecimal.valueOf(totalFailCount).divide(BigDecimal.valueOf(totalScoreList.size()), 4, BigDecimal.ROUND_HALF_UP);
|
|
|
+
|
|
|
+ // 应届
|
|
|
+ List<Double> currentScoreList = taExamCourseRecordList.stream().filter(TAExamCourseRecord::getStudentCurrent).map(e -> e.getAssignedScore().doubleValue()).collect(Collectors.toList());
|
|
|
+ DoubleSummaryStatistics currentStatistics = currentScoreList.stream().collect(Collectors.summarizingDouble(e -> e));
|
|
|
+ double currentAvgScore = currentStatistics.getAverage();
|
|
|
+ long currentFailCount = currentScoreList.stream().filter(e -> e < passScore.doubleValue()).count();
|
|
|
+ BigDecimal currentFailRate = BigDecimal.valueOf(currentFailCount).divide(BigDecimal.valueOf(currentScoreList.size()), 4, BigDecimal.ROUND_HALF_UP);
|
|
|
+
|
|
|
+ // 组装
|
|
|
+ TrialCalculationResult trialCalculationResult = new TrialCalculationResult();
|
|
|
+ trialCalculationResult.setTotalCount(totalCount);
|
|
|
+ trialCalculationResult.setCurrentCount(currentCount);
|
|
|
+ // - 卷面-总体
|
|
|
+ trialCalculationResult.setAvgScore(BigDecimal.valueOf(paperTotalAvgScore));
|
|
|
+ trialCalculationResult.setFailRate(paperTotalFailRate);
|
|
|
+ trialCalculationResult.setFailCount((int) paperTotalFailCount);
|
|
|
+ // - 卷面-应届
|
|
|
+ trialCalculationResult.setCurrentAvgScore(BigDecimal.valueOf(paperCurrentAvgScore));
|
|
|
+ trialCalculationResult.setCurrentFailRate(paperCurrentFailRate);
|
|
|
+ trialCalculationResult.setCurrentFailCount((int) paperCurrentFailCount);
|
|
|
+ // - 赋分-总体
|
|
|
+ trialCalculationResult.setAvgScoreAssign(BigDecimal.valueOf(totalAvgScore));
|
|
|
+ trialCalculationResult.setFailRateAssign(totalFailRate);
|
|
|
+ trialCalculationResult.setFailCountAssign((int) totalFailCount);
|
|
|
+ // - 赋分-应届
|
|
|
+ trialCalculationResult.setCurrentAvgScoreAssign(BigDecimal.valueOf(currentAvgScore));
|
|
|
+ trialCalculationResult.setCurrentFailRateAssign(currentFailRate);
|
|
|
+ trialCalculationResult.setCurrentFailCountAssign((int) currentFailCount);
|
|
|
|
|
|
-// // 数据同步操作
|
|
|
-// // 获取当前课程下所有学生考试成绩记录
|
|
|
-// List<BasicExamRecordDto> basicExamRecordDtoDatasource = tbExamRecordService.findByExamIdAndCourseCodeS(examId, courseCodeList);
|
|
|
-// for (String s : courseCodeList) {
|
|
|
-// if (tbExamCourseService.verifyExamCourseCantRun(examId, tbExamService.getById(examId).getSchoolId(), s, basicCourseService.findByCourseCode(s).getName())) {
|
|
|
-// throw ExceptionResultEnum.ERROR.exception("课程编号[" + s + "]的课程分析数据已测试或发布,不能变更基础数据");
|
|
|
-// }
|
|
|
-// List<BasicExamRecordDto> basicExamRecordDtoList = basicExamRecordDtoDatasource.stream()
|
|
|
-// .filter(e -> s.equals(e.getCourseCode())).collect(Collectors.toList());
|
|
|
-// if (basicExamRecordDtoList.size() > 0) {
|
|
|
-// // 迁移数据至't_a_exam_course_record'
|
|
|
-// List<TAExamCourseRecord> taExamCourseRecordList = new ArrayList<>();
|
|
|
-// for (BasicExamRecordDto basicExamRecordDto : basicExamRecordDtoList) {
|
|
|
-// boolean absent = basicExamRecordDto.getAbsent();
|
|
|
-// // 正常公式赋分操作
|
|
|
-// Long paperId = basicExamRecordDto.getPaperId();
|
|
|
-// TBPaper tbPaper = tbPaperService.getById(paperId);
|
|
|
-// if (Objects.isNull(tbPaper)) {
|
|
|
-// throw ExceptionResultEnum.ERROR.exception("试卷信息数据异常");
|
|
|
-// }
|
|
|
-// BigDecimal fullScore = tbPaper.getTotalScore();
|
|
|
-// BigDecimal myScore = basicExamRecordDto.getTotalScore();
|
|
|
-// BigDecimal coefficient = tbPaper.getCoefficient();
|
|
|
-// BigDecimal assignScore;
|
|
|
-// // 当该试卷的赋分系数不为0时赋分
|
|
|
-// if (coefficient != null && coefficient.compareTo(BigDecimal.ZERO) > 0 && !absent) {
|
|
|
-// assignScore = myScore.add((fullScore.subtract(myScore)).divide(coefficient, 0, BigDecimal.ROUND_HALF_UP));
|
|
|
-// } else {
|
|
|
-// assignScore = myScore;
|
|
|
-// }
|
|
|
-//
|
|
|
-// TAExamCourseRecord taExamCourseRecord = new TAExamCourseRecord();
|
|
|
-// taExamCourseRecord.setId(SystemConstant.getDbUuid());
|
|
|
-// taExamCourseRecord.setExamRecordId(basicExamRecordDto.getTbExamRecordId());
|
|
|
-// // 数据同步默认赋分成绩为卷面成绩
|
|
|
-// taExamCourseRecord.setSchoolId(tbExamService.getById(examId).getSchoolId());
|
|
|
-// taExamCourseRecord.setAssignedScore(assignScore);
|
|
|
-// taExamCourseRecord.setExamId(examId);
|
|
|
-// taExamCourseRecord.setCourseCode(basicExamRecordDto.getCourseCode());
|
|
|
-// taExamCourseRecord.setPaperId(basicExamRecordDto.getPaperId());
|
|
|
-// taExamCourseRecord.setPaperType(basicExamRecordDto.getPaperType());
|
|
|
-// taExamCourseRecord.setStudentId(basicExamRecordDto.getStudentId());
|
|
|
-// taExamCourseRecord.setStudentCode(basicExamRecordDto.getStudentCode());
|
|
|
-// taExamCourseRecord.setTeacherId(basicExamRecordDto.getTeacherId());
|
|
|
-// taExamCourseRecord.setClazzId(basicExamRecordDto.getClazzId());
|
|
|
-// taExamCourseRecord.setTeachCollegeId(basicExamRecordDto.getTeachCollegeId());
|
|
|
-// taExamCourseRecord.setInspectCollegeId(basicExamRecordDto.getInspectCollegeId());
|
|
|
-// taExamCourseRecord.setMajorId(basicExamRecordDto.getMajorId());
|
|
|
-// taExamCourseRecord.setTotalScore(myScore);
|
|
|
-// taExamCourseRecord.setAbsent(absent);
|
|
|
-// taExamCourseRecord.setStudentCurrent(basicExamRecordDto.getStudentCurrent());
|
|
|
-// taExamCourseRecordList.add(taExamCourseRecord);
|
|
|
-// }
|
|
|
-// taExamCourseRecordService.saveBatch(taExamCourseRecordList);
|
|
|
-// }
|
|
|
-// }
|
|
|
- return null;
|
|
|
+ return trialCalculationResult;
|
|
|
}
|
|
|
}
|