基于ssm vue协同过滤算法的图书推荐系统源码和论文742
idea 数据库mysql5.7+ 数据库链接工具:navcat,小海豚等
环境: jdk8 tomcat8.5
开发技术 ssm
摘 要
“互联网+”的战略实施后,很多行业的信息化水平都有了很大的提升。但是目前很多行业的管理仍是通过人工管理的方式进行,需要在各个岗位投入大量的人力进行很多重复性工作,使得对人力物力造成诸多浪费,工作效率不高等情况;同时为后续的工作带来了隐患。并且现有的图书推荐系统由于用户的体验感较差、系统流程不完善导致系统的使用率较低。此基于协同过滤算法的图书推荐系统的部署与应用,将对首页、个人中心、用户管理、书籍管理、书籍分类管理、热门图书管理、我的收藏管理、系统管理、订单管理等功能进行管理,这可以简化管理工作程序、降低劳动成本、提高业务效率和工作效率。为了有效推动个性化智能图书推荐资源的合理配置和使用,适应现代个性化智能图书推荐机构的管理办法,迫切需要研发一套更加全面的基于协同过滤算法的图书推荐系统。
本课题在充分研究了ssm框架基础上,采用B/S模式,以Java为开发语言,MyEclipse为开发工具,MySQL为数据管理平台,实现的内容主要包括首页、个人中心、用户管理、书籍管理、书籍分类管理、热门图书管理、我的收藏管理、系统管理、订单管理等功能。
关键词:协同过滤算法;图书推荐;Java;互联网+
演示视频:
基于ssm vue协同过滤算法的图书推荐系统源码和论文
Abstract
After the implementation of the "Internet plus" strategy, the informatization level of many industries has been greatly improved. But at present, the management of many industries is still carried out by manual management, which requires a lot of human resources to be invested in various positions for a lot of repetitive work, resulting in a lot of waste of human and material resources and low work efficiency. At the same time for the follow-up work brought hidden trouble. In addition, the existing book recommendation system has a low utilization rate due to poor user experience and imperfect system process. This book recommendation system based on collaborative filtering algorithm, the deployment and application to the home page, personal center, user management, books management, books classification management, hot pictures, my collection management, system management, order management, and other functions of management, it can simplify the management processes, reduce labor cost, improve business efficiency and work efficiency. In order to effectively promote the rational allocation and use of personalized intelligent book recommendation resources and adapt to the management methods of modern personalized intelligent book recommendation institutions, it is urgent to develop a more comprehensive book recommendation system based on collaborative filtering algorithm.
Based on the full study of THE SSM framework, this topic uses B/S mode, Java as the development language, MyEclipse as the development tool, MySQL as the data management platform, The main contents include home page, personal center, user management, book management, book classification management, popular picture management, my collection management, system management, order management and other functions.
Key words: collaborative filtering algorithm; Book recommendation; Java; Internet +
package com.controller;import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Map;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Date;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;import com.utils.ValidatorUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.annotation.IgnoreAuth;
import com.entity.OrdersEntity;
import com.service.OrdersService;import com.entity.ShujiEntity;
import com.entity.view.ShujiView;import com.service.ShujiService;
import com.service.TokenService;
import com.utils.PageUtils;
import com.utils.R;
import com.utils.MD5Util;
import com.utils.MPUtil;
import com.utils.CommonUtil;
import com.service.StoreupService;
import com.entity.StoreupEntity;/*** 书籍* 后端接口* @author * @email * @date 2022-04-25 22:30:44*/
@RestController
@RequestMapping("/shuji")
public class ShujiController {@Autowiredprivate ShujiService shujiService;@Autowiredprivate StoreupService storeupService;@Autowiredprivate OrdersService ordersService;/*** 后端列表*/@RequestMapping("/page")public R page(@RequestParam Map<String, Object> params,ShujiEntity shuji, HttpServletRequest request){EntityWrapper<ShujiEntity> ew = new EntityWrapper<ShujiEntity>();PageUtils page = shujiService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, shuji), params), params));return R.ok().put("data", page);}/*** 前端列表*/@IgnoreAuth@RequestMapping("/list")public R list(@RequestParam Map<String, Object> params,ShujiEntity shuji, HttpServletRequest request){EntityWrapper<ShujiEntity> ew = new EntityWrapper<ShujiEntity>();PageUtils page = shujiService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, shuji), params), params));return R.ok().put("data", page);}/*** 列表*/@RequestMapping("/lists")public R list( ShujiEntity shuji){EntityWrapper<ShujiEntity> ew = new EntityWrapper<ShujiEntity>();ew.allEq(MPUtil.allEQMapPre( shuji, "shuji")); return R.ok().put("data", shujiService.selectListView(ew));}/*** 查询*/@RequestMapping("/query")public R query(ShujiEntity shuji){EntityWrapper< ShujiEntity> ew = new EntityWrapper< ShujiEntity>();ew.allEq(MPUtil.allEQMapPre( shuji, "shuji")); ShujiView shujiView = shujiService.selectView(ew);return R.ok("查询书籍成功").put("data", shujiView);}/*** 后端详情*/@RequestMapping("/info/{id}")public R info(@PathVariable("id") Long id){ShujiEntity shuji = shujiService.selectById(id);shuji.setClicknum(shuji.getClicknum()+1);shuji.setClicktime(new Date());shujiService.updateById(shuji);return R.ok().put("data", shuji);}/*** 前端详情*/@IgnoreAuth@RequestMapping("/detail/{id}")public R detail(@PathVariable("id") Long id){ShujiEntity shuji = shujiService.selectById(id);shuji.setClicknum(shuji.getClicknum()+1);shuji.setClicktime(new Date());shujiService.updateById(shuji);return R.ok().put("data", shuji);}/*** 赞或踩*/@RequestMapping("/thumbsup/{id}")public R thumbsup(@PathVariable("id") String id,String type){ShujiEntity shuji = shujiService.selectById(id);if(type.equals("1")) {shuji.setThumbsupnum(shuji.getThumbsupnum()+1);} else {shuji.setCrazilynum(shuji.getCrazilynum()+1);}shujiService.updateById(shuji);return R.ok();}/*** 后端保存*/@RequestMapping("/save")public R save(@RequestBody ShujiEntity shuji, HttpServletRequest request){shuji.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue());//ValidatorUtils.validateEntity(shuji);shujiService.insert(shuji);return R.ok();}/*** 前端保存*/@IgnoreAuth@RequestMapping("/add")public R add(@RequestBody ShujiEntity shuji, HttpServletRequest request){shuji.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue());//ValidatorUtils.validateEntity(shuji);shujiService.insert(shuji);return R.ok();}/*** 修改*/@RequestMapping("/update")@Transactionalpublic R update(@RequestBody ShujiEntity shuji, HttpServletRequest request){//ValidatorUtils.validateEntity(shuji);shujiService.updateById(shuji);//全部更新return R.ok();}/*** 删除*/@RequestMapping("/delete")public R delete(@RequestBody Long[] ids){shujiService.deleteBatchIds(Arrays.asList(ids));return R.ok();}/*** 提醒接口*/@RequestMapping("/remind/{columnName}/{type}")public R remindCount(@PathVariable("columnName") String columnName, HttpServletRequest request, @PathVariable("type") String type,@RequestParam Map<String, Object> map) {map.put("column", columnName);map.put("type", type);if(type.equals("2")) {SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");Calendar c = Calendar.getInstance();Date remindStartDate = null;Date remindEndDate = null;if(map.get("remindstart")!=null) {Integer remindStart = Integer.parseInt(map.get("remindstart").toString());c.setTime(new Date()); c.add(Calendar.DAY_OF_MONTH,remindStart);remindStartDate = c.getTime();map.put("remindstart", sdf.format(remindStartDate));}if(map.get("remindend")!=null) {Integer remindEnd = Integer.parseInt(map.get("remindend").toString());c.setTime(new Date());c.add(Calendar.DAY_OF_MONTH,remindEnd);remindEndDate = c.getTime();map.put("remindend", sdf.format(remindEndDate));}}Wrapper<ShujiEntity> wrapper = new EntityWrapper<ShujiEntity>();if(map.get("remindstart")!=null) {wrapper.ge(columnName, map.get("remindstart"));}if(map.get("remindend")!=null) {wrapper.le(columnName, map.get("remindend"));}int count = shujiService.selectCount(wrapper);return R.ok().put("count", count);}/*** 前端智能排序*/@IgnoreAuth@RequestMapping("/autoSort")public R autoSort(@RequestParam Map<String, Object> params,ShujiEntity shuji, HttpServletRequest request,String pre){EntityWrapper<ShujiEntity> ew = new EntityWrapper<ShujiEntity>();Map<String, Object> newMap = new HashMap<String, Object>();Map<String, Object> param = new HashMap<String, Object>();Iterator<Map.Entry<String, Object>> it = param.entrySet().iterator();while (it.hasNext()) {Map.Entry<String, Object> entry = it.next();String key = entry.getKey();String newKey = entry.getKey();if (pre.endsWith(".")) {newMap.put(pre + newKey, entry.getValue());} else if (StringUtils.isEmpty(pre)) {newMap.put(newKey, entry.getValue());} else {newMap.put(pre + "." + newKey, entry.getValue());}}params.put("sort", "clicknum");params.put("order", "desc");PageUtils page = shujiService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, shuji), params), params));return R.ok().put("data", page);}/*** 协同算法(按用户购买推荐)*/@RequestMapping("/autoSort2")public R autoSort2(@RequestParam Map<String, Object> params,ShujiEntity shuji, HttpServletRequest request){String userId = request.getSession().getAttribute("userId").toString();String goodtypeColumn = "zuozhe";List<OrdersEntity> orders = ordersService.selectList(new EntityWrapper<OrdersEntity>().eq("userid", userId).eq("tablename", "shuji").orderBy("addtime", false));List<String> goodtypes = new ArrayList<String>();Integer limit = params.get("limit")==null?10:Integer.parseInt(params.get("limit").toString());List<ShujiEntity> shujiList = new ArrayList<ShujiEntity>();//去重List<OrdersEntity> ordersDist = new ArrayList<OrdersEntity>();for(OrdersEntity o1 : orders) {boolean addFlag = true;for(OrdersEntity o2 : ordersDist) {if(o1.getGoodid()==o2.getGoodid() || o1.getGoodtype().equals(o2.getGoodtype())) {addFlag = false;break;}}if(addFlag) ordersDist.add(o1);}if(ordersDist!=null && ordersDist.size()>0) {for(OrdersEntity o : ordersDist) {shujiList.addAll(shujiService.selectList(new EntityWrapper<ShujiEntity>().eq(goodtypeColumn, o.getGoodtype())));}}EntityWrapper<ShujiEntity> ew = new EntityWrapper<ShujiEntity>();params.put("sort", "id");params.put("order", "desc");PageUtils page = shujiService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, shuji), params), params));List<ShujiEntity> pageList = (List<ShujiEntity>)page.getList();if(shujiList.size()<limit) {int toAddNum = (limit-shujiList.size())<=pageList.size()?(limit-shujiList.size()):pageList.size();for(ShujiEntity o1 : pageList) {boolean addFlag = true;for(ShujiEntity o2 : shujiList) {if(o1.getId().intValue()==o2.getId().intValue()) {addFlag = false;break;}}if(addFlag) {shujiList.add(o1);if(--toAddNum==0) break;}}} else if(shujiList.size()>limit) {shujiList = shujiList.subList(0, limit);}page.setList(shujiList);return R.ok().put("data", page);}}
package com.controller;import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Map;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Date;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;import com.utils.ValidatorUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.annotation.IgnoreAuth;import com.entity.OrdersEntity;
import com.entity.view.OrdersView;import com.service.OrdersService;
import com.service.TokenService;
import com.utils.PageUtils;
import com.utils.R;
import com.utils.MD5Util;
import com.utils.MPUtil;
import com.utils.CommonUtil;/*** 订单* 后端接口* @author * @email * @date 2022-04-25 22:30:44*/
@RestController
@RequestMapping("/orders")
public class OrdersController {@Autowiredprivate OrdersService ordersService;/*** 后端列表*/@RequestMapping("/page")public R page(@RequestParam Map<String, Object> params,OrdersEntity orders, HttpServletRequest request){if(!request.getSession().getAttribute("role").toString().equals("管理员")) {orders.setUserid((Long)request.getSession().getAttribute("userId"));}EntityWrapper<OrdersEntity> ew = new EntityWrapper<OrdersEntity>();PageUtils page = ordersService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, orders), params), params));return R.ok().put("data", page);}/*** 前端列表*/@IgnoreAuth@RequestMapping("/list")public R list(@RequestParam Map<String, Object> params,OrdersEntity orders, HttpServletRequest request){EntityWrapper<OrdersEntity> ew = new EntityWrapper<OrdersEntity>();PageUtils page = ordersService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, orders), params), params));return R.ok().put("data", page);}/*** 列表*/@RequestMapping("/lists")public R list( OrdersEntity orders){EntityWrapper<OrdersEntity> ew = new EntityWrapper<OrdersEntity>();ew.allEq(MPUtil.allEQMapPre( orders, "orders")); return R.ok().put("data", ordersService.selectListView(ew));}/*** 查询*/@RequestMapping("/query")public R query(OrdersEntity orders){EntityWrapper< OrdersEntity> ew = new EntityWrapper< OrdersEntity>();ew.allEq(MPUtil.allEQMapPre( orders, "orders")); OrdersView ordersView = ordersService.selectView(ew);return R.ok("查询订单成功").put("data", ordersView);}/*** 后端详情*/@RequestMapping("/info/{id}")public R info(@PathVariable("id") Long id){OrdersEntity orders = ordersService.selectById(id);return R.ok().put("data", orders);}/*** 前端详情*/@IgnoreAuth@RequestMapping("/detail/{id}")public R detail(@PathVariable("id") Long id){OrdersEntity orders = ordersService.selectById(id);return R.ok().put("data", orders);}/*** 后端保存*/@RequestMapping("/save")public R save(@RequestBody OrdersEntity orders, HttpServletRequest request){orders.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue());//ValidatorUtils.validateEntity(orders);orders.setUserid((Long)request.getSession().getAttribute("userId"));ordersService.insert(orders);return R.ok();}/*** 前端保存*/@RequestMapping("/add")public R add(@RequestBody OrdersEntity orders, HttpServletRequest request){orders.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue());//ValidatorUtils.validateEntity(orders);ordersService.insert(orders);return R.ok();}/*** 修改*/@RequestMapping("/update")@Transactionalpublic R update(@RequestBody OrdersEntity orders, HttpServletRequest request){//ValidatorUtils.validateEntity(orders);ordersService.updateById(orders);//全部更新return R.ok();}/*** 删除*/@RequestMapping("/delete")public R delete(@RequestBody Long[] ids){ordersService.deleteBatchIds(Arrays.asList(ids));return R.ok();}/*** 提醒接口*/@RequestMapping("/remind/{columnName}/{type}")public R remindCount(@PathVariable("columnName") String columnName, HttpServletRequest request, @PathVariable("type") String type,@RequestParam Map<String, Object> map) {map.put("column", columnName);map.put("type", type);if(type.equals("2")) {SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");Calendar c = Calendar.getInstance();Date remindStartDate = null;Date remindEndDate = null;if(map.get("remindstart")!=null) {Integer remindStart = Integer.parseInt(map.get("remindstart").toString());c.setTime(new Date()); c.add(Calendar.DAY_OF_MONTH,remindStart);remindStartDate = c.getTime();map.put("remindstart", sdf.format(remindStartDate));}if(map.get("remindend")!=null) {Integer remindEnd = Integer.parseInt(map.get("remindend").toString());c.setTime(new Date());c.add(Calendar.DAY_OF_MONTH,remindEnd);remindEndDate = c.getTime();map.put("remindend", sdf.format(remindEndDate));}}Wrapper<OrdersEntity> wrapper = new EntityWrapper<OrdersEntity>();if(map.get("remindstart")!=null) {wrapper.ge(columnName, map.get("remindstart"));}if(map.get("remindend")!=null) {wrapper.le(columnName, map.get("remindend"));}if(!request.getSession().getAttribute("role").toString().equals("管理员")) {wrapper.eq("userid", (Long)request.getSession().getAttribute("userId"));}int count = ordersService.selectCount(wrapper);return R.ok().put("count", count);}/*** (按值统计)*/@RequestMapping("/value/{xColumnName}/{yColumnName}")public R value(@PathVariable("yColumnName") String yColumnName, @PathVariable("xColumnName") String xColumnName,HttpServletRequest request) {Map<String, Object> params = new HashMap<String, Object>();params.put("xColumn", xColumnName);params.put("yColumn", yColumnName);EntityWrapper<OrdersEntity> ew = new EntityWrapper<OrdersEntity>();ew.in("status", new String[]{"已支付","已发货","已完成"});List<Map<String, Object>> result = ordersService.selectValue(params, ew);SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");for(Map<String, Object> m : result) {for(String k : m.keySet()) {if(m.get(k) instanceof Date) {m.put(k, sdf.format((Date)m.get(k)));}}}return R.ok().put("data", result);}/*** (按值统计)时间统计类型*/@RequestMapping("/value/{xColumnName}/{yColumnName}/{timeStatType}")public R valueDay(@PathVariable("yColumnName") String yColumnName, @PathVariable("xColumnName") String xColumnName, @PathVariable("timeStatType") String timeStatType,HttpServletRequest request) {Map<String, Object> params = new HashMap<String, Object>();params.put("xColumn", xColumnName);params.put("yColumn", yColumnName);params.put("timeStatType", timeStatType);EntityWrapper<OrdersEntity> ew = new EntityWrapper<OrdersEntity>();ew.in("status", new String[]{"已支付","已发货","已完成"});List<Map<String, Object>> result = ordersService.selectTimeStatValue(params, ew);SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");for(Map<String, Object> m : result) {for(String k : m.keySet()) {if(m.get(k) instanceof Date) {m.put(k, sdf.format((Date)m.get(k)));}}}return R.ok().put("data", result);}/*** 分组统计*/@RequestMapping("/group/{columnName}")public R group(@PathVariable("columnName") String columnName,HttpServletRequest request) {Map<String, Object> params = new HashMap<String, Object>();params.put("column", columnName);EntityWrapper<OrdersEntity> ew = new EntityWrapper<OrdersEntity>();ew.in("status", new String[]{"已支付","已发货","已完成"});List<Map<String, Object>> result = ordersService.selectGroup(params, ew);SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");for(Map<String, Object> m : result) {for(String k : m.keySet()) {if(m.get(k) instanceof Date) {m.put(k, sdf.format((Date)m.get(k)));}}}return R.ok().put("data", result);}
}