基于javaweb的SSM+Maven教材管理系统(java+ssm+jsp+mysql+maven)

运行环境

Java≥8、MySQL≥5.7、Tomcat≥8

开发工具

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

适用

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

功能说明

180023252402

190023252402

200023252402

210023252402

220023252402

基于javaweb的SSM+Maven教材管理系统(java+ssm+jsp+mysql+maven)

一、项目简述

功能包括: 管理员可以增删改查教材、教材商、入库教材、用户(用 户包括学生和教师)可以对教材商、教材进行。xcel的导入 导出操作。教U阿以领取入库的教材,可以退还教材。学 生只能在对应的教师那里领取教材,并且可以退还教材、 查询自己已经领取的教材。并且对已领教材付款等等。

二、项目运行

环境配置: Jdk1.8 + Tomcat8.5 + mysql + Eclispe (IntelliJ IDEA,Eclispe,MyEclispe,Sts 都支持)

项目技术: JSP +Spring + SpringMVC + 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


@Controller
public class BookController {
@Autowired
BookService bookService;

/*
将表格中的数据插入到
*/
@ResponseBody
@RequestMapping("/book/insertData")
public Object supplierImportExcel(@RequestParam("file") MultipartFile file){
int n= 0;
//long s = file.getSize();
Map<String,Object> map = new HashMap<>();
Map<String, Object> result = new HashMap<String, Object>();
List<Book> book = POIUtil.importExcel(file,Book.class);
System.out.println(book);
//List <Supplier> supplier2 = supplierService.findAllSupplier();
//supplier1.addAll(supplier2);
for(int i=0;i<book.size();i++){
map.put("id",book.get(i).getId());
map.put("book_name",book.get(i).getBook_name());
map.put("book_kind",book.get(i).getBook_kind());
map.put("book_price",book.get(i).getBook_price());
map.put("qs_name",book.get(i).getQs_name());
n = bookService.addBook(map);
}
System.out.println("map:"+map);
if(n>0){
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
        workbook.write(response.getOutputStream());
} catch (IOException e) {
throw new RuntimeException(e.getMessage());
}
}

private static void defaultExport(List<Map<String, Object>> list, String fileName, HttpServletResponse response) {
Workbook workbook = ExcelExportUtil.exportExcel(list, ExcelType.HSSF);
if (workbook != null) ;
downLoadExcel(fileName, response, workbook);
}

/**
* 导入
* @param filePath
* @param titleRows
* @param headerRows
* @param pojoClass
* @param <T>
* @return
*/
public static <T> List<T> importExcel(String filePath, Integer titleRows, Integer headerRows, Class<T> pojoClass) {
if (StringUtils.isBlank(filePath)) {
return null;
}
ImportParams params = new ImportParams();
params.setTitleRows(titleRows);
params.setHeadRows(headerRows);
List<T> list = null;
try {
list = ExcelImportUtil.importExcel(new File(filePath), pojoClass, params);
} catch (NoSuchElementException e) {
throw new RuntimeException("模板不能为空");
} catch (Exception e) {
e.printStackTrace();
throw new RuntimeException(e.getMessage());
}
return list;
}

/**
* 导入表格
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
        System.out.println(map);
int book_count = 0;
int book_init = 0;
double persent = 0.0;
List<StoreIn> so = new ArrayList<>();
for (Map.Entry<String, List<StoreIn>> a : map.entrySet()) {
List<StoreIn> sto = a.getValue();
for(int i=0;i<sto.size();i++) {
book_count += sto.get(i).getBook_count();
book_init += sto.get(i).getBook_init();
System.out.println("book_count:"+book_count);
System.out.println("book_init:"+book_init);
Double p = (book_init-book_count) *1.0/ book_init;
BigDecimal bd = new BigDecimal(p);
persent = bd.setScale(2,BigDecimal.ROUND_HALF_UP).doubleValue();
System.out.println(persent);
}
so.add(new StoreIn(a.getKey(),persent));
book_count = 0;
book_init = 0;
}
System.out.println("list表总计:"+so);
String jsonString = JSON.toJSONString(so);
return jsonString;
}
}
package com.dev.books.util;



/**
* @Description: 表格工具类
*/
public class POIUtil {
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
    public String pathAll(@PathVariable(value="pageName") String pageName){
return pageName;
}

@RequestMapping(value = "/uploadImg", method = RequestMethod.POST)
public @ResponseBody Object updatePersonal(@RequestParam("photo") MultipartFile file, HttpServletRequest request)
throws IllegalStateException, IOException {
Map<String, Object> map = new HashMap<String, Object>();
String name = System.currentTimeMillis() + "_" + file.getOriginalFilename();

String imgAbsolutePath = MyTool.SaveImg(file, MyTool.getImg(), name);
map.put("code", 0);
map.put("message", "上传成功");
map.put("data", name);
return map;
}

@RequestMapping("/loginOut")
public String loginOut(HttpSession httpSession) {
httpSession.removeAttribute("user");
return "redirect:/";
}
}
package com.dev.books.controller;



@Controller
public class GradeController {
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
    String id = user.getId();
System.out.println(map);
String password = map.get("password").toString();
System.out.println("password:"+password);
int n = userService.updateUserPwd(password,id);
if(n>0){
return "success";
}
return "failure";
}

@ResponseBody
@RequestMapping(value = "/findUserById" ,produces="application/json;charset=UTF-8")
public String findUserById(HttpServletRequest request){
HttpSession session = request.getSession(true);//新建session对象
User user = (User) session.getAttribute("user"); //将对应数据存入session中
String id = user.getId();
User u = userService.findUserById(id);
List<User> list = new ArrayList<>();
list.add(u);
Layui l = Layui.data(list.size(), list);
return JSON.toJSONString(l);
}

/*
删除学生,教师信息
*/
@ResponseBody
@RequestMapping("/deleteUser")
public String deleteUser(@RequestParam("id")String id){
User user = userService.findUserById(id);
int n = 0;
if(user.getIdentification().equals("学生")){
userService.deleteUser(id);
n = userService.deleteStuUserInfo(id);
if(n>0){
return "success";
}else {
return "failure";
}
}else if(user.getIdentification().equals("教师")){
userService.deleteUser(id);
userService.deleteStuUserInfo(id);
n = userService.deleteTeacherUserInfo(id);
if(n>0){
return "success";
}else {
return "failure";
}
}
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
@ResponseBody
@RequestMapping("/supplier/insertData")
public Object supplierImportExcel(@RequestParam("file") MultipartFile file){
int n= 0;
long s = file.getSize();
Map<String,String> map = new HashMap<>();
Map<String, Object> result = new HashMap<String, Object>();
List<Supplier> supplier1 = POIUtil.importExcel(file,Supplier.class);
System.out.println(supplier1);
//List <Supplier> supplier2 = supplierService.findAllSupplier();
//supplier1.addAll(supplier2);
for(int i=0;i<supplier1.size();i++){
map.put("id",supplier1.get(i).getId());
map.put("qs_name",supplier1.get(i).getQs_name());
map.put("qs_location",supplier1.get(i).getQs_location());
map.put("qs_phone",supplier1.get(i).getQs_phone());
n = supplierService.addSupplier(map);
}
if(n>0){
result.put("code", 0);
result.put("message", "success");
result.put("data", file.getOriginalFilename());
}else{
result.put("code", -1);
result.put("message", "failure");
result.put("data", file.getOriginalFilename());
}
return result;
}

@ResponseBody
@RequestMapping(value = "/supplier/getAllSupplierByPage",produces="application/json;charset=UTF-8")
public String getAllSupplierByPage(@RequestParam("limit") String limit, @RequestParam("page") String page){
int start = (Integer.parseInt(page) - 1)*Integer.parseInt(limit);
int pageSize = Integer.parseInt(limit);
List <Supplier> suppliers = supplierService.findAllSupplierByPages(start,pageSize);
List <Supplier> allData = supplierService.findAllSupplier();
Layui l = Layui.data(allData.size(), suppliers);
return JSON.toJSONString(l);
}

@ResponseBody
@RequestMapping(value = "/supplier/getAllSupplier",produces="application/json;charset=UTF-8")
public String getAllSupplier(){
List <Supplier> allData = supplierService.findAllSupplier();


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