新增账户流水功能

This commit is contained in:
季圣华
2017-11-01 00:08:00 +08:00
parent 848601f0e4
commit 887cfcad4d
7 changed files with 213 additions and 9 deletions

View File

@@ -9,6 +9,7 @@ import java.text.*;
import com.jsh.model.po.AccountHead;
import com.jsh.model.po.AccountItem;
import com.jsh.util.JshException;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import org.springframework.dao.DataAccessException;
@@ -470,6 +471,46 @@ public class AccountAction extends BaseAction<AccountModel>
}
}
/**
* 账户流水信息
*/
public void findAccountInOutList(){
PageUtil pageUtil = new PageUtil();
pageUtil.setPageSize(model.getPageSize());
pageUtil.setCurPage(model.getPageNo());
Long accountId = model.getAccountID();
try{
accountService.findAccountInOutList(pageUtil, accountId);
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("type", arr[1]); //类型
item.put("supplierName", arr[2]); //单位信息
item.put("changeAmount", arr[3]); //金额
item.put("operTime", arr[4]); //入库出库日期
dataArray.add(item);
}
}
outer.put("rows", dataArray);
//回写查询结果
toClient(outer.toString());
}
catch (JshException e) {
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>查找信息异常", e);
}
catch (IOException e) {
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>回写查询信息结果异常", e);
}
}
/**
* 拼接搜索条件
* @return

View File

@@ -2,6 +2,10 @@ package com.jsh.dao.basic;
import com.jsh.base.BaseDAO;
import com.jsh.model.po.Account;
import com.jsh.util.JshException;
import com.jsh.util.PageUtil;
import com.jsh.util.SearchConditionUtil;
import org.hibernate.Query;
public class AccountDAO extends BaseDAO<Account> implements AccountIDAO
{
@@ -14,4 +18,54 @@ public class AccountDAO extends BaseDAO<Account> implements AccountIDAO
{
return Account.class;
}
@SuppressWarnings("unchecked")
public void findAccountInOutList(PageUtil<Account> pageUtil, Long accountId) throws JshException {
StringBuffer queryString = new StringBuffer();
queryString.append("select dh.Number,concat(dh.SubType,dh.Type) as newType,s.supplier,dh.ChangeAmount,date_format(dh.OperTime,'%Y-%m-%d %H:%i:%S') as oTime " +
" from jsh_depothead dh inner join jsh_supplier s on dh.OrganId = s.id where 1=1 ");
if(accountId!=null && !accountId.equals("")) {
queryString.append(" and dh.AccountId='"+ accountId +"' ");
}
queryString.append("UNION ALL " +
"select ah.BillNo,ah.Type as newType,s.supplier,ah.ChangeAmount,date_format(ah.BillTime,'%Y-%m-%d %H:%i:%S') as oTime " +
" from jsh_accounthead ah inner join jsh_supplier s on ah.OrganId=s.id where 1=1 ");
if(accountId!=null && !accountId.equals("")) {
queryString.append(" and ah.AccountId='"+ accountId +"' ");
}
queryString.append("UNION ALL " +
"select ah.BillNo,ah.Type as newType,s.supplier,ai.EachAmount,date_format(ah.BillTime,'%Y-%m-%d %H:%i:%S') as oTime " +
" from jsh_accounthead ah inner join jsh_supplier s on ah.OrganId=s.id " +
" inner join jsh_accountitem ai on ai.HeaderId=ah.Id " +
" where ah.Type in ('收款','付款','收预付款') ");
if(accountId!=null && !accountId.equals("")) {
queryString.append(" and ai.AccountId='"+ accountId +"' ");
}
queryString.append("UNION ALL " +
"select ah.BillNo,ah.Type as newType, '' as sName,ah.ChangeAmount,date_format(ah.BillTime,'%Y-%m-%d %H:%i:%S') as oTime " +
" from jsh_accounthead ah inner join jsh_accountitem ai on ai.HeaderId=ah.Id " +
" where ah.Type='转账' ");
if(accountId!=null && !accountId.equals("")) {
queryString.append(" and ah.AccountId='"+ accountId +"' ");
}
queryString.append("UNION ALL " +
"select ah.BillNo,ah.Type as newType, '' as sName,ai.EachAmount,date_format(ah.BillTime,'%Y-%m-%d %H:%i:%S') as oTime " +
" from jsh_accounthead ah inner join jsh_accountitem ai on ai.HeaderId=ah.Id " +
" where ah.Type='转账' ");
if(accountId!=null && !accountId.equals("")) {
queryString.append(" and ai.AccountId='"+ accountId +"' ");
}
queryString.append(" ORDER BY oTime 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());
}
}

View File

@@ -2,8 +2,11 @@ package com.jsh.dao.basic;
import com.jsh.base.BaseIDAO;
import com.jsh.model.po.Account;
import com.jsh.util.JshException;
import com.jsh.util.PageUtil;
public interface AccountIDAO extends BaseIDAO<Account>
{
public interface AccountIDAO extends BaseIDAO<Account> {
public void findAccountInOutList(PageUtil<Account> pageUtil, Long accountId) throws JshException;
}

View File

@@ -2,8 +2,10 @@ package com.jsh.service.basic;
import com.jsh.base.BaseIService;
import com.jsh.model.po.Account;
import com.jsh.util.JshException;
import com.jsh.util.PageUtil;
public interface AccountIService extends BaseIService<Account>
{
public void findAccountInOutList(PageUtil<Account> depotHead, Long accountId)throws JshException;
}

View File

@@ -2,6 +2,8 @@ package com.jsh.service.basic;
import com.jsh.base.BaseService;
import com.jsh.dao.basic.AccountIDAO;
import com.jsh.model.po.Account;
import com.jsh.util.JshException;
import com.jsh.util.PageUtil;
public class AccountService extends BaseService<Account> implements AccountIService
{
@@ -19,4 +21,8 @@ public class AccountService extends BaseService<Account> implements AccountIServ
return Account.class;
}
public void findAccountInOutList(PageUtil<Account> pageUtil, Long accountId) throws JshException {
accountDao.findAccountInOutList(pageUtil, accountId);
}
}