|
@@ -1,4 +1,4 @@
|
|
|
-package cn.com.qmth.stmms.api.controller;
|
|
|
+package cn.com.qmth.stmms.report;
|
|
|
|
|
|
import java.util.List;
|
|
|
|
|
@@ -10,9 +10,9 @@ import net.sf.json.JSONObject;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Controller;
|
|
|
import org.springframework.ui.Model;
|
|
|
+import org.springframework.web.bind.annotation.PathVariable;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestMethod;
|
|
|
-import org.springframework.web.bind.annotation.RequestParam;
|
|
|
|
|
|
import cn.com.qmth.stmms.biz.exam.model.Exam;
|
|
|
import cn.com.qmth.stmms.biz.exam.model.ExamSubject;
|
|
@@ -39,7 +39,7 @@ import cn.com.qmth.stmms.biz.school.model.School;
|
|
|
import cn.com.qmth.stmms.biz.school.service.SchoolService;
|
|
|
|
|
|
@Controller("reportApiController")
|
|
|
-@RequestMapping("/api/report")
|
|
|
+@RequestMapping("/report")
|
|
|
public class ReportController {
|
|
|
|
|
|
@Autowired
|
|
@@ -77,16 +77,30 @@ public class ReportController {
|
|
|
|
|
|
public static final String ANSWER_SPLIT = ",";
|
|
|
|
|
|
- @RequestMapping(value = "/teachAndResearch", method = RequestMethod.GET)
|
|
|
- public String getReport(Model model, HttpServletRequest request, @RequestParam Integer examId,
|
|
|
- @RequestParam String subjectCode, @RequestParam(required = false) String paperType) {
|
|
|
+ @RequestMapping(value = "/teachAndResearch/{examId}/{subjectCode}", method = RequestMethod.GET)
|
|
|
+ public String getSubject(Model model, HttpServletRequest request, @PathVariable Integer examId,
|
|
|
+ @PathVariable String subjectCode) {
|
|
|
+ JSONObject result = getJson(examId, subjectCode, null);
|
|
|
+ model.addAttribute("data", result);
|
|
|
+ return "modules/report/pdf";
|
|
|
+ }
|
|
|
+
|
|
|
+ @RequestMapping(value = "/teachAndResearch/{examId}/{subjectCode}/{paperType}", method = RequestMethod.GET)
|
|
|
+ public String getReport(Model model, HttpServletRequest request, @PathVariable Integer examId,
|
|
|
+ @PathVariable String subjectCode, @PathVariable String paperType) {
|
|
|
+ JSONObject result = getJson(examId, subjectCode, paperType);
|
|
|
+ model.addAttribute("data", result);
|
|
|
+ return "modules/report/pdf";
|
|
|
+ }
|
|
|
+
|
|
|
+ private JSONObject getJson(Integer examId, String subjectCode, String paperType) {
|
|
|
Exam exam = examService.findById(examId);
|
|
|
School school = schoolService.findById(exam.getSchoolId());
|
|
|
ExamSubject subject = subjectService.find(examId, subjectCode);
|
|
|
JSONObject result = new JSONObject();
|
|
|
result.accumulate("examName", exam.getName());
|
|
|
result.accumulate("schoolName", school.getName());
|
|
|
- result.accumulate("subjectName", subject.getName());
|
|
|
+ result.accumulate("subjectName", paperType == null ? subject.getName() : subject.getName() + "_" + paperType);
|
|
|
ReportSubjectQuery query = new ReportSubjectQuery();
|
|
|
query.setExamId(examId);
|
|
|
query.setSubjectCode(subjectCode);
|
|
@@ -110,8 +124,7 @@ public class ReportController {
|
|
|
result.accumulate("range_10_totalScore", getRange10(reportSubject, subjectClasses));
|
|
|
result.accumulate("range_1_totalScore", getRange1(reportSubject, subjectClasses));
|
|
|
result.accumulate("range_segment_6", getRange6(reportSubject, subjectClasses));
|
|
|
- model.addAttribute("data", result);
|
|
|
- return "modules/report/pdf";
|
|
|
+ return result;
|
|
|
}
|
|
|
|
|
|
private String getPaperJson(ReportSubject r) {
|
|
@@ -137,15 +150,17 @@ public class ReportController {
|
|
|
JSONArray groups = new JSONArray();
|
|
|
JSONObject value = new JSONObject();
|
|
|
value.accumulate("name", "全体");
|
|
|
- value.accumulate("segments", getScoreRange(subject.getScoreRange(), subject.getTotalScore(), 20, subject.getRealityCount()));
|
|
|
+ value.accumulate("segments",
|
|
|
+ getScoreRange6(subject.getScoreRange(), subject.getTotalScore(), 20, subject.getRealityCount()));
|
|
|
groups.add(value);
|
|
|
for (ReportSubjectClass c : list) {
|
|
|
JSONObject classValue = new JSONObject();
|
|
|
classValue.accumulate("name", c.getClassName());
|
|
|
- classValue.accumulate("segments", getScoreRange(c.getScoreRange(), subject.getTotalScore(), 20, c.getRealityCount()));
|
|
|
+ classValue.accumulate("segments",
|
|
|
+ getScoreRange6(c.getScoreRange(), subject.getTotalScore(), 20, c.getRealityCount()));
|
|
|
groups.add(classValue);
|
|
|
}
|
|
|
- jsonObject.accumulate("groups",groups );
|
|
|
+ jsonObject.accumulate("groups", groups);
|
|
|
result.add(jsonObject);
|
|
|
return result.toString();
|
|
|
}
|
|
@@ -207,6 +222,32 @@ public class ReportController {
|
|
|
}
|
|
|
return result;
|
|
|
}
|
|
|
+
|
|
|
+ private JSONArray getScoreRange6(String scoreRange, double totalScore, int range, Integer totalCount) {
|
|
|
+ JSONArray result = new JSONArray();
|
|
|
+ JSONObject jsonObject = JSONObject.fromObject(scoreRange);
|
|
|
+ int rangeCount = 0;
|
|
|
+ int sumCount = 0;
|
|
|
+ int total = (int) totalScore;
|
|
|
+ for (int i = 0; i <= total; i++) {
|
|
|
+ rangeCount = jsonObject.getInt(String.valueOf(i));
|
|
|
+ if (i == 0) {
|
|
|
+ sumCount = rangeCount;
|
|
|
+ } else {
|
|
|
+ sumCount = sumCount + rangeCount;
|
|
|
+ }
|
|
|
+ if (i % range == 0) {
|
|
|
+ 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);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
|
|
|
private String getRangeLevel(ReportSubjectQuery query, ReportSubject reportSubject, List<ReportSubjectClass> classes) {
|
|
|
JSONArray array = new JSONArray();
|