基于idea-VUE协同过滤算法的图书借阅管理系统开发与制作(javaweb-python-asp.netC#-j2ee)包含借阅个性化推荐统计分析

本文围绕协同过滤算法的图书借阅管理系统展开,介绍了系统可实现图书分类管理、借阅管理等功能,依据借阅记录进行个性化推荐。还阐述了系统搭建环境,使用javaweb、J2EE,配合mysql数据库,采用SSH框架,最后给出了后端和前端代码示例。

目录

0、效果展示

1、协同过滤算法的图书借阅管理系统概述

2、协同过滤算法的图书借阅管理系统搭建环境

3、协同过滤算法的图书借阅管理系统数据表结构

​4、后端代码示例

5、前端代码示例


0、效果展示

1、协同过滤算法的图书借阅管理系统概述

个性化推荐:依据借阅用户的借阅记录,分析用户的喜好,主动向用户推荐可能喜欢的图书

协同过滤是根据用户借阅书籍编号以及对书籍的评分去计算的


很多用户(M)借阅同几本书(N),并且评分比较相近, 如果其他的某个用户借阅了(N)中的某几本书, 
那么M用户借阅的其他书籍就可以推荐给这个用户

本系统实现的功能包含:图书分类管理,图书管理查询,图书收藏,借阅管理,续借管理,逾期管理,预约管理,协同过滤推荐图书查询,还书提醒,借阅统计,预约统计,推荐统计

2、协同过滤算法的图书借阅管理系统搭建环境

本文以实现一个线上协同过滤算法的图书借阅管理系统为目标,从环境搭建到编码实现全过程讲述

我们使用javaweb、J2EE来构建协同过滤算法的图书借阅管理系统,环境使用最新版jdk和tomcat,配合mysql数据库

开发工具使用idea(也可以使用eclipse),数据库管理工具使用Navicat Premium 

开发框架使用SSH(Struts+Spring+Hibernate);

没有使用JavaBean Servlet MVC结构或SSM(Spring+SpringMVC+MyBatis),这两个框架我们在别的项目中再介绍开发过程

3、协同过滤算法的图书借阅管理系统数据表结构

表英文名称表中文名称字段名称数据类型字段说明
t_book idint(11) 
t_book authorvarchar(255) 
t_book filePathvarchar(255) 
t_book namevarchar(255) 
t_book notevarchar(255) 
t_book pricedouble 
t_book publishDatevarchar(255) 
t_book publishervarchar(255) 
t_book sidvarchar(255) 
t_book tagsvarchar(255) 
t_book statusvarchar(255) 
t_book book_type_idint(11) 
t_book_borrow idint(11) 
t_book_borrow daysint(11) 
t_book_borrow endDatevarchar(255) 
t_book_borrow outDealvarchar(255) 
t_book_borrow realDatevarchar(255) 
t_book_borrow startDatevarchar(255) 
t_book_borrow book_idint(11) 
t_book_borrow user_idint(11) 
t_book_borrow scoreint(11) 
t_book_type idint(11) 
t_book_type namevarchar(255) 
t_book_user idint(11) 
t_book_user book_idint(11) 
t_book_user user_idint(11) 
t_sysuser idint(11) 
t_sysuser userIDint(11) 
t_user idint(11) 
t_user userIDint(11) 
t_user_filter_result idint(11) 
t_user_filter_result memberidint(11) 
t_user_filter_result productidsvarchar(255) 
t_user_order idint(11) 
t_user_order daysint(11) 
t_user_order startDatevarchar(255) 
t_user_order statusvarchar(255) 
t_user_order book_idint(11) 
t_user_order user_idint(11) 
t_userinfo userIDint(11) 
t_userinfo unamevarchar(20) 
t_userinfo userAddressvarchar(100) 
t_userinfo userBirthvarchar(10) 
t_userinfo userEmailvarchar(50) 
t_userinfo userGenderint(11) 
t_userinfo userNamevarchar(20) 
t_userinfo userPasswordvarchar(150) 
t_userinfo userPhonevarchar(255) 
t_userinfo checkcodevarchar(255) 

​4、后端代码示例

package biz.web.action;

import biz.entity.UserOrder;
import biz.entity.main.Book;
import biz.entity.main.BookBorrow;
import biz.entity.main.SimpleUser;
import biz.web.service.impl.BizService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import util.*;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.LinkedList;
import java.util.List;
import java.util.Map.Entry;
import java.util.Set;

@Controller
@RequestMapping("/sys")
public class ABookBorrow extends BaseAction {
    @Autowired
    private BizService service;

    @RequestMapping(value = "/add2BookBorrow.do", method = RequestMethod.GET)
    public String add2() {
        return "sys/addBookBorrow";
    }

    @RequestMapping(value = "/borrowWarn.do", method = RequestMethod.GET)
    public String borrowWarn() {
        String lastdate = DateUtil.addDays(DateUtil.getCurrentTime(), 1);
        List<BookBorrow> list = service.queryByHQL("from BookBorrow where realDate is null and endDate<=? and user.id=?", lastdate,
                getSimpleUser().getId());
        putRequestValue("list", list);
        return "sys/borrowWarn";
    }

    @RequestMapping(value = "/queryBookBorrowMonth.do")
    public String queryBookBorrowMonth() {
        String lastdate = DateUtil.addDays(DateUtil.getCurrentTime(), -60);
        List<BookBorrow> list = service.queryByHQL("from BookBorrow where realDate is null and endDate<=?", lastdate);
        putRequestValue("list", list);
        return "sys/queryBookBorrowMonth";
    }

    @RequestMapping(value = "/add2BookBack.do", method = RequestMethod.GET)
    public String add2BookBack() {
        return "sys/addBookBorrowBack";
    }

    @RequestMapping(value = "/add2BookBorrowRE.do", method = RequestMethod.GET)
    public String add2BookBorrowRE() {
        return "sys/addBookBorrowRE";
    }

    @RequestMapping(value = "/getBookBorrow.do", method = RequestMethod.GET)
    public String get(int uid) {
        try {
            BookBorrow bean = (BookBorrow) service.get(BookBorrow.class, uid);
            request.setAttribute("modifybean", bean);

            return "sys/modifyBookBorrow";
        } catch (Exception e) {
            e.printStackTrace();
            MessageUtil.addMessage(request, "获取信息失败.");
            return ERROR;
        }
    }

    @RequestMapping(value = "/deleteBookBorrow.do")
    public String delete(String ids) {
        try {
            service.delete(BookBorrow.class, ids);
            MessageUtil.addRelMessage(request, "删除信息成功.", "mainquery");
            return SUCCESS;
        } catch (Exception e) {
            e.printStackTrace();
            MessageUtil.addMessage(request, "删除信息失败.");
            return ERROR;
        }
    }

    @RequestMapping(value = "/addBookBorrow.do")
    public String add(BookBorrow bean) {
        try {
            SimpleUser user = service.getSimpleUserById(bean.getUser().getUser().getUname());
            if (user == null) {
                MessageUtil.addMessage(request, "用户编号错误.");
                return ERROR;
            }
            Book book = (Book) service.get(Book.class, bean.getBook().getId());
            if (!book.getStatus().equals("在架")) {
                MessageUtil.addMessage(request, "图书已借外借了.");
                return ERROR;
            }
            bean.setBook(book);
            bean.setUser(user);

            SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd");
            Date s = sf.parse(bean.getStartDate());
            String endDate = sf.format(DateUtil.addDays(s, bean.getDays()));
            bean.setEndDate(endDate);
            service.addBookBorrow(bean);
            MessageUtil.addMessage(request, "添加成功.");
            return SUCCESS;
        } catch (Exception e) {
            e.printStackTrace();
            MessageUtil.addMessage(request, "添加失败.");
            return ERROR;
        }

    }

    @RequestMapping(value = "/addBookBorrowByUser.do")
    public String addBookBorrowByUser(UserOrder bean) {
        try {
            SimpleUser user = getSimpleUser();
            List<?> list = service.queryByHQL("from UserOrder where user.id=? and status='失约'", user.getId());
            if (list.size() >= 3) {
                MessageUtil.addMessage(request, "你失约已达3次,不能预约");
                return ERROR;
            }

            Book book = (Book) service.get(Book.class, bean.getBook().getId());
            if (!book.getStatus().equals("在架")) {
                MessageUtil.addMessage(request, "图书已借外借了.");
                return ERROR;
            }

            UserOrder order = new UserOrder();

            order.setBook(book);
            order.setUser(user);
            order.setDays(30);
            order.setStartDate(DateUtil.addDays(DateUtil.getCurrentTime(), 3));

            //			SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd");
            //			Date s = sf.parse(bean.getStartDate());
            //			String endDate = sf.format(DateUtil.addDays(s, bean.getDays()));
            //			bean.setEndDate(endDate);

            service.addUserOrder(order);
            MessageUtil.addRelMessage(request, "预约成功.请在3天内到馆取书", "mainquery");
            return SUCCESS;
        } catch (Exception e) {
            e.printStackTrace();
            MessageUtil.addMessage(request, "预约失败.");
            return ERROR;
        }

    }

    @RequestMapping(value = "/addBookBorrowBack.do")
    public String addBookBorrowBack(BookBorrow bean) {
        try {

            Book book = service.getBookBySid(bean.getBook().getSid());
            if (book == null) {
                MessageUtil.addMessage(request, "图书编号不存在.");
                return ERROR;
            }
            if (book.getStatus().equals("在架")) {
                MessageUtil.addMessage(request, "图书已在架.");
                return ERROR;
            }
            bean.setBook(book);

            service.updateBookBorrowBack(bean);
            MessageUtil.addMessage(request, "还书成功.");
            return SUCCESS;
        } catch (Exception e) {
            e.printStackTrace();
            MessageUtil.addMessage(request, "还书失败.");
            return ERROR;
        }

    }

    @RequestMapping(value = "/addBookBorrowBackByUser.do")
    public String addBookBorrowBackByUser(BookBorrow bean) {
        try {

            Book book = (Book) service.get(Book.class, bean.getBook().getId());
            if (book == null) {
                MessageUtil.addMessage(request, "图书不存在.");
                return ERROR;
            }
            if (book.getStatus().equals("在架")) {
                MessageUtil.addMessage(request, "图书已在架.");
                return ERROR;
            }
            bean.setBook(book);

            service.updateBookBorrowBackUser(bean);
            MessageUtil.addRelMessage(request, "还书成功.", "mainquery");
            return SUCCESS;
        } catch (Exception e) {
            e.printStackTrace();
            MessageUtil.addMessage(request, "还书失败.");
            return ERROR;
        }

    }

    @RequestMapping(value = "/addBookBorrowRE.do")
    public String addBookBorrowRE(BookBorrow bean) {
        try {

            Book book = service.getBookBySid(bean.getBook().getSid());
            if (book == null) {
                MessageUtil.addMessage(request, "图书编号不存在.");
                return ERROR;
            }
            if (book.getStatus().equals("在架")) {
                MessageUtil.addMessage(request, "图书未外借.");
                return ERROR;
            }
            bean.setBook(book);

            service.updateBookBorrowRE(bean);
            MessageUtil.addMessage(request, "续借成功.");
            return SUCCESS;
        } catch (Exception e) {
            e.printStackTrace();
            MessageUtil.addMessage(request, "续借失败.");
            return ERROR;
        }

    }

    @RequestMapping(value = "/updateBookBorrow.do")
    public String update(BookBorrow bean) {
        try {
            service.update(bean);
            MessageUtil.addMessage(request, "更新成功.");
            return SUCCESS;
        } catch (Exception e) {
            e.printStackTrace();
            MessageUtil.addMessage(request, "更新失败.");
            return ERROR;
        }
    }

    @RequestMapping(value = "/updateBookBorrowScore.do")
    public String updateBookBorrowScore(BookBorrow bean) {
        try {
            BookBorrow temp = (BookBorrow) service.get(BookBorrow.class, bean.getId());
            temp.setScore(bean.getScore());
            service.update(temp);
            MessageUtil.addRelMessage(request, "更新成功.", "baseAdd");
            return SUCCESS;
        } catch (Exception e) {
            e.printStackTrace();
            MessageUtil.addMessage(request, "更新失败.");
            return ERROR;
        }
    }

    @RequestMapping(value = "/queryBookBorrow.do")
    public String query() {
        try {
            int pageNum = 0;
            String t = request.getParameter("pageNum");
            if (StringUtil.notEmpty(t)) {
                pageNum = Integer.valueOf(t);
            }
            Page p = (Page) session.getAttribute(Constant.SESSION_PAGE);
            if (pageNum == 0 || p == null) {
                p = new Page();
                p.setCurrentPageNumber(1);
                p.setTotalNumber(0l);
                p.setItemsPerPage(Constant.SESSION_PAGE_NUMBER);

                // 字段名称集合
                LinkedList<String> parmnames = new LinkedList<String>();
                // 字段值集合
                LinkedList<Object> parmvalues = new LinkedList<Object>();
                // 页面参数集合
                Set parm = request.getParameterMap().entrySet();
                for (Object o : parm) {
                    Entry<String, Object> e = (Entry<String, Object>) o;
                    String name = e.getKey();// 页面字段名称
                    if (name.startsWith("s_")) {
                        String fieldValue = request.getParameter(name);// 页面字段值
                        if (StringUtil.notEmpty(fieldValue)) {
                            name = name.substring(2, name.length());// 实体字段名称
                            if ("user.user.uname".equals(name)) {
                                parmnames.add(name);
                                parmvalues.add(fieldValue);

                            } else {
                                parmnames.add(name);
                                parmvalues.add(FieldUtil.format(BookBorrow.class, name, fieldValue));
                            }
                        }
                    }
                }
                Object user = getSessionUser();
                if (user instanceof SimpleUser) {
                    parmnames.add("user.id");
                    SimpleUser su = (SimpleUser) user;
                    parmvalues.add(su.getId());
                }

                SearchParamBean sbean = new SearchParamBean();
                sbean.setParmnames(parmnames);
                sbean.setParmvalues(parmvalues);

                p.setConditonObject(sbean);
            } else {
                p.setCurrentPageNumber(pageNum);
            }
            Page page = null;
            page = service.find(p, BookBorrow.class);

            session.setAttribute(Constant.SESSION_PAGE, page);
            return "sys/listBookBorrow";
        } catch (Exception e) {
            e.printStackTrace();
            return ERROR;
        }
    }

}

5、前端代码示例

<%@ page pageEncoding="UTF-8" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ include file="./head.jsp" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>${appTitle }</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <script type="text/javascript" src="login/js/jquery-1.9.0.min.js"></script>
    <script type="text/javascript" src="login/images/login.js"></script>
    <link href="login/css/login2.css" rel="stylesheet" type="text/css"/>
    <script src="login/bootstrap.min.js" type="text/javascript"></script>
</head>
<body>
<h1>${appTitle }</h1>

<div class="login" style="margin-top:50px;">

    <div class="header">
        <div class="switch" id="switch"><a class="switch_btn_focus" id="switch_qlogin" href="javascript:void(0);"
                                           tabindex="7">登录</a>
            <!-- 			<a class="switch_btn" id="switch_login" href="javascript:void(0);" tabindex="8">快速注册</a><div class="switch_bottom" id="switch_bottom" style="position: absolute; width: 64px; left: 0px;"></div> -->
        </div>
    </div>


    <div class="web_qr_login" id="web_qr_login" style="display: block;">

        <!--登录-->
        <div class="web_login" id="web_login">
            <div class="login-box">
                <div class="login_form">
                    <form action="${pageContext.request.contextPath }/com/login.do" name="loginform" id="loginform"
                          accept-charset="utf-8" id="login_form" class="loginForm" method="post">
                        <div class="uinArea" id="uinArea">
                            <label class="input-tips" for="u">帐号:</label>
                            <div class="inputOuter" id="uArea">
                                <input type="text" name="loginid" id="username"   class="inputstyle"
                                       rel="tooltip" data-original-title="请输入您的登陆账号" data-placement="button" value="admin"/>
                            </div>
                        </div>
                        <div class="pwdArea" id="pwdArea">
                            <label class="input-tips" for="p">密码:</label>
                            <div class="inputOuter" id="pArea">
                                <input type="password" name="password" id="password" value="111111" rel="tooltip"
                                       data-original-title="请输入您的登录密码" class="inputstyle" data-placement="button"/>
                            </div>
                        </div>
                        <div class="uinArea" id="uinArea">
                            <label class="input-tips" for="u">角色:</label>
                            <div class="inputOuter" id="uArea">
                                <select name="logintype" class="selectstyle">
                                    <option value="SysUser">管理员</option>
                                    <option value="SimpleUser">用户</option>
                                </select>
                            </div>
                        </div>
                        <div class="uinArea" id="uinArea">
                            <label class="input-tips" for="u">验证码:</label>
                            <div class="inputOuter" id="uArea">
                                <a href="javascript:void(0);"><img style="border: 0px; float: right" width="110px"
                                                                   height="40px"
                                                                   src="${pageContext.request.contextPath }/checkcode"
                                                                   alt="验证码" align="left"
                                                                   onclick="this.src = '${pageContext.request.contextPath }/checkcode?' + Math.random();"/></a>
                                <input type="text" id="captcha-code" name="checkcode" class="codestyle" rel="tooltip"
                                       data-original-title="请输入验证码" data-placement="button"/>
                            </div>
                        </div>
                        <c:if test="${not empty signErrorMessage }">
                            <div class="alert alert-error"><strong>提示:</strong><br/><i
                                    class="icon-exclamation-sign"></i> ${signErrorMessage }</div>
                        </c:if>
                        <%session.removeAttribute("signErrorMessage"); %>
                        <div style="padding-left:50px;margin-top:20px;"><input type="submit" value="登 录"
                                                                               style="width:150px;"
                                                                               class="button_blue"/>
                            <a href="./reg.jsp" style="margin-left: 5px">用户注册</a><br/>
                        </div>
                    </form>
                </div>
            </div>
        </div>
        <!--登录end-->
    </div>

    <!--注册-->
    <div class="qlogin" id="qlogin" style="display: none; ">

        <div class="web_login">
            <form name="form2" id="regUser" accept-charset="utf-8" action="" method="post">
                <input type="hidden" name="to" value="reg"/>
                <input type="hidden" name="did" value="0"/>
                <ul class="reg_form" id="reg-ul">
                    <div id="userCue" class="cue">快速注册请注意格式</div>
                    <li>

                        <label for="user" class="input-tips2">用户名:</label>
                        <div class="inputOuter2">
                            <input type="text" id="user" name="user" maxlength="16" class="inputstyle2"/>
                        </div>

                    </li>

                    <li>
                        <label for="passwd" class="input-tips2">密码:</label>
                        <div class="inputOuter2">
                            <input type="password" id="passwd" name="passwd" maxlength="16" class="inputstyle2"/>
                        </div>

                    </li>
                    <li>
                        <label for="passwd2" class="input-tips2">确认密码:</label>
                        <div class="inputOuter2">
                            <input type="password" id="passwd2" name="" maxlength="16" class="inputstyle2"/>
                        </div>

                    </li>

                    <li>
                        <label for="qq" class="input-tips2">QQ:</label>
                        <div class="inputOuter2">

                            <input type="text" id="qq" name="qq" maxlength="10" class="inputstyle2"/>
                        </div>

                    </li>

                    <li>
                        <div class="inputArea">
                            <input type="button" id="reg" style="margin-top:10px;margin-left:85px;" class="button_blue"
                                   value="同意协议并注册"/> <a href="#" class="zcxy" target="_blank">注册协议</a>
                        </div>

                    </li>
                    <div class="cl"></div>
                </ul>
            </form>


        </div>


    </div>
    <!--注册end-->
</div>
<script type="text/javascript">
    $("[rel=tooltip]").tooltip();
    $("#captcha-code").keyup(function () {
        if (this.value.match(/[^a-zA-Z0-9 ]/g)) this.value = this.value.replace(/[^a-zA-Z0-9 ]/g, '');
    });
    $("#loginform").submit(function () {
        if ($("#username").val().length < 2 || $("#username").val().length > 14) {
            $("#usernamecontrol").addClass("error");
            $("#username").focus();
            return false;
        } else $("#usernamecontrol").removeClass("error");
        if ($("#password").val().length < 4 || $("#password").val().length > 30) {
            $("#passwordcontrol").addClass("error");
            $("#password").focus();
            return false;
        } else $("#passwordcontrol").removeClass("error");
        if ($("#captcha-code").val().length != 4) {
            $("#captcha-codecontrol").addClass("error");
            $("#captcha-code").tooltip("show");
            $("#captcha-code").focus();
            return false;
        } else $("#captcha-codecontrol").removeClass("error");
        return true;
    });

    function toreg() {
        window.location = "./reg.jsp";
    }
</script>
</body>
</html>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

QQ1978519681计算机程序

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值