|
@@ -159,13 +159,13 @@ public class ReportController {
|
|
JSONObject value = new JSONObject();
|
|
JSONObject value = new JSONObject();
|
|
value.accumulate("name", "全体");
|
|
value.accumulate("name", "全体");
|
|
value.accumulate("segments",
|
|
value.accumulate("segments",
|
|
- getScoreRange6(subject.getScoreRange(), subject.getTotalScore(), 20, subject.getRealityCount()));
|
|
|
|
|
|
+ getScoreRange6(subject.getScoreRange(), subject.getTotalScore(), subject.getRealityCount()));
|
|
groups.add(value);
|
|
groups.add(value);
|
|
for (ReportSubjectClass c : list) {
|
|
for (ReportSubjectClass c : list) {
|
|
JSONObject classValue = new JSONObject();
|
|
JSONObject classValue = new JSONObject();
|
|
classValue.accumulate("name", c.getClassName());
|
|
classValue.accumulate("name", c.getClassName());
|
|
classValue.accumulate("segments",
|
|
classValue.accumulate("segments",
|
|
- getScoreRange6(c.getScoreRange(), subject.getTotalScore(), 20, c.getRealityCount()));
|
|
|
|
|
|
+ getScoreRange6(c.getScoreRange(), subject.getTotalScore(), c.getRealityCount()));
|
|
groups.add(classValue);
|
|
groups.add(classValue);
|
|
}
|
|
}
|
|
jsonObject.accumulate("groups", groups);
|
|
jsonObject.accumulate("groups", groups);
|
|
@@ -192,13 +192,13 @@ public class ReportController {
|
|
private String getRange10(ReportSubject subject, List<ReportSubjectClass> list) {
|
|
private String getRange10(ReportSubject subject, List<ReportSubjectClass> list) {
|
|
JSONObject result = new JSONObject();
|
|
JSONObject result = new JSONObject();
|
|
result.accumulate("total",
|
|
result.accumulate("total",
|
|
- getScoreRange(subject.getScoreRange(), subject.getTotalScore(), 10, subject.getRealityCount()));
|
|
|
|
|
|
+ getScoreRange10(subject.getScoreRange(), subject.getTotalScore(), subject.getRealityCount()));
|
|
JSONArray classes = new JSONArray();
|
|
JSONArray classes = new JSONArray();
|
|
for (ReportSubjectClass r : list) {
|
|
for (ReportSubjectClass r : list) {
|
|
JSONObject classValue = new JSONObject();
|
|
JSONObject classValue = new JSONObject();
|
|
classValue.accumulate("name", r.getClassName());
|
|
classValue.accumulate("name", r.getClassName());
|
|
classValue.accumulate("ranges",
|
|
classValue.accumulate("ranges",
|
|
- getScoreRange(r.getScoreRange(), subject.getTotalScore(), 10, r.getRealityCount()));
|
|
|
|
|
|
+ getScoreRange10(r.getScoreRange(), subject.getTotalScore(), r.getRealityCount()));
|
|
classes.add(classValue);
|
|
classes.add(classValue);
|
|
}
|
|
}
|
|
result.accumulate("classes", classes);
|
|
result.accumulate("classes", classes);
|
|
@@ -231,33 +231,71 @@ public class ReportController {
|
|
return result;
|
|
return result;
|
|
}
|
|
}
|
|
|
|
|
|
- private JSONArray getScoreRange6(String scoreRange, double totalScore, int range, Integer totalCount) {
|
|
|
|
|
|
+ private JSONArray getScoreRange10(String scoreRange, double totalScore, Integer totalCount) {
|
|
JSONArray result = new JSONArray();
|
|
JSONArray result = new JSONArray();
|
|
JSONObject jsonObject = JSONObject.fromObject(scoreRange);
|
|
JSONObject jsonObject = JSONObject.fromObject(scoreRange);
|
|
int rangeCount = 0;
|
|
int rangeCount = 0;
|
|
int sumCount = 0;
|
|
int sumCount = 0;
|
|
- int total = (int) totalScore;
|
|
|
|
- for (int i = 0; i <= total; i++) {
|
|
|
|
- if (i % range == 0) {
|
|
|
|
- if (i == 0) {
|
|
|
|
- rangeCount = jsonObject.getInt(String.valueOf(i));
|
|
|
|
- sumCount = rangeCount;
|
|
|
|
- } else {
|
|
|
|
- rangeCount = getSumCount(jsonObject, i - range + 1, i);
|
|
|
|
- sumCount = sumCount + rangeCount;
|
|
|
|
- }
|
|
|
|
- JSONObject value = new JSONObject();
|
|
|
|
- value.accumulate("score", i == 0 ? 0 : (i - range + 0.5) + "~" + i);
|
|
|
|
- value.accumulate("rangeCount", rangeCount);
|
|
|
|
- value.accumulate("rangeRate", rangeCount * 100.0 / totalCount);
|
|
|
|
- value.accumulate("sumCount", sumCount);
|
|
|
|
- value.accumulate("sumRate", sumCount * 100.0 / totalCount);
|
|
|
|
- result.add(value);
|
|
|
|
|
|
+ int range = 10;
|
|
|
|
+ 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;
|
|
|
|
+ JSONObject value = new JSONObject();
|
|
|
|
+ value.accumulate("score", i * range);
|
|
|
|
+ value.accumulate("rangeCount", rangeCount);
|
|
|
|
+ value.accumulate("rangeRate", rangeCount * 100.0 / totalCount);
|
|
|
|
+ value.accumulate("sumCount", sumCount);
|
|
|
|
+ value.accumulate("sumRate", sumCount * 100.0 / totalCount);
|
|
|
|
+ result.add(value);
|
|
|
|
+ }
|
|
|
|
+ return result;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private JSONArray getScoreRange6(String scoreRange, double totalScore, Integer totalCount) {
|
|
|
|
+ JSONArray result = new JSONArray();
|
|
|
|
+ JSONObject jsonObject = JSONObject.fromObject(scoreRange);
|
|
|
|
+ int rangeCount = jsonObject.getInt(String.valueOf(0));
|
|
|
|
+ int sumCount = rangeCount;
|
|
|
|
+ int range = (int) Math.floor(totalScore / 5);
|
|
|
|
+ int remainder = (int) Math.ceil(totalScore % 5);
|
|
|
|
+ int start = 0;
|
|
|
|
+ int end = 0;
|
|
|
|
+ result.add(getRangeJson(totalCount, rangeCount, sumCount, start, end));
|
|
|
|
+ for (int i = 1; i <= 5; i++) {
|
|
|
|
+ end = i * range + remainder;
|
|
|
|
+ rangeCount = getSumCount(jsonObject, start, end);
|
|
|
|
+ sumCount = sumCount + rangeCount;
|
|
|
|
+ result.add(getRangeJson(totalCount, rangeCount, sumCount, start, end));
|
|
|
|
+ start = end + 1;
|
|
}
|
|
}
|
|
return result;
|
|
return result;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ private JSONObject getRangeJson(Integer totalCount, int rangeCount, int sumCount, int start, int end) {
|
|
|
|
+ JSONObject value = new JSONObject();
|
|
|
|
+ if (start == 0 && end == 0) {
|
|
|
|
+ value.accumulate("score", 0);
|
|
|
|
+ } else if (start == 0 && end != 0) {
|
|
|
|
+ value.accumulate("score", start + "~" + end);
|
|
|
|
+ } else {
|
|
|
|
+ value.accumulate("score", (start - 0.5) + "~" + end);
|
|
|
|
+ }
|
|
|
|
+ value.accumulate("rangeCount", rangeCount);
|
|
|
|
+ value.accumulate("rangeRate", rangeCount * 100.0 / totalCount);
|
|
|
|
+ value.accumulate("sumCount", sumCount);
|
|
|
|
+ value.accumulate("sumRate", sumCount * 100.0 / totalCount);
|
|
|
|
+ return value;
|
|
|
|
+ }
|
|
|
|
+
|
|
private int getSumCount(JSONObject jsonObject, int start, int end) {
|
|
private int getSumCount(JSONObject jsonObject, int start, int end) {
|
|
int sumCount = 0;
|
|
int sumCount = 0;
|
|
int currentCount = 0;
|
|
int currentCount = 0;
|