diff --git a/src/main/java/com/yipin/liuwanr/Test.java b/src/main/java/com/yipin/liuwanr/Test.java index 98b9246..c9d8102 100644 --- a/src/main/java/com/yipin/liuwanr/Test.java +++ b/src/main/java/com/yipin/liuwanr/Test.java @@ -15,9 +15,9 @@ public class Test { public static void main(String[] args) throws Exception { //方法一 - System.out.println((new Test()).getURLContent()); - String urlStr = "http://vip.stock.finance.sina.com.cn/quotes_service/api/json_v2.php/Market_Center.getHQNodeData?page=1&num=40&sort=symbol&asc=1&node=hs_a&symbol=&_s_r_a=init"; - System.out.println((new Test()).getURLContent(urlStr)); +// System.out.println((new Test()).getURLContent()); +// String urlStr = "http://vip.stock.finance.sina.com.cn/quotes_service/api/json_v2.php/Market_Center.getHQNodeData?page=1&num=40&sort=symbol&asc=1&node=hs_a&symbol=&_s_r_a=init"; +// System.out.println((new Test()).getURLContent(urlStr)); } diff --git a/src/main/java/com/yipin/liuwanr/controller/AssesmentController.java b/src/main/java/com/yipin/liuwanr/controller/AssesmentController.java index 8b1cdad..3c613fb 100644 --- a/src/main/java/com/yipin/liuwanr/controller/AssesmentController.java +++ b/src/main/java/com/yipin/liuwanr/controller/AssesmentController.java @@ -367,12 +367,6 @@ public class AssesmentController { if(StringUtils.isEmpty(assesmentId)){ resp.setStatus(300); resp.setErrmessage("考核信息为空"); - }else if(StringUtils.isEmpty(experimentalClassId)){ - resp.setStatus(300); - resp.setErrmessage("实验班级信息为空"); - }else if(StringUtils.isEmpty(classId)){ - resp.setStatus(300); - resp.setErrmessage("行政信息为空"); }else{ HashMap ret = service.queryScore(assesmentId,experimentalClassId,classId); int status = (int) ret.get("retcode"); @@ -397,18 +391,11 @@ public class AssesmentController { * @return */ @GetMapping("/queryHistogram") - Response queryHistogram(@RequestParam Integer assesmentId,@RequestParam Integer experimentalClassId, - @RequestParam List classId) { + Response queryHistogram(@RequestParam Integer assesmentId,@RequestParam Integer experimentalClassId,@RequestParam Integer classId) { Response resp = new Response(); if(StringUtils.isEmpty(assesmentId)){ resp.setStatus(300); resp.setErrmessage("考核信息为空"); - }else if(StringUtils.isEmpty(experimentalClassId)){ - resp.setStatus(300); - resp.setErrmessage("实验班级信息为空"); - }else if(classId.isEmpty()&&classId.size()<0){ - resp.setStatus(300); - resp.setErrmessage("行政信息为空"); }else { HashMap ret = service.queryHistogram(assesmentId, experimentalClassId, classId); int status = (int) ret.get("retcode"); @@ -432,18 +419,11 @@ public class AssesmentController { * @return */ @GetMapping("/getLinechart") - Response getLinechart(@RequestParam Integer assesmentId,@RequestParam Integer experimentalClassId, - @RequestParam List classId) { + Response getLinechart(@RequestParam Integer assesmentId,@RequestParam Integer experimentalClassId,@RequestParam Integer classId) { Response resp = new Response(); if(StringUtils.isEmpty(assesmentId)){ resp.setStatus(300); resp.setErrmessage("考核信息为空"); - }else if(StringUtils.isEmpty(experimentalClassId)){ - resp.setStatus(300); - resp.setErrmessage("实验班级信息为空"); - }else if(classId.isEmpty()&&classId.size()<0){ - resp.setStatus(300); - resp.setErrmessage("行政信息为空"); }else{ HashMap ret = service.getLinechart(assesmentId,experimentalClassId,classId); int status = (int) ret.get("retcode"); @@ -467,18 +447,11 @@ public class AssesmentController { * @return */ @GetMapping("/queryAssesmentScore") - Response queryAssesmentScore(@RequestParam Integer assesmentId,@RequestParam Integer experimentalClassId, - @RequestParam List classId) { + Response queryAssesmentScore(@RequestParam Integer assesmentId,@RequestParam Integer experimentalClassId,@RequestParam Integer classId) { Response resp = new Response(); if(StringUtils.isEmpty(assesmentId)){ resp.setStatus(300); resp.setErrmessage("考核信息为空"); - }else if(StringUtils.isEmpty(experimentalClassId)){ - resp.setStatus(300); - resp.setErrmessage("实验班级信息为空"); - }else if(classId.isEmpty()&&classId.size()<0){ - resp.setStatus(300); - resp.setErrmessage("行政信息为空"); }else{ HashMap ret = service.queryAssesmentScore(assesmentId,experimentalClassId,classId); int status = (int) ret.get("retcode"); diff --git a/src/main/java/com/yipin/liuwanr/entity/Record.java b/src/main/java/com/yipin/liuwanr/entity/Record.java index a1a382a..91ff834 100644 --- a/src/main/java/com/yipin/liuwanr/entity/Record.java +++ b/src/main/java/com/yipin/liuwanr/entity/Record.java @@ -17,6 +17,16 @@ public class Record { private Integer integral; private String projectName; + private String studentName; + + public String getStudentName() { + return studentName; + } + + public void setStudentName(String studentName) { + this.studentName = studentName; + } + private Integer number; public Integer getNumber() { diff --git a/src/main/java/com/yipin/liuwanr/mapper/AssesmentMapper.java b/src/main/java/com/yipin/liuwanr/mapper/AssesmentMapper.java index f639203..034c27e 100644 --- a/src/main/java/com/yipin/liuwanr/mapper/AssesmentMapper.java +++ b/src/main/java/com/yipin/liuwanr/mapper/AssesmentMapper.java @@ -127,7 +127,8 @@ public interface AssesmentMapper { * @param studentIds * @return */ - @Select({""}) @@ -186,7 +187,7 @@ public interface AssesmentMapper { * @return */ @Select("select DISTINCT DATE_FORMAT(creationTime,'%Y') as creationTime from experimental_class_ning " + - " WHERE isdel=0 and founder=(select staffName from staff where staffId=#{staffId}) and schoolId={schoolId} GROUP BY creationTime ORDER BY creationTime desc ") + " WHERE isdel=0 and founder=(select staffName from staff where staffId=#{staffId}) and schoolId=#{schoolId} GROUP BY creationTime ORDER BY creationTime desc ") List queryCreationTime(@Param("staffId") Integer staffId,@Param("schoolId")Integer schoolId); @@ -234,12 +235,12 @@ public interface AssesmentMapper { @Select("SELECT c.classId as classId,c.className as className from assessment ass left join class c on FIND_IN_SET(c.classId,ass.classId) where ass.id=#{assesmentId}") List queryClass(Integer assesmentId); - - @Select("select s.studentId,studentName from student s left join experimental_class_student ecs on s.studentId=ecs.studentId where s.isdel=0 and ecs.experimentalClassId=#{experimentalClassId} ") + //s.isdel=0 and + @Select("select s.studentId,studentName from student s left join experimental_class_student ecs on s.studentId=ecs.studentId where ecs.experimentalClassId=#{experimentalClassId} ") List getByExperimentalClassId(Integer experimentalClassId); - - @Select("SELECT studentId,studentName from student where isdel=0 and classId=#{classId} ") + //isdel=0 and + @Select("SELECT studentId,studentName from student where classId=#{classId} ") List getByclassId(Integer classId); @@ -257,23 +258,13 @@ public interface AssesmentMapper { /** * 分组查询分数和对应人数 - * - * @param assesmentId - * @param experimentalClassId - * @param classId - * @return */ @Select({""}) - List queryScore2(@Param("assesmentId") Integer assesmentId, @Param("experimentalClassId") Integer experimentalClassId, - @Param("classId") List classId); + List getGroupByScore(@Param("assesmentId") Integer assesmentId,@Param("students") List students); /** @@ -312,28 +303,21 @@ public interface AssesmentMapper { * @return */ @Select({""}) List queryError(@Param("assesmentId") Integer assesmentId, @Param("experimentalClassId") Integer experimentalClassId, - @Param("classId") List classId); + @Param("classId") Integer classId); @Select({""}) - List> queryScore3(@Param("assesmentId") Integer assesmentId, @Param("experimentalClassId") Integer experimentalClassId, - @Param("classId") List classId); + List queryScoreDetailed(@Param("assesmentId") Integer assesmentId,@Param("students") List students); //开始考核 diff --git a/src/main/java/com/yipin/liuwanr/service/AssesmentService.java b/src/main/java/com/yipin/liuwanr/service/AssesmentService.java index 3732701..e670df0 100644 --- a/src/main/java/com/yipin/liuwanr/service/AssesmentService.java +++ b/src/main/java/com/yipin/liuwanr/service/AssesmentService.java @@ -76,9 +76,9 @@ public class AssesmentService { try { //转换时间格式 assesment = AssesmentHelper.helpAssesment(assesment); - if (assesment.getExperimentalClassId() != null) { - //行政班级id - List classid = mapper.queryClassId(studentIds); + String experimentalClassId=assesment.getExperimentalClassId(); + if (!StringUtils.isEmpty(experimentalClassId)) { + List classid = mapper.queryClassId(studentIds);//行政班级id String classId = String.join(",", classid); assesment.setClassId(classId); } @@ -92,13 +92,6 @@ public class AssesmentService { //得到考核id Integer assesmentId = assesment.getId(); - String name = assesment.getAssesmentName(); - Integer number = mapper.getByAssesmentName(name); - if (number != null && number > 0) { - name += (number + 1); - assesment.setAssesmentName(name); - } - //往记录表中添加选中的学生信息,哪名学生要参与某一课程的什么考核,该考核下的 哪一项目 mapper.insertRecore(studentIds, assesment.getExperimentId(), assesment.getCourseId(), assesmentId); @@ -180,16 +173,14 @@ public class AssesmentService { Assesment before = mapper.queryGetById(assesment.getId()); //数据库存储的学生 List students = mapper.queryStudent(assesment.getId()); - if (assesment.getExperimentalClassId() != null) { - //新的行政班级id - List classid = mapper.queryClassId(studentIds); + String experimentalClassId=assesment.getExperimentalClassId(); + if (!StringUtils.isEmpty(experimentalClassId)) { + List classid = mapper.queryClassId(studentIds);//新的行政班级id String classId = String.join(",", classid); if (!classId.equals(before.getClassId())) { assesment.setClassId(classId); - } else { - assesment.setClassId(before.getClassId()); } - } else if (assesment.getClassId() != null) { + } else if (!StringUtils.isEmpty(assesment.getClassId())) { assesment.setExperimentalClassId(null); } // 比较两批学生的信息 @@ -217,13 +208,6 @@ public class AssesmentService { Integer pointNumber = mapper.queryPointNumber(assesment.getExperimentId()); assesment.setAssessmentNumber(pointNumber); - String name = assesment.getAssesmentName(); - Integer number = mapper.getByAssesmentName(name); - if (number != null && number > 0) { - name += (number + 1); - assesment.setAssesmentName(name); - } - mapper.updateAssesment(assesment); resp.put("retcode", 200); @@ -391,7 +375,7 @@ public class AssesmentService { try { List experimentalClasses = mapper.queryExperimental(assesmentId); List classes = mapper.queryClass(assesmentId); - obj.put("xperimentalClass", experimentalClasses); + obj.put("experimentalClass", experimentalClasses); obj.put("class", classes); resp.put("retvalue", obj); @@ -412,15 +396,9 @@ public class AssesmentService { public HashMap queryScore(Integer assesmentId, Integer experimentalClassId, Integer classId) { HashMap resp = new HashMap(); Score score; - List students = null; int size = 0; try { - - if (experimentalClassId != null) { - students = mapper.getByExperimentalClassId(experimentalClassId); - } else if (classId != null) { - students = mapper.getByclassId(classId); - } + List students=queryStudents(experimentalClassId,classId); //判分点数量 Integer pointNumber = mapper.getAssesmentNumber(assesmentId); if (StringUtils.isEmpty(pointNumber)) { @@ -467,7 +445,6 @@ public class AssesmentService { } else { score = new Score(0.0, 0.0, 0, 0, 0, pointNumber, 0.0); } - resp.put("retvalue", score); resp.put("retcode", 200); } catch (Exception e) { @@ -479,16 +456,25 @@ public class AssesmentService { return resp; } + private List queryStudents(Integer experimentalClassId, Integer classId){ + List students=null; + if (experimentalClassId != null) { + students = mapper.getByExperimentalClassId(experimentalClassId); + } else if (classId != null) { + students = mapper.getByclassId(classId); + } + return students; + } + /** * 成绩柱状图 - * * @param assesmentId * @param experimentalClassId * @param classId * @return */ - public HashMap queryHistogram(Integer assesmentId, Integer experimentalClassId, List classId) { + public HashMap queryHistogram(Integer assesmentId, Integer experimentalClassId,Integer classId) { HashMap resp = new HashMap(); List obj = new ArrayList(); try { @@ -503,7 +489,9 @@ public class AssesmentService { Integer nine = 0; Integer ten = 0; - List scores = mapper.queryScore2(assesmentId, experimentalClassId, classId); + List students=queryStudents(experimentalClassId,classId); + + List scores = mapper.getGroupByScore(assesmentId,students); for (int i = 0; i < scores.size(); i++) { Integer score = scores.get(i).getScore(); Integer number = scores.get(i).getNumber(); @@ -563,7 +551,7 @@ public class AssesmentService { * @param classId * @return */ - public HashMap getLinechart(Integer assesmentId, Integer experimentalClassId, List classId) { + public HashMap getLinechart(Integer assesmentId, Integer experimentalClassId,Integer classId) { HashMap resp = new HashMap(); List obj = new ArrayList(); try { @@ -599,10 +587,14 @@ public class AssesmentService { * @param classId * @return */ - public HashMap queryAssesmentScore(Integer assesmentId, Integer experimentalClassId, List classId) { + public HashMap queryAssesmentScore(Integer assesmentId, Integer experimentalClassId,Integer classId) { HashMap resp = new HashMap(); try { - resp.put("retvalue", mapper.queryScore3(assesmentId, experimentalClassId, classId)); + List students=queryStudents(experimentalClassId,classId); + if(!students.isEmpty() && students.size()>0){ + List records=mapper.queryScoreDetailed(assesmentId,students); + resp.put("retvalue",records ); + } resp.put("retcode", 200); } catch (Exception e) { logger.error(e.getMessage());