|
@@ -2,8 +2,6 @@ package cn.com.qmth.stmms.biz.report.service.impl;
|
|
|
|
|
|
import java.io.ByteArrayInputStream;
|
|
import java.io.ByteArrayInputStream;
|
|
import java.io.IOException;
|
|
import java.io.IOException;
|
|
-import java.math.BigDecimal;
|
|
|
|
-import java.math.RoundingMode;
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
import java.util.HashMap;
|
|
import java.util.HashMap;
|
|
import java.util.HashSet;
|
|
import java.util.HashSet;
|
|
@@ -11,9 +9,6 @@ import java.util.List;
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
import java.util.Set;
|
|
import java.util.Set;
|
|
|
|
|
|
-import net.sf.json.JSONArray;
|
|
|
|
-import net.sf.json.JSONObject;
|
|
|
|
-
|
|
|
|
import org.apache.commons.io.output.ByteArrayOutputStream;
|
|
import org.apache.commons.io.output.ByteArrayOutputStream;
|
|
import org.apache.commons.lang.StringUtils;
|
|
import org.apache.commons.lang.StringUtils;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.Logger;
|
|
@@ -21,6 +16,8 @@ import org.slf4j.LoggerFactory;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Component;
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
|
|
+import com.qmth.boot.tools.codec.CodecUtils;
|
|
|
|
+
|
|
import cn.com.qmth.stmms.biz.exam.model.Exam;
|
|
import cn.com.qmth.stmms.biz.exam.model.Exam;
|
|
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;
|
|
@@ -50,13 +47,18 @@ import cn.com.qmth.stmms.biz.report.service.ReportSubjectService;
|
|
import cn.com.qmth.stmms.biz.report.service.ReportSubjectTeacherClassService;
|
|
import cn.com.qmth.stmms.biz.report.service.ReportSubjectTeacherClassService;
|
|
import cn.com.qmth.stmms.biz.report.service.ReportSubjectTeacherService;
|
|
import cn.com.qmth.stmms.biz.report.service.ReportSubjectTeacherService;
|
|
import cn.com.qmth.stmms.biz.report.utils.ReportContext;
|
|
import cn.com.qmth.stmms.biz.report.utils.ReportContext;
|
|
|
|
+import cn.com.qmth.stmms.biz.report.utils.ReportSubjectClassDTO;
|
|
|
|
+import cn.com.qmth.stmms.biz.report.utils.ReportSubjectCollegeDTO;
|
|
|
|
+import cn.com.qmth.stmms.biz.report.utils.ReportSubjectGroupDTO;
|
|
|
|
+import cn.com.qmth.stmms.biz.report.utils.ReportSubjectQuestionDTO;
|
|
import cn.com.qmth.stmms.biz.report.utils.ReportSubjectRangeDTO;
|
|
import cn.com.qmth.stmms.biz.report.utils.ReportSubjectRangeDTO;
|
|
|
|
+import cn.com.qmth.stmms.biz.report.utils.ReportSubjectTeacherDTO;
|
|
import cn.com.qmth.stmms.biz.utils.ExportExcel;
|
|
import cn.com.qmth.stmms.biz.utils.ExportExcel;
|
|
import cn.com.qmth.stmms.common.enums.ExamStatus;
|
|
import cn.com.qmth.stmms.common.enums.ExamStatus;
|
|
import cn.com.qmth.stmms.common.enums.LockType;
|
|
import cn.com.qmth.stmms.common.enums.LockType;
|
|
import cn.com.qmth.stmms.common.enums.SubjectiveStatus;
|
|
import cn.com.qmth.stmms.common.enums.SubjectiveStatus;
|
|
-
|
|
|
|
-import com.qmth.boot.tools.codec.CodecUtils;
|
|
|
|
|
|
+import net.sf.json.JSONArray;
|
|
|
|
+import net.sf.json.JSONObject;
|
|
|
|
|
|
@Component
|
|
@Component
|
|
public class ReportServiceImpl implements ReportService {
|
|
public class ReportServiceImpl implements ReportService {
|
|
@@ -241,10 +243,10 @@ public class ReportServiceImpl implements ReportService {
|
|
if (SubjectiveStatus.MARKED.equals(student.getSubjectiveStatus())
|
|
if (SubjectiveStatus.MARKED.equals(student.getSubjectiveStatus())
|
|
|| (subject.getSubjectiveScore().doubleValue() == 0 && subject.getObjectiveScore() > 0)) {
|
|
|| (subject.getSubjectiveScore().doubleValue() == 0 && subject.getObjectiveScore() > 0)) {
|
|
student.setSubject(subject);
|
|
student.setSubject(subject);
|
|
- student.setObjectiveQuestionList(findQuestionList(student.getExamId(), student.getSubjectCode(),
|
|
|
|
- student.getPaperType(), true));
|
|
|
|
- student.setSubjectiveQuestionList(findQuestionList(student.getExamId(), student.getSubjectCode(),
|
|
|
|
- student.getPaperType(), false));
|
|
|
|
|
|
+ student.setObjectiveQuestionList(
|
|
|
|
+ findQuestionList(student.getExamId(), student.getSubjectCode(), student.getPaperType(), true));
|
|
|
|
+ student.setSubjectiveQuestionList(
|
|
|
|
+ findQuestionList(student.getExamId(), student.getSubjectCode(), student.getPaperType(), false));
|
|
context.process(student);
|
|
context.process(student);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -288,22 +290,20 @@ public class ReportServiceImpl implements ReportService {
|
|
uploadGroup(examId, subjectCode, findExamSubject(examId, subjectCode).getName(), "分组统计分析");
|
|
uploadGroup(examId, subjectCode, findExamSubject(examId, subjectCode).getName(), "分组统计分析");
|
|
}
|
|
}
|
|
|
|
|
|
- private void uploadGroup(int examId, String subjectCode, String subjectName, String name) throws IOException,
|
|
|
|
- Exception {
|
|
|
|
|
|
+ private void uploadGroup(int examId, String subjectCode, String subjectName, String name)
|
|
|
|
+ throws IOException, Exception {
|
|
ReportSubjectQuery query = new ReportSubjectQuery();
|
|
ReportSubjectQuery query = new ReportSubjectQuery();
|
|
query.setExamId(examId);
|
|
query.setExamId(examId);
|
|
query.setSubjectCode(subjectCode);
|
|
query.setSubjectCode(subjectCode);
|
|
query.setPageNumber(1);
|
|
query.setPageNumber(1);
|
|
query.setPageSize(Integer.MAX_VALUE);
|
|
query.setPageSize(Integer.MAX_VALUE);
|
|
- List<ReportSubjectGroup> list = reportSubjectGroupService.findByQuery(query);
|
|
|
|
- for (ReportSubjectGroup r : list) {
|
|
|
|
- r.setAvgScore(new BigDecimal(r.getAvgScore()).setScale(2, RoundingMode.HALF_UP).doubleValue());
|
|
|
|
- r.setScoreRate(new BigDecimal(r.getScoreRate()).setScale(2, RoundingMode.HALF_UP).doubleValue());
|
|
|
|
- r.setStdev(new BigDecimal(r.getStdev()).setScale(2, RoundingMode.HALF_UP).doubleValue());
|
|
|
|
- r.setCoefficient(new BigDecimal(r.getCoefficient()).setScale(2, RoundingMode.HALF_UP).doubleValue());
|
|
|
|
|
|
+ List<ReportSubjectGroup> result = reportSubjectGroupService.findByQuery(query);
|
|
|
|
+ List<ReportSubjectGroupDTO> list = new ArrayList<>();
|
|
|
|
+ for (ReportSubjectGroup r : result) {
|
|
|
|
+ list.add(new ReportSubjectGroupDTO(r));
|
|
}
|
|
}
|
|
ByteArrayOutputStream os = new ByteArrayOutputStream();
|
|
ByteArrayOutputStream os = new ByteArrayOutputStream();
|
|
- new ExportExcel(name, ReportSubjectGroup.class).setDataList(list).write(os);
|
|
|
|
|
|
+ new ExportExcel(name, ReportSubjectGroupDTO.class).setDataList(list).write(os);
|
|
os.flush();
|
|
os.flush();
|
|
byte[] value = os.toByteArray();
|
|
byte[] value = os.toByteArray();
|
|
String md5 = CodecUtils.toHexString(CodecUtils.md5(value));
|
|
String md5 = CodecUtils.toHexString(CodecUtils.md5(value));
|
|
@@ -319,15 +319,13 @@ public class ReportServiceImpl implements ReportService {
|
|
query.setObjective(objective);
|
|
query.setObjective(objective);
|
|
query.setPageNumber(1);
|
|
query.setPageNumber(1);
|
|
query.setPageSize(Integer.MAX_VALUE);
|
|
query.setPageSize(Integer.MAX_VALUE);
|
|
- List<ReportSubjectQuestion> list = reportSubjectQuestionService.findByQuery(query);
|
|
|
|
- for (ReportSubjectQuestion r : list) {
|
|
|
|
- r.setAvgScore(new BigDecimal(r.getAvgScore()).setScale(2, RoundingMode.HALF_UP).doubleValue());
|
|
|
|
- r.setStdev(new BigDecimal(r.getStdev()).setScale(2, RoundingMode.HALF_UP).doubleValue());
|
|
|
|
- r.setScoreRate(new BigDecimal(r.getScoreRate()).setScale(2, RoundingMode.HALF_UP).doubleValue());
|
|
|
|
- r.setFullScoreRate(new BigDecimal(r.getFullScoreRate()).setScale(2, RoundingMode.HALF_UP).doubleValue());
|
|
|
|
|
|
+ List<ReportSubjectQuestion> result = reportSubjectQuestionService.findByQuery(query);
|
|
|
|
+ List<ReportSubjectQuestionDTO> list = new ArrayList<>();
|
|
|
|
+ for (ReportSubjectQuestion r : result) {
|
|
|
|
+ list.add(new ReportSubjectQuestionDTO(r));
|
|
}
|
|
}
|
|
ByteArrayOutputStream os = new ByteArrayOutputStream();
|
|
ByteArrayOutputStream os = new ByteArrayOutputStream();
|
|
- new ExportExcel(name, ReportSubjectQuestion.class).setDataList(list).write(os);
|
|
|
|
|
|
+ new ExportExcel(name, ReportSubjectQuestionDTO.class).setDataList(list).write(os);
|
|
os.flush();
|
|
os.flush();
|
|
byte[] value = os.toByteArray();
|
|
byte[] value = os.toByteArray();
|
|
String md5 = CodecUtils.toHexString(CodecUtils.md5(value));
|
|
String md5 = CodecUtils.toHexString(CodecUtils.md5(value));
|
|
@@ -335,23 +333,20 @@ public class ReportServiceImpl implements ReportService {
|
|
FormatType.XLSX);
|
|
FormatType.XLSX);
|
|
}
|
|
}
|
|
|
|
|
|
- private void uploadTeacher(int examId, String subjectCode, String subjectName, String name) throws IOException,
|
|
|
|
- Exception {
|
|
|
|
|
|
+ private void uploadTeacher(int examId, String subjectCode, String subjectName, String name)
|
|
|
|
+ throws IOException, Exception {
|
|
ReportSubjectQuery query = new ReportSubjectQuery();
|
|
ReportSubjectQuery query = new ReportSubjectQuery();
|
|
query.setExamId(examId);
|
|
query.setExamId(examId);
|
|
query.setSubjectCode(subjectCode);
|
|
query.setSubjectCode(subjectCode);
|
|
query.setPageNumber(1);
|
|
query.setPageNumber(1);
|
|
query.setPageSize(Integer.MAX_VALUE);
|
|
query.setPageSize(Integer.MAX_VALUE);
|
|
- List<ReportSubjectTeacher> list = reportSubjectTeacherService.findByQuery(query);
|
|
|
|
- for (ReportSubjectTeacher r : list) {
|
|
|
|
- r.setAvgScore(new BigDecimal(r.getAvgScore()).setScale(2, RoundingMode.HALF_UP).doubleValue());
|
|
|
|
- r.setExcellentRate(new BigDecimal(r.getExcellentRate()).setScale(2, RoundingMode.HALF_UP).doubleValue());
|
|
|
|
- r.setPassRate(new BigDecimal(r.getPassRate()).setScale(2, RoundingMode.HALF_UP).doubleValue());
|
|
|
|
- r.setRelativeAvgScore(new BigDecimal(r.getRelativeAvgScore()).setScale(2, RoundingMode.HALF_UP)
|
|
|
|
- .doubleValue());
|
|
|
|
|
|
+ List<ReportSubjectTeacher> result = reportSubjectTeacherService.findByQuery(query);
|
|
|
|
+ List<ReportSubjectTeacherDTO> list = new ArrayList<>();
|
|
|
|
+ for (ReportSubjectTeacher r : result) {
|
|
|
|
+ list.add(new ReportSubjectTeacherDTO(r));
|
|
}
|
|
}
|
|
ByteArrayOutputStream os = new ByteArrayOutputStream();
|
|
ByteArrayOutputStream os = new ByteArrayOutputStream();
|
|
- new ExportExcel(name, ReportSubjectTeacher.class).setDataList(list).write(os);
|
|
|
|
|
|
+ new ExportExcel(name, ReportSubjectTeacherDTO.class).setDataList(list).write(os);
|
|
os.flush();
|
|
os.flush();
|
|
byte[] value = os.toByteArray();
|
|
byte[] value = os.toByteArray();
|
|
String md5 = CodecUtils.toHexString(CodecUtils.md5(value));
|
|
String md5 = CodecUtils.toHexString(CodecUtils.md5(value));
|
|
@@ -359,21 +354,20 @@ public class ReportServiceImpl implements ReportService {
|
|
FormatType.XLSX);
|
|
FormatType.XLSX);
|
|
}
|
|
}
|
|
|
|
|
|
- private void uploadClass(int examId, String subjectCode, String subjectName, String name) throws IOException,
|
|
|
|
- Exception {
|
|
|
|
|
|
+ private void uploadClass(int examId, String subjectCode, String subjectName, String name)
|
|
|
|
+ throws IOException, Exception {
|
|
ReportSubjectQuery query = new ReportSubjectQuery();
|
|
ReportSubjectQuery query = new ReportSubjectQuery();
|
|
query.setExamId(examId);
|
|
query.setExamId(examId);
|
|
query.setSubjectCode(subjectCode);
|
|
query.setSubjectCode(subjectCode);
|
|
query.setPageNumber(1);
|
|
query.setPageNumber(1);
|
|
query.setPageSize(Integer.MAX_VALUE);
|
|
query.setPageSize(Integer.MAX_VALUE);
|
|
- List<ReportSubjectClass> list = reportSubjectClassService.findByQuery(query);
|
|
|
|
- for (ReportSubjectClass r : list) {
|
|
|
|
- r.setAvgScore(new BigDecimal(r.getAvgScore()).setScale(2, RoundingMode.HALF_UP).doubleValue());
|
|
|
|
- r.setExcellentRate(new BigDecimal(r.getExcellentRate()).setScale(2, RoundingMode.HALF_UP).doubleValue());
|
|
|
|
- r.setPassRate(new BigDecimal(r.getPassRate()).setScale(2, RoundingMode.HALF_UP).doubleValue());
|
|
|
|
|
|
+ List<ReportSubjectClass> result = reportSubjectClassService.findByQuery(query);
|
|
|
|
+ List<ReportSubjectClassDTO> list = new ArrayList<>();
|
|
|
|
+ for (ReportSubjectClass r : result) {
|
|
|
|
+ list.add(new ReportSubjectClassDTO(r));
|
|
}
|
|
}
|
|
ByteArrayOutputStream os = new ByteArrayOutputStream();
|
|
ByteArrayOutputStream os = new ByteArrayOutputStream();
|
|
- new ExportExcel(name, ReportSubjectClass.class).setDataList(list).write(os);
|
|
|
|
|
|
+ new ExportExcel(name, ReportSubjectClassDTO.class).setDataList(list).write(os);
|
|
os.flush();
|
|
os.flush();
|
|
byte[] value = os.toByteArray();
|
|
byte[] value = os.toByteArray();
|
|
String md5 = CodecUtils.toHexString(CodecUtils.md5(value));
|
|
String md5 = CodecUtils.toHexString(CodecUtils.md5(value));
|
|
@@ -381,21 +375,20 @@ public class ReportServiceImpl implements ReportService {
|
|
FormatType.XLSX);
|
|
FormatType.XLSX);
|
|
}
|
|
}
|
|
|
|
|
|
- private void uploadCollege(int examId, String subjectCode, String subjectName, String name) throws IOException,
|
|
|
|
- Exception {
|
|
|
|
|
|
+ private void uploadCollege(int examId, String subjectCode, String subjectName, String name)
|
|
|
|
+ throws IOException, Exception {
|
|
ReportSubjectQuery query = new ReportSubjectQuery();
|
|
ReportSubjectQuery query = new ReportSubjectQuery();
|
|
query.setExamId(examId);
|
|
query.setExamId(examId);
|
|
query.setSubjectCode(subjectCode);
|
|
query.setSubjectCode(subjectCode);
|
|
query.setPageNumber(1);
|
|
query.setPageNumber(1);
|
|
query.setPageSize(Integer.MAX_VALUE);
|
|
query.setPageSize(Integer.MAX_VALUE);
|
|
- List<ReportSubjectCollege> list = reportSubjectCollegeService.findByQuery(query);
|
|
|
|
- for (ReportSubjectCollege r : list) {
|
|
|
|
- r.setAvgScore(new BigDecimal(r.getAvgScore()).setScale(2, RoundingMode.HALF_UP).doubleValue());
|
|
|
|
- r.setExcellentRate(new BigDecimal(r.getExcellentRate()).setScale(2, RoundingMode.HALF_UP).doubleValue());
|
|
|
|
- r.setPassRate(new BigDecimal(r.getPassRate()).setScale(2, RoundingMode.HALF_UP).doubleValue());
|
|
|
|
|
|
+ List<ReportSubjectCollege> result = reportSubjectCollegeService.findByQuery(query);
|
|
|
|
+ List<ReportSubjectCollegeDTO> list = new ArrayList<>();
|
|
|
|
+ for (ReportSubjectCollege r : result) {
|
|
|
|
+ list.add(new ReportSubjectCollegeDTO(r));
|
|
}
|
|
}
|
|
ByteArrayOutputStream os = new ByteArrayOutputStream();
|
|
ByteArrayOutputStream os = new ByteArrayOutputStream();
|
|
- new ExportExcel(name, ReportSubjectCollege.class).setDataList(list).write(os);
|
|
|
|
|
|
+ new ExportExcel(name, ReportSubjectCollegeDTO.class).setDataList(list).write(os);
|
|
os.flush();
|
|
os.flush();
|
|
byte[] value = os.toByteArray();
|
|
byte[] value = os.toByteArray();
|
|
String md5 = CodecUtils.toHexString(CodecUtils.md5(value));
|
|
String md5 = CodecUtils.toHexString(CodecUtils.md5(value));
|
|
@@ -403,13 +396,13 @@ public class ReportServiceImpl implements ReportService {
|
|
FormatType.XLSX);
|
|
FormatType.XLSX);
|
|
}
|
|
}
|
|
|
|
|
|
- private void uploadRange(int examId, String subjectCode, String subjectName, String name) throws IOException,
|
|
|
|
- Exception {
|
|
|
|
|
|
+ private void uploadRange(int examId, String subjectCode, String subjectName, String name)
|
|
|
|
+ throws IOException, Exception {
|
|
List<ReportSubjectRangeDTO> list = new ArrayList<ReportSubjectRangeDTO>();
|
|
List<ReportSubjectRangeDTO> list = new ArrayList<ReportSubjectRangeDTO>();
|
|
ReportSubject subject = reportSubjectService.findOne(examId, subjectCode);
|
|
ReportSubject subject = reportSubjectService.findOne(examId, subjectCode);
|
|
if (subject != null) {
|
|
if (subject != null) {
|
|
- JSONArray array = getScoreRange(subject.getScoreRange(), subject.getTotalScore(),
|
|
|
|
- subject.getRealityCount(), 0.25);
|
|
|
|
|
|
+ JSONArray array = getScoreRange(subject.getScoreRange(), subject.getTotalScore(), subject.getRealityCount(),
|
|
|
|
+ 0.25);
|
|
for (int i = 0; i < array.size(); i++) {
|
|
for (int i = 0; i < array.size(); i++) {
|
|
JSONObject jsonObject = array.getJSONObject(i);
|
|
JSONObject jsonObject = array.getJSONObject(i);
|
|
Double score = jsonObject.getDouble("score");
|
|
Double score = jsonObject.getDouble("score");
|
|
@@ -457,20 +450,20 @@ public class ReportServiceImpl implements ReportService {
|
|
int currentCount = 0;
|
|
int currentCount = 0;
|
|
double rate = 0.25;
|
|
double rate = 0.25;
|
|
if (start < end) {
|
|
if (start < end) {
|
|
-// for (int i = start; i < end; i++) {
|
|
|
|
-// currentCount = jsonObject.getInt(String.valueOf(i));
|
|
|
|
-// sumCount = sumCount + currentCount;
|
|
|
|
-// }
|
|
|
|
|
|
+ // for (int i = start; i < end; i++) {
|
|
|
|
+ // currentCount = jsonObject.getInt(String.valueOf(i));
|
|
|
|
+ // sumCount = sumCount + currentCount;
|
|
|
|
+ // }
|
|
double length = (end - start) / rate;
|
|
double length = (end - start) / rate;
|
|
for (int i = 0; i < length; i++) {
|
|
for (int i = 0; i < length; i++) {
|
|
currentCount = jsonObject.getInt(String.valueOf(start + i * rate));
|
|
currentCount = jsonObject.getInt(String.valueOf(start + i * rate));
|
|
sumCount = sumCount + currentCount;
|
|
sumCount = sumCount + currentCount;
|
|
}
|
|
}
|
|
} else if (start > end) {
|
|
} else if (start > end) {
|
|
-// for (int i = end; i < start; i++) {
|
|
|
|
-// currentCount = jsonObject.getInt(String.valueOf(i));
|
|
|
|
-// sumCount = sumCount + currentCount;
|
|
|
|
-// }
|
|
|
|
|
|
+ // for (int i = end; i < start; i++) {
|
|
|
|
+ // currentCount = jsonObject.getInt(String.valueOf(i));
|
|
|
|
+ // sumCount = sumCount + currentCount;
|
|
|
|
+ // }
|
|
double length = (start - end) / rate;
|
|
double length = (start - end) / rate;
|
|
for (int i = 0; i < length; i++) {
|
|
for (int i = 0; i < length; i++) {
|
|
currentCount = jsonObject.getInt(String.valueOf(end + i * rate));
|
|
currentCount = jsonObject.getInt(String.valueOf(end + i * rate));
|