From cf7b1c465eb87894d1f452c9065ff690f9123d87 Mon Sep 17 00:00:00 2001 From: thiago Date: Tue, 22 Aug 2017 20:08:11 +0000 Subject: [PATCH] =?UTF-8?q?fixed=20bug=20#9576=20-=20Corre=C3=A7=C3=A3o=20?= =?UTF-8?q?de=20query=20de=20atualiza=C3=A7=C3=A3o=20de=20taxa=20de=20emba?= =?UTF-8?q?rque.=20Faltava=20uma=20condi=C3=A7=C3=A3o=20de=20verifica?= =?UTF-8?q?=C3=A7=C3=A3o=20do=20org=C3=A3o=20concedente.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: http://desenvolvimento.rjconsultores.com.br/repositorio/sco/AdmVenta/Model/trunk/modelWeb@72808 d1611594-4594-4d17-8e1d-87c2c4800839 --- .../dao/sqlbuilder/impl/SQLBuilderOracle.java | 67 +++++++++---------- 1 file changed, 32 insertions(+), 35 deletions(-) diff --git a/src/com/rjconsultores/ventaboletos/dao/sqlbuilder/impl/SQLBuilderOracle.java b/src/com/rjconsultores/ventaboletos/dao/sqlbuilder/impl/SQLBuilderOracle.java index 79e9313bb..c00dc873b 100644 --- a/src/com/rjconsultores/ventaboletos/dao/sqlbuilder/impl/SQLBuilderOracle.java +++ b/src/com/rjconsultores/ventaboletos/dao/sqlbuilder/impl/SQLBuilderOracle.java @@ -19,7 +19,7 @@ public class SQLBuilderOracle implements SQLBuilder { private static final Integer RED_PAGO_FORMAPAGO_ID = Integer.valueOf(95); private static final String RED_PAGO_EMISSOR_TARJETA = "RDP"; private static final String RED_PAGO_FORMA_PAGO = "CR"; - + @Override public String getSQLGerarTabelaZerada(final Integer codRuta, final Integer usuarioId,final Integer orgaoConcedenteId, final List idsEmpresas){ @@ -120,7 +120,7 @@ public class SQLBuilderOracle implements SQLBuilder { @Override public String getSQLGerarTarifaOficialArtesp(final Integer codRuta, final Integer usuarioId, - final Integer orgaoConcedenteId, final List idsEmpresas) + final Integer orgaoConcedenteId, final List idsEmpresas) { StringBuilder sb = new StringBuilder(); sb.append(" INSERT "); @@ -152,8 +152,8 @@ public class SQLBuilderOracle implements SQLBuilder { sb.append(" select "); sb.append(" "); sb.append(" TARIFA_OFICIAL_SEQ.NEXTVAL, "); - - sb.append(" ROUND( "); + + sb.append(" ROUND( "); sb.append(" ("); sb.append(" "); sb.append(" case ( coalesce((select min( tkm.valortaxa ) from Tarifa_km tkm where tkm.kmate >= t.cantkmreal and r.CLASESERVICIO_ID = tkm.CLASESERVICIO_ID and tkm.activo = 1) , 0 )) when 0 then"); @@ -162,8 +162,8 @@ public class SQLBuilderOracle implements SQLBuilder { sb.append(" (select min( tkm.valortaxa ) from Tarifa_km tkm where tkm.kmate >= t.cantkmreal and r.CLASESERVICIO_ID = tkm.CLASESERVICIO_ID and tkm.activo = 1) end"); sb.append(" ) "); sb.append(" ,2), "); - - sb.append(" ROUND( "); + + sb.append(" ROUND( "); sb.append(" ("); sb.append(" "); sb.append(" case ( coalesce((select min( tkm.valortaxa ) from Tarifa_km tkm where tkm.kmate >= t.cantkmreal and r.CLASESERVICIO_ID = tkm.CLASESERVICIO_ID and tkm.activo = 1) , 0 )) when 0 then"); @@ -172,7 +172,7 @@ public class SQLBuilderOracle implements SQLBuilder { sb.append(" (select min( tkm.valortaxa ) from Tarifa_km tkm where tkm.kmate >= t.cantkmreal and r.CLASESERVICIO_ID = tkm.CLASESERVICIO_ID and tkm.activo = 1) end"); sb.append(" ) "); sb.append(" ,2), "); - + sb.append(" t.tramo_id, "); sb.append(" mc.marca_id, "); sb.append(" r.CLASESERVICIO_ID, "); @@ -197,10 +197,8 @@ public class SQLBuilderOracle implements SQLBuilder { sb.append(" inner join ruta r on r.ruta_id = rc.ruta_id "); sb.append(" inner join ruta_empresa re on r.ruta_id = re.ruta_id "); sb.append(" inner join marca ma on ma.empresa_id = re.empresa_id "); - //sb.append(" and tc.CLASESERVICIO_ID = r.CLASESERVICIO_ID and tc.activo =1 "); sb.append(" inner join orgao_concedente oc on oc.orgaoconcedente_id =r.orgaoconcedente_id "); sb.append(" inner join tramo t on t.tramo_id = rc.tramo_id and t.activo =1");//adicionei isso t.activo =1"); - // sb.append(" inner join orgao_tramo tc on tc.tramo_id = rc.tramo_id ");// sb.append(" inner join parada po on po.parada_id = t.origen_id "); sb.append(" inner join parada pd on pd.parada_id = t.destino_id "); sb.append(" inner join ciudad c on c.ciudad_id = po.ciudad_id "); @@ -216,7 +214,6 @@ public class SQLBuilderOracle implements SQLBuilder { sb.append(" and r.ruta_id = ").append(codRuta); } sb.append(" and r.activo = 1 "); - // sb.append(" and tc.activo = 1 "); sb.append(" and mc.marca_id <> -1 "); sb.append(" and mc.activo = 1 "); sb.append(" and re.activo = 1 "); @@ -237,10 +234,10 @@ public class SQLBuilderOracle implements SQLBuilder { sb.append(" not in (select tao.tramo_id,tao.marca_id,tao.CLASESERVICIO_ID, "); sb.append(" tao.moneda_id,tao.orgaoconcedente_id, tao.ruta_id "); sb.append(" from tarifa_oficial tao where tao.activo = 1) "); - + return sb.toString(); } - + @Override public String getSQLGerarTarifaOficial(final Integer codRuta, final Integer usuarioId, final OrgaoConcedente orgaoConcedente, final List idsEmpresas) { @@ -456,7 +453,7 @@ public class SQLBuilderOracle implements SQLBuilder { sb.append(" from "); sb.append(" TAXA_EMBARQUE_PARADA tepKm1 "); sb.append(" where "); - sb.append(" tepKm1.parada_id = t.origen_id and tepKm1.KMATE >= t.CANTKMREAL and tepKm1.activo = 1 and tepKm1.empresa_id in (-1, ").append(idsEmpresas.toString().substring(1, idsEmpresas.toString().length()-1)).append(" ) "); + sb.append(" tepKm1.parada_id = t.origen_id and tepKm1.KMATE >= t.CANTKMREAL and tepKm1.activo = 1 and tepKm1.orgaoconcedente_id = tao.orgaoconcedente_id and tepKm1.empresa_id in (-1, ").append(idsEmpresas.toString().substring(1, idsEmpresas.toString().length() - 1)).append(" ) "); sb.append(" ) "); sb.append(" and tao.marca_id = tarifa_oficial.marca_id "); sb.append(" and tao.orgaoconcedente_id = tarifa_oficial.orgaoconcedente_id "); @@ -480,7 +477,7 @@ public class SQLBuilderOracle implements SQLBuilder { if (orgaoConcedenteId != null) { sb.append(" and tarifa_oficial.orgaoconcedente_id = ").append(orgaoConcedenteId); } - + return sb.toString(); } @@ -518,11 +515,11 @@ public class SQLBuilderOracle implements SQLBuilder { sb.append(" and tao.moneda_id = tarifa_oficial.moneda_id "); sb.append(" and tao.ruta_id = tarifa_oficial.ruta_id "); sb.append(" and tao.tramo_id = tarifa_oficial.tramo_id "); - + if (idsEmpresas != null) { sb.append(" and m.empresa_id in ( ").append(idsEmpresas.toString().substring(1, idsEmpresas.toString().length()-1)).append(" ) "); } - + sb.append("),IMPORTETAXAEMBARQUE) "); sb.append(", usuario_id = ").append(usuarioId).append(",fecmodif = ").append(DBUtil.getInstance().dbSysdate()).append(" "); sb.append(" "); @@ -631,7 +628,7 @@ public class SQLBuilderOracle implements SQLBuilder { return sb.toString(); } - + @Override public String getSQLAtualizarPrecioPorTPP(final Integer rutaId, final Integer usuarioId, final Integer orgaoConcedenteId, TipoSeguro tipoSeguro) { @@ -645,7 +642,7 @@ public class SQLBuilderOracle implements SQLBuilder { if (orgaoConcedenteId != null) { sb.append(" and tarifa_oficial.orgaoconcedente_id = ").append(orgaoConcedenteId); } - + return sb.toString(); } @@ -694,9 +691,9 @@ public class SQLBuilderOracle implements SQLBuilder { } @Override - public String getSQLSelecionarTarifaPorTarifaOficalParaAtualizar(final Integer vigenciaTarifaId, Empresa empresa, OrgaoConcedente orgao) { + public String getSQLSelecionarTarifaPorTarifaOficalParaAtualizar(final Integer vigenciaTarifaId, Empresa empresa, OrgaoConcedente orgao) { StringBuilder sb = new StringBuilder(""); - + sb.append("SELECT tao.IMPORTEPEDAGIO AS \"taoimportepedagio\", "); sb.append(" tao.PRECIO AS \"taoprecio\", "); sb.append(" tao.PRECIOORIGINAL AS \"taopreciooriginal\", "); @@ -705,7 +702,7 @@ public class SQLBuilderOracle implements SQLBuilder { sb.append(" tao.IMPORTETPP AS \"taoimportetpp\", "); sb.append(" tao.IMPORTEOUTROS AS \"taoimporteoutros\", "); sb.append(" ta.TARIFA_ID AS \"tarifaId\" "); - + sb.append("FROM TARIFA_OFICIAL tao " ); sb.append("INNER JOIN TARIFA ta ON (tao.MARCA_ID = ta.MARCA_ID "); sb.append(" AND tao.CLASESERVICIO_ID = ta.CLASESERVICIO_ID "); @@ -716,9 +713,9 @@ public class SQLBuilderOracle implements SQLBuilder { sb.append(" )"); sb.append("INNER JOIN MARCA mTa ON tao.MARCA_ID = mTa.MARCA_ID "); sb.append("INNER JOIN MARCA mTao ON ta.MARCA_ID = mTao.MARCA_ID "); - + sb.append("WHERE ta.VIGENCIATARIFA_ID = ").append(vigenciaTarifaId); - + if(orgao != null){ sb.append(" AND tao.ORGAOCONCEDENTE_ID = ").append(orgao.getOrgaoConcedenteId()); } @@ -726,17 +723,17 @@ public class SQLBuilderOracle implements SQLBuilder { sb.append(" AND mTa.EMPRESA_ID = ").append(empresa.getEmpresaId()); sb.append(" AND mTao.EMPRESA_ID = ").append(empresa.getEmpresaId()); } - + return sb.toString(); } - + @Override - public String getSQLAtualizarTarifaPorTarifaOfical(Map dados, Integer usuarioId, Boolean calculaPegagio, + public String getSQLAtualizarTarifaPorTarifaOfical(Map dados, Integer usuarioId, Boolean calculaPegagio, Boolean calculaTarifa, Boolean calculaTaxaEmbarque, Boolean calculaSeguro, Boolean calculaTPP){ - + StringBuilder sb = new StringBuilder(""); sb.append("UPDATE TARIFA SET "); - + if(calculaPegagio){ sb.append("IMPORTEPEDAGIO=").append(dados.get("taoimportepedagio")).append(","); } @@ -1163,8 +1160,8 @@ public class SQLBuilderOracle implements SQLBuilder { sb.append("0, null, null, null,null, null, null, null, null,"); sb.append("null, null, null, null, null, null, 1, :fecModIf, :usuarioId, 1,"); sb.append("null, null, null, null, null, :importeTaxaEmbarque, :importePedagio, :importeOutros,"); - sb.append(":importeSeguro, 0, null, :rutaId, :serieImpFiscal, null, null, 0, null)"); - + sb.append(":importeSeguro, 0, null, :rutaId, :serieImpFiscal, null, null, 0, null)"); + return sb.toString(); } @@ -1198,12 +1195,12 @@ public class SQLBuilderOracle implements SQLBuilder { sb.append(":empresaPuntoVentaId, null, null, :origemId, :marcaId, null, null, :numAsiento, null,"); sb.append("null,null,:precioPagado,null,null, :numFolioPreimpresso, :fechorViaje, :fechorVenta, null, :numOperacion,"); sb.append("'F', null, null, 'V', 0, 0, 0, null, 1,"); - sb.append("0, :fecModIf, :usuarioId,null, null, null, 0, :precioBase, null,"); + sb.append("0, :fecModIf, :usuarioId,null, null, null, 0, :precioBase, null,"); sb.append("null,null, null, null, null, :estacionId, null, null, null,1,"); - sb.append("0, null, null, null, :precioPricing, null, null, :importeTaxaEmbarque,"); - sb.append(":importePedagio, :importeOutros, :importeSeguro, null, null, null, null, null, null,"); - sb.append("null, null, null, null, :rutaId, null, null, :serieImpFiscal, null, :boletoId)"); - + sb.append("0, null, null, null, :precioPricing, null, null, :importeTaxaEmbarque,"); + sb.append(":importePedagio, :importeOutros, :importeSeguro, null, null, null, null, null, null,"); + sb.append("null, null, null, null, :rutaId, null, null, :serieImpFiscal, null, :boletoId)"); + return sb.toString(); }