基于javaweb+mysql的springboot教务管理系统(java+thymeleaf+html+spring+springboot+layui+maven)

基于javaweb+mysql的springboot教务管理系统(java+thymeleaf+html+spring+springboot+layui+maven)

运行环境

Java≥8、MySQL≥5.7

开发工具

eclipse/idea/myeclipse/sts等均可配置运行

适用

课程设计,大作业,毕业设计,项目练习,学习演示等

功能说明

基于javaweb+mysql的SpringBoot教务管理系统(java+thymeleaf+html+spring+springboot+layui+maven)

一、项目简述

功能包括: 三角色教师 管理员,学生教务管理系统,包括院系管理,课题综合管理,信息管理,以及差旅管理,学生选题等等。

二、项目运行 环境配置:

Jdk1.8 + Tomcat8.5 + mysql + Eclispe(IntelliJ IDEA,Eclispe,MyEclispe,Sts都支持)

项目技术:

JSP +Spring + SpringBoot + MyBatis + html+ css + JavaScript + JQuery + Ajax + layui+ maven等等

        long start = 0;
        long end = file.length() - 1;
        if (!StringUtils.isEmpty(range)) {
            String[] arr = range.substring("bytes=".length()).split("-");
            if (arr.length > 0) {
                start = Long.valueOf(arr[0]);
                if (arr.length > 1) {
                    end = Long.valueOf(arr[1]);
                }
            }
            response.setHeader("Content-Range", "bytes " + start + "-" + end + "/" + file.length());
            response.setStatus(206);
        }

        long contentLength = end - start + 1;
        String fileName = new String(file.getName().getBytes("UTF-8"), "ISO-8859-1");
        response.setHeader("Content-Disposition", "attachment;fileName=" + fileName);
        response.addHeader("Content-Length", String.valueOf(contentLength));
        response.setContentType(Files.probeContentType(Paths.get(file.getAbsolutePath())));
        response.setHeader("Last-Modified", String.valueOf(file.lastModified()));
        response.setHeader("Accept-Ranges", "bytes");
        response.setBufferSize(2048);

        FileInputStream in = new FileInputStream(file);
        ServletOutputStream out = response.getOutputStream();
        try {
            StreamUtils.copyRange(in, out, start, end);
        } finally {
            IOUtils.closeQuietly(in);
        }
    }

    public static void clearSession(HttpSession session) {
        Enumeration enumeration = session.getAttributeNames();
        while (enumeration.hasMoreElements()) {
            session.removeAttribute(enumeration.nextElement().toString());
        }
    }

}
package com.hngy.educationaladministration.controller;

        return studentMapper.deleteByExample(new StudentExample().createCriteria().andIdClassEqualTo(classId).example());
    }

    public List<Student> selectByName(String username) {
//        return studentMapper.selectByExample();
        StudentExample studentExample = new StudentExample();
        StudentExample.Criteria criteria = studentExample.createCriteria();
        criteria.andUsernameEqualTo(username);
        return studentMapper.selectByExample(studentExample);
    }

    public StudentExample addCondition(StudentExample studentExample,Integer offset, String keyWord, Long classId, Long specialtyId,long id_institute)
    {

        List<MyClass> classes = classService.getClasses(-1,null,specialtyId,id_institute);

        List<Long> classesIDs = classes.stream().map(MyClass::getId).collect(Collectors.toList());

        if(classesIDs.size()==0 || classesIDs==null)
            return null;

        //代表为超管,则可以查询所有;
        if(id_institute==-1)
        {
            return studentExample.newAndCreateCriteria()
                    .example().or()
                    .when(StringUtil.stringIsNotNull(keyWord), criteria -> criteria.andNameEqualTo(keyWord)) //根据姓名
                    .when(classId!=null,criteria -> criteria.andIdClassEqualTo(classId)) //根据指定Class查询
                    .when(classesIDs!=null&&classesIDs.size()>0,
                            criteria -> criteria.andIdClassIn(classesIDs),// 按指定专业的班级查询
                            criteria -> criteria.andIdEqualTo(0L))

                    .example().or()
                    .when(StringUtil.stringIsNotNull(keyWord), criteria -> criteria.andUsernameEqualTo(keyWord)) //根据登录名查询
                    .when(classId!=null,criteria -> criteria.andIdClassEqualTo(classId)) //根据指定Class查询
                    .when(classesIDs!=null&&classesIDs.size()>0,
                            criteria -> criteria.andIdClassIn(classesIDs),// 按指定专业的班级查询
                            criteria -> criteria.andIdEqualTo(0L))

                    .example().or()
                    .when(classId!=null,criteria -> criteria.andIdClassEqualTo(classId)) //根据指定Class查询
                    .when(StringUtil.stringIsNotNull(keyWord), criteria -> criteria.andStunumEqualTo(keyWord)) // 根据学号查询
                    .when(classesIDs!=null&&classesIDs.size()>0,
    //审核页面按照条件查询课题
    @GetMapping("/condition_teacher")
    @ResponseBody
    public Msg fun10(Long zt, Long id_teacher, HttpSession httpSession){
        Teacher teacher = (Teacher) httpSession.getAttribute("teacherInfo");
        List<Project> list_project = staticService.selectByConditionTeacher(teacher.getIdSection(), zt, id_teacher);
        for (int i = 0; i < list_project.size(); i++) {
            if (list_project.get(i).getVerifyprojectFlag() == 0) list_project.get(i).setProjectZT("未审核");
            if (list_project.get(i).getVerifyprojectFlag() == 1) list_project.get(i).setProjectZT("审核未通过");
            if (list_project.get(i).getVerifyprojectFlag() == 2) list_project.get(i).setProjectZT("审核通过");
        }
        return Msg.success().add("projectList", list_project);
    }

    // 审核课题
    @PostMapping("/SH_project")
    @ResponseBody
    public String fun9(String zt, String projectID) {
        int s1 = Integer.parseInt(zt);
        Long s2 = Long.valueOf(projectID);
        teacherService.updateSHprojcet(s1, s2);
        Map<String, String> map = new HashMap<String, String>();
        map.put("pd", "" + 1);
        return JSONObject.toJSONString(map);
    }

    @GetMapping("/reject_project")
    @ResponseBody
    public Msg fun17(Long project_id){
        Project project = staticService.selectProjectbyid(project_id);
        if(project.getReleaseFlag() == 1 || project.getSelectcount() != 0){
          return Msg.fail();
        }else{
            SubjectWithBLOBs subject = new SubjectWithBLOBs();
            subject.setId(project.getId());

            //修改后状态置 0
            subject.setSelectFlag(0);
            subject.setVerifyprojectFlag(0);
            subject.setReleaseFlag(0);

            subjectService.updateSubjectByid(subject);

            @ModelAttribute("id_institute") long id_institute
    ) throws MyException {
        return Msg.sqlChange((int) specialtyService.postSpecialty(specialty, id_institute));
    }

//    班级

    @GetMapping("/ClassManagement")
    public String Class() {
        return "admin/Department/ClassManagement";
//    //获取管理员的 学院id
//    public static Long getIdInstitute(ModelMap modelMap) {
//        Subadmin subadmin = (Subadmin) modelMap.get("admin");
//        return subadmin.getIdInstitute();
//    }

    }

    @ResponseBody
    @GetMapping("/classes")
    public Msg getClasses(
            @RequestParam("offset") Integer offset,
            @RequestParam(required = false) Long specialtyId,
            @RequestParam(required = false) String keyWord,
            @ModelAttribute("id_institute") long id_institute) {
        long total = classService.getClassesCount(offset, keyWord, specialtyId, id_institute);
        return Msg.success()
                .add("classes", classService.getClasses(offset, keyWord, specialtyId, id_institute))
                .add("total", total);
    }

    @ResponseBody
    @DeleteMapping("/class")
    public Msg delClass(
            @RequestBody MyClass myClass,
            @ModelAttribute("id_institute") long id_institute
    ) throws MyException {
        return Msg.sqlChange((int) classService.delClass(myClass, id_institute));
    }

    @ResponseBody
    @PutMapping("/class")
    public Msg putClass(
        style1.setBorderRight(BorderStyle.THIN); // 有边框加黑
        style1.setBorderTop(BorderStyle.THIN); //上边框加黑

        XSSFFont font = wb.createFont();
        font.setFontName("宋体");
        font.setBold(true);//粗体显示
        font.setFontHeightInPoints((short) 16);

        style1.setFont(font);

        XSSFCellStyle style = wb.createCellStyle();
        style.setAlignment(HorizontalAlignment.CENTER); //文字水平居中
        style.setVerticalAlignment(VerticalAlignment.CENTER);//文字垂直居中
        style.setBorderBottom(BorderStyle.THIN); //底边框加黑
        style.setBorderLeft(BorderStyle.THIN);  //左边框加黑
        style.setBorderRight(BorderStyle.THIN); // 有边框加黑
        style.setBorderTop(BorderStyle.THIN); //上边框加黑
        XSSFFont font1 = wb.createFont();
        font1.setFontName("宋体");
        font1.setFontHeightInPoints((short) 10.5);//设置字体大小
        style.setFont(font1);

//        为单元格添加背景样式
        for (int i = 1;i < (students!=null?students.size():0) + 2; i++) {
            Row row = sheet.createRow(i); //创建行
            for (int j = 0; j < 8; j++) {//需要6列
                row.createCell(j).setCellStyle(style);
            }
        }
        //合并单元格s
        sheet.addMergedRegion(new CellRangeAddress(0, 0, 0, 7));//合并单元格,cellRangAddress四个参数,第一个起始行,第二终止行,第三个起始列,第四个终止列
        //设置标题栏
        XSSFRow row = sheet.createRow(0); //创建第一行
        row.createCell(0).setCellStyle(style1);
        row.getCell(0).setCellValue("选报 "+projectName+" 课题学生一览表"); //在第一行中创建一个单元格并赋值
        XSSFRow row1 = sheet.getRow(1); //获取第二行,为每一列添加字段
        row1.getCell(0).setCellValue("序号");
        row1.getCell(1).setCellValue("班级");
        row1.getCell(2).setCellValue("学号");
        row1.getCell(3).setCellValue("姓名");
        row1.getCell(4).setCellValue("性别");
        row1.getCell(5).setCellValue("课题名称");
        row1.getCell(6).setCellValue("备注");

        int hang = 2;
        teacherService.updateZTprojcet(s1, s2);
        //如果是关闭操作
        if(s1 == 1){
            teacherService.deleteSelected(s2);
        }
        Map<String, String> map = new HashMap<String, String>();
        map.put("pd", "" + 1);
        return JSONObject.toJSONString(map);
    }

    // 确认该学生选报该课题
    @RequestMapping("/QRstudentXB")
    @ResponseBody
    public String fun13(String studet_id, Long project_id, String zt) {
        Long s1 = Long.valueOf(studet_id);
        Long s3 = Long.valueOf(zt);
        teacherService.updateXZstudent(s1, project_id, s3);
//        teacherService.updateselectnum(s3, project_name);
        Map<String, String> map = new HashMap<String, String>();
        map.put("pd", "" + 1);
        return JSONObject.toJSONString(map);
    }

    @GetMapping("/Classindex")
    public String fun14(ModelMap modelMap, HttpSession httpSession) {
        Teacher teacher = (Teacher) httpSession.getAttribute("teacherInfo");
        String institute_name = teacher.getInstituteName();//学院名字
        List<Specialty> specialties = staticService.selectSpercialtyByall(institute_name);
        List<Class> classes = staticService.selectClassByall(institute_name);

        modelMap.addAttribute("Spercialtys", specialties);
        modelMap.addAttribute("Classs", classes);
        return "teacher/graduation/classxq/Classxq";
    }

    // 根据 专业,班级 等信息查询学生选题情况
    @PostMapping("/SelectAll")
    @ResponseBody
    public List<Static_student> fun15(String Spercialty, String csa) {
        List<Static_student> static_students = staticService.select_studentXT_all(null, null, null, Spercialty, null, csa);
        Collections.sort(static_students, new Comparator<Static_student>() {
            @Override
            public int compare(Static_student o1, Static_student o2) {
                return (Integer.valueOf(o1.getStuNum()) - Integer.valueOf(o2.getStuNum()));
            }
        });

            httpSession.setAttribute("teacherInfo", teacher);
            httpSession.setMaxInactiveInterval(3600);
        }
        return Msg.success().add("info", flag);
    }

    //教师信息修改
    //修改教师密码
    @PostMapping("/teacherupdetpwd")
    @ResponseBody
    public Msg fun6(String oldpwd, String newpwd, HttpSession httpSession) {
        Teacher teacher = (Teacher) httpSession.getAttribute("teacherInfo");
        int flag = teacherService.teacherUpdetpwd(teacher.getUsername(), oldpwd, newpwd);
        return Msg.success().add("flag", flag);
    }

    //修改教师信息
    @PostMapping("/teacherupdeteinfo")
    @ResponseBody
    public Msg updateinfo(String name, String gender, HttpSession httpSession) {
        TeacherWithBLOBs teacher = (TeacherWithBLOBs) httpSession.getAttribute("teacherInfo");
        teacher.setName(name);
        teacher.setGender(gender);
        teacherService.teacherupdateInfo(teacher);
        return Msg.success();
    }

    //教师出差模块
    //查询所有教师出差申请信息
    @GetMapping("/select_work_all")
    @ResponseBody
    public Msg fun1(HttpSession httpSession) {
        TeacherWithBLOBs teacher = (TeacherWithBLOBs) httpSession.getAttribute("teacherInfo");
        List<WorkapprovalWithBLOBs> list = teacherService.selectTeacherWorkAll(teacher.getId());
        return Msg.success().add("workinfo", list);
    }

    //查询申请成功教师出差申请
    @GetMapping("/select_work_success")
    @ResponseBody
    public Msg fun2(HttpSession httpSession) {
        TeacherWithBLOBs teacher = (TeacherWithBLOBs) httpSession.getAttribute("teacherInfo");
                res = XWPFDocument.PICTURE_TYPE_PNG;
            } else if (picType.equalsIgnoreCase("dib")) {
                res = XWPFDocument.PICTURE_TYPE_DIB;
            } else if (picType.equalsIgnoreCase("emf")) {
                res = XWPFDocument.PICTURE_TYPE_EMF;
            } else if (picType.equalsIgnoreCase("jpg") || picType.equalsIgnoreCase("jpeg")) {
                res = XWPFDocument.PICTURE_TYPE_JPEG;
            } else if (picType.equalsIgnoreCase("wmf")) {
                res = XWPFDocument.PICTURE_TYPE_WMF;
            }
        }
        return res;
    }

    /**
     * 将输入流中的数据写入字节数组
     *
     * @param in
     * @return
     */
    public static byte[] inputStream2ByteArray(InputStream in, boolean isClose) {
        byte[] byteArray = null;
        try {
            int total = in.available();
            byteArray = new byte[total];
            in.read(byteArray);
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            if (isClose) {
                try {
                    in.close();
                } catch (Exception e2) {
                    e2.getStackTrace();
                }
            }
        }
        return byteArray;
    }

     * @param excelFile
     * @param id_institute
     */
    @Override
    public Msg teacherExcelImport(MultipartFile excelFile, long id_institute) throws IOException {
        if(excelFile==null)
        {
            throw new MyException("文件上传失败");
        }
        String name = excelFile.getOriginalFilename();
        LOGGER.info("Excel文件名{}",name);
        if(
                name.indexOf("xlsx")<0 &&
                        name.indexOf("xls")<0
        ){
            throw new MyException("文件格式有问题!");
        }
        //使用easyExcel
        //给监听器初始化
        teacherExcelUtil.init();
        teacherExcelUtil.setId_institute(id_institute);

        //excel读取
        EasyExcel.read(excelFile.getInputStream(), TeacherExcel.class, teacherExcelUtil).sheet().doRead();

        //如果 出现异常 则显示导入多少教师,和没导入的教师message
        if(teacherExcelUtil.isP())
        {
            return Msg.error(teacherExcelUtil.getExceptionMessage().toString())
                    .add("count",teacherExcelUtil.getCount())
                    .add("countMax",teacherExcelUtil.getCountMax())
                    .add("errorData",teacherExcelUtil.getErrorData());
        }

        return Msg.success();
    }

    /**
     * 教师模板下载
     *
     * @param response
     */
    @Override
    public void teacherExcelDownload(HttpServletResponse response) throws IOException {
        //名字
        if (count > 0) {
            request.getSession().setAttribute("student",student);
            request.getSession().setAttribute("modifyFlag",1);
            return "200";
        } else {
            request.getSession().setAttribute("modifyFlag",0);
            return "201";
        }
    }*/

    /**
     *   跳转页面(修改密码)
     */
    @RequestMapping("/changepsw")
    public String changepsw() {
        return "student/changepsw";
    }

    /**
     * 200修改成功
     * 201对不起密码错误
     * 202对不起输入框为空
     * 203新密码不一致
     * 204修改失败
     */
    @RequestMapping(value = "/changepassword", method = RequestMethod.PUT)
    @ResponseBody
    public String changepswdao(String oldpassword, String newpassword, String newpassword1) {
        if(!verifypassword(newpassword)){
            return "206";
        }
        if(!verifypassword(newpassword1)){
            return "206";
        }
        Student student = (Student) request.getSession().getAttribute("student");
        Student studentdao = loginService.selectByName(student.getUsername());
        int result;
        if (newpassword.equals(newpassword1) && !newpassword.equals("") && !newpassword1.equals("")) {
            if (studentdao.getPwd().equals(oldpassword)) {

                if(oldpassword.equals(newpassword)){
                    return "205";
                }else{
                    result = indexService.updatepassword(newpassword, student.getId());
                    if (result > 0) {
                        return "200";
                    }else{
                        return "204";
                    }
                }
            } else {
     * @param params 参数
     */
    private void replaceInPara(XWPFDocument doc, Map<String, Object> params) {
        Iterator<XWPFParagraph> iterator = doc.getParagraphsIterator();
        XWPFParagraph para;
        while (iterator.hasNext()) {
            para = iterator.next();
            this.replaceInPara(para, params, doc);
        }
    }

    /**
     * 替换段落里面的变量
     *
     * @param para   要替换的段落
     * @param params 参数
     */
    private void replaceInPara(XWPFParagraph para, Map<String, Object> params, XWPFDocument doc) {
        List<XWPFRun> runs;
        Matcher matcher;
        if (this.matcher(para.getParagraphText()).find()) {
            runs = para.getRuns();
            int start = -1;
            int end = -1;
            String str = "";
            for (int i = 0; i < runs.size(); i++) {
                XWPFRun run = runs.get(i);
                String runText = run.toString();
                if ('$' == runText.charAt(0) && '{' == runText.charAt(1)) {
                    start = i;
                }
                if ((start != -1)) {
                    str += runText;
                }
                if ('}' == runText.charAt(runText.length() - 1)) {
                    if (start != -1) {
                        end = i;
                        break;
                    }
                }
            }

            for (int i = start; i <= end; i++) {
                para.removeRun(i);
                i--;
                end--;
            }

            for (Map.Entry<String, Object> entry : params.entrySet()) {
            sheet.addMergedRegion(region);
            fun8(region, sheet, workBook);
            cell = row.createCell(2);
            cell.setCellValue(aa[j]);
            cell.setCellStyle(style3);
            row.setHeightInPoints(30);
        }

        //获取其它方面工作
        String otherWork = debriefingYear.getOtherwork();
        aa = otherWork.split("/");

        region = new CellRangeAddress(index, index + aa.length - 1, (short) 0, (short) 0);
        sheet.addMergedRegion(region);
        fun8(region, sheet, workBook);

        //填充其它方面工作
        for (int j = 0; j < aa.length; index++, j++) {
            row = sheet.createRow(index);
            cell = row.createCell(1);
            cell.setCellValue(j + 1);
            cell.setCellStyle(style3);
            cell = row.createCell(0);
            cell.setCellValue("其它方面工作");
            cell.setCellStyle(style3);
            region = new CellRangeAddress(index, index, (short) 2, (short) 6);
            sheet.addMergedRegion(region);
            fun8(region, sheet, workBook);
            cell = row.createCell(2);
            cell.setCellValue(aa[j]);
            cell.setCellStyle(style3);
            row.setHeightInPoints(30);

        }

        //获取获奖情况
        String winAward = debriefingYear.getWinaward();
        aa = winAward.split("/");

        region = new CellRangeAddress(index, index + aa.length - 1, (short) 0, (short) 0);
        sheet.addMergedRegion(region);
        fun8(region, sheet, workBook);

        //填充获奖情况
        for (int j = 0; j < aa.length; index++, j++) {
            row = sheet.createRow(index);
            cell = row.createCell(1);
            cell.setCellValue(j + 1);
            cell.setCellStyle(style3);
        {
            return studentExample.newAndCreateCriteria()
                    .example().or()
                    .when(StringUtil.stringIsNotNull(keyWord), criteria -> criteria.andNameEqualTo(keyWord)) //根据姓名
                    .when(classId!=null,criteria -> criteria.andIdClassEqualTo(classId)) //根据指定Class查询
                    .when(classesIDs!=null&&classesIDs.size()>0,
                            criteria -> criteria.andIdClassIn(classesIDs),// 按指定专业的班级查询
                            criteria -> criteria.andIdEqualTo(0L))

                    .example().or()
                    .when(StringUtil.stringIsNotNull(keyWord), criteria -> criteria.andUsernameEqualTo(keyWord)) //根据登录名查询
                    .when(classId!=null,criteria -> criteria.andIdClassEqualTo(classId)) //根据指定Class查询
                    .when(classesIDs!=null&&classesIDs.size()>0,
                            criteria -> criteria.andIdClassIn(classesIDs),// 按指定专业的班级查询
                            criteria -> criteria.andIdEqualTo(0L))

                    .example().or()
                    .when(classId!=null,criteria -> criteria.andIdClassEqualTo(classId)) //根据指定Class查询
                    .when(StringUtil.stringIsNotNull(keyWord), criteria -> criteria.andStunumEqualTo(keyWord)) // 根据学号查询
                    .when(classesIDs!=null&&classesIDs.size()>0,
                            criteria -> criteria.andIdClassIn(classesIDs),// 按指定专业的班级查询
                            criteria -> criteria.andIdEqualTo(0L))

                    .example()
                    .when(offset!=-1 && offset != 0,criteria -> criteria.page(offset-1, 10));// 查询第offest-1页数据(每页10条);
        }

        return studentExample.newAndCreateCriteria()
                .example().or()
                    .when(StringUtil.stringIsNotNull(keyWord), criteria -> criteria.andNameEqualTo(keyWord)) //根据姓名
                    .when(classId!=null,criteria -> criteria.andIdClassEqualTo(classId)) //根据指定Class查询
                    .when(classesIDs!=null&&classesIDs.size()>0,
                            criteria -> criteria.andIdClassIn(classesIDs),// 查询的学生只能在当前的学院的班级下
                            criteria -> criteria.andIdEqualTo(0L))

                .example().or()
                    .when(StringUtil.stringIsNotNull(keyWord), criteria -> criteria.andUsernameEqualTo(keyWord)) //根据登录名查询
                    .when(classId!=null,criteria -> criteria.andIdClassEqualTo(classId)) //根据指定Class查询
                    .when(classesIDs!=null&&classesIDs.size()>0,
                            criteria -> criteria.andIdClassIn(classesIDs),// 查询的学生只能在当前的学院的班级下
                            criteria -> criteria.andIdEqualTo(0L))

                .example().or()
                    .when(StringUtil.stringIsNotNull(keyWord), criteria -> criteria.andStunumEqualTo(keyWord)) // 根据学号查询
                    .when(classId!=null,criteria -> criteria.andIdClassEqualTo(classId)) //根据指定Class查询
        return JSONObject.toJSONString(map);
    }

    @GetMapping("/Classindex")
    public String fun14(ModelMap modelMap, HttpSession httpSession) {
        Teacher teacher = (Teacher) httpSession.getAttribute("teacherInfo");
        String institute_name = teacher.getInstituteName();//学院名字
        List<Specialty> specialties = staticService.selectSpercialtyByall(institute_name);
        List<Class> classes = staticService.selectClassByall(institute_name);

        modelMap.addAttribute("Spercialtys", specialties);
        modelMap.addAttribute("Classs", classes);
        return "teacher/graduation/classxq/Classxq";
    }

    // 根据 专业,班级 等信息查询学生选题情况
    @PostMapping("/SelectAll")
    @ResponseBody
    public List<Static_student> fun15(String Spercialty, String csa) {
        List<Static_student> static_students = staticService.select_studentXT_all(null, null, null, Spercialty, null, csa);
        Collections.sort(static_students, new Comparator<Static_student>() {
            @Override
            public int compare(Static_student o1, Static_student o2) {
                return (Integer.valueOf(o1.getStuNum()) - Integer.valueOf(o2.getStuNum()));
            }
        });

        for (int i = 0; i < static_students.size(); i++) {
            if (static_students.get(i).getStuselectFlag().equals("0")) static_students.get(i).setStuselectFlag("未选题");
            if (static_students.get(i).getStuselectFlag().equals("1")) static_students.get(i).setStuselectFlag("选题待审核");
            if (static_students.get(i).getStuselectFlag().equals("2")) static_students.get(i).setStuselectFlag("选题未通过");
            if (static_students.get(i).getStuselectFlag().equals("3")) static_students.get(i).setStuselectFlag("选题通过");
        }
        return static_students;
    }

    @GetMapping("/czstudentpwd")
    public String fun16() {
        return "teacher/graduation/reStudentpwd";
    }

    // 通过学生的 id,名字,学号查询学生
    @GetMapping("/selectStudent")
    public String getStudent(String username, ModelMap modelMap) {
        modelMap.addAttribute("Students", staticService.selectStudents(username));

        return "teacher/graduation/reStudentpwd";
    }
        String teacherName = teacher.getName();
        if (teachernames == null || teachernames.trim().length() == 0) {
            teachernames = teacherName;
        } else {
            teachernames = teacherName + "&" + teachernames;
        }

        SubjectWithBLOBs subject = null;

        //文件大小 为 0 则表示 文件没上传
        long size = file.getSize();
        //不更新课题文件情况
        if (file == null || size == 0) {
            subject = new SubjectWithBLOBs();

            subject.setId(id);
            subject.setProjectname(projectName);
            subject.setIdProjecttype(idProjecttype);
            subject.setIdProjectsource(idProjectsource);
            subject.setMarchspecialty(marchspecialty);
            subject.setTeachernames(teachernames);

            //修改后状态置 0
            subject.setSelectFlag(0);
            subject.setVerifyprojectFlag(0);
            subject.setReleaseFlag(0);

            subjectService.updateSubjectByid(subject);

            return Msg.success();

        } else {

            //获取课题
            SubjectWithBLOBs subject1 = subjectService.getSubjectByID(id);
            //获取课题路径
            String oldPath = subject1.getFilepath();
            File oldFile = new File(oldPath);

            //如果文件存在则删除
            if (oldFile.exists()) {
                //删除成功
                if (true || oldFile.delete()) {

                } else {
                    return Msg.fail();
                }
            }

            ServletContext servletContext = request.getSession().getServletContext();

            String uploadFileName = file.getOriginalFilename(); // 获取上传文件的原名

            uploadFileName = uploadFileName.substring(uploadFileName.lastIndexOf(File.separator) + 1);
        return sadminMapper.updateByExampleSelective(sadmin, sadminExample);
    }

    // 班级的增加
    @Override
    public int add_class(Long specialty_id, String class_name) {
        List<Class> classes = select_class(null, null, null, null, class_name);
        if (classes == null || classes.size() == 0) {
            Class class1 = new Class();
            class1.setClassName(class_name);
            class1.setIdSpecialty(specialty_id);
            return classMapper.insert(class1);
        }
        return 0;
    }

    @Override
    public int addAdmin(Admin admin) {
        //添加的时候检测又没用户名重复的
        publicService.CheckIfTheUsernameIsDuplicated(admin.getName());
        return adminMapper.insert(admin);
    }

    @Override
    public int delAdmin(Admin admin) {
        return adminMapper.deleteByPrimaryKey(admin.getId());
    }

    @Override
    public int updateAdmin(Admin admin) {
        //不更新username
        admin.setName(null);
        return adminMapper.updateByPrimaryKeySelective(admin);
    }

    @Override
    public List selectAdmins(Long offset) {

        if(offset!=null && offset==-1){
            return adminMapper.selectByExampleSelective(
                    new AdminExample(),
                    Admin.Column.id
            );
        }

    public String enroll(Long project_id, HttpSession httpSession) {
        String projectName = topicsService.selectprojectname(project_id);
        Student student = (Student) request.getSession().getAttribute("student");
        List<Subjectselected> subjectselected = subjectselectedMapper.selectBystudentid(student.getId());

        if(subjectselected.size() == 0){
            studentService.updateselectnumAdd(projectName);
            topicsService.insertproject(projectName, student.getId());
            httpSession.setAttribute("XZproject", projectName);
            return "200";
        }else {
            return "201";
        }

    }

    /**
     * 取消选报
     */
    @RequestMapping("/cancel")
    @ResponseBody()
    public String cancel(Long project_id, Model model, HttpSession httpSession) {
        System.out.println(1);
        String projectName = topicsService.selectprojectname(project_id);
        Student student = (Student) request.getSession().getAttribute("student");
        List<Subjectselected> subjectselected = subjectselectedMapper.selectBystudentid(student.getId());

        if (subjectselected != null && subjectselected.size() != 0 && subjectselected.get(0).getStuselectFlag() != 3
                && project_id.equals(subjectselected.get(0).getIdProject())) {
            topicsService.deleteprojectselectedid(student.getId());
            httpSession.removeAttribute("XZproject");
            model.addAttribute("XZproject", null);
            httpSession.setAttribute("XZproject", null);
            studentService.updateselectnumReduce(projectName);
            return "200";

        } else {
            return "203";
        }
    }

    /**
     * 清除session中存的项目名
        style3.setBorderTop(BorderStyle.THIN);//上边框

        //创建表格主体
        //获取教学任务
        String teachingTask = debriefing.getTeachingtask();
        String[] aa = teachingTask.split("/");

        row = sheet.createRow(2);
        region = new CellRangeAddress(2, 2 + aa.length, (short) 0, (short) 0);
        sheet.addMergedRegion(region);
        fun8(region, sheet, workBook);
        cell = row.createCell(0);
        cell.setCellValue("教学任务");
        cell.setCellStyle(style3); //赋值样式

        cell = row.createCell(1);
        cell.setCellValue("序号");
        cell.setCellStyle(style2);
        region = new CellRangeAddress(2, 2, (short) 2, (short) 6);
        sheet.addMergedRegion(region);
        fun8(region, sheet, workBook);
        cell = row.createCell(2);
        cell.setCellValue("具体内容");
        cell.setCellStyle(style2);
        row.setHeightInPoints(30);

        //填充教学任务
        int index = 3;
        for (int j = 0; j < aa.length; index++, j++) {
            row = sheet.createRow(index);
            cell = row.createCell(1);
            cell.setCellValue(j + 1);
            cell.setCellStyle(style3);
            cell = row.createCell(0);
            cell.setCellStyle(style3);
            region = new CellRangeAddress(index, index, (short) 2, (short) 6);
            sheet.addMergedRegion(region);
            fun8(region, sheet, workBook);
            cell = row.createCell(2);
            cell.setCellValue(aa[j]);
                    return "205";
                }else{
                    result = indexService.updatepassword(newpassword, student.getId());
                    if (result > 0) {
                        return "200";
                    }else{
                        return "204";
                    }
                }
            } else {
                return "201";
            }
        } else if (newpassword.equals("") && newpassword1.equals("")) {
            return "202";
        }
        return "203";
    }

    //密码验证
    public boolean verifypassword(String password){
        if(password.length() < 6 || password.length() > 16){
            return false;
        }
        for(int i = 0;i < password.length();i++){
            if(!(password.charAt(i)>='A' && password.charAt(i)<='Z')){
                if(!(password.charAt(i)>='a' && password.charAt(i)<='z')){
                    if(!(password.charAt(i)>='0' && password.charAt(i)<='9')){
                        return false;
                    }
                }
            }
        }
        return true;
    }

    //退出
    //清除Session数据
    @RequestMapping("/exit")
    public String exit(HttpServletResponse response,HttpSession httpSession) {
//        httpSession.setAttribute("XZproject", null);
//       清除Session
    private static final Logger LOGGER = LoggerFactory.getLogger(ExcelServiceImpl.class);

    @Autowired
    TeacherExcelUtil teacherExcelUtil;
    @Autowired
    StudentExcelUtil studentExcelUtil;
    @Autowired
    SubjectExcelUtil subjectExcelUtil;

    /**
     * 教师导入
     *
     * @param excelFile
     * @param id_institute
     */
    @Override
    public Msg teacherExcelImport(MultipartFile excelFile, long id_institute) throws IOException {
        if(excelFile==null)
        {
            throw new MyException("文件上传失败");
        }
        String name = excelFile.getOriginalFilename();
        LOGGER.info("Excel文件名{}",name);
        if(
                name.indexOf("xlsx")<0 &&
                        name.indexOf("xls")<0
        ){
            throw new MyException("文件格式有问题!");
        }
        //使用easyExcel
        //给监听器初始化
        teacherExcelUtil.init();
        teacherExcelUtil.setId_institute(id_institute);

        //excel读取
        EasyExcel.read(excelFile.getInputStream(), TeacherExcel.class, teacherExcelUtil).sheet().doRead();

        //如果 出现异常 则显示导入多少教师,和没导入的教师message
        if(teacherExcelUtil.isP())
        {
            return Msg.error(teacherExcelUtil.getExceptionMessage().toString())
                    .add("count",teacherExcelUtil.getCount())
                    .add("countMax",teacherExcelUtil.getCountMax())
                    .add("errorData",teacherExcelUtil.getErrorData());
        }

        return Msg.success();
    }
    @ResponseBody
    public Msg fun17(Long project_id){
        Project project = staticService.selectProjectbyid(project_id);
        if(project.getReleaseFlag() == 1 || project.getSelectcount() != 0){
          return Msg.fail();
        }else{
            SubjectWithBLOBs subject = new SubjectWithBLOBs();
            subject.setId(project.getId());

            //修改后状态置 0
            subject.setSelectFlag(0);
            subject.setVerifyprojectFlag(0);
            subject.setReleaseFlag(0);

            subjectService.updateSubjectByid(subject);

            return Msg.success();
        }

    }

}
package com.hngy.educationaladministration.controller;

        return "student/modifyinfo";
    }

    /**
     * 修改个人信息
     * 根据班级(className)修改
     *
     */
    /*@RequestMapping(value = "/modifyinfodao", method = RequestMethod.PUT)
    @ResponseBody
    public String modifyinfodao(Student student, String className, Model model) {
        Student Tstudent = (Student) request.getSession().getAttribute("student");
        MyClass Tclass = indexService.selectByclassName(className);
        int count = -1;
        student.setIdClass(Tclass.getId());
        System.out.println("******"+Tstudent.toString());
        System.out.println("******"+student.toString());

        if (student.getStunum().equals(Tstudent.getStunum())) {
            student.setStunum(null);
        }
        if (student.getIdClass().equals(Tstudent.getIdClass())) {
            student.setIdClass(null);
        }
        if (student.getName().equals(Tstudent.getName())) {
            student.setName(null);
        }
        if (student.getGender().equals(Tstudent.getGender())) {
            student.setGender(null);
        }
        if (student.getGender() == null && student.getName() == null && student.getIdClass() == null && student.getStunum() == null) {

        } else {
            student.setId(Tstudent.getId());
            count = indexService.updateBymodifyinfo(student);
            student = indexService.selectByid(Tstudent.getId());
            model.addAttribute("student", student);
        }
        if (count > 0) {
            request.getSession().setAttribute("student",student);
            request.getSession().setAttribute("modifyFlag",1);
            return "200";
        } else {
            request.getSession().setAttribute("modifyFlag",0);
            return "201";
        }
    }*/

    /**
     *   跳转页面(修改密码)
     */

    @ResponseBody
    @PostMapping("/subject")
    public Msg addSubject(
            @RequestBody @Validated(Add.class) SubjectWithBLOBs subject,
            @ModelAttribute("id_institute") long id_institute) throws MyException {
        return Msg.sqlChange((int) subjectService.insertSubject(subject, id_institute));
    }

    @ResponseBody
    @DeleteMapping("/subject")
    public Msg delSubject(
            @RequestBody SubjectWithBLOBs subject,
            @ModelAttribute("id_institute") long id_institute) throws MyException {
        return Msg.sqlChange(subjectService.delSubject(subject, id_institute));
    }

    @ResponseBody
    @PutMapping("/subject")
    public Msg updateSubject(
            @RequestBody @Validated(Update.class) SubjectWithBLOBs subject,
            @ModelAttribute("id_institute") long id_institute) throws MyException {
        return Msg.sqlChange(subjectService.updateSuject(subject, id_institute));
    }

    //get学生选题的状态

    @GetMapping("/SRS")
    @ResponseBody
    public Msg getSelectSubjected(
            @ModelAttribute("id_institute") long id_institute
    ) {
        System.out.println(subjectService.getSelectSubjected(null, id_institute));
        return Msg.success().add("SRS", subjectService.getSelectSubjected(null, id_institute));
    }

    //get 选某个课题的所有学生
    @GetMapping("/studentsBySubject")
    @ResponseBody
    public Msg getStuentBySubject(
            @RequestParam("id") Long id,
            @ModelAttribute("id_institute") long id_institute
    ) {
        return subjectService.getStuentBySubject(id, id_institute);
    }

//    教师管理 增删改查

    @Autowired
    GeneralPurposeMapper mapper;

    @Autowired
    PublicService publicService;

    //Session 保存时间(秒)
    private final Integer SAVE_TIME = 60*60*24;

    //超管 和 子管用一个登录
    @Autowired
    StudentMapper studentMapper;

    @Autowired
    SubjectselectedMapper subjectselectedMapper;

    @Autowired
    SubjectMapper subjectMapper;
    @Autowired
    ProjectMapper projectMapper;

    @Autowired
    ClassMapper classMapper;

    @Autowired
    SpecialtyMapper specialtyMapper;

    @Autowired
    InstituteMapper instituteMapper;

    @Autowired
    HttpServletRequest request;

    @Autowired
    HttpServletResponse response;

    @Override
    public Msg login(String name, String pwd , HttpSession httpSession) {

        Sadmin sadmin = selectSadminByName(name);
        if(sadmin!=null){
            //验证密码是否与数据库中的相同
            if(sadmin.getPwd().equals(pwd)){
                User user = new User();
                //-1表示为超管
                user.setId(-1L);
                user.setRole("sadmin");
            String str = "";
            for (int i = 0; i < runs.size(); i++) {
                XWPFRun run = runs.get(i);
                String runText = run.toString();
                if ('$' == runText.charAt(0) && '{' == runText.charAt(1)) {
                    start = i;
                }
                if ((start != -1)) {
                    str += runText;
                }
                if ('}' == runText.charAt(runText.length() - 1)) {
                    if (start != -1) {
                        end = i;
                        break;
                    }
                }
            }

            for (int i = start; i <= end; i++) {
                para.removeRun(i);
                i--;
                end--;
            }

            for (Map.Entry<String, Object> entry : params.entrySet()) {
                String key = entry.getKey();
                if (str.indexOf(key) != -1) {
                    Object value = entry.getValue();
                    if (value instanceof String) {
                        str = str.replace(key, value.toString());
                        para.createRun().setText(str, 0);
                        break;
                    } else if (value instanceof Map) {
                        str = str.replace(key, "");
                        Map pic = (Map) value;
                        int width = Integer.parseInt(pic.get("width").toString());
                        int height = Integer.parseInt(pic.get("height").toString());
                        int picType = getPictureType(pic.get("type").toString());
                        byte[] byteArray = (byte[]) pic.get("content");
                        ByteArrayInputStream byteInputStream = new ByteArrayInputStream(byteArray);
                        try {
                            //int ind = doc.addPicture(byteInputStream,picType);
                            //doc.createPicture(ind, width , height,para);
                            doc.addPictureData(byteInputStream, picType);
//                            doc.createPicture(doc.getAllPictures().size() - 1, width, height, para);
                            para.createRun().setText(str, 0);
                            break;
                        } catch (Exception e) {
            for (int i = start; i <= end; i++) {
                para.removeRun(i);
                i--;
                end--;
            }

            for (Map.Entry<String, Object> entry : params.entrySet()) {
                String key = entry.getKey();
                if (str.indexOf(key) != -1) {
                    Object value = entry.getValue();
                    if (value instanceof String) {
                        str = str.replace(key, value.toString());
                        para.createRun().setText(str, 0);
                        break;
                    } else if (value instanceof Map) {
                        str = str.replace(key, "");
                        Map pic = (Map) value;
                        int width = Integer.parseInt(pic.get("width").toString());
                        int height = Integer.parseInt(pic.get("height").toString());
                        int picType = getPictureType(pic.get("type").toString());
                        byte[] byteArray = (byte[]) pic.get("content");
                        ByteArrayInputStream byteInputStream = new ByteArrayInputStream(byteArray);
                        try {
                            //int ind = doc.addPicture(byteInputStream,picType);
                            //doc.createPicture(ind, width , height,para);
                            doc.addPictureData(byteInputStream, picType);
//                            doc.createPicture(doc.getAllPictures().size() - 1, width, height, para);
                            para.createRun().setText(str, 0);
                            break;
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                    }
                }
            }
        }
    }

    /**
     * 为表格插入数据,行数不够添加新行
     *
     * @param table     需要插入数据的表格
     * @param tableList 插入数据集合
     */
    private static void insertTable(XWPFTable table, List<String[]> tableList) {
        //创建行,根据需要插入的数据添加新行,不处理表头
        for (int i = 0; i < tableList.size(); i++) {

请添加图片描述

请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值