修改用户登录接口

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. 112
      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")
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();
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{

@ -10,6 +10,19 @@ public class Score {
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;
}

@ -235,24 +235,24 @@ public interface AssesmentMapper {
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
*/
@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 "
+ " where re.assesmentId=#{assesmentId} ",
" <if test=' experimentalClassId!=null '>and FIND_IN_SET(#{experimentalClassId},stu.experimentalClassId)</if>",
" <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",
"select score FROM record where score is not null and assesmentId=#{assesmentId} ",
"<foreach collection='student' item='stu' open='and studentId in (' separator=',' close=')'> #{stu.studentId}</foreach>",
" ORDER BY score",
"</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 count(*) from PointRecord where rightAndWrong = -1 and assesmentId=#{assesmentId}",
" <if test='experimentalClassId!=null '> and experimentalClassId=#{experimentalClassId} </if>",
" <if test='classId!=null '>"
+ "<foreach collection='classId' item='id' open='and classId in (' separator=',' close=')'>#{id}</foreach>"
+ "</if>",
" <if test='classId!=null '> and classId=#{classId} </if>",
"</script>"})
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 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({"<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 com.yipin.liuwanr.entity.UserM;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
@ -75,8 +76,19 @@ 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}"})
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,10 +67,11 @@ public class AssesmentService {
/**
* 创建考核
*
* @return
*/
@Transactional
public HashMap<String, Object> addAssesment(Assesment assesment, List<Integer> studentIds ) {
public HashMap<String, Object> addAssesment(Assesment assesment, List<Integer> studentIds) {
HashMap<String, Object> resp = new HashMap<String, Object>();
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<String, Object> queryGetById(Integer id) {
HashMap<String, Object> resp = new HashMap<String, Object>();
HashMap<String, Object> obj=new HashMap<>();
HashMap<String, Object> obj = new HashMap<>();
try {
//考核信息
Assesment assesment = mapper.queryGetById(id);
//之前选中的学生
List<Student> 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);
}
@ -267,6 +269,7 @@ public class AssesmentService {
/**
* 修改考核状态
*
* @return
*/
public HashMap<String, Object> updateState(Assesment assesment) {
@ -315,13 +318,14 @@ public class AssesmentService {
/**
* 查询实验班级一级栏目
*
* @param staffId教师id
* @return
*/
public HashMap<String, Object> queryCretionTime(Integer staffId,Integer schoolId) {
public HashMap<String, Object> queryCretionTime(Integer staffId, Integer schoolId) {
HashMap<String, Object> resp = new HashMap<String, Object>();
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<String, Object> queryCretionTime(String cretionTime, Integer staffId,Integer schoolId) {
public HashMap<String, Object> queryCretionTime(String cretionTime, Integer staffId, Integer schoolId) {
HashMap<String, Object> resp = new HashMap<String, Object>();
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
*/
@ -386,8 +391,8 @@ public class AssesmentService {
try {
List<ExperimentalClass> experimentalClasses = mapper.queryExperimental(assesmentId);
List<SutdentClass> 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<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>();
Score score = new Score();
Score score;
List<Student> students = null;
int size = 0;
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();
//最低分
score.setMin(scores.get(0));
//最高分
score.setMax(scores.get(size - 1));
//考核人数
score.setPeopleSize(size);
//中位数
double median = 0.0;
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;
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.setMin(0);//最低分
score.setMax(0);//最高分
score.setPeopleSize(size);//考核人数
score.setMedian(0);//中位数
score.setAvg(0);//平均分
}
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
*/

@ -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<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>();
List<Object> 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", "登录失败,账号密码有误或不存在!");
}else {
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", 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;

Loading…
Cancel
Save