|
@@ -1,33 +1,37 @@
|
|
package cn.com.qmth.stmms.biz.report.service.impl;
|
|
package cn.com.qmth.stmms.biz.report.service.impl;
|
|
|
|
|
|
|
|
+import java.util.Arrays;
|
|
|
|
+import java.util.Collections;
|
|
|
|
+import java.util.HashMap;
|
|
|
|
+import java.util.LinkedList;
|
|
|
|
+import java.util.List;
|
|
|
|
+import java.util.Map;
|
|
|
|
+
|
|
|
|
+import javax.persistence.criteria.CriteriaBuilder;
|
|
|
|
+import javax.persistence.criteria.CriteriaQuery;
|
|
|
|
+import javax.persistence.criteria.Predicate;
|
|
|
|
+import javax.persistence.criteria.Root;
|
|
|
|
+
|
|
|
|
+import org.apache.commons.lang.StringUtils;
|
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
+import org.springframework.data.jpa.domain.Specification;
|
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
|
+
|
|
import cn.com.qmth.stmms.biz.common.BaseQueryService;
|
|
import cn.com.qmth.stmms.biz.common.BaseQueryService;
|
|
import cn.com.qmth.stmms.biz.exam.dao.ExamQuestionDao;
|
|
import cn.com.qmth.stmms.biz.exam.dao.ExamQuestionDao;
|
|
import cn.com.qmth.stmms.biz.exam.dao.ExamStudentDao;
|
|
import cn.com.qmth.stmms.biz.exam.dao.ExamStudentDao;
|
|
import cn.com.qmth.stmms.biz.exam.dao.ExamSubjectDao;
|
|
import cn.com.qmth.stmms.biz.exam.dao.ExamSubjectDao;
|
|
|
|
+import cn.com.qmth.stmms.biz.exam.dao.MarkGroupDao;
|
|
import cn.com.qmth.stmms.biz.exam.model.ExamQuestion;
|
|
import cn.com.qmth.stmms.biz.exam.model.ExamQuestion;
|
|
import cn.com.qmth.stmms.biz.exam.model.ExamStudent;
|
|
import cn.com.qmth.stmms.biz.exam.model.ExamStudent;
|
|
import cn.com.qmth.stmms.biz.exam.model.ExamSubject;
|
|
import cn.com.qmth.stmms.biz.exam.model.ExamSubject;
|
|
|
|
+import cn.com.qmth.stmms.biz.exam.model.MarkGroup;
|
|
import cn.com.qmth.stmms.biz.report.dao.ReportSubjectGroupDao;
|
|
import cn.com.qmth.stmms.biz.report.dao.ReportSubjectGroupDao;
|
|
import cn.com.qmth.stmms.biz.report.model.ReportSubjectGroup;
|
|
import cn.com.qmth.stmms.biz.report.model.ReportSubjectGroup;
|
|
import cn.com.qmth.stmms.biz.report.query.ReportSubjectQuery;
|
|
import cn.com.qmth.stmms.biz.report.query.ReportSubjectQuery;
|
|
import cn.com.qmth.stmms.biz.report.service.ReportSubjectGroupService;
|
|
import cn.com.qmth.stmms.biz.report.service.ReportSubjectGroupService;
|
|
import cn.com.qmth.stmms.biz.utils.DoubleUtil;
|
|
import cn.com.qmth.stmms.biz.utils.DoubleUtil;
|
|
|
|
|
|
-import org.apache.commons.lang.StringUtils;
|
|
|
|
-import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
-import org.springframework.data.jpa.domain.Specification;
|
|
|
|
-import org.springframework.stereotype.Service;
|
|
|
|
-
|
|
|
|
-import javax.persistence.criteria.CriteriaBuilder;
|
|
|
|
-import javax.persistence.criteria.CriteriaQuery;
|
|
|
|
-import javax.persistence.criteria.Predicate;
|
|
|
|
-import javax.persistence.criteria.Root;
|
|
|
|
-
|
|
|
|
-import java.util.Arrays;
|
|
|
|
-import java.util.Collections;
|
|
|
|
-import java.util.LinkedList;
|
|
|
|
-import java.util.List;
|
|
|
|
-
|
|
|
|
/**
|
|
/**
|
|
* 大题型统计分析 service 实现
|
|
* 大题型统计分析 service 实现
|
|
*
|
|
*
|
|
@@ -48,6 +52,9 @@ public class ReportSubjectGroupServiceImpl extends BaseQueryService<ReportSubjec
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
private ExamSubjectDao examSubjectDao;
|
|
private ExamSubjectDao examSubjectDao;
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ private MarkGroupDao groupDao;
|
|
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@@ -81,9 +88,9 @@ public class ReportSubjectGroupServiceImpl extends BaseQueryService<ReportSubjec
|
|
@Override
|
|
@Override
|
|
public void saveReportSubjectGroupData(Integer examId, String subjectCode) {
|
|
public void saveReportSubjectGroupData(Integer examId, String subjectCode) {
|
|
//保存客观题统计分析
|
|
//保存客观题统计分析
|
|
- saveReportSubjectGroupData(examId, subjectCode, true);
|
|
|
|
|
|
+ saveReportSubjectObjectiveGroupData(examId, subjectCode);
|
|
//保存主观题统计分析
|
|
//保存主观题统计分析
|
|
- saveReportSubjectGroupData(examId, subjectCode, false);
|
|
|
|
|
|
+ saveReportSubjectSubjectiveGroupData(examId, subjectCode);
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -91,22 +98,139 @@ public class ReportSubjectGroupServiceImpl extends BaseQueryService<ReportSubjec
|
|
*
|
|
*
|
|
* @param examId 考试Id
|
|
* @param examId 考试Id
|
|
* @param subjectCode 科目Code
|
|
* @param subjectCode 科目Code
|
|
- * @param objective 客观题,主观题
|
|
|
|
|
|
+ * @param subjective 主观题
|
|
*/
|
|
*/
|
|
- private void saveReportSubjectGroupData(Integer examId, String subjectCode, Boolean objective) {
|
|
|
|
|
|
+ private void saveReportSubjectSubjectiveGroupData(Integer examId, String subjectCode) {
|
|
|
|
+
|
|
ExamSubject subject = examSubjectDao.findByExamIdAndCode(examId, subjectCode);
|
|
ExamSubject subject = examSubjectDao.findByExamIdAndCode(examId, subjectCode);
|
|
- List<Object[]> questionGroups = reportSubjectGroupDao.countGroupByMainNum(examId, subjectCode, objective);
|
|
|
|
|
|
+ List<MarkGroup> groups = groupDao.findByExamIdAndSubjectCode(examId, subjectCode);
|
|
|
|
+
|
|
List<ExamStudent> examStudentList = examStudentDao.findByExamIdAndSubjectCodeAndUploadTimeNotNullAndAbsent(examId, subjectCode, false);
|
|
List<ExamStudent> examStudentList = examStudentDao.findByExamIdAndSubjectCodeAndUploadTimeNotNullAndAbsent(examId, subjectCode, false);
|
|
Integer studentCount = examStudentList.size();
|
|
Integer studentCount = examStudentList.size();
|
|
Integer begin = 0;
|
|
Integer begin = 0;
|
|
|
|
+ for (int i = 0; i < groups.size(); i++) {
|
|
|
|
+ MarkGroup group = groups.get(i);
|
|
|
|
+ //满分
|
|
|
|
+ Double fullScore = group.getTotalScore();
|
|
|
|
+ Integer questionCount = examQuestionDao.findByExamIdAndSubjectCodeAndObjectiveAndMainNumber(examId, subjectCode, false, group.getNumber()).size();
|
|
|
|
+ Double[] totalScoreArray = new Double[studentCount];
|
|
|
|
+ //题型 总分
|
|
|
|
+ Double totalScore = 0d;
|
|
|
|
+ //0分人数
|
|
|
|
+ Integer zeroScoreCount = 0;
|
|
|
|
+ //满分人数
|
|
|
|
+ Integer fullScoreCount = 0;
|
|
|
|
+ //方差
|
|
|
|
+ Double variance = 0d;
|
|
|
|
+ for (int j = 0; j < studentCount; j++) {
|
|
|
|
+ ExamStudent student = examStudentList.get(j);
|
|
|
|
+ String[] answers = null;
|
|
|
|
+ if (StringUtils.isNotBlank(student.getSubjectiveScoreList())) {
|
|
|
|
+ answers = student.getSubjectiveScoreList().split(";");
|
|
|
|
+ }
|
|
|
|
+ Double score = 0d;
|
|
|
|
+ for (int k = begin; k < begin + questionCount; k++) {
|
|
|
|
+ Double s = 0d;
|
|
|
|
+ if (answers != null) {
|
|
|
|
+ s = Double.parseDouble(answers[k]);
|
|
|
|
+ }
|
|
|
|
+ score = DoubleUtil.sum(score, s);
|
|
|
|
+ }
|
|
|
|
+ if (score.doubleValue() == 0) {
|
|
|
|
+ zeroScoreCount++;
|
|
|
|
+ }
|
|
|
|
+ if (score.doubleValue() == fullScore.doubleValue()) {
|
|
|
|
+ fullScoreCount++;
|
|
|
|
+ }
|
|
|
|
+ totalScoreArray[j] = score;
|
|
|
|
+ totalScore = DoubleUtil.sum(totalScore, score);
|
|
|
|
+ }
|
|
|
|
+ //最大分
|
|
|
|
+ Double maxScore = Collections.max(Arrays.asList(totalScoreArray));
|
|
|
|
+ //最小分
|
|
|
|
+ Double minScore = Collections.min(Arrays.asList(totalScoreArray));
|
|
|
|
+ //平均分
|
|
|
|
+ Double avgScore = DoubleUtil.div(totalScore, studentCount, 2);
|
|
|
|
+ //计算方差
|
|
|
|
+ for (int j = 0; j < studentCount; j++) {
|
|
|
|
+ ExamStudent student = examStudentList.get(j);
|
|
|
|
+ String[] answers = null;
|
|
|
|
+ if (StringUtils.isNotBlank(student.getSubjectiveScoreList())) {
|
|
|
|
+ answers = student.getSubjectiveScoreList().split(";");
|
|
|
|
+ }
|
|
|
|
+ Double score = 0d;
|
|
|
|
+ for (int k = begin; k < begin + questionCount; k++) {
|
|
|
|
+ Double s = 0d;
|
|
|
|
+ if (answers != null) {
|
|
|
|
+ s = Double.parseDouble(answers[k]);
|
|
|
|
+ }
|
|
|
|
+ score = DoubleUtil.sum(score, s);
|
|
|
|
+ }
|
|
|
|
+ variance = DoubleUtil.sum(variance, DoubleUtil.mul(DoubleUtil.sub(score, avgScore), DoubleUtil.sub(score, avgScore)));
|
|
|
|
+ }
|
|
|
|
+ //标准差
|
|
|
|
+ Double sd = DoubleUtil.format(Math.sqrt(variance / studentCount), "0.00");
|
|
|
|
+ //差异系数
|
|
|
|
+ Double cv = 0d;
|
|
|
|
+ if (avgScore.doubleValue() > 0) {
|
|
|
|
+ cv = DoubleUtil.mul(DoubleUtil.div(sd, avgScore, 4), 100);
|
|
|
|
+ }
|
|
|
|
+ //得分率
|
|
|
|
+ Double scoreRate = 0d;
|
|
|
|
+ if(fullScore != 0){
|
|
|
|
+ scoreRate = DoubleUtil.div(avgScore,fullScore, 2);
|
|
|
|
+ }
|
|
|
|
+ ReportSubjectGroup reportSubjectGroup = new ReportSubjectGroup();
|
|
|
|
+ reportSubjectGroup.setExamId(examId);
|
|
|
|
+ reportSubjectGroup.setSubjectCode(subjectCode);
|
|
|
|
+ reportSubjectGroup.setSubjectName(subject.getName());
|
|
|
|
+ reportSubjectGroup.setGroupName(group.getTitle());
|
|
|
|
+ reportSubjectGroup.setGroupNumber(group.getNumber());
|
|
|
|
+ reportSubjectGroup.setMaxScore(maxScore);
|
|
|
|
+ reportSubjectGroup.setMinScore(minScore);
|
|
|
|
+ reportSubjectGroup.setAvgScore(avgScore);
|
|
|
|
+ reportSubjectGroup.setTotalScore(fullScore);
|
|
|
|
+ reportSubjectGroup.setSD(sd);
|
|
|
|
+ reportSubjectGroup.setCV(cv);
|
|
|
|
+ reportSubjectGroup.setScoreRate(scoreRate);
|
|
|
|
+ reportSubjectGroup.setZeroCount(zeroScoreCount);
|
|
|
|
+ reportSubjectGroup.setFullCount(fullScoreCount);
|
|
|
|
+
|
|
|
|
+ begin += questionCount;
|
|
|
|
+ reportSubjectGroupDao.save(reportSubjectGroup);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 保存题型统计分析
|
|
|
|
+ *
|
|
|
|
+ * @param examId 考试Id
|
|
|
|
+ * @param subjectCode 科目Code
|
|
|
|
+ * @param objective 客观题
|
|
|
|
+ */
|
|
|
|
+ private void saveReportSubjectObjectiveGroupData(Integer examId, String subjectCode) {
|
|
|
|
+ ExamSubject subject = examSubjectDao.findByExamIdAndCode(examId, subjectCode);
|
|
|
|
+ List<Object[]> questionGroups = reportSubjectGroupDao.countGroupByMainNum(examId, subjectCode, true);
|
|
|
|
+ List<ExamStudent> examStudentList = examStudentDao.findByExamIdAndSubjectCodeAndUploadTimeNotNullAndAbsent(examId, subjectCode, false);
|
|
|
|
+ Integer studentCount = examStudentList.size();
|
|
|
|
+ Integer begin = 0;
|
|
|
|
+ Map<Integer,ExamQuestion> map = new HashMap<Integer, ExamQuestion>();
|
|
for (int i = 0; i < questionGroups.size(); i++) {
|
|
for (int i = 0; i < questionGroups.size(); i++) {
|
|
Object[] obj = questionGroups.get(i);
|
|
Object[] obj = questionGroups.get(i);
|
|
ExamQuestion question = new ExamQuestion();
|
|
ExamQuestion question = new ExamQuestion();
|
|
question.setMainNumber(Integer.parseInt(obj[0].toString()));
|
|
question.setMainNumber(Integer.parseInt(obj[0].toString()));
|
|
question.setMainTitle(obj[1].toString());
|
|
question.setMainTitle(obj[1].toString());
|
|
- question.setSubNumber(Integer.parseInt(obj[2].toString()));
|
|
|
|
|
|
+ question.setPaperType(obj[2].toString());
|
|
|
|
+ question.setSubNumber(Integer.parseInt(obj[3].toString()));
|
|
|
|
+ if(map.get(question.getMainNumber())!=null){
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ map.put(question.getMainNumber(), question);
|
|
//满分
|
|
//满分
|
|
- Double fullScore = examQuestionDao.queryFullScoreByExamIdAndSubjectCodeAndMainNumber(examId, subjectCode, question.getMainNumber());
|
|
|
|
|
|
+ Double fullScore = examQuestionDao.queryFullScoreByExamIdAndSubjectCodeAndMainNumberAndPaperType(examId, subjectCode, question.getMainNumber(),question.getPaperType());
|
|
Integer questionCount = question.getSubNumber();
|
|
Integer questionCount = question.getSubNumber();
|
|
Double[] totalScoreArray = new Double[studentCount];
|
|
Double[] totalScoreArray = new Double[studentCount];
|
|
//题型 总分
|
|
//题型 总分
|
|
@@ -120,24 +244,14 @@ public class ReportSubjectGroupServiceImpl extends BaseQueryService<ReportSubjec
|
|
for (int j = 0; j < studentCount; j++) {
|
|
for (int j = 0; j < studentCount; j++) {
|
|
ExamStudent student = examStudentList.get(j);
|
|
ExamStudent student = examStudentList.get(j);
|
|
String[] answers = null;
|
|
String[] answers = null;
|
|
- if (objective) {
|
|
|
|
if (StringUtils.isNotBlank(student.getObjectiveScoreList())) {
|
|
if (StringUtils.isNotBlank(student.getObjectiveScoreList())) {
|
|
answers = student.getObjectiveScoreList().split(";");
|
|
answers = student.getObjectiveScoreList().split(";");
|
|
}
|
|
}
|
|
- } else {
|
|
|
|
- if (StringUtils.isNotBlank(student.getSubjectiveScoreList())) {
|
|
|
|
- answers = student.getSubjectiveScoreList().split(";");
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
Double score = 0d;
|
|
Double score = 0d;
|
|
for (int k = begin; k < begin + questionCount; k++) {
|
|
for (int k = begin; k < begin + questionCount; k++) {
|
|
Double s = 0d;
|
|
Double s = 0d;
|
|
if (answers != null) {
|
|
if (answers != null) {
|
|
- if (objective) {
|
|
|
|
s = Double.parseDouble(answers[k].split(":")[1]);
|
|
s = Double.parseDouble(answers[k].split(":")[1]);
|
|
- } else {
|
|
|
|
- s = Double.parseDouble(answers[k]);
|
|
|
|
- }
|
|
|
|
}
|
|
}
|
|
score = DoubleUtil.sum(score, s);
|
|
score = DoubleUtil.sum(score, s);
|
|
}
|
|
}
|
|
@@ -160,24 +274,14 @@ public class ReportSubjectGroupServiceImpl extends BaseQueryService<ReportSubjec
|
|
for (int j = 0; j < studentCount; j++) {
|
|
for (int j = 0; j < studentCount; j++) {
|
|
ExamStudent student = examStudentList.get(j);
|
|
ExamStudent student = examStudentList.get(j);
|
|
String[] answers = null;
|
|
String[] answers = null;
|
|
- if (objective) {
|
|
|
|
if (StringUtils.isNotBlank(student.getObjectiveScoreList())) {
|
|
if (StringUtils.isNotBlank(student.getObjectiveScoreList())) {
|
|
answers = student.getObjectiveScoreList().split(";");
|
|
answers = student.getObjectiveScoreList().split(";");
|
|
}
|
|
}
|
|
- } else {
|
|
|
|
- if (StringUtils.isNotBlank(student.getSubjectiveScoreList())) {
|
|
|
|
- answers = student.getSubjectiveScoreList().split(";");
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
Double score = 0d;
|
|
Double score = 0d;
|
|
for (int k = begin; k < begin + questionCount; k++) {
|
|
for (int k = begin; k < begin + questionCount; k++) {
|
|
Double s = 0d;
|
|
Double s = 0d;
|
|
if (answers != null) {
|
|
if (answers != null) {
|
|
- if (objective) {
|
|
|
|
s = Double.parseDouble(answers[k].split(":")[1]);
|
|
s = Double.parseDouble(answers[k].split(":")[1]);
|
|
- } else {
|
|
|
|
- s = Double.parseDouble(answers[k]);
|
|
|
|
- }
|
|
|
|
}
|
|
}
|
|
score = DoubleUtil.sum(score, s);
|
|
score = DoubleUtil.sum(score, s);
|
|
}
|
|
}
|