更新库存状况报表的数据(优化)

This commit is contained in:
季圣华
2017-11-03 00:23:35 +08:00
parent aca6d40af5
commit 052af95bb3

View File

@@ -61,6 +61,47 @@ public class DepotItemDAO extends BaseDAO<DepotItem> implements DepotItemIDAO
pageUtil.setPageList(query.list());
}
@SuppressWarnings("unchecked")
@Override
public void findPriceByType(PageUtil<DepotItem> pageUtil,String type,Integer dId,Long MId,String MonthTime,Boolean isPrev) throws JshException
{
//多表联查,多表连查此处用到了createSQLQuery可以随便写sql语句很方便
Query query;
StringBuffer queryString = new StringBuffer();
if(type.equals("入库")) {
if (isPrev) {
queryString.append("select sum(AllPrice) as AllPrice from jsh_depotitem di,jsh_depothead dh where di.HeaderId = dh.id ");
queryString.append(" and ((type='入库' and DepotId='" + dId + "') " +
" or (SubType='调拨' and AnotherDepotId='" + dId + "') " +
" or (SubType='礼品充值' and AnotherDepotId='" + dId + "')) ");
queryString.append(" and MaterialId =" + MId + " and dh.OperTime <'" + MonthTime + "-01 00:00:00' ");
query = this.getHibernateTemplate().getSessionFactory().getCurrentSession().createSQLQuery(queryString + SearchConditionUtil.getCondition(pageUtil.getAdvSearch()));
} else {
queryString.append("select sum(AllPrice) as AllPrice from jsh_depotitem di,jsh_depothead dh where di.HeaderId = dh.id ");
queryString.append(" and ((type='入库' and DepotId='" + dId + "') " +
" or (SubType='调拨' and AnotherDepotId='" + dId + "') " +
" or (SubType='礼品充值' and AnotherDepotId='" + dId + "')) ");
queryString.append(" and MaterialId =" + MId + " and dh.OperTime >='" + MonthTime + "-01 00:00:00' and dh.OperTime <='" + MonthTime + "-31 59:59:59' ");
query = this.getHibernateTemplate().getSessionFactory().getCurrentSession().createSQLQuery(queryString + SearchConditionUtil.getCondition(pageUtil.getAdvSearch()));
}
}
else {
if (isPrev) {
queryString.append("select sum(AllPrice) as AllPrice from jsh_depotitem,jsh_depothead where jsh_depotitem.HeaderId = jsh_depothead.id and type='出库'");
queryString.append(" and DepotId='" + dId + "'");
queryString.append(" and MaterialId =" + MId + " and jsh_depothead.OperTime <'" + MonthTime + "-01 00:00:00' ");
query = this.getHibernateTemplate().getSessionFactory().getCurrentSession().createSQLQuery(queryString + SearchConditionUtil.getCondition(pageUtil.getAdvSearch()));
} else {
queryString.append("select sum(AllPrice) as AllPrice from jsh_depotitem,jsh_depothead where jsh_depotitem.HeaderId = jsh_depothead.id and type='出库'");
queryString.append(" and DepotId='" + dId + "'");
queryString.append(" and MaterialId =" + MId + " and jsh_depothead.OperTime >='" + MonthTime + "-01 00:00:00' and jsh_depothead.OperTime <='" + MonthTime + "-31 59:59:59' ");
query = this.getHibernateTemplate().getSessionFactory().getCurrentSession().createSQLQuery(queryString + SearchConditionUtil.getCondition(pageUtil.getAdvSearch()));
}
}
pageUtil.setTotalCount(query.list().size());
pageUtil.setPageList(query.list());
}
@SuppressWarnings("unchecked")
@Override
public void findByTypeAndMaterialId(PageUtil<DepotItem> pageUtil,String type,Long MId) throws JshException {
@@ -103,32 +144,6 @@ public class DepotItemDAO extends BaseDAO<DepotItem> implements DepotItemIDAO
}
pageUtil.setPageList(query.list());
}
@SuppressWarnings("unchecked")
@Override
public void findPriceByType(PageUtil<DepotItem> pageUtil,String type,Integer ProjectId,Long MId,String MonthTime,Boolean isPrev) throws JshException
{
//多表联查,多表连查此处用到了createSQLQuery可以随便写sql语句很方便
Query query;
StringBuffer queryString = new StringBuffer();
if (isPrev) {
queryString.append("select sum(AllPrice) as AllPrice from jsh_depotitem,jsh_depothead where jsh_depotitem.HeaderId = jsh_depothead.id and type='" + type + "'");
if (ProjectId != null) {
queryString.append(" and DepotId='" + ProjectId + "'");
}
queryString.append(" and MaterialId =" + MId + " and jsh_depothead.OperTime <'" + MonthTime + "-01 00:00:00' ");
query = this.getHibernateTemplate().getSessionFactory().getCurrentSession().createSQLQuery(queryString + SearchConditionUtil.getCondition(pageUtil.getAdvSearch()));
} else {
queryString.append("select sum(AllPrice) as AllPrice from jsh_depotitem,jsh_depothead where jsh_depotitem.HeaderId = jsh_depothead.id and type='" + type + "'");
if (ProjectId != null) {
queryString.append(" and DepotId='" + ProjectId + "'");
}
queryString.append(" and MaterialId =" + MId + " and jsh_depothead.OperTime >='" + MonthTime + "-01 00:00:00' and jsh_depothead.OperTime <='" + MonthTime + "-31 59:59:59' ");
query = this.getHibernateTemplate().getSessionFactory().getCurrentSession().createSQLQuery(queryString + SearchConditionUtil.getCondition(pageUtil.getAdvSearch()));
}
pageUtil.setTotalCount(query.list().size());
pageUtil.setPageList(query.list());
}
@SuppressWarnings("unchecked")
@Override