-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
623 additions
and
259 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
*.classpath | ||
cw/.classpath |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,150 @@ | ||
package com.wuzhou.controller; | ||
|
||
import org.apache.log4j.Logger; | ||
|
||
import com.jfinal.aop.Enhancer; | ||
import com.jfinal.core.Controller; | ||
import com.jfinal.kit.JsonKit; | ||
import com.wuzhou.bean.BookBaseBean; | ||
import com.wuzhou.service.BookService; | ||
import com.wuzhou.service.ExcelMapService; | ||
import com.wuzhou.service.UserService; | ||
|
||
/** | ||
* | ||
* @author wanghonghui | ||
* | ||
*/ | ||
public class BookController extends Controller { | ||
Logger log = Logger.getLogger(BookController.class); | ||
UserService userService = Enhancer.enhance(UserService.class); | ||
BookService service = Enhancer.enhance(BookService.class); | ||
ExcelMapService excelMapService = Enhancer.enhance(ExcelMapService.class); | ||
/** | ||
* 书号检索列表页面 | ||
*/ | ||
public void bookList() { | ||
setAttr("searchConditionJson", JsonKit.toJson(BookBaseBean.getInstence().searchConditionMap)); | ||
render("/cw/BookList.jsp"); | ||
} | ||
|
||
public void bookInfo() { | ||
int id = getParaToInt("id", 0); | ||
if(id==0) { | ||
setAttr("bookBaseModel", ""); | ||
} else { | ||
try{ | ||
setAttr("bookBaseModel", service.getBookInfo(id)); | ||
} catch(Exception ex) { | ||
setAttr("bookBaseModel", ""); | ||
ex.printStackTrace(); | ||
log.error(ex); | ||
} | ||
} | ||
render("/cw/EditBook.jsp"); | ||
} | ||
|
||
/** | ||
* 书号列表 | ||
*/ | ||
public void getBookList() { | ||
String mySearchSql = getPara("mySearchSql", "1=1"); | ||
int pageNumber = getParaToInt("page", 1); | ||
try { | ||
renderJson(service.getBookList(pageNumber, mySearchSql, 1)); | ||
} catch(Exception ex) { | ||
renderJson("-1"); | ||
ex.printStackTrace(); | ||
log.error(ex); | ||
} | ||
} | ||
|
||
public void getSummary() { | ||
String mySearchSql = getPara("mySearchSql", "1=1"); | ||
try { | ||
renderJson(service.getSummary(mySearchSql)); | ||
} catch(Exception ex) { | ||
renderJson("-1"); | ||
ex.printStackTrace(); | ||
log.error(ex); | ||
} | ||
} | ||
|
||
public void getExcelList() { | ||
renderJson(excelMapService.getExcelList()); | ||
} | ||
|
||
/** | ||
* 被“删除”的图书 | ||
*/ | ||
public void bookDelPage() { | ||
setAttr("userJson", JsonKit.toJson(userService.getUserList())); | ||
render("/cw/DelBookList.jsp"); | ||
} | ||
|
||
/** | ||
* 假删除图书 | ||
*/ | ||
public void updateBookById() { | ||
int bookId = getParaToInt("bookId", 0); | ||
if(bookId==0) { | ||
renderJson("0"); | ||
return; | ||
} | ||
try { | ||
if(service.updateBookById(bookId, 0)) { | ||
renderJson("1"); | ||
} else { | ||
renderJson("2"); | ||
} | ||
} catch(Exception ex) { | ||
renderJson("-1"); | ||
ex.printStackTrace(); | ||
log.error(ex); | ||
} | ||
} | ||
|
||
/** | ||
* 恢复图书 | ||
*/ | ||
public void recoveryBookById() { | ||
// int bookId = getParaToInt("bookId", 0); | ||
// if(bookId==0) { | ||
// renderJson("0"); | ||
// return; | ||
// } | ||
// try { | ||
// if(service.updateBookById(bookId, 1)) { | ||
// renderJson("1"); | ||
// } else { | ||
// renderJson("2"); | ||
// } | ||
// } catch(Exception ex) { | ||
// renderJson("-1"); | ||
// ex.printStackTrace(); | ||
// log.error(ex); | ||
// } | ||
} | ||
|
||
/** | ||
* 删除图书 | ||
*/ | ||
public void deleteBookById() { | ||
int bookId = getParaToInt("bookId", 0); | ||
if(bookId==0) { | ||
renderJson("0"); | ||
return; | ||
} | ||
try { | ||
if(service.deleteBookById(bookId)) { | ||
renderJson("1"); | ||
} else { | ||
renderJson("2"); | ||
} | ||
} catch(Exception ex) { | ||
renderJson("-1"); | ||
ex.printStackTrace(); | ||
log.error(ex); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,80 @@ | ||
package com.wuzhou.controller; | ||
|
||
import java.io.File; | ||
import java.util.Date; | ||
|
||
import org.apache.log4j.Logger; | ||
|
||
import com.jfinal.aop.Enhancer; | ||
import com.jfinal.core.Controller; | ||
import com.jfinal.kit.PathKit; | ||
import com.jfinal.upload.UploadFile; | ||
import com.wuzhou.Result; | ||
import com.wuzhou.service.ExcelImportService; | ||
import com.wuzhou.service.ExcelMapService; | ||
import com.wuzhou.service.UserService; | ||
|
||
/** | ||
* excel导入控制 | ||
* @author wanghonghui | ||
* | ||
*/ | ||
public class ExcelImportController extends Controller{ | ||
Logger log = Logger.getLogger(ExcelImportController.class); | ||
|
||
UserService userService = Enhancer.enhance(UserService.class); | ||
ExcelMapService excelMapService = Enhancer.enhance(ExcelMapService.class); | ||
ExcelImportService service = Enhancer.enhance(ExcelImportService.class); | ||
|
||
Result result = new Result(); | ||
|
||
/** | ||
* 图书基本信息导入页面 | ||
*/ | ||
public void baseBookImportPage() { | ||
render(""); | ||
public void importBaseBookPage() { | ||
render("/cw/ImportBookBase.jsp"); | ||
} | ||
|
||
/** | ||
* 上传excel | ||
*/ | ||
public void uploadBaseBookExcel() { | ||
UploadFile file = getFile("file"); | ||
String uploadExcelName = file.getOriginalFileName(); | ||
String serverExcelName = new Date().getTime()+".xlsx"; | ||
String filePath = PathKit.getWebRootPath()+File.separator+"uploadFiles"+File.separator+serverExcelName; | ||
file.getFile().renameTo(new File(filePath)); | ||
try{ | ||
excelMapService.addExcelMap(uploadExcelName, serverExcelName); | ||
setSessionAttr("excelPath", filePath); | ||
renderJson("0"); | ||
} catch(Exception ex) { | ||
ex.printStackTrace(); | ||
renderJson(ex.getMessage()); | ||
log.error(ex); | ||
} | ||
} | ||
|
||
/** | ||
* 解析excel并返回 | ||
*/ | ||
public void saveBaseBookExcel() { | ||
Object excelPath = getSessionAttr("excelPath"); | ||
if(excelPath==null) { | ||
result.setStatus(false); | ||
result.setMessage("未加载到EXCEL"); | ||
return; | ||
} | ||
try{ | ||
int out = service.parserBookBaseExcel(excelPath.toString()); | ||
result.setStatus(true); | ||
result.setMessage("共入库["+out+"]本"); | ||
} catch(Exception ex) { | ||
ex.printStackTrace(); | ||
result.setStatus(false); | ||
result.setMessage(ex.getMessage()); | ||
log.error(ex); | ||
} | ||
renderJson(result); | ||
} | ||
} |
Oops, something went wrong.