更新后端代码
This commit is contained in:
@@ -2,7 +2,7 @@ package com.jsh.dao.basic;
|
||||
|
||||
import com.jsh.base.BaseDAO;
|
||||
import com.jsh.model.po.Supplier;
|
||||
import com.jsh.util.PageUtil;
|
||||
import com.jsh.util.JshException;
|
||||
import com.jsh.util.SearchConditionUtil;
|
||||
import org.hibernate.Query;
|
||||
|
||||
@@ -18,4 +18,11 @@ public class SupplierDAO extends BaseDAO<Supplier> implements SupplierIDAO
|
||||
return Supplier.class;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public void batchSetEnable(Boolean enable,String supplierIDs) {
|
||||
String sql="update jsh_supplier s set s.enabled=" + enable + " where s.id in (" + supplierIDs + ")";
|
||||
Query query = this.getHibernateTemplate().getSessionFactory().getCurrentSession().createSQLQuery(sql);
|
||||
query.executeUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,4 +5,5 @@ import com.jsh.model.po.Supplier;
|
||||
|
||||
public interface SupplierIDAO extends BaseIDAO<Supplier>
|
||||
{
|
||||
public void batchSetEnable(Boolean enable,String supplierIDs);
|
||||
}
|
||||
|
||||
17
src/main/java/com/jsh/dao/basic/UnitDAO.java
Normal file
17
src/main/java/com/jsh/dao/basic/UnitDAO.java
Normal file
@@ -0,0 +1,17 @@
|
||||
package com.jsh.dao.basic;
|
||||
|
||||
import com.jsh.base.BaseDAO;
|
||||
import com.jsh.model.po.Unit;
|
||||
|
||||
public class UnitDAO extends BaseDAO<Unit> implements UnitIDAO
|
||||
{
|
||||
/**
|
||||
* 设置dao映射基类
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Class<Unit> getEntityClass()
|
||||
{
|
||||
return Unit.class;
|
||||
}
|
||||
}
|
||||
9
src/main/java/com/jsh/dao/basic/UnitIDAO.java
Normal file
9
src/main/java/com/jsh/dao/basic/UnitIDAO.java
Normal file
@@ -0,0 +1,9 @@
|
||||
package com.jsh.dao.basic;
|
||||
|
||||
import com.jsh.base.BaseIDAO;
|
||||
import com.jsh.model.po.Unit;
|
||||
|
||||
public interface UnitIDAO extends BaseIDAO<Unit>
|
||||
{
|
||||
|
||||
}
|
||||
@@ -5,12 +5,10 @@ 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.UserBusiness;
|
||||
import com.jsh.util.PageUtil;
|
||||
import com.jsh.util.SearchConditionUtil;
|
||||
|
||||
public class DepotHeadDAO extends BaseDAO<DepotHead> implements DepotHeadIDAO
|
||||
{
|
||||
public class DepotHeadDAO extends BaseDAO<DepotHead> implements DepotHeadIDAO {
|
||||
/**
|
||||
* 设置dao映射基类
|
||||
* @return
|
||||
@@ -46,67 +44,10 @@ public class DepotHeadDAO extends BaseDAO<DepotHead> implements DepotHeadIDAO
|
||||
}
|
||||
|
||||
@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=dh.ProjectId " +
|
||||
"where dh.Type='"+ type +"' and dh.OperTime >='"+ beginTime +"' and dh.OperTime <='"+ endTime +"' ");
|
||||
if(pid!=null){
|
||||
queryString.append(" and dh.ProjectId=" + pid );
|
||||
}
|
||||
else {
|
||||
queryString.append(" and dh.ProjectId 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 dh.ProjectId=" + pid );
|
||||
}
|
||||
else {
|
||||
queryString.append(" and dh.ProjectId 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 dh.ProjectId=" + pid );
|
||||
}
|
||||
else {
|
||||
queryString.append(" and dh.ProjectId 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());
|
||||
@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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,8 +15,6 @@ public interface DepotHeadIDAO extends BaseIDAO<DepotHead>
|
||||
|
||||
void findAllMoney(PageUtil<DepotHead> pageUtil, Integer supplierId, String type, String subType, String mode) throws JshException;
|
||||
|
||||
public void findInDetail(PageUtil pageUtil,String beginTime,String endTime,String type,Long pid,String dids) throws JshException;
|
||||
|
||||
public void findInOutMaterialCount(PageUtil pageUtil,String beginTime,String endTime,String type,Long pid,String dids) throws JshException;
|
||||
public void batchSetStatus(Boolean status,String depotHeadIDs);
|
||||
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ public class DepotItemDAO extends BaseDAO<DepotItem> implements DepotItemIDAO
|
||||
{
|
||||
return DepotItem.class;
|
||||
}
|
||||
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public void findByType(PageUtil<DepotItem> pageUtil,String type,Integer ProjectId,Long MId,String MonthTime,Boolean isPrev) throws JshException
|
||||
@@ -29,19 +29,19 @@ public class DepotItemDAO extends BaseDAO<DepotItem> implements DepotItemIDAO
|
||||
Query query;
|
||||
StringBuffer queryString = new StringBuffer();
|
||||
if(isPrev) {
|
||||
queryString.append("select sum(OperNumber) as OperNumber from jsh_depotitem,jsh_depothead where jsh_depotitem.HeaderId = jsh_depothead.id and type='" + type +"'");
|
||||
queryString.append("select sum(BasicNumber) as BasicNumber from jsh_depotitem,jsh_depothead where jsh_depotitem.HeaderId = jsh_depothead.id and type='" + type +"'");
|
||||
if(ProjectId!=null) {
|
||||
queryString.append(" and ProjectId='" + ProjectId +"'");
|
||||
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(OperNumber) as OperNumber from jsh_depotitem,jsh_depothead where jsh_depotitem.HeaderId = jsh_depothead.id and type='" + type +"'");
|
||||
queryString.append("select sum(BasicNumber) as BasicNumber from jsh_depotitem,jsh_depothead where jsh_depotitem.HeaderId = jsh_depothead.id and type='" + type +"'");
|
||||
if(ProjectId!=null) {
|
||||
queryString.append(" and ProjectId='" + ProjectId +"'");
|
||||
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 00:00:00' ");
|
||||
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());
|
||||
@@ -58,16 +58,16 @@ public class DepotItemDAO extends BaseDAO<DepotItem> implements DepotItemIDAO
|
||||
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 ProjectId='" + ProjectId + "'");
|
||||
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 ProjectId='" + ProjectId + "'");
|
||||
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 00:00:00' ");
|
||||
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());
|
||||
@@ -81,10 +81,10 @@ public class DepotItemDAO extends BaseDAO<DepotItem> implements DepotItemIDAO
|
||||
//多表联查,多表连查,此处用到了createSQLQuery,可以随便写sql语句,很方便
|
||||
Query query;
|
||||
if(sumType.equals("Number")) {
|
||||
query = this.getHibernateTemplate().getSessionFactory().getCurrentSession().createSQLQuery("select sum(OperNumber) as OperNumber 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 00:00:00' " + SearchConditionUtil.getCondition(pageUtil.getAdvSearch()));
|
||||
query = this.getHibernateTemplate().getSessionFactory().getCurrentSession().createSQLQuery("select sum(OperNumber) as OperNumber 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 00:00:00' " + SearchConditionUtil.getCondition(pageUtil.getAdvSearch()));
|
||||
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());
|
||||
@@ -103,7 +103,7 @@ public class DepotItemDAO extends BaseDAO<DepotItem> implements DepotItemIDAO
|
||||
queryString.append(" and AllocationProjectId='" + ProjectId +"'"); //礼品充值时
|
||||
}
|
||||
else if(type.equals("out")){
|
||||
queryString.append(" and ProjectId='" + ProjectId +"'");
|
||||
queryString.append(" and DepotId='" + ProjectId +"'");
|
||||
}
|
||||
}
|
||||
queryString.append(" and MaterialId ="+ MId);
|
||||
|
||||
@@ -2,6 +2,10 @@ 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
|
||||
{
|
||||
@@ -14,4 +18,25 @@ public class MaterialDAO extends BaseDAO<Material> implements MaterialIDAO
|
||||
{
|
||||
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());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -2,8 +2,12 @@ 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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user