(java毕业设计源码)基于jsp+mysql+ssh图书管理系统

基于jsp+mysql+ssh图书管理系统

项目获取请看文章最底下官网

本系统适用于java毕业设计和java课程设计,基于java语言实现,主要功能有系统管理员:管理系统用户、角色与权限、拥有系统全部权限,保证系统正常运行。图书馆管理员:拥有操作图书入库和下架,图书借阅与归还,扣款查看功能。图书借阅者:查看图书。


一.技术环境

JDK版本:1.8
IDE工具:eclipse
数据库: mysql
编程语言: Java
tomcat: 8.0
详细技术:HTML+CSS+JS+JSP+JAVA+SERVLET+SSH+MYSQL


二.项目文件

在这里插入图片描述


三.系统功能

在这里插入图片描述


四.代码示例

package com.bjpowernode.web.buss.controller;

import com.bjpowernode.core.common.controller.BaseController;
import com.bjpowernode.core.common.exception.BusinessException;
import com.bjpowernode.core.common.hibernate.qbc.CriteriaQuery;
import com.bjpowernode.core.common.model.json.AjaxJson;
import com.bjpowernode.core.common.model.json.DataGrid;
import com.bjpowernode.core.common.model.json.Highchart;
import com.bjpowernode.core.constant.Globals;
import com.bjpowernode.core.extend.hqlsearch.HqlGenerateUtil;
import com.bjpowernode.core.util.ExceptionUtil;
import com.bjpowernode.core.util.MyBeanUtils;
import com.bjpowernode.core.util.StringUtil;
import com.bjpowernode.poi.excel.ExcelImportUtil;
import com.bjpowernode.poi.excel.entity.ImportParams;
import com.bjpowernode.tag.core.easyui.TagUtil;
import com.bjpowernode.web.buss.entity.base.TBBookEntity;
import com.bjpowernode.web.buss.entity.base.TBPressEntity;
import com.bjpowernode.web.buss.service.TBBookServiceI;
import com.bjpowernode.web.system.pojo.base.TSType;
import com.bjpowernode.web.system.service.SystemService;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.StringReader;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.batik.transcoder.Transcoder;
import org.apache.batik.transcoder.TranscoderException;
import org.apache.batik.transcoder.TranscoderInput;
import org.apache.batik.transcoder.TranscoderOutput;
import org.apache.batik.transcoder.image.JPEGTranscoder;
import org.apache.batik.transcoder.image.PNGTranscoder;
import org.apache.fop.svg.PDFTranscoder;
import org.apache.log4j.Logger;
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 org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;
import org.springframework.web.servlet.ModelAndView;

@Controller
@RequestMapping({"/tBBookController"})
public class TBBookController extends BaseController {

   private static final Logger logger = Logger.getLogger(TBBookController.class);
   @Autowired
   private TBBookServiceI tBBookService;
   @Autowired
   private SystemService systemService;


   @RequestMapping(
      params = {"tBBook"}
   )
   public ModelAndView tBBook(HttpServletRequest request) {
      return new ModelAndView("buss/book/tBBookList");
   }

   @RequestMapping(
      params = {"press"}
   )
   public ModelAndView press(HttpServletRequest request) {
      return new ModelAndView("buss/book/press");
   }

   @RequestMapping(
      params = {"datagridPress"}
   )
   public void datagridPress(TBPressEntity tbPress, HttpServletRequest request, HttpServletResponse response, DataGrid dataGrid) {
      CriteriaQuery cq = new CriteriaQuery(TBPressEntity.class, dataGrid);
      HqlGenerateUtil.installHql(cq, tbPress, request.getParameterMap());
      this.systemService.getDataGridReturn(cq, true);
      TagUtil.datagrid(response, dataGrid);
   }

   @RequestMapping(
      params = {"datagrid"}
   )
   public void datagrid(TBBookEntity tBBook, HttpServletRequest request, HttpServletResponse response, DataGrid dataGrid) {
      CriteriaQuery cq = new CriteriaQuery(TBBookEntity.class, dataGrid);
      HqlGenerateUtil.installHql(cq, tBBook, request.getParameterMap());
      cq.add();
      this.tBBookService.getDataGridReturn(cq, true);
      TagUtil.datagrid(response, dataGrid);
   }

   @RequestMapping(
      params = {"doDel"}
   )
   @ResponseBody
   public AjaxJson doDel(TBBookEntity tBBook, HttpServletRequest request) {
      AjaxJson j = new AjaxJson();
      tBBook = (TBBookEntity)this.systemService.getEntity(TBBookEntity.class, tBBook.getId());
      String message = "图书表删除成功";

      try {
         this.tBBookService.delete(tBBook);
         this.systemService.addLog(message, Globals.Log_Type_DEL, Globals.Log_Leavel_INFO);
      } catch (Exception var6) {
         var6.printStackTrace();
         message = "图书表删除失败";
         throw new BusinessException(var6.getMessage());
      }

      j.setMsg(message);
      return j;
   }

   @RequestMapping(
      params = {"doBatchDel"}
   )
   @ResponseBody
   public AjaxJson doBatchDel(String ids, HttpServletRequest request) {
      AjaxJson j = new AjaxJson();
      String message = "图书表删除成功";

      try {
         String[] var8;
         int var7 = (var8 = ids.split(",")).length;

         for(int var6 = 0; var6 < var7; ++var6) {
            String e = var8[var6];
            TBBookEntity tBBook = (TBBookEntity)this.systemService.getEntity(TBBookEntity.class, e);
            this.tBBookService.delete(tBBook);
            this.systemService.addLog(message, Globals.Log_Type_DEL, Globals.Log_Leavel_INFO);
         }
      } catch (Exception var10) {
         var10.printStackTrace();
         message = "图书表删除失败";
         throw new BusinessException(var10.getMessage());
      }

      j.setMsg(message);
      return j;
   }

   @RequestMapping(
      params = {"doAdd"}
   )
   @ResponseBody
   public AjaxJson doAdd(TBBookEntity tBBook, HttpServletRequest request) {
      AjaxJson j = new AjaxJson();
      String message = "图书表添加成功";

      try {
         tBBook.setStatus(Globals.BOOK_RETURN);
         this.tBBookService.save(tBBook);
         this.systemService.addLog(message, Globals.Log_Type_INSERT, Globals.Log_Leavel_INFO);
      } catch (Exception var6) {
         var6.printStackTrace();
         message = "图书表添加失败";
         throw new BusinessException(var6.getMessage());
      }

      j.setMsg(message);
      return j;
   }

   @RequestMapping(
      params = {"doUpdate"}
   )
   @ResponseBody
   public AjaxJson doUpdate(TBBookEntity tBBook, HttpServletRequest request) {
      AjaxJson j = new AjaxJson();
      String message = "图书表更新成功";
      TBBookEntity t = (TBBookEntity)this.tBBookService.get(TBBookEntity.class, tBBook.getId());

      try {
         MyBeanUtils.copyBeanNotNull2Bean(tBBook, t);
         this.tBBookService.saveOrUpdate(t);
         this.systemService.addLog(message, Globals.Log_Type_UPDATE, Globals.Log_Leavel_INFO);
      } catch (Exception var7) {
         var7.printStackTrace();
         message = "图书表更新失败";
         throw new BusinessException(var7.getMessage());
      }

      j.setMsg(message);
      return j;
   }

   @RequestMapping(
      params = {"goAdd"}
   )
   public ModelAndView goAdd(TBBookEntity tBBook, HttpServletRequest req) {
      if(StringUtil.isNotEmpty(tBBook.getId())) {
         tBBook = (TBBookEntity)this.tBBookService.getEntity(TBBookEntity.class, tBBook.getId());
         req.setAttribute("tBBookPage", tBBook);
      }

      return new ModelAndView("buss/book/tBBook-add");
   }

   @RequestMapping(
      params = {"goUpdate"}
   )
   public ModelAndView goUpdate(TBBookEntity tBBook, HttpServletRequest req) {
      if(StringUtil.isNotEmpty(tBBook.getId())) {
         tBBook = (TBBookEntity)this.tBBookService.getEntity(TBBookEntity.class, tBBook.getId());
         req.setAttribute("tBBookPage", tBBook);
      }

      return new ModelAndView("buss/book/tBBook-update");
   }

   @RequestMapping(
      params = {"bookStatisticTabs"}
   )
   public ModelAndView bookStatisticTabs(HttpServletRequest request) {
      return new ModelAndView("buss/book/tBBookReport");
   }

   @RequestMapping(
      params = {"bookCount"}
   )
   @ResponseBody
   public List bookCount(HttpServletRequest request, String reportType, HttpServletResponse response) {
      ArrayList list = new ArrayList();
      new Highchart();
      StringBuffer sb = new StringBuffer();
      sb.append("SELECT booktype ,count(booktype) FROM TBBookEntity group by booktype");
      List bookTypeList = this.systemService.findByQueryString(sb.toString());
      Long count = this.systemService.getCountForJdbc("SELECT COUNT(1) FROM T_B_book WHERE 1=1");
      ArrayList lt = new ArrayList();
      Highchart hc = new Highchart();
      hc.setName("图书种类统计");
      hc.setType(reportType);
      String hql = "from TSType where typegroupid=\'" + Globals.TYPEGROUP_ID + "\'";
      List typeList = this.systemService.findByQueryString(hql);
      HashMap typeMap = new HashMap();
      Iterator var15;
      if(typeList.size() > 0) {
         var15 = typeList.iterator();

         while(var15.hasNext()) {
            TSType object = (TSType)var15.next();
            typeMap.put(object.getTypecode(), object.getTypename());
         }
      }

      if(bookTypeList.size() > 0) {
         var15 = bookTypeList.iterator();

         while(var15.hasNext()) {
            Object object1 = var15.next();
            HashMap map = new HashMap();
            Object[] obj = (Object[])object1;
            map.put("name", typeMap.get(obj[0]));
            map.put("y", obj[1]);
            Long groupCount = (Long)obj[1];
            Double percentage = Double.valueOf(0.0D);
            if(count != null && count.intValue() != 0) {
               percentage = Double.valueOf((new Double((double)groupCount.longValue())).doubleValue() / (double)count.longValue());
            }

            map.put("percentage", Double.valueOf(percentage.doubleValue() * 100.0D));
            lt.add(map);
         }
      }

      hc.setData(lt);
      list.add(hc);
      return list;
   }

   @RequestMapping(
      params = {"export"}
   )
   public void export(HttpServletRequest request, HttpServletResponse response) throws IOException {
      request.setCharacterEncoding("utf-8");
      response.setCharacterEncoding("utf-8");
      String type = request.getParameter("type");
      String svg = request.getParameter("svg");
      String filename = request.getParameter("filename");
      filename = filename == null?"chart":filename;
      ServletOutputStream out = response.getOutputStream();

      try {
         if(type != null && svg != null) {
            svg = svg.replaceAll(":rect", "rect");
            String ext = "";
            Object t = null;
            if(type.equals("image/png")) {
               ext = "png";
               t = new PNGTranscoder();
            } else if(type.equals("image/jpeg")) {
               ext = "jpg";
               t = new JPEGTranscoder();
            } else if(type.equals("application/pdf")) {
               ext = "pdf";
               t = new PDFTranscoder();
            } else if(type.equals("image/svg+xml")) {
               ext = "svg";
            }

            response.addHeader("Content-Disposition", "attachment; filename=" + new String(filename.getBytes("GBK"), "ISO-8859-1") + "." + ext);
            response.addHeader("Content-Type", type);
            if(t != null) {
               TranscoderInput writer = new TranscoderInput(new StringReader(svg));
               TranscoderOutput output = new TranscoderOutput(out);

               try {
                  ((Transcoder)t).transcode(writer, output);
               } catch (TranscoderException var15) {
                  out.print("Problem transcoding stream. See the web logs for more details.");
                  var15.printStackTrace();
               }
            } else if(ext.equals("svg")) {
               OutputStreamWriter writer1 = new OutputStreamWriter(out, "UTF-8");
               writer1.append(svg);
               writer1.close();
            } else {
               out.print("Invalid type: " + type);
            }
         } else {
            response.addHeader("Content-Type", "text/html");
            out.println("Usage:\n\tParameter [svg]: The DOM Element to be converted.\n\tParameter [type]: The destination MIME type for the elment to be transcoded.");
         }
      } finally {
         if(out != null) {
            out.flush();
            out.close();
         }

      }

   }

   @RequestMapping(
      params = {"upload"}
   )
   public ModelAndView upload(HttpServletRequest req) {
      return new ModelAndView("buss/book/bookUpload");
   }

   @RequestMapping(
      params = {"importExcel"},
      method = {RequestMethod.POST}
   )
   @ResponseBody
   public AjaxJson importExcel(HttpServletRequest request, HttpServletResponse response) {
      AjaxJson j = new AjaxJson();
      MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest)request;
      Map fileMap = multipartRequest.getFileMap();
      Iterator var7 = fileMap.entrySet().iterator();

      while(var7.hasNext()) {
         Entry entity = (Entry)var7.next();
         MultipartFile file = (MultipartFile)entity.getValue();
         ImportParams params = new ImportParams();

         try {
            List e = (List)ExcelImportUtil.importExcelByIs(file.getInputStream(), TBBookEntity.class, params);
            Iterator var12 = e.iterator();

            while(var12.hasNext()) {
               TBBookEntity book = (TBBookEntity)var12.next();
               if(book != null && book.getBookname() != null) {
                  book.setStatus(Globals.BOOK_RETURN);
                  this.tBBookService.save(book);
               }
            }

            j.setMsg("文件导入成功!");
         } catch (Exception var21) {
            j.setMsg("文件导入失败!");
            logger.error(ExceptionUtil.getExceptionMessage(var21));
         } finally {
            try {
               file.getInputStream().close();
            } catch (IOException var20) {
               var20.printStackTrace();
            }

         }
      }

      return j;
   }
}


五.项目截图

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值