整理代码
This commit is contained in:
@@ -1,21 +1,21 @@
|
||||
package com.jsh.dao.asset;
|
||||
|
||||
import org.hibernate.Query;
|
||||
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
|
||||
|
||||
import com.jsh.exception.AmsException;
|
||||
import com.jsh.model.po.Asset;
|
||||
import com.jsh.util.common.PageUtil;
|
||||
import com.jsh.util.common.SearchConditionUtil;
|
||||
|
||||
public class ReportDAO extends HibernateDaoSupport implements ReportIDAO
|
||||
{
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public void find(PageUtil<Asset> pageUtil,String reportType,String reportName) throws AmsException
|
||||
{
|
||||
Query query = this.getHibernateTemplate().getSessionFactory().getCurrentSession().createQuery("select count(" + reportType +") as dataSum, " + reportName + " from Asset asset where 1=1 " + SearchConditionUtil.getCondition(pageUtil.getAdvSearch()));
|
||||
pageUtil.setTotalCount(query.list().size());
|
||||
pageUtil.setPageList(query.list());
|
||||
}
|
||||
}
|
||||
package com.jsh.dao.asset;
|
||||
|
||||
import org.hibernate.Query;
|
||||
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
|
||||
|
||||
import com.jsh.exception.JshException;
|
||||
import com.jsh.model.po.Asset;
|
||||
import com.jsh.util.common.PageUtil;
|
||||
import com.jsh.util.common.SearchConditionUtil;
|
||||
|
||||
public class ReportDAO extends HibernateDaoSupport implements ReportIDAO
|
||||
{
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public void find(PageUtil<Asset> pageUtil,String reportType,String reportName) throws JshException
|
||||
{
|
||||
Query query = this.getHibernateTemplate().getSessionFactory().getCurrentSession().createQuery("select count(" + reportType +") as dataSum, " + reportName + " from Asset asset where 1=1 " + SearchConditionUtil.getCondition(pageUtil.getAdvSearch()));
|
||||
pageUtil.setTotalCount(query.list().size());
|
||||
pageUtil.setPageList(query.list());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
package com.jsh.dao.asset;
|
||||
|
||||
import com.jsh.exception.AmsException;
|
||||
import com.jsh.model.po.Asset;
|
||||
import com.jsh.util.common.PageUtil;
|
||||
|
||||
public interface ReportIDAO
|
||||
{
|
||||
/**
|
||||
* 查找资产列表
|
||||
* @param pageUtil 分页工具类
|
||||
* @param reportType 报表统计字段
|
||||
* @throws AmsException
|
||||
*/
|
||||
void find(PageUtil<Asset> pageUtil,String reportType,String reportName) throws AmsException;
|
||||
}
|
||||
package com.jsh.dao.asset;
|
||||
|
||||
import com.jsh.exception.JshException;
|
||||
import com.jsh.model.po.Asset;
|
||||
import com.jsh.util.common.PageUtil;
|
||||
|
||||
public interface ReportIDAO
|
||||
{
|
||||
/**
|
||||
* 查找资产列表
|
||||
* @param pageUtil 分页工具类
|
||||
* @param reportType 报表统计字段
|
||||
* @throws JshException
|
||||
*/
|
||||
void find(PageUtil<Asset> pageUtil,String reportType,String reportName) throws JshException;
|
||||
}
|
||||
|
||||
@@ -1,32 +1,32 @@
|
||||
package com.jsh.dao.basic;
|
||||
|
||||
import org.hibernate.Query;
|
||||
|
||||
import com.jsh.base.BaseDAO;
|
||||
import com.jsh.exception.AmsException;
|
||||
import com.jsh.model.po.Asset;
|
||||
import com.jsh.model.po.UserBusiness;
|
||||
import com.jsh.util.common.PageUtil;
|
||||
import com.jsh.util.common.SearchConditionUtil;
|
||||
|
||||
public class UserBusinessDAO extends BaseDAO<UserBusiness> implements UserBusinessIDAO
|
||||
{
|
||||
/**
|
||||
* 设置dao映射基类
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Class<UserBusiness> getEntityClass()
|
||||
{
|
||||
return UserBusiness.class;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public void find(PageUtil<UserBusiness> pageUtil,String ceshi) throws AmsException
|
||||
{
|
||||
Query query = this.getHibernateTemplate().getSessionFactory().getCurrentSession().createQuery("select count(id),sum(id) from UserBusiness userBusiness where 1=1 " + SearchConditionUtil.getCondition(pageUtil.getAdvSearch()));
|
||||
pageUtil.setTotalCount(query.list().size());
|
||||
pageUtil.setPageList(query.list());
|
||||
}
|
||||
}
|
||||
package com.jsh.dao.basic;
|
||||
|
||||
import org.hibernate.Query;
|
||||
|
||||
import com.jsh.base.BaseDAO;
|
||||
import com.jsh.exception.JshException;
|
||||
import com.jsh.model.po.Asset;
|
||||
import com.jsh.model.po.UserBusiness;
|
||||
import com.jsh.util.common.PageUtil;
|
||||
import com.jsh.util.common.SearchConditionUtil;
|
||||
|
||||
public class UserBusinessDAO extends BaseDAO<UserBusiness> implements UserBusinessIDAO
|
||||
{
|
||||
/**
|
||||
* 设置dao映射基类
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Class<UserBusiness> getEntityClass()
|
||||
{
|
||||
return UserBusiness.class;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public void find(PageUtil<UserBusiness> pageUtil,String ceshi) throws JshException
|
||||
{
|
||||
Query query = this.getHibernateTemplate().getSessionFactory().getCurrentSession().createQuery("select count(id),sum(id) from UserBusiness userBusiness where 1=1 " + SearchConditionUtil.getCondition(pageUtil.getAdvSearch()));
|
||||
pageUtil.setTotalCount(query.list().size());
|
||||
pageUtil.setPageList(query.list());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
package com.jsh.dao.basic;
|
||||
|
||||
import com.jsh.base.BaseIDAO;
|
||||
import com.jsh.exception.AmsException;
|
||||
import com.jsh.model.po.UserBusiness;
|
||||
import com.jsh.util.common.PageUtil;
|
||||
|
||||
public interface UserBusinessIDAO extends BaseIDAO<UserBusiness>
|
||||
{
|
||||
/*
|
||||
* 测试hql语句
|
||||
*/
|
||||
void find(PageUtil<UserBusiness> pageUtil,String ceshi) throws AmsException;
|
||||
}
|
||||
package com.jsh.dao.basic;
|
||||
|
||||
import com.jsh.base.BaseIDAO;
|
||||
import com.jsh.exception.JshException;
|
||||
import com.jsh.model.po.UserBusiness;
|
||||
import com.jsh.util.common.PageUtil;
|
||||
|
||||
public interface UserBusinessIDAO extends BaseIDAO<UserBusiness>
|
||||
{
|
||||
/*
|
||||
* 测试hql语句
|
||||
*/
|
||||
void find(PageUtil<UserBusiness> pageUtil,String ceshi) throws JshException;
|
||||
}
|
||||
|
||||
@@ -1,32 +1,32 @@
|
||||
package com.jsh.dao.materials;
|
||||
|
||||
import org.hibernate.Query;
|
||||
|
||||
import com.jsh.base.BaseDAO;
|
||||
import com.jsh.exception.AmsException;
|
||||
import com.jsh.model.po.DepotHead;
|
||||
import com.jsh.model.po.UserBusiness;
|
||||
import com.jsh.util.common.PageUtil;
|
||||
import com.jsh.util.common.SearchConditionUtil;
|
||||
|
||||
public class DepotHeadDAO extends BaseDAO<DepotHead> implements DepotHeadIDAO
|
||||
{
|
||||
/**
|
||||
* 设置dao映射基类
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Class<DepotHead> getEntityClass()
|
||||
{
|
||||
return DepotHead.class;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public void find(PageUtil<DepotHead> pageUtil,String maxid) throws AmsException
|
||||
{
|
||||
Query query = this.getHibernateTemplate().getSessionFactory().getCurrentSession().createQuery("select max(Id) as Id from DepotHead depotHead where 1=1 " + SearchConditionUtil.getCondition(pageUtil.getAdvSearch()));
|
||||
pageUtil.setTotalCount(query.list().size());
|
||||
pageUtil.setPageList(query.list());
|
||||
}
|
||||
}
|
||||
package com.jsh.dao.materials;
|
||||
|
||||
import org.hibernate.Query;
|
||||
|
||||
import com.jsh.base.BaseDAO;
|
||||
import com.jsh.exception.JshException;
|
||||
import com.jsh.model.po.DepotHead;
|
||||
import com.jsh.model.po.UserBusiness;
|
||||
import com.jsh.util.common.PageUtil;
|
||||
import com.jsh.util.common.SearchConditionUtil;
|
||||
|
||||
public class DepotHeadDAO extends BaseDAO<DepotHead> implements DepotHeadIDAO
|
||||
{
|
||||
/**
|
||||
* 设置dao映射基类
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Class<DepotHead> getEntityClass()
|
||||
{
|
||||
return DepotHead.class;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public void find(PageUtil<DepotHead> pageUtil,String maxid) throws JshException
|
||||
{
|
||||
Query query = this.getHibernateTemplate().getSessionFactory().getCurrentSession().createQuery("select max(Id) as Id from DepotHead depotHead where 1=1 " + SearchConditionUtil.getCondition(pageUtil.getAdvSearch()));
|
||||
pageUtil.setTotalCount(query.list().size());
|
||||
pageUtil.setPageList(query.list());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
package com.jsh.dao.materials;
|
||||
|
||||
import com.jsh.base.BaseIDAO;
|
||||
import com.jsh.exception.AmsException;
|
||||
import com.jsh.model.po.DepotHead;
|
||||
import com.jsh.model.po.UserBusiness;
|
||||
import com.jsh.util.common.PageUtil;
|
||||
|
||||
public interface DepotHeadIDAO extends BaseIDAO<DepotHead>
|
||||
{
|
||||
/*
|
||||
* 获取MaxId
|
||||
*/
|
||||
void find(PageUtil<DepotHead> pageUtil,String maxid) throws AmsException;
|
||||
}
|
||||
package com.jsh.dao.materials;
|
||||
|
||||
import com.jsh.base.BaseIDAO;
|
||||
import com.jsh.exception.JshException;
|
||||
import com.jsh.model.po.DepotHead;
|
||||
import com.jsh.model.po.UserBusiness;
|
||||
import com.jsh.util.common.PageUtil;
|
||||
|
||||
public interface DepotHeadIDAO extends BaseIDAO<DepotHead>
|
||||
{
|
||||
/*
|
||||
* 获取MaxId
|
||||
*/
|
||||
void find(PageUtil<DepotHead> pageUtil,String maxid) throws JshException;
|
||||
}
|
||||
|
||||
@@ -1,59 +1,59 @@
|
||||
package com.jsh.dao.materials;
|
||||
|
||||
import org.hibernate.Query;
|
||||
|
||||
import com.jsh.base.BaseDAO;
|
||||
import com.jsh.exception.AmsException;
|
||||
import com.jsh.model.po.DepotHead;
|
||||
import com.jsh.model.po.DepotItem;
|
||||
import com.jsh.util.common.PageUtil;
|
||||
import com.jsh.util.common.SearchConditionUtil;
|
||||
|
||||
public class DepotItemDAO extends BaseDAO<DepotItem> implements DepotItemIDAO
|
||||
{
|
||||
/**
|
||||
* 设置dao映射基类
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Class<DepotItem> getEntityClass()
|
||||
{
|
||||
return DepotItem.class;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public void findByType(PageUtil<DepotItem> pageUtil,String type,Long MId,String MonthTime,Boolean isPrev) throws AmsException
|
||||
{
|
||||
//多表联查,多表连查,此处用到了createSQLQuery,可以随便写sql语句,很方便
|
||||
Query query;
|
||||
if(isPrev) {
|
||||
query = this.getHibernateTemplate().getSessionFactory().getCurrentSession().createSQLQuery("select sum(OperNumber) as OperNumber from jsh_depotitem,jsh_depothead where jsh_depotitem.HeaderId = jsh_depothead.id and type='" + type +"' and MaterialId ="+ MId + " and jsh_depothead.OperTime <'"+ MonthTime +"-01 00:00:00' " + SearchConditionUtil.getCondition(pageUtil.getAdvSearch()));
|
||||
}
|
||||
else {
|
||||
query = this.getHibernateTemplate().getSessionFactory().getCurrentSession().createSQLQuery("select sum(OperNumber) as OperNumber from jsh_depotitem,jsh_depothead where jsh_depotitem.HeaderId = jsh_depothead.id and type='" + type +"' and MaterialId ="+ MId + " and jsh_depothead.OperTime >='"+ MonthTime +"-01 00:00:00' and jsh_depothead.OperTime <='"+ MonthTime +"-31 00:00:00' " + SearchConditionUtil.getCondition(pageUtil.getAdvSearch()));
|
||||
}
|
||||
pageUtil.setTotalCount(query.list().size());
|
||||
pageUtil.setPageList(query.list());
|
||||
}
|
||||
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public void findOrderByMaterial(PageUtil<DepotItem> pageUtil) throws AmsException
|
||||
{
|
||||
//多表联查,多表连查,此处用到了createSQLQuery,可以随便写sql语句,很方便
|
||||
Query query = this.getHibernateTemplate().getSessionFactory().getCurrentSession().createSQLQuery("select * from jsh_depotitem where 1=1 " + SearchConditionUtil.getCondition(pageUtil.getAdvSearch()));
|
||||
pageUtil.setTotalCount(query.list().size());
|
||||
|
||||
// 分页查询
|
||||
int pageNo = pageUtil.getCurPage();
|
||||
int pageSize = pageUtil.getPageSize();
|
||||
if (0 != pageNo && 0 != pageSize)
|
||||
{
|
||||
query.setFirstResult((pageNo - 1) * pageSize);
|
||||
query.setMaxResults(pageSize);
|
||||
}
|
||||
pageUtil.setPageList(query.list());
|
||||
}
|
||||
}
|
||||
package com.jsh.dao.materials;
|
||||
|
||||
import org.hibernate.Query;
|
||||
|
||||
import com.jsh.base.BaseDAO;
|
||||
import com.jsh.exception.JshException;
|
||||
import com.jsh.model.po.DepotHead;
|
||||
import com.jsh.model.po.DepotItem;
|
||||
import com.jsh.util.common.PageUtil;
|
||||
import com.jsh.util.common.SearchConditionUtil;
|
||||
|
||||
public class DepotItemDAO extends BaseDAO<DepotItem> implements DepotItemIDAO
|
||||
{
|
||||
/**
|
||||
* 设置dao映射基类
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Class<DepotItem> getEntityClass()
|
||||
{
|
||||
return DepotItem.class;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public void findByType(PageUtil<DepotItem> pageUtil,String type,Long MId,String MonthTime,Boolean isPrev) throws JshException
|
||||
{
|
||||
//多表联查,多表连查,此处用到了createSQLQuery,可以随便写sql语句,很方便
|
||||
Query query;
|
||||
if(isPrev) {
|
||||
query = this.getHibernateTemplate().getSessionFactory().getCurrentSession().createSQLQuery("select sum(OperNumber) as OperNumber from jsh_depotitem,jsh_depothead where jsh_depotitem.HeaderId = jsh_depothead.id and type='" + type +"' and MaterialId ="+ MId + " and jsh_depothead.OperTime <'"+ MonthTime +"-01 00:00:00' " + SearchConditionUtil.getCondition(pageUtil.getAdvSearch()));
|
||||
}
|
||||
else {
|
||||
query = this.getHibernateTemplate().getSessionFactory().getCurrentSession().createSQLQuery("select sum(OperNumber) as OperNumber from jsh_depotitem,jsh_depothead where jsh_depotitem.HeaderId = jsh_depothead.id and type='" + type +"' and MaterialId ="+ MId + " and jsh_depothead.OperTime >='"+ MonthTime +"-01 00:00:00' and jsh_depothead.OperTime <='"+ MonthTime +"-31 00:00:00' " + SearchConditionUtil.getCondition(pageUtil.getAdvSearch()));
|
||||
}
|
||||
pageUtil.setTotalCount(query.list().size());
|
||||
pageUtil.setPageList(query.list());
|
||||
}
|
||||
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public void findOrderByMaterial(PageUtil<DepotItem> pageUtil) throws JshException
|
||||
{
|
||||
//多表联查,多表连查,此处用到了createSQLQuery,可以随便写sql语句,很方便
|
||||
Query query = this.getHibernateTemplate().getSessionFactory().getCurrentSession().createSQLQuery("select * from jsh_depotitem where 1=1 " + SearchConditionUtil.getCondition(pageUtil.getAdvSearch()));
|
||||
pageUtil.setTotalCount(query.list().size());
|
||||
|
||||
// 分页查询
|
||||
int pageNo = pageUtil.getCurPage();
|
||||
int pageSize = pageUtil.getPageSize();
|
||||
if (0 != pageNo && 0 != pageSize)
|
||||
{
|
||||
query.setFirstResult((pageNo - 1) * pageSize);
|
||||
query.setMaxResults(pageSize);
|
||||
}
|
||||
pageUtil.setPageList(query.list());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
package com.jsh.dao.materials;
|
||||
|
||||
import com.jsh.base.BaseIDAO;
|
||||
import com.jsh.exception.AmsException;
|
||||
import com.jsh.model.po.DepotHead;
|
||||
import com.jsh.model.po.DepotItem;
|
||||
import com.jsh.util.common.PageUtil;
|
||||
|
||||
public interface DepotItemIDAO extends BaseIDAO<DepotItem>
|
||||
{
|
||||
void findByType(PageUtil<DepotItem> pageUtil,String type,Long MId, String MonthTime,Boolean isPrev) throws AmsException;
|
||||
|
||||
void findOrderByMaterial(PageUtil<DepotItem> pageUtil) throws AmsException;
|
||||
}
|
||||
package com.jsh.dao.materials;
|
||||
|
||||
import com.jsh.base.BaseIDAO;
|
||||
import com.jsh.exception.JshException;
|
||||
import com.jsh.model.po.DepotHead;
|
||||
import com.jsh.model.po.DepotItem;
|
||||
import com.jsh.util.common.PageUtil;
|
||||
|
||||
public interface DepotItemIDAO extends BaseIDAO<DepotItem>
|
||||
{
|
||||
void findByType(PageUtil<DepotItem> pageUtil,String type,Long MId, String MonthTime,Boolean isPrev) throws JshException;
|
||||
|
||||
void findOrderByMaterial(PageUtil<DepotItem> pageUtil) throws JshException;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user