增加4张报表查询功能

This commit is contained in:
季圣华
2017-08-31 22:42:05 +08:00
parent 34d2e0e612
commit 99dcba59d1
5 changed files with 173 additions and 0 deletions

View File

@@ -50,4 +50,69 @@ public class DepotHeadDAO extends BaseDAO<DepotHead> implements DepotHeadIDAO {
Query query = this.getHibernateTemplate().getSessionFactory().getCurrentSession().createSQLQuery(sql);
query.executeUpdate();
}
@SuppressWarnings("unchecked")
public void findInDetail(PageUtil pageUtil,String beginTime,String endTime,String type,Long pid,String dids) throws JshException {
StringBuffer queryString = new StringBuffer();
queryString.append("select dh.Number,m.`name`,m.Model,di.UnitPrice,di.OperNumber,di.AllPrice,s.supplier,d.dName,date_format(dh.OperTime, '%Y-%m-%d') " +
"from jsh_depothead dh inner join jsh_depotitem di on di.HeaderId=dh.id " +
"inner join jsh_material m on m.id=di.MaterialId " +
"inner join jsh_supplier s on s.id=dh.OrganId " +
"inner join (select id,name as dName from jsh_depot) d on d.id=di.DepotId " +
"where dh.Type='"+ type +"' and dh.OperTime >='"+ beginTime +"' and dh.OperTime <='"+ endTime +"' ");
if(pid!=null){
queryString.append(" and di.DepotId=" + pid );
}
else {
queryString.append(" and di.DepotId in (" + dids + ")" );
}
queryString.append(" ORDER BY OperTime DESC,Number desc");
Query query;
query = this.getHibernateTemplate().getSessionFactory().getCurrentSession().createSQLQuery(queryString + 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());
}
@SuppressWarnings("unchecked")
public void findInOutMaterialCount(PageUtil pageUtil,String beginTime,String endTime,String type,Long pid,String dids) throws JshException {
StringBuffer queryString = new StringBuffer();
queryString.append("select di.MaterialId, m.mName,m.Model,m.categoryName, "+
" (select sum(jsh_depotitem.AllPrice) priceSum from jsh_depothead INNER JOIN jsh_depotitem " +
"on jsh_depothead.id=jsh_depotitem.HeaderId where jsh_depotitem.MaterialId=di.MaterialId " +
" and jsh_depothead.type='"+ type +"' and dh.OperTime >='"+ beginTime +"' and dh.OperTime <='"+ endTime +"'");
if(pid!=null){
queryString.append(" and di.DepotId=" + pid );
}
else {
queryString.append(" and di.DepotId in (" + dids + ")" );
}
queryString.append(" ) priceSum from jsh_depothead dh INNER JOIN jsh_depotitem di on dh.id=di.HeaderId " +
" INNER JOIN (SELECT jsh_material.id,jsh_material.name mName, Model,jsh_materialcategory.`Name` categoryName from jsh_material INNER JOIN jsh_materialcategory on jsh_material.CategoryId=jsh_materialcategory.Id) m " +
" on m.Id=di.MaterialId where dh.type='"+ type +"' and dh.OperTime >='"+ beginTime +"' and dh.OperTime <='"+ endTime +"' ");
if(pid!=null){
queryString.append(" and di.DepotId=" + pid );
}
else {
queryString.append(" and di.DepotId in (" + dids + ")" );
}
queryString.append(" GROUP BY di.MaterialId,m.mName,m.Model,m.categoryName ");
Query query;
query = this.getHibernateTemplate().getSessionFactory().getCurrentSession().createSQLQuery(queryString + 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());
}
}