diff --git a/src/com/rjconsultores/integracaoreceitadespesa/dao/Totalbus.java b/src/com/rjconsultores/integracaoreceitadespesa/dao/Totalbus.java index 4de2b176b..4669b0f87 100644 --- a/src/com/rjconsultores/integracaoreceitadespesa/dao/Totalbus.java +++ b/src/com/rjconsultores/integracaoreceitadespesa/dao/Totalbus.java @@ -306,11 +306,6 @@ public class Totalbus { public List getDepositos(Integer puntoventaId, Integer empresaId, Date fechaParam){ List depositos = new ArrayList(); -// StringBuilder sb = new StringBuilder(); -// sb.append("select fdep.fechamentodeposito_id, fdep.valor, fdep.numdeposito, fdep.FECCREACION, fdep.fecha_deposito "); -// sb.append("from fechamento_deposito fdep "); -// sb.append("where trunc(FECCREACION) = :fecha and fdep.activo = 1 "); - StringBuilder strFechamentos = new StringBuilder(); strFechamentos.append("Select sum(fdep.valor), fdep.numdeposito, fdep.fecha_deposito, fc.empresa_id, pv.numpuntoventa, ec.numagencia, ec.numconta, if.CODIGO, ec.numintegracion, fdep.feccreacion "); @@ -337,60 +332,45 @@ public class Totalbus { if(fechaParam == null){ fecha = getData(); } - - //PreparedStatement pstmt = null; - //ResultSet rs = null; - -// pstmt = getConnection().prepareStatement(sb.toString()); -// pstmt.setDate(1, new java.sql.Date(fecha.getTime())); -// -// rs = pstmt.executeQuery(); - Integer codigoReceitaDespesaGlobus = getCodigoReceitaDespesaGlobus(); + PreparedStatement pstmtFechamentos = null; + ResultSet rsFechamentos = null; + BigDecimal soma = BigDecimal.ZERO; + try{ + pstmtFechamentos = getConnection().prepareStatement(strFechamentos.toString()); + pstmtFechamentos.setDate(1, new java.sql.Date(fecha.getTime())); - SimpleDateFormat sdf = new SimpleDateFormat("MM/yy"); + rsFechamentos = pstmtFechamentos.executeQuery(); - PreparedStatement pstmtFechamentos = null; - ResultSet rsFechamentos = null; - BigDecimal soma = BigDecimal.ZERO; - try{ -// while (rs.next()){ - pstmtFechamentos = getConnection().prepareStatement(strFechamentos.toString()); - pstmtFechamentos.setDate(1, new java.sql.Date(fecha.getTime())); - - rsFechamentos = pstmtFechamentos.executeQuery(); - - while (rsFechamentos.next()){ - Integer empId = null; - Integer pvId = null; - String banco = "" ; - String agencia = ""; - String contaCorrente = ""; - String numDep = " Dep: " + rsFechamentos.getString(2); - String valor = " R$ " + df.format(rsFechamentos.getBigDecimal(1)); - String ref = " Ref: "; - Integer codRecDesp = null; + while (rsFechamentos.next()){ + Integer empId = null; + Integer pvId = null; + String banco = "" ; + String agencia = ""; + String contaCorrente = ""; + String numDep = " Dep: " + rsFechamentos.getString(2); + Integer codRecDesp = null; - if (empId == null ){ empId = rsFechamentos.getInt(4); } - if (banco.isEmpty()){banco = "Bco: " + DespesaReceita.lpad(rsFechamentos.getString(8), "0", 3);} - if (pvId == null){ pvId = rsFechamentos.getInt(5); } - if (agencia.isEmpty()){ agencia = " Ag: " + rsFechamentos.getString(6); } - if (contaCorrente.isEmpty()){ contaCorrente = " C/C: " + rsFechamentos.getString(7); } - //ref += ref.length() <= 6 ? sdf.format(rsFechamentos.getDate(3)) : ", " + sdf.format(rsFechamentos.getDate(3)); - if (codRecDesp == null){ codRecDesp = rsFechamentos.getInt(9); } - - DespesaReceita deposito = new DespesaReceita(); - deposito.setCodigoEmpresa(empId); - deposito.setDataLancamento(rsFechamentos.getDate(10)); - deposito.setDataMovimento(rsFechamentos.getDate(3)); - deposito.setLocalArrecadação(pvId); - deposito.setValorLancamento(df.format(rsFechamentos.getBigDecimal(1))); - deposito.setIdentificadorReceitaDespesa("D"); - deposito.setCodigoReceitaDespesa(codRecDesp); - deposito.setDescricaoDetalhada(banco + agencia + contaCorrente + numDep); - depositos.add(deposito); - soma = soma.add(rsFechamentos.getBigDecimal(1)); - } + if (empId == null ){ empId = rsFechamentos.getInt(4); } + if (banco.isEmpty()){banco = "Bco: " + DespesaReceita.lpad(rsFechamentos.getString(8), "0", 3);} + if (pvId == null){ pvId = rsFechamentos.getInt(5); } + if (agencia.isEmpty()){ agencia = " Ag: " + rsFechamentos.getString(6); } + if (contaCorrente.isEmpty()){ contaCorrente = " C/C: " + rsFechamentos.getString(7); } + //ref += ref.length() <= 6 ? sdf.format(rsFechamentos.getDate(3)) : ", " + sdf.format(rsFechamentos.getDate(3)); + if (codRecDesp == null){ codRecDesp = rsFechamentos.getInt(9); } + + DespesaReceita deposito = new DespesaReceita(); + deposito.setCodigoEmpresa(empId); + deposito.setDataLancamento(rsFechamentos.getDate(10)); + deposito.setDataMovimento(rsFechamentos.getDate(3)); + deposito.setLocalArrecadação(pvId); + deposito.setValorLancamento(df.format(rsFechamentos.getBigDecimal(1))); + deposito.setIdentificadorReceitaDespesa("D"); + deposito.setCodigoReceitaDespesa(codRecDesp); + deposito.setDescricaoDetalhada(banco + agencia + contaCorrente + numDep); + depositos.add(deposito); + soma = soma.add(rsFechamentos.getBigDecimal(1)); + } log.debug("Total depósitos: " + soma); } catch (Exception e){ log.error(e.getMessage(), e);