增加对账单的功能

This commit is contained in:
季圣华
2017-10-06 17:15:55 +08:00
parent 6a7af6ff59
commit 789c2c9838
9 changed files with 543 additions and 4263 deletions

View File

@@ -731,6 +731,55 @@ public class DepotHeadAction extends BaseAction<DepotHeadModel>
}
return allReturn;
}
/**
*对账单接口
*/
public void findStatementAccount(){
PageUtil pageUtil = new PageUtil();
pageUtil.setPageSize(model.getPageSize());
pageUtil.setCurPage(model.getPageNo());
Long pid =model.getProjectId();
String dids =model.getDepotIds();
String beginTime = model.getBeginTime();
String endTime = model.getEndTime();
Long organId = model.getOrganId();
try{
depotHeadService.findStatementAccount(pageUtil, beginTime, endTime, organId, pid, dids);
List dataList = pageUtil.getPageList();
JSONObject outer = new JSONObject();
outer.put("total", pageUtil.getTotalCount());
//存放数据json数组
JSONArray dataArray = new JSONArray();
if(dataList!=null){
for(Integer i=0; i<dataList.size(); i++){
JSONObject item = new JSONObject();
Object dl = dataList.get(i); //获取对象
Object[] arr = (Object[]) dl; //转为数组
item.put("number", arr[0]); //单据编号
item.put("materialName", arr[1]); //商品名称
item.put("materialModel", arr[2]); //商品型号
item.put("unitPrice", arr[3]); //单价
item.put("operNumber", arr[4]); //入库出库数量
item.put("allPrice", arr[5]); //金额
item.put("supplierName", arr[6]); //供应商
item.put("depotName", arr[7]); //仓库
item.put("operTime", arr[8]); //入库出库日期
item.put("type", arr[9]); //单据类型
dataArray.add(item);
}
}
outer.put("rows", dataArray);
//回写查询结果
toClient(outer.toString());
}
catch (JshException e) {
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>查找信息异常", e);
}
catch (IOException e) {
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>回写查询信息结果异常", e);
}
}
/**
* 拼接搜索条件

View File

@@ -59,13 +59,16 @@ public class DepotHeadDAO extends BaseDAO<DepotHead> implements DepotHeadIDAO {
"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.Type='"+ type +"' and dh.OperTime >='"+ beginTime +"' and dh.OperTime <='"+ endTime +"' ");
"where dh.OperTime >='"+ beginTime +"' and dh.OperTime <='"+ endTime +"' ");
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()));
@@ -125,6 +128,38 @@ public class DepotHeadDAO extends BaseDAO<DepotHead> implements DepotHeadIDAO {
pageUtil.setPageList(query.list());
}
@SuppressWarnings("unchecked")
public void findStatementAccount(PageUtil pageUtil,String beginTime,String endTime,Long organId,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'),dh.type " +
"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 s.type!='会员' and dh.OperTime >='"+ beginTime +"' and dh.OperTime <='"+ endTime +"' ");
if(pid!=null){
queryString.append(" and di.DepotId=" + pid );
}
else {
queryString.append(" and di.DepotId in (" + dids + ")" );
}
if(organId!=null && !organId.equals("")) {
queryString.append(" and dh.OrganId='"+ organId +"'");
}
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 getHeaderIdByMaterial(PageUtil pageUtil,String materialParam) throws JshException {
StringBuffer queryString = new StringBuffer();

View File

@@ -23,6 +23,8 @@ public interface DepotHeadIDAO extends BaseIDAO<DepotHead>
public void findMaterialsListByHeaderId(PageUtil pageUtil,Long headerId) throws JshException;
public void findStatementAccount(PageUtil pageUtil,String beginTime,String endTime,Long organId,Long pid,String dids) throws JshException;
public void getHeaderIdByMaterial(PageUtil pageUtil,String materialParam) throws JshException;
}

View File

@@ -23,5 +23,7 @@ public interface DepotHeadIService extends BaseIService<DepotHead>
public void findMaterialsListByHeaderId(PageUtil pageUtil,Long headerId)throws JshException;
public void findStatementAccount(PageUtil pageUtil,String beginTime,String endTime, Long organId, Long pid,String dids)throws JshException;
public void getHeaderIdByMaterial(PageUtil pageUtil,String materialParam)throws JshException;
}

View File

@@ -50,6 +50,10 @@ public class DepotHeadService extends BaseService<DepotHead> implements DepotHea
depotHeadDao.findMaterialsListByHeaderId(pageUtil, headerId);
}
public void findStatementAccount(PageUtil pageUtil,String beginTime,String endTime,Long organId,Long pid,String dids) throws JshException {
depotHeadDao.findStatementAccount(pageUtil, beginTime, endTime, organId, pid, dids);
}
public void getHeaderIdByMaterial(PageUtil pageUtil,String materialParam) throws JshException {
depotHeadDao.getHeaderIdByMaterial(pageUtil, materialParam);
}