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

运行环境

Java≥8、MySQL≥5.7

开发工具

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

适用

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

功能说明

500023242402

510023242402

520023242402

530023242402

540023242402

560023242402

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

一、项目简述

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

二、项目运行 环境配置:

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

项目技术:

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

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
@Controller
@RequestMapping("/sadmin")
public class SuperAdminController {

@Autowired
AdminService adminService;

@Autowired
HttpServletRequest request;

@Autowired
HttpServletResponse response;

@Autowired
CollegeService collegeService;

@ModelAttribute("id_institute")
public long getRoleInfo(HttpSession session) throws MyException {
User user = (User) request.getAttribute("user");
if(user!=null)
return user.getId();
throw new MyException("无法访问");
}

/**
* 在这个controller 添加超管独有的功能
*/
private static final Logger LOGGER = LoggerFactory.getLogger(SuperAdminController.class);

@PostMapping("/updatePwd")
@ResponseBody
public Msg updatePwd(
@RequestBody Sadmin sadmin,
HttpSession httpSession){
// LOGGER.info("newPwd:{}",sadmin.getPwd());

User user = (User)request.getAttribute("user");
adminService.updateSadminPwdByUserName(
user.getUserName(),
sadmin.getPwd()
);
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
fun8(region, sheet, workBook);
cell = row.createCell(6);
cell.setCellValue(teacher.getName());
cell.setCellStyle(style2); //获取指定行并赋值样式
row.setHeightInPoints(30);


//设置单元格样式
XSSFCellStyle style3 = workBook.createCellStyle();
f = workBook.createFont();
f.setFontHeightInPoints((short) 12);//字号
f.setFontName("仿宋_GB2312");//设置字体
style3.setFont(f);
style3.setWrapText(true);
style3.setAlignment(HorizontalAlignment.CENTER);//左右居中
style3.setVerticalAlignment(VerticalAlignment.CENTER);//上下居中
style3.setBorderBottom(BorderStyle.THIN);//下边框
style3.setBorderLeft(BorderStyle.THIN);//左边框
style3.setBorderRight(BorderStyle.THIN);//右边框
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);
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
    RegionUtil.setBorderBottom(borderStyle, region, sheet); // 下边框
RegionUtil.setBorderLeft(borderStyle, region, sheet); // 左边框
RegionUtil.setBorderRight(borderStyle, region, sheet); // 右边框
RegionUtil.setBorderTop(borderStyle, region, sheet); // 上边框
}

//下载学期述职表
@GetMapping("/down_debriefing")
public void fun9(Long year, String term, HttpSession httpSession, HttpServletResponse response) throws IOException {
Teacher teacher = (Teacher) httpSession.getAttribute("teacherInfo");

//查询指定年份的年度,学期述职信息
DebriefingWithBLOBs debriefing = teacherService.selectTermDebriefingInfo(teacher.getId(), year, term);


// 新建工作簿对象
XSSFWorkbook workBook = new XSSFWorkbook();
// 创建sheet对象
XSSFSheet sheet = workBook.createSheet("Sheet1");

sheet.setColumnWidth(0, 15 * 256);//设置第1列宽

sheet.setColumnWidth(6, 24 * 256);//设置第1列宽


//创建行,头标题
XSSFRow row = sheet.createRow(0);
CellRangeAddress region = new CellRangeAddress(0, 0, (short) 0, (short) 6); //合并单元格,
sheet.addMergedRegion(region);
//合并单元格边框
fun8(region, sheet, workBook);

row.createCell(0).setCellValue(teacher.getInstituteName() + year + term + "学期述职表");
row.setHeightInPoints(40); //设置行高

//设置头部单元格样式
XSSFCellStyle style1 = workBook.createCellStyle();
XSSFFont f = workBook.createFont();
f.setFontHeightInPoints((short) 18);//字号
f.setFontName("仿宋_GB2312");//设置字体
f.setBold(true);//加粗
style1.setFont(f);
style1.setAlignment(HorizontalAlignment.CENTER);//左右居中
style1.setVerticalAlignment(VerticalAlignment.CENTER);//上下居中
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
cell.setCellValue("部 门");
cell.setCellStyle(style2); //获取指定行并赋值样式

region = new CellRangeAddress(1, 1, (short) 1, (short) 3);
sheet.addMergedRegion(region);
fun8(region, sheet, workBook);
cell = row.createCell(1);
cell.setCellValue(teacher.getInstituteName());
cell.setCellStyle(style2); //获取指定行并赋值样式

cell = row.createCell(4);
cell.setCellValue("填报人");
cell.setCellStyle(style2); //获取指定行并赋值样式

region = new CellRangeAddress(1, 1, (short) 4, (short) 5);
sheet.addMergedRegion(region);
fun8(region, sheet, workBook);
cell = row.createCell(6);
cell.setCellValue(teacher.getName());
cell.setCellStyle(style2); //获取指定行并赋值样式
row.setHeightInPoints(30);


//设置单元格样式
XSSFCellStyle style3 = workBook.createCellStyle();
f = workBook.createFont();
f.setFontHeightInPoints((short) 12);//字号
f.setFontName("仿宋_GB2312");//设置字体
style3.setFont(f);
style3.setWrapText(true);
style3.setAlignment(HorizontalAlignment.CENTER);//左右居中
style3.setVerticalAlignment(VerticalAlignment.CENTER);//上下居中
style3.setBorderBottom(BorderStyle.THIN);//下边框
style3.setBorderLeft(BorderStyle.THIN);//左边框
style3.setBorderRight(BorderStyle.THIN);//右边框
style3.setBorderTop(BorderStyle.THIN);//上边框


//创建表格主体
//获取教学任务
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
//            rowxx.getCell(0).setCellValue(hang - 2);
// rowxx.getCell(1).setCellValue(projects.get(j).getSection_name());
// rowxx.getCell(2).setCellValue(projects.get(j).getTeachernames());
// rowxx.getCell(3).setCellValue(projects.get(j).getProjectname());
// rowxx.getCell(4).setCellValue(projects.get(j).getTypeName());
// rowxx.getCell(5).setCellValue(projects.get(j).getSourceName());
// rowxx.getCell(6).setCellValue(" " + projects.get(j).getSelectcount());
// }
//
// // 自动列宽
// sheet.setDefaultRowHeight((short) (2 * 256));
// setSizeColumn(sheet, 7);
//
// String filename = "课题一览表.xlsx";
// if (Idinstitute != null && institutes != null && institutes.size() > 0) filename = institutes.get(0).getInstituteName() + "课题一览表.xlsx";
// filename = ExcelImportUtils.filenameEncoding(filename, request);
// response.setContentType("application/vnd.ms-excel;charset=utf-8");
// OutputStream os = response.getOutputStream();
// response.setHeader("Content-disposition", "attachment;filename=" + filename);//默认Excel名称
// wb.write(os);
// os.flush();
// os.close();
// }

// 自适应宽度(中文支持)
private void setSizeColumn(XSSFSheet sheet, int size) {
for (int columnNum = 1; columnNum < size; columnNum++) {
int columnWidth = sheet.getColumnWidth(columnNum) / 256;
for (int rowNum = 0; rowNum < sheet.getLastRowNum(); rowNum++) {
XSSFRow currentRow;
//当前行未被使用过
if (sheet.getRow(rowNum) == null) {
currentRow = sheet.createRow(rowNum);
} else {
currentRow = sheet.getRow(rowNum);
}
if (currentRow.getCell(columnNum) != null) {
XSSFCell currentCell = currentRow.getCell(columnNum);
if (currentCell.getCellType() == XSSFCell.CELL_TYPE_STRING) {
int length = currentCell.getStringCellValue().getBytes().length;
if (columnWidth < length) {
columnWidth = length;
}
}
}
}
sheet.setColumnWidth(columnNum, (columnWidth + 4) * 256);
}
}

// 以专业生成 课题一览表;
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
        setSizeColumn(sheet, 8);

response.setCharacterEncoding("utf-8");
response.setContentType("application/msexcel");
OutputStream os = response.getOutputStream();
String outputName = "学生一览表";
String encodeFilename = URLEncoder.encode(outputName, StandardCharsets.UTF_8.toString());
response.setHeader("Content-disposition", "attachment; filename=" + encodeFilename + ".xlsx");

wb.write(os);
os.flush();
os.close();
}


//设置合并单元格边框
public void fun8(CellRangeAddress region, XSSFSheet sheet, XSSFWorkbook workBook) {

BorderStyle borderStyle = BorderStyle.THIN;

RegionUtil.setBorderBottom(borderStyle, region, sheet); // 下边框
RegionUtil.setBorderLeft(borderStyle, region, sheet); // 左边框
RegionUtil.setBorderRight(borderStyle, region, sheet); // 右边框
RegionUtil.setBorderTop(borderStyle, region, sheet); // 上边框
}

}
package com.hngy.educationaladministration.controller;


项目链接:
https://javayms.github.io?id=521422312105200jc
https://javayms.pages.dev?id=521422312105200jc