派生自 projectDept/qhighschool

EricsHu
2023-11-24 0ad2f07a292895eeb3b9618eb1e275568c63a59e
src/main/java/com/qxueyou/scc/teach/student/service/impl/StudentService.java
@@ -1,10 +1,7 @@
package com.qxueyou.scc.teach.student.service.impl;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.stream.Collectors;
import cn.hutool.core.date.LocalDateTimeUtil;
@@ -34,6 +31,7 @@
import com.qxueyou.scc.user.model.QUser;
import com.qxueyou.scc.user.model.User;
import com.qxueyou.scc.user.service.IUserService;
import org.springframework.util.DigestUtils;
@Service
public class StudentService extends CommonAppService implements IStudentService {
@@ -85,7 +83,10 @@
    @Override
    public Result insertStudent(String classId, String name, String studentNo, boolean sex, String phoneNo, String orgId,String comName) {
    public Result insertStudent(String classId, String name, String studentNo, boolean sex, String phoneNo, String orgId, String comName,
                                String photo, String passporName, String nationality, String ancestralHome, String birthday, String birthplace,
                                String chinaStatus, String registeredAddress, String homeAddress, String religiousBelief, String email,
                                String workUnit) {
        if (dao.exists(studentNo, orgId)) {
            return new Result(false, "身份证已存在");
@@ -110,7 +111,18 @@
        student.setMobilePhone(phoneNo);
        //公司名称
        student.setSubjectId(comName);
        student.setPhoto(photo);
        student.setPassporName(passporName);
        student.setNationality(nationality);
        student.setAncestralHome(ancestralHome);
        student.setBirthday(birthday);
        student.setBirthplace(birthplace);
        student.setChinaStatus(chinaStatus);
        student.setRegisteredAddress(registeredAddress);
        student.setHomeAddress(homeAddress);
        student.setReligiousBelief(religiousBelief);
        student.setEmail(email);
        student.setWorkUnit(workUnit);
        if(StringUtils.isNoneBlank(classId)) {
            bulkUpdate("update ClsClass set studentCount = studentCount + 1  where deleteFlag is false and classId = ?", new Object[]{classId});
        }
@@ -128,27 +140,48 @@
        return new Result(true, "success");
    }
    @Override
    public Result updateStudent(String studentId, String name,String password, String studentNo, boolean sex, String phoneNo) {
    public Result updateStudent(String studentId, String name,String password, String studentNo, boolean sex, String phoneNo
    , String photo, String passporName, String nationality, String ancestralHome, String birthday, String birthplace,
                                String chinaStatus, String registeredAddress, String homeAddress, String religiousBelief, String email,
                                String workUnit, String graduationDestination) {
        //根据学学员ID,获取用户信息
        StuStudent stu = this.read(StuStudent.class, studentId);
        if (!stu.getStudentNo().equals(studentNo) && dao.exists(studentNo,ClientUtils.getOrgId())) {
            return new Result(false, "学号已存在");
        if(stu.getStudentNo() != null){
            if (!stu.getStudentNo().equals(studentNo) && dao.exists(studentNo,ClientUtils.getOrgId())) {
                return new Result(false, "学号已存在");
            }
        }
        stu.setName(name);
        stu.setSex(sex);
        stu.setStudentNo(studentNo);
        stu.setMobilePhone(phoneNo);
        TraceUtils.setUpdateTrace(stu);
        stu.setPhoto(photo);
        stu.setPassporName(passporName);
        stu.setNationality(nationality);
        stu.setAncestralHome(ancestralHome);
        stu.setBirthday(birthday);
        stu.setBirthplace(birthplace);
        stu.setChinaStatus(chinaStatus);
        stu.setRegisteredAddress(registeredAddress);
        stu.setHomeAddress(homeAddress);
        stu.setReligiousBelief(religiousBelief);
        stu.setEmail(email);
        stu.setWorkUnit(workUnit);
        save(stu);
        User user = this.read(User.class, stu.getUserId());
        user.setAccount(studentNo);
        user.setSex(sex);
        user.setMobilePhone(phoneNo);
        if(!StringUtils.isEmpty(password)){
            user.setPassword(password);
        //随机字符串
        String salt= UUID.randomUUID().toString();
        //盐值
        user.setSalt(salt);
        //对密码进行加密处理
        String newPassword= DigestUtils.md5DigestAsHex((salt+password).getBytes());
        if(!StringUtils.isEmpty(newPassword)){
            user.setPassword(newPassword);
        }
        user.setName(name);
        save(user);
@@ -161,7 +194,9 @@
        QUser qUser = QUser.user;
        QStuStudent qStuStudent = QStuStudent.stuStudent;
        return this.getQueryFactory()
                .select(qStuStudent.studentId, qStuStudent.name, qStuStudent.studentNo, qStuStudent.sex,
                .select(qStuStudent.photo,qStuStudent.passporName,qStuStudent.nationality,qStuStudent.ancestralHome,qStuStudent.birthday,qStuStudent.birthplace,qStuStudent.chinaStatus,
                        qStuStudent.registeredAddress,qStuStudent.homeAddress,qStuStudent.religiousBelief,qStuStudent.email,qStuStudent.workUnit,qStuStudent.graduationDestination,
                        qStuStudent.studentId, qStuStudent.name, qStuStudent.studentNo, qStuStudent.sex,
                        qStuStudent.mobilePhone, qStuStudent.status, qStuStudent.studyDuration, qStuStudent.tenantId, qStuStudent.score, qStuStudent.graduationText,
                        qUser.imgPath)
                .from(qUser, qStuStudent)
@@ -181,6 +216,19 @@
                    map.put("score", tuple.get(qStuStudent.score));
                    map.put("graduationText", tuple.get(qStuStudent.graduationText));
                    map.put("imgPath", tuple.get(qUser.imgPath));
                    map.put("photo", tuple.get(qStuStudent.photo));
                    map.put("passporName", tuple.get(qStuStudent.passporName));
                    map.put("nationality", tuple.get(qStuStudent.nationality));
                    map.put("ancestralHome", tuple.get(qStuStudent.ancestralHome));
                    map.put("birthday", tuple.get(qStuStudent.birthday));
                    map.put("birthplace", tuple.get(qStuStudent.birthplace));
                    map.put("chinaStatus", tuple.get(qStuStudent.chinaStatus));
                    map.put("registeredAddress", tuple.get(qStuStudent.registeredAddress));
                    map.put("homeAddress", tuple.get(qStuStudent.homeAddress));
                    map.put("religiousBelief", tuple.get(qStuStudent.religiousBelief));
                    map.put("email", tuple.get(qStuStudent.email));
                    map.put("workUnit", tuple.get(qStuStudent.workUnit));
                    map.put("graduationDestination", tuple.get(qStuStudent.graduationDestination));
                    return map;
                }).collect(Collectors.toList());
    }