From 458409b4632ef145ff47bfbb4f899dd46e347bba Mon Sep 17 00:00:00 2001 From: AlanGao Date: Sat, 7 Apr 2018 13:09:49 +0800 Subject: [PATCH] format code --- .../com/jsh/dao/materials/AccountHeadDAO.java | 5 + .../com/jsh/dao/materials/DepotItemDAO.java | 308 +++++----- .../model/vo/materials/DepotHeadModel.java | 581 +++++++++--------- 3 files changed, 449 insertions(+), 445 deletions(-) diff --git a/src/main/java/com/jsh/dao/materials/AccountHeadDAO.java b/src/main/java/com/jsh/dao/materials/AccountHeadDAO.java index 1731bb97..cbd2f0c1 100644 --- a/src/main/java/com/jsh/dao/materials/AccountHeadDAO.java +++ b/src/main/java/com/jsh/dao/materials/AccountHeadDAO.java @@ -10,6 +10,9 @@ import com.jsh.model.po.UserBusiness; import com.jsh.util.PageUtil; import com.jsh.util.SearchConditionUtil; +/** + * @author alan + */ public class AccountHeadDAO extends BaseDAO implements AccountHeadIDAO { /** @@ -23,6 +26,7 @@ public class AccountHeadDAO extends BaseDAO implements AccountHeadI } @SuppressWarnings("unchecked") + @Override public void find(PageUtil pageUtil,String maxid) throws JshException { Query query = this.getHibernateTemplate().getSessionFactory().getCurrentSession().createQuery("select max(Id) as Id from AccountHead accountHead where 1=1 " + SearchConditionUtil.getCondition(pageUtil.getAdvSearch())); @@ -31,6 +35,7 @@ public class AccountHeadDAO extends BaseDAO implements AccountHeadI } @SuppressWarnings("unchecked") + @Override public void findAllMoney(PageUtil pageUtil, Integer supplierId, String type, String mode) throws JshException { Query query; diff --git a/src/main/java/com/jsh/dao/materials/DepotItemDAO.java b/src/main/java/com/jsh/dao/materials/DepotItemDAO.java index 0fc01531..8c29b634 100644 --- a/src/main/java/com/jsh/dao/materials/DepotItemDAO.java +++ b/src/main/java/com/jsh/dao/materials/DepotItemDAO.java @@ -1,188 +1,176 @@ package com.jsh.dao.materials; -import org.hibernate.Query; - import com.jsh.base.BaseDAO; -import com.jsh.util.JshException; -import com.jsh.model.po.DepotHead; import com.jsh.model.po.DepotItem; +import com.jsh.util.JshException; import com.jsh.util.PageUtil; import com.jsh.util.SearchConditionUtil; +import org.hibernate.Query; -public class DepotItemDAO extends BaseDAO implements DepotItemIDAO -{ - /** +public class DepotItemDAO extends BaseDAO implements DepotItemIDAO { + /** * 设置dao映射基类 + * * @return */ - @Override - public Class getEntityClass() - { + @Override + public Class getEntityClass() { return DepotItem.class; } + private final static String TYPE = "入库"; + @SuppressWarnings("unchecked") @Override - public void findByType(PageUtil 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(BasicNumber) as BasicNumber 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(BasicNumber) as BasicNumber 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(BasicNumber) as BasicNumber 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(BasicNumber) as BasicNumber 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())); - } - } + public void findByType(PageUtil pageUtil, String type, Integer dId, Long MId, String MonthTime, Boolean isPrev) throws JshException { + //多表联查,多表连查,此处用到了createSQLQuery,可以随便写sql语句,很方便 + Query query; + StringBuilder queryString = new StringBuilder(); + if (TYPE.equals(type)) { + if (isPrev) { + queryString.append("select sum(BasicNumber) as BasicNumber from jsh_depotitem di,jsh_depothead dh where di.HeaderId = dh.id "); + queryString.append(" and ((type='入库' and DepotId='").append(dId).append("') ").append(" or (SubType='调拨' and AnotherDepotId='").append(dId).append("') ").append(" or (SubType='礼品充值' and AnotherDepotId='").append(dId).append("')) "); + queryString.append(" and MaterialId =").append(MId).append(" and dh.OperTime <'").append(MonthTime).append("-01 00:00:00' "); + query = this.getHibernateTemplate().getSessionFactory().getCurrentSession().createSQLQuery(queryString + SearchConditionUtil.getCondition(pageUtil.getAdvSearch())); + } else { + queryString.append("select sum(BasicNumber) as BasicNumber from jsh_depotitem di,jsh_depothead dh where di.HeaderId = dh.id "); + queryString.append(" and ((type='入库' and DepotId='").append(dId).append("') ").append(" or (SubType='调拨' and AnotherDepotId='").append(dId).append("') ").append(" or (SubType='礼品充值' and AnotherDepotId='").append(dId).append("')) "); + queryString.append(" and MaterialId =").append(MId).append(" and dh.OperTime >='").append(MonthTime).append("-01 00:00:00' and dh.OperTime <='").append(MonthTime).append("-31 59:59:59' "); + query = this.getHibernateTemplate().getSessionFactory().getCurrentSession().createSQLQuery(queryString + SearchConditionUtil.getCondition(pageUtil.getAdvSearch())); + } + } else { + if (isPrev) { + queryString.append("select sum(BasicNumber) as BasicNumber from jsh_depotitem,jsh_depothead where jsh_depotitem.HeaderId = jsh_depothead.id and type='出库'"); + queryString.append(" and DepotId='").append(dId).append("'"); + queryString.append(" and MaterialId =").append(MId).append(" and jsh_depothead.OperTime <'").append(MonthTime).append("-01 00:00:00' "); + query = this.getHibernateTemplate().getSessionFactory().getCurrentSession().createSQLQuery(queryString + SearchConditionUtil.getCondition(pageUtil.getAdvSearch())); + } else { + queryString.append("select sum(BasicNumber) as BasicNumber from jsh_depotitem,jsh_depothead where jsh_depotitem.HeaderId = jsh_depothead.id and type='出库'"); + queryString.append(" and DepotId='").append(dId).append("'"); + queryString.append(" and MaterialId =").append(MId).append(" and jsh_depothead.OperTime >='").append(MonthTime).append("-01 00:00:00' and jsh_depothead.OperTime <='").append(MonthTime).append("-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 findPriceByType(PageUtil 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 pageUtil,String type,Long MId) throws JshException { - //多表联查,多表连查,此处用到了createSQLQuery,可以随便写sql语句,很方便 - Query query; - StringBuffer queryString = new StringBuffer(); - if(type.equals("入库")) { - queryString.append("select sum(BasicNumber) as BasicNumber from jsh_depothead dh INNER JOIN jsh_depotitem di on dh.id=di.HeaderId where type='入库'"); - queryString.append(" and MaterialId ="+ MId); - query = this.getHibernateTemplate().getSessionFactory().getCurrentSession().createSQLQuery(queryString + SearchConditionUtil.getCondition(pageUtil.getAdvSearch())); - } - else { - queryString.append("select sum(BasicNumber) as BasicNumber from jsh_depothead dh INNER JOIN jsh_depotitem di on dh.id=di.HeaderId where type='出库'"); - queryString.append(" and SubType!='调拨' and SubType!='礼品充值' and MaterialId ="+ MId); - 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 findDetailByTypeAndMaterialId(PageUtil pageUtil,Long MId) throws JshException { - //多表联查,多表连查,此处用到了createSQLQuery,可以随便写sql语句,很方便 - Query query; - StringBuffer queryString = new StringBuffer(); - queryString.append("select dh.Number,concat(dh.SubType,dh.Type) as newType, " + - "case when type='入库' then di.BasicNumber when type='出库' then 0-di.BasicNumber else 0 end as b_num, " + - "date_format(dh.OperTime,'%Y-%m-%d %H:%i:%S') as oTime " + - "from jsh_depothead dh INNER JOIN jsh_depotitem di on dh.id=di.HeaderId where type!='其它' " + - "and SubType!='调拨' and SubType!='礼品充值' "); - queryString.append(" and MaterialId ="+ MId +" ORDER BY oTime desc "); - 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") @Override - public void buyOrSale(PageUtil pageUtil,String type, String subType,Long MId,String MonthTime, String sumType) throws JshException - { - //多表联查,多表连查,此处用到了createSQLQuery,可以随便写sql语句,很方便 - Query query; - if(sumType.equals("Number")) { - query = this.getHibernateTemplate().getSessionFactory().getCurrentSession().createSQLQuery("select sum(BasicNumber) as BasicNumber from jsh_depotitem,jsh_depothead where jsh_depotitem.HeaderId = jsh_depothead.id and type='" + type +"' and subType='" + subType +"' and MaterialId ="+ MId + " and jsh_depothead.OperTime >='"+ MonthTime +"-01 00:00:00' and jsh_depothead.OperTime <='"+ MonthTime +"-31 59:59:59' " + SearchConditionUtil.getCondition(pageUtil.getAdvSearch())); - } - else { - query = this.getHibernateTemplate().getSessionFactory().getCurrentSession().createSQLQuery("select sum(AllPrice) as AllPrice from jsh_depotitem,jsh_depothead where jsh_depotitem.HeaderId = jsh_depothead.id and type='" + type +"' and subType='" + subType +"' and MaterialId ="+ MId + " and jsh_depothead.OperTime >='"+ MonthTime +"-01 00:00:00' and jsh_depothead.OperTime <='"+ MonthTime +"-31 59:59:59' " + SearchConditionUtil.getCondition(pageUtil.getAdvSearch())); + public void findPriceByType(PageUtil pageUtil, String type, Integer dId, Long MId, String MonthTime, Boolean isPrev) throws JshException { + //多表联查,多表连查,此处用到了createSQLQuery,可以随便写sql语句,很方便 + Query query; + StringBuilder queryString = new StringBuilder(); + if (TYPE.equals(type)) { + 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='").append(dId).append("') ").append(" or (SubType='调拨' and AnotherDepotId='").append(dId).append("') ").append(" or (SubType='礼品充值' and AnotherDepotId='").append(dId).append("')) "); + queryString.append(" and MaterialId =").append(MId).append(" and dh.OperTime <'").append(MonthTime).append("-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='").append(dId).append("') ").append(" or (SubType='调拨' and AnotherDepotId='").append(dId).append("') ").append(" or (SubType='礼品充值' and AnotherDepotId='").append(dId).append("')) "); + queryString.append(" and MaterialId =").append(MId).append(" and dh.OperTime >='").append(MonthTime).append("-01 00:00:00' and dh.OperTime <='").append(MonthTime).append("-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='").append(dId).append("'"); + queryString.append(" and MaterialId =").append(MId).append(" and jsh_depothead.OperTime <'").append(MonthTime).append("-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='").append(dId).append("'"); + queryString.append(" and MaterialId =").append(MId).append(" and jsh_depothead.OperTime >='").append(MonthTime).append("-01 00:00:00' and jsh_depothead.OperTime <='").append(MonthTime).append("-31 59:59:59' "); + query = this.getHibernateTemplate().getSessionFactory().getCurrentSession().createSQLQuery(queryString + SearchConditionUtil.getCondition(pageUtil.getAdvSearch())); + } } - pageUtil.setTotalCount(query.list().size()); + pageUtil.setTotalCount(query.list().size()); pageUtil.setPageList(query.list()); } - @SuppressWarnings("unchecked") - @Override - public void findGiftByType(PageUtil pageUtil,String subType,Integer ProjectId,Long MId,String type) throws JshException - { - //多表联查,多表连查,此处用到了createSQLQuery,可以随便写sql语句,很方便 - Query query; - StringBuffer queryString = new StringBuffer(); - queryString.append("select sum(BasicNumber) as BasicNumber from jsh_depotitem,jsh_depothead where jsh_depotitem.HeaderId = jsh_depothead.id and jsh_depothead.SubType='" + subType +"'"); - if(ProjectId!=null) { - if(type.equals("in")){ - queryString.append(" and jsh_depotitem.AnotherDepotId='" + ProjectId +"'"); //礼品充值时 - } - else if(type.equals("out")){ - queryString.append(" and jsh_depotitem.DepotId='" + ProjectId +"'"); - } - } - queryString.append(" and jsh_depotitem.MaterialId ="+ MId); - 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 pageUtil, String type, Long MId) throws JshException { + //多表联查,多表连查,此处用到了createSQLQuery,可以随便写sql语句,很方便 + Query query; + StringBuilder queryString = new StringBuilder(); + if (TYPE.equals(type)) { + queryString.append("select sum(BasicNumber) as BasicNumber from jsh_depothead dh INNER JOIN jsh_depotitem di on dh.id=di.HeaderId where type='入库'"); + queryString.append(" and MaterialId =").append(MId); + query = this.getHibernateTemplate().getSessionFactory().getCurrentSession().createSQLQuery(queryString + SearchConditionUtil.getCondition(pageUtil.getAdvSearch())); + } else { + queryString.append("select sum(BasicNumber) as BasicNumber from jsh_depothead dh INNER JOIN jsh_depotitem di on dh.id=di.HeaderId where type='出库'"); + queryString.append(" and SubType!='调拨' and SubType!='礼品充值' and MaterialId =").append(MId); + 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 findDetailByTypeAndMaterialId(PageUtil pageUtil, Long MId) throws JshException { + //多表联查,多表连查,此处用到了createSQLQuery,可以随便写sql语句,很方便 + Query query; + StringBuilder queryString = new StringBuilder(); + queryString.append("select dh.Number,concat(dh.SubType,dh.Type) as newType, " + + "case when type='入库' then di.BasicNumber when type='出库' then 0-di.BasicNumber else 0 end as b_num, " + + "date_format(dh.OperTime,'%Y-%m-%d %H:%i:%S') as oTime " + + "from jsh_depothead dh INNER JOIN jsh_depotitem di on dh.id=di.HeaderId where type!='其它' " + + "and SubType!='调拨' and SubType!='礼品充值' "); + queryString.append(" and MaterialId =").append(MId).append(" ORDER BY oTime desc "); + 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()); + } + + private final static String SUM_TYPE = "Number"; + + @SuppressWarnings("unchecked") + @Override + public void buyOrSale(PageUtil pageUtil, String type, String subType, Long MId, String MonthTime, String sumType) throws JshException { + //多表联查,多表连查,此处用到了createSQLQuery,可以随便写sql语句,很方便 + Query query; + if (SUM_TYPE.equals(sumType)) { + query = this.getHibernateTemplate().getSessionFactory().getCurrentSession().createSQLQuery("select sum(BasicNumber) as BasicNumber from jsh_depotitem,jsh_depothead where jsh_depotitem.HeaderId = jsh_depothead.id and type='" + type + "' and subType='" + subType + "' and MaterialId =" + MId + " and jsh_depothead.OperTime >='" + MonthTime + "-01 00:00:00' and jsh_depothead.OperTime <='" + MonthTime + "-31 59:59:59' " + SearchConditionUtil.getCondition(pageUtil.getAdvSearch())); + } else { + query = this.getHibernateTemplate().getSessionFactory().getCurrentSession().createSQLQuery("select sum(AllPrice) as AllPrice from jsh_depotitem,jsh_depothead where jsh_depotitem.HeaderId = jsh_depothead.id and type='" + type + "' and subType='" + subType + "' and MaterialId =" + MId + " and jsh_depothead.OperTime >='" + MonthTime + "-01 00:00:00' and jsh_depothead.OperTime <='" + MonthTime + "-31 59:59:59' " + SearchConditionUtil.getCondition(pageUtil.getAdvSearch())); + } + pageUtil.setTotalCount(query.list().size()); + pageUtil.setPageList(query.list()); + } + + private final static String IN = "in"; + private final static String OUT = "out"; + + @SuppressWarnings("unchecked") + @Override + public void findGiftByType(PageUtil pageUtil, String subType, Integer ProjectId, Long MId, String type) throws JshException { + //多表联查,多表连查,此处用到了createSQLQuery,可以随便写sql语句,很方便 + Query query; + StringBuilder queryString = new StringBuilder(); + queryString.append("select sum(BasicNumber) as BasicNumber from jsh_depotitem,jsh_depothead where jsh_depotitem.HeaderId = jsh_depothead.id and jsh_depothead.SubType='").append(subType).append("'"); + if (ProjectId != null) { + if (IN.equals(type)) { + queryString.append(" and jsh_depotitem.AnotherDepotId='").append(ProjectId).append("'"); //礼品充值时 + } else if (OUT.equals(type)) { + queryString.append(" and jsh_depotitem.DepotId='").append(ProjectId).append("'"); + } + } + queryString.append(" and jsh_depotitem.MaterialId =").append(MId); + query = this.getHibernateTemplate().getSessionFactory().getCurrentSession().createSQLQuery(queryString + SearchConditionUtil.getCondition(pageUtil.getAdvSearch())); + pageUtil.setTotalCount(query.list().size()); + pageUtil.setPageList(query.list()); + } } diff --git a/src/main/java/com/jsh/model/vo/materials/DepotHeadModel.java b/src/main/java/com/jsh/model/vo/materials/DepotHeadModel.java index 54c7a577..c5a9ee59 100644 --- a/src/main/java/com/jsh/model/vo/materials/DepotHeadModel.java +++ b/src/main/java/com/jsh/model/vo/materials/DepotHeadModel.java @@ -2,392 +2,403 @@ package com.jsh.model.vo.materials; import java.io.Serializable; +/** + * @author alan + */ @SuppressWarnings("serial") -public class DepotHeadModel implements Serializable -{ +public class DepotHeadModel implements Serializable { private DepotHeadShowModel showModel = new DepotHeadShowModel(); - /**======开始接受页面参数=================**/ - private String Type = ""; - private String SubType = ""; - private Long ProjectId; - private String DepotIds = ""; - private String DefaultNumber = ""; - private String Number = ""; - private String OperPersonName = ""; - private String OperTime; - private Long OrganId; - private Long HandsPersonId; - private Long AccountId; - private Double ChangeAmount; - private Long AllocationProjectId; - private Double TotalPrice; - private String PayType = ""; - private String Remark = ""; + /** + * ======开始接受页面参数================= + **/ + private String Type = ""; + private String SubType = ""; + private Long ProjectId; + private String DepotIds = ""; + private String DefaultNumber = ""; + private String Number = ""; + private String OperPersonName = ""; + private String OperTime; + private Long OrganId; + private Long HandsPersonId; + private Long AccountId; + private Double ChangeAmount; + private Long AllocationProjectId; + private Double TotalPrice; + private String PayType = ""; + private String Remark = ""; - private String Salesman; - private String AccountIdList; - private String AccountMoneyList; - private Double Discount; - private Double DiscountMoney; - private Double DiscountLastMoney; - private Double OtherMoney; - private String OtherMoneyList; - private String OtherMoneyItem; - private Integer AccountDay; - private Boolean Status = false; //单据状态 - - private String BeginTime; //查询开始时间 - private String EndTime; //查询结束时间 - private String MonthTime; //查询月份 - - private String supplierId; //单位Id,用于查询单位的应收应付 - private String MaterialParam; //商品参数 - private String dhIds; //单据id列表 - private String supType; //单位类型,客户、供应商 + private String Salesman; + private String AccountIdList; + private String AccountMoneyList; + private Double Discount; + private Double DiscountMoney; + private Double DiscountLastMoney; + private Double OtherMoney; + private String OtherMoneyList; + private String OtherMoneyItem; + private Integer AccountDay; + //单据状态 + private Boolean Status = false; + //查询开始时间 + private String BeginTime; + //查询结束时间 + private String EndTime; + //查询月份 + private String MonthTime; + //单位Id,用于查询单位的应收应付 + private String supplierId; + //商品参数 + private String MaterialParam; + //单据id列表 + private String dhIds; + //单位类型,客户、供应商 + private String supType; - /** + + /** * 分类ID */ - private Long depotHeadID = 0l; - + private Long depotHeadID = 0L; + /** * 分类IDs 批量操作使用 */ private String depotHeadIDs = ""; - + /** * 每页显示的个数 */ private int pageSize = 10; - + /** * 当前页码 */ private int pageNo = 1; - + /** * 用户IP,用户记录操作日志 */ private String clientIp = ""; - public DepotHeadShowModel getShowModel() { - return showModel; - } + public DepotHeadShowModel getShowModel() { + return showModel; + } - public void setShowModel(DepotHeadShowModel showModel) { - this.showModel = showModel; - } + public void setShowModel(DepotHeadShowModel showModel) { + this.showModel = showModel; + } - public String getType() { - return Type; - } + public String getType() { + return Type; + } - public void setType(String type) { - Type = type; - } + public void setType(String type) { + Type = type; + } - public String getSubType() { - return SubType; - } + public String getSubType() { + return SubType; + } - public void setSubType(String subType) { - SubType = subType; - } + public void setSubType(String subType) { + SubType = subType; + } - public Long getProjectId() { - return ProjectId; - } + public Long getProjectId() { + return ProjectId; + } - public void setProjectId(Long projectId) { - ProjectId = projectId; - } + public void setProjectId(Long projectId) { + ProjectId = projectId; + } - public String getDepotIds() { - return DepotIds; - } + public String getDepotIds() { + return DepotIds; + } - public void setDepotIds(String depotIds) { - DepotIds = depotIds; - } + public void setDepotIds(String depotIds) { + DepotIds = depotIds; + } - public String getDefaultNumber() { - return DefaultNumber; - } + public String getDefaultNumber() { + return DefaultNumber; + } - public void setDefaultNumber(String defaultNumber) { - DefaultNumber = defaultNumber; - } + public void setDefaultNumber(String defaultNumber) { + DefaultNumber = defaultNumber; + } - public String getNumber() { - return Number; - } + public String getNumber() { + return Number; + } - public void setNumber(String number) { - Number = number; - } + public void setNumber(String number) { + Number = number; + } - public String getOperPersonName() { - return OperPersonName; - } + public String getOperPersonName() { + return OperPersonName; + } - public void setOperPersonName(String operPersonName) { - OperPersonName = operPersonName; - } + public void setOperPersonName(String operPersonName) { + OperPersonName = operPersonName; + } - public Long getOrganId() { - return OrganId; - } + public Long getOrganId() { + return OrganId; + } - public void setOrganId(Long organId) { - OrganId = organId; - } + public void setOrganId(Long organId) { + OrganId = organId; + } - public Long getHandsPersonId() { - return HandsPersonId; - } + public Long getHandsPersonId() { + return HandsPersonId; + } - public void setHandsPersonId(Long handsPersonId) { - HandsPersonId = handsPersonId; - } + public void setHandsPersonId(Long handsPersonId) { + HandsPersonId = handsPersonId; + } - public Long getAccountId() { - return AccountId; - } + public Long getAccountId() { + return AccountId; + } - public void setAccountId(Long accountId) { - AccountId = accountId; - } + public void setAccountId(Long accountId) { + AccountId = accountId; + } - public Double getChangeAmount() { - return ChangeAmount; - } + public Double getChangeAmount() { + return ChangeAmount; + } - public void setChangeAmount(Double changeAmount) { - ChangeAmount = changeAmount; - } + public void setChangeAmount(Double changeAmount) { + ChangeAmount = changeAmount; + } - public Long getAllocationProjectId() { - return AllocationProjectId; - } + public Long getAllocationProjectId() { + return AllocationProjectId; + } - public void setAllocationProjectId(Long allocationProjectId) { - AllocationProjectId = allocationProjectId; - } + public void setAllocationProjectId(Long allocationProjectId) { + AllocationProjectId = allocationProjectId; + } - public Double getTotalPrice() { - return TotalPrice; - } + public Double getTotalPrice() { + return TotalPrice; + } - public void setTotalPrice(Double totalPrice) { - TotalPrice = totalPrice; - } + public void setTotalPrice(Double totalPrice) { + TotalPrice = totalPrice; + } - public String getPayType() { - return PayType; - } + public String getPayType() { + return PayType; + } - public void setPayType(String payType) { - PayType = payType; - } + public void setPayType(String payType) { + PayType = payType; + } - public String getRemark() { - return Remark; - } + public String getRemark() { + return Remark; + } - public void setRemark(String remark) { - Remark = remark; - } + public void setRemark(String remark) { + Remark = remark; + } - public Long getDepotHeadID() { - return depotHeadID; - } + public Long getDepotHeadID() { + return depotHeadID; + } - public void setDepotHeadID(Long depotHeadID) { - this.depotHeadID = depotHeadID; - } + public void setDepotHeadID(Long depotHeadID) { + this.depotHeadID = depotHeadID; + } - public String getDepotHeadIDs() { - return depotHeadIDs; - } + public String getDepotHeadIDs() { + return depotHeadIDs; + } - public void setDepotHeadIDs(String depotHeadIDs) { - this.depotHeadIDs = depotHeadIDs; - } + public void setDepotHeadIDs(String depotHeadIDs) { + this.depotHeadIDs = depotHeadIDs; + } - public int getPageSize() { - return pageSize; - } + public int getPageSize() { + return pageSize; + } - public void setPageSize(int pageSize) { - this.pageSize = pageSize; - } + public void setPageSize(int pageSize) { + this.pageSize = pageSize; + } - public int getPageNo() { - return pageNo; - } + public int getPageNo() { + return pageNo; + } - public void setPageNo(int pageNo) { - this.pageNo = pageNo; - } + public void setPageNo(int pageNo) { + this.pageNo = pageNo; + } - public String getClientIp() { - return clientIp; - } + public String getClientIp() { + return clientIp; + } - public void setClientIp(String clientIp) { - this.clientIp = clientIp; - } + public void setClientIp(String clientIp) { + this.clientIp = clientIp; + } - public String getBeginTime() { - return BeginTime; - } + public String getBeginTime() { + return BeginTime; + } - public void setBeginTime(String beginTime) { - BeginTime = beginTime; - } + public void setBeginTime(String beginTime) { + BeginTime = beginTime; + } - public String getEndTime() { - return EndTime; - } + public String getEndTime() { + return EndTime; + } - public void setEndTime(String endTime) { - EndTime = endTime; - } + public void setEndTime(String endTime) { + EndTime = endTime; + } - public String getOperTime() { - return OperTime; - } + public String getOperTime() { + return OperTime; + } - public void setOperTime(String operTime) { - OperTime = operTime; - } + public void setOperTime(String operTime) { + OperTime = operTime; + } - public String getMonthTime() { - return MonthTime; - } + public String getMonthTime() { + return MonthTime; + } - public void setMonthTime(String monthTime) { - MonthTime = monthTime; - } + public void setMonthTime(String monthTime) { + MonthTime = monthTime; + } - public String getSupplierId() { - return supplierId; - } + public String getSupplierId() { + return supplierId; + } - public void setSupplierId(String supplierId) { - this.supplierId = supplierId; - } + public void setSupplierId(String supplierId) { + this.supplierId = supplierId; + } - public String getSalesman() { - return Salesman; - } + public String getSalesman() { + return Salesman; + } - public void setSalesman(String salesman) { - Salesman = salesman; - } + public void setSalesman(String salesman) { + Salesman = salesman; + } - public String getAccountIdList() { - return AccountIdList; - } + public String getAccountIdList() { + return AccountIdList; + } - public void setAccountIdList(String accountIdList) { - AccountIdList = accountIdList; - } + public void setAccountIdList(String accountIdList) { + AccountIdList = accountIdList; + } - public String getAccountMoneyList() { - return AccountMoneyList; - } + public String getAccountMoneyList() { + return AccountMoneyList; + } - public void setAccountMoneyList(String accountMoneyList) { - AccountMoneyList = accountMoneyList; - } + public void setAccountMoneyList(String accountMoneyList) { + AccountMoneyList = accountMoneyList; + } - public Double getDiscount() { - return Discount; - } + public Double getDiscount() { + return Discount; + } - public void setDiscount(Double discount) { - Discount = discount; - } + public void setDiscount(Double discount) { + Discount = discount; + } - public Double getDiscountMoney() { - return DiscountMoney; - } + public Double getDiscountMoney() { + return DiscountMoney; + } - public void setDiscountMoney(Double discountMoney) { - DiscountMoney = discountMoney; - } + public void setDiscountMoney(Double discountMoney) { + DiscountMoney = discountMoney; + } - public Double getDiscountLastMoney() { - return DiscountLastMoney; - } + public Double getDiscountLastMoney() { + return DiscountLastMoney; + } - public void setDiscountLastMoney(Double discountLastMoney) { - DiscountLastMoney = discountLastMoney; - } + public void setDiscountLastMoney(Double discountLastMoney) { + DiscountLastMoney = discountLastMoney; + } - public Double getOtherMoney() { - return OtherMoney; - } + public Double getOtherMoney() { + return OtherMoney; + } - public void setOtherMoney(Double otherMoney) { - OtherMoney = otherMoney; - } + public void setOtherMoney(Double otherMoney) { + OtherMoney = otherMoney; + } - public String getOtherMoneyList() { - return OtherMoneyList; - } + public String getOtherMoneyList() { + return OtherMoneyList; + } - public void setOtherMoneyList(String otherMoneyList) { - OtherMoneyList = otherMoneyList; - } + public void setOtherMoneyList(String otherMoneyList) { + OtherMoneyList = otherMoneyList; + } - public String getOtherMoneyItem() { - return OtherMoneyItem; - } + public String getOtherMoneyItem() { + return OtherMoneyItem; + } - public void setOtherMoneyItem(String otherMoneyItem) { - OtherMoneyItem = otherMoneyItem; - } + public void setOtherMoneyItem(String otherMoneyItem) { + OtherMoneyItem = otherMoneyItem; + } - public Integer getAccountDay() { - return AccountDay; - } + public Integer getAccountDay() { + return AccountDay; + } - public void setAccountDay(Integer accountDay) { - AccountDay = accountDay; - } + public void setAccountDay(Integer accountDay) { + AccountDay = accountDay; + } - public Boolean getStatus() { - return Status; - } + public Boolean getStatus() { + return Status; + } - public void setStatus(Boolean status) { - Status = status; - } + public void setStatus(Boolean status) { + Status = status; + } - public String getMaterialParam() { - return MaterialParam; - } + public String getMaterialParam() { + return MaterialParam; + } - public void setMaterialParam(String materialParam) { - MaterialParam = materialParam; - } + public void setMaterialParam(String materialParam) { + MaterialParam = materialParam; + } - public String getDhIds() { - return dhIds; - } + public String getDhIds() { + return dhIds; + } - public void setDhIds(String dhIds) { - this.dhIds = dhIds; - } + public void setDhIds(String dhIds) { + this.dhIds = dhIds; + } - public String getSupType() { - return supType; - } + public String getSupType() { + return supType; + } - public void setSupType(String supType) { - this.supType = supType; - } + public void setSupType(String supType) { + this.supType = supType; + } }