基于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等等
WorkapprovalWithBLOBs workapproval = teacherService.selectWorkById(id);
SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd");
String start = sdf.format(workapproval.getBeginDate());
String end = sdf.format(workapproval.getEndDate());
String time = start + " - " + end;
model.addAttribute("workapproval", workapproval);
model.addAttribute("time", time);
return "teacher/workapproval/fillwdata";
}
//上传出差报告
@PostMapping("/fill_in_w")
@ResponseBody
public Msg fun7(@RequestParam("id_work") Long idWork, @RequestParam("news") String news, @RequestParam("flag") Integer flag,
@RequestParam("file") MultipartFile file) throws IOException {
//判断file的值是否为空
if (file.isEmpty()) {
return Msg.error();
}
String fileName = file.getOriginalFilename();// 获取上传文件的原名
int size = (int) file.getSize();
System.out.println(fileName + "-->" + size);
File path = new File(ResourceUtils.getURL("target").getPath());
String savePath = path.getAbsolutePath() + "\\classes\\static\\model";
String saveFileName = savePath + "\\" + fileName;
// String path = "D:/test";//文件保存路径
File targetFile = new File(savePath);
if (!targetFile.getParentFile().exists()) { //判断文件父目录是否存在
targetFile.getParentFile().mkdir();
}
file.transferTo(new File(targetFile, fileName)); // 开始接受文件
Workapprovaldata workapprovaldata = new Workapprovaldata();
workapprovaldata.setIdWorkapproval(idWork);
workapprovaldata.setNews(news);
workapprovaldata.setDatarar(saveFileName);
//flag == 0 公有 flag == 1私有
workapprovaldata.setFlag(flag);
teacherService.insertWordData(workapprovaldata);
return Msg.success();
}
//查看出差报告
@GetMapping("/select_work_data")
@ResponseBody
workBook.close();
}
//毕业设计管理
//加载教师课题已发布页面
@GetMapping("/sectionProject")
public String fun10(ModelMap modelMap, Model model, HttpSession session) {
Teacher teacher = (Teacher) session.getAttribute("teacherInfo");
List<Project> projects = teacherService.selectTeacherFBProject(teacher.getName());
List<Integer> selectnum = new ArrayList<Integer>();
int successNum = 0, num = 0;
if (projects != null) {
for (int i = 0; i < projects.size(); i++) {
num = teacherService.selectedSuccessNum(projects.get(i).getId());
selectnum.add(num);
successNum += num;
if (projects.get(i).getSelectFlag() == 0) projects.get(i).setProjectGB("可选");
else if (projects.get(i).getSelectFlag() == 1) projects.get(i).setProjectGB("不可选");
}
}
int allNnm = teacherService.selectAllXB(teacher.getId());
modelMap.addAttribute("Myproject", projects);
model.addAttribute("number", selectnum);
model.addAttribute("successNum", successNum);
model.addAttribute("allNum", allNnm);
return "teacher/graduation/section_xb/subjectclass";
}
// 加载课题学生选报页面
@GetMapping("/topicsinfoto")
public String fun11(ModelMap modelMap, Model model, String projectName) {
List<Static_student> static_students = staticService.seleStudentbyTJ("", "", projectName);
Project project = staticService.selectProjectbyName(projectName);
//判断课题是否属于关闭状态
if(project.getSelectFlag() == 1){
//关闭
@Autowired
TeacherService teacherService;
@Autowired
StudentService studentService;
@Autowired
SubjectService subjectService;
@Autowired
ExcelService excelService;
@Autowired
SubjectRelationStudentMapper subjectRelationStudentMapper;
@Autowired
HttpServletRequest request;
@Autowired
HttpServletResponse response;
@Autowired
HttpSession session;
@ModelAttribute("id_institute")
public long getRoleInfo() {
User user = (User) request.getAttribute("user");
// LOGGER.info("USER:{}",user);
if (user != null) {
if (user.getRole().equals("admin")) {
Institute institute = collegeService.selectCollege(adminMapper.selectByPrimaryKey(user.getId()).getIdInstitute());
return institute.getId();
}
if (user.getRole().equals("sadmin")) {
return -1;
}
return 0;
} else {
return 0;
}
}
// admin index page 子管首页
@GetMapping(value = {"", "/index"})
public String index() {
User user = (User) request.getAttribute("user");
// LOGGER.info("index user:{}",user);
//这部分还是用了session存储部分信息 后续可能修改
//根据 user的id 判断 渲染页面
if (user.getId() == -1) {
LOGGER.info("超级管理员登录");
if(token == null){
token = request.getHeader("Authorization");
}
if(token == null){
return null;
}
try {
//选用 HMAC256 算法 ,私钥为 JWT_SECRET
JWTVerifier verifier = JWT.require(Algorithm.HMAC256(JWT_SECRET))
// .withIssuer("zz")
.build(); //Reusable verifier instance
//验证Token的合法性
DecodedJWT jwt = verifier.verify(token);
User user = JSON.parseObject(jwt.getClaim("user").asString(),User.class);
return user;
} catch ( TokenExpiredException e){
// e.printStackTrace();
throw new LoginTimeoutException("登录超时");
} catch (JWTVerificationException exception ){
// exception.printStackTrace();
}
return null;
}
}
File dirs = new File(savePath);
//判断路径是否存在,如果不存在就创建一个
if (!dirs.exists()) {
dirs.mkdirs();
}
file.transferTo(new File(dirs, uploadFileName)); // 开始接受文件
SubjectWithBLOBs project = subject1;
project.setProjectname(projectName);
project.setIdProjecttype(idProjecttype);
project.setIdProjectsource(idProjectsource);
project.setFilepath(saveFileName);
project.setMarchspecialty(marchspecialty.trim());
project.setTeachernames(teachernames);
//修改后状态置 0
project.setSelectFlag(0);
project.setVerifyprojectFlag(0);
project.setReleaseFlag(0);
int i = subjectService.updateSubjectByid(project);
return Msg.success();
}
}
@GetMapping("/getSubjectById")
@ResponseBody
public Msg getss(Long id) {
SubjectWithBLOBs subject = subjectService.getSubjectByID(id);
System.out.println(subject);
* @param user
* @return
*/
public static String createToken(User user){
String token = null;
try {
token = JWT.create()
// .withIssuer("zz")
//将 user 信息 存放到 Token 之中
.withClaim("user", JSONObject.toJSONString(user))
//设置过期时间
.withExpiresAt(new Date(System.currentTimeMillis()+TOKEN_EXPIRED_TIME))
//签名采用 HMAC256 算法 私钥为JWT_SECRET
.sign(Algorithm.HMAC256(JWT_SECRET));
System.out.println(token);
} catch (JWTCreationException exception){
//Invalid Signing configuration / Couldn't convert Claims.
}
return token;
}
/**
* 验证token
* @param request
* @return
*/
public static User verifyToken(HttpServletRequest request){
Cookie[] cookies = request.getCookies();
if(cookies==null)
return null;
String token = null;
for(Cookie cookie : cookies){
// System.out.println("cookie:"+cookie.getName());
// System.out.println("value:"+cookie.getValue());
// System.out.println("path:"+cookie.getPath());
// System.out.println();
String path = cookie.getPath();
String name = cookie.getName();
String value = cookie.getValue();
if(
name.equals("token") &&
value!=null &&
value.length()!=0
//flag == 0 公有 flag == 1私有
workapprovaldata.setFlag(flag);
teacherService.insertWordData(workapprovaldata);
return Msg.success();
}
//查看出差报告
@GetMapping("/select_work_data")
@ResponseBody
public Msg fun8(Integer pn, HttpSession httpSession) {
Teacher teacher = (Teacher) httpSession.getAttribute("teacherInfo");
PageHelper.startPage(pn, 9);
List<Workapprovaldata> list = teacherService.selectWorkData(teacher.getIdSection());
PageInfo page = new PageInfo(list, 5);
return Msg.success().add("dataInfo", page);
}
//出差附件下载
@RequestMapping(value = "/file_download")
public ResponseEntity<byte[]> downloadFile(String dataId, HttpServletRequest req, HttpServletResponse response) throws IOException {
Workapprovaldata workapprovaldata = null;
if (dataId != null) {
Long id = Long.valueOf(dataId);
workapprovaldata = teacherService.selectWorkDataById(id);
}
if (workapprovaldata != null) {
String filePath = workapprovaldata.getDatarar();
//设置文件路径
File file = new File(filePath);
if (!file.exists()) {
file.mkdirs();
}
String fileName = file.getName();
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.MULTIPART_FORM_DATA);
put("name", teacher.getName());
put("gender", teacher.getGender());
put("education", teacher.getEducation());
// SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
// String time = sdf.format(teacher.getParticipationdate());
System.out.println(teacher.getParticipationdate());
put("date", teacher.getParticipationdate());
put("administrativeDuty", teacher.getAdministrativeduty());
put("technicalPosition", teacher.getTechnicalposition());
put("politicalStatus", teacher.getPoliticalstatus());
put("year", assessment.getYear());
put("personalSummary", assessment.getPersonalsummary());
}
};
File path = new File(ResourceUtils.getURL("target").getPath());
String wordPath = path.getAbsolutePath() + "\\classes\\static\\model\\";
String modelName = "ndkh.docx";
XWPFTemplate template = XWPFTemplate.compile(wordPath + modelName)
.render(datas);
try {
BufferedOutputStream out = new BufferedOutputStream(output);
template.write(out);
out.flush();
out.close();
template.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
//下载年度述职表
@GetMapping("/down_year_debriefing")
public void fun7(Long year, HttpSession httpSession, HttpServletResponse response) throws IOException {
Teacher teacher = (Teacher) httpSession.getAttribute("teacherInfo");
//查询指定年份的年度述职信息
.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 {
//名字
String encodeFilename = URLEncoder.encode("教师导入模板", StandardCharsets.UTF_8.toString());
response.setContentType("application/vnd.ms-excel");
response.setCharacterEncoding("utf-8");
response.setHeader("Content-Disposition", "attachment; filename=" + encodeFilename + ".xlsx");
// 模板样例数据
ArrayList<TeacherExcel> teacherExcels = new ArrayList<>();
TeacherExcel teacherExcel = new TeacherExcel();
teacherExcel.setName("张三");
teacherExcel.setGender("男");
teacherExcel.setSectionName("软件教研室");
teacherExcel.setUsername("430181199903035022");
teacherExcel.setVerifyFlag("教师");
teacherExcels.add(teacherExcel);
// 这里 需要指定写用哪个class去读 TeacherExcel.class
EasyExcel.write(response.getOutputStream())
// 这里放入动态头
.head(TeacherExcelUtil.head()).sheet("模板")
// table的时候 传入class 并且设置needHead =false
.table().head(TeacherExcel.class)
.needHead(Boolean.FALSE)
.doWrite(teacherExcels);//写入空数据
}
/**
* 学生导入
*
* @param excelFile
* @param id_institute
*/
@Override
public Msg studentExcelImport(MultipartFile excelFile, long id_institute) throws IOException {
// List<Project> projects = adminService.select_project(Idinstitute, null, null);
//
// //创建工作簿
// XSSFWorkbook wb = new XSSFWorkbook();
// //创建一个sheet
// XSSFSheet sheet = wb.createSheet();
//
// // 创建单元格样式
// XSSFCellStyle style1 = wb.createCellStyle();
// style1.setAlignment(HorizontalAlignment.CENTER); //文字水平居中
// style1.setVerticalAlignment(VerticalAlignment.CENTER);//文字垂直居中
// style1.setBorderBottom(BorderStyle.THIN); //底边框加黑
// style1.setBorderLeft(BorderStyle.THIN); //左边框加黑
// 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 < projects.size() + 3; i++) { //需要6行表格
// Row row = sheet.createRow(i); //创建行
// for (int j = 0; j < 7; j++) {//需要6列
// row.createCell(j).setCellStyle(style);
// 学院的增删改查
// int add_institute(String institute_name);
//
// int delete_institute(Long institute_id);
//
// int update_institute(Long institute_id, String institute_name);
List<Institute> select_institute(Long institute_id, String institute_name);
// 专业方向的增删改查
int add_specialty(Long section_id, String specialty_name);
int delete_specialty(Long specialty_id);
int update_specialty(Long specialty_id, Long section_id, String specialty_name);
List<Specialty> select_specialty(Long institute_id, Long section_id, Long specialty_id, String specialty_name); // 根据学院id 或者 教研室id 查所有专业方向
}
student.setUsername(userName);
student.setStunum(stuNum);
student.setIdClass(id_class);
student.setName(name);
student.setGender(gender);
student.setPwd(pwd);
return studentMapper.updateByPrimaryKeySelective((StudentWithBLOBs) student);
}
@Override
public List<Static_student> select_student(Long institute_id, Long specialty_id, Long class_id, Long student_id, String name) {
List<Static_student> static_students = studentMapper.select_Student(institute_id, specialty_id, class_id, student_id, name);
if (static_students != null) {
for (int i = 0; i < static_students.size(); i++) {
Static_student static_student = static_students.get(i);
List<Subjectselected> projectselected = select_Projectselected(static_student.getId(), null);
if (projectselected != null && projectselected.size() != 0) {
String s = "";
if (projectselected.get(0).getStuselectFlag() == 1) s = "选题待审核";
else if (projectselected.get(0).getStuselectFlag() == 2) s = "选题未通过";
else s = "选题通过";
static_student.setStuselectFlag(s);
static_student.setProjectname(projectselected.get(0).getProject_name());
static_student.setTeachernames(projectselected.get(0).getProject_teachers());
}
}
return static_students;
}
return null;
}
// 通过学生id 或者 课题id 查 课题的选择 情况
public List<Subjectselected> select_Projectselected(Long student_id, Long project_id) {
return subjectselectedMapper.select_Projectselected(student_id, project_id);
}
public List<Subject> select_ProjectXQ(Long institute_id, Long section_id, String name) {
List<Subject> projects = subjectMapper.select_ProjectXQ(institute_id, section_id, name);
if (projects != null) {
for (int i = 0; i < projects.size(); i++) {
if (projects.get(i).getSelectFlag() == 0) projects.get(i).setProjectGB("可选");
else if (projects.get(i).getSelectFlag() == 1) projects.get(i).setProjectGB("不可选");
}
}
return projects;
}
public int delete_specialty(Long specialty_id) {
}
@ResponseBody
@PutMapping("/class")
public Msg putClass(
@RequestBody @Validated({One.class}) MyClass myClass,
@ModelAttribute("id_institute") long id_institute
) throws MyException {
return Msg.sqlChange((int) classService.putClass(myClass, id_institute));
}
@ResponseBody
@PostMapping("/class")
public Msg postClass(
@RequestBody @Validated({One.class}) MyClass myClass,
@ModelAttribute("id_institute") long id_institute
) throws MyException {
return Msg.sqlChange((int) classService.postClass(myClass, id_institute));
}
// 课题综合管理
@GetMapping("/SourceManagement")
public String source() {
return "admin/Subject/SourceManagement";
}
@ResponseBody
@GetMapping("/sources")
public Msg getSources() {
return Msg.success().add("sources", subjectService.selectSubjectSources());
}
@ResponseBody
@PostMapping("/source")
public Msg addSource(@RequestBody @Validated SubjectSource source) throws MyException {
return Msg.sqlChange((int) subjectService.insertSubjectSource(source.getSourcename()));
}
@ResponseBody
@DeleteMapping("/source")
public Msg delSource(@RequestBody SubjectSource source) throws MyException {
return Msg.sqlChange(subjectService.delSubjectSource(source.getId()));
}
String otherWork, String winAward, String summary, HttpSession httpSession) {
Teacher teacher = (Teacher) httpSession.getAttribute("teacherInfo");
DebriefingWithBLOBs debriefingWithBLOBs = new DebriefingWithBLOBs();
debriefingWithBLOBs.setIdTeacher(teacher.getId());
debriefingWithBLOBs.setYear(Long.parseLong(year));
debriefingWithBLOBs.setTerm(term);
debriefingWithBLOBs.setTeachingtask(teachingTask);
debriefingWithBLOBs.setAchievementsinscientificresearch(scientificResearch);
debriefingWithBLOBs.setOtherwork(otherWork);
debriefingWithBLOBs.setWinaward(winAward);
debriefingWithBLOBs.setSummary(summary);
int flag = teacherService.selectTermDebriefingFlag(teacher.getId(), Long.parseLong(year), term);
if (flag == 1) {
teacherService.updateTermDebriefing(debriefingWithBLOBs);
} else {
int i = teacherService.insertTermDebriefing(debriefingWithBLOBs);
}
return Msg.success();
}
// 工作量表相关
@GetMapping("/wordload")
public String wordloadPage() {
return "teacher/table/workload";
}
@GetMapping("/wordloadData")
@ResponseBody
public Msg wordloadData(
@RequestParam("year") String year,
@RequestParam("trem") String trem
) {
Teacher teacher = (Teacher) request.getSession().getAttribute("teacherInfo");
return Msg.success()
.add("teacher", teacher)
.add("workloadDTO", teacherService.getWorkload(teacher.getId(), year, trem));
}
private static final Logger LOGGER = LoggerFactory.getLogger(TeacherController.class);
@Autowired
HttpServletRequest request;
@PostMapping("/wordload")
@ResponseBody
public Msg wordloadSave(
@RequestBody WorkloadDTO workloadDTO
) {
List<WorkapprovalWithBLOBs> list = staticService.selectAllWorkApproval(teacher.getIdSection());
PageInfo page = new PageInfo(list, 5);
return Msg.success().add("workInfo", page);
}
//审核员审核出差申请
@PostMapping("/SH_work")
@ResponseBody
public Msg fun4(Long zt, Long workID, HttpSession httpSession) {
Teacher teacher = (Teacher) httpSession.getAttribute("teacherInfo");
WorkapprovalWithBLOBs workapprovalWithBLOBs = teacherService.selectWorkById(workID);
if (zt == 1) {
workapprovalWithBLOBs.setAppovalflag(1);
} else {
workapprovalWithBLOBs.setAppovalflag(2);
}
Date date = new Date();
workapprovalWithBLOBs.setAppovaldate(date);
workapprovalWithBLOBs.setIdSubadmin(teacher.getId());
staticService.updateShWorkApproval(workapprovalWithBLOBs);
return Msg.success();
}
//下载年度专业技术人员考核表
@GetMapping("/down_technical_personnel")
public void fun5(Long year, HttpSession httpSession, HttpServletResponse response) throws IOException {
Teacher teacher = (Teacher) httpSession.getAttribute("teacherInfo");
response.setCharacterEncoding("utf-8");
response.setContentType("application/ms-word");
OutputStream output = response.getOutputStream();
String outputName = "专业技术人员考核表(一年一张)";
String encodeFilename = URLEncoder.encode(outputName, StandardCharsets.UTF_8.toString());
response.setHeader("Content-disposition", "attachment; filename=" + encodeFilename + ".docx");
TechnicalPersonnelWithBLOBs technicalPersonnelWithBLOBs = teacherService.selectTechnicalPersonnelInfo(teacher.getId(), year);
Map<String, Object> datas = new HashMap<String, Object>() {
{
row1.getCell(3).setCellValue("课题来源");
row1.getCell(4).setCellValue("适用专业");
row1.getCell(5).setCellValue("知道教师");
row1.getCell(6).setCellValue("当前状态");
row1.getCell(7).setCellValue("备注");
int hang = 2;
//导入数据
for (int j = 0; j < projects.size(); j++, hang++) {
XSSFRow rowxx = sheet.getRow(hang);
rowxx.getCell(0).setCellValue(hang - 1);
rowxx.getCell(1).setCellValue(projects.get(j).getProjectname());
rowxx.getCell(2).setCellValue(projects.get(j).getSourceName());
rowxx.getCell(3).setCellValue(projects.get(j).getTypeName());
rowxx.getCell(4).setCellValue(projects.get(j).getMarchspecialty());
rowxx.getCell(5).setCellValue(projects.get(j).getTeachernames());
rowxx.getCell(6).setCellValue(projects.get(j).getProjectZT());
rowxx.getCell(7).setCellValue(" ");
}
// 自动列宽
sheet.setDefaultRowHeight((short) (2 * 256));
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();
}
//生成课题选报成功学生一览表
@RequestMapping("/projectXSYLB/{projectId}")
public void project_students_excel(@PathVariable Long projectId, String projectName, HttpServletRequest request, HttpServletResponse response) throws IOException {
List<Student> students = teacherService.selectProjectStudents(projectId);
List<Long> classIds = new ArrayList<>();
Map<Long, Class> ClassMap = new HashMap<>();
@GetMapping("/sectionProject")
public String fun10(ModelMap modelMap, Model model, HttpSession session) {
Teacher teacher = (Teacher) session.getAttribute("teacherInfo");
List<Project> projects = teacherService.selectTeacherFBProject(teacher.getName());
List<Integer> selectnum = new ArrayList<Integer>();
int successNum = 0, num = 0;
if (projects != null) {
for (int i = 0; i < projects.size(); i++) {
num = teacherService.selectedSuccessNum(projects.get(i).getId());
selectnum.add(num);
successNum += num;
if (projects.get(i).getSelectFlag() == 0) projects.get(i).setProjectGB("可选");
else if (projects.get(i).getSelectFlag() == 1) projects.get(i).setProjectGB("不可选");
}
}
int allNnm = teacherService.selectAllXB(teacher.getId());
modelMap.addAttribute("Myproject", projects);
model.addAttribute("number", selectnum);
model.addAttribute("successNum", successNum);
model.addAttribute("allNum", allNnm);
return "teacher/graduation/section_xb/subjectclass";
}
// 加载课题学生选报页面
@GetMapping("/topicsinfoto")
public String fun11(ModelMap modelMap, Model model, String projectName) {
List<Static_student> static_students = staticService.seleStudentbyTJ("", "", projectName);
Project project = staticService.selectProjectbyName(projectName);
//判断课题是否属于关闭状态
if(project.getSelectFlag() == 1){
//关闭
model.addAttribute("flag", 1);
}else {
//打开
model.addAttribute("flag", 0);
}
model.addAttribute("projectId",project.getId());
model.addAttribute("projectName",projectName);
System.out.println(static_students);
modelMap.addAttribute("Myproject", static_students);
return "teacher/graduation/section_xb/topicsinfoto";
}
// font1.setFontName("宋体");
// font1.setFontHeightInPoints((short) 10.5);//设置字体大小
// style.setFont(font1);
为单元格添加背景样式
// for (int i = 1; i < projects.size() + 3; i++) { //需要6行表格
// Row row = sheet.createRow(i); //创建行
// for (int j = 0; j < 7; j++) {//需要6列
// row.createCell(j).setCellStyle(style);
// }
// }
// //合并单元格
// sheet.addMergedRegion(new CellRangeAddress(0, 0, 0, 6));//合并单元格,cellRangAddress四个参数,第一个起始行,第二终止行,第三个起始列,第四个终止列
// sheet.addMergedRegion(new CellRangeAddress(1, 2, 0, 0));
// sheet.addMergedRegion(new CellRangeAddress(1, 2, 1, 1));
// sheet.addMergedRegion(new CellRangeAddress(1, 2, 2, 2));
// sheet.addMergedRegion(new CellRangeAddress(1, 1, 3, 5));
// sheet.addMergedRegion(new CellRangeAddress(1, 2, 6, 6));
// //设置标题栏
// XSSFRow row = sheet.createRow(0); //获取第一行
// row.createCell(0).setCellStyle(style1);
// if (Idinstitute != null) {
// row.getCell(0).setCellValue("湖南工业职业技术学院 " + institutes.get(0).getInstituteName() + " 毕业设计课题汇总表"); //在第一行中创建一个单元格并赋值
// } else {
// row.getCell(0).setCellValue("湖南工业职业技术学院全院毕业设计课题汇总表");
// }
// XSSFRow row1 = sheet.getRow(1); //获取第二行,为每一列添加字段
// row1.getCell(0).setCellValue("序号");
// row1.getCell(1).setCellValue("专业");
// row1.getCell(2).setCellValue("指导老师");
// row1.getCell(3).setCellValue("课 题");
// row1.getCell(6).setCellValue("报选人数");
// XSSFRow row2 = sheet.getRow(2); //获取第三行
// row2.getCell(3).setCellValue("课题名称");
// row2.getCell(4).setCellValue("课题类型");
// row2.getCell(5).setCellValue("课题来源");
//
// int hang = 3;
// //导入数据
// for (int j = 0; j < projects.size(); j++, hang++) {
// XSSFRow rowxx = sheet.getRow(hang);
// 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());