diff --git a/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/relatorios/RelatorioEmbarqueLocalidadeController.java b/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/relatorios/RelatorioEmbarqueLocalidadeController.java index d49e05adc..c2ef9f3d8 100644 --- a/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/relatorios/RelatorioEmbarqueLocalidadeController.java +++ b/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/relatorios/RelatorioEmbarqueLocalidadeController.java @@ -4,6 +4,7 @@ import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.InputStream; +import java.sql.Connection; import java.sql.ResultSet; import java.sql.SQLException; import java.text.SimpleDateFormat; @@ -31,6 +32,7 @@ import org.apache.poi.ss.usermodel.CellStyle; import org.apache.poi.ss.usermodel.Font; import org.apache.poi.ss.util.CellRangeAddress; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.jdbc.datasource.DataSourceUtils; import org.springframework.stereotype.Controller; import org.zkoss.util.resource.Labels; import org.zkoss.zhtml.Filedownload; @@ -56,22 +58,22 @@ import com.rjconsultores.ventaboletos.web.utilerias.MyGenericForwardComposer; import com.rjconsultores.ventaboletos.web.utilerias.NamedParameterStatement; @Controller("relatorioEmbarqueLocalidadeController") -public class RelatorioEmbarqueLocalidadeController extends MyGenericForwardComposer { +public class RelatorioEmbarqueLocalidadeController extends MyGenericForwardComposer { private static final long serialVersionUID = 1L; - + private static Logger log = Logger.getLogger(RelatorioEmbarqueLocalidadeController.class); @Autowired private DataSource dataSourceRead; - @Autowired + @Autowired private EmpresaService empresaService; - @Autowired + @Autowired private RutaService rutaService; - @Autowired + @Autowired private ParadaService paradaService; - @Autowired + @Autowired private OrgaoConcedenteService orgaoConcedenteService; - + private Datebox datInicial; private Datebox datFinal; private Timebox horInicial; @@ -80,12 +82,12 @@ public class RelatorioEmbarqueLocalidadeController extends MyGenericForwardComp private MyComboboxEstandar cmbOrgaoConcedente; private MyComboboxEstandar cmbRuta; private MyComboboxEstandar cmbOrigem; - + private List lsEmpresas; private List lsOrgaosConcedentes; private List lsRutas; private List lsOrigens; - + protected static final String FIELD_FEC_FINAL = "fecFinal"; protected static final String FILED_FEC_INICIO = "fecInicio"; protected static final String FIELD_HOR_INICIO = "horInicio"; @@ -94,123 +96,138 @@ public class RelatorioEmbarqueLocalidadeController extends MyGenericForwardComp protected static final String FIELD_RUTA_ID = "ruta"; protected static final String FIELD_ORGAO_CONCEDENTE_ID = "orgao"; protected static final String FIELD_ORIGEM_ID = "origem"; - + private static final int NUM_LINHA_TITULO = 0; private static final int NUM_LINHA_PERIODO = 1; private static final int NUM_LINHA_DATA_EMPRESA = 3; private static final int NUM_LINHA_INICIO = 5; - + private Empresa empresa; private Ruta ruta; - private OrgaoConcedente orgao; + private OrgaoConcedente orgao; private Parada origem; private int total; private Map mapAux = new HashMap(); - + private List ls; - + private void executarRelatorio() throws Exception { - - empresa = cmbEmpresa.getSelectedItem() != null ? (Empresa)cmbEmpresa.getSelectedItem().getValue() : null; - ruta = cmbRuta.getSelectedItem() != null ? (Ruta)cmbRuta.getSelectedItem().getValue() : null; - orgao = cmbOrgaoConcedente.getSelectedItem() != null ? (OrgaoConcedente)cmbOrgaoConcedente.getSelectedItem().getValue() : null; - origem = cmbOrigem.getSelectedItem() != null ? (Parada)cmbOrigem.getSelectedItem().getValue() : null; - + + empresa = cmbEmpresa.getSelectedItem() != null ? (Empresa) cmbEmpresa.getSelectedItem().getValue() : null; + ruta = cmbRuta.getSelectedItem() != null ? (Ruta) cmbRuta.getSelectedItem().getValue() : null; + orgao = cmbOrgaoConcedente.getSelectedItem() != null ? (OrgaoConcedente) cmbOrgaoConcedente.getSelectedItem().getValue() : null; + origem = cmbOrigem.getSelectedItem() != null ? (Parada) cmbOrigem.getSelectedItem().getValue() : null; + SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy"); SimpleDateFormat hf = new SimpleDateFormat("HH:mm:ss"); String fecInicio = sdf.format(this.datInicial.getValue()) + " 00:00:00"; String fecFinal = sdf.format(this.datFinal.getValue()) + " 23:59:59"; String horInicio = horInicial.getValue() != null ? hf.format(horInicial.getValue()) : ""; String horFim = horFinal.getValue() != null ? hf.format(horFinal.getValue()) : ""; - - - - String sql = getSql(empresa, ruta != null ? ruta.getRutaId().toString() : null, - orgao != null ? orgao.getOrgaoConcedenteId().toString() : null, - origem != null ? origem.getParadaId().toString() : null, horInicio, horFim); - - ResultSet rset = null; - try{ - - NamedParameterStatement stmt = new NamedParameterStatement(dataSourceRead.getConnection(), sql); - + + Connection connection = null; + + try { + connection = getConnectionRead(); + + String sql = getSql(empresa, ruta != null ? ruta.getRutaId().toString() : null, + orgao != null ? orgao.getOrgaoConcedenteId().toString() : null, + origem != null ? origem.getParadaId().toString() : null, horInicio, horFim); + + NamedParameterStatement stmt = new NamedParameterStatement(connection, sql); + stmt.setString(FILED_FEC_INICIO, fecInicio); stmt.setString(FIELD_FEC_FINAL, fecFinal); if (empresa != null) { stmt.setInt(FIELD_EMPRESA_ID, empresa.getEmpresaId()); } - - if (ruta != null && !ruta.equals("-1")) { + + if (ruta != null && !"-1".equals(ruta.getRutaId().toString())) { stmt.setInt(FIELD_RUTA_ID, ruta.getRutaId()); } - + if (orgao != null) { stmt.setInt(FIELD_ORGAO_CONCEDENTE_ID, orgao.getOrgaoConcedenteId()); } - + if (origem != null) { stmt.setInt(FIELD_ORIGEM_ID, origem.getParadaId()); } - - if (!horInicio.isEmpty() && !horFim.isEmpty()){ + + if (!horInicio.isEmpty() && !horFim.isEmpty()) { stmt.setString(FIELD_HOR_INICIO, horInicio); stmt.setString(FIELD_HOR_FINAL, horFim); } - rset = stmt.executeQuery(); - - Map>> datas = ResultSetToList(rset); + + ResultSet rset = stmt.executeQuery(); + + Map>> datas = resultSetToList(rset); exportaExcel(datas); - } catch (Exception e){ + + rset.close(); + stmt.close(); + + } catch (Exception e) { log.error("", e); - }finally { - if(rset != null && !rset.isClosed()) { - rset.close(); + } finally { + try { + if (connection != null && !connection.isClosed()) { + connection.close(); + } + } catch (SQLException e) { + log.error("error fechar conexão", e); + + throw new RuntimeException(e); } } } - + + private Connection getConnectionRead() { + return DataSourceUtils.getConnection(dataSourceRead); + } + private void exportaExcel(Map>> datas) { try { - HSSFWorkbook wb = new HSSFWorkbook(); - - HSSFCellStyle estiloVerticalMerge = wb.createCellStyle(); - estiloVerticalMerge.setVerticalAlignment(CellStyle.ALIGN_CENTER); - - HSSFFont font = wb.createFont(); - HSSFCellStyle style = wb.createCellStyle(); - font.setFontName(HSSFFont.FONT_ARIAL); - font.setFontHeightInPoints((short)10); - font.setBoldweight(Font.BOLDWEIGHT_BOLD); - style.setFont(font); - - HSSFSheet sheet1 = null; + HSSFWorkbook wb = new HSSFWorkbook(); - int linha = NUM_LINHA_INICIO; - HSSFRow row = null; - - sheet1 = wb.createSheet("07-08-19"); - geraCabecalho(sheet1, "07-08-19", wb); - - Map linhas = new HashMap(); - int totalGeral = 0; + HSSFCellStyle estiloVerticalMerge = wb.createCellStyle(); + estiloVerticalMerge.setVerticalAlignment(CellStyle.ALIGN_CENTER); - int linhaTotalizador = 6; - HSSFCell cellTotal = null ; - for (RelatorioEmbarqueLocalidadeBean bean : ls) { + HSSFFont font = wb.createFont(); + HSSFCellStyle style = wb.createCellStyle(); + font.setFontName(HSSFFont.FONT_ARIAL); + font.setFontHeightInPoints((short) 10); + font.setBoldweight(Font.BOLDWEIGHT_BOLD); + style.setFont(font); + + HSSFSheet sheet1 = null; + + int linha = NUM_LINHA_INICIO; + HSSFRow row = null; + + sheet1 = wb.createSheet("07-08-19"); + geraCabecalho(sheet1, "07-08-19", wb); + + Map linhas = new HashMap(); + int totalGeral = 0; + + int linhaTotalizador = 6; + HSSFCell cellTotal = null; + for (RelatorioEmbarqueLocalidadeBean bean : ls) { + + int indexColun = mapAux.get(bean.getHorario()); + + if (!linhas.containsKey(bean.getLinha())) { + linhas.put(bean.getLinha(), linha); + row = sheet1.createRow(linha); + linhaTotalizador = linha; + linha++; + + } else { + row = sheet1.getRow(linhas.get(bean.getLinha())); + linhaTotalizador = sheet1.getRow(linhas.get(bean.getLinha())).getRowNum(); + } - int indexColun = mapAux.get(bean.getHorario()); - - if(!linhas.containsKey(bean.getLinha())) { - linhas.put(bean.getLinha(), linha); - row = sheet1.createRow(linha); - linhaTotalizador = linha; - linha++; - - }else { - row = sheet1.getRow(linhas.get(bean.getLinha())); - linhaTotalizador = sheet1.getRow(linhas.get(bean.getLinha())).getRowNum(); - } - HSSFCell cellHorario = row.createCell(0); cellHorario.setCellStyle(estiloVerticalMerge); @@ -219,181 +236,179 @@ public class RelatorioEmbarqueLocalidadeController extends MyGenericForwardComp row.createCell(indexColun).setCellValue(bean.getEmbarques()); row.createCell(0).setCellValue(bean.getLinha()); row.createCell(1).setCellValue(bean.getClasse()); - - cellTotal.setCellStyle(estiloVerticalMerge); - String colluna; - String celTotal ; - colluna = CellReference.convertNumToColString(mapAux.size()+2); - celTotal = "SUM(D"+(linhaTotalizador+1)+":"+colluna+(linhaTotalizador+1)+")"; - row.createCell(mapAux.size()+3).setCellValue(celTotal); - cellTotal.setCellFormula(celTotal); - cellTotal.setCellStyle(style); - totalGeral += bean.getEmbarques(); - } + cellTotal.setCellStyle(estiloVerticalMerge); + String colluna; + String celTotal; + colluna = CellReference.convertNumToColString(mapAux.size() + 2); + celTotal = "SUM(D" + (linhaTotalizador + 1) + ":" + colluna + (linhaTotalizador + 1) + ")"; + row.createCell(mapAux.size() + 3).setCellValue(celTotal); + cellTotal.setCellFormula(celTotal); + cellTotal.setCellStyle(style); - row = sheet1.createRow(linha); - int qtdLinhas = linhas.size()+5; - - int somatorioColuna = 3; - for (int i = 3; i < mapAux.size()+3; i++) { - - String colluna = CellReference.convertNumToColString(i); - cellTotal = row.createCell(somatorioColuna); - cellTotal.setCellFormula("SUM("+colluna+6+":"+colluna+(qtdLinhas)+")"); - cellTotal.setCellStyle(style); - somatorioColuna++; - - } - - HSSFCell cellTotalValue = row.createCell(total); - cellTotalValue = row.createCell(mapAux.size()+3); - cellTotalValue.setCellValue(totalGeral); - cellTotalValue.setCellStyle(style); - - - linha = NUM_LINHA_INICIO; - - for (int i = 0; i <= total; i++) { - sheet1.autoSizeColumn(i); + totalGeral += bean.getEmbarques(); } - - if(mapAux.isEmpty()){ - Messagebox.show( - Labels.getLabel("relatorio.parametro.msgNoData"), - Labels.getLabel("relatorioEmbarqueLocalidadeController.window.title"), - Messagebox.OK, Messagebox.INFORMATION); - return; - } - - String nomeArquivo = - UsuarioLogado.getUsuarioLogado().getNombusuario() - + "_" + Calendar.getInstance().getTime().getTime() - + "_" + "EmbarqueLocalidade"; - - File fNomeArquivo = File.createTempFile(nomeArquivo, ".tmp"); - FileOutputStream stream = new FileOutputStream(fNomeArquivo); - stream.flush(); - wb.write(stream); - stream.close(); + row = sheet1.createRow(linha); + int qtdLinhas = linhas.size() + 5; - InputStream is = null; - is = new FileInputStream(fNomeArquivo); - Filedownload.save(is, "application/xls", "EmbarqueLocalidade.xls"); + int somatorioColuna = 3; + for (int i = 3; i < mapAux.size() + 3; i++) { - fNomeArquivo.delete(); - }catch (Exception e) { + String colluna = CellReference.convertNumToColString(i); + cellTotal = row.createCell(somatorioColuna); + cellTotal.setCellFormula("SUM(" + colluna + 6 + ":" + colluna + (qtdLinhas) + ")"); + cellTotal.setCellStyle(style); + somatorioColuna++; + + } + + HSSFCell cellTotalValue = row.createCell(total); + cellTotalValue = row.createCell(mapAux.size() + 3); + cellTotalValue.setCellValue(totalGeral); + cellTotalValue.setCellStyle(style); + + linha = NUM_LINHA_INICIO; + + for (int i = 0; i <= total; i++) { + sheet1.autoSizeColumn(i); + } + + if (mapAux.isEmpty()) { + Messagebox.show( + Labels.getLabel("relatorio.parametro.msgNoData"), + Labels.getLabel("relatorioEmbarqueLocalidadeController.window.title"), + Messagebox.OK, Messagebox.INFORMATION); + return; + } + + String nomeArquivo = UsuarioLogado.getUsuarioLogado().getNombusuario() + + "_" + Calendar.getInstance().getTime().getTime() + + "_" + "EmbarqueLocalidade"; + + File fNomeArquivo = File.createTempFile(nomeArquivo, ".tmp"); + + FileOutputStream stream = new FileOutputStream(fNomeArquivo); + + wb.write(stream); + + InputStream is = null; + is = new FileInputStream(fNomeArquivo); + Filedownload.save(is, "application/xls", "EmbarqueLocalidade.xls"); + fNomeArquivo.delete(); + stream.flush(); + stream.close(); + //is.close(); + + + } catch (Exception e) { e.printStackTrace(); + }finally { + } - } - private void geraCabecalhoTitulo(HSSFSheet sheet1, HSSFWorkbook wb){ + private void geraCabecalhoTitulo(HSSFSheet sheet1, HSSFWorkbook wb) { HSSFRow titulo = sheet1.createRow(NUM_LINHA_TITULO); sheet1.addMergedRegion(new CellRangeAddress( - NUM_LINHA_TITULO, //first row (0-based) - NUM_LINHA_TITULO, //last row (0-based) - 0, //first column (0-based) - 7 //last column (0-based) - )); - + NUM_LINHA_TITULO, // first row (0-based) + NUM_LINHA_TITULO, // last row (0-based) + 0, // first column (0-based) + 7 // last column (0-based) + )); + HSSFFont fonte = wb.createFont(); - fonte.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD); - HSSFCellStyle estilo = wb.createCellStyle(); - estilo.setFont(fonte); - - titulo.createCell(0).setCellValue("EMBARQUE POR LOCALIDADE"); + fonte.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD); + HSSFCellStyle estilo = wb.createCellStyle(); + estilo.setFont(fonte); + + titulo.createCell(0).setCellValue("EMBARQUE POR LOCALIDADE"); titulo.setRowStyle(estilo); } - - private void geraCabecalhoPeriodo(HSSFSheet sheet1){ - HSSFRow periodo = sheet1.createRow(NUM_LINHA_PERIODO); + + private void geraCabecalhoPeriodo(HSSFSheet sheet1) { + HSSFRow periodo = sheet1.createRow(NUM_LINHA_PERIODO); SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy"); - + sheet1.addMergedRegion(new CellRangeAddress( - NUM_LINHA_PERIODO, //first row (0-based) - NUM_LINHA_PERIODO, //last row (0-based) - 0, //first column (0-based) - 7 //last column (0-based) - )); - periodo.createCell(0).setCellValue("Período: " + sdf.format(this.datInicial.getValue()) + " a " + sdf.format(this.datFinal.getValue()) ); - + NUM_LINHA_PERIODO, // first row (0-based) + NUM_LINHA_PERIODO, // last row (0-based) + 0, // first column (0-based) + 7 // last column (0-based) + )); + periodo.createCell(0).setCellValue("Período: " + sdf.format(this.datInicial.getValue()) + " a " + sdf.format(this.datFinal.getValue())); + } - - private void geraCabecalho(HSSFSheet sheet1, String dataAtual, HSSFWorkbook wb){ - + + private void geraCabecalho(HSSFSheet sheet1, String dataAtual, HSSFWorkbook wb) { + geraCabecalhoTitulo(sheet1, wb); - - geraCabecalhoPeriodo(sheet1); - - + + geraCabecalhoPeriodo(sheet1); + sheet1.addMergedRegion(new CellRangeAddress( - NUM_LINHA_DATA_EMPRESA, //first row (0-based) - NUM_LINHA_DATA_EMPRESA, //last row (0-based) - 1, //first column (0-based) - 7 //last column (0-based) - )); + NUM_LINHA_DATA_EMPRESA, // first row (0-based) + NUM_LINHA_DATA_EMPRESA, // last row (0-based) + 1, // first column (0-based) + 7 // last column (0-based) + )); HSSFFont font = wb.createFont(); - HSSFCellStyle style = wb.createCellStyle(); - font.setFontName(HSSFFont.FONT_ARIAL); - font.setFontHeightInPoints((short)10); - font.setBoldweight(Font.BOLDWEIGHT_BOLD); - style.setFont(font); - //Montando o Cabeçalho - HSSFRow r0 = sheet1.createRow(NUM_LINHA_DATA_EMPRESA); + HSSFCellStyle style = wb.createCellStyle(); + font.setFontName(HSSFFont.FONT_ARIAL); + font.setFontHeightInPoints((short) 10); + font.setBoldweight(Font.BOLDWEIGHT_BOLD); + style.setFont(font); + // Montando o Cabeçalho + HSSFRow r0 = sheet1.createRow(NUM_LINHA_DATA_EMPRESA); + + if (empresa != null) { + r0.createCell(1).setCellValue("EMPRESA: " + empresa.getNombempresa()); + r0.getCell(1).setCellStyle(style); + r0.createCell(1).setCellValue("EMPRESA: " + empresa.getNombempresa()); + r0.getCell(1).setCellStyle(style); + font.setColor(HSSFColor.RED.index); + style.setFont(font); + } else { - if(empresa != null) { - r0.createCell(1).setCellValue("EMPRESA: " + empresa.getNombempresa()); - r0.getCell(1).setCellStyle(style); - r0.createCell(1).setCellValue("EMPRESA: " + empresa.getNombempresa()); - r0.getCell(1).setCellStyle(style); - font.setColor(HSSFColor.RED.index); - style.setFont(font); - }else { - - } - - - - HSSFRow r1 = sheet1.createRow(NUM_LINHA_DATA_EMPRESA+1); - List lsAux = new ArrayList(); - - mapAux = new HashMap(); - Map map = new HashMap(); - - int i = 3; - for (RelatorioEmbarqueLocalidadeBean bean : ls) { - - if(map.containsKey(bean.getHorario())) { - Integer indice = map.get(bean.getHorario()); - map.put(bean.getHorario(), indice); - bean.setIndexColun(indice); - }else { - map.put(bean.getHorario(),i); - bean.setIndexColun(i); - i++; - } - lsAux.add(bean); - } - i = 3; - mapAux = new TreeMap(map); - HSSFFont fontHorario = wb.createFont(); - HSSFCellStyle styleHorario = wb.createCellStyle(); - fontHorario.setColor(HSSFColor.BLACK.index); - fontHorario.setBoldweight(Font.BOLDWEIGHT_BOLD); - styleHorario.setFont(fontHorario); - - for (Entry bean : mapAux.entrySet()) { - r1.createCell(bean.getValue()).setCellValue(bean.getKey()); - r1.getCell(bean.getValue()).setCellStyle(styleHorario); - i++; } - - r1.createCell(i++).setCellValue("TOTAL"); - r1.setRowStyle(styleHorario); - total = i; + HSSFRow r1 = sheet1.createRow(NUM_LINHA_DATA_EMPRESA + 1); + List lsAux = new ArrayList(); + + mapAux = new HashMap(); + Map map = new HashMap(); + + int i = 3; + for (RelatorioEmbarqueLocalidadeBean bean : ls) { + + if (map.containsKey(bean.getHorario())) { + Integer indice = map.get(bean.getHorario()); + map.put(bean.getHorario(), indice); + bean.setIndexColun(indice); + } else { + map.put(bean.getHorario(), i); + bean.setIndexColun(i); + i++; + } + lsAux.add(bean); + } + i = 3; + mapAux = new TreeMap(map); + HSSFFont fontHorario = wb.createFont(); + HSSFCellStyle styleHorario = wb.createCellStyle(); + fontHorario.setColor(HSSFColor.BLACK.index); + fontHorario.setBoldweight(Font.BOLDWEIGHT_BOLD); + styleHorario.setFont(fontHorario); + + for (Entry bean : mapAux.entrySet()) { + r1.createCell(bean.getValue()).setCellValue(bean.getKey()); + r1.getCell(bean.getValue()).setCellStyle(styleHorario); + i++; + } + + r1.createCell(i++).setCellValue("TOTAL"); + r1.setRowStyle(styleHorario); + total = i; } public void onClick$btnExecutarRelatorio(Event ev) throws Exception { @@ -402,11 +417,12 @@ public class RelatorioEmbarqueLocalidadeController extends MyGenericForwardComp @Override public void doAfterCompose(Component comp) throws Exception { + super.doAfterCompose(comp); + lsEmpresas = empresaService.obtenerTodos(); lsOrgaosConcedentes = orgaoConcedenteService.obtenerTodos(); - lsOrigens = paradaService.obtenerTodos(); - lsRutas = rutaService.obtenerTodos(); - super.doAfterCompose(comp); + lsOrigens = paradaService.obtenerTodos(); + // lsRutas = rutaService.obtenerTodos(); } public void onChange$cmbOrgaoConcedente(Event ev) throws Exception { @@ -414,16 +430,16 @@ public class RelatorioEmbarqueLocalidadeController extends MyGenericForwardComp lsRutas = orgao != null ? rutaService.buscaSomenteRutasFromOrgao(orgao) : rutaService.obtenerTodos(); cmbRuta.setModel(new ListModelList(lsRutas)); } - + public void onChange$cmbRuta(Event ev) throws Exception { Ruta ruta = cmbRuta.getSelectedItem() != null ? (Ruta) cmbRuta.getSelectedItem().getValue() : null; lsOrigens = ruta != null ? paradaService.obtenerOrigenPorRuta(ruta) : paradaService.obtenerTodos(); cmbOrigem.setModel(new ListModelList(lsOrigens)); } - + protected String getSql(Empresa empresa, String ruta, String orgao, String origem, String horInicio, String horFim) { StringBuilder sql = new StringBuilder(); - + sql.append("select "); sql.append(" concat(concat(concat(TO_CHAR(b.fechorviaje,'HH24'), ':00'), ' a '),concat(TO_CHAR(b.fechorviaje,'HH24'), ':59')), "); sql.append(" concat(concat(r.prefixo, ' '), r.descruta), cla.descclase, "); @@ -433,53 +449,55 @@ public class RelatorioEmbarqueLocalidadeController extends MyGenericForwardComp sql.append(" inner join ruta r on r.ruta_id = b.ruta_id "); sql.append(" inner join clase_servicio cla on cla.claseservicio_id = r.claseservicio_id "); sql.append(" inner join marca m on m.marca_id = b.marca_id "); - sql.append("where "); + sql.append("where "); sql.append(" b.fechorviaje between TO_DATE(:fecInicio, 'DD/MM/YYYY HH24:MI:SS') AND TO_DATE(:fecFinal, 'DD/MM/YYYY HH24:MI:SS') "); - if (!horInicio.isEmpty() && !horFim.isEmpty()){ + if (!horInicio.isEmpty() && !horFim.isEmpty()) { sql.append(" and TO_CHAR(b.fechorviaje, 'HH24:MI:SS') between :horInicio AND :horFinal "); } sql.append(" and b.motivocancelacion_id is null and b.numasiento is not null and b.indstatusoperacion = 'F' "); - if (orgao != null && !orgao.isEmpty()){ + if (orgao != null && !orgao.isEmpty()) { sql.append(" and r.orgaoconcedente_id = :orgao "); } - if (empresa != null){ + if (empresa != null) { sql.append(" and m.empresa_id = :empresa "); } - if (ruta != null && !ruta.isEmpty() && !ruta.equals("-1")){ + if (ruta != null && !ruta.isEmpty() && !ruta.equals("-1")) { sql.append(" and b.ruta_id = :ruta "); } - if (origem != null && !origem.isEmpty()){ + if (origem != null && !origem.isEmpty()) { sql.append(" and b.origen_id = :origem "); } - + sql.append("group by "); sql.append(" concat(concat(concat(TO_CHAR(b.fechorviaje,'HH24'), ':00'), ' a '),concat(TO_CHAR(b.fechorviaje,'HH24'), ':59')), "); sql.append(" concat(concat(r.prefixo, ' '), r.descruta), cla.descclase "); sql.append("order by "); - sql.append(" 1 "); - + sql.append(" 1 "); + return sql.toString(); } - - protected Map>> ResultSetToList(ResultSet rset) throws SQLException { - + + protected Map>> resultSetToList(ResultSet rset) throws SQLException { + Map>> datas = new LinkedHashMap>>(); ls = new ArrayList(); - - while (rset.next()) { + + while (rset.next()) { RelatorioEmbarqueLocalidadeBean bean = new RelatorioEmbarqueLocalidadeBean(); bean.setHorario(rset.getString(1)); bean.setLinha(rset.getString(2)); bean.setClasse(rset.getString(3)); bean.setEmbarques(rset.getLong(4)); - ls.add(bean);; + ls.add(bean); } - + return datas; } + public void checarLinhasDuplicadas() { - + } + public Datebox getDatInicial() { return datInicial; } @@ -577,4 +595,3 @@ public class RelatorioEmbarqueLocalidadeController extends MyGenericForwardComp } } - \ No newline at end of file