package com.tarena.pfm.biz.impl;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import org.hibernate.HibernateException;
import org.hibernate.Session;
import org.hibernate.Transaction;
import com.tarena.pfm.biz.WasteBookBiz;
import com.tarena.pfm.entity.BookList;
import com.tarena.pfm.entity.User;
import com.tarena.pfm.entity.WasteBook;
import com.tarena.pfm.util.HibernateSessionFactory;
public class WasteBookBizImpl implements WasteBookBiz {
public void addWasteBook(WasteBook wasteBook) {
Session session = HibernateSessionFactory.getSession();
Transaction tran = null;
try {
tran = session.beginTransaction();
session.save(wasteBook);
User user = wasteBook.getUser();
session.update(user);
tran.commit();
} catch (HibernateException e) {
e.printStackTrace();
tran.rollback();
} finally {
HibernateSessionFactory.closeSession();
}
}
@SuppressWarnings("unchecked")
public List<BookList> findDebtBooksByDebtName(Integer userId,
String debtName) {
Session session = HibernateSessionFactory.getSession();
String hql = "select new com.tarena.pfm.entity.BookList(wb.id, wb.bizDate, wb.money, i.itemName, wb.desc, i.debtType ) "
+ "from WasteBook wb left join wb.item i where wb.user.id = :userId "
+ "and i.itemName = :debtName and (i.debtType = 'indebt' or i.debtType = 'outdebt')";
Transaction tran = null;
List<BookList> books = null;
try {
tran = session.beginTransaction();
books = session.createQuery(hql).setInteger("userId", userId)
.setString("debtName", debtName).list();
tran.commit();
} catch (HibernateException e) {
e.printStackTrace();
tran.rollback();
} finally {
HibernateSessionFactory.closeSession();
}
return books;
}
@SuppressWarnings("unchecked")
public List<BookList> findDebtBooksInDaily(Integer userId, Calendar day) {
Session session = HibernateSessionFactory.getSession();
String hql = "select new com.tarena.pfm.entity.BookList(wb.id, wb.bizDate, wb.money, i.itemName, wb.desc, i.debtType ) "
+ "from WasteBook wb left join wb.item i where wb.user.id = :userId "
+ "and wb.bizDate = :day "
+ "and (i.debtType = 'indebt' or i.debtType = 'outdebt')";
Transaction tran = null;
List<BookList> books = null;
try {
tran = session.beginTransaction();
books = session.createQuery(hql).setInteger("userId", userId)
.setDate("day", day.getTime()).list();
tran.commit();
} catch (HibernateException e) {
e.printStackTrace();
tran.rollback();
} finally {
HibernateSessionFactory.closeSession();
}
return books;
}
@SuppressWarnings("unchecked")
public List<BookList> findDebtBooksInMonth(Integer userId, Calendar month) {
Session session = HibernateSessionFactory.getSession();
String hql = "select new com.tarena.pfm.entity.BookList(wb.id, wb.bizDate, wb.money, i.itemName, wb.desc, i.debtType ) "
+ "from WasteBook wb left join wb.item i where wb.user.id = :userId "
+ "and wb.bizDate >= :monthStart and wb.bizDate <= :monthEnd "
+ "and (i.debtType = 'indebt' or i.debtType = 'outdebt')";
month.set(Calendar.DAY_OF_MONTH, 1);
Date monthStart = month.getTime();
month.set(Calendar.DAY_OF_MONTH, this.getMaxMonthDays(month
.get(Calendar.YEAR), month.get(Calendar.MONTH) + 1));
Date monthEnd = month.getTime();
Transaction tran = null;
List<BookList> books = null;
try {
tran = session.beginTransaction();
books = session.createQuery(hql).setInteger("userId", userId)
.setDate("monthStart", monthStart).setDate("monthEnd",
monthEnd).list();
tran.commit();
} catch (HibernateException e) {
e.printStackTrace();
tran.rollback();
} finally {
HibernateSessionFactory.closeSession();
}
return books;
}
@SuppressWarnings("unchecked")
public List<BookList> findDebtBooksInYear(Integer userId, int year) {
Session session = HibernateSessionFactory.getSession();
String hql = "select new com.tarena.pfm.entity.BookList(wb.id, wb.bizDate, wb.money, i.itemName, wb.desc, i.debtType ) "
+ "from WasteBook wb left join wb.item i where wb.user.id = :userId "
+ "and wb.bizDate >= :yearStart and wb.bizDate <= :yearEnd "
+ "and (i.debtType = 'indebt' or i.debtType = 'outdebt')";
Calendar cal = Calendar.getInstance();
cal.set(year, 0, 1, 0, 0, 0);
Date yearStart = cal.getTime();
cal.set(Calendar.MONTH, 11);
cal.set(Calendar.DAY_OF_MONTH, 31);
Date yearEnd = cal.getTime();
Transaction tran = null;
List<BookList> books = null;
try {
tran = session.beginTransaction();
books = session.createQuery(hql).setInteger("userId", userId)
.setDate("yearStart", yearStart)
.setDate("yearEnd", yearEnd).list();
tran.commit();
} catch (HibernateException e) {
e.printStackTrace();
tran.rollback();
} finally {
HibernateSessionFactory.closeSession();
}
return books;
}
@SuppressWarnings("unchecked")
public List<BookList> findLifeBooksByItemName(Integer userId,
String itemName) {
Session session = HibernateSessionFactory.getSession();
String hql = "select new com.tarena.pfm.entity.BookList(wb.id, wb.bizDate, wb.money, i.itemName, wb.desc, i.itemType ) "
+ "from WasteBook wb left join wb.item i where wb.user.id = :userId "
+ "and wb.item.itemName = :itemName "
+ "and (i.itemType = 'income' or i.itemType = 'outlay')";
Transaction tran = null;
List<BookList> books = null;
try {
tran = session.beginTransaction();
books = session.createQuery(hql).setInteger("userId", userId)
.setString("itemName", itemName).list();
tran.commit();
} catch (HibernateException e) {
e.printStackTrace();
tran.rollback();
} finally {
HibernateSessionFactory.closeSession();
}
return books;
}
@SuppressWarnings("unchecked")
public List<BookList> findLifeBooksByMoney(Integer userId, double money,
String operate) {
Session session = HibernateSessionFactory.getSession();
String hql = "select new com.tarena.pfm.entity.BookList(wb.id, wb.bizDate, wb.money, i.itemName, wb.desc, i.itemType ) "
+ "from WasteBook wb left join wb.item i where wb.user.id = :userId "
+ "and wb.money " + operate + " :money "
+ "and (i.itemType = 'income' or i.itemType = 'outlay')";
Transaction tran = null;
List<BookList> books = null;
try {
tran = session.beginTransaction();
books = session.createQuery(hql).setInteger("userId", userId)
.setDouble("money", money).list();
tran.commit();
} catch (HibernateException e) {
e.printStackTrace();
tran.rollback();
} finally {
HibernateSessionFactory.closeSession();
}
return books;
}
@SuppressWarnings("unchecked")
public List<BookList> findLifeBooksInDaily(Integer userId, Calendar day) {
Session session = HibernateSessionFactory.getSession();
String hql = "select new com.tarena.pfm.entity.BookList(wb.id, wb.bizDate, wb.money, i.itemName, wb.desc, i.itemType ) "
+ "from WasteBook wb left join wb.item i where wb.user.id = :userId "
+ "and wb.bizDate = :day "
+ "and (i.itemType = 'income' or i.itemType = 'outlay')";
Transaction tran = null;
List<BookList> books = null;
try {
tran = session.beginTransaction();
books = session.createQuery(hql).setInteger("userId", userId)
.setDate("day", day.getTime()).list();
tran.commit();
} catch (HibernateException e) {
e.printStackTrace();
tran.rollback();
} finally {
HibernateSessionFactory.closeSession();
}
return books;
}
// has been test
@SuppressWarnings("unchecked")
public List<BookList> findLifeBooksInMonth(Integer userId, Calendar month) {
Session session = HibernateSessionFactory.getSession();
String hql = "select new com.tarena.pfm.entity.BookList(wb.id, wb.bizDate, wb.money, i.itemName, wb.desc, i.itemTy
没有合适的资源?快使用搜索试试~ 我知道了~
Java项目个人理财项目
共133个文件
class:30个
java:30个
jsp:26个
需积分: 50 11 下载量 4 浏览量
2017-04-12
16:08:48
上传
评论 1
收藏 5.19MB ZIP 举报
温馨提示
个人理财项目主要是为了个人在自己经济方面的一个掌控,通过对各项的监控可以合理使用分配个人财产。项目主要有添加收支项目,添加债务项目,查看项目列表,查询个人信息等多个模块。对每笔资金流通都进行监控。
资源推荐
资源详情
资源评论
收起资源包目录
Java项目个人理财项目 (133个子文件)
WasteBookBizImpl.class 10KB
WasteBookAction.class 6KB
AccountAction.class 5KB
UserBizImpl.class 4KB
UserAction.class 3KB
FixedAssetsBizImpl.class 3KB
ItemBizImpl.class 3KB
Test.class 3KB
TestFixedAssetsBiz.class 3KB
HibernateSessionFactory.class 2KB
TestWasteBookBiz.class 2KB
BookList.class 2KB
TestItemBiz.class 2KB
WasteBookForm.class 2KB
ConditionForm.class 2KB
FixedAssetForm.class 2KB
ResourceProtectedFilter.class 2KB
WasteBook.class 2KB
ItemForm.class 2KB
UserForm.class 1KB
FixedAssets.class 1KB
BaseHttpFilter.class 1KB
Item.class 1KB
CharacterEncodingFilter.class 1KB
User.class 1KB
WasteBookBiz.class 1KB
BaseEntity.class 574B
FixedAssetsBiz.class 520B
UserBiz.class 479B
ItemBiz.class 449B
.classpath 2KB
user.css 613B
frame.css 72B
hibernate3.jar 2.11MB
mysql-connector-java-5.1.6-bin.jar 687KB
struts.jar 531KB
antlr-2.7.6.jar 433KB
dom4j-1.6.1.jar 307KB
standard.jar 287KB
cglib-2.1.3.jar 276KB
ehcache-1.2.3.jar 203KB
commons-beanutils.jar 184KB
commons-collections-2.1.1.jar 171KB
commons-digester.jar 164KB
commons-validator.jar 82KB
jakarta-oro.jar 64KB
commons-logging-1.0.4.jar 37KB
asm.jar 26KB
commons-fileupload.jar 22KB
jstl.jar 17KB
asm-attrs.jar 16KB
jta.jar 9KB
WasteBookBizImpl.java 10KB
WasteBookAction.java 5KB
AccountAction.java 5KB
HibernateSessionFactory.java 3KB
UserBizImpl.java 3KB
FixedAssetsBizImpl.java 3KB
UserAction.java 3KB
ItemBizImpl.java 2KB
Test.java 2KB
TestWasteBookBiz.java 2KB
WasteBookBiz.java 1KB
BookList.java 1KB
ConditionForm.java 1KB
WasteBookForm.java 1KB
FixedAssetForm.java 1KB
ItemForm.java 1KB
TestFixedAssetsBiz.java 1KB
BaseHttpFilter.java 1KB
UserForm.java 1KB
FixedAssets.java 1KB
Item.java 1014B
WasteBook.java 948B
TestItemBiz.java 866B
User.java 793B
ResourceProtectedFilter.java 775B
CharacterEncodingFilter.java 686B
ItemBiz.java 471B
FixedAssetsBiz.java 405B
UserBiz.java 360B
BaseEntity.java 275B
checkForm.js 7KB
addWasteBook.jsp 2KB
dayReportForm.jsp 2KB
queryByMoney.jsp 2KB
monthReportForm.jsp 2KB
yearReportForm.jsp 2KB
queryByItemName.jsp 2KB
banner.jsp 2KB
modifyFixedAsset.jsp 2KB
addFixedAsset.jsp 2KB
register.jsp 2KB
modifyPassword.jsp 1KB
addLifeItem.jsp 1KB
login.jsp 1KB
addDebtItem.jsp 1KB
listFixedAssets.jsp 1KB
listItems.jsp 982B
main.jsp 838B
共 133 条
- 1
- 2
资源评论
jackeidean
- 粉丝: 0
- 资源: 1
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功