派生自 projectDept/qhighschool

yn147
2023-05-10 96286178ee1c257c130cb2ad964a781f36c4eee5
src/main/java/com/qxueyou/scc/admin/schoolRoll/impl/SchoolRollServiceImpl.java
@@ -1,5 +1,8 @@
package com.qxueyou.scc.admin.schoolRoll.impl;
import cn.hutool.core.date.LocalDateTimeUtil;
import cn.hutool.core.util.RandomUtil;
import com.qxueyou.scc.admin.classes.model.ClsClass;
import com.qxueyou.scc.admin.schoolRoll.ISchoolRollService;
import com.qxueyou.scc.base.model.ExcelExportParam;
import com.qxueyou.scc.base.model.Pager;
@@ -8,8 +11,10 @@
import com.qxueyou.scc.base.util.ClientUtils;
import com.qxueyou.scc.base.util.CollectionUtils;
import com.qxueyou.scc.base.util.ExcelExportUtils;
import com.qxueyou.scc.base.util.TraceUtils;
import com.qxueyou.scc.teach.student.model.StuStudent;
import com.qxueyou.scc.user.model.UserRegistration;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@@ -17,6 +22,7 @@
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
@@ -49,20 +55,34 @@
    }
    @Override
    public String updateSchool(String StudentId, String ClassId) {
        StringBuffer hql=new StringBuffer("from StuStudent where studentId=? and deleteFlag is false");
    public Result updateSchool(String [] studentIds, String classId) {
        for (String studentId:
                studentIds) {
            StringBuffer hql=new StringBuffer("from StuStudent where studentId=? and deleteFlag is false");
        List<Object> args = CollectionUtils.newList(StudentId);
            List<Object> args = CollectionUtils.newList(studentId);
        StuStudent stuStudent = findUnique(hql.toString(), args, StuStudent.class);
            StuStudent stuStudent = findUnique(hql.toString(), args, StuStudent.class);
        if(stuStudent!=null && ClassId!=null){
            stuStudent.setClassId(ClassId);
            save(stuStudent);
            return "true";
            if(stuStudent!=null && classId!=null){
                StringBuffer ClaHql=new StringBuffer("from ClsClass where classId=? and deleteFlag is false");
                List<Object> claArgs = CollectionUtils.newList(classId);
                ClsClass cLaClass = findUnique(ClaHql.toString(), claArgs, ClsClass.class);
                cLaClass.setStudentCount(cLaClass.getStudentCount()+1);
                stuStudent.setClassId(classId);
                save(stuStudent);
            }else {
                return new Result(false,"班级不存在或学生不存在");
            }
        }
        return "false";
        return new Result(true,"分班成功");
    }
    @Override
@@ -74,10 +94,10 @@
        List<StuStudent> stuStudents = find(hql.toString(), args, StuStudent.class);
        ExcelExportUtils<StuStudent> ex = new ExcelExportUtils<StuStudent>();
        String[] headers = { "姓名", "性别" ,"手机号" ,"身份证"};
        String[] headers = { "姓名", "性别" ,"手机号" ,"身份证"};
        List<StuStudent> dataset = new ArrayList<StuStudent>();
        for (StuStudent stuStudent:
        stuStudents) {
                stuStudents) {
            StuStudent u = new StuStudent();
            u.setName(stuStudent.getName());
            u.setSex(stuStudent.getSex());
@@ -95,7 +115,7 @@
            obj.setOut(out);
            ex.exportExcel(obj);
            out.close();
            System.out.println("excel导出成功!");
            System.out.println("excel导出成功!");
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
@@ -111,7 +131,7 @@
            obj.setOut(out);
            ex.exportExcelByColomn(obj);
            out.close();
            System.out.println("excel指定列导出成功!");
            System.out.println("excel指定列导出成功!");
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
@@ -120,18 +140,37 @@
    }
    @Override
    public Boolean auditStudent(String Student) {
        StringBuffer hql=new StringBuffer("from StuStudent where studentId=? and deleteFlag is false");
    public Result loopStudentIds(String[] studentIds) {
        for (String studentId:
                studentIds) {
            auditStudent(studentId);
        }
        return new Result(true);
    }
        List<Object> arg = CollectionUtils.newList(Student);
    private Result auditStudent(String studentId) {
        StuStudent student = read(StuStudent.class, studentId);
        TraceUtils.setUpdateTrace(student);
        String currentTime = LocalDateTimeUtil.format(LocalDateTime.now(), "yyMMddHHmmssSSS");
        StuStudent stuStudent = findUnique(hql.toString(), arg, StuStudent.class);
        String examCardNo = currentTime.concat(RandomUtil.randomNumbers(1));
        stuStudent.setStatus(StuStudent.STATUS_ACTIVE);
        student.setStudentNumber(examCardNo);
        student.setStatus(StuStudent.STATUS_ACTIVE);
        save(student);
        Result save = save(stuStudent);
        return new Result(true);
    }
        return save.isSuccess();
    @Override
    public List<ClsClass> findClass() {
        StringBuffer hql=new StringBuffer("from ClsClass where deleteFlag is false");
        List<Object> arg = CollectionUtils.newList();
        List<ClsClass> clsClasses = find(hql.toString(), arg, ClsClass.class);
        return clsClasses;
    }
}