diff --git a/src/main/java/cn/teammodel/controller/admin/controller/TeacherController.java b/src/main/java/cn/teammodel/controller/admin/controller/TeacherController.java index 10c5740..0884d0e 100644 --- a/src/main/java/cn/teammodel/controller/admin/controller/TeacherController.java +++ b/src/main/java/cn/teammodel/controller/admin/controller/TeacherController.java @@ -15,6 +15,7 @@ import org.springframework.web.bind.annotation.RestController; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; import javax.validation.Valid; +import java.util.LinkedHashMap; import java.util.List; import java.util.Map; @@ -69,8 +70,8 @@ public class TeacherController { } @PostMapping("getTeachingOfTeacher") @ApiOperation("获取教师教学法数据") - public R>>> getTeachingOfTeacher(@Valid @RequestBody TeacherDto teacherDto, HttpServletRequest request) { - List>> res = teacherService.getTeachingOfTeacher(teacherDto,request); + public R>> > getTeachingOfTeacher(@Valid @RequestBody TeacherDto teacherDto, HttpServletRequest request) { + List>> res = teacherService.getTeachingOfTeacher(teacherDto,request); return R.success(res); } diff --git a/src/main/java/cn/teammodel/controller/admin/service/TeacherService.java b/src/main/java/cn/teammodel/controller/admin/service/TeacherService.java index a1ebbff..9ca4305 100644 --- a/src/main/java/cn/teammodel/controller/admin/service/TeacherService.java +++ b/src/main/java/cn/teammodel/controller/admin/service/TeacherService.java @@ -4,6 +4,7 @@ import cn.teammodel.model.dto.admin.teacher.GpTeacherDto; import cn.teammodel.model.dto.admin.teacher.TeacherDto; import javax.servlet.http.HttpServletRequest; +import java.util.LinkedHashMap; import java.util.List; import java.util.Map; @@ -15,5 +16,5 @@ public interface TeacherService { Map getTeacherGradeCount(TeacherDto teacherDto, HttpServletRequest request); List>> getDistributionOfTeachers(TeacherDto teacherDto, HttpServletRequest request); Map getTeachingAndResearch(TeacherDto teacherDto, HttpServletRequest request); - List>> getTeachingOfTeacher(TeacherDto teacherDto, HttpServletRequest request); + List>> getTeachingOfTeacher(TeacherDto teacherDto, HttpServletRequest request); } diff --git a/src/main/java/cn/teammodel/controller/admin/service/impl/TeacherServiceImpl.java b/src/main/java/cn/teammodel/controller/admin/service/impl/TeacherServiceImpl.java index c9abf99..e69b4c8 100644 --- a/src/main/java/cn/teammodel/controller/admin/service/impl/TeacherServiceImpl.java +++ b/src/main/java/cn/teammodel/controller/admin/service/impl/TeacherServiceImpl.java @@ -763,11 +763,11 @@ public class TeacherServiceImpl implements TeacherService { } @Override - public List>> getTeachingOfTeacher(TeacherDto teacherDto, HttpServletRequest request) { - List>> list = new ArrayList<>(); + public List>> getTeachingOfTeacher(TeacherDto teacherDto, HttpServletRequest request) { + List>> list = new ArrayList<>(); if(teacherDto.getGrade() != null) { - Map> map = new HashMap<>(); - Map mapTeach = new HashMap<>(); + LinkedHashMap> map = new LinkedHashMap<>(); + LinkedHashMap mapTeach = new LinkedHashMap<>(); mapTeach.put("interaction", new Random().nextInt(50) + 1); mapTeach.put("cooperation", new Random().nextInt(50) + 1); mapTeach.put("test", new Random().nextInt(50) + 1); @@ -779,19 +779,10 @@ public class TeacherServiceImpl implements TeacherService { }else { List school = schoolRepository.findBaseById(teacherDto.getCode()); - List grades = new ArrayList<>(); - if(school != null && !school.isEmpty()) { - for (School base : school) { - for (School.Period period : base.getPeriod()) { - if(period.getId().equals(teacherDto.getPeriodId())) { - grades = period.getGrades(); - } - } - } - } - Map> map = new HashMap<>(); + List grades = getGrades(teacherDto, school); + LinkedHashMap> map = new LinkedHashMap<>(); for (String grade : grades) { - Map mapTeach = new HashMap<>(); + LinkedHashMap mapTeach = new LinkedHashMap<>(); mapTeach.put("interaction", new Random().nextInt(50) + 1); mapTeach.put("cooperation", new Random().nextInt(50) + 1); mapTeach.put("test", new Random().nextInt(50) + 1); @@ -805,6 +796,22 @@ public class TeacherServiceImpl implements TeacherService { return list; } + private static @NotNull List getGrades(TeacherDto teacherDto, List school) { + List grades = new ArrayList<>(); + if(school != null && !school.isEmpty()) { + for (School base : school) { + for (School.Period period : base.getPeriod()) { + if(period.getId().equals(teacherDto.getPeriodId())) { + for(String grade : period.getGrades()) { + grades.add(grade.trim()); + } + } + } + } + } + return grades; + } + public Map getTeacherBase(GpTeacherDto gpTeacherDto, HttpServletRequest request) { Map gradeMap;