|
@@ -1,15 +1,26 @@
|
|
package cn.com.qmth.stmms.admin.thread;
|
|
package cn.com.qmth.stmms.admin.thread;
|
|
|
|
|
|
|
|
+import java.io.ByteArrayInputStream;
|
|
|
|
+import java.io.IOException;
|
|
|
|
+import java.math.BigDecimal;
|
|
|
|
+import java.math.RoundingMode;
|
|
|
|
+import java.util.ArrayList;
|
|
import java.util.HashMap;
|
|
import java.util.HashMap;
|
|
import java.util.HashSet;
|
|
import java.util.HashSet;
|
|
import java.util.List;
|
|
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.lang.StringUtils;
|
|
import org.apache.commons.lang.StringUtils;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.LoggerFactory;
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
|
|
|
+import cn.com.qmth.stmms.admin.dto.ReportSubjectRangeDTO;
|
|
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;
|
|
@@ -18,12 +29,30 @@ import cn.com.qmth.stmms.biz.exam.service.ExamQuestionService;
|
|
import cn.com.qmth.stmms.biz.exam.service.ExamService;
|
|
import cn.com.qmth.stmms.biz.exam.service.ExamService;
|
|
import cn.com.qmth.stmms.biz.exam.service.ExamStudentService;
|
|
import cn.com.qmth.stmms.biz.exam.service.ExamStudentService;
|
|
import cn.com.qmth.stmms.biz.exam.service.ExamSubjectService;
|
|
import cn.com.qmth.stmms.biz.exam.service.ExamSubjectService;
|
|
|
|
+import cn.com.qmth.stmms.biz.file.enums.FormatType;
|
|
|
|
+import cn.com.qmth.stmms.biz.file.service.FileService;
|
|
import cn.com.qmth.stmms.biz.lock.LockService;
|
|
import cn.com.qmth.stmms.biz.lock.LockService;
|
|
|
|
+import cn.com.qmth.stmms.biz.report.model.ReportSubject;
|
|
|
|
+import cn.com.qmth.stmms.biz.report.model.ReportSubjectClass;
|
|
|
|
+import cn.com.qmth.stmms.biz.report.model.ReportSubjectCollege;
|
|
|
|
+import cn.com.qmth.stmms.biz.report.model.ReportSubjectGroup;
|
|
|
|
+import cn.com.qmth.stmms.biz.report.model.ReportSubjectQuestion;
|
|
|
|
+import cn.com.qmth.stmms.biz.report.model.ReportSubjectTeacher;
|
|
|
|
+import cn.com.qmth.stmms.biz.report.query.ReportSubjectQuery;
|
|
import cn.com.qmth.stmms.biz.report.service.ReportService;
|
|
import cn.com.qmth.stmms.biz.report.service.ReportService;
|
|
|
|
+import cn.com.qmth.stmms.biz.report.service.ReportSubjectClassService;
|
|
|
|
+import cn.com.qmth.stmms.biz.report.service.ReportSubjectCollegeService;
|
|
|
|
+import cn.com.qmth.stmms.biz.report.service.ReportSubjectGroupService;
|
|
|
|
+import cn.com.qmth.stmms.biz.report.service.ReportSubjectQuestionService;
|
|
|
|
+import cn.com.qmth.stmms.biz.report.service.ReportSubjectService;
|
|
|
|
+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.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 cn.com.qmth.stmms.common.utils.ExportExcel;
|
|
|
|
+
|
|
|
|
+import com.qmth.boot.tools.codec.CodecUtils;
|
|
|
|
|
|
public class ScoreReportThread implements Runnable {
|
|
public class ScoreReportThread implements Runnable {
|
|
|
|
|
|
@@ -51,13 +80,38 @@ public class ScoreReportThread implements Runnable {
|
|
|
|
|
|
private ExamService examService;
|
|
private ExamService examService;
|
|
|
|
|
|
|
|
+ private FileService fileService;
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ private ReportSubjectQuestionService reportSubjectQuestionService;
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ private ReportSubjectClassService reportSubjectClassService;
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ private ReportSubjectTeacherService reportSubjectTeacherService;
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ private ReportSubjectCollegeService reportSubjectCollegeService;
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ private ReportSubjectGroupService reportSubjectGroupService;
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ private ReportSubjectService reportSubjectService;
|
|
|
|
+
|
|
private ReportContext context;
|
|
private ReportContext context;
|
|
|
|
|
|
private boolean examLock;
|
|
private boolean examLock;
|
|
|
|
|
|
public ScoreReportThread(int examId, Set<String> subjectCodeSet, LockService lockService,
|
|
public ScoreReportThread(int examId, Set<String> subjectCodeSet, LockService lockService,
|
|
ExamStudentService studentService, ExamQuestionService questionService, ReportService reportService,
|
|
ExamStudentService studentService, ExamQuestionService questionService, ReportService reportService,
|
|
- ExamService examService, ExamSubjectService subjectService, boolean examLock) {
|
|
|
|
|
|
+ ExamService examService, ExamSubjectService subjectService, FileService fileService, boolean examLock,
|
|
|
|
+ ReportSubjectQuestionService reportSubjectQuestionService,
|
|
|
|
+ ReportSubjectClassService reportSubjectClassService,
|
|
|
|
+ ReportSubjectTeacherService reportSubjectTeacherService,
|
|
|
|
+ ReportSubjectCollegeService reportSubjectCollegeService,
|
|
|
|
+ ReportSubjectGroupService reportSubjectGroupService, ReportSubjectService reportSubjectService) {
|
|
this.examId = examId;
|
|
this.examId = examId;
|
|
this.subjectCodeSet = subjectCodeSet != null ? subjectCodeSet : new HashSet<>();
|
|
this.subjectCodeSet = subjectCodeSet != null ? subjectCodeSet : new HashSet<>();
|
|
this.lockService = lockService;
|
|
this.lockService = lockService;
|
|
@@ -66,7 +120,14 @@ public class ScoreReportThread implements Runnable {
|
|
this.reportService = reportService;
|
|
this.reportService = reportService;
|
|
this.examService = examService;
|
|
this.examService = examService;
|
|
this.subjectService = subjectService;
|
|
this.subjectService = subjectService;
|
|
|
|
+ this.fileService = fileService;
|
|
this.examLock = examLock;
|
|
this.examLock = examLock;
|
|
|
|
+ this.reportSubjectClassService = reportSubjectClassService;
|
|
|
|
+ this.reportSubjectCollegeService = reportSubjectCollegeService;
|
|
|
|
+ this.reportSubjectGroupService = reportSubjectGroupService;
|
|
|
|
+ this.reportSubjectQuestionService = reportSubjectQuestionService;
|
|
|
|
+ this.reportSubjectService = reportSubjectService;
|
|
|
|
+ this.reportSubjectTeacherService = reportSubjectTeacherService;
|
|
this.objectiveMap = new HashMap<>();
|
|
this.objectiveMap = new HashMap<>();
|
|
this.subjectiveMap = new HashMap<>();
|
|
this.subjectiveMap = new HashMap<>();
|
|
this.subjectMap = new HashMap<>();
|
|
this.subjectMap = new HashMap<>();
|
|
@@ -110,6 +171,8 @@ public class ScoreReportThread implements Runnable {
|
|
}
|
|
}
|
|
// 结束统计
|
|
// 结束统计
|
|
context.save();
|
|
context.save();
|
|
|
|
+ // 生成文件
|
|
|
|
+ reoprtExcel(examId, subjectCode);
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
log.error("report exception for examId=" + examId + ", subjectCode=" + subjectCode, e);
|
|
log.error("report exception for examId=" + examId + ", subjectCode=" + subjectCode, e);
|
|
} finally {
|
|
} finally {
|
|
@@ -161,4 +224,221 @@ public class ScoreReportThread implements Runnable {
|
|
return subject;
|
|
return subject;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ private void reoprtExcel(int examId, String subjectCode) throws IOException, Exception {
|
|
|
|
+ uploadRange(examId, subjectCode, findExamSubject(subjectCode).getName(), "课程分段统计");
|
|
|
|
+ uploadCollege(examId, subjectCode, findExamSubject(subjectCode).getName(), "学院分析");
|
|
|
|
+ uploadClass(examId, subjectCode, findExamSubject(subjectCode).getName(), "班级分析");
|
|
|
|
+ uploadTeacher(examId, subjectCode, findExamSubject(subjectCode).getName(), "任课老师统计");
|
|
|
|
+ uploadQuestion(examId, subjectCode, findExamSubject(subjectCode).getName(), true, "客观题分析");
|
|
|
|
+ uploadQuestion(examId, subjectCode, findExamSubject(subjectCode).getName(), false, "主观题分析");
|
|
|
|
+ uploadGroup(examId, subjectCode, findExamSubject(subjectCode).getName(), "分组统计分析");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private void uploadGroup(int examId, String subjectCode, String subjectName, String name) throws IOException,
|
|
|
|
+ Exception {
|
|
|
|
+ ReportSubjectQuery query = new ReportSubjectQuery();
|
|
|
|
+ query.setExamId(examId);
|
|
|
|
+ query.setSubjectCode(subjectCode);
|
|
|
|
+ query.setPageNumber(1);
|
|
|
|
+ query.setPageSize(Integer.MAX_VALUE);
|
|
|
|
+ List<ReportSubjectGroup> list = reportSubjectGroupService.findByQuery(query);
|
|
|
|
+ if (list.isEmpty()) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ 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());
|
|
|
|
+ }
|
|
|
|
+ if (list.isEmpty()) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ ByteArrayOutputStream os = new ByteArrayOutputStream();
|
|
|
|
+ new ExportExcel(name, ReportSubjectGroup.class).setDataList(list).write(os);
|
|
|
|
+ os.flush();
|
|
|
|
+ byte[] value = os.toByteArray();
|
|
|
|
+ String md5 = CodecUtils.toHexString(CodecUtils.md5(value));
|
|
|
|
+ fileService.uploadReport(new ByteArrayInputStream(value), md5, examId, subjectCode + "-" + subjectName, name,
|
|
|
|
+ FormatType.XLSX);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private void uploadQuestion(int examId, String subjectCode, String subjectName, boolean objective, String name)
|
|
|
|
+ throws IOException, Exception {
|
|
|
|
+ ReportSubjectQuery query = new ReportSubjectQuery();
|
|
|
|
+ query.setExamId(examId);
|
|
|
|
+ query.setSubjectCode(subjectCode);
|
|
|
|
+ query.setObjective(objective);
|
|
|
|
+ query.setPageNumber(1);
|
|
|
|
+ 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());
|
|
|
|
+ }
|
|
|
|
+ if (list.isEmpty()) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ ByteArrayOutputStream os = new ByteArrayOutputStream();
|
|
|
|
+ new ExportExcel(name, ReportSubjectQuestion.class).setDataList(list).write(os);
|
|
|
|
+ os.flush();
|
|
|
|
+ byte[] value = os.toByteArray();
|
|
|
|
+ String md5 = CodecUtils.toHexString(CodecUtils.md5(value));
|
|
|
|
+ fileService.uploadReport(new ByteArrayInputStream(value), md5, examId, subjectCode + "-" + subjectName, name,
|
|
|
|
+ FormatType.XLSX);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private void uploadTeacher(int examId, String subjectCode, String subjectName, String name) throws IOException,
|
|
|
|
+ Exception {
|
|
|
|
+ ReportSubjectQuery query = new ReportSubjectQuery();
|
|
|
|
+ query.setExamId(examId);
|
|
|
|
+ query.setSubjectCode(subjectCode);
|
|
|
|
+ query.setPageNumber(1);
|
|
|
|
+ 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());
|
|
|
|
+ }
|
|
|
|
+ if (list.isEmpty()) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ ByteArrayOutputStream os = new ByteArrayOutputStream();
|
|
|
|
+ new ExportExcel(name, ReportSubjectTeacher.class).setDataList(list).write(os);
|
|
|
|
+ os.flush();
|
|
|
|
+ byte[] value = os.toByteArray();
|
|
|
|
+ String md5 = CodecUtils.toHexString(CodecUtils.md5(value));
|
|
|
|
+ fileService.uploadReport(new ByteArrayInputStream(value), md5, examId, subjectCode + "-" + subjectName, name,
|
|
|
|
+ FormatType.XLSX);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private void uploadClass(int examId, String subjectCode, String subjectName, String name) throws IOException,
|
|
|
|
+ Exception {
|
|
|
|
+ ReportSubjectQuery query = new ReportSubjectQuery();
|
|
|
|
+ query.setExamId(examId);
|
|
|
|
+ query.setSubjectCode(subjectCode);
|
|
|
|
+ query.setPageNumber(1);
|
|
|
|
+ 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());
|
|
|
|
+ }
|
|
|
|
+ if (list.isEmpty()) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ ByteArrayOutputStream os = new ByteArrayOutputStream();
|
|
|
|
+ new ExportExcel(name, ReportSubjectClass.class).setDataList(list).write(os);
|
|
|
|
+ os.flush();
|
|
|
|
+ byte[] value = os.toByteArray();
|
|
|
|
+ String md5 = CodecUtils.toHexString(CodecUtils.md5(value));
|
|
|
|
+ fileService.uploadReport(new ByteArrayInputStream(value), md5, examId, subjectCode + "-" + subjectName, name,
|
|
|
|
+ FormatType.XLSX);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private void uploadCollege(int examId, String subjectCode, String subjectName, String name) throws IOException,
|
|
|
|
+ Exception {
|
|
|
|
+ ReportSubjectQuery query = new ReportSubjectQuery();
|
|
|
|
+ query.setExamId(examId);
|
|
|
|
+ query.setSubjectCode(subjectCode);
|
|
|
|
+ query.setPageNumber(1);
|
|
|
|
+ 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());
|
|
|
|
+ }
|
|
|
|
+ if (list.isEmpty()) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ ByteArrayOutputStream os = new ByteArrayOutputStream();
|
|
|
|
+ new ExportExcel(name, ReportSubjectCollege.class).setDataList(list).write(os);
|
|
|
|
+ os.flush();
|
|
|
|
+ byte[] value = os.toByteArray();
|
|
|
|
+ String md5 = CodecUtils.toHexString(CodecUtils.md5(value));
|
|
|
|
+ fileService.uploadReport(new ByteArrayInputStream(value), md5, examId, subjectCode + "-" + subjectName, name,
|
|
|
|
+ FormatType.XLSX);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private void uploadRange(int examId, String subjectCode, String subjectName, String name) throws IOException,
|
|
|
|
+ Exception {
|
|
|
|
+ List<ReportSubjectRangeDTO> list = new ArrayList<ReportSubjectRangeDTO>();
|
|
|
|
+ ReportSubject subject = reportSubjectService.findOne(examId, subjectCode);
|
|
|
|
+ JSONArray array = getScoreRange(subject.getScoreRange(), subject.getTotalScore(), subject.getRealityCount(), 10);
|
|
|
|
+ for (int i = 0; i < array.size(); i++) {
|
|
|
|
+ JSONObject jsonObject = array.getJSONObject(i);
|
|
|
|
+ String score = jsonObject.getInt("score") + "-";
|
|
|
|
+ Integer rangeCount = jsonObject.getInt("rangeCount");
|
|
|
|
+ Double rangeRate = jsonObject.getDouble("rangeRate");
|
|
|
|
+ list.add(new ReportSubjectRangeDTO(score, rangeCount, rangeRate));
|
|
|
|
+ }
|
|
|
|
+ if (list.isEmpty()) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ ByteArrayOutputStream os = new ByteArrayOutputStream();
|
|
|
|
+ new ExportExcel(name, ReportSubjectRangeDTO.class).setDataList(list).write(os);
|
|
|
|
+ os.flush();
|
|
|
|
+ byte[] value = os.toByteArray();
|
|
|
|
+ String md5 = CodecUtils.toHexString(CodecUtils.md5(value));
|
|
|
|
+ fileService.uploadReport(new ByteArrayInputStream(value), md5, examId, subjectCode + "-" + subjectName, name,
|
|
|
|
+ FormatType.XLSX);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private JSONArray getScoreRange(String scoreRange, double totalScore, Integer totalCount, int range) {
|
|
|
|
+ JSONArray result = new JSONArray();
|
|
|
|
+ JSONObject jsonObject = JSONObject.fromObject(scoreRange);
|
|
|
|
+ int rangeCount = 0;
|
|
|
|
+ int sumCount = 0;
|
|
|
|
+ int total = (int) Math.ceil(totalScore / range);
|
|
|
|
+ for (int i = total; i >= 0; i--) {
|
|
|
|
+ int start = i * range;
|
|
|
|
+ int end = (i - 1) * range + 1;
|
|
|
|
+ if (start > totalScore) {
|
|
|
|
+ start = (int) Math.ceil(totalScore);
|
|
|
|
+ }
|
|
|
|
+ if (end < 0) {
|
|
|
|
+ end = 0;
|
|
|
|
+ }
|
|
|
|
+ rangeCount = getSumCount(jsonObject, start, end);
|
|
|
|
+ sumCount = sumCount + rangeCount;
|
|
|
|
+ result.add(getRangeJson(totalCount, rangeCount, sumCount, i * range));
|
|
|
|
+ }
|
|
|
|
+ return result;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private int getSumCount(JSONObject jsonObject, int start, int end) {
|
|
|
|
+ int sumCount = 0;
|
|
|
|
+ int currentCount = 0;
|
|
|
|
+ if (start < end) {
|
|
|
|
+ for (int i = start; i <= end; i++) {
|
|
|
|
+ currentCount = jsonObject.getInt(String.valueOf(i));
|
|
|
|
+ sumCount = sumCount + currentCount;
|
|
|
|
+ }
|
|
|
|
+ } else if (start >= end) {
|
|
|
|
+ for (int i = end; i <= start; i++) {
|
|
|
|
+ currentCount = jsonObject.getInt(String.valueOf(i));
|
|
|
|
+ sumCount = sumCount + currentCount;
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ sumCount = jsonObject.getInt(String.valueOf(start));
|
|
|
|
+ }
|
|
|
|
+ return sumCount;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private JSONObject getRangeJson(Integer totalCount, int rangeCount, int sumCount, int score) {
|
|
|
|
+ JSONObject value = new JSONObject();
|
|
|
|
+ value.accumulate("score", score);
|
|
|
|
+ value.accumulate("rangeCount", rangeCount);
|
|
|
|
+ value.accumulate("rangeRate", rangeCount * 100.0 / totalCount);
|
|
|
|
+ value.accumulate("sumCount", sumCount);
|
|
|
|
+ value.accumulate("sumRate", sumCount * 100.0 / totalCount);
|
|
|
|
+ return value;
|
|
|
|
+ }
|
|
}
|
|
}
|