Commit 5cc26a22 authored by 季圣华's avatar 季圣华
Browse files

更新后端,采用Springboot+mybatis

parent bb6f5528
package com.jsh.dao.basic;
import com.jsh.base.BaseIDAO;
import com.jsh.model.po.UserBusiness;
import com.jsh.util.JshException;
import com.jsh.util.PageUtil;
public interface UserBusinessIDAO extends BaseIDAO<UserBusiness> {
/*
* 测试hql语句
*/
void find(PageUtil<UserBusiness> pageUtil, String ceshi) throws JshException;
}
package com.jsh.dao.basic;
import com.jsh.base.BaseDAO;
import com.jsh.model.po.Basicuser;
public class UserDAO extends BaseDAO<Basicuser> implements UserIDAO {
/**
* 设置dao映射基类
*
* @return
*/
@Override
public Class<Basicuser> getEntityClass() {
return Basicuser.class;
}
}
package com.jsh.dao.basic;
import com.jsh.base.BaseIDAO;
import com.jsh.model.po.Basicuser;
public interface UserIDAO extends BaseIDAO<Basicuser> {
}
package com.jsh.dao.materials;
import com.jsh.base.BaseDAO;
import com.jsh.model.po.AccountHead;
import com.jsh.util.JshException;
import com.jsh.util.PageUtil;
import com.jsh.util.SearchConditionUtil;
import org.hibernate.Query;
/**
* @author alan
*/
public class AccountHeadDAO extends BaseDAO<AccountHead> implements AccountHeadIDAO {
/**
* 设置dao映射基类
*
* @return
*/
@Override
public Class<AccountHead> getEntityClass() {
return AccountHead.class;
}
@SuppressWarnings("unchecked")
@Override
public void find(PageUtil<AccountHead> 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()));
pageUtil.setTotalCount(query.list().size());
pageUtil.setPageList(query.list());
}
@SuppressWarnings("unchecked")
@Override
public void findAllMoney(PageUtil<AccountHead> pageUtil, Integer supplierId, String type, String mode) throws JshException {
Query query;
String modeName = "";
if (mode.equals("实际")) {
modeName = "ChangeAmount";
} else if (mode.equals("合计")) {
modeName = "TotalPrice";
}
query = this.getHibernateTemplate().getSessionFactory().getCurrentSession().createQuery("select sum(" + modeName + ") as allMoney from AccountHead accountHead where Type='" + type + "' and OrganId =" + supplierId + SearchConditionUtil.getCondition(pageUtil.getAdvSearch()));
pageUtil.setTotalCount(query.list().size());
pageUtil.setPageList(query.list());
}
}
package com.jsh.dao.materials;
import com.jsh.base.BaseIDAO;
import com.jsh.model.po.AccountHead;
import com.jsh.util.JshException;
import com.jsh.util.PageUtil;
public interface AccountHeadIDAO extends BaseIDAO<AccountHead> {
/*
* 获取MaxId
*/
void find(PageUtil<AccountHead> pageUtil, String maxid) throws JshException;
void findAllMoney(PageUtil<AccountHead> pageUtil, Integer supplierId, String type, String mode) throws JshException;
}
package com.jsh.dao.materials;
import com.jsh.base.BaseDAO;
import com.jsh.model.po.AccountItem;
public class AccountItemDAO extends BaseDAO<AccountItem> implements AccountItemIDAO {
/**
* 设置dao映射基类
*
* @return
*/
@Override
public Class<AccountItem> getEntityClass() {
return AccountItem.class;
}
}
package com.jsh.dao.materials;
import com.jsh.base.BaseIDAO;
import com.jsh.model.po.AccountItem;
public interface AccountItemIDAO extends BaseIDAO<AccountItem> {
}
package com.jsh.dao.materials;
import com.jsh.base.BaseDAO;
import com.jsh.model.po.DepotHead;
import com.jsh.util.JshException;
import com.jsh.util.PageUtil;
import com.jsh.util.SearchConditionUtil;
import org.hibernate.Query;
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());
}
@SuppressWarnings("unchecked")
@Override
public void findAllMoney(PageUtil<DepotHead> pageUtil, Integer supplierId, String type, String subType, String mode) throws JshException {
Query query;
String modeName = "";
if (mode.equals("实际")) {
modeName = "ChangeAmount";
} else if (mode.equals("合计")) {
modeName = "DiscountLastMoney";
}
query = this.getHibernateTemplate().getSessionFactory().getCurrentSession().createQuery("select sum(" + modeName + ") as allMoney from DepotHead depotHead where Type='" + type + "' and SubType = '" + subType + "' and OrganId =" + supplierId + SearchConditionUtil.getCondition(pageUtil.getAdvSearch()));
pageUtil.setTotalCount(query.list().size());
pageUtil.setPageList(query.list());
}
@SuppressWarnings("unchecked")
@Override
public void batchSetStatus(Boolean status, String depotHeadIDs) {
String sql = "update jsh_depothead d set d.Status=" + status + " where d.id in (" + depotHeadIDs + ")";
Query query = this.getHibernateTemplate().getSessionFactory().getCurrentSession().createSQLQuery(sql);
query.executeUpdate();
}
@Override
@SuppressWarnings("unchecked")
public void findInDetail(PageUtil pageUtil, String beginTime, String endTime, String type, Long pid, String dids, Long oId) 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'), concat(dh.SubType,dh.Type) as newType " +
"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.OperTime >='" + beginTime + "' and dh.OperTime <='" + endTime + "' ");
if (oId != null) {
queryString.append(" and dh.OrganId = " + oId);
}
if (pid != null) {
queryString.append(" and di.DepotId=" + pid);
} else {
queryString.append(" and di.DepotId in (" + dids + ")");
}
if (type != null && !type.equals("")) {
queryString.append(" and dh.Type='" + type + "'");
}
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());
}
@Override
@SuppressWarnings("unchecked")
public void findInOutMaterialCount(PageUtil pageUtil, String beginTime, String endTime, String type, Long pid, String dids, Long oId) throws JshException {
StringBuffer queryString = new StringBuffer();
queryString.append("select di.MaterialId, m.mName,m.Model,m.categoryName, ");
//数量汇总
queryString.append(" (select sum(jdi.BasicNumber) numSum from jsh_depothead jdh INNER JOIN jsh_depotitem jdi " +
"on jdh.id=jdi.HeaderId where jdi.MaterialId=di.MaterialId " +
" and jdh.type='" + type + "' and jdh.OperTime >='" + beginTime + "' and jdh.OperTime <='" + endTime + "'");
if (oId != null) {
queryString.append(" and jdh.OrganId = " + oId);
}
if (pid != null) {
queryString.append(" and jdi.DepotId=" + pid);
} else {
queryString.append(" and jdi.DepotId in (" + dids + ")");
}
queryString.append(" ) numSum, ");
//金额汇总
queryString.append(" (select sum(jdi.AllPrice) priceSum from jsh_depothead jdh INNER JOIN jsh_depotitem jdi " +
"on jdh.id=jdi.HeaderId where jdi.MaterialId=di.MaterialId " +
" and jdh.type='" + type + "' and jdh.OperTime >='" + beginTime + "' and jdh.OperTime <='" + endTime + "'");
if (oId != null) {
queryString.append(" and jdh.OrganId = " + oId);
}
if (pid != null) {
queryString.append(" and jdi.DepotId=" + pid);
} else {
queryString.append(" and jdi.DepotId in (" + dids + ")");
}
queryString.append(" ) priceSum ");
queryString.append(" 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 (oId != null) {
queryString.append(" and dh.OrganId = " + oId);
}
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());
}
@SuppressWarnings("unchecked")
public void findMaterialsListByHeaderId(PageUtil pageUtil, Long headerId) throws JshException {
StringBuffer queryString = new StringBuffer();
queryString.append("select group_concat(concat(jsh_material.`Name`,' ',jsh_material.Model)) as mName from jsh_depotitem inner join jsh_material " +
" on jsh_depotitem.MaterialId = jsh_material.Id where jsh_depotitem.HeaderId =" + headerId);
Query query = this.getHibernateTemplate().getSessionFactory().getCurrentSession().createSQLQuery(queryString + SearchConditionUtil.getCondition(pageUtil.getAdvSearch()));
pageUtil.setPageList(query.list());
}
@SuppressWarnings("unchecked")
public void findStatementAccount(PageUtil pageUtil, String beginTime, String endTime, Long organId, String supType) throws JshException {
StringBuffer queryString = new StringBuffer();
queryString.append("select dh.Number,concat(dh.SubType,dh.Type) as newType,dh.DiscountLastMoney,dh.ChangeAmount,s.supplier,date_format(dh.OperTime,'%Y-%m-%d %H:%i:%S') as oTime from jsh_depothead dh " +
"inner join jsh_supplier s on s.id=dh.OrganId where s.type='" + supType + "' and dh.SubType!='其它' " +
"and dh.OperTime >='" + beginTime + "' and dh.OperTime<='" + endTime + "' ");
if (organId != null && !organId.equals("")) {
queryString.append(" and dh.OrganId='" + organId + "' ");
}
queryString.append("UNION ALL " +
"select ah.BillNo,ah.Type as newType,ah.TotalPrice,ah.ChangeAmount,s.supplier,date_format(ah.BillTime,'%Y-%m-%d %H:%i:%S') as oTime from jsh_accounthead ah " +
"inner join jsh_supplier s on s.id=ah.OrganId where s.type='" + supType + "' " +
"and ah.BillTime >='" + beginTime + "' and ah.BillTime<='" + endTime + "' ");
if (organId != null && !organId.equals("")) {
queryString.append(" and ah.OrganId='" + organId + "' ");
}
queryString.append(" ORDER BY oTime");
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());
}
@Override
@SuppressWarnings("unchecked")
public void getHeaderIdByMaterial(PageUtil pageUtil, String materialParam, String depotIds) throws JshException {
StringBuffer queryString = new StringBuffer();
queryString.append("select dt.HeaderId from jsh_depotitem dt INNER JOIN jsh_material m on dt.MaterialId = m.Id where ( m.`Name` " +
" like '%" + materialParam + "%' or m.Model like '%" + materialParam + "%') ");
if (!depotIds.equals("")) {
queryString.append(" and dt.DepotId in (" + depotIds + ") ");
}
Query query = this.getHibernateTemplate().getSessionFactory().getCurrentSession().createSQLQuery(queryString + SearchConditionUtil.getCondition(pageUtil.getAdvSearch()));
pageUtil.setPageList(query.list());
}
}
package com.jsh.dao.materials;
import com.jsh.base.BaseIDAO;
import com.jsh.model.po.DepotHead;
import com.jsh.util.JshException;
import com.jsh.util.PageUtil;
public interface DepotHeadIDAO extends BaseIDAO<DepotHead> {
/*
* 获取MaxId
*/
void find(PageUtil<DepotHead> pageUtil, String maxid) throws JshException;
void findAllMoney(PageUtil<DepotHead> pageUtil, Integer supplierId, String type, String subType, String mode) throws JshException;
void batchSetStatus(Boolean status, String depotHeadIDs);
void findInDetail(PageUtil pageUtil, String beginTime, String endTime, String type, Long pid, String dids, Long oId) throws JshException;
void findInOutMaterialCount(PageUtil pageUtil, String beginTime, String endTime, String type, Long pid, String dids, Long oId) throws JshException;
void findMaterialsListByHeaderId(PageUtil pageUtil, Long headerId) throws JshException;
void findStatementAccount(PageUtil pageUtil, String beginTime, String endTime, Long organId, String supType) throws JshException;
void getHeaderIdByMaterial(PageUtil pageUtil, String materialParam, String depotIds) throws JshException;
}
package com.jsh.dao.materials;
import com.jsh.base.BaseDAO;
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<DepotItem> implements DepotItemIDAO {
private final static String TYPE = "入库";
private final static String SUM_TYPE = "Number";
private final static String IN = "in";
private final static String OUT = "out";
/**
* 设置dao映射基类
*
* @return
*/
@Override
public Class<DepotItem> getEntityClass() {
return DepotItem.class;
}
@SuppressWarnings("unchecked")
@Override
public void findByType(PageUtil<DepotItem> 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<DepotItem> 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.setPageList(query.list());
}
@SuppressWarnings("unchecked")
@Override
public void findByTypeAndMaterialId(PageUtil<DepotItem> 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<DepotItem> 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());
}
@SuppressWarnings("unchecked")
@Override
public void buyOrSale(PageUtil<DepotItem> 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());
}
@SuppressWarnings("unchecked")
@Override
public void findGiftByType(PageUtil<DepotItem> 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());
}
}
package com.jsh.dao.materials;
import com.jsh.base.BaseIDAO;
import com.jsh.model.po.DepotItem;
import com.jsh.util.JshException;
import com.jsh.util.PageUtil;
public interface DepotItemIDAO extends BaseIDAO<DepotItem> {
public void findByType(PageUtil<DepotItem> pageUtil, String type, Integer ProjectId, Long MId, String MonthTime, Boolean isPrev) throws JshException;
public void findByTypeAndMaterialId(PageUtil<DepotItem> pageUtil, String type, Long MId) throws JshException;
public void findDetailByTypeAndMaterialId(PageUtil<DepotItem> pageUtil, Long MId) throws JshException;
public void findPriceByType(PageUtil<DepotItem> pageUtil, String type, Integer ProjectId, Long MId, String MonthTime, Boolean isPrev) throws JshException;
public void buyOrSale(PageUtil<DepotItem> pageUtil, String type, String subType, Long MId, String MonthTime, String sumType) throws JshException;
public void findGiftByType(PageUtil<DepotItem> pageUtil, String subType, Integer ProjectId, Long MId, String type) throws JshException;
}
package com.jsh.dao.materials;
import com.jsh.base.BaseDAO;
import com.jsh.model.po.MaterialCategory;
public class MaterialCategoryDAO extends BaseDAO<MaterialCategory> implements MaterialCategoryIDAO {
/**
* 设置dao映射基类
*
* @return
*/
@Override
public Class<MaterialCategory> getEntityClass() {
return MaterialCategory.class;
}
}
package com.jsh.dao.materials;
import com.jsh.base.BaseIDAO;
import com.jsh.model.po.MaterialCategory;
public interface MaterialCategoryIDAO extends BaseIDAO<MaterialCategory> {
}
package com.jsh.dao.materials;
import com.jsh.base.BaseDAO;
import com.jsh.model.po.Material;
import com.jsh.util.JshException;
import com.jsh.util.PageUtil;
import com.jsh.util.SearchConditionUtil;
import org.hibernate.Query;
public class MaterialDAO extends BaseDAO<Material> implements MaterialIDAO {
/**
* 设置dao映射基类
*
* @return
*/
@Override
public Class<Material> getEntityClass() {
return Material.class;
}
@SuppressWarnings("unchecked")
@Override
public void batchSetEnable(Boolean enable, String supplierIDs) {
String sql = "update jsh_material m set m.enabled=" + enable + " where m.id in (" + supplierIDs + ")";
Query query = this.getHibernateTemplate().getSessionFactory().getCurrentSession().createSQLQuery(sql);
query.executeUpdate();
}
@SuppressWarnings("unchecked")
@Override
public void findUnitName(PageUtil<Material> pageUtil, Long mId) throws JshException {
//多表联查,多表连查,此处用到了createSQLQuery,可以随便写sql语句,很方便,
StringBuffer queryString = new StringBuffer();
queryString.append("select jsh_unit.UName from jsh_unit inner join jsh_material on UnitId=jsh_unit.id where jsh_material.id=" + mId);
Query query;
query = this.getHibernateTemplate().getSessionFactory().getCurrentSession().createSQLQuery(queryString + SearchConditionUtil.getCondition(pageUtil.getAdvSearch()));
pageUtil.setTotalCount(query.list().size());
pageUtil.setPageList(query.list());
}
}
package com.jsh.dao.materials;
import com.jsh.base.BaseIDAO;
import com.jsh.model.po.Material;
import com.jsh.util.JshException;
import com.jsh.util.PageUtil;
public interface MaterialIDAO extends BaseIDAO<Material> {
public void batchSetEnable(Boolean enable, String supplierIDs);
public void findUnitName(PageUtil<Material> pageUtil, Long mId) throws JshException;
}
package com.jsh.dao.materials;
import com.jsh.base.BaseDAO;
import com.jsh.model.po.MaterialProperty;
public class MaterialPropertyDAO extends BaseDAO<MaterialProperty> implements MaterialPropertyIDAO {
/**
* 设置dao映射基类
*
* @return
*/
@Override
public Class<MaterialProperty> getEntityClass() {
return MaterialProperty.class;
}
}
package com.jsh.dao.materials;
import com.jsh.base.BaseIDAO;
import com.jsh.model.po.MaterialProperty;
public interface MaterialPropertyIDAO extends BaseIDAO<MaterialProperty> {
}
package com.jsh.dao.materials;
import com.jsh.base.BaseDAO;
import com.jsh.model.po.Person;
public class PersonDAO extends BaseDAO<Person> implements PersonIDAO {
/**
* 设置dao映射基类
*
* @return
*/
@Override
public Class<Person> getEntityClass() {
return Person.class;
}
}
package com.jsh.dao.materials;
import com.jsh.base.BaseIDAO;
import com.jsh.model.po.Person;
public interface PersonIDAO extends BaseIDAO<Person> {
}
package com.jsh.erp;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.scheduling.annotation.EnableScheduling;
@SpringBootApplication
@MapperScan(basePackages = {"com.jsh.erp.datasource.mappers"})
@EnableScheduling
public class ErpApplication {
public static void main(String[] args) {
SpringApplication.run(ErpApplication.class, args);
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment