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+"' ");