|
@@ -0,0 +1,374 @@
|
|
|
+package cn.com.qmth.stmms.api.controller;
|
|
|
+
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
|
+
|
|
|
+import net.sf.json.JSONArray;
|
|
|
+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.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;
|
|
|
+import cn.com.qmth.stmms.biz.exam.service.ExamService;
|
|
|
+import cn.com.qmth.stmms.biz.exam.service.ExamSubjectService;
|
|
|
+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.ReportSubjectClassGroup;
|
|
|
+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.model.ReportSubjectTeacherClass;
|
|
|
+import cn.com.qmth.stmms.biz.report.query.ReportSubjectQuery;
|
|
|
+import cn.com.qmth.stmms.biz.report.service.ReportSubjectClassGroupService;
|
|
|
+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.ReportSubjectTeacherClassService;
|
|
|
+import cn.com.qmth.stmms.biz.report.service.ReportSubjectTeacherService;
|
|
|
+import cn.com.qmth.stmms.biz.school.model.School;
|
|
|
+import cn.com.qmth.stmms.biz.school.service.SchoolService;
|
|
|
+
|
|
|
+@Controller("reportApiController")
|
|
|
+@RequestMapping("/api/report")
|
|
|
+public class ReportController {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ExamService examService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private SchoolService schoolService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ExamSubjectService subjectService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ReportSubjectQuestionService questionService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ReportSubjectClassService classService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ReportSubjectTeacherService teacherService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ReportSubjectCollegeService collegeService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ReportSubjectGroupService groupService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ReportSubjectTeacherClassService teacherClassService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ReportSubjectClassGroupService classGroupService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ReportSubjectService reportSubjectService;
|
|
|
+
|
|
|
+ @RequestMapping(value = "/teachAndResearch", method = RequestMethod.GET)
|
|
|
+ public String getReport(Model model, HttpServletRequest request, @RequestParam Integer examId,
|
|
|
+ @RequestParam String subjectCode, @RequestParam(required = false) 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());
|
|
|
+ ReportSubjectQuery query = new ReportSubjectQuery();
|
|
|
+ query.setExamId(examId);
|
|
|
+ query.setSubjectCode(subjectCode);
|
|
|
+ query.setPaperType(paperType);
|
|
|
+ query.setPageSize(Integer.MAX_VALUE);
|
|
|
+ result.accumulate("basic_question_objective", getQuestionJson(query, true));
|
|
|
+ result.accumulate("basic_question_subjective", getQuestionJson(query, true));
|
|
|
+ result.accumulate("basic_class", getClassJson(query));
|
|
|
+ result.accumulate("basic_teacher", getTeacerJson(query));
|
|
|
+ result.accumulate("basic_college", getCollegeJson(query));
|
|
|
+ result.accumulate("basic_main_question", getGroupJson(query));
|
|
|
+ result.accumulate("basic_question_option", getOptionJson(query));
|
|
|
+ result.accumulate("discrimination_level", getDiscrimination(query));
|
|
|
+ result.accumulate("difficulty_level", getDifficulty(query));
|
|
|
+ result.accumulate("range_level", getRangeLevel(query));
|
|
|
+// result.accumulate("range_10_totalScore", getRange10(query));
|
|
|
+ result.accumulate("range_1_totalScore", getRange1(query));
|
|
|
+// result.accumulate("range_segment_6", getRange6(query));
|
|
|
+ model.addAttribute("data", result);
|
|
|
+ return "modules/report/pdf";
|
|
|
+ }
|
|
|
+
|
|
|
+// private String getRange6(ReportSubjectQuery query) {
|
|
|
+// // TODO Auto-generated method stub
|
|
|
+// }
|
|
|
+
|
|
|
+ private String getRange1(ReportSubjectQuery query) {
|
|
|
+ JSONObject result = new JSONObject();
|
|
|
+ ReportSubject reportSubject = reportSubjectService.findOne(query.getExamId(), query.getSubjectCode());
|
|
|
+ JSONArray array = new JSONArray();
|
|
|
+// result.accumulate("total", getScoreRange(array,reportSubject.getScoreRange(),100,1));
|
|
|
+ JSONArray classes = new JSONArray();
|
|
|
+ List<ReportSubjectClass> list = classService.findByQuery(query);
|
|
|
+ for (ReportSubjectClass reportSubjectClass : list) {
|
|
|
+
|
|
|
+ }
|
|
|
+ result.accumulate("classes", classes);
|
|
|
+ return result.toString();
|
|
|
+ }
|
|
|
+
|
|
|
+// private JSONArray getScoreRange(JSONArray array, String scoreRange, int totalScore, int range) {
|
|
|
+// JSONObject value = new JSONObject();
|
|
|
+// value.accumulate(key, value);
|
|
|
+// array.add(value);
|
|
|
+// return array;
|
|
|
+// }
|
|
|
+
|
|
|
+// private String getRange10(ReportSubjectQuery query) {
|
|
|
+// // TODO Auto-generated method stub
|
|
|
+// }
|
|
|
+
|
|
|
+ private String getRangeLevel(ReportSubjectQuery query) {
|
|
|
+ JSONArray array = new JSONArray();
|
|
|
+ ReportSubject reportSubject = reportSubjectService.findOne(query.getExamId(), query.getSubjectCode());
|
|
|
+ JSONObject value = JSONObject.fromObject(reportSubject.getRangeLevel());
|
|
|
+ value.accumulate("name", "全部");
|
|
|
+ value.accumulate("totalCount", reportSubject.getRealityCount());
|
|
|
+ array.add(value);
|
|
|
+ List<ReportSubjectClass> classes = classService.findByQuery(query);
|
|
|
+ for (ReportSubjectClass reportSubjectClass : classes) {
|
|
|
+ JSONObject classValue = JSONObject.fromObject(reportSubjectClass.getRangeLevel());
|
|
|
+ classValue.accumulate("name", reportSubjectClass.getClassName());
|
|
|
+// value.accumulate("totalCount", reportSubjectClass.getRealityCount());
|
|
|
+ array.add(value);
|
|
|
+ }
|
|
|
+ return array.toString();
|
|
|
+ }
|
|
|
+
|
|
|
+ private String getDifficulty(ReportSubjectQuery query) {
|
|
|
+ JSONArray array = new JSONArray();
|
|
|
+ // 全部
|
|
|
+ ReportSubject reportSubject = reportSubjectService.findOne(query.getExamId(), query.getSubjectCode());
|
|
|
+ JSONObject value = new JSONObject();
|
|
|
+ value.accumulate("name", "全部");
|
|
|
+ JSONArray groups = new JSONArray();
|
|
|
+ List<ReportSubjectGroup> list = groupService.findByQuery(query);
|
|
|
+ for (ReportSubjectGroup r : list) {
|
|
|
+ JSONObject jsonObject = new JSONObject();
|
|
|
+ jsonObject.accumulate("name", r.getGroupName());
|
|
|
+ jsonObject.accumulate("questionCount", r.getQuestionCount());
|
|
|
+ jsonObject.accumulate("fullScore", r.getTotalScore());
|
|
|
+ jsonObject.accumulate("difficulty", r.getDifficulty());
|
|
|
+ jsonObject.accumulate("levels", r.getDifficulityLevel());
|
|
|
+ groups.add(jsonObject);
|
|
|
+ }
|
|
|
+ value.accumulate("groups", groups);
|
|
|
+ array.add(value);
|
|
|
+ // 班级
|
|
|
+ List<ReportSubjectClass> classes = classService.findByQuery(query);
|
|
|
+ for (ReportSubjectClass reportSubjectClass : classes) {
|
|
|
+ JSONObject classValue = new JSONObject();
|
|
|
+ value.accumulate("name", reportSubjectClass.getClassName());
|
|
|
+ JSONArray classGroups = new JSONArray();
|
|
|
+ query.setClassName(reportSubjectClass.getClassName());
|
|
|
+ List<ReportSubjectClassGroup> classGroupsList = classGroupService.findByQuery(query);
|
|
|
+ for (ReportSubjectClassGroup r : classGroupsList) {
|
|
|
+ JSONObject jsonObject = new JSONObject();
|
|
|
+ jsonObject.accumulate("name", r.getGroupName());
|
|
|
+ jsonObject.accumulate("questionCount", r.getQuestionCount());
|
|
|
+ jsonObject.accumulate("fullScore", r.getTotalScore());
|
|
|
+// jsonObject.accumulate("difficulty", r.getDifficulty());
|
|
|
+ jsonObject.accumulate("levels", r.getDifficulityLevel());
|
|
|
+ groups.add(jsonObject);
|
|
|
+ }
|
|
|
+ value.accumulate("groups", classGroups);
|
|
|
+ array.add(classValue);
|
|
|
+ }
|
|
|
+ return array.toString();
|
|
|
+ }
|
|
|
+
|
|
|
+ private String getDiscrimination(ReportSubjectQuery query) {
|
|
|
+ JSONArray array = new JSONArray();
|
|
|
+ // 全部
|
|
|
+ ReportSubject reportSubject = reportSubjectService.findOne(query.getExamId(), query.getSubjectCode());
|
|
|
+ JSONObject value = new JSONObject();
|
|
|
+ value.accumulate("name", "全部");
|
|
|
+ JSONArray groups = new JSONArray();
|
|
|
+ List<ReportSubjectGroup> list = groupService.findByQuery(query);
|
|
|
+ for (ReportSubjectGroup r : list) {
|
|
|
+ JSONObject jsonObject = new JSONObject();
|
|
|
+ jsonObject.accumulate("name", r.getGroupName());
|
|
|
+ jsonObject.accumulate("questionCount", r.getQuestionCount());
|
|
|
+ jsonObject.accumulate("fullScore", r.getTotalScore());
|
|
|
+ jsonObject.accumulate("coefficient", r.getCoefficient());
|
|
|
+ jsonObject.accumulate("levels", r.getDiscriminationLevel());
|
|
|
+ groups.add(jsonObject);
|
|
|
+ }
|
|
|
+ value.accumulate("groups", groups);
|
|
|
+ array.add(value);
|
|
|
+ // 班级
|
|
|
+ List<ReportSubjectClass> classes = classService.findByQuery(query);
|
|
|
+ for (ReportSubjectClass reportSubjectClass : classes) {
|
|
|
+ JSONObject classValue = new JSONObject();
|
|
|
+ value.accumulate("name", reportSubjectClass.getClassName());
|
|
|
+ JSONArray classGroups = new JSONArray();
|
|
|
+ query.setClassName(reportSubjectClass.getClassName());
|
|
|
+ List<ReportSubjectClassGroup> classGroupsList = classGroupService.findByQuery(query);
|
|
|
+ for (ReportSubjectClassGroup r : classGroupsList) {
|
|
|
+ JSONObject jsonObject = new JSONObject();
|
|
|
+ jsonObject.accumulate("name", r.getGroupName());
|
|
|
+ jsonObject.accumulate("questionCount", r.getQuestionCount());
|
|
|
+ jsonObject.accumulate("fullScore", r.getTotalScore());
|
|
|
+// jsonObject.accumulate("coefficient", r.getCoefficient());
|
|
|
+ jsonObject.accumulate("levels", r.getDiscriminationLevel());
|
|
|
+ groups.add(jsonObject);
|
|
|
+ }
|
|
|
+ value.accumulate("groups", classGroups);
|
|
|
+ array.add(classValue);
|
|
|
+ }
|
|
|
+ return array.toString();
|
|
|
+ }
|
|
|
+
|
|
|
+ private String getOptionJson(ReportSubjectQuery query) {
|
|
|
+ JSONObject value = new JSONObject();
|
|
|
+ ReportSubject reportSubject = reportSubjectService.findOne(query.getExamId(), query.getSubjectCode());
|
|
|
+ value.accumulate("options", reportSubject.getOptions());
|
|
|
+ JSONArray array = new JSONArray();
|
|
|
+ query.setObjective(true);
|
|
|
+ List<ReportSubjectQuestion> list = questionService.findByQuery(query);
|
|
|
+ for (ReportSubjectQuestion r : list) {
|
|
|
+ JSONObject jsonObject = new JSONObject();
|
|
|
+ jsonObject.accumulate("number", r.getMainNumber()+"-"+r.getSubNumber());
|
|
|
+ jsonObject.accumulate("totalCount", r.getRealityCount());
|
|
|
+// jsonObject.accumulate("correctCount", r.getf);
|
|
|
+ jsonObject.accumulate("difficulty", r.getDifficulty());
|
|
|
+ jsonObject.accumulate("discrimination", r.getDiscrimination());
|
|
|
+// jsonObject.accumulate("answer", r.get);
|
|
|
+ jsonObject.accumulate("options", r.getOptions());
|
|
|
+ array.add(jsonObject);
|
|
|
+ }
|
|
|
+ value.accumulate("questions", array);
|
|
|
+ return value.toString();
|
|
|
+ }
|
|
|
+
|
|
|
+ private String getGroupJson(ReportSubjectQuery query) {
|
|
|
+ JSONArray array = new JSONArray();
|
|
|
+ List<ReportSubjectGroup> list = groupService.findByQuery(query);
|
|
|
+ for (ReportSubjectGroup r : list) {
|
|
|
+ JSONObject jsonObject = new JSONObject();
|
|
|
+ jsonObject.accumulate("name", r.getGroupName());
|
|
|
+ jsonObject.accumulate("difficulty", r.getDifficulty());
|
|
|
+ jsonObject.accumulate("objective", r.getObjective());
|
|
|
+ array.add(jsonObject);
|
|
|
+ }
|
|
|
+ return array.toString();
|
|
|
+ }
|
|
|
+
|
|
|
+ private String getCollegeJson(ReportSubjectQuery query) {
|
|
|
+ JSONArray array = new JSONArray();
|
|
|
+ List<ReportSubjectCollege> list = collegeService.findByQuery(query);
|
|
|
+ for (ReportSubjectCollege r : list) {
|
|
|
+ JSONObject jsonObject = new JSONObject();
|
|
|
+ jsonObject.accumulate("name", r.getCollegeName());
|
|
|
+ jsonObject.accumulate("maxScore", r.getMaxScore());
|
|
|
+ jsonObject.accumulate("minScore", r.getMinScore());
|
|
|
+ jsonObject.accumulate("avgScore", r.getAvgScore());
|
|
|
+ jsonObject.accumulate("excellentCount", r.getExcellentCount());
|
|
|
+ jsonObject.accumulate("excellentRate", r.getExcellentRate());
|
|
|
+ jsonObject.accumulate("passCount", r.getPassCount());
|
|
|
+ jsonObject.accumulate("passRate", r.getPassRate());
|
|
|
+ array.add(jsonObject);
|
|
|
+ }
|
|
|
+ return array.toString();
|
|
|
+ }
|
|
|
+
|
|
|
+ private String getTeacerJson(ReportSubjectQuery query) {
|
|
|
+ JSONArray array = new JSONArray();
|
|
|
+ List<ReportSubjectTeacher> list = teacherService.findByQuery(query);
|
|
|
+ for (ReportSubjectTeacher r : list) {
|
|
|
+ JSONObject jsonObject = new JSONObject();
|
|
|
+ jsonObject.accumulate("name", r.getTeacherName());
|
|
|
+ jsonObject.accumulate("maxScore", r.getMaxScore());
|
|
|
+ jsonObject.accumulate("minScore", r.getMinScore());
|
|
|
+ jsonObject.accumulate("avgScore", r.getAvgScore());
|
|
|
+ jsonObject.accumulate("excellentCount", r.getExcellentCount());
|
|
|
+ jsonObject.accumulate("excellentRate", r.getExcellentRate());
|
|
|
+ jsonObject.accumulate("passCount", r.getPassCount());
|
|
|
+ jsonObject.accumulate("passRate", r.getPassRate());
|
|
|
+ jsonObject.accumulate("relativeAvgScore", r.getRelativeAvgScore());
|
|
|
+ JSONArray classes = new JSONArray();
|
|
|
+ query.setTeacherName(r.getTeacherName());
|
|
|
+ List<ReportSubjectTeacherClass> teacherClasses = teacherClassService.findByQuery(query);
|
|
|
+ for (ReportSubjectTeacherClass teacherClass : teacherClasses) {
|
|
|
+ JSONObject value = new JSONObject();
|
|
|
+ value.accumulate("name", teacherClass.getTeacherName());
|
|
|
+ value.accumulate("maxScore", teacherClass.getMaxScore());
|
|
|
+ value.accumulate("minScore", teacherClass.getMinScore());
|
|
|
+ value.accumulate("avgScore", teacherClass.getAvgScore());
|
|
|
+ value.accumulate("excellentCount", teacherClass.getExcellentCount());
|
|
|
+ value.accumulate("excellentRate", teacherClass.getExcellentRate());
|
|
|
+ value.accumulate("passCount", teacherClass.getPassCount());
|
|
|
+ value.accumulate("passRate", teacherClass.getPassRate());
|
|
|
+ value.accumulate("relativeAvgScore", teacherClass.getRelativeAvgScore());
|
|
|
+ classes.add(value);
|
|
|
+ }
|
|
|
+ jsonObject.accumulate("classes", classes);
|
|
|
+ array.add(jsonObject);
|
|
|
+ }
|
|
|
+ return array.toString();
|
|
|
+ }
|
|
|
+
|
|
|
+ private String getClassJson(ReportSubjectQuery query) {
|
|
|
+ JSONArray array = new JSONArray();
|
|
|
+ List<ReportSubjectClass> list = classService.findByQuery(query);
|
|
|
+ for (ReportSubjectClass r : list) {
|
|
|
+ JSONObject jsonObject = new JSONObject();
|
|
|
+ jsonObject.accumulate("name", r.getClassName());
|
|
|
+ jsonObject.accumulate("maxScore", r.getMaxScore());
|
|
|
+ jsonObject.accumulate("minScore", r.getMinScore());
|
|
|
+ jsonObject.accumulate("avgScore", r.getAvgScore());
|
|
|
+ jsonObject.accumulate("stdevScore", r.getStdev());
|
|
|
+ jsonObject.accumulate("excellentCount", r.getExcellentCount());
|
|
|
+ jsonObject.accumulate("excellentRate", r.getExcellentRate());
|
|
|
+ jsonObject.accumulate("passCount", r.getPassCount());
|
|
|
+ jsonObject.accumulate("passRate", r.getPassRate());
|
|
|
+ array.add(jsonObject);
|
|
|
+ }
|
|
|
+ return array.toString();
|
|
|
+ }
|
|
|
+
|
|
|
+ private String getQuestionJson(ReportSubjectQuery query, boolean isObjective) {
|
|
|
+ query.setObjective(isObjective);
|
|
|
+ JSONArray array = new JSONArray();
|
|
|
+ List<ReportSubjectQuestion> list = questionService.findByQuery(query);
|
|
|
+ for (ReportSubjectQuestion r : list) {
|
|
|
+ JSONObject jsonObject = new JSONObject();
|
|
|
+ jsonObject.accumulate("name", r.getQuestionName());
|
|
|
+ jsonObject.accumulate("number", r.getMainNumber() + "-" + r.getSubNumber());
|
|
|
+ jsonObject.accumulate("fullScore", r.getTotalScore());
|
|
|
+ jsonObject.accumulate("maxScore", r.getMaxScore());
|
|
|
+ jsonObject.accumulate("minScore", r.getMinScore());
|
|
|
+ jsonObject.accumulate("avgScore", r.getAvgScore());
|
|
|
+ jsonObject.accumulate("stdevScore", r.getStdev());
|
|
|
+ jsonObject.accumulate("coefficient", r.getCoefficient());
|
|
|
+ jsonObject.accumulate("difficulty", r.getDifficulty());
|
|
|
+ jsonObject.accumulate("discrimination", r.getDiscrimination());
|
|
|
+ jsonObject.accumulate("totalCount", r.getRealityCount());
|
|
|
+ jsonObject.accumulate("zeroCount", r.getZeroCount());
|
|
|
+ jsonObject.accumulate("fullCount", r.getScoreRate());
|
|
|
+ jsonObject.accumulate("fullRate", r.getFullScoreRate());
|
|
|
+ jsonObject.accumulate("scoreRate", r.getScoreRate());
|
|
|
+ array.add(jsonObject);
|
|
|
+ }
|
|
|
+ return array.toString();
|
|
|
+ }
|
|
|
+
|
|
|
+}
|