fixes bug#15983

dev:
qua:

git-svn-id: http://desenvolvimento.rjconsultores.com.br/repositorio/sco/AdmVenta/Web/trunk/ventaboletos@98186 d1611594-4594-4d17-8e1d-87c2c4800839
master
thiago.clemente 2019-10-09 20:24:48 +00:00
parent c2b9b69de5
commit 77de90da71
1 changed files with 61 additions and 5 deletions

View File

@ -74,12 +74,14 @@ public class RelatorioAcompanhamentoEquivalentes extends Relatorio {
this.prepareQuery();
Map<Integer, List<Integer>> mapa = getMapaCorridaIdListaRoloperativoId();
Date dataInicial = (Date) this.relatorio.getParametros().get("DATA_MES");
while (this.resultSet.next()) {
Integer indicador = (Integer) this.relatorio.getParametros().get("INDICADOR");
Integer rolOperativoId = this.resultSet.getInt("ROLOPERATIVO_ID");
// Integer rolOperativoId = this.resultSet.getInt("ROLOPERATIVO_ID");
Integer corridaId = this.resultSet.getInt("CORRIDA_ID");
Integer assentos = this.resultSet.getInt("ASSENTOS");
Integer rutaId = this.resultSet.getInt("RUTA_ID");
@ -95,7 +97,17 @@ public class RelatorioAcompanhamentoEquivalentes extends Relatorio {
cal.setTime(dataInicial);
cal.set(Calendar.DATE, 1);
List<RelatorioAcompanhamentoEquivalenteBean> ls = getValorByIndicador(corridaId, rolOperativoId, indicador, assentos, dataInicial, rutaId, horario, isServicoExtra);
List<RelatorioAcompanhamentoEquivalenteBean> ls = new ArrayList<RelatorioAcompanhamentoEquivalenteBean>();
List<Integer> listaRoloperativoId = mapa.get(corridaId);
// Mantis 15983
// A query principal do relatório possuía a coluna ROLOPERATIVO_ID assim duplicando os serviços quando existiam mais de um ROLOPERATIVO_ID por CORRIDA_ID.
// Assim foi retirado a coluna ROLOPERATIVO_ID da query principal mas foi feito antes um mapa com a relação CORRIDA_ID x ROLOPERATIVO_ID(s)
if (listaRoloperativoId != null) {
for (Integer rolOperativoId : listaRoloperativoId) {
ls.addAll(getValorByIndicador(corridaId, rolOperativoId, indicador, assentos, dataInicial, rutaId, horario, isServicoExtra));
}
}
// Roda todos os dias do mes
for (int dia = 1; dia <= cal.getActualMaximum(Calendar.DATE); dia++) {
@ -143,7 +155,7 @@ public class RelatorioAcompanhamentoEquivalentes extends Relatorio {
Connection conexao = this.relatorio.getConexao();
Map<String, Object> parametros = this.relatorio.getParametros();
String sql = getSql();
String sql = getSql(false);
NamedParameterStatement stmt = new NamedParameterStatement(conexao, sql);
@ -217,6 +229,46 @@ public class RelatorioAcompanhamentoEquivalentes extends Relatorio {
return getListaValoresIndicadores(corridaId, rolOperativoId, indicador, assentos, sql, dataInicial, rutaId, horario);
}
protected Map<Integer, List<Integer>> getMapaCorridaIdListaRoloperativoId() throws SQLException {
Connection conexao = this.relatorio.getConexao();
String sql = getSql(true);
NamedParameterStatement stmt = new NamedParameterStatement(conexao, sql);
Map<String, Object> parametros = this.relatorio.getParametros();
if (parametros.get("EMPRESA_ID") != null) {
stmt.setInt("EMPRESA_ID", (Integer) parametros.get("EMPRESA_ID"));
} else {
stmt.setNull("EMPRESA_ID", java.sql.Types.INTEGER);
}
if (parametros.get("TIPOSERVICIO_ID") != null) {
stmt.setInt("TIPOSERVICIO_ID", (Integer) parametros.get("TIPOSERVICIO_ID"));
} else {
stmt.setNull("TIPOSERVICIO_ID", java.sql.Types.INTEGER);
}
stmt.setDate("DATA_MES", new java.sql.Date(((Date) parametros.get("DATA_MES")).getTime()));
Map<Integer, List<Integer>> mapa = new HashMap<Integer, List<Integer>>();
ResultSet rs = stmt.executeQuery();
while (rs.next()) {
Integer corridaId = rs.getInt("CORRIDA_ID");
Integer rolOperativoId = rs.getInt("ROLOPERATIVO_ID");
List<Integer> lista = mapa.get(corridaId);
if (lista == null) {
lista = new ArrayList<Integer>();
}
lista.add(rolOperativoId);
mapa.put(corridaId, lista);
}
return mapa;
}
});
}
@ -574,7 +626,7 @@ public class RelatorioAcompanhamentoEquivalentes extends Relatorio {
public void processaParametros() throws Exception {
}
private String getSql() {
private String getSql(boolean addRoloperativo_id) {
StringBuilder sql = new StringBuilder();
@ -584,7 +636,11 @@ public class RelatorioAcompanhamentoEquivalentes extends Relatorio {
sql.append(" DA.CANTASIENTOS ASSENTOS, ");
sql.append(" PO.CVEPARADA||' - '||PD.CVEPARADA SIGLA, ");
sql.append(" TO_CHAR(CR.FECHORSALIDAORIGINAL, 'HH24:MI') HORARIO, ");
sql.append(" CR.ROLOPERATIVO_ID, ");
if (addRoloperativo_id) {
sql.append(" CR.ROLOPERATIVO_ID, ");
}
sql.append(" CASE ");
sql.append(" WHEN CO.ESTADO_ID <> CD.ESTADO_ID THEN ");
sql.append(" 'S' ");