From b59945cedff1297b6ec2736db45a46395abae26f Mon Sep 17 00:00:00 2001 From: pd <2776455882@qq.com> Date: Wed, 29 Jul 2020 10:48:08 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=94=A8=E6=88=B7=E7=99=BB?= =?UTF-8?q?=E5=BD=95=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/AssesmentController.java | 8 +- .../java/com/yipin/liuwanr/entity/Score.java | 15 +- .../yipin/liuwanr/mapper/AssesmentMapper.java | 30 ++-- .../com/yipin/liuwanr/mapper/StaffMapper.java | 17 +++ .../yipin/liuwanr/mapper/StudentMapper.java | 14 +- .../com/yipin/liuwanr/mapper/UserMapper.java | 11 ++ .../liuwanr/service/AssesmentService.java | 136 ++++++++++-------- .../yipin/liuwanr/service/UserService.java | 80 +++++++++-- 8 files changed, 212 insertions(+), 99 deletions(-) diff --git a/src/main/java/com/yipin/liuwanr/controller/AssesmentController.java b/src/main/java/com/yipin/liuwanr/controller/AssesmentController.java index 88747d2..8b1cdad 100644 --- a/src/main/java/com/yipin/liuwanr/controller/AssesmentController.java +++ b/src/main/java/com/yipin/liuwanr/controller/AssesmentController.java @@ -360,13 +360,9 @@ public class AssesmentController { /** * 成绩概况 - * @param assesmentId - * @param experimentalClassId - * @param classId - * @return */ @GetMapping("/queryClassScore") - Response queryClassScore(@RequestParam Integer assesmentId,@RequestParam Integer experimentalClassId,@RequestParam List classId) { + Response queryClassScore(@RequestParam Integer assesmentId,@RequestParam Integer experimentalClassId,@RequestParam Integer classId) { Response resp = new Response(); if(StringUtils.isEmpty(assesmentId)){ resp.setStatus(300); @@ -374,7 +370,7 @@ public class AssesmentController { }else if(StringUtils.isEmpty(experimentalClassId)){ resp.setStatus(300); resp.setErrmessage("实验班级信息为空"); - }else if(classId.isEmpty()&&classId.size()<0){ + }else if(StringUtils.isEmpty(classId)){ resp.setStatus(300); resp.setErrmessage("行政信息为空"); }else{ diff --git a/src/main/java/com/yipin/liuwanr/entity/Score.java b/src/main/java/com/yipin/liuwanr/entity/Score.java index 644bac7..889533f 100644 --- a/src/main/java/com/yipin/liuwanr/entity/Score.java +++ b/src/main/java/com/yipin/liuwanr/entity/Score.java @@ -9,7 +9,20 @@ public class Score { private Integer peopleSize;//考核人数 private Integer pointNumber;//判分点数量 private double error;//错误率 - + + public Score(double avg, double median, Integer min, Integer max, Integer peopleSize, Integer pointNumber, double error) { + this.avg = avg; + this.median = median; + this.min = min; + this.max = max; + this.peopleSize = peopleSize; + this.pointNumber = pointNumber; + this.error = error; + } + + public Score() { + } + public double getAvg() { return avg; } diff --git a/src/main/java/com/yipin/liuwanr/mapper/AssesmentMapper.java b/src/main/java/com/yipin/liuwanr/mapper/AssesmentMapper.java index cac2060..f639203 100644 --- a/src/main/java/com/yipin/liuwanr/mapper/AssesmentMapper.java +++ b/src/main/java/com/yipin/liuwanr/mapper/AssesmentMapper.java @@ -235,24 +235,24 @@ public interface AssesmentMapper { 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} ") + List getByExperimentalClassId(Integer experimentalClassId); + + + @Select("SELECT studentId,studentName from student where isdel=0 and classId=#{classId} ") + List getByclassId(Integer classId); + + /** * 查询成绩(升序) - * - * @param assesmentId - * @param experimentalClassId - * @param classId * @return */ @Select({""}) - List queryScore(Integer assesmentId, @Param("experimentalClassId") Integer experimentalClassId, @Param("classId") List classId); + List queryScore(Integer assesmentId,@Param("student") List student); /** @@ -287,12 +287,10 @@ public interface AssesmentMapper { @Select({""}) Integer queryRight(@Param("assesmentId") Integer assesmentId, @Param("experimentalClassId") Integer experimentalClassId, - @Param("classId") List classId); + @Param("classId") Integer classId); /** diff --git a/src/main/java/com/yipin/liuwanr/mapper/StaffMapper.java b/src/main/java/com/yipin/liuwanr/mapper/StaffMapper.java index bb2e046..c6a7dee 100644 --- a/src/main/java/com/yipin/liuwanr/mapper/StaffMapper.java +++ b/src/main/java/com/yipin/liuwanr/mapper/StaffMapper.java @@ -2,6 +2,7 @@ package com.yipin.liuwanr.mapper; import java.util.List; +import com.yipin.liuwanr.entity.UserM; import org.apache.ibatis.annotations.Insert; import org.apache.ibatis.annotations.Select; import org.apache.ibatis.annotations.Update; @@ -75,4 +76,20 @@ public interface StaffMapper { @Select("select a.staffProfessionalArchitectureId,g.staffGradeId from staff_professional_architecture a left join staff_grade g on (a.staffProfessionalArchitectureId=g.staffProfessionalArchitectureId)" + "where a.isdel=0 and g.isdel=0 and schoolId=#{schoolId} and staffProfessionalArchitectureName=#{staffProfessionalArchitectureName} and staffGradeName=#{staffGradeName}") Staff getStaff(Staff staff); + + + + //=======全承珠 + + @Select({""}) + Staff queryStaffQ(UserM user); + + + @Update("update staff set lastTimeOfLanding=#{lastTime},logNumber=#{logNumber} where staffId=#{staffId}") + void updateStaffQ(@Param("lastTime") String lastTime,@Param("logNumber") Integer logNumber,@Param("staffId") Integer staffId); } \ No newline at end of file diff --git a/src/main/java/com/yipin/liuwanr/mapper/StudentMapper.java b/src/main/java/com/yipin/liuwanr/mapper/StudentMapper.java index 1533ef4..69c6113 100644 --- a/src/main/java/com/yipin/liuwanr/mapper/StudentMapper.java +++ b/src/main/java/com/yipin/liuwanr/mapper/StudentMapper.java @@ -2,6 +2,7 @@ package com.yipin.liuwanr.mapper; import java.util.List; +import com.yipin.liuwanr.entity.UserM; import org.apache.ibatis.annotations.Insert; import org.apache.ibatis.annotations.Select; import org.apache.ibatis.annotations.Update; @@ -75,7 +76,18 @@ public interface StudentMapper { - + //========全承珠 + @Select({""}) + Student queryStudentQ(UserM user); + + + @Update("update student set lastLoginTime=#{lastTime},loginNumber=#{loginNumber} where studentId=#{studentId}") + void updateStudentQ(@Param("lastTime") String lastTime,@Param("loginNumber") Integer loginNumber,@Param("studentId") Integer studentId); diff --git a/src/main/java/com/yipin/liuwanr/mapper/UserMapper.java b/src/main/java/com/yipin/liuwanr/mapper/UserMapper.java index b1fe52b..40879b7 100644 --- a/src/main/java/com/yipin/liuwanr/mapper/UserMapper.java +++ b/src/main/java/com/yipin/liuwanr/mapper/UserMapper.java @@ -184,4 +184,15 @@ public interface UserMapper { //更新用户登录次数和最后一次登录时间 @Update({ "UPDATE staff SET logNumber=logNumber+1, lastTimeOfLanding=now() WHERE phone=#{phone}"}) void updateStaffLogInNumber(UserM user); + + + + //========全承珠 + @Select("select userId,password,accountRole,logInNumber,workNumber,phone,uniqueIdentificationAccount,schoolId from user " + + " where isdel=0 and password=#{password} and (phone=#{userAccount} or workNumber=#{userAccount} or uniqueIdentificationAccount=#{userAccount})") + UserM loginsQ(@Param("userAccount")String userAccount,@Param("password")String password); + + + @Update("update user set lastTimeOfLanding=#{time},logInNumber=#{logInNumber} where userId=#{userId}") + void updateUserQ(@Param("time")String time,@Param("logInNumber") Integer logInNumber,@Param("userId") Integer userId); } \ No newline at end of file diff --git a/src/main/java/com/yipin/liuwanr/service/AssesmentService.java b/src/main/java/com/yipin/liuwanr/service/AssesmentService.java index ac7582f..3732701 100644 --- a/src/main/java/com/yipin/liuwanr/service/AssesmentService.java +++ b/src/main/java/com/yipin/liuwanr/service/AssesmentService.java @@ -67,10 +67,11 @@ public class AssesmentService { /** * 创建考核 + * * @return */ @Transactional - public HashMap addAssesment(Assesment assesment, List studentIds ) { + public HashMap addAssesment(Assesment assesment, List studentIds) { HashMap resp = new HashMap(); try { //转换时间格式 @@ -91,10 +92,10 @@ 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); + String name = assesment.getAssesmentName(); + Integer number = mapper.getByAssesmentName(name); + if (number != null && number > 0) { + name += (number + 1); assesment.setAssesmentName(name); } @@ -143,14 +144,14 @@ public class AssesmentService { */ public HashMap queryGetById(Integer id) { HashMap resp = new HashMap(); - HashMap obj=new HashMap<>(); + HashMap obj = new HashMap<>(); try { //考核信息 Assesment assesment = mapper.queryGetById(id); //之前选中的学生 List students = mapper.queryStudent(id); - obj.put("assesment",assesment); - obj.put("students",students); + obj.put("assesment", assesment); + obj.put("students", students); resp.put("retvalue", obj); resp.put("retcode", 200); @@ -166,6 +167,7 @@ public class AssesmentService { /** * 修改考核管理 + * * @return */ @Transactional @@ -215,10 +217,10 @@ 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); + String name = assesment.getAssesmentName(); + Integer number = mapper.getByAssesmentName(name); + if (number != null && number > 0) { + name += (number + 1); assesment.setAssesmentName(name); } @@ -229,7 +231,7 @@ public class AssesmentService { logger.error(e.getMessage()); resp.put("retcode", 500); resp.put("retvalue", "Update Failed"); - throw new RuntimeException(); + throw new RuntimeException(); } return resp; } @@ -267,6 +269,7 @@ public class AssesmentService { /** * 修改考核状态 + * * @return */ public HashMap updateState(Assesment assesment) { @@ -315,13 +318,14 @@ public class AssesmentService { /** * 查询实验班级一级栏目 + * * @param staffId:教师id * @return */ - public HashMap queryCretionTime(Integer staffId,Integer schoolId) { + public HashMap queryCretionTime(Integer staffId, Integer schoolId) { HashMap resp = new HashMap(); try { - resp.put("retvalue", mapper.queryCreationTime(staffId,schoolId)); + resp.put("retvalue", mapper.queryCreationTime(staffId, schoolId)); resp.put("retcode", 200); } catch (Exception e) { logger.error(e.getMessage()); @@ -339,10 +343,10 @@ public class AssesmentService { * @param cretionTime * @return */ - public HashMap queryCretionTime(String cretionTime, Integer staffId,Integer schoolId) { + public HashMap queryCretionTime(String cretionTime, Integer staffId, Integer schoolId) { HashMap resp = new HashMap(); try { - resp.put("retvalue", mapper.queryExperimentalClass(cretionTime, staffId,schoolId)); + resp.put("retvalue", mapper.queryExperimentalClass(cretionTime, staffId, schoolId)); resp.put("retcode", 200); } catch (Exception e) { logger.error(e.getMessage()); @@ -356,6 +360,7 @@ public class AssesmentService { /** * 考核信息展示 + * * @param assesmentId * @return */ @@ -382,12 +387,12 @@ public class AssesmentService { */ public HashMap getByclass(Integer assesmentId) { HashMap resp = new HashMap(); - HashMap obj = new HashMap(); + HashMap obj = new HashMap(); try { List experimentalClasses = mapper.queryExperimental(assesmentId); List classes = mapper.queryClass(assesmentId); - obj.put("xperimentalClass",experimentalClasses); - obj.put("class",classes); + obj.put("xperimentalClass", experimentalClasses); + obj.put("class", classes); resp.put("retvalue", obj); resp.put("retcode", 200); @@ -404,59 +409,63 @@ public class AssesmentService { /** * 成绩概况 */ - public HashMap queryScore(Integer assesmentId, Integer experimentalClassId, List classId) { + public HashMap queryScore(Integer assesmentId, Integer experimentalClassId, Integer classId) { HashMap resp = new HashMap(); - Score score = new Score(); + Score score; + List students = null; 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); + + if (experimentalClassId != null) { + students = mapper.getByExperimentalClassId(experimentalClassId); + } else if (classId != null) { + students = mapper.getByclassId(classId); + } + //判分点数量 + Integer pointNumber = mapper.getAssesmentNumber(assesmentId); + if (StringUtils.isEmpty(pointNumber)) { + pointNumber = 0; + } + if (!students.isEmpty() && students.size() > 0) { + List scores = mapper.queryScore(assesmentId, students); + score = new Score(); + if (!scores.isEmpty() && 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 { - 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.setMin(0);//最低分 + score.setMax(0);//最高分 + score.setPeopleSize(size);//考核人数 + score.setMedian(0);//中位数 + score.setAvg(0);//平均分 } - 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) { + 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; + } else { + double error = (classError * 1.0 / (size * pointNumber)) * 100; score.setError(error); } + + } else { + score = new Score(0.0, 0.0, 0, 0, 0, pointNumber, 0.0); } resp.put("retvalue", score); @@ -607,6 +616,7 @@ public class AssesmentService { /** * 开启考核 + * * @param courseId * @return */ diff --git a/src/main/java/com/yipin/liuwanr/service/UserService.java b/src/main/java/com/yipin/liuwanr/service/UserService.java index d3e956f..4a028eb 100644 --- a/src/main/java/com/yipin/liuwanr/service/UserService.java +++ b/src/main/java/com/yipin/liuwanr/service/UserService.java @@ -1,8 +1,14 @@ package com.yipin.liuwanr.service; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; import java.util.HashMap; import java.util.List; +import com.yipin.liuwanr.entity.*; +import com.yipin.liuwanr.mapper.StaffMapper; +import com.yipin.liuwanr.mapper.StudentMapper; import org.jboss.logging.Logger; import org.springframework.beans.factory.BeanFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -13,11 +19,6 @@ import com.aliyun.oss.OSSClient; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; import com.yipin.liuwanr.AliyunOssConfig; -import com.yipin.liuwanr.entity.Demo; -import com.yipin.liuwanr.entity.FilesResult; -import com.yipin.liuwanr.entity.PageResult; -import com.yipin.liuwanr.entity.User; -import com.yipin.liuwanr.entity.UserM; import com.yipin.liuwanr.helper.OssConfigUtil; import com.yipin.liuwanr.helper.RandomUtil; import com.yipin.liuwanr.mapper.UserMapper; @@ -32,6 +33,10 @@ public class UserService { @Autowired private UserMapper userMapper; + @Autowired + private StaffMapper staffMapper; + @Autowired + private StudentMapper studentMapper; @Autowired private JedisCluster jedis; @@ -195,21 +200,72 @@ public class UserService { return resp; } - public HashMap logins(UserM user){ +// public HashMap logins(UserM user){ +//// +//// HashMap resp = new HashMap(); +//// try { +//// resp.put("retvalue", userMapper.logins(user)); +//// if (resp.get("retvalue")==null) { +//// resp.put("retcode", 300); +//// resp.put("retvalue", "登录失败,账号密码有误或不存在!"); +//// }else { +//// resp.put("retcode", 200); +//// } +//// } catch (RuntimeException e) { +//// logger.error(e.getMessage()); +//// resp.put("retcode", 500); +//// resp.put("retvalue", "登录异常,请稍后再试!"); +//// return resp; +//// } +//// return resp; +//// } + + public HashMap logins(UserM userM){ HashMap resp = new HashMap(); + List obj=new ArrayList<>(); + String param=userM.getPhone(); + String password=userM.getPassword(); + Student student; + Staff staff; try { - resp.put("retvalue", userMapper.logins(user)); - if (resp.get("retvalue")==null) { - resp.put("retcode", 300); - resp.put("retvalue", "登录失败,账号密码有误或不存在!"); + UserM user=userMapper.loginsQ(param,password); + if(user!=null) { + int loginNumber=user.getLogInNumber()+1; + Integer userId=user.getUserId(); + long time=System.currentTimeMillis(); + Date date = new Date(time); + SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + String lastTime=sd.format(date); + if(user.getAccountRole().equals(4)) { + student=studentMapper.queryStudentQ(user); + if(student!=null) { + Integer studentId=student.getStudentId(); + studentMapper.updateStudentQ(lastTime,loginNumber, studentId); + obj.add(student); + } + }else if(user.getAccountRole().equals(3)) { + staff=staffMapper.queryStaffQ(user); + if(staff!=null) { + Integer staffId=staff.getStaffId(); + staffMapper.updateStaffQ(lastTime,loginNumber, staffId); + obj.add(staff); + } + } + user.setPassword(null); + obj.add(user); + userMapper.updateUserQ(lastTime,loginNumber, userId); + + resp.put("retcode", 200); + resp.put("retvalue", obj); }else { - resp.put("retcode", 200); + resp.put("retcode", 300); + resp.put("retvalue", "Login failed"); } } catch (RuntimeException e) { logger.error(e.getMessage()); resp.put("retcode", 500); - resp.put("retvalue", "登录异常,请稍后再试!"); + resp.put("retvalue", "Inquiry Failed"); return resp; } return resp;