From b4dbe7c6c3ac9f4290396bd5a5c09887f62a7572 Mon Sep 17 00:00:00 2001 From: wilian Date: Fri, 6 Apr 2018 21:09:26 +0000 Subject: [PATCH] fixes bug#10852 dev:thiago qua:marcelo git-svn-id: http://desenvolvimento.rjconsultores.com.br/repositorio/sco/AdmVenta/Model/trunk/modelWeb@80613 d1611594-4594-4d17-8e1d-87c2c4800839 --- .../ConferenciaComissaoHibernateDAO.java | 314 +++++++++++------- .../impl/CalculoComissaoServiceImpl.java | 2 + 2 files changed, 193 insertions(+), 123 deletions(-) diff --git a/src/com/rjconsultores/ventaboletos/dao/hibernate/ConferenciaComissaoHibernateDAO.java b/src/com/rjconsultores/ventaboletos/dao/hibernate/ConferenciaComissaoHibernateDAO.java index f81af1616..57ce5f572 100644 --- a/src/com/rjconsultores/ventaboletos/dao/hibernate/ConferenciaComissaoHibernateDAO.java +++ b/src/com/rjconsultores/ventaboletos/dao/hibernate/ConferenciaComissaoHibernateDAO.java @@ -54,6 +54,7 @@ import com.rjconsultores.ventaboletos.vo.comissao.EventosFinanceirosVO; import com.rjconsultores.ventaboletos.vo.comissao.FormapagoVO; import com.rjconsultores.ventaboletos.vo.comissao.LogConferenciaVO; import com.rjconsultores.ventaboletos.vo.comissao.OcdVO; +import com.rjconsultores.ventaboletos.web.utilerias.NamedParameterStatement; @Repository("conferenciaComissaoDAO") public class ConferenciaComissaoHibernateDAO extends GenericHibernateDAO @@ -244,6 +245,12 @@ public class ConferenciaComissaoHibernateDAO extends GenericHibernateDAO parametros) throws SQLException { + for (Entry parametro : parametros.entrySet()) { + npst.setObject(parametro.getKey(), parametro.getValue()); + } + } private void carregarMovimentoVendas(Connection con, List lsConferencias, String competencia, Empresa empresa, PuntoVenta puntoVenta, Date dataMovimento, Date dataInicialDate, Date dataFinalDate) @@ -588,16 +595,19 @@ public class ConferenciaComissaoHibernateDAO extends GenericHibernateDAO carregarEventosFinanceiros(Conferencia conferencia) throws BusinessException { + Connection con = null; + NamedParameterStatement npst = null; + ResultSet rSet = null; + try { Map parametros = carregarParametros(null, null, conferencia.getCompetencia(), conferencia.getEmpresa(), conferencia.getPuntoVenta(), conferencia.getDatamovimento(), true); StringBuilder sQuery = new StringBuilder() .append("SELECT EE.BOLETO_ID AS \"boletoId\", EE.EVENTOEXTRA_ID AS \"eventoextraId\", EE.NUMDOCUMENTO AS \"numdocumento\", ") .append("CFP.IMPORTE AS \"impingreso\", TEE.DESCTIPOEVENTO AS \"desctipoevento\", EE.DESCINFO AS \"descinfo\", ") - .append("LOG.STATUS AS \"status\", FP.FORMAPAGO_ID AS \"formapagoId\", FP.DESCPAGO AS \"descpago\", ") + .append("NVL(LOG.STATUS,-1) AS \"status\", FP.FORMAPAGO_ID AS \"formapagoId\", FP.DESCPAGO AS \"descpago\", ") .append("TEE.INDTIPO AS \"indtipo\", U.NOMBUSUARIO AS \"nombusuario\", LOG.LOGCONFERENCIA_ID AS \"logconferenciaId\", ") .append("COMFP.COMEMPFORMAPAGO_ID AS \"comempformapagoId\", COMTEE.COMEMPTIPOEVENTOEXTRA_ID AS \"comemptipoeventoextraId\", ") .append("COALESCE(CEC.INDTIPO_DEB_CRED, 0) AS \"tipoeventoextradebcred\", ") @@ -631,43 +641,60 @@ public class ConferenciaComissaoHibernateDAO extends GenericHibernateDAO result = qr.list(); - - for (EventosFinanceirosVO e : result) { - e.setConferencia(conferencia); + + con = getConnection(); + npst = new NamedParameterStatement(con, sQuery.toString()); + setParametros(npst, parametros); + rSet = npst.executeQuery(); + + List result = new ArrayList(); + while(rSet.next()) { + EventosFinanceirosVO eventosFinanceiros = new EventosFinanceirosVO(); + eventosFinanceiros.setBoletoId(rSet.getLong("boletoId") > 0 ? rSet.getLong("boletoId") : null); + eventosFinanceiros.setEventoextraId(rSet.getLong("eventoextraId")); + eventosFinanceiros.setNumdocumento(rSet.getString("numdocumento")); + eventosFinanceiros.setImpingreso(rSet.getBigDecimal("impingreso")); + eventosFinanceiros.setDesctipoevento(rSet.getString("desctipoevento")); + eventosFinanceiros.setDescinfo(rSet.getString("descinfo")); + eventosFinanceiros.setStatus(rSet.getInt("status") >= 0 ? rSet.getInt("status") : null); + eventosFinanceiros.setFormapagoId(rSet.getInt("formapagoId") > 0 ? rSet.getInt("formapagoId") : null); + eventosFinanceiros.setDescpago(rSet.getString("descpago")); + eventosFinanceiros.setComempformapagoId(rSet.getInt("comempformapagoId") > 0 ? rSet.getInt("comempformapagoId") : null); + eventosFinanceiros.setComemptipoeventoextraId(rSet.getInt("comemptipoeventoextraId") > 0 ? rSet.getInt("comemptipoeventoextraId") : null); + eventosFinanceiros.setTipoeventoextradebcred(rSet.getInt("tipoeventoextradebcred") > 0 ? rSet.getInt("tipoeventoextradebcred") : null); + eventosFinanceiros.setIndtipo(rSet.getString("indtipo")); + eventosFinanceiros.setNombusuario(rSet.getString("nombusuario")); + eventosFinanceiros.setLogconferenciaId(rSet.getLong("logconferenciaId") > 0 ? rSet.getLong("logconferenciaId") : null); + eventosFinanceiros.setExigeConferenciaAba(rSet.getBoolean("exigeConferenciaAba")); + eventosFinanceiros.setNumFolioSistema(rSet.getString("numFolioSistema")); + eventosFinanceiros.setCvetipoevento(rSet.getString("cvetipoevento")); + eventosFinanceiros.setFeccorte(rSet.getDate("feccorte")); + eventosFinanceiros.setIcmsBase(rSet.getBigDecimal("icmsBase")); + eventosFinanceiros.setEstadoId(rSet.getInt("estadoId") > 0 ? rSet.getInt("estadoId") : null); + + eventosFinanceiros.setConferencia(conferencia); + + result.add(eventosFinanceiros); } return result; } catch (Exception e) { log.error(e.getMessage(), e); throw new BusinessException(e.getMessage(), e); + } finally { + try { + if(rSet != null && !rSet.isClosed()) { + rSet.close(); + } + if(npst != null && !npst.isClosed()) { + npst.close(); + } + if(con != null && !con.isClosed()) { + con.close(); + } + } catch (SQLException e) { + log.error(e.getMessage(), e); + } } } @@ -791,9 +818,13 @@ public class ConferenciaComissaoHibernateDAO extends GenericHibernateDAO carregarBilhetesComissao(Conferencia conferencia, boolean isCalculoComissao, boolean isConsideraBilhetesDevolvidosEmOutraAgencia) throws BusinessException { + + Connection con = null; + NamedParameterStatement npst = null; + ResultSet rSet = null; + try { Map parametros = carregarParametros(null, null, conferencia.getCompetencia(), conferencia.getEmpresa(), conferencia.getPuntoVenta(), conferencia.getDatamovimento(), true); @@ -802,7 +833,7 @@ public class ConferenciaComissaoHibernateDAO extends GenericHibernateDAO lsBoletoComissao = new ArrayList(); - List auxLsBoletoComissao = qr.list(); - for (BoletoComissao boletoComissao : auxLsBoletoComissao) { - + while(rSet.next()) { + BoletoComissao boletoComissao = new BoletoComissao(); + boletoComissao.setCajaId(rSet.getLong("cajaId")); + boletoComissao.setTransacaoOriginalId(rSet.getLong("transacaoOriginalId") > 0 ? rSet.getLong("transacaoOriginalId") : null ); + boletoComissao.setNumAsiento(rSet.getString("numAsiento")); + boletoComissao.setNumAsientoVinculado(rSet.getString("numAsientoVinculado")); + boletoComissao.setNumFolioSistema(rSet.getString("numFolioSistema")); + boletoComissao.setNumSeriePreimpresa(rSet.getString("numSeriePreimpresa")); + boletoComissao.setNumFolioPreImpreso(rSet.getString("numFolioPreImpreso")); + boletoComissao.setUf(rSet.getString("uf")); + boletoComissao.setDesccategoria(rSet.getString("desccategoria")); + boletoComissao.setValorpagado(rSet.getBigDecimal("valorpagado")); + boletoComissao.setValorTabela(rSet.getBigDecimal("valorTabela")); + boletoComissao.setSeguroOutros(rSet.getBigDecimal("seguroOutros")); + boletoComissao.setPedagio(rSet.getBigDecimal("pedagio")); + boletoComissao.setEmbarque(rSet.getBigDecimal("embarque")); + boletoComissao.setTipoVenta(rSet.getInt("tipoVenta")); + boletoComissao.setIndstatusboleto(rSet.getString("indstatusboleto")); + boletoComissao.setStatus(rSet.getInt("status") >= 0 ? rSet.getInt("status") : null); + boletoComissao.setFormapagoId(rSet.getInt("formapagoId") > 0 ? rSet.getInt("formapagoId") : null); + boletoComissao.setDescpago(rSet.getString("descpago")); + boletoComissao.setLogconferenciaId(rSet.getLong("logconferenciaId") > 0 ? rSet.getLong("logconferenciaId") : null); + boletoComissao.setDescmotivocancelacion(rSet.getString("descmotivocancelacion")); + boletoComissao.setNombusuario(rSet.getString("nombusuario")); + boletoComissao.setMotivoCancelacionId(rSet.getInt("motivoCancelacionId") > 0 ? rSet.getInt("motivoCancelacionId") : null); + boletoComissao.setImporteFp(rSet.getBigDecimal("importeFp")); + boletoComissao.setComempformapagoId(rSet.getInt("comempformapagoId") > 0 ? rSet.getInt("comempformapagoId") : null); + boletoComissao.setComempcategoriaId(rSet.getInt("comempcategoriaId") > 0 ? rSet.getInt("comempcategoriaId") : null); + boletoComissao.setNumoperacion(rSet.getString("numoperacion")); + boletoComissao.setNombpasajero(rSet.getString("nombpasajero")); + boletoComissao.setIndcarboletosdevolvidosconf(rSet.getBoolean("indcarboletosdevolvidosconf")); + boletoComissao.setFeccorrida(rSet.getDate("feccorrida")); + boletoComissao.setCorridaId(rSet.getInt("corridaId") > 0 ? rSet.getInt("corridaId") : null); + boletoComissao.setIndCancelacion(rSet.getBoolean("indCancelacion")); + boletoComissao.setIndreimpresion(rSet.getBoolean("indreimpresion")); + boletoComissao.setFeccorte(rSet.getDate("feccorte")); + boletoComissao.setIcmsBase(rSet.getBigDecimal("icmsBase")); + boletoComissao.setEstadoId(rSet.getInt("estadoId") > 0 ? rSet.getInt("estadoId") : null); + boletoComissao.setPtoVtaOrigem(rSet.getBoolean("ptoVtaOrigem")); + boletoComissao.setValorbase(rSet.getBigDecimal("valorbase")); + boletoComissao.setEmpresaId(rSet.getInt("empresaId")); + boletoComissao.setTransacaoId(rSet.getLong("transacaoId") > 0 ? rSet.getLong("transacaoId") : null); + boletoComissao.setConferidoEntrega(rSet.getBoolean("conferidoEntrega")); + if(boletoComissao.getStatus() == null && boletoComissao.getConferidoEntrega() != null && boletoComissao.getConferidoEntrega()) { boletoComissao.setConferido(true); boletoComissao.setStatus(StatusLogConferencia.CONFERIDO.getValue()); @@ -962,24 +997,42 @@ public class ConferenciaComissaoHibernateDAO extends GenericHibernateDAO carregarOcds(Conferencia conferencia) throws BusinessException { + + Connection con = null; + NamedParameterStatement npst = null; + ResultSet rSet = null; + try { Map parametros = carregarParametros(null, null, null, conferencia.getEmpresa(), conferencia.getPuntoVenta(), conferencia.getDatamovimento(), false); StringBuilder sQuery = new StringBuilder() .append("SELECT DISTINCT O.OCD_ID AS \"ocdId\", O.NUMOPERACION AS \"numoperacion\", O.FECINC AS \"fecinc\", O.FECPAGAR AS \"fecpagar\", O.FECPAGO AS \"fecpago\", ") - .append("O.INDPAGO AS \"indpago\", O.VALOR_PAGAR AS \"valorPagar\", (B.PRECIOPAGADO * (O.PENALIZACION / 100)) AS \"penalizacion\", LOG.STATUS AS \"status\", ") + .append("O.INDPAGO AS \"indpago\", O.VALOR_PAGAR AS \"valorPagar\", (B.PRECIOPAGADO * (O.PENALIZACION / 100)) AS \"penalizacion\", NVL(LOG.STATUS,-1) AS \"status\", ") .append("U.NOMBUSUARIO AS \"nombusuario\", LOG.LOGCONFERENCIA_ID AS \"logconferenciaId\", U.CVEUSUARIO AS \"login\", B.NUMFOLIOSISTEMA AS \"numFolioSistema\", ") .append("CEC.INDOCD AS \"exigeConferenciaAba\" ") .append("FROM OCD O ") @@ -999,36 +1052,51 @@ public class ConferenciaComissaoHibernateDAO extends GenericHibernateDAO result = qr.list(); - - for (OcdVO ocd : result) { + + con = getConnection(); + npst = new NamedParameterStatement(con, sQuery.toString()); + setParametros(npst, parametros); + rSet = npst.executeQuery(); + + List result = new ArrayList(); + while(rSet.next()) { + OcdVO ocd = new OcdVO(); + ocd.setOcdId(rSet.getLong("ocdId")); + ocd.setNumoperacion(rSet.getString("numoperacion")); + ocd.setFecinc(rSet.getDate("fecinc")); + ocd.setFecpagar(rSet.getDate("fecpagar")); + ocd.setFecpago(rSet.getDate("fecpago")); + ocd.setIndpago(rSet.getBoolean("indpago")); + ocd.setValorPagar(rSet.getBigDecimal("valorPagar")); + ocd.setPenalizacion(rSet.getBigDecimal("penalizacion")); + ocd.setStatus(rSet.getInt("status") >= 0 ? rSet.getInt("status") : null); + ocd.setLogconferenciaId(rSet.getLong("logconferenciaId") > 0 ? rSet.getLong("logconferenciaId") : null); + ocd.setLogin(rSet.getString("login")); + ocd.setNumFolioSistema(rSet.getString("numFolioSistema")); + ocd.setExigeConferenciaAba(rSet.getBoolean("exigeConferenciaAba")); ocd.setConferencia(conferencia); + + result.add(ocd); } return result; } catch (Exception e) { log.error(e.getMessage(), e); throw new BusinessException(e.getMessage(), e); + } finally { + try { + if(rSet != null && !rSet.isClosed()) { + rSet.close(); + } + if(npst != null && !npst.isClosed()) { + npst.close(); + } + if(con != null && !con.isClosed()) { + con.close(); + } + } catch (SQLException e) { + log.error(e.getMessage(), e); + } } } diff --git a/src/com/rjconsultores/ventaboletos/service/impl/CalculoComissaoServiceImpl.java b/src/com/rjconsultores/ventaboletos/service/impl/CalculoComissaoServiceImpl.java index fcd3d2f01..bb9c488fe 100644 --- a/src/com/rjconsultores/ventaboletos/service/impl/CalculoComissaoServiceImpl.java +++ b/src/com/rjconsultores/ventaboletos/service/impl/CalculoComissaoServiceImpl.java @@ -200,6 +200,7 @@ public class CalculoComissaoServiceImpl implements CalculoComissaoService { } @Override + @Transactional public RegistroCalculo relatorioCalculoComissao(Integer puntoVentaId, Integer empresaId, Date periodo, Integer usuarioId, Boolean isRetencaoDiaria, Boolean isRefazerCalculo) throws ComissaoException, BusinessException { return realizarCalculoComissao(puntoVentaId, empresaId, periodo, isRetencaoDiaria, usuarioId, isRefazerCalculo); } @@ -305,6 +306,7 @@ public class CalculoComissaoServiceImpl implements CalculoComissaoService { return respDescontos; } + @Transactional public RegistroCalculo realizarCalculoComissao(Integer puntoVentaId, Integer empresaId, Date periodo, Boolean isRetencaoDiaria, Integer usuarioId, Boolean isRefazerCalculo) throws ComissaoException, BusinessException { PtovtaComissao ptovtaComissao = ptovtaComissaoService.buscarPuntaVentaEmpresa(puntoVentaId, empresaId);