Java项目:教材征订与发放管理系统(java+SSM+JSP+jQuery+mysql)

源码获取:博客首页 "资源" 里下载!

 
项目介绍

教材征订与发放管理系统。本系统共分三种角色,分别为管理员、老师、班长;现在分别来介绍各个角色的功能: 

```管理员```

查看所有图书 
修改图书库存 
审批图书订单(通过图书订单,不通过订单) 
删除图书订单 
查看等待发放的图书 
查看已经发放的图书 
增加库存图书 
删除库存图书 
修改图书数量 
教师与班级管理 
查看教师列表 
查看班长列表 
修改教师信息 
修改班长信息 
修改班长密码 
修改教师密码 
删除教师 
删除班长 
发放图书 
修改教师信息 
修改学生信息 
查看已经发放订单 

```老师```

查看自己订单 
查看图书信息 
增加订单 
查看发放订单 
修改个人信息 
修改学生 
查看班长列表 
修改班长信息 

```班长```

修改个人信息 

查看自己班已经审批订单


环境需要

1.运行环境:最好是java jdk 1.8,我们在这个平台上运行的。其他版本理论上也可以。
2.IDE环境:IDEA,Eclipse,Myeclipse都可以。推荐IDEA;
3.tomcat环境:Tomcat 7.x,8.x,9.x版本均可
4.硬件环境:windows 7/8/10 1G内存以上;或者 Mac OS;
5.是否Maven项目: 否;查看源码目录中是否包含pom.xml;若包含,则为maven项目,否则为非maven项目 
6.数据库:MySql 5.7版本;


技术栈

1. 后端:Spring SpringMVC MyBatis
2. 前端:JSP+jQuery

使用说明

1. 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件;
2. 将项目中jdbc.properties配置文件中的数据库配置改为自己的配置
3. 使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven;
   若为maven项目,导入成功后请执行maven clean;maven install命令,配置tomcat,然后运行;
4. 运行项目,输入localhost:8080/xxx 登录

 

 

 

 

 

书籍管理控制层:

@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){
            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 = "/book/getAllBookByPage",produces="application/json;charset=UTF-8")
    public String getAllBookByPage(@RequestParam("limit") String limit, @RequestParam("page") String page){
        int start = (Integer.parseInt(page) - 1)*Integer.parseInt(limit);
        int pageSize = Integer.parseInt(limit);
        List <Supplier> books = bookService.findAllBookByPages(start,pageSize);
        List <Supplier> allData = bookService.findAllBook();
        Layui l = Layui.data(allData.size(), books);
        return JSON.toJSONString(l);
    }

    @ResponseBody
    @RequestMapping(value = "/book/getAllBook",produces="application/json;charset=UTF-8")
    public String getAllBook(){
        List <Supplier> allData = bookService.findAllBook();
        Layui l = Layui.data(allData.size(), allData);
        return JSON.toJSONString(l);
    }


    @ResponseBody
    @RequestMapping(value = "/book/findAllBookKind",produces="application/json;charset=UTF-8")
    public String findAllBookKind(){
        List <String> allKinds = bookService.findAllBookKind();
        return JSON.toJSONString(allKinds);
    }

    @RequestMapping("/book/exportData")
    public String exportData(HttpServletResponse response){
        List <Supplier> books = bookService.findAllBook();
        POIUtil.exportExcel(books,Book.class,"书籍基本信息","",response);
        return  NormalExcelConstants.EASYPOI_EXCEL_VIEW;//需要配置新的视图解析器并设置优先级和扫描
    }

    @ResponseBody
    @RequestMapping(value = "/updateBookById")
    public String updateBookById(@RequestBody Map map){
        int n = bookService.updateBookById(map);
        if(n>0){
            return "success";
        }
        return "failure";
    }

    @ResponseBody
    @RequestMapping(value = "/deleteBookById")
    public String deleteBookById(@RequestParam("book_id")String book_id){
        int n = bookService.deleteBookById(book_id);
        if(n>0){
            return "success";
        }
        return "failure";
    }

    @ResponseBody
    @RequestMapping(value = "/findAllBookByBookName",produces="application/json;charset=UTF-8")
    public String findAllBookByBookName(@RequestParam("key[book_name]")String book_name){
        List<Supplier> books = bookService.findAllBookByBookName(book_name);
        Layui l = Layui.data(books.size(), books);
        return JSON.toJSONString(l);
    }

    @ResponseBody
    @RequestMapping(value = "/findBookNameByQsName",produces="application/json;charset=UTF-8")
    public String findBookNameByQsName(@RequestParam("qs_name")String qs_name){
        List<String> book_names = bookService.findBookNameByQsName(qs_name);
        return JSON.toJSONString(book_names);
    }
}

用户管理控制层:

@Controller
public class UserController {
    @Autowired
    UserService userService;
    private final Logger log =  LoggerFactory.getLogger(UserController.class);



    @ResponseBody
    @RequestMapping(value = "/userLogin")
    @ApiOperation(value = "根据用户名获取用户对象", httpMethod = "GET", response = User.class, notes = "根据用户名获取用户对象")
    public String userLogin(String account, String password, HttpServletRequest request ){
        HttpSession session = request.getSession(true);//新建session对象
        User user = userService.findOneUser(account,password);
        session.setAttribute("user",user);
        if(user!=null){
            return "success";
        }
        return "fail";
    }

    @ResponseBody
    @RequestMapping(value = "/getAllUser",produces="application/json;charset=UTF-8")
    public String getAllUser(@RequestParam("limit") String limit, @RequestParam("page") String page

    ){
        //System.out.println("bjshbd");
        //int error = 1/0;
        int start = (Integer.parseInt(page) - 1)*Integer.parseInt(limit);
        int pageSize = Integer.parseInt(limit);
        List<User>list = userService.findAllUsersByPage(start,pageSize);
        List<User>allData = userService.findAllUsers();
        System.out.println(list);
        Layui l = Layui.data(allData.size(), list);
        String result = JSON.toJSONString(l);
        System.out.println(result);
        return result;
    }

    @ResponseBody
    @RequestMapping(value = "/getUserInfo",produces="application/json;charset=UTF-8",method =RequestMethod.POST )
    public String getUserInfo(@RequestParam("limit") String limit, @RequestParam("page") String page,
                              @RequestParam("key[college_data]") String college_data,
                              @RequestParam("key[profession_data]") String profession_data,
                              @RequestParam("key[grade_data]") String grade_data,
                              @RequestParam("key[cclass_data]") String cclass_data
    ){
        System.out.println("profession_data:"+profession_data);
        List<User>list = userService.findUserByCondictions(college_data,profession_data,grade_data,cclass_data);
        Layui l = Layui.data(list.size(), list);
        return JSON.toJSONString(l);
    }

    @ResponseBody
    @RequestMapping(value = "/updateUserInfo" )
    public String updateUserInfo(@RequestBody Map map,HttpServletRequest request){
        HttpSession session = request.getSession(true);//新建session对象
        User user = (User) session.getAttribute("user");  //将对应数据存入session中
        String id = user.getId();
        map.put("id",id);
        int n = userService.updateUserInfo(map);
        if(n>0){
            return "success";
        }
        return "failure";
    }

    @ResponseBody
    @RequestMapping(value = "/updateUserPwd" )
    public String updateUserPwd(@RequestBody Map map,HttpServletRequest request){
        HttpSession session = request.getSession(true);//新建session对象
        User user = (User) session.getAttribute("user");  //将对应数据存入session中
        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";
            }
        }
        return "failure";
    }

    /*
    增加学生信息
     */
    @ResponseBody
    @RequestMapping("/insertUser")
    public String insertUser(){
        return "";
    }

    @ResponseBody
    @RequestMapping(value = "/findAllTeacher",produces="application/json;charset=UTF-8")
    public String findAllTeacher(){
        List<User> users = userService.findAllTeacher();
        Layui l = Layui.data(users.size(), users);
        return JSON.toJSONString(l);
    }


    @ResponseBody
    @RequestMapping(value = "/insertStuUser",produces="application/json;charset=UTF-8")
    public String insertStuUser(@RequestBody Map map){
        Map userMap = new HashMap();
        Map userInfoMap = new HashMap();
        String id = RandNum.getGUID();
        userMap.put("id",id);
        userMap.put("identification","学生");
        userMap.put("name",map.get("name"));
        userMap.put("password",map.get("password"));
        userMap.put("phone",map.get("phone"));
        userMap.put("email",map.get("email"));
        userInfoMap.put("user_id",id);
        userInfoMap.put("col_id",map.get("col_id"));
        userInfoMap.put("prof_id",map.get("prof_id"));
        userInfoMap.put("gra_id",map.get("gra_id"));
        userInfoMap.put("ccl_id",map.get("ccl_id"));
        userInfoMap.put("t_id",map.get("t_id"));
        userService.insertUser(userMap);
        int n = userService.insertStuUserInfo(userInfoMap);
        if(n>0){
            return "success";
        }else {
            return "failure";
        }
    }

    @ResponseBody
    @RequestMapping(value = "/insertTeaUser",produces="application/json;charset=UTF-8")
    public String insertTeaUser(@RequestBody Map map){
        Map userMap = new HashMap();
        Map teacherInfoMap = new HashMap();
        String id = RandNum.getGUID();
        userMap.put("id",id);
        userMap.put("identification","教师");
        userMap.put("name",map.get("name"));
        userMap.put("password",map.get("password"));
        userMap.put("phone",map.get("phone"));
        userMap.put("email",map.get("email"));
        teacherInfoMap.put("user_id",id);
        teacherInfoMap.put("col_id",map.get("col_id"));
        teacherInfoMap.put("prof_id",map.get("prof_id"));
        teacherInfoMap.put("gra_id",map.get("gra_id"));
        teacherInfoMap.put("ccl_id",map.get("ccl_id"));
        userService.insertUser(userMap);
        int n = userService.insertStuUserInfo(teacherInfoMap);
        if(n>0){
            return "success";
        }else {
            return "failure";
        }
    }

}

库存管理控制层:

@Controller
public class StoreInController {

    @Autowired
    StoreInService storeInService;

    @ResponseBody
    @RequestMapping(value = "/getAllStoreInByPage",produces="application/json;charset=UTF-8")
    public String getAllStoreInByPage(@RequestParam("limit") String limit, @RequestParam("page") String page){
        int start = (Integer.parseInt(page) - 1)*Integer.parseInt(limit);
        int pageSize = Integer.parseInt(limit);
        List<StoreIn> storeIns = storeInService.findAllStoreInByPage(start,pageSize);
        List<StoreIn> allData = storeInService.findAllStoreIn();
        Layui l = Layui.data(allData.size(), storeIns);
        String result = JSON.toJSONString(l);
        System.out.println("result:"+result);
        return  result;
    }

    @ResponseBody
    @RequestMapping(value = "/getAllStoreInBookName",produces="application/json;charset=UTF-8")
    public String getAllStoreInBookName(){
        List<StoreIn> allData = storeInService.findAllStoreIn();
        List<String> list = new ArrayList<>();
        for (int i=0;i<allData.size();i++){
            list.add(allData.get(i).getBook_name());
        }
        Layui l = Layui.data(allData.size(), list);
        String result = JSON.toJSONString(l);
        System.out.println("result:"+result);
        return  result;
    }

    @ResponseBody
    @RequestMapping(value = "/insertStoreIn")
    public String insertStoreIn(/*@RequestParam("store_info")String store_info
            ,@RequestParam("book_count")String book_count
            ,@RequestParam("book_name")String book_name*/
            @RequestBody Map dataMap
    ){
        System.out.println(dataMap);
        String store_info =dataMap.get("store_info").toString();
        String book_count = dataMap.get("book_count").toString();
        String book_name =dataMap.get("book_name").toString();
        String qs_name = dataMap.get("qs_name").toString();
        String id = RandNum.getGUID();
        Date date = new Date();
        StoreIn storeIn = new StoreIn(id,date,store_info,Integer.parseInt(book_count),book_name,qs_name,Integer.parseInt(book_count));
        /*
        使用fastjson把类转换成json,有两个好处,
        1.需要map类型传参数
        2.fastjson能够格式化时间类型
         */
        String storeInJson = JSON.toJSONString(storeIn);
        Map map = JSON.parseObject(storeInJson, Map.class);
        System.out.println(map);
        int n = storeInService.insertStoreIn(map);
        if(n>0){
            return "success";
        }
        return  "failure";
    }

    @ResponseBody
    @RequestMapping(value = "/getStoreInById")
    public String getStoreInById(@RequestParam("id")String id){
        StoreIn storeIn = storeInService.findStoreInById(id);
        String book_id = storeIn.getBook_id();
        return book_id;
    }

    @ResponseBody
    @RequestMapping(value = "/deleteStoreIn")
    public String deleteStoreIn(@RequestParam("id")String id){
        int n = storeInService.deleteStoreIn(id);
        if(n>0){
            return "success";
        }
        return "failure";
    }

    @ResponseBody
    @RequestMapping(value = "/findStoreInPercent",produces="application/json;charset=UTF-8")
    public String findStoreInPercent(@RequestParam("book_type")String book_type){
        List<StoreIn> storeIns = storeInService.findStoreInPercent(book_type);
        Map<String, List<StoreIn>> map = new HashMap<String, List<StoreIn>>();
        for (StoreIn storeIn : storeIns) {
            if (map.get(storeIn.getBook_name()) == null) {
                List<StoreIn> data = new ArrayList<StoreIn>();
                data.add(storeIn);
                map.put(storeIn.getBook_name(), data);
            } else {
                //定位到和之前键相同的list,然后扩充list
                List<StoreIn> data = map.get(storeIn.getBook_name());
                data.add(storeIn);
            }
        }
        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;
    }
}

源码获取:博客首页 "资源" 里下载! 

猜你喜欢

转载自blog.csdn.net/m0_66863468/article/details/124702061