diff --git a/.classpath b/.classpath
index d757e511d..1ae8301a1 100644
--- a/.classpath
+++ b/.classpath
@@ -2,7 +2,6 @@
-
@@ -53,7 +52,7 @@
-
+
@@ -94,20 +93,15 @@
-
-
-
-
-
+
+
+
+
-
-
-
-
-
+
diff --git a/src/java/com/rjconsultores/ventaboletos/relatorios/impl/RelatorioTabelaPreco.java b/src/java/com/rjconsultores/ventaboletos/relatorios/impl/RelatorioTabelaPreco.java
index 0bbf34364..f279c9df9 100644
--- a/src/java/com/rjconsultores/ventaboletos/relatorios/impl/RelatorioTabelaPreco.java
+++ b/src/java/com/rjconsultores/ventaboletos/relatorios/impl/RelatorioTabelaPreco.java
@@ -1,24 +1,26 @@
package com.rjconsultores.ventaboletos.relatorios.impl;
-import java.net.URL;
+import java.math.BigDecimal;
import java.sql.Connection;
import java.sql.ResultSet;
import java.util.HashMap;
-import java.util.List;
import java.util.Map;
import com.rjconsultores.ventaboletos.relatorios.utilitarios.ArrayDataSource;
import com.rjconsultores.ventaboletos.relatorios.utilitarios.Relatorio;
+import com.rjconsultores.ventaboletos.service.SegVKMService;
import com.rjconsultores.ventaboletos.web.utilerias.NamedParameterStatement;
public class RelatorioTabelaPreco extends Relatorio {
private Boolean isLayoutArtesp;
+ private SegVKMService segVKMService;
- public RelatorioTabelaPreco(final Map parametros, Connection conexao) throws Exception {
+ public RelatorioTabelaPreco(final Map parametros, Connection conexao, SegVKMService segVKMService) throws Exception {
super(parametros, conexao);
+ this.segVKMService = segVKMService;
this.isLayoutArtesp = (Boolean) parametros.get("isLayoutArtesp");
-
+
this.setCustomDataSource(new ArrayDataSource(this) {
public void initDados() throws Exception {
@@ -26,15 +28,22 @@ public class RelatorioTabelaPreco extends Relatorio {
NamedParameterStatement stmt = new NamedParameterStatement(conexao, getSql());
ResultSet rset = stmt.executeQuery();
+ String series = RelatorioTabelaPreco.this.segVKMService.seriePorEmpresa((Integer) parametros.get("EMPRESA_ID"));
while (rset.next()) {
Map dataResult = new HashMap();
+ BigDecimal valorSegOpcional = BigDecimal.ZERO;
+ if (isLayoutArtesp) {
+ valorSegOpcional = RelatorioTabelaPreco.this.segVKMService.buscarSeguroPorKm(rset.getLong("kmReal"),
+ series, (Integer) parametros.get("ORGAO_CONCEDENTE_ID"));
+ }
+
dataResult.put("origem", rset.getString("origem"));
dataResult.put("destino", rset.getString("destino"));
dataResult.put("tarifa", rset.getBigDecimal("tarifa"));
dataResult.put("pedagio", rset.getBigDecimal("pedagio"));
dataResult.put("taxaEmbarque", rset.getBigDecimal("taxaEmbarque"));
- dataResult.put("seguroOpcional", rset.getBigDecimal("valorSegOpcional"));
+ dataResult.put("seguroOpcional", valorSegOpcional);
dataResult.put("outros", rset.getBigDecimal("outros"));
dataResult.put("tipoClasse", rset.getString("tipoClasse"));
dataResult.put("empresa", rset.getString("empresa"));
@@ -63,7 +72,7 @@ public class RelatorioTabelaPreco extends Relatorio {
StringBuilder sql = new StringBuilder();
if (isLayoutArtesp) {
- sql.append("SELECT DISTINCT origem,destino,tarifa,pedagio,taxaEmbarque,valorSegOpcional,outros,tipoClasse,empresa FROM (");
+ sql.append("SELECT DISTINCT origem,destino,tarifa,pedagio,taxaEmbarque,outros,tipoClasse,empresa,kmReal FROM (");
}
sql.append(" SELECT pOrigem.DESCPARADA as origem, ");
sql.append(" pDestino.DESCPARADA as destino, ");
@@ -71,7 +80,6 @@ public class RelatorioTabelaPreco extends Relatorio {
sql.append(" COALESCE(t.IMPORTEPEDAGIO, 0) as pedagio, ");
sql.append(" COALESCE(t.IMPORTETAXAEMBARQUE, 0) as taxaEmbarque, ");
sql.append(" COALESCE(t.IMPORTESEGURO, 0) as seguro, ");
- sql.append(" COALESCE(segop.VALOR, 0) as valorSegOpcional, ");
sql.append(" COALESCE(t.IMPORTEOUTROS, 0) as outros, ");
sql.append(" cs.DESCCLASE as tipoClasse, ");
sql.append(" r.DESCRUTA as linha, ");
@@ -80,7 +88,8 @@ public class RelatorioTabelaPreco extends Relatorio {
sql.append(" vt.FECFINVIGENCIA as dataVigenciaFinal, ");
sql.append(" vt.VIGENCIATARIFA_ID as idVigencia, ");
sql.append(" vt.FECINICIOVIGENCIA as dataVigenciaInicial, ");
- sql.append(" r.RUTA_ID as idLinha ");
+ sql.append(" r.RUTA_ID as idLinha, ");
+ sql.append(" tr.CANTKMREAL as kmReal ");
sql.append("FROM TARIFA t ");
sql.append("INNER JOIN PARADA pOrigem ON t.ORIGEN_ID = pOrigem.PARADA_ID ");
sql.append("INNER JOIN PARADA pDestino ON t.DESTINO_ID = pDestino.PARADA_ID ");
@@ -92,8 +101,6 @@ public class RelatorioTabelaPreco extends Relatorio {
sql.append("INNER JOIN RUTA_COMBINACION rc ON rc.RUTA_ID = r.RUTA_ID ");
sql.append("INNER JOIN TRAMO tr ON tr.TRAMO_ID = rc.TRAMO_ID ");
sql.append("INNER JOIN ORGAO_CONCEDENTE o ON o.ORGAOCONCEDENTE_ID = r.ORGAOCONCEDENTE_ID ");
- sql.append("INNER JOIN SEGURADORA_EMPRESA se on se.EMPRESA_ID=e.EMPRESA_ID ");
- sql.append("LEFT JOIN SEGVKM segOp on segOp.KM=tr.CANTKMREAL and segOp.SERIE=se.SERIESEGURADORA ");
sql.append("WHERE rc.INDVENTA = 1 ");
sql.append("AND rc.ACTIVO = 1 ");
sql.append("AND tr.ACTIVO = 1 ");
diff --git a/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/relatorios/RelatorioTabelaPrecoController.java b/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/relatorios/RelatorioTabelaPrecoController.java
index 0a044ae29..764b89a75 100644
--- a/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/relatorios/RelatorioTabelaPrecoController.java
+++ b/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/relatorios/RelatorioTabelaPrecoController.java
@@ -32,6 +32,7 @@ import com.rjconsultores.ventaboletos.relatorios.utilitarios.Relatorio;
import com.rjconsultores.ventaboletos.service.EmpresaService;
import com.rjconsultores.ventaboletos.service.OrgaoConcedenteService;
import com.rjconsultores.ventaboletos.service.ParadaService;
+import com.rjconsultores.ventaboletos.service.SegVKMService;
import com.rjconsultores.ventaboletos.service.TramoService;
import com.rjconsultores.ventaboletos.service.VigenciaTarifaService;
import com.rjconsultores.ventaboletos.utilerias.UsuarioLogado;
@@ -74,6 +75,8 @@ public class RelatorioTabelaPrecoController extends MyGenericForwardComposer {
private ParadaService paradaService;
@Autowired
private DataSource dataSourceRead;
+ @Autowired
+ private SegVKMService segVKMService;
private List destinoList;
private List lsVigencia;
@@ -152,7 +155,7 @@ public class RelatorioTabelaPrecoController extends MyGenericForwardComposer {
}
parametros.put("LINHAS", rutas);
- Relatorio relatorio = new RelatorioTabelaPreco(parametros, dataSourceRead.getConnection());
+ Relatorio relatorio = new RelatorioTabelaPreco(parametros, dataSourceRead.getConnection(), segVKMService);
Map args = new HashMap();
args.put("relatorio", relatorio);
@@ -186,6 +189,14 @@ public class RelatorioTabelaPrecoController extends MyGenericForwardComposer {
linhaSelList.addItemNovo(ruta);
}
+ public void onClick$chkLayoutArtesp() {
+ if (chkLayoutArtesp.isChecked()) {
+ cmbOrgaoConcedente.setConstraint("no empty");
+ } else {
+ cmbOrgaoConcedente.setConstraint((String) null);
+ }
+ }
+
public void onChange$cmbOrigem(Event ev) {
Parada origem = cmbOrigem.getSelectedObject();
destinoList = paradaService.obterPossiveisDestinos(origem);