更新库存状况报表的数据(优化)
This commit is contained in:
@@ -61,6 +61,47 @@ public class DepotItemDAO extends BaseDAO<DepotItem> implements DepotItemIDAO
|
|||||||
pageUtil.setPageList(query.list());
|
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")
|
@SuppressWarnings("unchecked")
|
||||||
@Override
|
@Override
|
||||||
public void findByTypeAndMaterialId(PageUtil<DepotItem> pageUtil,String type,Long MId) throws JshException {
|
public void findByTypeAndMaterialId(PageUtil<DepotItem> pageUtil,String type,Long MId) throws JshException {
|
||||||
@@ -104,32 +145,6 @@ public class DepotItemDAO extends BaseDAO<DepotItem> implements DepotItemIDAO
|
|||||||
pageUtil.setPageList(query.list());
|
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")
|
@SuppressWarnings("unchecked")
|
||||||
@Override
|
@Override
|
||||||
public void buyOrSale(PageUtil<DepotItem> pageUtil,String type, String subType,Long MId,String MonthTime, String sumType) throws JshException
|
public void buyOrSale(PageUtil<DepotItem> pageUtil,String type, String subType,Long MId,String MonthTime, String sumType) throws JshException
|
||||||
|
|||||||
Reference in New Issue
Block a user