diff --git a/src/main/java/com/yipin/liuwanr/controller/ExperimentalClassController.java b/src/main/java/com/yipin/liuwanr/controller/ExperimentalClassController.java index a2690f2..6adb4fc 100644 --- a/src/main/java/com/yipin/liuwanr/controller/ExperimentalClassController.java +++ b/src/main/java/com/yipin/liuwanr/controller/ExperimentalClassController.java @@ -205,6 +205,7 @@ public class ExperimentalClassController { * @param experimentalClassId * @return */ + @GetMapping("/getProfessionals") Response getProfessionals(@RequestParam Integer experimentalClassId) { Response resp = new Response(); HashMap ret=classService.getProfessionals(experimentalClassId); @@ -225,6 +226,7 @@ public class ExperimentalClassController { * @param experimentalClassId * @return */ + @GetMapping("/getStudentClass") Response getStudentClass(@RequestParam Integer experimentalClassId) { Response resp = new Response(); HashMap ret=classService.getStudentClass(experimentalClassId); @@ -241,6 +243,7 @@ public class ExperimentalClassController { //新增学生显示数据 + @GetMapping("/queryexperimentalClass") Response queryexperimentalClass(@RequestParam Integer experimentalClassId) { Response resp = new Response(); HashMap ret=classService.queryexperimentalClass(experimentalClassId); @@ -257,7 +260,8 @@ public class ExperimentalClassController { //新增学生 - Response addStudent(@RequestParam ExperimentalClassVo vo) { + @PostMapping("/addStudent") + Response addStudent(@RequestBody ExperimentalClassVo vo) { Response resp = new Response(); HashMap ret=classService.addStudent(vo); 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 df7b9ec..6484589 100644 --- a/src/main/java/com/yipin/liuwanr/controller/ExperimentallearningController.java +++ b/src/main/java/com/yipin/liuwanr/controller/ExperimentallearningController.java @@ -44,10 +44,6 @@ public class ExperimentallearningController { /** * 添加签到记录 - * @param courseId - * @param studentId - * @param experimentName - * @return */ @PostMapping("/insertAttendance") Response insertAttendance(@RequestBody Attendance attendance) { @@ -72,8 +68,6 @@ public class ExperimentallearningController { /** * 获取教师信息 - * @param courseId - * @return */ @GetMapping("/queryTeacherName") Response queryTeacherName(Integer courseId) { @@ -94,8 +88,6 @@ public class ExperimentallearningController { /** * 获取学生信息 - * @param courseId - * @return */ @GetMapping("/queryStudentName") Response queryStudentName(Integer courseId) { @@ -114,9 +106,6 @@ public class ExperimentallearningController { /** * 进入考核 - * @param courseId - * @param studentId - * @return */ @GetMapping("/queryAssesment") Response queryAssesment(Integer courseId,Integer studentId) { diff --git a/src/main/java/com/yipin/liuwanr/controller/ProjectAndCourseController.java b/src/main/java/com/yipin/liuwanr/controller/ProjectAndCourseController.java index 92eeba0..b710831 100644 --- a/src/main/java/com/yipin/liuwanr/controller/ProjectAndCourseController.java +++ b/src/main/java/com/yipin/liuwanr/controller/ProjectAndCourseController.java @@ -3,6 +3,7 @@ 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.PostMapping; import org.springframework.web.bind.annotation.RequestBody; @@ -40,11 +41,10 @@ public class ProjectAndCourseController { } return resp; } - + /** * 修改项目状态 - * @param projectId - * @param isExperiment + * @param management * @return */ @PostMapping("/updateIsExperiment") @@ -67,11 +67,10 @@ public class ProjectAndCourseController { } return resp; } - + /** * 修改考勤状态 - * @param projectId - * @param isAttendance + * @param management * @return */ @PostMapping("/updateIsAttendance") @@ -95,4 +94,24 @@ 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); + 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/mapper/AssesmentMapper.java b/src/main/java/com/yipin/liuwanr/mapper/AssesmentMapper.java index d122cb6..34f3b37 100644 --- a/src/main/java/com/yipin/liuwanr/mapper/AssesmentMapper.java +++ b/src/main/java/com/yipin/liuwanr/mapper/AssesmentMapper.java @@ -33,7 +33,7 @@ public interface AssesmentMapper { * @return */ @Select("select projectId,projectName,projectPermissions,founder,creationTime from hr_project_management " + - " where isdel=0 and projectPermissions=1 AND systemId in (SELECT systemId FROM course WHERE courseId=#{courseId})") + " where isdel=0 and projectPermissions=1 AND systemId in (select systemId FROM hr_course_tc where courseId=#{courseId} GROUP BY systemId)") List queryGetByAssesmentProject(Integer courseId); @@ -78,8 +78,8 @@ public interface AssesmentMapper { * 创建考核 * @param assesment */ - @Insert("insert into assessment (assesmentName,releaseType,creationTime,endTime,timesum,experimentId,classId,assesmentState,assessmentSize,experimentalClassId,staffId,courseId)" - + " values (#{assesmentName},#{releaseType},#{creationTime},#{endTime},#{timesum},#{experimentId},#{classId},#{assesmentState},#{assessmentSize},#{experimentalClassId},#{staffId},#{courseId})") + @Insert("insert into assessment (assesmentName,releaseType,creationTime,endTime,timesum,experimentId,classId,assesmentState,assessmentSize,experimentalClassId,staffId,courseId,assessmentNumber)" + + " values (#{assesmentName},#{releaseType},#{creationTime},#{endTime},#{timesum},#{experimentId},#{classId},#{assesmentState},#{assessmentSize},#{experimentalClassId},#{staffId},#{courseId},#{assessmentNumber})") @Options(useGeneratedKeys = true,keyColumn ="id",keyProperty = "id") void insertAssesment(Assesment assesment); @@ -88,14 +88,13 @@ public interface AssesmentMapper { * 修改考核 * @param assesment */ - @Update("update assessment set assesmentName=#{assesmentName},releaseType=#{releaseType},creationTime=#{creationTime},endTime=#{endTime},timesum=#{timesum},assessmentSize=#{assessmentSize}," + @Update("update assessment set assesmentName=#{assesmentName},releaseType=#{releaseType},creationTime=#{creationTime},endTime=#{endTime},timesum=#{timesum},assessmentSize=#{assessmentSize},assessmentNumber=#{assessmentNumber}" + "experimentId=#{experimentId},assesmentState=#{assesmentState},classId=#{classId},experimentalClassId=#{experimentalClassId} where id=#{id}") void updateAssesment(Assesment assesment); /** * 添加考核记录 - * @param record */ @Insert({ ""}) List queryScore(Integer assesmentId,@Param("experimentalClassId")Integer experimentalClassId,@Param("classId") List classId); - - + + /** * 分组查询分数和对应人数 * @param assesmentId @@ -284,11 +282,11 @@ public interface AssesmentMapper { /** * 统计该项目的判分点数量 - * @param projectId + * (select experimentId from assessment where id=#{assesmentId}) * @return */ - @Select("select count(judgmentPointsId) from hr_judgment_points where FIND_IN_SET((select experimentId from assessment where id=#{assesmentId}),projectId)") - Integer queryPointNumber(Integer assesmentId); + @Select("select count(judgmentPointsId) from hr_judgment_points where FIND_IN_SET(#{projectId},projectId)") + Integer queryPointNumber(Integer projectId); /** diff --git a/src/main/java/com/yipin/liuwanr/mapper/ExperimentalClassMapper.java b/src/main/java/com/yipin/liuwanr/mapper/ExperimentalClassMapper.java index 6c02983..27941e4 100644 --- a/src/main/java/com/yipin/liuwanr/mapper/ExperimentalClassMapper.java +++ b/src/main/java/com/yipin/liuwanr/mapper/ExperimentalClassMapper.java @@ -20,7 +20,7 @@ public interface ExperimentalClassMapper { + "VALUES(#{studentId},#{intExperimentalClassId})") void experimentClassAddStudent(Student student); - @Delete("DELETE from experimental_class_student where studentId = #{studentId} and experimentalClassId = #{experimentalClassId}") + @Delete("DELETE from experimental_class_student where studentId = #{studentId} and experimentalClassId = #{intExperimentalClassId}") void experimentClassDeleteStudent(Student student); //创建实验班级 @@ -84,7 +84,7 @@ public interface ExperimentalClassMapper { * @return */ @Select({""}) - List getBySystemId(@Param("systemIds") String[] systemIds,@Param("isExperiment")Integer isExperiment,@Param("isAttendance")Integer isAttendance); + List getBySystemId(@Param("courseId") Integer courseId,@Param("isExperiment")Integer isExperiment,@Param("isAttendance")Integer isAttendance); /** * 修改是否开启项目 @@ -51,5 +39,8 @@ public interface TeacherProjectAndCourseMapper { */ @Update("update hr_project_management set isAttendance=#{isAttendance} where projectId=#{projectId}") void updateIsAttendance(Project_Management management); + + @Select("select count(*) from hr_course_schedule where courseId=#{courseId}") + Integer getCourseSchedule(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 57b05f0..5b511a6 100644 --- a/src/main/java/com/yipin/liuwanr/service/AssesmentService.java +++ b/src/main/java/com/yipin/liuwanr/service/AssesmentService.java @@ -26,564 +26,573 @@ import com.yipin.liuwanr.vo.AssesmentStudentVo; @Service public class AssesmentService { - - private static Logger logger=Logger.getLogger(AssesmentService.class); - - @Autowired - private AssesmentMapper mapper; - - /** - * 考核管理列表查询 - * @param assesment - * @param pageNo - * @param pageSize - * @return - */ - public HashMap queryAssesmentCondition(Assesment assesment,Integer pageNo,Integer pageSize){ - HashMap resp = new HashMap(); - try { - PageHelper.startPage(pageNo, pageSize); - List assesments = mapper.getByCondition(assesment); - PageInfo info=new PageInfo(assesments); - int total1 = (int) info.getTotal(); - int totalPages; - totalPages = total1 / pageSize; - if (total1 % pageSize != 0){ - totalPages ++; - } - long total = total1; - resp.put("retvalue", new PageResult(total, assesments,totalPages)); - resp.put("retcode", 200); - } catch (RuntimeException e) { - logger.error(e.getMessage()); - resp.put("retcode", 500); - resp.put("retvalue", "Inquiry Failed"); - return resp; - } - return resp; - } - - - /** - * 创建考核 - * @param vo - * @return - */ - @Transactional - public HashMap addAssesment(AssesmentStudentVo vo) { - HashMap resp = new HashMap(); - Assesment assesment=vo.getAssesment(); - List studentIds=vo.getStudentIds(); - try { - //转换时间格式 - assesment = AssesmentHelper.helpAssesment(assesment); - if(assesment.getExperimentalClassId()!=null) { - //行政班级id - List classid=mapper.queryClassId(studentIds); - String classId = String.join(",", classid); - assesment.setClassId(classId); - } - //考核人数 - assesment.setAssessmentSize(studentIds.size()); - //添加考核 - mapper.insertAssesment(assesment); - //得到考核id - Integer assesmentId=assesment.getId(); - //往记录表中添加选中的学生信息,哪名学生要参与某一课程的什么考核,该考核下的 哪一项目 - mapper.insertRecore(studentIds, assesment.getExperimentId(), assesment.getCourseId(), assesmentId); - - resp.put("retcode", 200); - } catch (RuntimeException e) { - logger.error(e.getMessage()); - resp.put("retcode", 500); - resp.put("retvalue", "Add Failed"); - return resp; - } - return resp; - } - - - /** - * 查询选中的学生有哪些正在参与考核 - * @param studentIds - * @return - */ - public HashMap queryStudentisAssess(List studentIds) { - HashMap resp = new HashMap(); - try { - //查询出来的学生信息 - List stu=mapper.queryStudentisAssess(studentIds); - resp.put("retcode", 200); - resp.put("retvalue", stu); - } catch (Exception e) { - logger.error(e.getMessage()); - resp.put("retcode", 500); - resp.put("retvalue", "Inquiry Failed"); - return resp; - } - return resp; - } - - - /** - * 根据id查询考核的信息 - * @param id - * @return - */ - public HashMap queryGetById(Integer id) { - HashMap resp = new HashMap(); - List obj=new ArrayList(); - try { - //考核信息 - Assesment assesment=mapper.queryGetById(id); - //之前选中的学生 - List students=mapper.queryStudent(id); - obj.add(assesment); - obj.add(students); - - resp.put("retvalue",obj); - resp.put("retcode", 200); - } catch (Exception e) { - logger.error(e.getMessage()); - resp.put("retcode", 500); - resp.put("retvalue", "Inquiry Failed"); - return resp; - } - return resp; - } - - - /** - * 修改考核管理 - * @param vo - * @return - */ - @Transactional - public HashMap updateAssesment(Assesment assesment,List studentIds) { - HashMap resp = new HashMap(); - assesment = AssesmentHelper.helpAssesment(assesment); - - try { - //数据库存储的考核信息 - Assesment before= mapper.queryGetById(assesment.getId()); - //数据库存储的学生 - List students=mapper.queryStudent(assesment.getId()); - if(assesment.getExperimentalClassId()!=null) { - //新的行政班级id - List classid=mapper.queryClassId(studentIds); - String classId = String.join(",", classid); - if(!classId.equals(before.getClassId())) { - assesment.setClassId(classId); - }else { - assesment.setClassId(before.getClassId()); - } - }else if(assesment.getClassId()!=null) { - assesment.setExperimentalClassId(null); - } - // 比较两批学生的信息 - for (int i = 0; i < studentIds.size(); i++) { - for (int j = 0; j < students.size(); j++) { - if (studentIds.get(i).equals(students.get(j).getStudentId())) { - studentIds.remove(i); - students.remove(students.get(j)); - i--; - break; - } - } - } - //前端传来的添加 - if(studentIds.size()>0) { - mapper.insertRecore(studentIds, assesment.getExperimentId(), assesment.getCourseId(), assesment.getId()); - } - //后端剩余的删除 - if(students.size()>0) { - mapper.deleteRecord(assesment.getId(), students); - } - //更新考核 - assesment.setAssessmentSize(studentIds.size());//考核人数 - mapper.updateAssesment(assesment); - - resp.put("retcode", 200); - } catch (RuntimeException e) { - logger.error(e.getMessage()); - resp.put("retcode", 500); - resp.put("retvalue", "Update Failed"); - return resp; - } - return resp; - } - - /** - * 启动考核前的判断 - * @param assesmentId - * @return - */ - public HashMap assessmentJudgment(Integer assesmentId) { - HashMap resp = new HashMap(); - List obj=new ArrayList(); - try { - List datas=mapper.getStudentisAssess(); - List students=mapper.queryStudent(assesmentId); - for (int i = 0; i < students.size(); i++) { - Student stu=students.get(i); - if(datas.contains(stu.getStudentId())) { - obj.add(stu); - } - - } - resp.put("retvalue",obj); - resp.put("retcode", 200); - } catch (Exception e) { - logger.error(e.getMessage()); - resp.put("retcode", 500); - resp.put("retvalue", "Inquiry Failed"); - return resp; - } - return resp; - } - - - - - /** - * 修改考核状态 - * @param id - * @param state - * @return - */ - public HashMap updateState(Assesment assesment) { - HashMap resp = new HashMap(); - long starttime = 0; - long endtime = 0; - String[] datas; - int hour = 0; - int minute = 0; - try { - String createTime = assesment.getCreationTime(); - String endTime = assesment.getEndTime(); - String timeSum=assesment.getTimesum(); - - - if(createTime!=null&&!createTime.equals("")) { - starttime = Long.parseLong(assesment.getCreationTime()); - assesment.setCreationTime(AssesmentHelper.longPointDate(starttime)); - } - if(endTime!=null&&!endTime.equals("")) { - endtime = Long.parseLong(assesment.getEndTime()); - assesment.setEndTime(AssesmentHelper.longPointDate(endtime)); - }if(timeSum!=null&&!timeSum.equals("")) { - datas=timeSum.split("h"); - if(datas!=null&&datas.length>0) { - hour=Integer.parseInt(datas[0]); - if(datas.length>2) { - minute=Integer.parseInt(datas[1]); - } - } - long time=((hour*60)+minute)*60*1000; - endTime=AssesmentHelper.longPointDate(starttime+time); - assesment.setEndTime(endTime); - } - mapper.updateAssesmentState(assesment); - resp.put("retcode", 200); - } catch (Exception e) { - logger.error(e.getMessage()); - resp.put("retcode", 500); - resp.put("retvalue", "Inquiry Failed"); - return resp; - } - return resp; - } - - - /** - * 查询实验班级一级栏目 - * @param staffId:教师id - * @return - */ - public HashMap queryCretionTime(Integer staffId) { - HashMap resp = new HashMap(); - try { - resp.put("retvalue", mapper.queryCreationTime(staffId)); - resp.put("retcode", 200); - } catch (Exception e) { - logger.error(e.getMessage()); - resp.put("retcode", 500); - resp.put("retvalue", "Inquiry Failed"); - return resp; - } - return resp; - } - - - /** - * 查询实验班级名称,以及班级一下的学生 - * @param cretionTime - * @return - */ - public HashMap queryCretionTime(String cretionTime,Integer staffId) { - HashMap resp = new HashMap(); - try { - resp.put("retvalue", mapper.queryExperimentalClass(cretionTime,staffId)); - resp.put("retcode", 200); - } catch (Exception e) { - logger.error(e.getMessage()); - resp.put("retcode", 500); - resp.put("retvalue", "Inquiry Failed"); - return resp; - } - return resp; - } - - - /** - * 考核信息展示 - * @param assesmentId - * @return - */ - public HashMap queryAssesment(Integer assesmentId) { - HashMap resp = new HashMap(); - try { - resp.put("retvalue", mapper.queryAssesmentId(assesmentId)); - resp.put("retcode", 200); - } catch (Exception e) { - logger.error(e.getMessage()); - resp.put("retcode", 500); - resp.put("retvalue", "Inquiry Failed"); - return resp; - } - return resp; - } - - - /** - * 班级筛选 - * @param assesmentId - * @return - */ - public HashMap getByclass(Integer assesmentId) { - HashMap resp = new HashMap(); - List obj=new ArrayList(); - try { - ExperimentalClass experimentalClasses=mapper.queryExperimental(assesmentId); - List classes=mapper.queryClass(assesmentId); - obj.add(experimentalClasses); - obj.add(classes); - - resp.put("retvalue",obj); - resp.put("retcode", 200); - } catch (Exception e) { - logger.error(e.getMessage()); - resp.put("retcode", 500); - resp.put("retvalue", "Inquiry Failed"); - return resp; - } - return resp; - } - - - /** - * 成绩概况 - * @param assesmentId - * @param projectId - * @param experimentalClassId - * @param classId - * @return - */ - public HashMap queryScore(Integer assesmentId,Integer experimentalClassId,List classId) { - HashMap resp = new HashMap(); - Score score=new Score(); - int size = 0; - try { - List scores=mapper.queryScore(assesmentId, experimentalClassId, classId); - if(scores.size()>0) { - size=scores.size(); - //最低分 - score.setMin(scores.get(0)); - //最高分 - score.setMax(scores.get(size-1)); - //考核人数 - score.setPeopleSize(size); - //中位数 - double median=0.0; - if(size%2==1) { - median=scores.get((size-1)/2); - }else { - median=(scores.get((size/2-1))+scores.get(size/2)+0.0)/2; - } - score.setMedian(median); - //平均分 - int avg=0; - for (int i = 0; i < scores.size(); i++) { - avg+=scores.get(i); - } - score.setAvg(avg*1.0/size); - }else { - //最低分 - score.setMin(0); - //最高分 - score.setMax(0); - //考核人数 - score.setPeopleSize(size); - //中位数 - score.setMedian(0); - //平均分 - score.setAvg(0); - } - //判分点数量 - Integer pointNumber=mapper.queryPointNumber(assesmentId); - if(StringUtils.isEmpty(pointNumber)) { - score.setPointNumber(0); - }else { - score.setPointNumber(pointNumber); - //错误率 - Integer classError=mapper.queryRight(assesmentId, experimentalClassId, classId); - if(StringUtils.isEmpty(classError)||size==0) { - score.setError(0); - }else { - double error=(classError*1.0/(size*pointNumber))*100; - score.setError(error); - } - } - resp.put("retvalue", score); - resp.put("retcode", 200); - } catch (Exception e) { - logger.error(e.getMessage()); - resp.put("retcode", 500); - resp.put("retvalue", "Inquiry Failed"); - return resp; - } - return resp; - } - - - /** - * 成绩柱状图 - * @param assesmentId - * @param experimentalClassId - * @param classId - * @return - */ - public HashMap queryHistogram(Integer assesmentId,Integer experimentalClassId,List classId) { - HashMap resp = new HashMap(); - List obj=new ArrayList(); - try { - Integer one=0; - Integer two=0; - Integer three=0; - Integer four=0; - Integer five=0; - Integer six=0; - Integer seven=0; - Integer eight=0; - Integer nine=0; - Integer ten=0; - - List scores=mapper.queryScore2(assesmentId, experimentalClassId, classId); - for (int i = 0; i < scores.size(); i++) { - Integer score=scores.get(i).getScore(); - Integer number=scores.get(i).getNumber(); - if(score>=0&&score<=10) { - one+=number; - }else if(score>10&&score<=20) { - two+=number; - }else if(score>20&&score<=30) { - three+=number; - }else if(score>30&&score<=40) { - four+=number; - }else if(score>40&&score<=50) { - five+=number; - }else if(score>50&&score<=60) { - six+=number; - }else if(score>60&&score<=70) { - seven+=number; - }else if(score>70&&score<=80) { - eight+=number; - }else if(score>80&&score<=90) { - nine+=number; - }else if(score>90&&score<=100) { - ten+=number; - } - - } - - obj.add(ten); - obj.add(nine); - obj.add(eight); - obj.add(seven); - obj.add(six); - obj.add(five); - obj.add(four); - obj.add(three); - obj.add(two); - obj.add(one); - - - resp.put("retvalue", obj); - resp.put("retcode", 200); - } catch (Exception e) { - logger.error(e.getMessage()); - resp.put("retcode", 500); - resp.put("retvalue", "Inquiry Failed"); - return resp; - } - return resp; - } - - - /** - * 错误分布折线图 - * @param assesmentId - * @param experimentalClassId - * @param classId - * @return - */ - public HashMap getLinechart(Integer assesmentId,Integer experimentalClassId,List classId) { - HashMap resp = new HashMap(); - List obj=new ArrayList(); - try { - List errors=mapper.queryError(assesmentId, experimentalClassId, classId); - List names=new ArrayList(); - List datas=new ArrayList(); - - for (int i = 0; i < errors.size(); i++) { - PointRecord pointRecord=errors.get(i); - names.add(pointRecord.getJudgmentPointsName()); - datas.add(pointRecord.getNumber()); - } - - obj.add(names); - obj.add(datas); - resp.put("retvalue",obj); - resp.put("retcode", 200); - } catch (Exception e) { - logger.error(e.getMessage()); - resp.put("retcode", 500); - resp.put("retvalue", "Inquiry Failed"); - return resp; - } - return resp; - } - - - /** - * 成绩明细 - * @param assesmentId - * @param experimentalClassId - * @param classId - * @return - */ - public HashMap queryAssesmentScore(Integer assesmentId,Integer experimentalClassId,List classId) { - HashMap resp = new HashMap(); - try { - resp.put("retvalue", mapper.queryScore3(assesmentId, experimentalClassId, classId)); - 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(AssesmentService.class); + + @Autowired + private AssesmentMapper mapper; + + /** + * 考核管理列表查询 + * + * @param assesment + * @param pageNo + * @param pageSize + * @return + */ + public HashMap queryAssesmentCondition(Assesment assesment, Integer pageNo, Integer pageSize) { + HashMap resp = new HashMap(); + try { + PageHelper.startPage(pageNo, pageSize); + List assesments = mapper.getByCondition(assesment); + PageInfo info = new PageInfo(assesments); + int total1 = (int) info.getTotal(); + int totalPages; + totalPages = total1 / pageSize; + if (total1 % pageSize != 0) { + totalPages++; + } + long total = total1; + resp.put("retvalue", new PageResult(total, assesments, totalPages)); + resp.put("retcode", 200); + } catch (RuntimeException e) { + logger.error(e.getMessage()); + resp.put("retcode", 500); + resp.put("retvalue", "Inquiry Failed"); + return resp; + } + return resp; + } + + + /** + * 创建考核 + * + * @param vo + * @return + */ + @Transactional + public HashMap addAssesment(AssesmentStudentVo vo) { + HashMap resp = new HashMap(); + Assesment assesment = vo.getAssesment(); + List studentIds = vo.getStudentIds(); + try { + //转换时间格式 + assesment = AssesmentHelper.helpAssesment(assesment); + if (assesment.getExperimentalClassId() != null) { + //行政班级id + List classid = mapper.queryClassId(studentIds); + String classId = String.join(",", classid); + assesment.setClassId(classId); + } + //考核人数 + assesment.setAssessmentSize(studentIds.size()); + //判分点数量 + Integer pointNumber = mapper.queryPointNumber(assesment.getExperimentId()); + assesment.setAssessmentNumber(pointNumber); + //添加考核 + mapper.insertAssesment(assesment); + //得到考核id + Integer assesmentId = assesment.getId(); + //往记录表中添加选中的学生信息,哪名学生要参与某一课程的什么考核,该考核下的 哪一项目 + mapper.insertRecore(studentIds, assesment.getExperimentId(), assesment.getCourseId(), assesmentId); + + resp.put("retcode", 200); + } catch (RuntimeException e) { + logger.error(e.getMessage()); + resp.put("retcode", 500); + resp.put("retvalue", "Add Failed"); + throw new RuntimeException(); + } + return resp; + } + + + /** + * 查询选中的学生有哪些正在参与考核 + * + * @param studentIds + * @return + */ + public HashMap queryStudentisAssess(List studentIds) { + HashMap resp = new HashMap(); + try { + //查询出来的学生信息 + List stu = mapper.queryStudentisAssess(studentIds); + resp.put("retcode", 200); + resp.put("retvalue", stu); + } catch (Exception e) { + logger.error(e.getMessage()); + resp.put("retcode", 500); + resp.put("retvalue", "Inquiry Failed"); + return resp; + } + return resp; + } + + + /** + * 根据id查询考核的信息 + * + * @param id + * @return + */ + public HashMap queryGetById(Integer id) { + HashMap resp = new HashMap(); + List obj = new ArrayList(); + try { + //考核信息 + Assesment assesment = mapper.queryGetById(id); + //之前选中的学生 + List students = mapper.queryStudent(id); + obj.add(assesment); + obj.add(students); + + resp.put("retvalue", obj); + resp.put("retcode", 200); + } catch (Exception e) { + logger.error(e.getMessage()); + resp.put("retcode", 500); + resp.put("retvalue", "Inquiry Failed"); + return resp; + } + return resp; + } + + + /** + * 修改考核管理 + * @return + */ + @Transactional + public HashMap updateAssesment(Assesment assesment, List studentIds) { + HashMap resp = new HashMap(); + assesment = AssesmentHelper.helpAssesment(assesment); + + try { + //数据库存储的考核信息 + Assesment before = mapper.queryGetById(assesment.getId()); + //数据库存储的学生 + List students = mapper.queryStudent(assesment.getId()); + if (assesment.getExperimentalClassId() != null) { + //新的行政班级id + List classid = mapper.queryClassId(studentIds); + String classId = String.join(",", classid); + if (!classId.equals(before.getClassId())) { + assesment.setClassId(classId); + } else { + assesment.setClassId(before.getClassId()); + } + } else if (assesment.getClassId() != null) { + assesment.setExperimentalClassId(null); + } + // 比较两批学生的信息 + for (int i = 0; i < studentIds.size(); i++) { + for (int j = 0; j < students.size(); j++) { + if (studentIds.get(i).equals(students.get(j).getStudentId())) { + studentIds.remove(i); + students.remove(students.get(j)); + i--; + break; + } + } + } + //前端传来的添加 + if (studentIds.size() > 0) { + mapper.insertRecore(studentIds, assesment.getExperimentId(), assesment.getCourseId(), assesment.getId()); + } + //后端剩余的删除 + if (students.size() > 0) { + mapper.deleteRecord(assesment.getId(), students); + } + //更新考核 + assesment.setAssessmentSize(studentIds.size());//考核人数 + //判分点数量 + Integer pointNumber = mapper.queryPointNumber(assesment.getExperimentId()); + assesment.setAssessmentNumber(pointNumber); + mapper.updateAssesment(assesment); + + resp.put("retcode", 200); + } catch (RuntimeException e) { + logger.error(e.getMessage()); + resp.put("retcode", 500); + resp.put("retvalue", "Update Failed"); + throw new RuntimeException(); + } + return resp; + } + + /** + * 启动考核前的判断 + * + * @param assesmentId + * @return + */ + public HashMap assessmentJudgment(Integer assesmentId) { + HashMap resp = new HashMap(); + List obj = new ArrayList(); + try { + List datas = mapper.getStudentisAssess(); + List students = mapper.queryStudent(assesmentId); + for (int i = 0; i < students.size(); i++) { + Student stu = students.get(i); + if (datas.contains(stu.getStudentId())) { + obj.add(stu); + } + + } + resp.put("retvalue", obj); + resp.put("retcode", 200); + } catch (Exception e) { + logger.error(e.getMessage()); + resp.put("retcode", 500); + resp.put("retvalue", "Inquiry Failed"); + return resp; + } + return resp; + } + + + /** + * 修改考核状态 + * @return + */ + public HashMap updateState(Assesment assesment) { + HashMap resp = new HashMap(); + long starttime = 0; + long endtime = 0; + String[] datas; + int hour = 0; + int minute = 0; + try { + String createTime = assesment.getCreationTime(); + String endTime = assesment.getEndTime(); + String timeSum = assesment.getTimesum(); + + + if (createTime != null && !createTime.equals("")) { + starttime = Long.parseLong(assesment.getCreationTime()); + assesment.setCreationTime(AssesmentHelper.longPointDate(starttime)); + } + if (endTime != null && !endTime.equals("")) { + endtime = Long.parseLong(assesment.getEndTime()); + assesment.setEndTime(AssesmentHelper.longPointDate(endtime)); + } + if (timeSum != null && !timeSum.equals("")) { + datas = timeSum.split("h"); + if (datas != null && datas.length > 0) { + hour = Integer.parseInt(datas[0]); + if (datas.length > 2) { + minute = Integer.parseInt(datas[1]); + } + } + long time = ((hour * 60) + minute) * 60 * 1000; + endTime = AssesmentHelper.longPointDate(starttime + time); + assesment.setEndTime(endTime); + } + mapper.updateAssesmentState(assesment); + resp.put("retcode", 200); + } catch (Exception e) { + logger.error(e.getMessage()); + resp.put("retcode", 500); + resp.put("retvalue", "Inquiry Failed"); + return resp; + } + return resp; + } + + + /** + * 查询实验班级一级栏目 + * + * @param staffId:教师id + * @return + */ + public HashMap queryCretionTime(Integer staffId) { + HashMap resp = new HashMap(); + try { + resp.put("retvalue", mapper.queryCreationTime(staffId)); + resp.put("retcode", 200); + } catch (Exception e) { + logger.error(e.getMessage()); + resp.put("retcode", 500); + resp.put("retvalue", "Inquiry Failed"); + return resp; + } + return resp; + } + + + /** + * 查询实验班级名称,以及班级一下的学生 + * + * @param cretionTime + * @return + */ + public HashMap queryCretionTime(String cretionTime, Integer staffId) { + HashMap resp = new HashMap(); + try { + resp.put("retvalue", mapper.queryExperimentalClass(cretionTime, staffId)); + resp.put("retcode", 200); + } catch (Exception e) { + logger.error(e.getMessage()); + resp.put("retcode", 500); + resp.put("retvalue", "Inquiry Failed"); + return resp; + } + return resp; + } + + + /** + * 考核信息展示 + * + * @param assesmentId + * @return + */ + public HashMap queryAssesment(Integer assesmentId) { + HashMap resp = new HashMap(); + try { + resp.put("retvalue", mapper.queryAssesmentId(assesmentId)); + resp.put("retcode", 200); + } catch (Exception e) { + logger.error(e.getMessage()); + resp.put("retcode", 500); + resp.put("retvalue", "Inquiry Failed"); + return resp; + } + return resp; + } + + + /** + * 班级筛选 + * + * @param assesmentId + * @return + */ + public HashMap getByclass(Integer assesmentId) { + HashMap resp = new HashMap(); + List obj = new ArrayList(); + try { + ExperimentalClass experimentalClasses = mapper.queryExperimental(assesmentId); + List classes = mapper.queryClass(assesmentId); + obj.add(experimentalClasses); + obj.add(classes); + + resp.put("retvalue", obj); + 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 queryScore(Integer assesmentId, Integer experimentalClassId, List classId) { + HashMap resp = new HashMap(); + Score score = new Score(); + int size = 0; + try { + List scores = mapper.queryScore(assesmentId, experimentalClassId, classId); + if (scores.size() > 0) { + size = scores.size(); + //最低分 + score.setMin(scores.get(0)); + //最高分 + score.setMax(scores.get(size - 1)); + //考核人数 + score.setPeopleSize(size); + //中位数 + double median = 0.0; + if (size % 2 == 1) { + median = scores.get((size - 1) / 2); + } else { + median = (scores.get((size / 2 - 1)) + scores.get(size / 2) + 0.0) / 2; + } + score.setMedian(median); + //平均分 + int avg = 0; + for (int i = 0; i < scores.size(); i++) { + avg += scores.get(i); + } + score.setAvg(avg * 1.0 / size); + } else { + //最低分 + score.setMin(0); + //最高分 + score.setMax(0); + //考核人数 + score.setPeopleSize(size); + //中位数 + score.setMedian(0); + //平均分 + score.setAvg(0); + } + Integer pointNumber=mapper.getAssesmentNumber(assesmentId); + if(StringUtils.isEmpty(pointNumber)) { + score.setPointNumber(0); + }else { + score.setPointNumber(pointNumber); + //错误率 + Integer classError=mapper.queryRight(assesmentId, experimentalClassId, classId); + if(StringUtils.isEmpty(classError)||size==0) { + score.setError(0); + }else { + double error=(classError*1.0/(size*pointNumber))*100; + score.setError(error); + } + } + + resp.put("retvalue", score); + resp.put("retcode", 200); + } catch (Exception e) { + logger.error(e.getMessage()); + resp.put("retcode", 500); + resp.put("retvalue", "Inquiry Failed"); + return resp; + } + return resp; + } + + + /** + * 成绩柱状图 + * + * @param assesmentId + * @param experimentalClassId + * @param classId + * @return + */ + public HashMap queryHistogram(Integer assesmentId, Integer experimentalClassId, List classId) { + HashMap resp = new HashMap(); + List obj = new ArrayList(); + try { + Integer one = 0; + Integer two = 0; + Integer three = 0; + Integer four = 0; + Integer five = 0; + Integer six = 0; + Integer seven = 0; + Integer eight = 0; + Integer nine = 0; + Integer ten = 0; + + List scores = mapper.queryScore2(assesmentId, experimentalClassId, classId); + for (int i = 0; i < scores.size(); i++) { + Integer score = scores.get(i).getScore(); + Integer number = scores.get(i).getNumber(); + if (score >= 0 && score <= 10) { + one += number; + } else if (score > 10 && score <= 20) { + two += number; + } else if (score > 20 && score <= 30) { + three += number; + } else if (score > 30 && score <= 40) { + four += number; + } else if (score > 40 && score <= 50) { + five += number; + } else if (score > 50 && score <= 60) { + six += number; + } else if (score > 60 && score <= 70) { + seven += number; + } else if (score > 70 && score <= 80) { + eight += number; + } else if (score > 80 && score <= 90) { + nine += number; + } else if (score > 90 && score <= 100) { + ten += number; + } + + } + + obj.add(ten); + obj.add(nine); + obj.add(eight); + obj.add(seven); + obj.add(six); + obj.add(five); + obj.add(four); + obj.add(three); + obj.add(two); + obj.add(one); + + + resp.put("retvalue", obj); + resp.put("retcode", 200); + } catch (Exception e) { + logger.error(e.getMessage()); + resp.put("retcode", 500); + resp.put("retvalue", "Inquiry Failed"); + return resp; + } + return resp; + } + + + /** + * 错误分布折线图 + * + * @param assesmentId + * @param experimentalClassId + * @param classId + * @return + */ + public HashMap getLinechart(Integer assesmentId, Integer experimentalClassId, List classId) { + HashMap resp = new HashMap(); + List obj = new ArrayList(); + try { + List errors = mapper.queryError(assesmentId, experimentalClassId, classId); + List names = new ArrayList(); + List datas = new ArrayList(); + + for (int i = 0; i < errors.size(); i++) { + PointRecord pointRecord = errors.get(i); + names.add(pointRecord.getJudgmentPointsName()); + datas.add(pointRecord.getNumber()); + } + + obj.add(names); + obj.add(datas); + resp.put("retvalue", obj); + resp.put("retcode", 200); + } catch (Exception e) { + logger.error(e.getMessage()); + resp.put("retcode", 500); + resp.put("retvalue", "Inquiry Failed"); + return resp; + } + return resp; + } + + + /** + * 成绩明细 + * + * @param assesmentId + * @param experimentalClassId + * @param classId + * @return + */ + public HashMap queryAssesmentScore(Integer assesmentId, Integer experimentalClassId, List classId) { + HashMap resp = new HashMap(); + try { + resp.put("retvalue", mapper.queryScore3(assesmentId, experimentalClassId, classId)); + 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/ExperimentalClassService.java b/src/main/java/com/yipin/liuwanr/service/ExperimentalClassService.java index b1c53f1..313bcc3 100644 --- a/src/main/java/com/yipin/liuwanr/service/ExperimentalClassService.java +++ b/src/main/java/com/yipin/liuwanr/service/ExperimentalClassService.java @@ -137,9 +137,7 @@ public class ExperimentalClassService { //学生信息 List students=experimentalClassMapper.getExperimentalClassDetails(student); //考勤数量 - String systemId=projectAndCourseMapper.getBycourseId(courseId); - String[] systemIds=systemId.split(","); - List project=projectAndCourseMapper.getBySystemId(systemIds,0,0); + List project=projectAndCourseMapper.getBySystemId(courseId,0,0); int denominator=project.size(); for (int i = 0; i < students.size(); i++) { Student stu=students.get(i); @@ -170,8 +168,6 @@ public class ExperimentalClassService { try { Integer experimentalClassId=experimentalClass.getExperimentalClassId(); - Student stu=new Student(); - stu.setExperimentalClassId(experimentalClassId.toString()); List students=experimentalClassMapper.querystudent(experimentalClassId); //取出学生id @@ -194,7 +190,7 @@ public class ExperimentalClassService { for (int i=0;i resp = new HashMap(); try { List projectIds = mapper.queryIsAttendance(studentId, courseId); - - String systemId = mapper2.getBycourseId(courseId); - String[] systemIds = systemId.split(","); - List projects = mapper2.getBySystemId(systemIds, 0, null); + 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) { @@ -77,11 +73,6 @@ public class ExperimentallearningService { /** * 学生签到 - * - * @param courseId - * @param studentId - * @param experimentName - * @return */ public HashMap insertAttendance(Attendance attendance) { HashMap resp = new HashMap(); @@ -107,9 +98,6 @@ public class ExperimentallearningService { /** * 学生信息展示 - * - * @param courseId - * @return */ public HashMap queryStudentName(Integer courseId) { HashMap resp = new HashMap(); @@ -127,9 +115,6 @@ public class ExperimentallearningService { /** * 授课老师 - * - * @param courseId - * @return */ public HashMap queryTeacherName(Integer courseId) { HashMap resp = new HashMap(); @@ -147,9 +132,6 @@ public class ExperimentallearningService { /** * 进入考核 - * - * @param courseId - * @return */ public HashMap queryAssesment(Integer courseId, Integer studentId) { HashMap resp = new HashMap(); diff --git a/src/main/java/com/yipin/liuwanr/service/ProjectAndCourseService.java b/src/main/java/com/yipin/liuwanr/service/ProjectAndCourseService.java index b235b2d..99f9db7 100644 --- a/src/main/java/com/yipin/liuwanr/service/ProjectAndCourseService.java +++ b/src/main/java/com/yipin/liuwanr/service/ProjectAndCourseService.java @@ -32,10 +32,7 @@ public class ProjectAndCourseService { public HashMap queryProject(Integer courseId) { HashMap resp = new HashMap(); try { - String systemId=mapper.getBycourseId(courseId); - String[] systemIds=systemId.split(","); - List project=mapper.getBySystemId(systemIds,null, null); - + List project=mapper.getBySystemId(courseId,null, null); resp.put("retcode", 200); resp.put("retvalue", project); } catch (RuntimeException e) { @@ -49,9 +46,6 @@ public class ProjectAndCourseService { /** * 修改项目状态 - * @param projectId - * @param isExperiment - * @return */ public HashMap updateIsExperiment(Project_Management management) { HashMap resp = new HashMap(); @@ -69,9 +63,6 @@ public class ProjectAndCourseService { /** * 修改考勤状态 - * @param projectId - * @param isAttendance - * @return */ public HashMap updateIsAttendance(Project_Management management) { HashMap resp = new HashMap(); @@ -86,5 +77,32 @@ public class ProjectAndCourseService { } return resp; } - + + public HashMap getCourseSchedule(Integer courseId) { + 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); + } + resp.put("retcode", 200); + resp.put("retvalue",obj); + } catch (RuntimeException e) { + logger.error(e.getMessage()); + resp.put("retcode", 500); + resp.put("retvalue", "查询失败"); + return resp; + } + return resp; + } + + + }