修改用户登录接口

master
pd 4 years ago
parent 5fff04d322
commit b59945cedf
  1. 8
      src/main/java/com/yipin/liuwanr/controller/AssesmentController.java
  2. 13
      src/main/java/com/yipin/liuwanr/entity/Score.java
  3. 30
      src/main/java/com/yipin/liuwanr/mapper/AssesmentMapper.java
  4. 17
      src/main/java/com/yipin/liuwanr/mapper/StaffMapper.java
  5. 12
      src/main/java/com/yipin/liuwanr/mapper/StudentMapper.java
  6. 11
      src/main/java/com/yipin/liuwanr/mapper/UserMapper.java
  7. 66
      src/main/java/com/yipin/liuwanr/service/AssesmentService.java
  8. 80
      src/main/java/com/yipin/liuwanr/service/UserService.java

@ -360,13 +360,9 @@ public class AssesmentController {
/** /**
* 成绩概况 * 成绩概况
* @param assesmentId
* @param experimentalClassId
* @param classId
* @return
*/ */
@GetMapping("/queryClassScore") @GetMapping("/queryClassScore")
Response queryClassScore(@RequestParam Integer assesmentId,@RequestParam Integer experimentalClassId,@RequestParam List<Integer> classId) { Response queryClassScore(@RequestParam Integer assesmentId,@RequestParam Integer experimentalClassId,@RequestParam Integer classId) {
Response resp = new Response(); Response resp = new Response();
if(StringUtils.isEmpty(assesmentId)){ if(StringUtils.isEmpty(assesmentId)){
resp.setStatus(300); resp.setStatus(300);
@ -374,7 +370,7 @@ public class AssesmentController {
}else if(StringUtils.isEmpty(experimentalClassId)){ }else if(StringUtils.isEmpty(experimentalClassId)){
resp.setStatus(300); resp.setStatus(300);
resp.setErrmessage("实验班级信息为空"); resp.setErrmessage("实验班级信息为空");
}else if(classId.isEmpty()&&classId.size()<0){ }else if(StringUtils.isEmpty(classId)){
resp.setStatus(300); resp.setStatus(300);
resp.setErrmessage("行政信息为空"); resp.setErrmessage("行政信息为空");
}else{ }else{

@ -10,6 +10,19 @@ public class Score {
private Integer pointNumber;//判分点数量 private Integer pointNumber;//判分点数量
private double error;//错误率 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() { public double getAvg() {
return avg; return avg;
} }

@ -235,24 +235,24 @@ public interface AssesmentMapper {
List<SutdentClass> queryClass(Integer assesmentId); List<SutdentClass> 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<Student> getByExperimentalClassId(Integer experimentalClassId);
@Select("SELECT studentId,studentName from student where isdel=0 and classId=#{classId} ")
List<Student> getByclassId(Integer classId);
/** /**
* 查询成绩(升序) * 查询成绩(升序)
*
* @param assesmentId
* @param experimentalClassId
* @param classId
* @return * @return
*/ */
@Select({"<script>", @Select({"<script>",
"select re.score FROM (record re left join assessment ass on ass.id=re.assesmentId) left join student stu on re.studentId=stu.studentId " "select score FROM record where score is not null and assesmentId=#{assesmentId} ",
+ " where re.assesmentId=#{assesmentId} ", "<foreach collection='student' item='stu' open='and studentId in (' separator=',' close=')'> #{stu.studentId}</foreach>",
" <if test=' experimentalClassId!=null '>and FIND_IN_SET(#{experimentalClassId},stu.experimentalClassId)</if>", " ORDER BY score",
" <if test=' classId!=null '>"
+ "<foreach collection='classId' item='id' open='and stu.classId in (' separator=',' close=')'> #{id}</foreach>"
+ "</if>",
" and re.score is not null ORDER BY re.score",
"</script>"}) "</script>"})
List<Integer> queryScore(Integer assesmentId, @Param("experimentalClassId") Integer experimentalClassId, @Param("classId") List<Integer> classId); List<Integer> queryScore(Integer assesmentId,@Param("student") List<Student> student);
/** /**
@ -287,12 +287,10 @@ public interface AssesmentMapper {
@Select({"<script>", @Select({"<script>",
"select count(*) from PointRecord where rightAndWrong = -1 and assesmentId=#{assesmentId}", "select count(*) from PointRecord where rightAndWrong = -1 and assesmentId=#{assesmentId}",
" <if test='experimentalClassId!=null '> and experimentalClassId=#{experimentalClassId} </if>", " <if test='experimentalClassId!=null '> and experimentalClassId=#{experimentalClassId} </if>",
" <if test='classId!=null '>" " <if test='classId!=null '> and classId=#{classId} </if>",
+ "<foreach collection='classId' item='id' open='and classId in (' separator=',' close=')'>#{id}</foreach>"
+ "</if>",
"</script>"}) "</script>"})
Integer queryRight(@Param("assesmentId") Integer assesmentId, @Param("experimentalClassId") Integer experimentalClassId, Integer queryRight(@Param("assesmentId") Integer assesmentId, @Param("experimentalClassId") Integer experimentalClassId,
@Param("classId") List<Integer> classId); @Param("classId") Integer classId);
/** /**

@ -2,6 +2,7 @@ package com.yipin.liuwanr.mapper;
import java.util.List; import java.util.List;
import com.yipin.liuwanr.entity.UserM;
import org.apache.ibatis.annotations.Insert; import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select; import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update; 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)" + @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}") "where a.isdel=0 and g.isdel=0 and schoolId=#{schoolId} and staffProfessionalArchitectureName=#{staffProfessionalArchitectureName} and staffGradeName=#{staffGradeName}")
Staff getStaff(Staff staff); Staff getStaff(Staff staff);
//=======全承珠
@Select({"<script>",
"select staffId,staffWorkNumber,logNumber from staff where isdel=0",
"<if test='phone!=null'>and phone=#{phone} </if>",
"<if test='workNumber!=null'>and staffWorkNumber=#{workNumber} </if>",
"<if test='uniqueIdentificationAccount!=null'>and uniqueIdentificationAccount=#{uniqueIdentificationAccount} </if>",
"</script>"})
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);
} }

@ -2,6 +2,7 @@ package com.yipin.liuwanr.mapper;
import java.util.List; import java.util.List;
import com.yipin.liuwanr.entity.UserM;
import org.apache.ibatis.annotations.Insert; import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select; import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update; import org.apache.ibatis.annotations.Update;
@ -75,7 +76,18 @@ public interface StudentMapper {
//========全承珠
@Select({"<script>",
"select studentId,studentNumber,classId,loginNumber from student where isdel=0",
"<if test='phone!=null'>and phone=#{phone} </if>",
"<if test='workNumber!=null'>and studentNumber=#{workNumber} </if>",
"<if test='uniqueIdentificationAccount!=null'>and uniqueIdentificationAccount=#{uniqueIdentificationAccount} </if>",
"</script>"})
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);

@ -184,4 +184,15 @@ public interface UserMapper {
//更新用户登录次数和最后一次登录时间 //更新用户登录次数和最后一次登录时间
@Update({ "UPDATE staff SET logNumber=logNumber+1, lastTimeOfLanding=now() WHERE phone=#{phone}"}) @Update({ "UPDATE staff SET logNumber=logNumber+1, lastTimeOfLanding=now() WHERE phone=#{phone}"})
void updateStaffLogInNumber(UserM user); 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);
} }

@ -67,6 +67,7 @@ public class AssesmentService {
/** /**
* 创建考核 * 创建考核
*
* @return * @return
*/ */
@Transactional @Transactional
@ -166,6 +167,7 @@ public class AssesmentService {
/** /**
* 修改考核管理 * 修改考核管理
*
* @return * @return
*/ */
@Transactional @Transactional
@ -267,6 +269,7 @@ public class AssesmentService {
/** /**
* 修改考核状态 * 修改考核状态
*
* @return * @return
*/ */
public HashMap<String, Object> updateState(Assesment assesment) { public HashMap<String, Object> updateState(Assesment assesment) {
@ -315,6 +318,7 @@ public class AssesmentService {
/** /**
* 查询实验班级一级栏目 * 查询实验班级一级栏目
*
* @param staffId教师id * @param staffId教师id
* @return * @return
*/ */
@ -356,6 +360,7 @@ public class AssesmentService {
/** /**
* 考核信息展示 * 考核信息展示
*
* @param assesmentId * @param assesmentId
* @return * @return
*/ */
@ -404,50 +409,51 @@ public class AssesmentService {
/** /**
* 成绩概况 * 成绩概况
*/ */
public HashMap<String, Object> queryScore(Integer assesmentId, Integer experimentalClassId, List<Integer> classId) { public HashMap<String, Object> queryScore(Integer assesmentId, Integer experimentalClassId, Integer classId) {
HashMap<String, Object> resp = new HashMap<String, Object>(); HashMap<String, Object> resp = new HashMap<String, Object>();
Score score = new Score(); Score score;
List<Student> students = null;
int size = 0; int size = 0;
try { try {
List<Integer> scores = mapper.queryScore(assesmentId, experimentalClassId, classId);
if (scores.size() > 0) { 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<Integer> scores = mapper.queryScore(assesmentId, students);
score = new Score();
if (!scores.isEmpty() && scores.size() > 0) {
size = scores.size(); size = scores.size();
//最低分 score.setMin(scores.get(0));//最低分
score.setMin(scores.get(0)); score.setMax(scores.get(size - 1)); //最高分
//最高分 score.setPeopleSize(size);//考核人数
score.setMax(scores.get(size - 1)); double median = 0.0; //中位数
//考核人数
score.setPeopleSize(size);
//中位数
double median = 0.0;
if (size % 2 == 1) { if (size % 2 == 1) {
median = scores.get((size - 1) / 2); median = scores.get((size - 1) / 2);
} else { } else {
median = (scores.get((size / 2 - 1)) + scores.get(size / 2) + 0.0) / 2; median = (scores.get((size / 2 - 1)) + scores.get(size / 2) + 0.0) / 2;
} }
score.setMedian(median); score.setMedian(median);
//平均分 int avg = 0;//平均分
int avg = 0;
for (int i = 0; i < scores.size(); i++) { for (int i = 0; i < scores.size(); i++) {
avg += scores.get(i); avg += scores.get(i);
} }
score.setAvg(avg * 1.0 / size); score.setAvg(avg * 1.0 / size);
} else { } else {
//最低分 score.setMin(0);//最低分
score.setMin(0); score.setMax(0);//最高分
//最高分 score.setPeopleSize(size);//考核人数
score.setMax(0); score.setMedian(0);//中位数
//考核人数 score.setAvg(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); score.setPointNumber(pointNumber);
//错误率 //错误率
Integer classError = mapper.queryRight(assesmentId, experimentalClassId, classId); Integer classError = mapper.queryRight(assesmentId, experimentalClassId, classId);
@ -457,6 +463,9 @@ public class AssesmentService {
double error = (classError * 1.0 / (size * pointNumber)) * 100; double error = (classError * 1.0 / (size * pointNumber)) * 100;
score.setError(error); score.setError(error);
} }
} else {
score = new Score(0.0, 0.0, 0, 0, 0, pointNumber, 0.0);
} }
resp.put("retvalue", score); resp.put("retvalue", score);
@ -607,6 +616,7 @@ public class AssesmentService {
/** /**
* 开启考核 * 开启考核
*
* @param courseId * @param courseId
* @return * @return
*/ */

@ -1,8 +1,14 @@
package com.yipin.liuwanr.service; package com.yipin.liuwanr.service;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; 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.jboss.logging.Logger;
import org.springframework.beans.factory.BeanFactory; import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.annotation.Autowired; 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.PageHelper;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
import com.yipin.liuwanr.AliyunOssConfig; 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.OssConfigUtil;
import com.yipin.liuwanr.helper.RandomUtil; import com.yipin.liuwanr.helper.RandomUtil;
import com.yipin.liuwanr.mapper.UserMapper; import com.yipin.liuwanr.mapper.UserMapper;
@ -32,6 +33,10 @@ public class UserService {
@Autowired @Autowired
private UserMapper userMapper; private UserMapper userMapper;
@Autowired
private StaffMapper staffMapper;
@Autowired
private StudentMapper studentMapper;
@Autowired @Autowired
private JedisCluster jedis; private JedisCluster jedis;
@ -195,21 +200,72 @@ public class UserService {
return resp; return resp;
} }
public HashMap<String, Object> logins(UserM user){ // public HashMap<String, Object> logins(UserM user){
////
//// HashMap<String, Object> resp = new HashMap<String, Object>();
//// 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<String, Object> logins(UserM userM){
HashMap<String, Object> resp = new HashMap<String, Object>(); HashMap<String, Object> resp = new HashMap<String, Object>();
List<Object> obj=new ArrayList<>();
String param=userM.getPhone();
String password=userM.getPassword();
Student student;
Staff staff;
try { try {
resp.put("retvalue", userMapper.logins(user)); UserM user=userMapper.loginsQ(param,password);
if (resp.get("retvalue")==null) { if(user!=null) {
resp.put("retcode", 300); int loginNumber=user.getLogInNumber()+1;
resp.put("retvalue", "登录失败,账号密码有误或不存在!"); Integer userId=user.getUserId();
}else { 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("retcode", 200);
resp.put("retvalue", obj);
}else {
resp.put("retcode", 300);
resp.put("retvalue", "Login failed");
} }
} catch (RuntimeException e) { } catch (RuntimeException e) {
logger.error(e.getMessage()); logger.error(e.getMessage());
resp.put("retcode", 500); resp.put("retcode", 500);
resp.put("retvalue", "登录异常,请稍后再试!"); resp.put("retvalue", "Inquiry Failed");
return resp; return resp;
} }
return resp; return resp;

Loading…
Cancel
Save