📄 accountadjustdao.java
字号:
package com.ufmobile.business.account.dao;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import javax.persistence.EntityManager;
import javax.persistence.Query;
import com.ufmobile.business.account.entity.AccountAdjustEntity;
import com.ufmobile.common.dao.UFMobileDAO;
import com.ufmobile.mstreet.util.DateUtil;
import com.ufmobile.platform.Exception.BusinessException;
public class AccountAdjustDAO extends UFMobileDAO {
public AccountAdjustDAO(EntityManager manager){
super(manager);
}
public AccountAdjustDAO(){
super();
}
/**
* 创建账户调整单
*/
public AccountAdjustEntity create(AccountAdjustEntity accae) throws BusinessException{
if(accae == null){
throw new BusinessException(AccountAdjustDAO.class,"账户调整单不能为空!");
}
this.getManager().persist(accae);
return accae;
}
/**
*
* 更新账户调整单
* */
public void modify(AccountAdjustEntity accae) throws BusinessException{
this.getManager().merge(accae);
return;
}
/**
*
* 删除账户调整单
*/
public void delete(AccountAdjustEntity accae) throws BusinessException{
this.getManager().remove(accae);
}
/**
*
* 查询符合条件的结果集总数
* */
public Integer queryByBoothAdjustTypeOperateDateTotal(int accountType, int adjustType, Date fromDate, Date toDate, Long boothid) throws BusinessException{
Integer total = 0;
StringBuffer sql = new StringBuffer("");
sql.append("select count(*) from AccountAdjustEntity where 1=1 ");
if(boothid !=null && boothid.intValue()>0){
sql.append(" and boothIdIn = " + boothid+"");
}
if(accountType>2 || accountType<0){
throw new BusinessException(this.getClass(),"账户类型不合法!");
}else if(accountType==1 || accountType==2){
sql.append(" and accountType = " + accountType +" ");
}
if(adjustType>2 || adjustType<0){
throw new BusinessException(this.getClass(),"调整类型不合法!");
}else if(adjustType==1 || adjustType==2){
sql.append(" and adjustType = "+ adjustType +" ");
}
if (fromDate != null) {
String strStartTime = DateUtil.format(fromDate, "yyyy-MM-dd");
strStartTime = strStartTime+" 00 00 00";
sql.append(" and OperateDate >= to_date('" + strStartTime + "' , 'yyyy-mm-dd hh24:mi:ss')");
}
if (toDate != null) {
String strEndTime = DateUtil.format(toDate, "yyyy-MM-dd");
strEndTime = strEndTime +" 23 59 59";
sql.append(" and OperateDate <= to_date('" + strEndTime + "' , 'yyyy-mm-dd hh24:mi:ss')");
}
Query q = this.getManager().createQuery(sql.toString());
total = ((Long) q.getSingleResult()).intValue();
return total;
}
/**
*
* 查询符合条件的结果集
* */
public List<AccountAdjustEntity> queryByBoothAdjustTypeOperateDate(int accountType, int adjustType, Date fromDate, Date toDate, Long boothid,int total, int begin)throws BusinessException{
List<AccountAdjustEntity> accaeList = new ArrayList<AccountAdjustEntity>();
StringBuffer sql = new StringBuffer("");
sql.append(" from AccountAdjustEntity where 1=1 ");
if(boothid !=null && boothid.intValue()>0){
sql.append(" and boothIdIn = " + boothid+"");
}
if(accountType>2 || accountType<0){
throw new BusinessException(this.getClass(),"账户类型不合法!");
}else if(accountType==1 || accountType==2){
sql.append(" and accountType = " + accountType +" ");
}
if(adjustType>2 || adjustType<0){
throw new BusinessException(this.getClass(),"调整类型不合法!");
}else if(adjustType==1 || adjustType==2){
sql.append(" and adjustType = "+ adjustType +" ");
}
if (fromDate != null) {
String strStartTime = DateUtil.format(fromDate, "yyyy-MM-dd");
strStartTime = strStartTime+" 00 00 00";
sql.append(" and OperateDate >= to_date('" + strStartTime + "' , 'yyyy-mm-dd hh24:mi:ss')");
}
if (toDate != null) {
String strEndTime = DateUtil.format(toDate, "yyyy-MM-dd");
strEndTime = strEndTime +" 23 59 59";
sql.append(" and OperateDate <= to_date('" + strEndTime + "' , 'yyyy-mm-dd hh24:mi:ss')");
}
sql.append(" order by to_char(operatedate,'yyyy-MM-dd') desc,boothIdIn ASC");
Query q = this.getManager().createQuery(sql.toString());
if(total !=-1){
q.setFirstResult(begin);
q.setMaxResults(total);
}
accaeList.addAll(q.getResultList());
return accaeList;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -