diff --git a/src/main/java/com/yipin/liuwanr/controller/AssesmentRecordController.java b/src/main/java/com/yipin/liuwanr/controller/AssesmentRecordController.java index 3a9461c..4b90729 100644 --- a/src/main/java/com/yipin/liuwanr/controller/AssesmentRecordController.java +++ b/src/main/java/com/yipin/liuwanr/controller/AssesmentRecordController.java @@ -3,8 +3,10 @@ package com.yipin.liuwanr.controller; import java.util.HashMap; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.util.StringUtils; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; import com.yipin.liuwanr.entity.Response; @@ -26,22 +28,22 @@ public class AssesmentRecordController { * 考核管理查询成绩明细 */ @GetMapping("/queryStudentAssessment") - Response queryStudentAssessment(Integer studentId,Integer courseId) { + Response queryStudentAssessment(@RequestParam Integer studentId,@RequestParam Integer courseId) { Response resp = new Response(); if (studentId==null) { resp.setStatus(300); - resp.setErrmessage("studentId Empty"); - return resp; + resp.setErrmessage("学生信息为空"); + }else{ + HashMap ret = assesmentRecordService.queryStudentAssessment(studentId,courseId); + int status = (int) ret.get("retcode"); + if (200 == status) { + resp.setStatus(status); + resp.setMessage(ret.get("retvalue")); + } else { + resp.setStatus(status); + resp.setErrmessage(ret.get("retvalue").toString()); + } } - HashMap ret = assesmentRecordService.queryStudentAssessment(studentId,courseId); - int status = (int) ret.get("retcode"); - if (200 == status) { - 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/AttendanceController.java b/src/main/java/com/yipin/liuwanr/controller/AttendanceController.java index 5d681ed..6c1fd3f 100644 --- a/src/main/java/com/yipin/liuwanr/controller/AttendanceController.java +++ b/src/main/java/com/yipin/liuwanr/controller/AttendanceController.java @@ -5,8 +5,10 @@ import java.util.HashMap; import javax.servlet.http.HttpServletResponse; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.util.StringUtils; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; import com.yipin.liuwanr.entity.Response; @@ -33,16 +35,11 @@ public class AttendanceController { * @return */ @GetMapping("/queryAttendanceDetailed") - Response queryAttendanceDetailed(Integer studentId,Integer courseId,Integer pageNo,Integer pageSize) { + Response queryAttendanceDetailed(@RequestParam Integer studentId, @RequestParam Integer courseId,@RequestParam Integer pageNo,@RequestParam Integer pageSize) { Response resp = new Response(); if (null==studentId) { resp.setStatus(300); - resp.setErrmessage("studentId is empty"); - return resp; - }else if(null==courseId) { - resp.setStatus(300); - resp.setErrmessage("courseId is empty"); - return resp; + resp.setErrmessage("学生信息为空"); }else { HashMap ret = attendanceService.queryAttendanceDetailed(studentId,courseId,pageNo, pageSize); int status = (int) ret.get("retcode"); @@ -67,7 +64,7 @@ public class AttendanceController { * @return */ @GetMapping("/exportPractice") - Response exportPractice(HttpServletResponse response,Integer studentId,Integer courseId,String[] titles) { + Response exportPractice(HttpServletResponse response,@RequestParam Integer studentId,@RequestParam Integer courseId,@RequestParam String[] titles) { try { attendanceService.exportPractice(response,studentId,courseId,titles); } catch (Exception e) { @@ -84,16 +81,11 @@ public class AttendanceController { * @return */ @GetMapping("/queryAttendanceSignIn") - Response queryAttendanceSignIn(Integer studentId,Integer courseId) { + Response queryAttendanceSignIn(@RequestParam Integer studentId,@RequestParam Integer courseId) { Response resp = new Response(); if (null==studentId) { resp.setStatus(300); - resp.setErrmessage("studentId is empty"); - return resp; - }else if(null==courseId) { - resp.setStatus(300); - resp.setErrmessage("courseId is empty"); - return resp; + resp.setErrmessage("学生信息为空"); }else { HashMap ret = attendanceService.queryAttendance(studentId,courseId); int status = (int) ret.get("retcode"); diff --git a/src/main/java/com/yipin/liuwanr/controller/ExperimentallearningController.java b/src/main/java/com/yipin/liuwanr/controller/ExperimentallearningController.java index 6484589..73c58f8 100644 --- a/src/main/java/com/yipin/liuwanr/controller/ExperimentallearningController.java +++ b/src/main/java/com/yipin/liuwanr/controller/ExperimentallearningController.java @@ -3,11 +3,8 @@ package com.yipin.liuwanr.controller; import java.util.HashMap; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.util.StringUtils; +import org.springframework.web.bind.annotation.*; import com.yipin.liuwanr.entity.Attendance; import com.yipin.liuwanr.entity.Response; @@ -26,16 +23,21 @@ public class ExperimentallearningController { * @return */ @GetMapping("/queryExperimentallearning") - Response queryExperimentallearning(Integer studentId,Integer courseId) { + Response queryExperimentallearning(@RequestParam Integer studentId,@RequestParam Integer courseId) { Response resp = new Response(); - HashMap ret = service.queryProject(studentId,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(studentId)){ + resp.setStatus(300); + resp.setMessage("学生信息为空"); + }else { + HashMap ret = service.queryProject(studentId,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()); + } } return resp; } @@ -51,16 +53,16 @@ public class ExperimentallearningController { if(null==attendance) { resp.setStatus(300); resp.setMessage("attendance is null"); - return resp; - } - HashMap ret = service.insertAttendance(attendance); - 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()); + }else { + HashMap ret = service.insertAttendance(attendance); + 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; } @@ -70,17 +72,17 @@ public class ExperimentallearningController { * 获取教师信息 */ @GetMapping("/queryTeacherName") - Response queryTeacherName(Integer courseId) { + Response queryTeacherName(@RequestParam Integer courseId) { Response resp = new Response(); HashMap ret = service.queryTeacherName(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()); - } + 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; } @@ -90,16 +92,21 @@ public class ExperimentallearningController { * 获取学生信息 */ @GetMapping("/queryStudentName") - Response queryStudentName(Integer courseId) { + Response queryStudentName(@RequestParam Integer courseId) { 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 { - resp.setStatus(status); - resp.setErrmessage(ret.get("retvalue").toString()); + if(StringUtils.isEmpty(courseId)){ + resp.setStatus(300); + resp.setMessage("课程信息为空"); + }else { + HashMap ret = service.queryStudentName(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()); + } } return resp; } @@ -108,16 +115,21 @@ public class ExperimentallearningController { * 进入考核 */ @GetMapping("/queryAssesment") - Response queryAssesment(Integer courseId,Integer studentId) { + Response queryAssesment(@RequestParam Integer studentId,@RequestParam Integer courseId) { Response resp = new Response(); - HashMap ret = service.queryAssesment(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()); + if(StringUtils.isEmpty(studentId)){ + resp.setStatus(300); + resp.setMessage("学生信息为空"); + }else { + HashMap ret = service.queryAssesment(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; } diff --git a/src/main/java/com/yipin/liuwanr/controller/PracticeController.java b/src/main/java/com/yipin/liuwanr/controller/PracticeController.java index 00439cd..062947d 100644 --- a/src/main/java/com/yipin/liuwanr/controller/PracticeController.java +++ b/src/main/java/com/yipin/liuwanr/controller/PracticeController.java @@ -5,8 +5,10 @@ import java.util.HashMap; import javax.servlet.http.HttpServletResponse; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.util.StringUtils; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; import com.yipin.liuwanr.entity.Response; @@ -33,14 +35,12 @@ public class PracticeController { * @return */ @GetMapping("/queryStudentByPage") - Response queryStudentByPage(Integer studentId,Integer projectPermissions,Integer courseId,Integer pageNum,Integer pageSize) { + Response queryStudentByPage(@RequestParam Integer studentId,@RequestParam Integer projectPermissions, + @RequestParam Integer courseId,@RequestParam Integer pageNum,@RequestParam Integer pageSize) { Response resp = new Response(); - if( null==studentId) { - resp.setStatus(500); - resp.setErrmessage("student is null"); - }else if(null==projectPermissions) { - resp.setStatus(500); - resp.setErrmessage("projectPermissions is null"); + if(StringUtils.isEmpty(studentId)) { + resp.setStatus(300); + resp.setErrmessage("学生信息为空"); }else { HashMap ret = service.queryStudentByPage(studentId,projectPermissions,courseId,pageNum,pageSize); int status = (int) ret.get("retcode"); @@ -64,7 +64,7 @@ public class PracticeController { * @return */ @GetMapping("/exportPractice") - Response exportPractice(HttpServletResponse response, Integer studentId,Integer projectPermissions,Integer courseId,String[] titles) { + Response exportPractice(HttpServletResponse response,@RequestParam Integer studentId,@RequestParam Integer projectPermissions,@RequestParam Integer courseId,@RequestParam String[] titles) { try { service.exportPractice(response,studentId,projectPermissions,courseId,titles); } catch (Exception e) { @@ -76,7 +76,6 @@ public class PracticeController { /** * 练习信息 - * @param vo * @return */ @GetMapping("/queryPracticeVo") diff --git a/src/main/java/com/yipin/liuwanr/mapper/AssesmentMapper.java b/src/main/java/com/yipin/liuwanr/mapper/AssesmentMapper.java index 4f9a82a..e18b8d1 100644 --- a/src/main/java/com/yipin/liuwanr/mapper/AssesmentMapper.java +++ b/src/main/java/com/yipin/liuwanr/mapper/AssesmentMapper.java @@ -57,7 +57,7 @@ public interface AssesmentMapper { " and a.releaseType=#{releaseType} ", " and a.assesmentState=#{assesmentState} ", " and c.className like concat('%',#{className},'%') ", - " GROUP BY a.id ORDER BY a.creationTime", + " GROUP BY a.id ORDER BY a.creationTime ORDER BY a.id desc ", " "}) List getByCondition(Assesment assesment); diff --git a/src/main/java/com/yipin/liuwanr/mapper/AttendanceMapper.java b/src/main/java/com/yipin/liuwanr/mapper/AttendanceMapper.java index 98936e1..c87010c 100644 --- a/src/main/java/com/yipin/liuwanr/mapper/AttendanceMapper.java +++ b/src/main/java/com/yipin/liuwanr/mapper/AttendanceMapper.java @@ -16,7 +16,7 @@ public interface AttendanceMapper { * @return */ @Select("SELECT pm.projectName as experimentName,att.signIn as signIn,att.creationTime as creationTime FROM hr_project_management pm,attendance att" - + " WHERE pm.projectId=att.experimentId AND att.studentId=#{studentId} AND FIND_IN_SET(pm.systemId,(SELECT systemId FROM course WHERE courseId=#{courseId})) > 0") + + " WHERE pm.projectId=att.experimentId AND att.studentId=#{studentId} AND FIND_IN_SET(pm.systemId,(SELECT systemId FROM course WHERE courseId=#{courseId})) > 0") List getByCourseId(@Param("studentId") Integer studentId,@Param("courseId") Integer courseId); diff --git a/src/main/java/com/yipin/liuwanr/mapper/ExperimentallearningMapper.java b/src/main/java/com/yipin/liuwanr/mapper/ExperimentallearningMapper.java index 3f93132..d84a41c 100644 --- a/src/main/java/com/yipin/liuwanr/mapper/ExperimentallearningMapper.java +++ b/src/main/java/com/yipin/liuwanr/mapper/ExperimentallearningMapper.java @@ -86,7 +86,7 @@ public interface ExperimentallearningMapper { * @param courseId * @return */ - @Select("select id,experimentId,experimentalClassId,classId from assessment a left join hr_project_management pm on a.experimentId=pm.projectId left join hr_course_tc tc on pm.systemId=tc.systemId\n" + + @Select("select id,experimentId,experimentalClassId,classId from assessment a left join hr_project_management pm on a.experimentId=pm.projectId left join hr_course_tc tc on pm.systemId=tc.systemId" + "where a.assesmentState=1 AND pm.state=1 and pm.isdel=0 AND pm.projectPermissions=1 and a.courseId=tc.courseId and tc.courseId=#{courseId} GROUP BY tc.systemId") List queryAssesment(Integer courseId); diff --git a/src/main/java/com/yipin/liuwanr/mapper/RecordMapper.java b/src/main/java/com/yipin/liuwanr/mapper/RecordMapper.java index 5eaef89..bb271ae 100644 --- a/src/main/java/com/yipin/liuwanr/mapper/RecordMapper.java +++ b/src/main/java/com/yipin/liuwanr/mapper/RecordMapper.java @@ -55,7 +55,7 @@ public interface RecordMapper { * @return */ @Select("SELECT stu.studentName as studentName,SUM(re.timeSum) as totaltime,avg(re.score) as avg,SUM(integral) as integral" + - " FROM record re,student stu,hr_project_management pm WHERE re.studentId=stu.studentId and re.projectId=pm.projectId and pm.projectPermissions=0 and re.studentId=1 and re.courseId=2") + " FROM record re,student stu,hr_project_management pm WHERE re.studentId=stu.studentId and re.projectId=pm.projectId and pm.projectPermissions=0 and re.studentId=#{studentId} and re.courseId=#{courseId}") PracticeRecordVo getByPracticeVO(@Param("studentId")Integer studentId,@Param("courseId")Integer courseId); diff --git a/src/main/java/com/yipin/liuwanr/service/AssesmentRecordService.java b/src/main/java/com/yipin/liuwanr/service/AssesmentRecordService.java index ec90e61..3a5885a 100644 --- a/src/main/java/com/yipin/liuwanr/service/AssesmentRecordService.java +++ b/src/main/java/com/yipin/liuwanr/service/AssesmentRecordService.java @@ -27,31 +27,29 @@ public class AssesmentRecordService { HashMap resp = new HashMap(); AssesmentRecordVo vo=null; try { - //学生信息 - vo=mapper.getByStudentId(studentId,courseId); - //学校最高平均分 - Integer schoolHeight=mapper.getBySchool(courseId,studentId); - if(schoolHeight!=null) { - vo.setSchoolheightscore(schoolHeight); - }else { - vo.setSchoolheightscore(0); + if(studentId!=null&&courseId!=null){ + vo=mapper.getByStudentId(studentId,courseId);//学生信息 + Integer schoolHeight=mapper.getBySchool(courseId,studentId);//学校最高平均分 + if(schoolHeight!=null) { + vo.setSchoolheightscore(schoolHeight); + }else { + vo.setSchoolheightscore(0); + } + AssesmentRecordVo vo1=mapper.getByCountry(courseId);//全国信息 + if(vo1!=null) { + vo.setCountryavgscore(vo1.getCountryavgscore()); + vo.setCountryheightscore(vo1.getCountryheightscore()); + }else { + vo.setCountryavgscore(0.0); + vo.setCountryheightscore(0.0); + } } - //全国信息 - AssesmentRecordVo vo1=mapper.getByCountry(courseId); - if(vo1!=null) { - vo.setCountryavgscore(vo1.getCountryavgscore()); - vo.setCountryheightscore(vo1.getCountryheightscore()); - }else { - vo.setCountryavgscore(0.0); - vo.setCountryheightscore(0.0); - } - resp.put("retvalue", vo); resp.put("retcode", 200); } catch (RuntimeException e) { logger.error(e.getMessage()); resp.put("retcode", 500); - resp.put("retvalue", "Inquiry Failed"); + resp.put("retvalue", "考核记录信息查询失败"); return resp; } return resp; diff --git a/src/main/java/com/yipin/liuwanr/service/AttendanceService.java b/src/main/java/com/yipin/liuwanr/service/AttendanceService.java index 50e156d..33074bb 100644 --- a/src/main/java/com/yipin/liuwanr/service/AttendanceService.java +++ b/src/main/java/com/yipin/liuwanr/service/AttendanceService.java @@ -43,18 +43,20 @@ public class AttendanceService { public HashMap queryAttendanceDetailed(Integer studentId,Integer courseId,Integer pageNo,Integer pageSize){ HashMap resp = new HashMap(); try { - PageHelper.startPage(pageNo, pageSize); - List list = mapper.getByCourseId(studentId,courseId); - PageInfo info=new PageInfo(list); - int total1 = (int) info.getTotal(); - int totalPages; - totalPages = total1 / pageSize; - if (total1 % pageSize != 0){ - totalPages ++; - } - long total = total1; - resp.put("retvalue", new PageResult(total, list,totalPages)); - resp.put("retcode", 200); + if(courseId!=null&&studentId!=null){ + PageHelper.startPage(pageNo, pageSize); + List list = mapper.getByCourseId(studentId,courseId); + PageInfo info=new PageInfo(list); + int total1 = (int) info.getTotal(); + int totalPages; + totalPages = total1 / pageSize; + if (total1 % pageSize != 0){ + totalPages ++; + } + long total = total1; + resp.put("retvalue", new PageResult(total, list,totalPages)); + } + resp.put("retcode", 200); } catch (RuntimeException e) { logger.error(e.getMessage()); resp.put("retcode", 500); @@ -73,15 +75,17 @@ public class AttendanceService { */ public HashMap exportPractice(HttpServletResponse response,Integer studentId,Integer courseId,String[] titles) { try { - String fileName="考勤记录.xls"; - String sheetName="考勤记录"; - List list = mapper.getByCourseId(studentId,courseId); - HSSFWorkbook bos=ExcelExportHelper.exportAttendance(list, sheetName, titles); - response.setHeader("content-Type","application/vnd.ms-excel"); - response.setHeader("Content-disposition","attachment;filename="+URLEncoder.encode(fileName,"UTF-8")); - response.flushBuffer(); - bos.write(response.getOutputStream()); - bos.close(); + if(studentId!=null&&courseId!=null&&titles.length>0){ + String fileName="考勤记录.xls"; + String sheetName="考勤记录"; + List list = mapper.getByCourseId(studentId,courseId); + HSSFWorkbook bos=ExcelExportHelper.exportAttendance(list, sheetName, titles); + response.setHeader("content-Type","application/vnd.ms-excel"); + response.setHeader("Content-disposition","attachment;filename="+URLEncoder.encode(fileName,"UTF-8")); + response.flushBuffer(); + bos.write(response.getOutputStream()); + bos.close(); + } } catch (Exception e) { logger.error(e.getMessage()); return null; @@ -100,25 +104,27 @@ public class AttendanceService { HashMap resp = new HashMap(); Attendance attendance=new Attendance(); try { - attendance.setStudentName(mapper.getByStudentName(studentId)); - List projectIds=mapper.queryProjectIds(courseId); - attendance.setCount(projectIds.size()); - List att=mapper.querySigIn(studentId,projectIds); - int absence=0;//缺勤次数 - int signInNumber=0;//签到次数 - for (Attendance attendance2 : att) { - if(attendance2.getSignIn()==0) { - signInNumber++; - }else if(attendance2.getSignIn()==1) { - absence++; + if(studentId!=null&&courseId!=null){ + attendance.setStudentName(mapper.getByStudentName(studentId)); + List projectIds=mapper.queryProjectIds(courseId); + attendance.setCount(projectIds.size()); + List att=mapper.querySigIn(studentId,projectIds); + int absence=0;//缺勤次数 + int signInNumber=0;//签到次数 + for (Attendance attendance2 : att) { + if(attendance2.getSignIn()==0) { + signInNumber++; + }else if(attendance2.getSignIn()==1) { + absence++; + } } - } - //设置缺勤次数 - attendance.setAbsence(absence); - //设置考勤次数 - attendance.setSignInNumber(signInNumber); - resp.put("retcode", 200); - resp.put("retvalue", attendance); + //设置缺勤次数 + attendance.setAbsence(absence); + //设置考勤次数 + attendance.setSignInNumber(signInNumber); + resp.put("retvalue", attendance); + } + resp.put("retcode", 200); } catch (Exception e) { logger.error(e.getMessage()); resp.put("retcode", 500); diff --git a/src/main/java/com/yipin/liuwanr/service/ExperimentallearningService.java b/src/main/java/com/yipin/liuwanr/service/ExperimentallearningService.java index f9811aa..5eeeb05 100644 --- a/src/main/java/com/yipin/liuwanr/service/ExperimentallearningService.java +++ b/src/main/java/com/yipin/liuwanr/service/ExperimentallearningService.java @@ -41,27 +41,29 @@ public class ExperimentallearningService { public HashMap queryProject(Integer studentId, Integer courseId) { HashMap resp = new HashMap(); try { - List projectIds = mapper.queryIsAttendance(studentId, courseId); - List projects = mapper2.getBySystemId(courseId, 0, null); - for (int i = 0; i < projects.size(); i++) { - Project_Management project = projects.get(i); - if (project.getIsExperiment() == 0) { - // 教师那边开启了考勤,学生这边才可以有是否已经签到 - if (project.getIsAttendance() == 0) { - // 判断该学生签到的项目,是否在开启的项目中 - if (projectIds.contains(project.getProjectId())) { - project.setSignin(0); - } else { - project.setSignin(1); + if(studentId!=null&&courseId!=null){ + List projectIds = mapper.queryIsAttendance(studentId, courseId); + List projects = mapper2.getBySystemId(courseId, 0, null); + for (int i = 0; i < projects.size(); i++) { + Project_Management project = projects.get(i); + if (project.getIsExperiment() == 0) { + // 教师那边开启了考勤,学生这边才可以有是否已经签到 + if (project.getIsAttendance() == 0) { + // 判断该学生签到的项目,是否在开启的项目中 + if (projectIds.contains(project.getProjectId())) { + project.setSignin(0); + } else { + project.setSignin(1); + } + projects.set(i, project); } + } else { + project.setIsAttendance(null); projects.set(i, project); } - } else { - project.setIsAttendance(null); - projects.set(i, project); } + resp.put("retvalue", projects); } - resp.put("retvalue", projects); resp.put("retcode", 200); }catch(Exception e){ logger.error(e.getMessage()); @@ -85,12 +87,11 @@ public class ExperimentallearningService { } else { mapper.insertAttendance(attendance); } - resp.put("retcode", 200); } catch (Exception e) { logger.error(e.getMessage()); resp.put("retcode", 500); - resp.put("retvalue", "Add Failed"); + resp.put("retvalue", "考勤签到失败"); return resp; } return resp; @@ -102,7 +103,9 @@ public class ExperimentallearningService { public HashMap queryStudentName(Integer courseId) { HashMap resp = new HashMap(); try { - resp.put("retvalue", mapper.queryStudentName(courseId)); + if(courseId!=null){ + resp.put("retvalue", mapper.queryStudentName(courseId)); + } resp.put("retcode", 200); } catch (Exception e) { logger.error(e.getMessage()); @@ -119,7 +122,9 @@ public class ExperimentallearningService { public HashMap queryTeacherName(Integer courseId) { HashMap resp = new HashMap(); try { - resp.put("retvalue", mapper.queryTeacherName(courseId)); + if(courseId!=null){ + resp.put("retvalue", mapper.queryTeacherName(courseId)); + } resp.put("retcode", 200); } catch (Exception e) { logger.error(e.getMessage()); @@ -139,25 +144,23 @@ public class ExperimentallearningService { try { List assesments = mapper.queryAssesment(courseId); // 查询出来该课程有多个考核开启,则不符合逻辑(一门课程一次只能开启一个考核,不能有多个) - if (assesments.size() > 1) { - resp.put("retcode", 300); - resp.put("retvalue", "同一课程只能开启一个考核"); - return resp; - } else { - if (assesments.size() != 0) { - - Assesment assesment = assesments.get(0); - Integer assesmentId = assesment.getId(); - // 查询该考核的学生 - List studentIds = mapper.queryStudentId(assesmentId); - if (studentIds.contains(studentId)) { - val.put("courseId", courseId); - val.put("studentId", studentId); - val.put("projectId", assesment.getExperimentId()); - val.put("assesmentId", assesmentId); - } + if(!assesments.isEmpty()&&assesments.size()>0){ + if (assesments.size() > 1) { + resp.put("retcode", 300); + resp.put("retvalue", "同一课程只能开启一个考核"); + return resp; + } else { + Assesment assesment = assesments.get(0); + Integer assesmentId = assesment.getId(); + // 查询该考核的学生 + List studentIds = mapper.queryStudentId(assesmentId); + if (studentIds.contains(studentId)) { + val.put("courseId", courseId); + val.put("studentId", studentId); + val.put("projectId", assesment.getExperimentId()); + val.put("assesmentId", assesmentId); + } } - } resp.put("retcode", 200); resp.put("retvalue", val); diff --git a/src/main/java/com/yipin/liuwanr/service/PracticeService.java b/src/main/java/com/yipin/liuwanr/service/PracticeService.java index 903a45b..c906ffb 100644 --- a/src/main/java/com/yipin/liuwanr/service/PracticeService.java +++ b/src/main/java/com/yipin/liuwanr/service/PracticeService.java @@ -49,7 +49,7 @@ public class PracticeService { public HashMap queryStudentByPage(Integer studentId,Integer projectPermissions,Integer courseId,Integer pageNum,Integer pageSize) { HashMap resp = new HashMap(); try { - if(pageNum!=null&&pageSize!=null) { + if(studentId!=null&&courseId!=null&&projectPermissions!=null) { PageHelper.startPage(pageNum, pageSize); List records=mapper.getByStudentId(projectPermissions,courseId,studentId); PageInfo info=new PageInfo(records); @@ -117,42 +117,44 @@ public class PracticeService { public HashMap queryPracticeVo(Integer studentId,Integer courseId) { HashMap resp = new HashMap(); try { - // 学生个人的练习信息 - PracticeRecordVo practiceVo = mapper.getByPracticeVO(studentId,courseId); - // 练习项目数量 - Integer practiceNumber=mapper.queryPracticeNumber(courseId); - if(practiceNumber!=null) { - practiceVo.setPracticeNumber(practiceNumber); - - // 求完成项目数量 - Integer accomplishNumber=mapper.queryAccomplishNumber(studentId,courseId); - if(accomplishNumber!=null) { - practiceVo.setAccomplishNumber(accomplishNumber); + if(studentId!=null&&courseId!=null){ + // 学生个人的练习信息 + PracticeRecordVo practiceVo = mapper.getByPracticeVO(studentId,courseId); + // 练习项目数量 + Integer practiceNumber=mapper.queryPracticeNumber(courseId); + if(practiceNumber!=null) { + practiceVo.setPracticeNumber(practiceNumber); + + // 求完成项目数量 + Integer accomplishNumber=mapper.queryAccomplishNumber(studentId,courseId); + if(accomplishNumber!=null) { + practiceVo.setAccomplishNumber(accomplishNumber); + } + }else { + practiceVo.setPracticeNumber(0); + practiceVo.setAccomplishNumber(0); } - }else { - practiceVo.setPracticeNumber(0); - practiceVo.setAccomplishNumber(0); - } - // 练习总次数 - Integer sumNumber=mapper.querySumNumber(studentId,courseId); - if(sumNumber!=null) { - practiceVo.setSumNumber(sumNumber); - }else { - practiceVo.setSumNumber(0); - } - PracticeRecordVo vo=mapper.queryCountry(courseId); - if(vo!=null) { - //全国实训积分平均分 - practiceVo.setAvgintegral(vo.getAvgintegral()); - //全国最高实训积分 - practiceVo.setHeightintegral(vo.getHeightintegral()); - }else { - //全国实训积分平均分 - practiceVo.setAvgintegral(0); - //全国最高实训积分 - practiceVo.setHeightintegral(0); + // 练习总次数 + Integer sumNumber=mapper.querySumNumber(studentId,courseId); + if(sumNumber!=null) { + practiceVo.setSumNumber(sumNumber); + }else { + practiceVo.setSumNumber(0); + } + PracticeRecordVo vo=mapper.queryCountry(courseId); + if(vo!=null) { + //全国实训积分平均分 + practiceVo.setAvgintegral(vo.getAvgintegral()); + //全国最高实训积分 + practiceVo.setHeightintegral(vo.getHeightintegral()); + }else { + //全国实训积分平均分 + practiceVo.setAvgintegral(0); + //全国最高实训积分 + practiceVo.setHeightintegral(0); + } + resp.put("retvalue", practiceVo); } - resp.put("retvalue", practiceVo); resp.put("retcode", 200); } catch (Exception e) { logger.error(e.getMessage()); @@ -167,8 +169,10 @@ public class PracticeService { public HashMap queryAllExperiment(Integer coureseId) { HashMap resp = new HashMap(); try { + if(coureseId!=null){ + resp.put("retvalue", assesment.queryGetByAssesmentProject(coureseId)); + } resp.put("retcode", 200); - resp.put("retvalue", assesment.queryGetByAssesmentProject(coureseId)); } catch (Exception e) { logger.error(e.getMessage()); resp.put("retcode", 500);