From 12c4f755ea5a9e936e5f55aea91919ef40fa90af Mon Sep 17 00:00:00 2001 From: pd <2776455882@qq.com> Date: Fri, 31 Jul 2020 11:11:02 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=AD=A6=E7=94=9F=E7=AB=AF?= =?UTF-8?q?=E5=85=B3=E4=BA=8E=E8=AF=BE=E7=A8=8B=E7=9A=84service?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/AssesmentController.java | 23 +- .../ExperimentallearningController.java | 17 +- .../ProjectAndCourseController.java | 9 +- .../yipin/liuwanr/mapper/AssesmentMapper.java | 2 +- .../mapper/ExperimentallearningMapper.java | 2 +- .../liuwanr/service/AssesmentService.java | 4 +- .../liuwanr/service/AttendanceService.java | 7 +- .../service/ExperimentallearningService.java | 16 +- .../liuwanr/service/PracticeService.java | 317 +++++++++--------- .../service/ProjectAndCourseService.java | 21 +- 10 files changed, 211 insertions(+), 207 deletions(-) diff --git a/src/main/java/com/yipin/liuwanr/controller/AssesmentController.java b/src/main/java/com/yipin/liuwanr/controller/AssesmentController.java index e89e3b0..015b765 100644 --- a/src/main/java/com/yipin/liuwanr/controller/AssesmentController.java +++ b/src/main/java/com/yipin/liuwanr/controller/AssesmentController.java @@ -469,20 +469,17 @@ public class AssesmentController { @GetMapping("/releaseAssesment") Response releaseAssesment(@RequestParam Integer courseId){ Response resp = new Response(); - if(StringUtils.isEmpty(courseId)){ - resp.setStatus(300); - resp.setErrmessage("课程信息为空"); - }else{ - HashMap ret = service.releaseAssesment(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 = service.releaseAssesment(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/ExperimentallearningController.java b/src/main/java/com/yipin/liuwanr/controller/ExperimentallearningController.java index 73c58f8..38f827b 100644 --- a/src/main/java/com/yipin/liuwanr/controller/ExperimentallearningController.java +++ b/src/main/java/com/yipin/liuwanr/controller/ExperimentallearningController.java @@ -94,19 +94,14 @@ public class ExperimentallearningController { @GetMapping("/queryStudentName") Response queryStudentName(@RequestParam Integer courseId) { Response resp = new Response(); - 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 { + 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; } diff --git a/src/main/java/com/yipin/liuwanr/controller/ProjectAndCourseController.java b/src/main/java/com/yipin/liuwanr/controller/ProjectAndCourseController.java index b710831..f7b65c0 100644 --- a/src/main/java/com/yipin/liuwanr/controller/ProjectAndCourseController.java +++ b/src/main/java/com/yipin/liuwanr/controller/ProjectAndCourseController.java @@ -94,15 +94,11 @@ public class ProjectAndCourseController { return resp; } + //课程进度 @GetMapping("/getCourseSchedule") Response getCourseSchedule(Integer courseId) { Response resp = new Response(); - if(StringUtils.isEmpty(courseId)) { - resp.setStatus(300); - resp.setErrmessage("课程id为空"); - return resp; - }else { - HashMap ret = service.getCourseSchedule(courseId); + HashMap ret = service.getCourseSchedule(courseId); int status = (int) ret.get("retcode"); if (status == 200) { resp.setStatus(status); @@ -111,7 +107,6 @@ public class ProjectAndCourseController { resp.setStatus(status); resp.setErrmessage(ret.get("retvalue").toString()); } - } return resp; } } diff --git a/src/main/java/com/yipin/liuwanr/mapper/AssesmentMapper.java b/src/main/java/com/yipin/liuwanr/mapper/AssesmentMapper.java index e18b8d1..aaa3f73 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 ORDER BY a.id desc ", + " GROUP BY a.id ORDER BY a.id desc ", " "}) List getByCondition(Assesment assesment); diff --git a/src/main/java/com/yipin/liuwanr/mapper/ExperimentallearningMapper.java b/src/main/java/com/yipin/liuwanr/mapper/ExperimentallearningMapper.java index d84a41c..82c6b71 100644 --- a/src/main/java/com/yipin/liuwanr/mapper/ExperimentallearningMapper.java +++ b/src/main/java/com/yipin/liuwanr/mapper/ExperimentallearningMapper.java @@ -87,7 +87,7 @@ public interface ExperimentallearningMapper { * @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" + - "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") + " 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/service/AssesmentService.java b/src/main/java/com/yipin/liuwanr/service/AssesmentService.java index 2884a07..7c48060 100644 --- a/src/main/java/com/yipin/liuwanr/service/AssesmentService.java +++ b/src/main/java/com/yipin/liuwanr/service/AssesmentService.java @@ -615,7 +615,9 @@ public class AssesmentService { public HashMap releaseAssesment(Integer courseId) { HashMap resp = new HashMap(); try { - resp.put("retvalue", mapper.releaseAssesment(courseId)); + if(courseId!=null){ + resp.put("retvalue", mapper.releaseAssesment(courseId)); + } resp.put("retcode", 200); } catch (Exception e) { logger.error(e.getMessage()); diff --git a/src/main/java/com/yipin/liuwanr/service/AttendanceService.java b/src/main/java/com/yipin/liuwanr/service/AttendanceService.java index 33074bb..a18004f 100644 --- a/src/main/java/com/yipin/liuwanr/service/AttendanceService.java +++ b/src/main/java/com/yipin/liuwanr/service/AttendanceService.java @@ -17,6 +17,7 @@ import com.yipin.liuwanr.entity.Attendance; import com.yipin.liuwanr.entity.PageResult; import com.yipin.liuwanr.helper.ExcelExportHelper; import com.yipin.liuwanr.mapper.AttendanceMapper; +import org.springframework.util.StringUtils; /** * 考勤记录 @@ -43,7 +44,7 @@ public class AttendanceService { public HashMap queryAttendanceDetailed(Integer studentId,Integer courseId,Integer pageNo,Integer pageSize){ HashMap resp = new HashMap(); try { - if(courseId!=null&&studentId!=null){ + if(!StringUtils.isEmpty(courseId)&&!StringUtils.isEmpty(studentId)){ PageHelper.startPage(pageNo, pageSize); List list = mapper.getByCourseId(studentId,courseId); PageInfo info=new PageInfo(list); @@ -75,7 +76,7 @@ public class AttendanceService { */ public HashMap exportPractice(HttpServletResponse response,Integer studentId,Integer courseId,String[] titles) { try { - if(studentId!=null&&courseId!=null&&titles.length>0){ + if(!StringUtils.isEmpty(courseId)&&!StringUtils.isEmpty(studentId)&&titles.length>0){ String fileName="考勤记录.xls"; String sheetName="考勤记录"; List list = mapper.getByCourseId(studentId,courseId); @@ -104,7 +105,7 @@ public class AttendanceService { HashMap resp = new HashMap(); Attendance attendance=new Attendance(); try { - if(studentId!=null&&courseId!=null){ + if(!StringUtils.isEmpty(courseId)&&!StringUtils.isEmpty(studentId)){ attendance.setStudentName(mapper.getByStudentName(studentId)); List projectIds=mapper.queryProjectIds(courseId); attendance.setCount(projectIds.size()); diff --git a/src/main/java/com/yipin/liuwanr/service/ExperimentallearningService.java b/src/main/java/com/yipin/liuwanr/service/ExperimentallearningService.java index 5eeeb05..60ad02e 100644 --- a/src/main/java/com/yipin/liuwanr/service/ExperimentallearningService.java +++ b/src/main/java/com/yipin/liuwanr/service/ExperimentallearningService.java @@ -14,6 +14,7 @@ import com.yipin.liuwanr.entity.Attendance; import com.yipin.liuwanr.entity.Project_Management; import com.yipin.liuwanr.mapper.ExperimentallearningMapper; import com.yipin.liuwanr.mapper.TeacherProjectAndCourseMapper; +import org.springframework.util.StringUtils; /** * 学生端_实验学习 @@ -41,7 +42,7 @@ public class ExperimentallearningService { public HashMap queryProject(Integer studentId, Integer courseId) { HashMap resp = new HashMap(); try { - if(studentId!=null&&courseId!=null){ + if(!StringUtils.isEmpty(courseId)&&!StringUtils.isEmpty(studentId)){ List projectIds = mapper.queryIsAttendance(studentId, courseId); List projects = mapper2.getBySystemId(courseId, 0, null); for (int i = 0; i < projects.size(); i++) { @@ -103,7 +104,7 @@ public class ExperimentallearningService { public HashMap queryStudentName(Integer courseId) { HashMap resp = new HashMap(); try { - if(courseId!=null){ + if(!StringUtils.isEmpty(courseId)){ resp.put("retvalue", mapper.queryStudentName(courseId)); } resp.put("retcode", 200); @@ -122,7 +123,7 @@ public class ExperimentallearningService { public HashMap queryTeacherName(Integer courseId) { HashMap resp = new HashMap(); try { - if(courseId!=null){ + if(!StringUtils.isEmpty(courseId)){ resp.put("retvalue", mapper.queryTeacherName(courseId)); } resp.put("retcode", 200); @@ -142,7 +143,10 @@ public class ExperimentallearningService { HashMap resp = new HashMap(); HashMap val = new HashMap(); try { - List assesments = mapper.queryAssesment(courseId); + List assesments=null; + if(!StringUtils.isEmpty(courseId)) { + assesments = mapper.queryAssesment(courseId); + } // 查询出来该课程有多个考核开启,则不符合逻辑(一门课程一次只能开启一个考核,不能有多个) if(!assesments.isEmpty()&&assesments.size()>0){ if (assesments.size() > 1) { @@ -161,13 +165,13 @@ public class ExperimentallearningService { val.put("assesmentId", assesmentId); } } + resp.put("retvalue", val); } resp.put("retcode", 200); - resp.put("retvalue", val); } catch (Exception 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/PracticeService.java b/src/main/java/com/yipin/liuwanr/service/PracticeService.java index c906ffb..3c1f3b6 100644 --- a/src/main/java/com/yipin/liuwanr/service/PracticeService.java +++ b/src/main/java/com/yipin/liuwanr/service/PracticeService.java @@ -19,167 +19,174 @@ import com.yipin.liuwanr.helper.ExcelExportHelper; import com.yipin.liuwanr.mapper.AssesmentMapper; import com.yipin.liuwanr.mapper.RecordMapper; import com.yipin.liuwanr.vo.PracticeRecordVo; +import org.springframework.util.StringUtils; /** * 练习记录 - * @author 或然 * + * @author 或然 */ @Service public class PracticeService { - - - private static Logger logger = Logger.getLogger(PracticeService.class); - - @Autowired - private RecordMapper mapper; - - @Autowired - private AssesmentMapper assesment; - - - /** - * 练习记录 And 考核记录 - * @param studentId - * @param projectPermissions - * @param pageNum - * @param pageSize - * @return - */ - public HashMap queryStudentByPage(Integer studentId,Integer projectPermissions,Integer courseId,Integer pageNum,Integer pageSize) { - HashMap resp = new HashMap(); - try { - if(studentId!=null&&courseId!=null&&projectPermissions!=null) { - PageHelper.startPage(pageNum, pageSize); - List records=mapper.getByStudentId(projectPermissions,courseId,studentId); - PageInfo info=new PageInfo(records); - int total1 = (int) info.getTotal(); - int totalPages; - totalPages = total1 / pageSize; - if (total1 % pageSize != 0){ - totalPages ++; - } - long total = total1; - resp.put("retvalue", new PageResult(total, records,totalPages)); - } - resp.put("retcode", 200); - } catch (Exception e) { - logger.error(e.getMessage()); - resp.put("retcode", 500); - resp.put("retvalue", "Inquiry Failed"); - return resp; - } - return resp; - } - - /** - * 练习记录 and 考核记录导出 - * @param response - * @param studentId:学生id - * @param projectPermissions:权限(练习、考核) - * @param titles(标题) - * @return - */ - public HashMap exportPractice(HttpServletResponse response,Integer studentId,Integer projectPermissions,Integer courseId,String[] titles) { - String fileName=null; - String sheetName=null; - try { - List records=mapper.getByStudentId(projectPermissions,courseId,studentId); - if(records.size()>0&&!records.isEmpty()) { - if(projectPermissions==0) { - fileName = "练习记录.xls"; - sheetName = "练习记录"; - }else if(projectPermissions==1){ - fileName = "考核记录.xls"; - sheetName = "考核记录"; - } - HSSFWorkbook bos = ExcelExportHelper.exportPractice(records, 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; - } - return null; - } - - - /** - * 练习信息 - * @param studentId - * @return - */ - public HashMap queryPracticeVo(Integer studentId,Integer courseId) { - HashMap resp = new HashMap(); - try { - 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); - } - // 练习总次数 - 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("retcode", 200); - } catch (Exception e) { - logger.error(e.getMessage()); - resp.put("retcode", 500); - resp.put("retvalue", "Inquiry Failed"); - return resp; - } - return resp; - } - - - public HashMap queryAllExperiment(Integer coureseId) { - HashMap resp = new HashMap(); - try { - if(coureseId!=null){ - resp.put("retvalue", assesment.queryGetByAssesmentProject(coureseId)); - } - resp.put("retcode", 200); - } catch (Exception e) { - logger.error(e.getMessage()); - resp.put("retcode", 500); - resp.put("retvalue", "Inquiry Failed"); - return resp; - } - return resp; - } + + + private static Logger logger = Logger.getLogger(PracticeService.class); + + @Autowired + private RecordMapper mapper; + + @Autowired + private AssesmentMapper assesment; + + + /** + * 练习记录 And 考核记录 + * + * @param studentId + * @param projectPermissions + * @param pageNum + * @param pageSize + * @return + */ + public HashMap queryStudentByPage(Integer studentId, Integer projectPermissions, Integer courseId, Integer pageNum, Integer pageSize) { + HashMap resp = new HashMap(); + try { + if (!StringUtils.isEmpty(courseId) && !StringUtils.isEmpty(studentId) && projectPermissions != null) { + PageHelper.startPage(pageNum, pageSize); + List records = mapper.getByStudentId(projectPermissions, courseId, studentId); + PageInfo info = new PageInfo(records); + int total1 = (int) info.getTotal(); + int totalPages; + totalPages = total1 / pageSize; + if (total1 % pageSize != 0) { + totalPages++; + } + long total = total1; + resp.put("retvalue", new PageResult(total, records, totalPages)); + } + resp.put("retcode", 200); + } catch (Exception e) { + logger.error(e.getMessage()); + resp.put("retcode", 500); + resp.put("retvalue", "Inquiry Failed"); + return resp; + } + return resp; + } + + /** + * 练习记录 and 考核记录导出 + * + * @param response + * @param studentId:学生id + * @param projectPermissions:权限(练习、考核) + * @param titles(标题) + * @return + */ + public HashMap exportPractice(HttpServletResponse response, Integer studentId, Integer projectPermissions, Integer courseId, String[] titles) { + String fileName = null; + String sheetName = null; + List records = null; + try { + if (!StringUtils.isEmpty(courseId) && !StringUtils.isEmpty(studentId)) { + records = mapper.getByStudentId(projectPermissions, courseId, studentId); + } + if (records.size() > 0 && !records.isEmpty()) { + if (projectPermissions == 0) { + fileName = "练习记录.xls"; + sheetName = "练习记录"; + } else if (projectPermissions == 1) { + fileName = "考核记录.xls"; + sheetName = "考核记录"; + } + HSSFWorkbook bos = ExcelExportHelper.exportPractice(records, 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; + } + return null; + } + + + /** + * 练习信息 + * + * @param studentId + * @return + */ + public HashMap queryPracticeVo(Integer studentId, Integer courseId) { + HashMap resp = new HashMap(); + try { + if (!StringUtils.isEmpty(courseId) && !StringUtils.isEmpty(studentId)) { + // 学生个人的练习信息 + 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); + } + // 练习总次数 + 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("retcode", 200); + } catch (Exception e) { + logger.error(e.getMessage()); + resp.put("retcode", 500); + resp.put("retvalue", "Inquiry Failed"); + return resp; + } + return resp; + } + + + public HashMap queryAllExperiment(Integer courseId) { + HashMap resp = new HashMap(); + try { + if (!StringUtils.isEmpty(courseId)) { + resp.put("retvalue", assesment.queryGetByAssesmentProject(courseId)); + } + resp.put("retcode", 200); + } catch (Exception 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/ProjectAndCourseService.java b/src/main/java/com/yipin/liuwanr/service/ProjectAndCourseService.java index 99f9db7..0d8f1f4 100644 --- a/src/main/java/com/yipin/liuwanr/service/ProjectAndCourseService.java +++ b/src/main/java/com/yipin/liuwanr/service/ProjectAndCourseService.java @@ -9,6 +9,7 @@ import org.springframework.stereotype.Service; import com.yipin.liuwanr.entity.Project_Management; import com.yipin.liuwanr.mapper.TeacherProjectAndCourseMapper; +import org.springframework.util.StringUtils; /** * @@ -82,15 +83,17 @@ public class ProjectAndCourseService { HashMap resp = new HashMap(); HashMap obj = new HashMap(); try { - //完成的课程项目 - Integer number=mapper.getCourseSchedule(courseId); - //总项目数量 - List project=mapper.getBySystemId(courseId,null, null); - obj.put("total",project.size()); - if(number!=null){ - obj.put("number",number); - }else{ - obj.put("number",0); + if(StringUtils.isEmpty(courseId)){ + //完成的课程项目 + Integer number=mapper.getCourseSchedule(courseId); + //总项目数量 + List project=mapper.getBySystemId(courseId,null, null); + obj.put("total",project.size()); + if(number!=null){ + obj.put("number",number); + }else{ + obj.put("number",0); + } } resp.put("retcode", 200); resp.put("retvalue",obj);