作者主頁:夜未央5788
?簡(jiǎn)介:Java領(lǐng)域優(yōu)質(zhì)創(chuàng)作者、Java項(xiàng)目、學(xué)習(xí)資料、技術(shù)互助
文末獲取源碼
?
項(xiàng)目介紹
本畢業(yè)設(shè)計(jì)運(yùn)用了使用技術(shù):spring mvc+spring+hibernate,數(shù)據(jù)庫使用了當(dāng)前較為流行的Mysql5.7。根據(jù)本校圖書館的工作流程與實(shí)際的需求和特色,本系統(tǒng)需滿足以下幾個(gè)方面的要求:
1.對(duì)新書進(jìn)行登記入庫、下架管理;
2.對(duì)借書讀者信息提供維護(hù)功能;
3.提供圖書借書、續(xù)借、還書功能;
4.提供圖書超期未還自動(dòng)扣款功能;
5.提供數(shù)據(jù)導(dǎo)入功能。
共22張表
環(huán)境需要
1.運(yùn)行環(huán)境:最好是java jdk 1.8,我們?cè)谶@個(gè)平臺(tái)上運(yùn)行的。其他版本理論上也可以。
2.IDE環(huán)境:IDEA,Eclipse,Myeclipse都可以。推薦IDEA;
3.tomcat環(huán)境:Tomcat 7.x,8.x,9.x版本均可
4.硬件環(huán)境:windows 7/8/10 1G內(nèi)存以上;或者 Mac OS;
5.是否Maven項(xiàng)目: 是;查看源碼目錄中是否包含pom.xml;若包含,則為maven項(xiàng)目,否則為非maven項(xiàng)目?
6.數(shù)據(jù)庫:MySql 5.7版本;
技術(shù)棧
1. spring mvc+spring+hibernate
2. JSP+easyUI+BootStrap+JQuery
使用說明
1. 使用Navicat或者其它工具,在mysql中創(chuàng)建對(duì)應(yīng)名稱的數(shù)據(jù)庫,并導(dǎo)入項(xiàng)目的sql文件;
2. 將項(xiàng)目中dbconfig.properties配置文件中的數(shù)據(jù)庫配置改為自己的配置
3. 使用IDEA/Eclipse/MyEclipse導(dǎo)入項(xiàng)目,Eclipse/MyEclipse導(dǎo)入時(shí),若為maven項(xiàng)目請(qǐng)選擇maven;若為maven項(xiàng)目,導(dǎo)入成功后請(qǐng)執(zhí)行maven clean;maven install命令,配置tomcat,然后運(yùn)行;
4. 運(yùn)行項(xiàng)目,輸入localhost:8080/xxx 登錄?
運(yùn)行截圖
?
?
?
?
?文章來源:http://www.zghlxwxcb.cn/news/detail-478554.html
代碼相關(guān)
圖書管理控制器
@Controller
@RequestMapping("/tBBookController")
public class TBBookController extends BaseController {
/**
* Logger for this class
*/
private static final Logger logger = Logger.getLogger(TBBookController.class);
@Autowired
private TBBookServiceI tBBookService;
@Autowired
private SystemService systemService;
/**
* 圖書表列表 頁面跳轉(zhuǎn)
*
* @return
*/
@RequestMapping(params = "tBBook")
public ModelAndView tBBook(HttpServletRequest request) {
return new ModelAndView("buss/book/tBBookList");
}
/**
* 出版社表列表 頁面跳轉(zhuǎn)
*
* @return
*/
@RequestMapping(params = "press")
public ModelAndView press(HttpServletRequest request) {
return new ModelAndView("buss/book/press");
}
/**
* 出版社顯示列表
*
* @param request
* @param response
* @param dataGrid
*/
@RequestMapping(params = "datagridPress")
public void datagridPress(TBPressEntity tbPress, HttpServletRequest request, HttpServletResponse response, DataGrid dataGrid) {
CriteriaQuery cq = new CriteriaQuery(TBPressEntity.class, dataGrid);
com.bjpowernode.core.extend.hqlsearch.HqlGenerateUtil.installHql(cq, tbPress, request.getParameterMap());
this.systemService.getDataGridReturn(cq, true);
TagUtil.datagrid(response, dataGrid);
}
/**
* easyui AJAX請(qǐng)求數(shù)據(jù)
*
* @param request
* @param response
* @param dataGrid
* @param user
*/
@RequestMapping(params = "datagrid")
public void datagrid(TBBookEntity tBBook,HttpServletRequest request, HttpServletResponse response, DataGrid dataGrid) {
CriteriaQuery cq = new CriteriaQuery(TBBookEntity.class, dataGrid);
//查詢條件組裝器
com.bjpowernode.core.extend.hqlsearch.HqlGenerateUtil.installHql(cq, tBBook, request.getParameterMap());
try{
//自定義追加查詢條件
}catch (Exception e) {
throw new BusinessException(e.getMessage());
}
cq.add();
this.tBBookService.getDataGridReturn(cq, true);
TagUtil.datagrid(response, dataGrid);
}
/**
* 刪除圖書表
*
* @return
*/
@RequestMapping(params = "doDel")
@ResponseBody
public AjaxJson doDel(TBBookEntity tBBook, HttpServletRequest request) {
AjaxJson j = new AjaxJson();
tBBook = systemService.getEntity(TBBookEntity.class, tBBook.getId());
String message = "圖書表刪除成功";
try{
tBBookService.delete(tBBook);
systemService.addLog(message, Globals.Log_Type_DEL, Globals.Log_Leavel_INFO);
}catch(Exception e){
e.printStackTrace();
message = "圖書表刪除失敗";
throw new BusinessException(e.getMessage());
}
j.setMsg(message);
return j;
}
/**
* 批量刪除圖書表
*
* @return
*/
@RequestMapping(params = "doBatchDel")
@ResponseBody
public AjaxJson doBatchDel(String ids,HttpServletRequest request){
AjaxJson j = new AjaxJson();
String message = "圖書表刪除成功";
try{
for(String id:ids.split(",")){
TBBookEntity tBBook = systemService.getEntity(TBBookEntity.class,
id
);
tBBookService.delete(tBBook);
systemService.addLog(message, Globals.Log_Type_DEL, Globals.Log_Leavel_INFO);
}
}catch(Exception e){
e.printStackTrace();
message = "圖書表刪除失敗";
throw new BusinessException(e.getMessage());
}
j.setMsg(message);
return j;
}
/**
* 添加圖書表
*
* @param ids
* @return
*/
@RequestMapping(params = "doAdd")
@ResponseBody
public AjaxJson doAdd(TBBookEntity tBBook, HttpServletRequest request) {
AjaxJson j = new AjaxJson();
String message = "圖書表添加成功";
try{
tBBook.setStatus(Globals.BOOK_RETURN);
tBBookService.save(tBBook);
systemService.addLog(message, Globals.Log_Type_INSERT, Globals.Log_Leavel_INFO);
}catch(Exception e){
e.printStackTrace();
message = "圖書表添加失敗";
throw new BusinessException(e.getMessage());
}
j.setMsg(message);
return j;
}
/**
* 更新圖書表
*
* @param ids
* @return
*/
@RequestMapping(params = "doUpdate")
@ResponseBody
public AjaxJson doUpdate(TBBookEntity tBBook, HttpServletRequest request) {
AjaxJson j = new AjaxJson();
String message = "圖書表更新成功";
TBBookEntity t = tBBookService.get(TBBookEntity.class, tBBook.getId());
try {
MyBeanUtils.copyBeanNotNull2Bean(tBBook, t);
tBBookService.saveOrUpdate(t);
systemService.addLog(message, Globals.Log_Type_UPDATE, Globals.Log_Leavel_INFO);
} catch (Exception e) {
e.printStackTrace();
message = "圖書表更新失敗";
throw new BusinessException(e.getMessage());
}
j.setMsg(message);
return j;
}
/**
* 圖書表新增頁面跳轉(zhuǎn)
*
* @return
*/
@RequestMapping(params = "goAdd")
public ModelAndView goAdd(TBBookEntity tBBook, HttpServletRequest req) {
if (StringUtil.isNotEmpty(tBBook.getId())) {
tBBook = tBBookService.getEntity(TBBookEntity.class, tBBook.getId());
req.setAttribute("tBBookPage", tBBook);
}
return new ModelAndView("buss/book/tBBook-add");
}
/**
* 圖書表編輯頁面跳轉(zhuǎn)
*
* @return
*/
@RequestMapping(params = "goUpdate")
public ModelAndView goUpdate(TBBookEntity tBBook, HttpServletRequest req) {
if (StringUtil.isNotEmpty(tBBook.getId())) {
tBBook = tBBookService.getEntity(TBBookEntity.class, tBBook.getId());
req.setAttribute("tBBookPage", tBBook);
}
return new ModelAndView("buss/book/tBBook-update");
}
/**
* 統(tǒng)計(jì)集合頁面
*
* @return
*/
@RequestMapping(params = "bookStatisticTabs")
public ModelAndView bookStatisticTabs(HttpServletRequest request) {
return new ModelAndView("buss/book/tBBookReport");
}
/**
* 報(bào)表數(shù)據(jù)生成
*
* @return
*/
@RequestMapping(params = "bookCount")
@ResponseBody
public List<Highchart> bookCount(HttpServletRequest request,String reportType, HttpServletResponse response) {
List<Highchart> list = new ArrayList<Highchart>();
Highchart hc = new Highchart();
StringBuffer sb = new StringBuffer();
sb.append("SELECT booktype ,count(booktype) FROM TBBookEntity group by booktype");
List bookTypeList = systemService.findByQueryString(sb.toString());
Long count = systemService.getCountForJdbc("SELECT COUNT(1) FROM T_B_book WHERE 1=1");
List lt = new ArrayList();
hc = new Highchart();
hc.setName("圖書種類統(tǒng)計(jì)");
hc.setType(reportType);
Map<String, Object> map;
String hql = "from TSType where typegroupid='" + Globals.TYPEGROUP_ID+ "'";
List<TSType> typeList = systemService.findByQueryString(hql);
Map<String, String> typeMap = new HashMap<String, String>();
if(typeList.size() > 0){
for(TSType type : typeList){
typeMap.put(type.getTypecode(), type.getTypename());
}
}
if (bookTypeList.size() > 0) {
for (Object object : bookTypeList) {
map = new HashMap<String, Object>();
Object[] obj = (Object[]) object;
map.put("name", typeMap.get(obj[0]));
map.put("y", obj[1]);
Long groupCount = (Long) obj[1];
Double percentage = 0.0;
if (count != null && count.intValue() != 0) {
percentage = new Double(groupCount)/count;
}
map.put("percentage", percentage*100);
lt.add(map);
}
}
hc.setData(lt);
list.add(hc);
return list;
}
/**
* 報(bào)表打印
* @param request
* @param response
* @throws IOException
*/
@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 (null != type && null != svg) {
svg = svg.replaceAll(":rect", "rect");
String ext = "";
Transcoder 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 = (Transcoder) 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 (null != t) {
TranscoderInput input = new TranscoderInput(
new StringReader(svg));
TranscoderOutput output = new TranscoderOutput(out);
try {
t.transcode(input, output);
} catch (TranscoderException e) {
out
.print("Problem transcoding stream. See the web logs for more details.");
e.printStackTrace();
}
} else if (ext.equals("svg")) {
// out.print(svg);
OutputStreamWriter writer = new OutputStreamWriter(out,
"UTF-8");
writer.append(svg);
writer.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();
}
}
}
/**
* 圖書導(dǎo)入
*
* @return
*/
@RequestMapping(params = "upload")
public ModelAndView upload(HttpServletRequest req) {
return new ModelAndView("buss/book/bookUpload");
}
/**
* 圖書導(dǎo)入
* @param request
* @param response
* @return
*/
@SuppressWarnings("unchecked")
@RequestMapping(params = "importExcel", method = RequestMethod.POST)
@ResponseBody
public AjaxJson importExcel(HttpServletRequest request, HttpServletResponse response) {
AjaxJson j = new AjaxJson();
MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
MultipartFile file = entity.getValue();// 獲取上傳文件對(duì)象
ImportParams params = new ImportParams();
try {
List<TBBookEntity> listBooks =
(List<TBBookEntity>)ExcelImportUtil.importExcelByIs(file.getInputStream(),TBBookEntity.class,params);
for (TBBookEntity book : listBooks) {
if(book != null && book.getBookname() != null){
book.setStatus(Globals.BOOK_RETURN);
tBBookService.save(book);
}
}
j.setMsg("文件導(dǎo)入成功!");
} catch (Exception e) {
j.setMsg("文件導(dǎo)入失??!");
logger.error(ExceptionUtil.getExceptionMessage(e));
}finally{
try {
file.getInputStream().close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
return j;
}
}
?
如果也想學(xué)習(xí)本系統(tǒng),下面領(lǐng)取?;貜?fù):003ssh?文章來源地址http://www.zghlxwxcb.cn/news/detail-478554.html
到了這里,關(guān)于java項(xiàng)目-圖書館管理系統(tǒng)源碼的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!