From 5ad0c6479e120f7d611245834ed3702f367a9696 Mon Sep 17 00:00:00 2001 From: pd <2776455882@qq.com> Date: Wed, 5 Aug 2020 17:27:18 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AD=A6=E7=94=9F=E7=AB=AF=E3=80=81=E6=95=99?= =?UTF-8?q?=E5=B8=88=E7=AB=AF=E5=AE=9E=E9=AA=8C=E5=AD=A6=E4=B9=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ExperimentalClassController.java | 1 - .../ExperimentallearningController.java | 49 +- .../ProjectAndCourseController.java | 47 +- .../liuwanr/entity/Project_Management.java | 17 +- .../mapper/ExperimentallearningMapper.java | 40 +- .../mapper/TeacherProjectAndCourseMapper.java | 45 +- .../service/ExperimentalClassService.java | 526 +++++++++--------- .../service/ExperimentallearningService.java | 41 +- .../service/ProjectAndCourseService.java | 21 +- .../yipin/liuwanr/vo/CourseAndProjectVo.java | 34 ++ 10 files changed, 477 insertions(+), 344 deletions(-) create mode 100644 src/main/java/com/yipin/liuwanr/vo/CourseAndProjectVo.java diff --git a/src/main/java/com/yipin/liuwanr/controller/ExperimentalClassController.java b/src/main/java/com/yipin/liuwanr/controller/ExperimentalClassController.java index 350133c..3f945e5 100644 --- a/src/main/java/com/yipin/liuwanr/controller/ExperimentalClassController.java +++ b/src/main/java/com/yipin/liuwanr/controller/ExperimentalClassController.java @@ -48,7 +48,6 @@ public class ExperimentalClassController { /** * 查询实验班级 - * @param experimentalClassId * @return */ @GetMapping("/queryExperimentalClass") diff --git a/src/main/java/com/yipin/liuwanr/controller/ExperimentallearningController.java b/src/main/java/com/yipin/liuwanr/controller/ExperimentallearningController.java index 38f827b..abdde49 100644 --- a/src/main/java/com/yipin/liuwanr/controller/ExperimentallearningController.java +++ b/src/main/java/com/yipin/liuwanr/controller/ExperimentallearningController.java @@ -72,9 +72,13 @@ public class ExperimentallearningController { * 获取教师信息 */ @GetMapping("/queryTeacherName") - Response queryTeacherName(@RequestParam Integer courseId) { + Response queryTeacherName(@RequestParam Integer courseId,@RequestParam Integer studentId) { Response resp = new Response(); - HashMap ret = service.queryTeacherName(courseId); + if(StringUtils.isEmpty(studentId)){ + resp.setStatus(300); + resp.setErrmessage("学生信息为空"); + }else{ + HashMap ret = service.queryTeacherName(courseId,studentId); int status = (int) ret.get("retcode"); if (status == 200) { resp.setStatus(status); @@ -83,6 +87,7 @@ public class ExperimentallearningController { resp.setStatus(status); resp.setErrmessage(ret.get("retvalue").toString()); } + } return resp; } @@ -92,16 +97,21 @@ public class ExperimentallearningController { * 获取学生信息 */ @GetMapping("/queryStudentName") - Response queryStudentName(@RequestParam Integer courseId) { + Response queryStudentName(@RequestParam Integer courseId,@RequestParam Integer studentId) { Response resp = new Response(); - HashMap ret = service.queryStudentName(courseId); - int status = (int) ret.get("retcode"); - if (status == 200) { - resp.setStatus(status); - resp.setMessage(ret.get("retvalue")); - } else { + if(StringUtils.isEmpty(studentId)){ + resp.setStatus(300); + resp.setErrmessage("学生信息为空"); + }else{ + HashMap ret = service.queryStudentName(courseId,studentId); + int status = (int) ret.get("retcode"); + if (status == 200) { + resp.setStatus(status); + resp.setMessage(ret.get("retvalue")); + } else { resp.setStatus(status); resp.setErrmessage(ret.get("retvalue").toString()); + } } return resp; } @@ -128,5 +138,26 @@ public class ExperimentallearningController { } return resp; } + + @GetMapping("/queryStudentCourse") + Response queryStudentCourse(@RequestParam Integer studentId) { + Response resp = new Response(); + if(StringUtils.isEmpty(studentId)){ + resp.setStatus(300); + resp.setMessage("学生信息为空"); + }else { + HashMap ret = service.queryStudentCourse(studentId); + int status = (int) ret.get("retcode"); + if (status == 200) { + resp.setStatus(status); + resp.setMessage(ret.get("retvalue")); + } else { + resp.setStatus(status); + resp.setErrmessage(ret.get("retvalue").toString()); + } + } + return resp; + } + } diff --git a/src/main/java/com/yipin/liuwanr/controller/ProjectAndCourseController.java b/src/main/java/com/yipin/liuwanr/controller/ProjectAndCourseController.java index f7b65c0..7267c66 100644 --- a/src/main/java/com/yipin/liuwanr/controller/ProjectAndCourseController.java +++ b/src/main/java/com/yipin/liuwanr/controller/ProjectAndCourseController.java @@ -2,6 +2,7 @@ package com.yipin.liuwanr.controller; import java.util.HashMap; +import com.yipin.liuwanr.vo.CourseAndProjectVo; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.util.StringUtils; import org.springframework.web.bind.annotation.GetMapping; @@ -28,34 +29,38 @@ public class ProjectAndCourseController { * @return */ @GetMapping("/queryProject") - Response queryProject(Integer courseId) { + Response queryProject(Integer courseId,Integer experimentalClassId) { Response resp = new Response(); - HashMap ret = service.queryProject(courseId); - int status = (int) ret.get("retcode"); - if (status == 200) { - resp.setStatus(status); - resp.setMessage(ret.get("retvalue")); - } else { - resp.setStatus(status); - resp.setErrmessage(ret.get("retvalue").toString()); + if(StringUtils.isEmpty(experimentalClassId)){ + resp.setStatus(300); + resp.setErrmessage("实验班级信息为空"); + }else { + HashMap ret = service.queryProject(courseId,experimentalClassId); + int status = (int) ret.get("retcode"); + if (status == 200) { + resp.setStatus(status); + resp.setMessage(ret.get("retvalue")); + } else { + resp.setStatus(status); + resp.setErrmessage(ret.get("retvalue").toString()); + } } return resp; } /** * 修改项目状态 - * @param management * @return */ @PostMapping("/updateIsExperiment") - Response updateIsExperiment(@RequestBody Project_Management management) { + Response updateIsExperiment(@RequestBody CourseAndProjectVo vo) { Response resp = new Response(); - if(null==management) { + if(null==vo) { resp.setStatus(300); resp.setErrmessage("management Is null"); return resp; }else { - HashMap ret = service.updateIsExperiment(management); + HashMap ret = service.updateIsExperiment(vo); int status = (int) ret.get("retcode"); if (status == 200) { resp.setStatus(status); @@ -70,18 +75,17 @@ public class ProjectAndCourseController { /** * 修改考勤状态 - * @param management * @return */ @PostMapping("/updateIsAttendance") - Response updateIsAttendance(@RequestBody Project_Management management) { + Response updateIsAttendance(@RequestBody CourseAndProjectVo vo) { Response resp = new Response(); - if(null==management) { + if(null==vo) { resp.setStatus(300); resp.setErrmessage("management Is null"); return resp; }else { - HashMap ret = service.updateIsAttendance(management); + HashMap ret = service.updateIsAttendance(vo); int status = (int) ret.get("retcode"); if (status == 200) { resp.setStatus(status); @@ -96,9 +100,13 @@ public class ProjectAndCourseController { //课程进度 @GetMapping("/getCourseSchedule") - Response getCourseSchedule(Integer courseId) { + Response getCourseSchedule(Integer courseId,Integer experimentalClassId) { Response resp = new Response(); - HashMap ret = service.getCourseSchedule(courseId); + if(StringUtils.isEmpty(experimentalClassId)){ + resp.setStatus(300); + resp.setErrmessage("实验班级为空"); + }else{ + HashMap ret = service.getCourseSchedule(courseId,experimentalClassId); int status = (int) ret.get("retcode"); if (status == 200) { resp.setStatus(status); @@ -107,6 +115,7 @@ public class ProjectAndCourseController { resp.setStatus(status); resp.setErrmessage(ret.get("retvalue").toString()); } + } return resp; } } diff --git a/src/main/java/com/yipin/liuwanr/entity/Project_Management.java b/src/main/java/com/yipin/liuwanr/entity/Project_Management.java index 15b7598..49dff99 100644 --- a/src/main/java/com/yipin/liuwanr/entity/Project_Management.java +++ b/src/main/java/com/yipin/liuwanr/entity/Project_Management.java @@ -24,7 +24,7 @@ public class Project_Management { private Integer isShow; private Integer isstartexperimental; private Integer isstartexperimentSuggests; - private Integer isExperiment; + private Integer isOpenProject; private Integer isAttendance; private Integer signin;//是否签到 @@ -167,14 +167,6 @@ public class Project_Management { this.systemId = systemId; } - public Integer getIsExperiment() { - return isExperiment; - } - - public void setIsExperiment(Integer isExperiment) { - this.isExperiment = isExperiment; - } - public Integer getIsAttendance() { return isAttendance; } @@ -183,4 +175,11 @@ public class Project_Management { this.isAttendance = isAttendance; } + public Integer getIsOpenProject() { + return isOpenProject; + } + + public void setIsOpenProject(Integer isOpenProject) { + this.isOpenProject = isOpenProject; + } } diff --git a/src/main/java/com/yipin/liuwanr/mapper/ExperimentallearningMapper.java b/src/main/java/com/yipin/liuwanr/mapper/ExperimentallearningMapper.java index 82c6b71..f5710c4 100644 --- a/src/main/java/com/yipin/liuwanr/mapper/ExperimentallearningMapper.java +++ b/src/main/java/com/yipin/liuwanr/mapper/ExperimentallearningMapper.java @@ -2,14 +2,12 @@ package com.yipin.liuwanr.mapper; import java.util.List; +import com.yipin.liuwanr.entity.*; import org.apache.ibatis.annotations.Insert; +import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Select; import org.apache.ibatis.annotations.Update; -import com.yipin.liuwanr.entity.Assesment; -import com.yipin.liuwanr.entity.Attendance; -import com.yipin.liuwanr.entity.Student; - /** * 学生_实验学习 * @author 86151 @@ -63,22 +61,31 @@ public interface ExperimentallearningMapper { + "values (#{courseId},#{experimentId},now(),#{signIn},#{studentId})") void insertAttendance(Attendance attendance); - + + /** + * 获取实验班级信息 + * @param courseId + * @param studentId + * @return + */ + @Select("select ecn.experimentalClassId from experimental_class_ning ecn left join experimental_class_student ecs on ecn.experimentalClassId=ecs.experimentalClassId where\n" + + "ecn.courseId=#{courseId} and ecs.studentId=#{studentId} GROUP BY ecn.experimentalClassId") + Integer queryExperimentalClassId(@Param("courseId") Integer courseId,@Param("studentId")Integer studentId); + /** * 授课老师信息 - * @param courseid * @return */ - @Select("select staffName from staff where staffId =(select staffId from course where courseId=#{courseid})") - String queryTeacherName(Integer courseid); + @Select("select name,userAvatars from experimental_class_ning ecs left join user u on ecs.userId=u.userId where ecs.experimentalClassId=#{experimentalClassId}") + UserM queryTeacherName(Integer experimentalClassId); /** * 多名学生信息展示 - * @param courseId * @return */ - @Select("select studentName from student where FIND_IN_SET(#{courseId},courseId) > 0 ") - List queryStudentName(Integer courseId); + @Select("select name,userAvatars from user u left join student s on (u.phone=s.phone and u.uniqueIdentificationAccount=s.uniqueIdentificationAccount) left join experimental_class_student ecs " + + " on s.studentId=ecs.studentId where ecs.experimentalClassId=#{experimentalClassId} GROUP BY u.userId") + List queryStudentName(Integer experimentalClassId); /** @@ -107,4 +114,15 @@ public interface ExperimentallearningMapper { */ @Select("select studentId from record where assesmentId=#{assesmentId}") List queryStudentId(Integer assesmentId); + + + @Select("select c.courseId,c.courseName from course c left join experimental_class_ning ecn on c.courseId=ecn.courseId left join experimental_class_student ecs " + + " on ecn.experimentalClassId=ecs.experimentalClassId where ecn.isdel=0 and c.isdel=0 and ecs.studentId=#{StudentId} GROUP BY c.courseId") + List queryStudentCourse(Integer StudentId); + + + + @Select("select DISTINCT hpm.projectId,projectName,isAttendance from hr_project_management hpm left join teacher_project tp on hpm.projectId=tp.projectId " + + " where tp.courseId=#{courseId} and tp.experimentalClassId=#{experimentalClassId} and tp.isOpenProject=0") + List getBycourseId(@Param("experimentalClassId")Integer experimentalClassId,@Param("courseId") Integer courseId); } diff --git a/src/main/java/com/yipin/liuwanr/mapper/TeacherProjectAndCourseMapper.java b/src/main/java/com/yipin/liuwanr/mapper/TeacherProjectAndCourseMapper.java index fe96976..6df5f43 100644 --- a/src/main/java/com/yipin/liuwanr/mapper/TeacherProjectAndCourseMapper.java +++ b/src/main/java/com/yipin/liuwanr/mapper/TeacherProjectAndCourseMapper.java @@ -2,6 +2,8 @@ package com.yipin.liuwanr.mapper; import java.util.List; +import com.yipin.liuwanr.vo.CourseAndProjectVo; +import org.apache.ibatis.annotations.Insert; import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Select; import org.apache.ibatis.annotations.Update; @@ -18,29 +20,42 @@ public interface TeacherProjectAndCourseMapper { /** * 查询实验项目信息 */ - @Select({""}) - List getBySystemId(@Param("courseId") Integer courseId,@Param("isExperiment")Integer isExperiment,@Param("isAttendance")Integer isAttendance); +// @Select({""}) + + @Select("select DISTINCT hpm.projectId,projectName,isOpenProject,isAttendance from hr_project_management hpm left join teacher_project tp on hpm.projectId=tp.projectId " + + " where tp.courseId=#{courseId} and tp.experimentalClassId=#{experimentalClassId}") + List getBySystemId(@Param("courseId") Integer courseId,@Param("experimentalClassId")Integer experimentalClassId); + /** * 修改是否开启项目 - * @param management */ - @Update("update hr_project_management set isExperiment=#{isExperiment} where projectId=#{projectId}") - void updateIsExperiment(Project_Management management); - + @Update("update teacher_project set isOpenProject=#{project.isOpenProject} where courseId=#{courseId} and experimentalClassId=#{experimentalClassId} and projectId=#{project.projectId}") + void updateIsExperiment(CourseAndProjectVo vo); + /** * 修改是否开启考勤 - * @param management */ - @Update("update hr_project_management set isAttendance=#{isAttendance} where projectId=#{projectId}") - void updateIsAttendance(Project_Management management); + @Update("update teacher_project set isAttendance=#{project.isAttendance} where courseId=#{courseId} and experimentalClassId=#{experimentalClassId} and projectId=#{project.projectId}") + void updateIsAttendance(CourseAndProjectVo vo); @Select("select count(*) from hr_course_schedule where courseId=#{courseId}") Integer getCourseSchedule(Integer courseId); - + + @Select("select DISTINCT tc.projectId from hr_course_tc tc left join hr_project_management pm on tc.projectId=pm.projectId where tc.courseId=#{courseId} and pm.projectPermissions=0 ") + List queryProject(Integer courseId); + + @Insert({""}) + void addBatchTeachProject(@Param("experimentalClassId") Integer experimentalClassId,@Param("courseId") Integer courseId,@Param("projectIds") List projectIds); + } diff --git a/src/main/java/com/yipin/liuwanr/service/ExperimentalClassService.java b/src/main/java/com/yipin/liuwanr/service/ExperimentalClassService.java index d6d7b05..f19025f 100644 --- a/src/main/java/com/yipin/liuwanr/service/ExperimentalClassService.java +++ b/src/main/java/com/yipin/liuwanr/service/ExperimentalClassService.java @@ -19,267 +19,275 @@ import com.yipin.liuwanr.vo.ExperimentalClassVo; @Service public class ExperimentalClassService { - - private static Logger logger = Logger.getLogger(ExperimentalClassService.class); - - @Autowired - private ExperimentalClassMapper experimentalClassMapper; - @Autowired - private TeacherProjectAndCourseMapper projectAndCourseMapper; + private static Logger logger = Logger.getLogger(ExperimentalClassService.class); - //实验班级添加学生 - public HashMap experimentClassAddStudent(List studentList){ - HashMap resp = new HashMap(); - Integer size = studentList.size(); - try { - for (int i = 0; i < size; i++) { - Student student = studentList.get(i); - Integer studentId = student.getStudentId(); - String experimentalClassId = student.getExperimentalClassId(); - if (studentId == null){ - resp.put("retcode", 300); - resp.put("retvalue", "学生为空!"); - }else if (experimentalClassId==null||experimentalClassId==""){ - resp.put("retcode", 300); - resp.put("retvalue", "实验班级为空!"); - }else{ - experimentalClassMapper.experimentClassAddStudent(student); - resp.put("retcode", 200); - } - } - } catch (RuntimeException e) { - logger.error(e.getMessage()); - resp.put("retcode", 500); - resp.put("retvalue", "添加学生失败!"); - return resp; - } - return resp; - } - - //实验班级删除学生 - public HashMap experimentClassDeleteStudent(List student){ - HashMap resp = new HashMap(); - try { - for (int i = 0; i < student.size(); i++) { - Student stu = student.get(i); - experimentalClassMapper.experimentClassDeleteStudent(stu); - } - resp.put("retcode", 200); - } catch (RuntimeException e) { - logger.error(e.getMessage()); - resp.put("retcode", 500); - resp.put("retvalue", "删除学生失败"); - return resp; - } - return resp; - } - - //创建实验班级 - public HashMap addExperimentalClass(ExperimentalClass experimentalClass){ - HashMap resp = new HashMap(); - try { - experimentalClassMapper.addExperimentalClass(experimentalClass); - resp.put("retcode", 200); - } catch (RuntimeException e) { - logger.error(e.getMessage()); - resp.put("retcode", 500); - resp.put("retvalue", "创建实验班级失败!"); - throw e; - } - return resp; - } - - public HashMap queryExperimentalClass(Integer schoolId){ - HashMap resp = new HashMap(); - try { - resp.put("retvalue", experimentalClassMapper.queryExperimentalClass(schoolId)); -// List a = experimentalClassMapper.queryExperimentalClass(schoolId); - resp.put("retcode", 200); - } catch (RuntimeException e) { - logger.error(e.getMessage()); - resp.put("retcode", 500); - resp.put("retvalue", "查询实验班级失败!"); - return resp; - } - return resp; - } - - //查询实验班级专业 - public HashMap queryExperimentalClassSP(Integer experimentalClassId){ - HashMap resp = new HashMap(); - try { - resp.put("retvalue", experimentalClassMapper.queryExperimentalClassSP(experimentalClassId)); - resp.put("retcode", 200); - } catch (RuntimeException e) { - logger.error(e.getMessage()); - resp.put("retcode", 500); - resp.put("retvalue", "查询实验班级专业失败!"); - return resp; - } - return resp; - } - - //查询学生行政班级 - public HashMap queryStudentClass(Integer experimentalClassId){ - HashMap resp = new HashMap(); - try { - resp.put("retvalue", experimentalClassMapper.queryStudentClass(experimentalClassId)); - resp.put("retcode", 200); - } catch (RuntimeException e) { - logger.error(e.getMessage()); - resp.put("retcode", 500); - resp.put("retvalue", "查询学生行政班级失败!"); - return resp; - } - return resp; - } - - /** - * 班级详情 - * @param student - * @param courseId - * @return - */ - public HashMap queryExperimentalClassDetails(Student student,Integer courseId){ - HashMap resp = new HashMap(); - try { - //学生信息 - List students=experimentalClassMapper.getExperimentalClassDetails(student); - //考勤数量 - List project=projectAndCourseMapper.getBySystemId(courseId,0,0); - int denominator=project.size(); - for (int i = 0; i < students.size(); i++) { - Student stu=students.get(i); - Integer studentId=stu.getStudentId(); - int molecule=experimentalClassMapper.getAttendance(studentId, courseId); - stu.setAttendance(molecule+"/"+denominator); - } - resp.put("retvalue", students); - resp.put("retcode", 200); - } catch (RuntimeException e) { - logger.error(e.getMessage()); - resp.put("retcode", 500); - resp.put("retvalue", "查询班级详情失败!"); - return resp; - } - return resp; - } + @Autowired + private ExperimentalClassMapper experimentalClassMapper; - - //新增学生显示数据 - public HashMap queryexperimentalClass(Integer experimentalClassId){ - HashMap resp = new HashMap(); - HashMap obj=new HashMap(); - try { - List classes=experimentalClassMapper.queryExperimentalClassDetails1(experimentalClassId); - List students=experimentalClassMapper.querystudent(experimentalClassId); - obj.put("experimentalClass", classes); - obj.put("students", students); - - resp.put("retvalue", obj); - resp.put("retcode", 200); - } catch (RuntimeException e) { - logger.error(e.getMessage()); - resp.put("retcode", 500); - resp.put("retvalue", "查询失败!"); - return resp; - } - return resp; - } - - - - //专业下拉框 - public HashMap getProfessionals(Integer experimentalClassId){ - HashMap resp = new HashMap(); - try { - List professionals=experimentalClassMapper.getProfessionals(experimentalClassId); - resp.put("retvalue", professionals); - resp.put("retcode", 200); - } catch (RuntimeException e) { - logger.error(e.getMessage()); - resp.put("retcode", 500); - resp.put("retvalue", "查询专业失败!"); - return resp; - } - return resp; - } - - - //班级下拉框 - public HashMap getStudentClass(Integer experimentalClassId){ - HashMap resp = new HashMap(); - try { - List professionals=experimentalClassMapper.getStudentClass(experimentalClassId); - resp.put("retvalue", professionals); - resp.put("retcode", 200); - } catch (RuntimeException e) { - logger.error(e.getMessage()); - resp.put("retcode", 500); - resp.put("retvalue", "查询班级失败!"); - return resp; - } - return resp; - } - - - - public HashMap deleteExperimentalClass(Integer experimentalClassId){ - HashMap resp = new HashMap(); - try { - experimentalClassMapper.deleteExperimentalClass(experimentalClassId); - resp.put("retcode", 200); - } catch (RuntimeException e) { - logger.error(e.getMessage()); - resp.put("retcode", 500); - resp.put("retvalue", "删除实验班级失败!"); - return resp; - } - return resp; - } - - public HashMap updateExperimentalClass(ExperimentalClass experimentalClass){ - HashMap resp = new HashMap(); - try { - experimentalClassMapper.updateExperimentalClass(experimentalClass); - resp.put("retcode", 200); - } catch (RuntimeException e) { - logger.error(e.getMessage()); - resp.put("retcode", 500); - resp.put("retvalue", "更新实验班级失败!"); - return resp; - } - return resp; - } - - //修改实验班级名称 - public HashMap updateExperimentClassName(ExperimentalClass experimentalClass){ - HashMap resp = new HashMap(); - try { - experimentalClassMapper.updateExperimentClassName(experimentalClass); - resp.put("retcode", 200); - } catch (RuntimeException e) { - logger.error(e.getMessage()); - resp.put("retcode", 500); - resp.put("retvalue", "修改实验班级名称失败!"); - return resp; - } - return resp; -} -//——————————————————————————————全承珠 - public HashMap queryGetByExperimentalClassName(String experimentalClassName){ - HashMap resp = new HashMap(); + @Autowired + private TeacherProjectAndCourseMapper projectAndCourseMapper; + + //实验班级添加学生 + public HashMap experimentClassAddStudent(List studentList) { + HashMap resp = new HashMap(); + Integer size = studentList.size(); + try { + for (int i = 0; i < size; i++) { + Student student = studentList.get(i); + Integer studentId = student.getStudentId(); + String experimentalClassId = student.getExperimentalClassId(); + if (studentId == null) { + resp.put("retcode", 300); + resp.put("retvalue", "学生为空!"); + } else if (experimentalClassId == null || experimentalClassId == "") { + resp.put("retcode", 300); + resp.put("retvalue", "实验班级为空!"); + } else { + experimentalClassMapper.experimentClassAddStudent(student); + resp.put("retcode", 200); + } + } + } catch (RuntimeException e) { + logger.error(e.getMessage()); + resp.put("retcode", 500); + resp.put("retvalue", "添加学生失败!"); + return resp; + } + return resp; + } + + //实验班级删除学生 + public HashMap experimentClassDeleteStudent(List student) { + HashMap resp = new HashMap(); + try { + for (int i = 0; i < student.size(); i++) { + Student stu = student.get(i); + experimentalClassMapper.experimentClassDeleteStudent(stu); + } + resp.put("retcode", 200); + } catch (RuntimeException e) { + logger.error(e.getMessage()); + resp.put("retcode", 500); + resp.put("retvalue", "删除学生失败"); + return resp; + } + return resp; + } + + //创建实验班级 + public HashMap addExperimentalClass(ExperimentalClass experimentalClass) { + HashMap resp = new HashMap(); + try { + experimentalClassMapper.addExperimentalClass(experimentalClass); + + //给实验班级绑定项目 + Integer experimentalClassId = experimentalClass.getExperimentalClassId(); + Integer courseId = experimentalClass.getCourseId(); + List projectIds = projectAndCourseMapper.queryProject(courseId); + projectAndCourseMapper.addBatchTeachProject(experimentalClassId,courseId,projectIds); + + resp.put("retcode", 200); + } catch (RuntimeException e) { + logger.error(e.getMessage()); + resp.put("retcode", 500); + resp.put("retvalue", "创建实验班级失败!"); + throw e; + } + return resp; + } + + public HashMap queryExperimentalClass(Integer schoolId) { + HashMap resp = new HashMap(); + try { + resp.put("retvalue", experimentalClassMapper.queryExperimentalClass(schoolId)); + List a = experimentalClassMapper.queryExperimentalClass(schoolId); + resp.put("retcode", 200); + } catch (RuntimeException e) { + logger.error(e.getMessage()); + resp.put("retcode", 500); + resp.put("retvalue", "查询实验班级失败!"); + return resp; + } + return resp; + } + + //查询实验班级专业 + public HashMap queryExperimentalClassSP(Integer experimentalClassId) { + HashMap resp = new HashMap(); + try { + resp.put("retvalue", experimentalClassMapper.queryExperimentalClassSP(experimentalClassId)); + resp.put("retcode", 200); + } catch (RuntimeException e) { + logger.error(e.getMessage()); + resp.put("retcode", 500); + resp.put("retvalue", "查询实验班级专业失败!"); + return resp; + } + return resp; + } + + //查询学生行政班级 + public HashMap queryStudentClass(Integer experimentalClassId) { + HashMap resp = new HashMap(); + try { + resp.put("retvalue", experimentalClassMapper.queryStudentClass(experimentalClassId)); + resp.put("retcode", 200); + } catch (RuntimeException e) { + logger.error(e.getMessage()); + resp.put("retcode", 500); + resp.put("retvalue", "查询学生行政班级失败!"); + return resp; + } + return resp; + } + + /** + * 班级详情 + * + * @param student + * @param courseId + * @return + */ + public HashMap queryExperimentalClassDetails(Student student, Integer courseId) { + HashMap resp = new HashMap(); + try { + Integer experimentalClassId = Integer.parseInt(student.getExperimentalClassId()); + //学生信息 + List students = experimentalClassMapper.getExperimentalClassDetails(student); + //考勤数量 + List project = projectAndCourseMapper.getBySystemId(courseId, experimentalClassId); + int denominator = project.size(); + for (int i = 0; i < students.size(); i++) { + Student stu = students.get(i); + Integer studentId = stu.getStudentId(); + int molecule = experimentalClassMapper.getAttendance(studentId, courseId); + stu.setAttendance(molecule + "/" + denominator); + } + resp.put("retvalue", students); + resp.put("retcode", 200); + } catch (RuntimeException e) { + logger.error(e.getMessage()); + resp.put("retcode", 500); + resp.put("retvalue", "查询班级详情失败!"); + return resp; + } + return resp; + } + + + //新增学生显示数据 + public HashMap queryexperimentalClass(Integer experimentalClassId) { + HashMap resp = new HashMap(); + HashMap obj = new HashMap(); + try { + List classes = experimentalClassMapper.queryExperimentalClassDetails1(experimentalClassId); + List students = experimentalClassMapper.querystudent(experimentalClassId); + obj.put("experimentalClass", classes); + obj.put("students", students); + + resp.put("retvalue", obj); + resp.put("retcode", 200); + } catch (RuntimeException e) { + logger.error(e.getMessage()); + resp.put("retcode", 500); + resp.put("retvalue", "查询失败!"); + return resp; + } + return resp; + } + + + //专业下拉框 + public HashMap getProfessionals(Integer experimentalClassId) { + HashMap resp = new HashMap(); + try { + List professionals = experimentalClassMapper.getProfessionals(experimentalClassId); + resp.put("retvalue", professionals); + resp.put("retcode", 200); + } catch (RuntimeException e) { + logger.error(e.getMessage()); + resp.put("retcode", 500); + resp.put("retvalue", "查询专业失败!"); + return resp; + } + return resp; + } + + + //班级下拉框 + public HashMap getStudentClass(Integer experimentalClassId) { + HashMap resp = new HashMap(); + try { + List professionals = experimentalClassMapper.getStudentClass(experimentalClassId); + resp.put("retvalue", professionals); + resp.put("retcode", 200); + } catch (RuntimeException e) { + logger.error(e.getMessage()); + resp.put("retcode", 500); + resp.put("retvalue", "查询班级失败!"); + return resp; + } + return resp; + } + + + public HashMap deleteExperimentalClass(Integer experimentalClassId) { + HashMap resp = new HashMap(); + try { + experimentalClassMapper.deleteExperimentalClass(experimentalClassId); + resp.put("retcode", 200); + } catch (RuntimeException e) { + logger.error(e.getMessage()); + resp.put("retcode", 500); + resp.put("retvalue", "删除实验班级失败!"); + return resp; + } + return resp; + } + + public HashMap updateExperimentalClass(ExperimentalClass experimentalClass) { + HashMap resp = new HashMap(); + try { + experimentalClassMapper.updateExperimentalClass(experimentalClass); + resp.put("retcode", 200); + } catch (RuntimeException e) { + logger.error(e.getMessage()); + resp.put("retcode", 500); + resp.put("retvalue", "更新实验班级失败!"); + return resp; + } + return resp; + } + + //修改实验班级名称 + public HashMap updateExperimentClassName(ExperimentalClass experimentalClass) { + HashMap resp = new HashMap(); + try { + experimentalClassMapper.updateExperimentClassName(experimentalClass); + resp.put("retcode", 200); + } catch (RuntimeException e) { + logger.error(e.getMessage()); + resp.put("retcode", 500); + resp.put("retvalue", "修改实验班级名称失败!"); + return resp; + } + return resp; + } + + //——————————————————————————————全承珠 + public HashMap queryGetByExperimentalClassName(String experimentalClassName) { + HashMap resp = new HashMap(); - try { - resp.put("retvalue", experimentalClassMapper.queryGetByExperimentalClassName(experimentalClassName)); - resp.put("retcode", 200); - } catch (RuntimeException e) { - logger.error(e.getMessage()); - resp.put("retcode", 500); - resp.put("retvalue", "Inquiry Failed"); - return resp; - } - return resp; - } + try { + resp.put("retvalue", experimentalClassMapper.queryGetByExperimentalClassName(experimentalClassName)); + resp.put("retcode", 200); + } catch (RuntimeException e) { + logger.error(e.getMessage()); + resp.put("retcode", 500); + resp.put("retvalue", "Inquiry Failed"); + return resp; + } + return resp; + } } diff --git a/src/main/java/com/yipin/liuwanr/service/ExperimentallearningService.java b/src/main/java/com/yipin/liuwanr/service/ExperimentallearningService.java index dc0a72d..e8d80cd 100644 --- a/src/main/java/com/yipin/liuwanr/service/ExperimentallearningService.java +++ b/src/main/java/com/yipin/liuwanr/service/ExperimentallearningService.java @@ -5,6 +5,7 @@ import java.util.Arrays; import java.util.HashMap; import java.util.List; +import com.yipin.liuwanr.entity.UserM; import org.jboss.logging.Logger; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -43,11 +44,11 @@ public class ExperimentallearningService { HashMap resp = new HashMap(); try { if(!StringUtils.isEmpty(courseId)&&!StringUtils.isEmpty(studentId)){ + Integer experimentalClassId=mapper.queryExperimentalClassId(courseId,studentId); List projectIds = mapper.queryIsAttendance(studentId, courseId); - List projects = mapper2.getBySystemId(courseId, 0, null); + List projects = mapper.getBycourseId(experimentalClassId,courseId); for (int i = 0; i < projects.size(); i++) { Project_Management project = projects.get(i); - if (project.getIsExperiment() == 0) { // 教师那边开启了考勤,学生这边才可以有是否已经签到 if (project.getIsAttendance() == 0) { // 判断该学生签到的项目,是否在开启的项目中 @@ -58,10 +59,6 @@ public class ExperimentallearningService { } projects.set(i, project); } - } else { - project.setIsAttendance(null); - projects.set(i, project); - } } resp.put("retvalue", projects); } @@ -69,7 +66,7 @@ public class ExperimentallearningService { }catch(Exception e){ logger.error(e.getMessage()); resp.put("retcode", 500); - resp.put("retvalue", "Inquiry Failed"); + resp.put("retvalue", "实验项目查询失败"); return resp; }return resp; } @@ -101,11 +98,15 @@ public class ExperimentallearningService { /** * 学生信息展示 */ - public HashMap queryStudentName(Integer courseId) { + public HashMap queryStudentName(Integer courseId,Integer studentId) { HashMap resp = new HashMap(); try { if(!StringUtils.isEmpty(courseId)){ - resp.put("retvalue", mapper.queryStudentName(courseId)); + //实验班级 + Integer experimentalClassId=mapper.queryExperimentalClassId(courseId,studentId); + //学生信息 + List users =mapper.queryStudentName(experimentalClassId); + resp.put("retvalue", users); } resp.put("retcode", 200); } catch (Exception e) { @@ -120,11 +121,15 @@ public class ExperimentallearningService { /** * 授课老师 */ - public HashMap queryTeacherName(Integer courseId) { + public HashMap queryTeacherName(Integer courseId,Integer studentId) { HashMap resp = new HashMap(); try { if(!StringUtils.isEmpty(courseId)){ - resp.put("retvalue", mapper.queryTeacherName(courseId)); + //实验班级 + Integer experimentalClassId=mapper.queryExperimentalClassId(courseId,studentId); + //教师信息 + UserM user =mapper.queryTeacherName(experimentalClassId); + resp.put("retvalue",user); } resp.put("retcode", 200); } catch (Exception e) { @@ -177,4 +182,18 @@ public class ExperimentallearningService { return resp; } + + public HashMap queryStudentCourse(Integer studentId){ + HashMap resp = new HashMap(); + try{ + resp.put("retvalue",mapper.queryStudentCourse(studentId)); + resp.put("retcode",200); + }catch(Exception e){ + logger.error(e.getMessage()); + resp.put("retcode", 500); + resp.put("retvalue", "查询课程信息失败"); + } + return resp; + } + } diff --git a/src/main/java/com/yipin/liuwanr/service/ProjectAndCourseService.java b/src/main/java/com/yipin/liuwanr/service/ProjectAndCourseService.java index 0d8f1f4..22519ac 100644 --- a/src/main/java/com/yipin/liuwanr/service/ProjectAndCourseService.java +++ b/src/main/java/com/yipin/liuwanr/service/ProjectAndCourseService.java @@ -3,6 +3,7 @@ package com.yipin.liuwanr.service; import java.util.HashMap; import java.util.List; +import com.yipin.liuwanr.vo.CourseAndProjectVo; import org.jboss.logging.Logger; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -30,10 +31,10 @@ public class ProjectAndCourseService { * @param courseId * @return */ - public HashMap queryProject(Integer courseId) { + public HashMap queryProject(Integer courseId,Integer experimentalClassId) { HashMap resp = new HashMap(); try { - List project=mapper.getBySystemId(courseId,null, null); + List project=mapper.getBySystemId(courseId,experimentalClassId); resp.put("retcode", 200); resp.put("retvalue", project); } catch (RuntimeException e) { @@ -48,15 +49,15 @@ public class ProjectAndCourseService { /** * 修改项目状态 */ - public HashMap updateIsExperiment(Project_Management management) { + public HashMap updateIsExperiment(CourseAndProjectVo vo) { HashMap resp = new HashMap(); try { - mapper.updateIsExperiment(management); + mapper.updateIsExperiment(vo); resp.put("retcode", 200); } catch (RuntimeException e) { logger.error(e.getMessage()); resp.put("retcode", 500); - resp.put("retvalue", "Update Failed"); + resp.put("retvalue", "修改项目实验失败"); return resp; } return resp; @@ -65,10 +66,10 @@ public class ProjectAndCourseService { /** * 修改考勤状态 */ - public HashMap updateIsAttendance(Project_Management management) { + public HashMap updateIsAttendance(CourseAndProjectVo vo) { HashMap resp = new HashMap(); try { - mapper.updateIsAttendance(management); + mapper.updateIsAttendance(vo); resp.put("retcode", 200); } catch (RuntimeException e) { logger.error(e.getMessage()); @@ -79,15 +80,15 @@ public class ProjectAndCourseService { return resp; } - public HashMap getCourseSchedule(Integer courseId) { + public HashMap getCourseSchedule(Integer courseId,Integer experimentalClassId) { HashMap resp = new HashMap(); HashMap obj = new HashMap(); try { - if(StringUtils.isEmpty(courseId)){ + if(!StringUtils.isEmpty(courseId)){ //完成的课程项目 Integer number=mapper.getCourseSchedule(courseId); //总项目数量 - List project=mapper.getBySystemId(courseId,null, null); + List project=mapper.getBySystemId(courseId,experimentalClassId); obj.put("total",project.size()); if(number!=null){ obj.put("number",number); diff --git a/src/main/java/com/yipin/liuwanr/vo/CourseAndProjectVo.java b/src/main/java/com/yipin/liuwanr/vo/CourseAndProjectVo.java new file mode 100644 index 0000000..3ce08e1 --- /dev/null +++ b/src/main/java/com/yipin/liuwanr/vo/CourseAndProjectVo.java @@ -0,0 +1,34 @@ +package com.yipin.liuwanr.vo; + +import com.yipin.liuwanr.entity.Project_Management; + +public class CourseAndProjectVo { + + private Integer courseId; + private Integer experimentalClassId; + private Project_Management project; + + public Integer getCourseId() { + return courseId; + } + + public void setCourseId(Integer courseId) { + this.courseId = courseId; + } + + public Integer getExperimentalClassId() { + return experimentalClassId; + } + + public void setExperimentalClassId(Integer experimentalClassId) { + this.experimentalClassId = experimentalClassId; + } + + public Project_Management getProject() { + return project; + } + + public void setProject(Project_Management project) { + this.project = project; + } +}