package com.jkj.books.struts.action;
import java.sql.Timestamp;
import java.util.List;
import com.jkj.books.biz.BookBiz;
import com.jkj.books.entity.ReaderFee;
import com.jkj.books.entity.Record;
import com.jkj.books.entity.SystemBooks;
import com.jkj.books.entity.SystemReaders;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.ModelDriven;
public class BookAction extends ActionSupport implements
ModelDriven<SystemBooks> {
/**
*
*/
private static final long serialVersionUID = 8160933970416306626L;
private int bookid;
BookBiz bookbiz;
private SystemBooks book = new SystemBooks();
private Record record = new Record();
private ReaderFee fee=new ReaderFee();
public Record getRecord() {
return record;
}
public void setRecord(Record record) {
this.record = record;
}
public ReaderFee getFee() {
return fee;
}
public void setFee(ReaderFee fee) {
this.fee = fee;
}
public void setBookbiz(BookBiz bookbiz) {
this.bookbiz = bookbiz;
}
public SystemBooks getModel() {
// TODO Auto-generated method stub
return book;
}
public int getBookid() {
return bookid;
}
public void setBookid(int bookid) {
this.bookid = bookid;
}
// 选书操作
public String doSelect() {
ActionContext context = ActionContext.getContext();
context.getSession().get("loginUser");
Timestamp now = new Timestamp(System.currentTimeMillis());//获取当前时间
SystemReaders reader = (SystemReaders) context.getSession().get(
"loginUser");// SystemReaders
//
book = (SystemBooks) bookbiz.searchBookById(book.getBookid());//通过Id获取book
Timestamp borrowdate = now;// 借阅时间
Timestamp returndate = null;// 归还时间:未归还
int isback = 0;// 状态0:未归还
Record record = new Record(reader, book, borrowdate, returndate, isback);
book.setIsborrowed(1);
bookbiz.doUpdate(book, record);
return "Message";
}
public String doReturn() {
ActionContext context = ActionContext.getContext();
context.getSession().get("loginUser");// SystemReaders
Timestamp now = new Timestamp(System.currentTimeMillis());
book = (SystemBooks) bookbiz.searchBookById(book.getBookid());// SystemBooks
record = bookbiz.searchRecordByBookid(book.getBookid());
int id = record.getId();
Timestamp borrowdate = record.getBorrowdate();// 借阅时间
Timestamp returndate = now;// 归还时间
int isback = 1;// 状态1:归还
record = bookbiz.searchRecordById(id);
if (bookbiz.getOverDate(borrowdate, returndate) < 30) {
record.setBorrowdate(borrowdate);
record.setReturndate(returndate);
book.setIsborrowed(0);
record.setIsback(isback);
bookbiz.doReturn(book, record);
return "Message";
}else {
record.setBorrowdate(borrowdate);
record.setReturndate(returndate);
book.setIsborrowed(1);
record.setIsback(0);
bookbiz.doReturn(book, record);
return "tofee";
}
}
//
public String toFee(){
ActionContext context = ActionContext.getContext();
context.getSession().get("loginUser");// SystemReaders
book = (SystemBooks) bookbiz.searchBookById(book.getBookid());// SystemBooks
record = bookbiz.searchRecordByBookid(book.getBookid());
int id = record.getId();
record=bookbiz.searchRecordById(id);//得到该条记录
//得到超期时长
int overday=bookbiz.getOverDate(record.getBorrowdate(), record.getReturndate())-30;
Double overfee=0.5*overday;//超期费用,每日0.5元
fee.setBookfee(overfee);
fee.setOvertime(overday);
fee.setBookname(record.getSystemBooks().getBookname());
fee.setSystemBooks(record.getSystemBooks());
fee.setReadername(record.getSystemReaders().getReadername());
fee.setSystemReaders(record.getSystemReaders());
bookbiz.doFee(fee);//插入罚款表
book.setIsborrowed(0);
bookbiz.doReturn(book, record);
return showFee();
}
public String showFee(){
ActionContext context = ActionContext.getContext();
context.getSession().get("loginUser");// SystemReaders
book = (SystemBooks) bookbiz.searchBookById(book.getBookid());// SystemBooks
fee=bookbiz.searchFeeByBookid(book.getBookid());
int feeid=fee.getFeeId();
List<ReaderFee> fee=bookbiz.showFee(feeid);
context.put("fee",fee);
return "showfee";
}
public String doFee(){
ActionContext context = ActionContext.getContext();
context.getSession().get("loginUser");// SystemReaders
book = (SystemBooks) bookbiz.searchBookById(book.getBookid());// SystemBooks
record = bookbiz.searchRecordByBookid(book.getBookid());
int id = record.getId();
record=bookbiz.searchRecordById(id);//得到该条记录
record.setIsback(1);
bookbiz.doReturn(book, record);
return "Message";
}
}
wilber_meng
- 粉丝: 2
- 资源: 3
最新资源
- 【未发表】基于遗传算法GA优化集成学习结合鲁棒极限学习机RELM-Adaboost实现负荷数据回归预测算法研究附Matlab代码.rar
- 【未发表】基于蚁狮优化算法ALO优化宽度学习BLS实现光伏数据预测算法研究附Matlab代码.rar
- 【未发表】基于蚁狮优化算法ALO优化集成学习结合鲁棒极限学习机RELM-Adaboost实现负荷数据回归预测算法研究附Matlab代码.rar
- 【未发表】基于蚁狮优化算法ALO优化集成学习结合核极限学习机KELM-Adaboost实现风电数据时序预测算法研究附Matlab代码.rar
- 【未发表】基于蚁狮优化算法ALO优化鲁棒极限学习机RELM实现负荷数据回归预测算法研究附Matlab代码.rar
- 【未发表】基于引力搜索优化算法GSA优化集成学习结合鲁棒极限学习机RELM-Adaboost实现负荷数据回归预测算法研究附Matlab代码.rar
- 【未发表】基于引力搜索优化算法GSA优化集成学习结合核极限学习机KELM-Adaboost实现风电数据时序预测算法研究附Matlab代码.rar
- 【未发表】基于引力搜索优化算法GSA优化鲁棒极限学习机RELM实现负荷数据回归预测算法研究附Matlab代码.rar
- 【未发表】基于引力搜索优化算法GSA优化宽度学习BLS实现光伏数据预测算法研究附Matlab代码.rar
- 【未发表】基于鱼鹰优化算法OOA优化集成学习结合核极限学习机KELM-Adaboost实现风电数据时序预测算法研究附Matlab代码.rar
- 【未发表】基于鱼鹰优化算法OOA优化鲁棒极限学习机RELM实现负荷数据回归预测算法研究附Matlab代码.rar
- 【未发表】基于鱼鹰优化算法OOA优化宽度学习BLS实现光伏数据预测算法研究附Matlab代码.rar
- 【未发表】基于鱼鹰优化算法OOA优化集成学习结合鲁棒极限学习机RELM-Adaboost实现负荷数据回归预测算法研究附Matlab代码.rar
- 【未发表】基于侏儒猫鼬优化算法IDMO优化宽度学习BLS实现光伏数据预测算法研究附Matlab代码.rar
- 【未发表】基于侏儒猫鼬优化算法IDMO优化集成学习结合鲁棒极限学习机RELM-Adaboost实现负荷数据回归预测算法研究附Matlab代码.rar
- 【未发表】基于侏儒猫鼬优化算法IDMO优化集成学习结合核极限学习机KELM-Adaboost实现风电数据时序预测算法研究附Matlab代码.rar
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈