From e746605ee0b1bb5851b1ad8b799ab2bffeafe9fa Mon Sep 17 00:00:00 2001 From: "hhb@hotmail.com" Date: Fri, 29 Nov 2024 10:15:09 +0800 Subject: [PATCH 1/8] =?UTF-8?q?update=20=E6=95=99=E5=B8=88=E4=BF=A1?= =?UTF-8?q?=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/controller/TeacherController.java | 2 +- .../service/impl/TeacherServiceImpl.java | 56 +++++++++++++++++++ .../model/entity/school/GpTeacher.java | 2 + .../teammodel/model/vo/admin/GpTeacherVo.java | 13 +++++ 4 files changed, 72 insertions(+), 1 deletion(-) 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 2540a4c..37199f0 100644 --- a/src/main/java/cn/teammodel/controller/admin/controller/TeacherController.java +++ b/src/main/java/cn/teammodel/controller/admin/controller/TeacherController.java @@ -31,7 +31,7 @@ public class TeacherController { return R.success(res); } @PostMapping("getTeacherDetail") - @ApiOperation("获取教师素质素养数据") + @ApiOperation("获取教师详细数据") public R> getTeacherDetail(@Valid @RequestBody TeacherDto teacherDto, HttpServletRequest request) { Map res = teacherService.getTeacherDetail(teacherDto,request); return R.success(res); 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 0b652fd..6805213 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 @@ -146,9 +146,49 @@ public class TeacherServiceImpl implements TeacherService { .collect(Collectors.groupingBy(GpTeacher::getDegree, Collectors.counting())); Map practiceCount = getStringIntegerMap(teacherDto, gpTeachers); + if(!genderCount.containsKey("F")) { + genderCount.put("F",0L); + }else if (!genderCount.containsKey("S")) { + genderCount.put("S",0L); + }else if (!genderCount.containsKey("M")){ + genderCount.put("M",0L); + } + Map genderMap = new HashMap<>(); + Map practiceMap = new HashMap<>(); + for (GpTeacher gpTeacher : gpTeachers) { + genderMap.put(gpTeacher.basic.name, gpTeacher.basic.gender); + practiceMap.put(gpTeacher.basic.name, gpTeacher.practiceTime); + } + + for (GpTeacherVo teacher : teachersList) { + for(GpTeacher gpTeacher : gpTeachers) { + if(StringUtils.isNotEmpty(teacher.phone) && teacher.phone.equalsIgnoreCase(gpTeacher.mobile)) { + if(gpTeacher.basic.gender != null) { + teacher.setGender(gpTeacher.basic.gender); + }else { + teacher.setGender(""); + } + if (gpTeacher.getPracticeTime() != null && gpTeacher.getPracticeTime() > 0) { + teacher.setPracticeTime(gpTeacher.getPracticeTime()); + }else { + teacher.setPracticeTime(0L); + } + if(gpTeacher.degree != null) { + teacher.setDegree(gpTeacher.degree); + }else { + teacher.setDegree(""); + } + break; + } + } + } teachers.put("practice", practiceCount); + teachers.put("practiceMap", practiceMap); + teachers.put("genderMap", genderMap); teachers.put("gender", genderCount); teachers.put("degree", degreeCount); + teachers.put("info", teachersList); + teachers.remove("teachers"); }catch (Exception e) { throw new ServiceException(ErrorCode.SYSTEM_ERROR.getCode(), "数据转换错误"); @@ -181,6 +221,16 @@ public class TeacherServiceImpl implements TeacherService { teacher.setName((String) map.get("name")); teacher.setPhone((String) map.get("phone")); teacher.setId((String) map.get("id")); + teacher.setEmail((String) map.get("email")); + teacher.setPicture((String) map.get("picture")); + teacher.setIname((String) map.get("iname")); + teacher.setJob((String) map.get("job")); + //teacher.setDegree((String) map.get("degree")); + //teacher.setPracticeTime((String) map.get("practiceTime")); + //teacher.setGender((String) map.get("gender")); + teacher.setNote((String) map.get("note")); + teacher.setSubjectIds((List) map.get("subjectIds")); + teacher.setSubjectNames((List) map.get("subjectNames")); // 根据实际属性进行转换 return teacher; } @@ -214,6 +264,12 @@ public class TeacherServiceImpl implements TeacherService { } else { teacher.setTitle(null); // 或者设置一个默认值 } + Object mobileObj = map.get("mobile"); + if (mobileObj instanceof String) { + teacher.setMobile((String) mobileObj); + } else { + teacher.setMobile(null); // 或者设置一个默认值 + } Object degreeObj = map.get("degree"); if (degreeObj instanceof String) { teacher.setDegree((String) degreeObj); diff --git a/src/main/java/cn/teammodel/model/entity/school/GpTeacher.java b/src/main/java/cn/teammodel/model/entity/school/GpTeacher.java index ff09116..787b9f8 100644 --- a/src/main/java/cn/teammodel/model/entity/school/GpTeacher.java +++ b/src/main/java/cn/teammodel/model/entity/school/GpTeacher.java @@ -19,6 +19,8 @@ public class GpTeacher { /// public String depict ; + public String mobile; + /// /// 学段 /// diff --git a/src/main/java/cn/teammodel/model/vo/admin/GpTeacherVo.java b/src/main/java/cn/teammodel/model/vo/admin/GpTeacherVo.java index 941e401..e6e1342 100644 --- a/src/main/java/cn/teammodel/model/vo/admin/GpTeacherVo.java +++ b/src/main/java/cn/teammodel/model/vo/admin/GpTeacherVo.java @@ -2,9 +2,22 @@ package cn.teammodel.model.vo.admin; import lombok.Data; +import java.util.List; + @Data public class GpTeacherVo { public String id ; public String name ; public String phone ; + public String email ; + public String picture ; + public String iname ; + public String job ; + public List subjectIds ; + public List subjectNames ; + public String note ; + public String degree; + public Long practiceTime ; + public String gender ; + } From c1bbd8a7acb4111423d5cae4340d44ed250beb7b Mon Sep 17 00:00:00 2001 From: "hhb@hotmail.com" Date: Fri, 29 Nov 2024 10:29:27 +0800 Subject: [PATCH 2/8] =?UTF-8?q?update=20=E6=95=99=E5=B8=88=E4=BF=A1?= =?UTF-8?q?=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/service/impl/TeacherServiceImpl.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) 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 6805213..bea99cc 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 @@ -144,7 +144,7 @@ public class TeacherServiceImpl implements TeacherService { Map degreeCount = gpTeachers.stream() .filter(gpTeacher -> gpTeacher.getDegree() != null) .collect(Collectors.groupingBy(GpTeacher::getDegree, Collectors.counting())); - Map practiceCount = getStringIntegerMap(teacherDto, gpTeachers); + //Map practiceCount = getStringIntegerMap(teacherDto, gpTeachers); if(!genderCount.containsKey("F")) { genderCount.put("F",0L); @@ -153,12 +153,12 @@ public class TeacherServiceImpl implements TeacherService { }else if (!genderCount.containsKey("M")){ genderCount.put("M",0L); } - Map genderMap = new HashMap<>(); + /* Map genderMap = new HashMap<>(); Map practiceMap = new HashMap<>(); for (GpTeacher gpTeacher : gpTeachers) { genderMap.put(gpTeacher.basic.name, gpTeacher.basic.gender); practiceMap.put(gpTeacher.basic.name, gpTeacher.practiceTime); - } + }*/ for (GpTeacherVo teacher : teachersList) { for(GpTeacher gpTeacher : gpTeachers) { @@ -182,9 +182,9 @@ public class TeacherServiceImpl implements TeacherService { } } } - teachers.put("practice", practiceCount); - teachers.put("practiceMap", practiceMap); - teachers.put("genderMap", genderMap); + //teachers.put("practice", practiceCount); + //teachers.put("practiceMap", practiceMap); + //teachers.put("genderMap", genderMap); teachers.put("gender", genderCount); teachers.put("degree", degreeCount); teachers.put("info", teachersList); From 49cfb374045d9d2bf8bfb29e521454e97fea26bf Mon Sep 17 00:00:00 2001 From: "hhb@hotmail.com" Date: Mon, 2 Dec 2024 14:39:00 +0800 Subject: [PATCH 3/8] =?UTF-8?q?update=20=E6=95=99=E5=B8=88=E8=BA=AB?= =?UTF-8?q?=E5=88=86=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/service/impl/TeacherServiceImpl.java | 2 ++ .../java/cn/teammodel/model/vo/admin/GpTeacherVo.java | 10 ++++++++++ 2 files changed, 12 insertions(+) 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 bea99cc..48b9502 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 @@ -225,6 +225,8 @@ public class TeacherServiceImpl implements TeacherService { teacher.setPicture((String) map.get("picture")); teacher.setIname((String) map.get("iname")); teacher.setJob((String) map.get("job")); + teacher.setRoles((List) map.get("roles")); + teacher.setGroups((List) map.get("groups")); //teacher.setDegree((String) map.get("degree")); //teacher.setPracticeTime((String) map.get("practiceTime")); //teacher.setGender((String) map.get("gender")); diff --git a/src/main/java/cn/teammodel/model/vo/admin/GpTeacherVo.java b/src/main/java/cn/teammodel/model/vo/admin/GpTeacherVo.java index e6e1342..af59296 100644 --- a/src/main/java/cn/teammodel/model/vo/admin/GpTeacherVo.java +++ b/src/main/java/cn/teammodel/model/vo/admin/GpTeacherVo.java @@ -15,9 +15,19 @@ public class GpTeacherVo { public String job ; public List subjectIds ; public List subjectNames ; + public List roles; + public List groups; public String note ; public String degree; public Long practiceTime ; public String gender ; + @Data + public static class IdNameCode{ + public String id ; + public String name ; + public String code ; + public String picture ; + public String nickname ; + } } From e447351729799e89cbbb1117dc5a605ee063b592 Mon Sep 17 00:00:00 2001 From: "hhb@hotmail.com" Date: Tue, 3 Dec 2024 10:56:23 +0800 Subject: [PATCH 4/8] =?UTF-8?q?update=20=E6=95=99=E5=B8=88=E5=88=86?= =?UTF-8?q?=E5=B8=83=E7=BB=9F=E8=AE=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/controller/TeacherController.java | 6 + .../admin/service/TeacherService.java | 1 + .../service/impl/TeacherServiceImpl.java | 293 +++++++++++++++++- .../model/entity/school/GpTeacher.java | 1 + .../teammodel/model/vo/admin/GpTeacherVo.java | 1 + .../model/vo/admin/TeacherGradeVo.java | 17 + 6 files changed, 318 insertions(+), 1 deletion(-) create mode 100644 src/main/java/cn/teammodel/model/vo/admin/TeacherGradeVo.java 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 37199f0..351e905 100644 --- a/src/main/java/cn/teammodel/controller/admin/controller/TeacherController.java +++ b/src/main/java/cn/teammodel/controller/admin/controller/TeacherController.java @@ -54,5 +54,11 @@ public class TeacherController { Map res = teacherService.getTeacherGradeCount(teacherDto,request); return R.success(res); } + @PostMapping("getDistributionOfTeachers") + @ApiOperation("获取教师分布情况") + public R>>> getDistributionOfTeachers(@Valid @RequestBody TeacherDto teacherDto, HttpServletRequest request) { + List>> res = teacherService.getDistributionOfTeachers(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 30a64a2..b3425e8 100644 --- a/src/main/java/cn/teammodel/controller/admin/service/TeacherService.java +++ b/src/main/java/cn/teammodel/controller/admin/service/TeacherService.java @@ -13,4 +13,5 @@ public interface TeacherService { Map getTeacherByRecord(TeacherDto teacherDto); Map getTeacherLearningCategory(TeacherDto teacherDto); Map getTeacherGradeCount(TeacherDto teacherDto, HttpServletRequest request); + List>> getDistributionOfTeachers(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 48b9502..4774d95 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 @@ -12,6 +12,7 @@ import cn.teammodel.model.entity.school.LessonRecord; import cn.teammodel.model.entity.school.School; import cn.teammodel.model.entity.school.SchoolTeacher; import cn.teammodel.model.vo.admin.GpTeacherVo; +import cn.teammodel.model.vo.admin.TeacherGradeVo; import cn.teammodel.repository.LessonRecordRepository; import cn.teammodel.repository.SchoolGroupListRepository; import cn.teammodel.repository.SchoolRepository; @@ -226,7 +227,22 @@ public class TeacherServiceImpl implements TeacherService { teacher.setIname((String) map.get("iname")); teacher.setJob((String) map.get("job")); teacher.setRoles((List) map.get("roles")); - teacher.setGroups((List) map.get("groups")); + //teacher.setGroups((List) map.get("groups")); + List> groupList = (List>) map.get("groups"); + if (groupList != null) { + + List groups = new ArrayList<>(); + for (Map groupMap : groupList) { + GpTeacherVo.IdNameCode group = new GpTeacherVo.IdNameCode(); + group.setId((String) groupMap.get("id")); + group.setName((String) groupMap.get("name")); + group.setCode((String) groupMap.get("code")); + group.setPicture((String) groupMap.get("picture")); + group.setNickname((String) groupMap.get("nickname")); + groups.add(group); + } + teacher.setGroups(groups); + } //teacher.setDegree((String) map.get("degree")); //teacher.setPracticeTime((String) map.get("practiceTime")); //teacher.setGender((String) map.get("gender")); @@ -236,6 +252,26 @@ public class TeacherServiceImpl implements TeacherService { // 根据实际属性进行转换 return teacher; } + + private TeacherGradeVo convertToTeacherGradeVo(Map map) { + TeacherGradeVo teacher = new TeacherGradeVo(); + teacher.setName((String) map.get("name")); + teacher.setId((String) map.get("tmdId")); + // 处理 grade 字段 + List> gradeList = (List>) map.get("grade"); + if (gradeList != null) { + List grades = new ArrayList<>(); + for (Map gradeMap : gradeList) { + TeacherGradeVo.IdAndName grade = new TeacherGradeVo.IdAndName(); + grade.setGrade((Integer) gradeMap.get("grade")); + grade.setGradeName((String) gradeMap.get("gradeName")); + grades.add(grade); + } + teacher.setGrade(grades); + } + // 根据实际属性进行转换 + return teacher; + } private GpTeacher convertToGpTeacher(Map map) { GpTeacher teacher = new GpTeacher(); // 假设 GpTeacherVo 有以下属性:name, age, subject @@ -245,6 +281,12 @@ public class TeacherServiceImpl implements TeacherService { } else { teacher.setDescribe(null); // 或者设置一个默认值 } + Object IdObj = map.get("id"); + if (describeObj instanceof String) { + teacher.setId((String) IdObj); + } else { + teacher.setId(null); // 或者设置一个默认值 + } Object depictObj = map.get("depict"); if (depictObj instanceof String) { teacher.setDepict((String) depictObj); @@ -430,6 +472,255 @@ public class TeacherServiceImpl implements TeacherService { return gradeMap; } + @Override + public List>> getDistributionOfTeachers(TeacherDto teacherDto, HttpServletRequest request) { + + List>> distributionList = new ArrayList<>(); + Map> gradesMap = new HashMap<>(); + Map> degreesMap = new HashMap<>(); + Map> subjectsMap= new HashMap<>(); + Map> groupsMap = new HashMap<>(); + Map teachers; + //获取全学校教师名单详情 + String url = env.getProperty("ies.server-url-get-teacher-all"); + try { + teachers = GroupUtil.getGroupId(teacherDto,new GroupUtil(env), request,url); + List teachersList = new ArrayList<>(); + for (Map.Entry entry : teachers.entrySet()) { + // 假设 entry.getValue() 返回的是 List> + List> mapList = (List>) entry.getValue(); + for (Map map : mapList) { + // 将 Map 转换为 GpTeacherVo 对象 + GpTeacherVo teacher = convertToGpTeacherVo(map); + teachersList.add(teacher); + } + } + List phones = new ArrayList<>(); + // 进一步处理 teachersList + for (GpTeacherVo teacher : teachersList) { + phones.add(teacher.getPhone()); + } + GpTeacherDto gpTeacherDto = new GpTeacherDto(); + gpTeacherDto.setMobiles(phones); + Map tBase = getTeacherBase(gpTeacherDto, request); + List gpTeachers = new ArrayList<>(); + for (Map.Entry entry : tBase.entrySet()) { + if (entry.getKey().equals("teachers")) { + List> dataList = (List>) entry.getValue(); + for (Map dataMap : dataList) { + GpTeacher gpTeacher = convertToGpTeacher(dataMap); + gpTeachers.add(gpTeacher); + } + } + } + //把对应年级的信息进行映射 + List gradeList = new ArrayList<>(); + Map gradeInfo = getTeacherGradeCount(teacherDto, request); + for (Map.Entry entry : gradeInfo.entrySet()) { + if (entry.getKey().equals("teacher")) { + List> dataList = (List>) entry.getValue(); + for (Map dataMap : dataList) { + TeacherGradeVo teacherGradeVo = convertToTeacherGradeVo(dataMap); + gradeList.add(teacherGradeVo); + } + } + } + for (GpTeacherVo teacher : teachersList) { + for(GpTeacher gpTeacher : gpTeachers) { + if(StringUtils.isNotEmpty(teacher.phone) && teacher.phone.equalsIgnoreCase(gpTeacher.mobile)) { + if(gpTeacher.basic.gender != null) { + teacher.setGender(gpTeacher.basic.gender); + }else { + teacher.setGender(""); + } + if (gpTeacher.getPracticeTime() != null && gpTeacher.getPracticeTime() > 0) { + teacher.setPracticeTime(gpTeacher.getPracticeTime()); + }else { + teacher.setPracticeTime(0L); + } + if(gpTeacher.degree != null) { + teacher.setDegree(gpTeacher.degree); + }else { + teacher.setDegree(""); + } + break; + } + } + for (TeacherGradeVo grade : gradeList) { + if(teacher.getId().equals(grade.getId())) { + List grades = grade.getGrade(); + for (TeacherGradeVo.IdAndName gg : grades) { + String id = String.valueOf(teacherDto.year - gg.getGrade()); + if (teacher.grade == null) { + teacher.setGrade(new ArrayList<>()); + } + teacher.grade.add(id); + + } + } + } + } + + Map gradeCount = new HashMap<>(); + Map degreeCount = new HashMap<>(); + Map subjectCount = new HashMap<>(); + Map GroupCount = new HashMap<>(); + if(StringUtils.isNotEmpty(teacherDto.getGrade()) && StringUtils.isNotEmpty(teacherDto.getSubjectId())) { + for (GpTeacherVo teacher : teachersList) { + if(teacher.getGrade() != null &&teacher.getSubjectIds() != null &&teacher.getGrade().contains(teacherDto.getGrade()) && teacher.getSubjectIds().contains(teacherDto.getSubjectId())) { + { + Long count = gradeCount.getOrDefault(teacherDto.getGrade(), 0L); + gradeCount.put(teacherDto.getGrade(), count + 1); + } + if(StringUtils.isNotEmpty(teacher.getDegree())) { + { + Long count = degreeCount.getOrDefault(teacher.getDegree(), 0L); + degreeCount.put(teacher.getDegree(), count + 1); + } + } + { + int index = teacher.subjectIds.indexOf(teacherDto.getSubjectId()); + String name = ""; + if (index >= 0) { + name = teacher.subjectNames.get(index); + } + Long count = subjectCount.getOrDefault(name, 0L); + subjectCount.put(name, count + 1); + } + if(teacher.getGroups() != null) { + for (GpTeacherVo.IdNameCode group : teacher.getGroups()) { + Long count = GroupCount.getOrDefault(group.getName(), 0L); + GroupCount.put(group.getName(), count + 1); + } + } + } + } + }else if(StringUtils.isEmpty(teacherDto.getGrade()) && StringUtils.isNotEmpty(teacherDto.getSubjectId())) { + for (GpTeacherVo teacher : teachersList) { + if(teacher.getSubjectIds() != null && teacher.getSubjectIds().contains(teacherDto.getSubjectId())) { + if(teacher.getGrade() != null) { + for (String grade : teacher.getGrade()) { + Long count = gradeCount.getOrDefault(grade, 0L); + gradeCount.put(grade, count + 1); + } + } + if(StringUtils.isNotEmpty(teacher.getDegree())) { + { + Long count = degreeCount.getOrDefault(teacher.getDegree(), 0L); + degreeCount.put(teacher.getDegree(), count + 1); + } + } + { + int index = teacher.subjectIds.indexOf(teacherDto.getSubjectId()); + String name = ""; + if (index >= 0) { + name = teacher.subjectNames.get(index); + } + Long count = subjectCount.getOrDefault(name, 0L); + subjectCount.put(name, count + 1); + } + if(teacher.getGroups() != null) { + for (GpTeacherVo.IdNameCode group : teacher.getGroups()) { + Long count = GroupCount.getOrDefault(group.getName(), 0L); + GroupCount.put(group.getName(), count + 1); + } + } + } + } + }else if(StringUtils.isNotEmpty(teacherDto.getGrade()) && StringUtils.isEmpty(teacherDto.getSubjectId())) { + + for (GpTeacherVo teacher : teachersList) { + if(teacher.getGrade() != null && teacher.getGrade().contains(teacherDto.getGrade())) { + { + Long count = gradeCount.getOrDefault(teacherDto.getGrade(), 0L); + gradeCount.put(teacherDto.getGrade(), count + 1); + } + if(StringUtils.isNotEmpty(teacher.getDegree())) { + { + Long count = degreeCount.getOrDefault(teacher.getDegree(), 0L); + degreeCount.put(teacher.getDegree(), count + 1); + } + } + if(teacher.getSubjectIds()!= null) { + for (String subjectId : teacher.getSubjectIds()) { + int index = teacher.subjectIds.indexOf(subjectId); + String name = ""; + if (index >= 0) { + name = teacher.subjectNames.get(index); + } + Long count = subjectCount.getOrDefault(name, 0L); + subjectCount.put(name, count + 1); + } + } + if(teacher.getGroups() != null) { + for (GpTeacherVo.IdNameCode group : teacher.getGroups()) { + Long count = GroupCount.getOrDefault(group.getName(), 0L); + GroupCount.put(group.getName(), count + 1); + } + } + } + } + + }else { + for (GpTeacherVo teacher : teachersList) { + if(teacher.getGrade() != null) { + for (String grade : teacher.getGrade()) { + Long count = gradeCount.getOrDefault(grade, 0L); + gradeCount.put(grade, count + 1); + } + } + if(StringUtils.isNotEmpty(teacher.getDegree())) { + { + Long count = degreeCount.getOrDefault(teacher.getDegree(), 0L); + degreeCount.put(teacher.getDegree(), count + 1); + } + } + if(teacher.getSubjectIds()!= null) { + for (String subjectId : teacher.getSubjectIds()) { + int index = teacher.subjectIds.indexOf(subjectId); + String name = ""; + if (index >= 0) { + name = teacher.subjectNames.get(index); + } + Long count = subjectCount.getOrDefault(name, 0L); + subjectCount.put(name, count + 1); + } + } + if(teacher.getGroups() != null) { + for (GpTeacherVo.IdNameCode group : teacher.getGroups()) { + Long count = GroupCount.getOrDefault(group.getName(), 0L); + GroupCount.put(group.getName(), count + 1); + } + } + + } + } + + gradesMap.put("grade", gradeCount); + degreesMap.put("degree", degreeCount); + subjectsMap.put("subject", subjectCount); + groupsMap.put("group", GroupCount); + distributionList.add(gradesMap); + distributionList.add(degreesMap); + distributionList.add(subjectsMap); + distributionList.add(groupsMap); + + /* Map genderCount = gpTeachers.stream() + .collect(Collectors.groupingBy(gpTeacher -> gpTeacher.getBasic().getGender(), Collectors.counting())); + Map degreeCount = gpTeachers.stream() + .filter(gpTeacher -> gpTeacher.getDegree() != null) + .collect(Collectors.groupingBy(GpTeacher::getDegree, Collectors.counting()));*/ + + + + + }catch (Exception e) { + throw new ServiceException(ErrorCode.SYSTEM_ERROR.getCode(), "数据转换错误"); + + } + return distributionList; + } + public Map getTeacherBase(GpTeacherDto gpTeacherDto, HttpServletRequest request) { Map gradeMap; diff --git a/src/main/java/cn/teammodel/model/entity/school/GpTeacher.java b/src/main/java/cn/teammodel/model/entity/school/GpTeacher.java index 787b9f8..11fd9fb 100644 --- a/src/main/java/cn/teammodel/model/entity/school/GpTeacher.java +++ b/src/main/java/cn/teammodel/model/entity/school/GpTeacher.java @@ -13,6 +13,7 @@ public class GpTeacher { /// 简介 /// public String describe ; + public String id ; /// /// 描述 diff --git a/src/main/java/cn/teammodel/model/vo/admin/GpTeacherVo.java b/src/main/java/cn/teammodel/model/vo/admin/GpTeacherVo.java index af59296..526c5ee 100644 --- a/src/main/java/cn/teammodel/model/vo/admin/GpTeacherVo.java +++ b/src/main/java/cn/teammodel/model/vo/admin/GpTeacherVo.java @@ -21,6 +21,7 @@ public class GpTeacherVo { public String degree; public Long practiceTime ; public String gender ; + public List grade; @Data public static class IdNameCode{ public String id ; diff --git a/src/main/java/cn/teammodel/model/vo/admin/TeacherGradeVo.java b/src/main/java/cn/teammodel/model/vo/admin/TeacherGradeVo.java new file mode 100644 index 0000000..cf279c9 --- /dev/null +++ b/src/main/java/cn/teammodel/model/vo/admin/TeacherGradeVo.java @@ -0,0 +1,17 @@ +package cn.teammodel.model.vo.admin; + +import lombok.Data; + +import java.util.List; + +@Data +public class TeacherGradeVo { + private List grade; + private String id; + private String name; + @Data + public static class IdAndName{ + public Integer grade; + public String gradeName; + } +} From 18b0acd64898b9bf282065a5f2417e86e4d371b5 Mon Sep 17 00:00:00 2001 From: "hhb@hotmail.com" Date: Tue, 3 Dec 2024 16:38:34 +0800 Subject: [PATCH 5/8] =?UTF-8?q?update=20=E6=95=99=E5=B8=88=E5=88=86?= =?UTF-8?q?=E5=B8=83=E7=BB=9F=E8=AE=A1=E8=BF=94=E5=9B=9E=E5=80=BC=E8=B0=83?= =?UTF-8?q?=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/admin/service/impl/TeacherServiceImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 4774d95..d5d529c 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 @@ -695,7 +695,7 @@ public class TeacherServiceImpl implements TeacherService { } } - + gradeCount.keySet().removeIf(key -> key.startsWith("20")); gradesMap.put("grade", gradeCount); degreesMap.put("degree", degreeCount); subjectsMap.put("subject", subjectCount); From cd421db42b8b7b1af3870e801261427fb67f7bfa Mon Sep 17 00:00:00 2001 From: "hhb@hotmail.com" Date: Tue, 3 Dec 2024 17:09:32 +0800 Subject: [PATCH 6/8] =?UTF-8?q?update=20=E6=95=99=E5=B8=88=E5=88=86?= =?UTF-8?q?=E5=B8=83=E7=BB=9F=E8=AE=A1=E8=BF=94=E5=9B=9E=E5=80=BC=E8=B0=83?= =?UTF-8?q?=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/admin/service/impl/TeacherServiceImpl.java | 7 +++++++ src/main/java/cn/teammodel/model/vo/admin/GpTeacherVo.java | 1 + .../java/cn/teammodel/model/vo/admin/TeacherGradeVo.java | 1 + 3 files changed, 9 insertions(+) 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 d5d529c..826882b 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 @@ -257,6 +257,7 @@ public class TeacherServiceImpl implements TeacherService { TeacherGradeVo teacher = new TeacherGradeVo(); teacher.setName((String) map.get("name")); teacher.setId((String) map.get("tmdId")); + teacher.setPeriodId((String) map.get("periodId")); // 处理 grade 字段 List> gradeList = (List>) map.get("grade"); if (gradeList != null) { @@ -548,6 +549,9 @@ public class TeacherServiceImpl implements TeacherService { } for (TeacherGradeVo grade : gradeList) { if(teacher.getId().equals(grade.getId())) { + if(StringUtils.isNotEmpty(grade.getPeriodId())) { + teacher.setPeriodId(grade.getPeriodId()); + } List grades = grade.getGrade(); for (TeacherGradeVo.IdAndName gg : grades) { String id = String.valueOf(teacherDto.year - gg.getGrade()); @@ -561,6 +565,9 @@ public class TeacherServiceImpl implements TeacherService { } } + teachersList = teachersList.stream() + .filter(teacher -> teacherDto.periodId.equals(teacher.getPeriodId())) + .collect(Collectors.toList()); Map gradeCount = new HashMap<>(); Map degreeCount = new HashMap<>(); Map subjectCount = new HashMap<>(); diff --git a/src/main/java/cn/teammodel/model/vo/admin/GpTeacherVo.java b/src/main/java/cn/teammodel/model/vo/admin/GpTeacherVo.java index 526c5ee..efd5d6b 100644 --- a/src/main/java/cn/teammodel/model/vo/admin/GpTeacherVo.java +++ b/src/main/java/cn/teammodel/model/vo/admin/GpTeacherVo.java @@ -22,6 +22,7 @@ public class GpTeacherVo { public Long practiceTime ; public String gender ; public List grade; + public String periodId ; @Data public static class IdNameCode{ public String id ; diff --git a/src/main/java/cn/teammodel/model/vo/admin/TeacherGradeVo.java b/src/main/java/cn/teammodel/model/vo/admin/TeacherGradeVo.java index cf279c9..6efb10e 100644 --- a/src/main/java/cn/teammodel/model/vo/admin/TeacherGradeVo.java +++ b/src/main/java/cn/teammodel/model/vo/admin/TeacherGradeVo.java @@ -9,6 +9,7 @@ public class TeacherGradeVo { private List grade; private String id; private String name; + private String periodId; @Data public static class IdAndName{ public Integer grade; From 13d095d02ba18c1afd44a2f24f35bb4f4825e304 Mon Sep 17 00:00:00 2001 From: "hhb@hotmail.com" Date: Tue, 3 Dec 2024 18:04:42 +0800 Subject: [PATCH 7/8] =?UTF-8?q?update=20=E6=95=99=E5=B8=88=E5=88=86?= =?UTF-8?q?=E5=B8=83=E7=BB=9F=E8=AE=A1=E7=A9=BA=E6=8C=87=E9=92=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/admin/service/impl/TeacherServiceImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 826882b..3443214 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 @@ -548,7 +548,7 @@ public class TeacherServiceImpl implements TeacherService { } } for (TeacherGradeVo grade : gradeList) { - if(teacher.getId().equals(grade.getId())) { + if(StringUtils.isNotEmpty(teacher.getId()) && teacher.getId().equals(grade.getId())) { if(StringUtils.isNotEmpty(grade.getPeriodId())) { teacher.setPeriodId(grade.getPeriodId()); } From 128a05e90afa44dfa57f7895a9d9a12b5769eaae Mon Sep 17 00:00:00 2001 From: "hhb@hotmail.com" Date: Wed, 4 Dec 2024 18:06:11 +0800 Subject: [PATCH 8/8] =?UTF-8?q?update=20=E8=B0=83=E6=95=B4=E5=8F=82?= =?UTF-8?q?=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/service/impl/CommonServiceImpl.java | 21 +++++++++++++++---- .../model/dto/admin/common/GCDto.java | 1 + .../model/dto/admin/teacher/TeacherDto.java | 1 + 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/src/main/java/cn/teammodel/controller/admin/service/impl/CommonServiceImpl.java b/src/main/java/cn/teammodel/controller/admin/service/impl/CommonServiceImpl.java index 439bc32..7d1a810 100644 --- a/src/main/java/cn/teammodel/controller/admin/service/impl/CommonServiceImpl.java +++ b/src/main/java/cn/teammodel/controller/admin/service/impl/CommonServiceImpl.java @@ -12,11 +12,14 @@ import cn.teammodel.repository.CommentRepository; import cn.teammodel.repository.SchoolRepository; import cn.teammodel.utils.MonthToNumberConverter; import com.azure.cosmos.models.PartitionKey; +import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Service; import javax.annotation.Resource; import java.time.Instant; +import java.time.LocalDate; import java.time.Month; +import java.time.ZoneId; import java.util.ArrayList; import java.util.List; @@ -38,10 +41,20 @@ public class CommonServiceImpl implements CommonService { //获取当前学校该学段下详细信息 List period = schoolRepository.findPeriodById(gcDto.getSchoolId(), gcDto.getPeriodId()); List classes = classRepository.findClassBySchoolIdAndPeriodId(gcDto.getPeriodId()); - int year = now().getYear(); - Month month = now().getMonth(); - int mon = MonthToNumberConverter.convertMonthToNumber(month.name()); - int day = now().getDayOfMonth(); + int year = 0; + int mon = 0; + int day = 0; + if (gcDto.getTime() != null && gcDto.getTime() != 0L) { + LocalDate date = Instant.ofEpochMilli(gcDto.getTime()).atZone(ZoneId.systemDefault()).toLocalDate(); + year = date.getYear(); + mon = date.getMonthValue(); + day = date.getDayOfMonth(); + }else { + year = now().getYear(); + Month month = now().getMonth(); + mon = MonthToNumberConverter.convertMonthToNumber(month.name()); + day = now().getDayOfMonth(); + } //处理年级ID for (ClassInfo classInfo : classes) { if(period.get(0).getId().equalsIgnoreCase(classInfo.getPeriodId())) { diff --git a/src/main/java/cn/teammodel/model/dto/admin/common/GCDto.java b/src/main/java/cn/teammodel/model/dto/admin/common/GCDto.java index d3afa41..22c8955 100644 --- a/src/main/java/cn/teammodel/model/dto/admin/common/GCDto.java +++ b/src/main/java/cn/teammodel/model/dto/admin/common/GCDto.java @@ -6,4 +6,5 @@ import lombok.Data; public class GCDto { private String schoolId; private String periodId; + private Long time; } diff --git a/src/main/java/cn/teammodel/model/dto/admin/teacher/TeacherDto.java b/src/main/java/cn/teammodel/model/dto/admin/teacher/TeacherDto.java index 86e1c2d..211e1ad 100644 --- a/src/main/java/cn/teammodel/model/dto/admin/teacher/TeacherDto.java +++ b/src/main/java/cn/teammodel/model/dto/admin/teacher/TeacherDto.java @@ -20,4 +20,5 @@ public class TeacherDto { public String grade; @ApiModelProperty("科目信息") public String subjectId; + public String semesterId; }