LearnStudentController.java
8.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
package com.jevon.controller;
import com.jevon.enums.DifficultEnums;
import com.jevon.enums.DimensionalEnums;
import com.jevon.model.Analyse;
import com.jevon.model.AnalyseDimensional;
import com.jevon.model.Dimensional;
import com.jevon.model.Student;
import com.jevon.service.*;
import com.jevon.vo.req.StudentReqVo;
import com.jevon.vo.school.Form6;
import com.jevon.vo.student.Form1;
import com.jevon.vo.student.Form2;
import com.jevon.vo.student.Form3;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @author chen
* @version 1.0
* @date 2019/11/1 0001 10:38
*/
@RestController
@RequestMapping(value = "/getStudent")
@Api(value = "学生报告")
public class LearnStudentController {
@Autowired
AnalyseService analyseService;
@Autowired
DimensionalService dimensionalService;
@Autowired
AnalyseDimensionalService analyseDimensionalService;
@Autowired
AnalyseDetailService analyseDetailService;
@Autowired
StudentDetailService studentDetailService;
@Autowired
StudentService studentService;
@Autowired
LeagueService leagueService;
@Autowired
ChapterService chapterService;
@ApiOperation("getForm1")
@RequestMapping(value = "getForm1", method = RequestMethod.POST)
public Form1 getStudent1(@RequestBody StudentReqVo studentReqVo){
Form1 form1 = new Form1();
Analyse analyse = analyseService.selectById(studentReqVo.getAnalyseId());
Student student = studentService.selectStudent(analyse.getId(),studentReqVo.getSchoolName(),studentReqVo.getStudentNumber());
List<Student> schoolStudent = studentService.selectByClassName(analyse.getId(),studentReqVo.getSchoolName(),null);
List<Student> classStudent = studentService.selectByClassName(analyse.getId(),studentReqVo.getSchoolName(),student.getClassName());
Double highestScore = studentService.selectClassMaxScore(analyse.getId(),student.getSchoolName(),student.getClassName());
int schoolRank = 0 , classRank = 0 ;
for (int i = 0; i < schoolStudent.size() ; i++) {
if(schoolStudent.get(i).getStudentNumber().equals(student.getStudentNumber())){
schoolRank = i+1 ;
}
}
for (int i = 0; i < classStudent.size() ; i++) {
if(classStudent.get(i).getStudentNumber().equals(student.getStudentNumber())){
classRank = i+1 ;
}
}
Double rank = new Double(classStudent.size()-classRank) / new Double(classStudent.size()) ;
form1.setClassName(student.getClassName());
form1.setMaxScore(highestScore);
form1.setScore(student.getScore());
form1.setRank(rank);
form1.setClassRank(classRank);
form1.setSchoolRank(schoolRank);
return form1;
}
@ApiOperation("getForm2")
@RequestMapping(value = "getForm2", method = RequestMethod.POST)
public Form2 getStudent2(@RequestBody StudentReqVo studentReqVo){
Form2 form2 = new Form2();
Analyse analyse = analyseService.selectById(studentReqVo.getAnalyseId());
Student student = studentService.selectStudent(analyse.getId(),studentReqVo.getSchoolName(),studentReqVo.getStudentNumber());
List<Student> classStudent = studentService.selectByClassName(analyse.getId(),studentReqVo.getSchoolName(),student.getClassName());
Map<String , List<Double>> typeMap = new HashMap<>();
List<String> questionTypes = analyseDetailService.selectQuestionType(analyse.getId());
for(String questionType : questionTypes){
List<Double> list = new ArrayList<>();
Double maxScore = analyseDetailService.selectSumType(analyse.getId(),questionType);
List<String> numberList = analyseDetailService.selectQuestionNumberByType(analyse.getId(),questionType);
Double score = studentDetailService.selectStudentSumScore(analyse.getId(),student.getSchoolName(),student.getStudentNumber(),numberList);
Double highestScore = new Double(0);
for(Student temp : classStudent){
Double tempScore = studentDetailService.selectStudentSumScore(analyse.getId(),temp.getSchoolName(),temp.getStudentNumber(),numberList);
if(tempScore > highestScore){
highestScore = tempScore ;
}
}
list.add(maxScore);
list.add(highestScore);
list.add(score);
typeMap.put(questionType,list);
}
Map<String , List<Double>> difficultMap = new HashMap<>();
for(DifficultEnums difficultEnum : DifficultEnums.values()){
List<Double> list = new ArrayList<>();
Double maxScore = analyseDetailService.selectDifficult(analyse.getId(),difficultEnum.getDifficultType());
List<String> numberList = analyseDetailService.selectQuestionNumberByDifficult(analyse.getId(),difficultEnum.getDifficultType());
Double score = studentDetailService.selectStudentSumScore(analyse.getId(),student.getSchoolName(),student.getStudentNumber(),numberList);
Double highestScore = new Double(0);
for(Student temp : classStudent){
Double tempScore = studentDetailService.selectStudentSumScore(analyse.getId(),temp.getSchoolName(),temp.getStudentNumber(),numberList);
if(tempScore > highestScore){
highestScore = tempScore ;
}
}
list.add(maxScore);
list.add(highestScore);
list.add(score);
difficultMap.put(difficultEnum.getDifficultShow(),list);
}
form2.setDifficultMap(difficultMap);
form2.setTypeMap(typeMap);
return form2;
}
@ApiOperation("getForm3")
@RequestMapping(value = "getForm3", method = RequestMethod.POST)
public Form3 getStudent3(@RequestBody StudentReqVo studentReqVo){
Form3 form3 = new Form3();
Analyse analyse = analyseService.selectById(studentReqVo.getAnalyseId());
Student student = studentService.selectStudent(analyse.getId(),studentReqVo.getSchoolName(),studentReqVo.getStudentNumber());
List<Student> classStudent = studentService.selectByClassName(analyse.getId(),studentReqVo.getSchoolName(),student.getClassName());
List<Dimensional> knowledgeList = dimensionalService.selectByAnalyse(analyse.getId(), DimensionalEnums.knowledge.getDimensionalType());
List<String> goodList = new ArrayList<>();
List<String> badList = new ArrayList<>();
for(Dimensional dimensional : knowledgeList) {
Form6 form6 = new Form6();
form6.setDimensional(dimensional.getDimensionalName());
List<AnalyseDimensional> analyseDimensionals = analyseDimensionalService.selectByDimensional(analyse.getId(), dimensional.getId());
Double score = 0d;
List<String> examNumberList = new ArrayList<>();
for (AnalyseDimensional analyseDimensional : analyseDimensionals) {
score = score + analyseDimensional.getScore();
examNumberList.add(analyseDimensional.getQuestionNumber());
}
Double sumScore = studentDetailService.selectClassSumScore(analyse.getId(),student.getSchoolName(),student.getClassName(),examNumberList);
Double classAvg = sumScore / new Double(classStudent.size()) ;
Double tempScore = studentDetailService.selectStudentSumScore(analyse.getId(),student.getSchoolName(),student.getStudentNumber(),examNumberList);
if(tempScore / classAvg > 1.1){
goodList.add(dimensional.getDimensionalName());
}
if(tempScore / classAvg < 0.9){
badList.add(dimensional.getDimensionalName());
}
}
form3.setGoodList(goodList);
form3.setBadList(badList);
return form3;
}
}