基于javaweb的SSM自习室图书馆座位预约占座管理系统前台后台(java+ssm+jsp+layui+mysql)

运行环境

Java≥8、MySQL≥5.7、Tomcat≥8

开发工具

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

适用

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

功能说明

221923082708

231923082708

241923082708

251923082708

261923082708

271923082708

281923082708

301923082708

311923082708

321923082708

331923082708

341923082708

351923082708

361923082708

基于javaweb的SSM自习室图书馆座位预约占座管理系统前台后台(java+ssm+jsp+layui+mysql)

管理员
admin 123456

学生
xs001 123456
xs002 123456
xs003 123456
xs004 123456

添加学生时会自动在用户表中注册
定时任务会定时生成座位信息,
阅览室分类中可设置信用等级,
学生被扣分后信用等级低于相应的值后不能预约相应的阅览室座位。

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
 * 用户管理
*/

@Controller
@RequestMapping("user")
public class UserController extends LogController{

private int page;
private int rows;
private User user;
@Autowired
private UserService<User> userService;
@Autowired
private StudentService<Student> studentStudentService;



@RequestMapping("userIndex")
public String index(){
return "sys/user";
}


@RequestMapping("userList")
public void userList(HttpServletRequest request,HttpServletResponse response){
try {
page = Integer.parseInt(request.getParameter("page"));
rows = Integer.parseInt(request.getParameter("limit"));
user = new User();
user.setPage((page-1)*rows);
user.setRows(rows);
user.setUserName(request.getParameter("userName"));
String roleId = request.getParameter("roleId");
if (StringUtil.isNotEmpty(roleId)) {
user.setRoleId(Integer.parseInt(roleId));
} else {
user.setRoleId(null);
}
List<User> list = userService.findUser(user);
int total = userService.countUser(user);
JSONObject jsonObj = new JSONObject();//new一个JSON
jsonObj.put("code", 0);
jsonObj.put("msg", "");
jsonObj.put("count",total );//total代表一共有多少数据
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
	WriterUtil.write(response, result.toString());
}



// 判断是不是叶子节点
public boolean isLeaf(String menuId){
boolean flag = false;
try {
menu = new Menu();
menu.setParentId(Integer.parseInt(menuId));
List<Menu> list = menuService.findMenu(menu);
if (list==null || list.size()==0) {
flag = true;
}
} catch (Exception e) {
e.printStackTrace();
}
return flag;
}




@RequestMapping("deleteMenu")
public void deleteMenu(HttpServletRequest request,HttpServletResponse response){
JSONObject result = new JSONObject();
try {
String menuId = request.getParameter("menuId");
String parentId = request.getParameter("parentId");
if (!isLeaf(menuId)) { //不是叶子节点,说明有子菜单,不能删除
result.put("errorMsg", "该菜单下面有子菜单,不能直接删除");
} else {
menu = new Menu();
menu.setParentId(Integer.parseInt(parentId));
int sonNum = menuService.countMenu(menu);
if (sonNum == 1) {
// 只有一个孩子,删除该孩子,且把父亲状态置为open
menu = new Menu();
menu.setMenuId(Integer.parseInt(parentId));
menu.setState("open");
menuService.updateMenu(menu);

menuService.deleteMenu(Integer.parseInt(menuId));
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
}


@RequestMapping("reserveIllegal")
public void reserveIllegal(HttpServletRequest request,HttpServletResponse response,Illegal illegal) {
JSONObject result = new JSONObject();
String illegalId = request.getParameter("id");
if (StringUtil.isNotEmpty(illegalId)) { // illegalId不为空 说明是修改
try {
illegal.setId(Integer.parseInt(illegalId));

this.illegal=illegalService.findOneIllegal(Integer.parseInt(illegalId));
String studentno = this.illegal.getStudentno(); //获得学号
score = scoreService.findOneScore(studentno); //获取socre对象
int total = score.getTotal(); //获得原始积分
int oldScore = this.illegal.getScore(); //原始扣除积分
int newScore = illegal.getScore();
int changeScore = newScore-oldScore;
if(changeScore!=0)
{
// 更新分数
score.setTotal(total - changeScore);
scoreService.updateScore(score);
}
illegalService.updateIllegal(illegal);
result.put("returnCode",200);
} catch (Exception e) {
e.printStackTrace();
result.put("returnCode", "对不起,操作失败");
}
}else { // 添加
try {
String studentno = illegal.getStudentno(); //获得学号
score = scoreService.findOneScore(studentno); //获取socre对象
int total = score.getTotal(); //获得原始积分
int thisScore = illegal.getScore(); //本次扣除积分
if(thisScore > total){
result.put("returnCode", "对不起!扣除失败,要扣除的分数大于剩余积分!");
} else {
illegalService.addIllegal(illegal); //加入违章记录
// 更新分数
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
		Field[] fields = o.getClass().getDeclaredFields();
String[] fieldNames = new String[fields.length];
for (int i = 0; i < fieldNames.length; i++) {
fieldNames[i] = fields[i].getName();
}
return fieldNames;
}


/**
* 反射获得对象信息
* @param o
* @return
*/
public static String getFieldsInfo(Object o){
Field[] fields = o.getClass().getDeclaredFields();
//String[] fieldNames = new String[fields.length];
StringBuffer sb = new StringBuffer("属性名和值:");
/**
* 遍历所有字段
* 从下标1开始
* 把0位置的serialVersionUID过滤掉
* 所以要求实体类的第一个属性都是serial*UID
*/
for (int i = 1; i < fields.length; i++) {
sb.append(fields[i].getName()+ "-->"+getFieldValueByName(fields[i].getName(), o)+" ");
/**infoMap = new HashMap();
infoMap.put("type",fields[i].getType().toString());
infoMap.put("name",fields[i].getName());
infoMap.put("value", getFieldValueByName(fields[i].getName(), o));
list.add(infoMap);*/
}
return sb.toString();
}


}

// 统计图
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
	return jsonArray;
}


public JSONArray getOperationJsonArray(int menuId,String operationIds){
JSONArray jsonArray=new JSONArray();
try {
operation = new Operation();
operation.setMenuId(menuId);
List<Operation> list = operationService.findOperation(operation);
for(Operation operation : list){
JSONObject jsonObject = new JSONObject();
int operationId = operation.getOperationId();
jsonObject.put("id", operationId);
jsonObject.put("text", operation.getOperationName());
jsonObject.put("iconCls", "");
jsonObject.put("state", "open");
if (StringUtil.isNotEmpty(operationIds)) {
if (dingzhen.util.StringUtil.existStrArr(operationId+"", operationIds.split(","))) {
jsonObject.put("checked", true);
}
}
jsonArray.add(jsonObject);
}
return jsonArray;
} catch (Exception e) {
e.printStackTrace();
return null;
}
}





@RequestMapping("updateRoleMenu")
public void updateRoleMenu(HttpServletRequest request,HttpServletResponse response){
JSONObject result = new JSONObject();
try {
String roleId = request.getParameter("roleId");
String[] ids = request.getParameter("menuIds").split(",");
String menuIds = "";
String operationIds = "";
/**
* 采用的方案是在菜单递归之后,再加上各菜单下的按钮
* 采用easyui的解析方式所以字段都用的是id和text。
* 为了区别两者,我们规定operationId自增从10000开始
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
		if(request.getParameter("roomid")!=null && request.getParameter("roomid").length() > 0){
seat.setRoomid(Integer.parseInt(request.getParameter("roomid")));
room.setId(Integer.parseInt(request.getParameter("roomid")));
} else {
seat.setRoomid(1);
room.setId(1);
}
String time = request.getParameter("time");
if(time == null || time.length()==0){
seat.setTime("08点-12点");
}else {
seat.setTime(time);
}
List<Seat> list = seatService.findSeat(seat);
for (Seat seat:list){
Student oneStudentByno = studentService.findOneStudentByno(seat.getStudentno());
if (oneStudentByno!=null){
seat.setStudentname(oneStudentByno.getName());
}

}
List<Room> roomlist = roomService.findRoom(room);
room = roomlist.get(0);
JSONObject jsonObject = new JSONObject();
jsonObject.put("seatList", list);
jsonObject.put("row", room.getRow());
jsonObject.put("col", room.getCol());
WriterUtil.write(response, jsonObject.toString());
} catch (Exception e) {
e.printStackTrace();
}
}

// 今天和明天
@RequestMapping("dateCombo")
public void dateCombo(HttpServletRequest request,HttpServletResponse response){
try {
// 获取今明两天时间的String值。格式是yyyy-MM-dd
Date todayDate = new Date();
Date tomorrowDate = getNextDay(todayDate);
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");


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