目 录
摘 要 I
Abstract II
1绪论 1
1.1选题背景及意义 1
1.2国内外研究现状 2
1.3研究主要内容 2
2系统工具 4
2.1 B/S结构 4
2.2 JSP技术 4
2.3 Tomcat虚拟服务器 5
2.4 MVC模式 5
2.5 SSM框架 6
2.6 MySQL数据库 10
3系统分析 11
3.1需求分析 11
3.2系统功能分析 12
3.3系统开发环境 12
4系统设计 14
4.1设计思想 14
4.2系统功能设计 14
4.3数据库设计 15
5系统实现 18
5.1登陆 18
5.2首页 18
5.3课程管理 19
5.4课程增加 19
5.5教师管理 20
5.6班级管理 20
5.7学生管理 21
5.8排课 21
5.9排课统计 22
5.10用户管理 23
6系统测试 24
6.1 程序调试 24
6.2 程序的测试 24
6.2.1 测试的重要性及目的 24
6.2.2 测试的步骤 25
6.2.3 测试的主要内容 26
总 结 28
参考文献 29
致 谢 31
1.3研究主要内容
以本人所在学院的实际情况为背景,对排课问题进行需求分析,建立系统业务模型,分析排课流程,从而给出排课系统的功能模块框图;使用合适的排课算法,使排课效率和质量得到提高;进行系统详细设计、数据库设计,编程实现自动排课系统全部功能,完成软件开发。通过对以上方面的研究,完成排课系统的设计与实现。智能排课系统需要同时实现对学院教师、教室、班级、课程及上课时间的信息管理。功能主要包括:
(1) 系统管理功能集合。该集合包括权限管理模块。当使用者为管理员时,可进行权限管理功能,它能够添加新的使用者,也可对已有的用户进行名称、密码的修改和删除。
(2) 基本信息管理功能集合。该集合包括教师信息管理、教室信息管理、班级信息管理、课程信息管理、上课时间管理五个模块。在该集合内可查看相应的数据表,对于管理员级别的用户,可对以数据库表中的内容进行添加、修改、删除等操作。对于一般用户,只能实现查看信息的基本功能。
(3) 排课管理功能集合。在基本信息设置模块中,可设置限制排课的条件,如不加限制排课、不在晚上和星期六排课等。而一般用户只能查看管理员设置的条件。在排课时,管理员先在课程信息管理中设置好要预先排课的课程,然后调节限制排课的条件,就可以使用自动排课功能。用户可在排好后的课表中查看课表,而手动排课也可针对实验课等灵活性的课程。
4系统设计
4.1设计思想
本系统采用各班级独立划分管理,所有教师均可为任何班级服务,各班级根据每天课程数目来进行自动排序,同时各教师允许教学多门课程,因此为了每名教师配置了时间占用表,只要与班级对应的时间空间表未被占用,都可以参与排课,并根据用户定义的要求排出课程。
数据管理类:由于班级,时间,教师,课程等信息都需要一个活动的管理过程,因为在节省资源的情况下,将各数据所需要的代码合并在一起进行编写和使用。
图4.1 数据管理
4.2系统功能设计
智能排课系统在功能上如图4.2:
图4.2 系统功能模块划分
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page import="java.util.*,java.io.*" %>
<%@ page import="java.text.SimpleDateFormat" %>
<%@ page import="org.apache.commons.fileupload.*" %>
<%@ page import="org.apache.commons.fileupload.disk.*" %>
<%@ page import="org.apache.commons.fileupload.servlet.*" %>
<%@ page import="org.json.simple.*" %>
<%
/**
* KindEditor JSP
*
* 本JSP程序是演示程序,建议不要直接在实际项目中使用。
* 如果您确定直接使用本程序,使用之前请仔细确认相关安全设置。
*
*/
//文件保存目录路径
String savePath = pageContext.getServletContext().getRealPath("/") + "upload/";
System.out.print(savePath);
//文件保存目录URL
String saveUrl = request.getContextPath() + "/upload/";
//定义允许上传的文件扩展名
HashMap<String, String> extMap = new HashMap<String, String>();
extMap.put("image", "gif,jpg,jpeg,png,bmp");
extMap.put("flash", "swf,flv");
extMap.put("media", "swf,flv,mp3,wav,wma,wmv,mid,avi,mpg,asf,rm,rmvb");
extMap.put("file", "doc,docx,xls,xlsx,ppt,htm,html,txt,zip,rar,gz,bz2");
//最大文件大小
long maxSize = 1000000000;
response.setContentType("text/html; charset=UTF-8");
if(!ServletFileUpload.isMultipartContent(request)){
out.println(getError("请选择文件。"));
return;
}
//检查目录
File uploadDir = new File(savePath);
if(!uploadDir.isDirectory()){
out.println(getError("上传目录不存在。"));
return;
}
//检查目录写权限
if(!uploadDir.canWrite()){
out.println(getError("上传目录没有写权限。"));
return;
}
String dirName = request.getParameter("dir");
if (dirName == null) {
dirName = "image";
}
if(!extMap.containsKey(dirName)){
out.println(getError("目录名不正确。"));
return;
}
//创建文件夹
savePath += dirName + "/";
saveUrl += dirName + "/";
File saveDirFile = new File(savePath);
if (!saveDirFile.exists()) {
saveDirFile.mkdirs();
}
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
String ymd = sdf.format(new Date());
savePath += ymd + "/";
saveUrl += ymd + "/";
File dirFile = new File(savePath);
if (!dirFile.exists()) {
dirFile.mkdirs();
}
FileItemFactory factory = new DiskFileItemFactory();
ServletFileUpload upload = new ServletFileUpload(factory);
upload.setHeaderEncoding("UTF-8");
List items = upload.parseRequest(request);
Iterator itr = items.iterator();
while (itr.hasNext()) {
FileItem item = (FileItem) itr.next();
String fileName = item.getName();
long fileSize = item.getSize();
if (!item.isFormField()) {
//检查文件大小
if(item.getSize() > maxSize){
out.println(getError("上传文件大小超过限制。"));
return;
}
//检查扩展名
String fileExt = fileName.substring(fileName.lastIndexOf(".") + 1).toLowerCase();
if(!Arrays.<String>asList(extMap.get(dirName).split(",")).contains(fileExt)){
out.println(getError("上传文件扩展名是不允许的扩展名。\n只允许" + extMap.get(dirName) + "格式。"));
return;
}
SimpleDateFormat df = new SimpleDateFormat("yyyyMMddHHmmss");
String newFileName = df.format(new Date()) + "_" + new Random().nextInt(1000) + "." + fileExt;
try{
File uploadedFile = new File(savePath, newFileName);
item.write(uploadedFile);
}catch(Exception e){
out.println(getError("上传文件失败。"));
return;
}
JSONObject obj = new JSONObject();
obj.put("error", 0);
obj.put("url", saveUrl + newFileName);
out.println(obj.toJSONString());
}
}
%>
<%!
private String getError(String message) {
JSONObject obj = new JSONObject();
obj.put("error", 1);
obj.put("message", message);
return obj.toJSONString();
}
%>
- 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
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
- 62
- 63
- 64
- 65
- 66
- 67
- 68
- 69
- 70
- 71
- 72
- 73
- 74
- 75
- 76
- 77
- 78
- 79
- 80
- 81
- 82
- 83
- 84
- 85
- 86
- 87
- 88
- 89
- 90
- 91
- 92
- 93
- 94
- 95
- 96
- 97
- 98
- 99
- 100
- 101
- 102
- 103
- 104
- 105
- 106
- 107
- 108
- 109
- 110
- 111
- 112
- 113
- 114
- 115
- 116
- 117
- 118
- 119
- 120
- 121
- 122