|
|
|
|
@ -1,2 +1,344 @@
|
|
|
|
|
# OEMS
|
|
|
|
|
public class StudentCount {
|
|
|
|
|
|
|
|
|
|
/** 班级对应学生人数折线图 */
|
|
|
|
|
public static String createBarJson(Map<String, Object> data) {
|
|
|
|
|
Set<String> set = data.keySet();
|
|
|
|
|
|
|
|
|
|
GsonOption option = new GsonOption();
|
|
|
|
|
option.title().text("班级学生数量统计").x(X.center).y(Y.top).borderWidth(1).textStyle().color("#438EB9");
|
|
|
|
|
option.toolbox().show(true).feature(Tool.mark, Tool.restore, new MagicType(Magic.bar, Magic.line), Tool.saveAsImage).x(X.right).y(Y.top);
|
|
|
|
|
//数据默认触发, 鼠标移入显示竖线 trigger(Trigger.axis)
|
|
|
|
|
option.tooltip().formatter("{b} {c}人").trigger(Trigger.axis);
|
|
|
|
|
option.legend().data("班级总人数").x(X.center).y(Y.bottom).borderWidth(1);
|
|
|
|
|
Line line = new Line("班级总人数");
|
|
|
|
|
//值轴
|
|
|
|
|
ValueAxis valueAxis = new ValueAxis();
|
|
|
|
|
valueAxis.axisLabel().formatter("{value}人").textStyle().color("#438EB9");
|
|
|
|
|
//valueAxis.min(0);
|
|
|
|
|
option.yAxis(valueAxis);
|
|
|
|
|
//类目轴
|
|
|
|
|
CategoryAxis categoryAxis = new CategoryAxis();
|
|
|
|
|
//interval(0):设置横轴信息全部显示
|
|
|
|
|
//rotate(-30):设置 -30 度角倾斜显示
|
|
|
|
|
categoryAxis.axisLabel().interval(0).rotate(-30).textStyle().color("#438EB9");
|
|
|
|
|
for (String className : set) {
|
|
|
|
|
categoryAxis.data(className);
|
|
|
|
|
ClassInfo classInfo = (ClassInfo)data.get(className);
|
|
|
|
|
line.data(classInfo.getClassId());
|
|
|
|
|
}
|
|
|
|
|
option.xAxis(categoryAxis);
|
|
|
|
|
line.smooth(true);
|
|
|
|
|
option.series(line);
|
|
|
|
|
option.grid().x(100);
|
|
|
|
|
System.out.println(option.toString());
|
|
|
|
|
return option.toString();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
public class StudentExamInfoCharts {
|
|
|
|
|
public static String createExamCountBarJson(List<StudentExamInfo> examInfos) {
|
|
|
|
|
GsonOption option = new GsonOption();
|
|
|
|
|
option.title().text("学生考试次数统计").x(X.center).y(Y.top).borderWidth(1).textStyle().color("#438EB9");
|
|
|
|
|
option.toolbox().show(true).feature(Tool.mark, Tool.restore, new MagicType(Magic.bar, Magic.line), Tool.saveAsImage).x(X.right).y(Y.top);
|
|
|
|
|
option.tooltip().show(true).formatter("{b} {c}次");
|
|
|
|
|
option.legend().data("学生考试次数统计").x(X.center).y(Y.bottom);
|
|
|
|
|
Bar bar = new Bar();
|
|
|
|
|
//值轴
|
|
|
|
|
ValueAxis valueAxis = new ValueAxis();
|
|
|
|
|
//设置y轴不出现小数值
|
|
|
|
|
valueAxis.interval(1);
|
|
|
|
|
valueAxis.axisLabel().formatter("{value} 次");
|
|
|
|
|
option.yAxis(valueAxis);
|
|
|
|
|
//类目轴
|
|
|
|
|
CategoryAxis categoryAxis = new CategoryAxis();
|
|
|
|
|
categoryAxis.axisLabel().interval(0);
|
|
|
|
|
for (StudentExamInfo studentExamInfo : examInfos) {
|
|
|
|
|
bar.data(studentExamInfo.getExamSum());
|
|
|
|
|
categoryAxis.data(studentExamInfo.getStudentName());
|
|
|
|
|
}
|
|
|
|
|
bar.barCategoryGap("20");
|
|
|
|
|
option.xAxis(categoryAxis);
|
|
|
|
|
option.series(bar);
|
|
|
|
|
return option.toString();
|
|
|
|
|
}
|
|
|
|
|
public static String createAvgCountLineJson(List<StudentExamInfo> examInfos) {
|
|
|
|
|
GsonOption option = new GsonOption();
|
|
|
|
|
option.title().text("学生考试平均成绩统计").x(X.center).y(Y.top).borderWidth(1).textStyle().color("#438EB9");
|
|
|
|
|
option.toolbox().show(true).feature(Tool.mark, Tool.restore, new MagicType(Magic.bar, Magic.line), Tool.saveAsImage).x(X.right).y(Y.top);
|
|
|
|
|
option.tooltip().show(true).trigger(Trigger.axis).axisPointer().type(PointerType.cross).crossStyle().color("#999");
|
|
|
|
|
option.legend().data("考试次数", "平均分").x(X.center).y(Y.bottom);
|
|
|
|
|
Line line = new Line("考试次数").smooth(true);
|
|
|
|
|
Bar bar = new Bar("平均分");
|
|
|
|
|
//值轴
|
|
|
|
|
ValueAxis valueAxis = new ValueAxis();
|
|
|
|
|
//设置y轴不出现小数值
|
|
|
|
|
valueAxis.interval(1);
|
|
|
|
|
valueAxis.axisLabel().formatter("{value} 次");
|
|
|
|
|
ValueAxis valueAxis1 = new ValueAxis();
|
|
|
|
|
valueAxis1.interval(1);
|
|
|
|
|
valueAxis1.axisLabel().formatter("{value} 分");
|
|
|
|
|
option.yAxis(valueAxis, valueAxis1);
|
|
|
|
|
//类目轴
|
|
|
|
|
CategoryAxis categoryAxis = new CategoryAxis();
|
|
|
|
|
categoryAxis.axisLabel().interval(0);
|
|
|
|
|
for (StudentExamInfo studentExamInfo : examInfos) {
|
|
|
|
|
if (studentExamInfo.getAvgScore() != null || studentExamInfo.getExamSum() != 0) {
|
|
|
|
|
bar.data(studentExamInfo.getAvgScore()/studentExamInfo.getExamSum());
|
|
|
|
|
} else {
|
|
|
|
|
bar.data("暂无记录");
|
|
|
|
|
}
|
|
|
|
|
line.data(studentExamInfo.getExamSum());
|
|
|
|
|
categoryAxis.data(studentExamInfo.getStudentName());
|
|
|
|
|
}
|
|
|
|
|
//实现双 y 轴,使用 yAxisIndex() 指定应用到哪个 y 轴
|
|
|
|
|
bar.barCategoryGap("20").yAxisIndex(1);
|
|
|
|
|
option.xAxis(categoryAxis);
|
|
|
|
|
option.series(bar, line);
|
|
|
|
|
return option.toString();
|
|
|
|
|
}
|
|
|
|
|
public static String createStudentExamLineJson(List<StudentExamInfo> examInfos) {
|
|
|
|
|
GsonOption option = new GsonOption();
|
|
|
|
|
option.title().text("学生考试试卷得分统计").x(X.center).y(Y.top).borderWidth(1).textStyle().color("#438EB9");
|
|
|
|
|
option.toolbox().show(true).feature(Tool.mark, Tool.restore, new MagicType(Magic.bar, Magic.line), Tool.saveAsImage).x(X.right).y(Y.top);
|
|
|
|
|
option.tooltip().show(true).formatter("{b} {c}分").trigger(Trigger.axis);
|
|
|
|
|
option.legend().data("得分").x(X.center).y(Y.bottom);
|
|
|
|
|
Line line = new Line("试卷得分");
|
|
|
|
|
//值轴
|
|
|
|
|
ValueAxis valueAxis = new ValueAxis();
|
|
|
|
|
//设置y轴不出现小数值
|
|
|
|
|
valueAxis.interval(1);
|
|
|
|
|
valueAxis.axisLabel().formatter("{value} 分");
|
|
|
|
|
option.yAxis(valueAxis);
|
|
|
|
|
//类目轴
|
|
|
|
|
CategoryAxis categoryAxis = new CategoryAxis();
|
|
|
|
|
categoryAxis.axisLabel().interval(0).rotate(-30);
|
|
|
|
|
|
|
|
|
|
for (StudentExamInfo studentExamInfo : examInfos) {
|
|
|
|
|
line.data(studentExamInfo.getExamScore());
|
|
|
|
|
categoryAxis.data(studentExamInfo.getExamPaperName());
|
|
|
|
|
}
|
|
|
|
|
option.xAxis(categoryAxis);
|
|
|
|
|
option.series(line);
|
|
|
|
|
System.out.println(option.toString());
|
|
|
|
|
return option.toString();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
public class AdminHomeHandler {
|
|
|
|
|
@Autowired
|
|
|
|
|
ExamPaperInfoService examPaperInfoService;
|
|
|
|
|
@Autowired
|
|
|
|
|
SubjectInfoService subjectInfoService;
|
|
|
|
|
@Autowired
|
|
|
|
|
TeacherInfoService teacherInfoService;
|
|
|
|
|
@Autowired
|
|
|
|
|
StudentInfoService studentInfoService;
|
|
|
|
|
@Autowired
|
|
|
|
|
Gson gson;
|
|
|
|
|
private Logger logger = Logger.getLogger(AdminHomeHandler.class);
|
|
|
|
|
@RequestMapping("/homeInfo")
|
|
|
|
|
public void homeInfo(HttpServletResponse response) throws IOException {
|
|
|
|
|
logger.info("加载后台首页相关数据");
|
|
|
|
|
int examPaperTotal = examPaperInfoService.getExamPpaerTotal();
|
|
|
|
|
int subjectTotal = subjectInfoService.getSubjectTotal();
|
|
|
|
|
int teacherTotal = teacherInfoService.getTeacherTotal();
|
|
|
|
|
int studentTotal = studentInfoService.getStudentTotal();
|
|
|
|
|
String json = "{\"examPaperTotal\":"+examPaperTotal+", " +
|
|
|
|
|
"\"subjectTotal\":"+subjectTotal+", " +
|
|
|
|
|
"\"teacherTotal\":"+teacherTotal+", " +
|
|
|
|
|
"\"studentTotal\":"+studentTotal+"}";
|
|
|
|
|
response.getWriter().print(json);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
public class ClassInfoHandler {
|
|
|
|
|
@Autowired
|
|
|
|
|
private ClassInfoService classInfoService;
|
|
|
|
|
@Autowired
|
|
|
|
|
private GradeInfoService gradeInfoService;
|
|
|
|
|
@Autowired
|
|
|
|
|
private TeacherInfoService teacherInfoService;
|
|
|
|
|
@Autowired
|
|
|
|
|
private TeacherInfo teacher;
|
|
|
|
|
@Autowired
|
|
|
|
|
private ClassInfo classInfo;
|
|
|
|
|
@Autowired
|
|
|
|
|
private Gson gson;
|
|
|
|
|
private Logger logger = Logger.getLogger(ClassInfoHandler.class);
|
|
|
|
|
@RequestMapping(value="/classes", method=RequestMethod.GET)
|
|
|
|
|
public ModelAndView getClasses(@RequestParam(value="gradeId", required=false) Integer gradeId,
|
|
|
|
|
@RequestParam(value="className", required=false) String className,
|
|
|
|
|
@RequestParam(value="classId", required=false) Integer classId) {
|
|
|
|
|
logger.info("获取班级集合 条件:gradeId: "+gradeId+", 班级编号:"+classId+", 班级:"+className);
|
|
|
|
|
ModelAndView model = new ModelAndView();
|
|
|
|
|
ClassInfo classInfo = new ClassInfo();
|
|
|
|
|
/*处理查询条件*/
|
|
|
|
|
if (gradeId != null) {
|
|
|
|
|
GradeInfo gradeInfo = new GradeInfo();
|
|
|
|
|
gradeInfo.setGradeId(gradeId);
|
|
|
|
|
classInfo.setGrade(gradeInfo);
|
|
|
|
|
}
|
|
|
|
|
if (classId != null)
|
|
|
|
|
classInfo.setClassId(classId);
|
|
|
|
|
if (className != null) {
|
|
|
|
|
if (className.trim() != "")
|
|
|
|
|
classInfo.setClassName(className);
|
|
|
|
|
}
|
|
|
|
|
List<ClassInfo> classes = classInfoService.getClasses(classInfo);
|
|
|
|
|
model.setViewName("admin/classes");
|
|
|
|
|
model.addObject("classes", classes);
|
|
|
|
|
return model;
|
|
|
|
|
}
|
|
|
|
|
@RequestMapping("/preAddClass")
|
|
|
|
|
public ModelAndView preAddClass() {
|
|
|
|
|
logger.info("预添加班级信息");
|
|
|
|
|
ModelAndView model = new ModelAndView();
|
|
|
|
|
//获取年级信息
|
|
|
|
|
List<GradeInfo> grades = gradeInfoService.getGrades();
|
|
|
|
|
model.setViewName("admin/classedit");
|
|
|
|
|
model.addObject("grades", grades);
|
|
|
|
|
//获取不是班主任的教师
|
|
|
|
|
teacher.setIsWork(0);
|
|
|
|
|
Map<String, Object> map = new HashMap<String, Object>();
|
|
|
|
|
map.put("startIndex", null);
|
|
|
|
|
map.put("pageShow", null);
|
|
|
|
|
map.put("teacher", teacher);
|
|
|
|
|
List<TeacherInfo> teachers = teacherInfoService.getTeachers(map);
|
|
|
|
|
model.addObject("teachers", teachers);
|
|
|
|
|
model.addObject("editClass", new ClassInfo());
|
|
|
|
|
return model;
|
|
|
|
|
}
|
|
|
|
|
@RequestMapping(value="/class", method=RequestMethod.POST)
|
|
|
|
|
public String isAddClass(ClassInfo classInfo, HttpServletRequest request) {
|
|
|
|
|
logger.info("添加班级信息 "+classInfo);
|
|
|
|
|
//修改教师班主任状态
|
|
|
|
|
String returnMsg = isChangeTeacherWork(1, classInfo.getTeacher().getTeacherId());
|
|
|
|
|
if (returnMsg != null) {
|
|
|
|
|
request.setAttribute("error", "修改教师班主任状态 对应教师编号有误");
|
|
|
|
|
return "error";
|
|
|
|
|
}
|
|
|
|
|
//添加
|
|
|
|
|
int row = classInfoService.isAddClass(classInfo);
|
|
|
|
|
if (row < 1) {
|
|
|
|
|
logger.error("班级 "+classInfo+" 删除失败");
|
|
|
|
|
request.setAttribute("error", "班级 "+classInfo.getClassName()+" 添加失败,请稍后再试!");
|
|
|
|
|
return "../error";
|
|
|
|
|
}
|
|
|
|
|
return "redirect:/classes";
|
|
|
|
|
}
|
|
|
|
|
@RequestMapping(value="/del/class/{classId}", method=RequestMethod.DELETE)
|
|
|
|
|
public String isDelClass(@PathVariable("classId") Integer classId, HttpServletRequest request) {
|
|
|
|
|
logger.info("删除班级 "+classId);
|
|
|
|
|
|
|
|
|
|
//将删除班级对于之前班主任改为 非班主任状态
|
|
|
|
|
//需要在删除班级之前修改,如果先删除了班级,再根据班级获取教师编号,就不能获取
|
|
|
|
|
ClassInfo delClass = classInfoService.getClassById(classId);
|
|
|
|
|
String returnMsg = isChangeTeacherWork(0, delClass.getTeacher().getTeacherId());
|
|
|
|
|
if (returnMsg != null) {
|
|
|
|
|
request.setAttribute("error", "修改教师班主任状态 对应教师编号有误");
|
|
|
|
|
return "error";
|
|
|
|
|
}
|
|
|
|
|
//删除
|
|
|
|
|
int row = classInfoService.isDelClass(classId);
|
|
|
|
|
if (row < 1) {
|
|
|
|
|
logger.error("班级 "+classId+" 删除失败");
|
|
|
|
|
request.setAttribute("error", "班级删除失败,请稍后再试!");
|
|
|
|
|
return "../error";
|
|
|
|
|
}
|
|
|
|
|
return "redirect:/classes";
|
|
|
|
|
}
|
|
|
|
|
@RequestMapping(value="edit/class/{classId}", method=RequestMethod.GET)
|
|
|
|
|
public ModelAndView preUpdateClass(@PathVariable("classId") Integer classId) {
|
|
|
|
|
logger.info("预修改班级处理");
|
|
|
|
|
ModelAndView model = new ModelAndView();
|
|
|
|
|
//获取要修改班级
|
|
|
|
|
ClassInfo classInfo = classInfoService.getClassById(classId);
|
|
|
|
|
model.setViewName("/admin/classedit");
|
|
|
|
|
model.addObject("editClass", classInfo);
|
|
|
|
|
List<GradeInfo> grades = gradeInfoService.getGrades();
|
|
|
|
|
//获取不是班主任的教师
|
|
|
|
|
teacher.setIsWork(0);
|
|
|
|
|
Map<String, Object> map = new HashMap<String, Object>();
|
|
|
|
|
map.put("startIndex", null);
|
|
|
|
|
map.put("pageShow", null);
|
|
|
|
|
map.put("teacher", teacher);
|
|
|
|
|
List<TeacherInfo> teachers = teacherInfoService.getTeachers(map);
|
|
|
|
|
//如果没有可用班主任
|
|
|
|
|
if (teachers.size() == 0 || teachers == null) {
|
|
|
|
|
teacher.setTeacherId(classInfo.getTeacher().getTeacherId());
|
|
|
|
|
teacher.setTeacherName("暂无剩余教师");
|
|
|
|
|
teachers.add(teacher);
|
|
|
|
|
}
|
|
|
|
|
model.addObject("teachers", teachers);
|
|
|
|
|
model.addObject("grades", grades);
|
|
|
|
|
return model;
|
|
|
|
|
}
|
|
|
|
|
@RequestMapping(value="edit/class/class", method=RequestMethod.PUT)
|
|
|
|
|
public String isUpdateClass(ClassInfo classInfo, HttpServletRequest request,
|
|
|
|
|
@RequestParam(value="lastTeacher", required=false) Integer lastTeacherId) {
|
|
|
|
|
//修改上一教师不为班主任状态
|
|
|
|
|
if (lastTeacherId != null) {
|
|
|
|
|
String returnMsg = isChangeTeacherWork(0, lastTeacherId);
|
|
|
|
|
if (returnMsg != null) {
|
|
|
|
|
request.setAttribute("error", "修改教师班主任状态 对应教师编号有误");
|
|
|
|
|
return "/error";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//修改当前教师为班主任状态
|
|
|
|
|
String returnMsg = isChangeTeacherWork(1, classInfo.getTeacher().getTeacherId());
|
|
|
|
|
if (returnMsg != null) {
|
|
|
|
|
request.setAttribute("error", "修改教师班主任状态 对应教师编号有误");
|
|
|
|
|
return "/error";
|
|
|
|
|
}
|
|
|
|
|
logger.info("修改班级 "+classInfo);
|
|
|
|
|
|
|
|
|
|
int row = classInfoService.isUpdateClass(classInfo);
|
|
|
|
|
if (row < 1) {
|
|
|
|
|
logger.error("班级 "+classInfo+" 修改失败");
|
|
|
|
|
|
|
|
|
|
request.setAttribute("error", "班级修改失败,请稍后再试!");
|
|
|
|
|
return "../error";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return "redirect:/classes";
|
|
|
|
|
}
|
|
|
|
|
@RequestMapping(value="/gradeclass/{gradeId}", method=RequestMethod.GET)
|
|
|
|
|
public void getClassesByGradeId(@PathVariable("gradeId") Integer gradeId,
|
|
|
|
|
HttpServletResponse response) throws IOException {
|
|
|
|
|
logger.info("获取年级 "+gradeId+" 下的班级集合");
|
|
|
|
|
|
|
|
|
|
List<ClassInfo> classes = classInfoService.getClassByGradeId(gradeId);
|
|
|
|
|
|
|
|
|
|
String json = gson.toJson(classes);
|
|
|
|
|
response.getWriter().print(json);
|
|
|
|
|
}
|
|
|
|
|
isChangeTeacherWork(int status, Integer teacherId) {
|
|
|
|
|
logger.info("修改教师 "+teacherId+" 的状态为 "+status);
|
|
|
|
|
teacher.setIsWork(status);
|
|
|
|
|
if (teacherId == null) {
|
|
|
|
|
logger.error("修改教师班主任状态 对应教师编号有误");
|
|
|
|
|
return "修改教师班主任状态 对应教师编号有误";
|
|
|
|
|
}
|
|
|
|
|
teacher.setTeacherId(teacherId);
|
|
|
|
|
int row = teacherInfoService.updateTeacherIsWork(teacher);
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
@RequestMapping("/stuCount")
|
|
|
|
|
public void getStudentCountForClass(
|
|
|
|
|
@RequestParam(value="gradeId", required=false) Integer gradeId,
|
|
|
|
|
HttpServletResponse response) throws IOException {
|
|
|
|
|
Map<String, Object> map = classInfoService.getStudentCountForClass(gradeId);
|
|
|
|
|
String json = StudentCount.createBarJson(map);
|
|
|
|
|
response.getWriter().print(json);
|
|
|
|
|
}
|
|
|
|
|
@RequestMapping("/preStudentCount")
|
|
|
|
|
public ModelAndView preStudentCount() {
|
|
|
|
|
ModelAndView model = new ModelAndView();
|
|
|
|
|
//获取年级信息
|
|
|
|
|
List<GradeInfo> grades = gradeInfoService.getGrades();
|
|
|
|
|
model.setViewName("admin/charts/studentCount");
|
|
|
|
|
model.addObject("grades", grades);
|
|
|
|
|
return model;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|