fixes bug#14354
dev:julio qua: git-svn-id: http://desenvolvimento.rjconsultores.com.br/repositorio/sco/AdmVenta/Web/trunk/ventaboletos@93640 d1611594-4594-4d17-8e1d-87c2c4800839master
parent
4d050fd238
commit
ee88c1f2e9
|
@ -4,6 +4,7 @@ import java.io.File;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
import java.sql.Connection;
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.text.SimpleDateFormat;
|
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.usermodel.Font;
|
||||||
import org.apache.poi.ss.util.CellRangeAddress;
|
import org.apache.poi.ss.util.CellRangeAddress;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.jdbc.datasource.DataSourceUtils;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.zkoss.util.resource.Labels;
|
import org.zkoss.util.resource.Labels;
|
||||||
import org.zkoss.zhtml.Filedownload;
|
import org.zkoss.zhtml.Filedownload;
|
||||||
|
@ -111,10 +113,10 @@ public class RelatorioEmbarqueLocalidadeController extends MyGenericForwardComp
|
||||||
|
|
||||||
private void executarRelatorio() throws Exception {
|
private void executarRelatorio() throws Exception {
|
||||||
|
|
||||||
empresa = cmbEmpresa.getSelectedItem() != null ? (Empresa)cmbEmpresa.getSelectedItem().getValue() : null;
|
empresa = cmbEmpresa.getSelectedItem() != null ? (Empresa) cmbEmpresa.getSelectedItem().getValue() : null;
|
||||||
ruta = cmbRuta.getSelectedItem() != null ? (Ruta)cmbRuta.getSelectedItem().getValue() : null;
|
ruta = cmbRuta.getSelectedItem() != null ? (Ruta) cmbRuta.getSelectedItem().getValue() : null;
|
||||||
orgao = cmbOrgaoConcedente.getSelectedItem() != null ? (OrgaoConcedente)cmbOrgaoConcedente.getSelectedItem().getValue() : null;
|
orgao = cmbOrgaoConcedente.getSelectedItem() != null ? (OrgaoConcedente) cmbOrgaoConcedente.getSelectedItem().getValue() : null;
|
||||||
origem = cmbOrigem.getSelectedItem() != null ? (Parada)cmbOrigem.getSelectedItem().getValue() : null;
|
origem = cmbOrigem.getSelectedItem() != null ? (Parada) cmbOrigem.getSelectedItem().getValue() : null;
|
||||||
|
|
||||||
SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
|
SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
|
||||||
SimpleDateFormat hf = new SimpleDateFormat("HH:mm:ss");
|
SimpleDateFormat hf = new SimpleDateFormat("HH:mm:ss");
|
||||||
|
@ -123,16 +125,16 @@ public class RelatorioEmbarqueLocalidadeController extends MyGenericForwardComp
|
||||||
String horInicio = horInicial.getValue() != null ? hf.format(horInicial.getValue()) : "";
|
String horInicio = horInicial.getValue() != null ? hf.format(horInicial.getValue()) : "";
|
||||||
String horFim = horFinal.getValue() != null ? hf.format(horFinal.getValue()) : "";
|
String horFim = horFinal.getValue() != null ? hf.format(horFinal.getValue()) : "";
|
||||||
|
|
||||||
|
Connection connection = null;
|
||||||
|
|
||||||
|
try {
|
||||||
|
connection = getConnectionRead();
|
||||||
|
|
||||||
String sql = getSql(empresa, ruta != null ? ruta.getRutaId().toString() : null,
|
String sql = getSql(empresa, ruta != null ? ruta.getRutaId().toString() : null,
|
||||||
orgao != null ? orgao.getOrgaoConcedenteId().toString() : null,
|
orgao != null ? orgao.getOrgaoConcedenteId().toString() : null,
|
||||||
origem != null ? origem.getParadaId().toString() : null, horInicio, horFim);
|
origem != null ? origem.getParadaId().toString() : null, horInicio, horFim);
|
||||||
|
|
||||||
ResultSet rset = null;
|
NamedParameterStatement stmt = new NamedParameterStatement(connection, sql);
|
||||||
try{
|
|
||||||
|
|
||||||
NamedParameterStatement stmt = new NamedParameterStatement(dataSourceRead.getConnection(), sql);
|
|
||||||
|
|
||||||
stmt.setString(FILED_FEC_INICIO, fecInicio);
|
stmt.setString(FILED_FEC_INICIO, fecInicio);
|
||||||
stmt.setString(FIELD_FEC_FINAL, fecFinal);
|
stmt.setString(FIELD_FEC_FINAL, fecFinal);
|
||||||
|
@ -140,7 +142,7 @@ public class RelatorioEmbarqueLocalidadeController extends MyGenericForwardComp
|
||||||
stmt.setInt(FIELD_EMPRESA_ID, empresa.getEmpresaId());
|
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());
|
stmt.setInt(FIELD_RUTA_ID, ruta.getRutaId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -152,23 +154,38 @@ public class RelatorioEmbarqueLocalidadeController extends MyGenericForwardComp
|
||||||
stmt.setInt(FIELD_ORIGEM_ID, origem.getParadaId());
|
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_INICIO, horInicio);
|
||||||
stmt.setString(FIELD_HOR_FINAL, horFim);
|
stmt.setString(FIELD_HOR_FINAL, horFim);
|
||||||
}
|
}
|
||||||
rset = stmt.executeQuery();
|
|
||||||
|
|
||||||
Map<String, Map<String, List<RelatorioEmbarqueLocalidadeBean>>> datas = ResultSetToList(rset);
|
ResultSet rset = stmt.executeQuery();
|
||||||
|
|
||||||
|
Map<String, Map<String, List<RelatorioEmbarqueLocalidadeBean>>> datas = resultSetToList(rset);
|
||||||
exportaExcel(datas);
|
exportaExcel(datas);
|
||||||
} catch (Exception e){
|
|
||||||
log.error("", e);
|
|
||||||
}finally {
|
|
||||||
if(rset != null && !rset.isClosed()) {
|
|
||||||
rset.close();
|
rset.close();
|
||||||
|
stmt.close();
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("", e);
|
||||||
|
} 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<String, Map<String, List<RelatorioEmbarqueLocalidadeBean>>> datas) {
|
private void exportaExcel(Map<String, Map<String, List<RelatorioEmbarqueLocalidadeBean>>> datas) {
|
||||||
try {
|
try {
|
||||||
HSSFWorkbook wb = new HSSFWorkbook();
|
HSSFWorkbook wb = new HSSFWorkbook();
|
||||||
|
@ -179,7 +196,7 @@ public class RelatorioEmbarqueLocalidadeController extends MyGenericForwardComp
|
||||||
HSSFFont font = wb.createFont();
|
HSSFFont font = wb.createFont();
|
||||||
HSSFCellStyle style = wb.createCellStyle();
|
HSSFCellStyle style = wb.createCellStyle();
|
||||||
font.setFontName(HSSFFont.FONT_ARIAL);
|
font.setFontName(HSSFFont.FONT_ARIAL);
|
||||||
font.setFontHeightInPoints((short)10);
|
font.setFontHeightInPoints((short) 10);
|
||||||
font.setBoldweight(Font.BOLDWEIGHT_BOLD);
|
font.setBoldweight(Font.BOLDWEIGHT_BOLD);
|
||||||
style.setFont(font);
|
style.setFont(font);
|
||||||
|
|
||||||
|
@ -195,18 +212,18 @@ public class RelatorioEmbarqueLocalidadeController extends MyGenericForwardComp
|
||||||
int totalGeral = 0;
|
int totalGeral = 0;
|
||||||
|
|
||||||
int linhaTotalizador = 6;
|
int linhaTotalizador = 6;
|
||||||
HSSFCell cellTotal = null ;
|
HSSFCell cellTotal = null;
|
||||||
for (RelatorioEmbarqueLocalidadeBean bean : ls) {
|
for (RelatorioEmbarqueLocalidadeBean bean : ls) {
|
||||||
|
|
||||||
int indexColun = mapAux.get(bean.getHorario());
|
int indexColun = mapAux.get(bean.getHorario());
|
||||||
|
|
||||||
if(!linhas.containsKey(bean.getLinha())) {
|
if (!linhas.containsKey(bean.getLinha())) {
|
||||||
linhas.put(bean.getLinha(), linha);
|
linhas.put(bean.getLinha(), linha);
|
||||||
row = sheet1.createRow(linha);
|
row = sheet1.createRow(linha);
|
||||||
linhaTotalizador = linha;
|
linhaTotalizador = linha;
|
||||||
linha++;
|
linha++;
|
||||||
|
|
||||||
}else {
|
} else {
|
||||||
row = sheet1.getRow(linhas.get(bean.getLinha()));
|
row = sheet1.getRow(linhas.get(bean.getLinha()));
|
||||||
linhaTotalizador = sheet1.getRow(linhas.get(bean.getLinha())).getRowNum();
|
linhaTotalizador = sheet1.getRow(linhas.get(bean.getLinha())).getRowNum();
|
||||||
}
|
}
|
||||||
|
@ -222,10 +239,10 @@ public class RelatorioEmbarqueLocalidadeController extends MyGenericForwardComp
|
||||||
|
|
||||||
cellTotal.setCellStyle(estiloVerticalMerge);
|
cellTotal.setCellStyle(estiloVerticalMerge);
|
||||||
String colluna;
|
String colluna;
|
||||||
String celTotal ;
|
String celTotal;
|
||||||
colluna = CellReference.convertNumToColString(mapAux.size()+2);
|
colluna = CellReference.convertNumToColString(mapAux.size() + 2);
|
||||||
celTotal = "SUM(D"+(linhaTotalizador+1)+":"+colluna+(linhaTotalizador+1)+")";
|
celTotal = "SUM(D" + (linhaTotalizador + 1) + ":" + colluna + (linhaTotalizador + 1) + ")";
|
||||||
row.createCell(mapAux.size()+3).setCellValue(celTotal);
|
row.createCell(mapAux.size() + 3).setCellValue(celTotal);
|
||||||
cellTotal.setCellFormula(celTotal);
|
cellTotal.setCellFormula(celTotal);
|
||||||
cellTotal.setCellStyle(style);
|
cellTotal.setCellStyle(style);
|
||||||
|
|
||||||
|
@ -233,32 +250,31 @@ public class RelatorioEmbarqueLocalidadeController extends MyGenericForwardComp
|
||||||
}
|
}
|
||||||
|
|
||||||
row = sheet1.createRow(linha);
|
row = sheet1.createRow(linha);
|
||||||
int qtdLinhas = linhas.size()+5;
|
int qtdLinhas = linhas.size() + 5;
|
||||||
|
|
||||||
int somatorioColuna = 3;
|
int somatorioColuna = 3;
|
||||||
for (int i = 3; i < mapAux.size()+3; i++) {
|
for (int i = 3; i < mapAux.size() + 3; i++) {
|
||||||
|
|
||||||
String colluna = CellReference.convertNumToColString(i);
|
String colluna = CellReference.convertNumToColString(i);
|
||||||
cellTotal = row.createCell(somatorioColuna);
|
cellTotal = row.createCell(somatorioColuna);
|
||||||
cellTotal.setCellFormula("SUM("+colluna+6+":"+colluna+(qtdLinhas)+")");
|
cellTotal.setCellFormula("SUM(" + colluna + 6 + ":" + colluna + (qtdLinhas) + ")");
|
||||||
cellTotal.setCellStyle(style);
|
cellTotal.setCellStyle(style);
|
||||||
somatorioColuna++;
|
somatorioColuna++;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
HSSFCell cellTotalValue = row.createCell(total);
|
HSSFCell cellTotalValue = row.createCell(total);
|
||||||
cellTotalValue = row.createCell(mapAux.size()+3);
|
cellTotalValue = row.createCell(mapAux.size() + 3);
|
||||||
cellTotalValue.setCellValue(totalGeral);
|
cellTotalValue.setCellValue(totalGeral);
|
||||||
cellTotalValue.setCellStyle(style);
|
cellTotalValue.setCellStyle(style);
|
||||||
|
|
||||||
|
|
||||||
linha = NUM_LINHA_INICIO;
|
linha = NUM_LINHA_INICIO;
|
||||||
|
|
||||||
for (int i = 0; i <= total; i++) {
|
for (int i = 0; i <= total; i++) {
|
||||||
sheet1.autoSizeColumn(i);
|
sheet1.autoSizeColumn(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(mapAux.isEmpty()){
|
if (mapAux.isEmpty()) {
|
||||||
Messagebox.show(
|
Messagebox.show(
|
||||||
Labels.getLabel("relatorio.parametro.msgNoData"),
|
Labels.getLabel("relatorio.parametro.msgNoData"),
|
||||||
Labels.getLabel("relatorioEmbarqueLocalidadeController.window.title"),
|
Labels.getLabel("relatorioEmbarqueLocalidadeController.window.title"),
|
||||||
|
@ -266,36 +282,39 @@ public class RelatorioEmbarqueLocalidadeController extends MyGenericForwardComp
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
String nomeArquivo =
|
String nomeArquivo = UsuarioLogado.getUsuarioLogado().getNombusuario()
|
||||||
UsuarioLogado.getUsuarioLogado().getNombusuario()
|
|
||||||
+ "_" + Calendar.getInstance().getTime().getTime()
|
+ "_" + Calendar.getInstance().getTime().getTime()
|
||||||
+ "_" + "EmbarqueLocalidade";
|
+ "_" + "EmbarqueLocalidade";
|
||||||
|
|
||||||
File fNomeArquivo = File.createTempFile(nomeArquivo, ".tmp");
|
File fNomeArquivo = File.createTempFile(nomeArquivo, ".tmp");
|
||||||
|
|
||||||
FileOutputStream stream = new FileOutputStream(fNomeArquivo);
|
FileOutputStream stream = new FileOutputStream(fNomeArquivo);
|
||||||
stream.flush();
|
|
||||||
wb.write(stream);
|
wb.write(stream);
|
||||||
stream.close();
|
|
||||||
|
|
||||||
InputStream is = null;
|
InputStream is = null;
|
||||||
is = new FileInputStream(fNomeArquivo);
|
is = new FileInputStream(fNomeArquivo);
|
||||||
Filedownload.save(is, "application/xls", "EmbarqueLocalidade.xls");
|
Filedownload.save(is, "application/xls", "EmbarqueLocalidade.xls");
|
||||||
|
|
||||||
fNomeArquivo.delete();
|
fNomeArquivo.delete();
|
||||||
}catch (Exception e) {
|
stream.flush();
|
||||||
|
stream.close();
|
||||||
|
//is.close();
|
||||||
|
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}finally {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void geraCabecalhoTitulo(HSSFSheet sheet1, HSSFWorkbook wb){
|
private void geraCabecalhoTitulo(HSSFSheet sheet1, HSSFWorkbook wb) {
|
||||||
HSSFRow titulo = sheet1.createRow(NUM_LINHA_TITULO);
|
HSSFRow titulo = sheet1.createRow(NUM_LINHA_TITULO);
|
||||||
sheet1.addMergedRegion(new CellRangeAddress(
|
sheet1.addMergedRegion(new CellRangeAddress(
|
||||||
NUM_LINHA_TITULO, //first row (0-based)
|
NUM_LINHA_TITULO, // first row (0-based)
|
||||||
NUM_LINHA_TITULO, //last row (0-based)
|
NUM_LINHA_TITULO, // last row (0-based)
|
||||||
0, //first column (0-based)
|
0, // first column (0-based)
|
||||||
7 //last column (0-based)
|
7 // last column (0-based)
|
||||||
));
|
));
|
||||||
|
|
||||||
HSSFFont fonte = wb.createFont();
|
HSSFFont fonte = wb.createFont();
|
||||||
|
@ -307,56 +326,53 @@ public class RelatorioEmbarqueLocalidadeController extends MyGenericForwardComp
|
||||||
titulo.setRowStyle(estilo);
|
titulo.setRowStyle(estilo);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void geraCabecalhoPeriodo(HSSFSheet sheet1){
|
private void geraCabecalhoPeriodo(HSSFSheet sheet1) {
|
||||||
HSSFRow periodo = sheet1.createRow(NUM_LINHA_PERIODO);
|
HSSFRow periodo = sheet1.createRow(NUM_LINHA_PERIODO);
|
||||||
SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
|
SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
|
||||||
|
|
||||||
sheet1.addMergedRegion(new CellRangeAddress(
|
sheet1.addMergedRegion(new CellRangeAddress(
|
||||||
NUM_LINHA_PERIODO, //first row (0-based)
|
NUM_LINHA_PERIODO, // first row (0-based)
|
||||||
NUM_LINHA_PERIODO, //last row (0-based)
|
NUM_LINHA_PERIODO, // last row (0-based)
|
||||||
0, //first column (0-based)
|
0, // first column (0-based)
|
||||||
7 //last 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()) );
|
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);
|
geraCabecalhoTitulo(sheet1, wb);
|
||||||
|
|
||||||
geraCabecalhoPeriodo(sheet1);
|
geraCabecalhoPeriodo(sheet1);
|
||||||
|
|
||||||
|
|
||||||
sheet1.addMergedRegion(new CellRangeAddress(
|
sheet1.addMergedRegion(new CellRangeAddress(
|
||||||
NUM_LINHA_DATA_EMPRESA, //first row (0-based)
|
NUM_LINHA_DATA_EMPRESA, // first row (0-based)
|
||||||
NUM_LINHA_DATA_EMPRESA, //last row (0-based)
|
NUM_LINHA_DATA_EMPRESA, // last row (0-based)
|
||||||
1, //first column (0-based)
|
1, // first column (0-based)
|
||||||
7 //last column (0-based)
|
7 // last column (0-based)
|
||||||
));
|
));
|
||||||
HSSFFont font = wb.createFont();
|
HSSFFont font = wb.createFont();
|
||||||
HSSFCellStyle style = wb.createCellStyle();
|
HSSFCellStyle style = wb.createCellStyle();
|
||||||
font.setFontName(HSSFFont.FONT_ARIAL);
|
font.setFontName(HSSFFont.FONT_ARIAL);
|
||||||
font.setFontHeightInPoints((short)10);
|
font.setFontHeightInPoints((short) 10);
|
||||||
font.setBoldweight(Font.BOLDWEIGHT_BOLD);
|
font.setBoldweight(Font.BOLDWEIGHT_BOLD);
|
||||||
style.setFont(font);
|
style.setFont(font);
|
||||||
//Montando o Cabeçalho
|
// Montando o Cabeçalho
|
||||||
HSSFRow r0 = sheet1.createRow(NUM_LINHA_DATA_EMPRESA);
|
HSSFRow r0 = sheet1.createRow(NUM_LINHA_DATA_EMPRESA);
|
||||||
|
|
||||||
if(empresa != null) {
|
if (empresa != null) {
|
||||||
r0.createCell(1).setCellValue("EMPRESA: " + empresa.getNombempresa());
|
r0.createCell(1).setCellValue("EMPRESA: " + empresa.getNombempresa());
|
||||||
r0.getCell(1).setCellStyle(style);
|
r0.getCell(1).setCellStyle(style);
|
||||||
r0.createCell(1).setCellValue("EMPRESA: " + empresa.getNombempresa());
|
r0.createCell(1).setCellValue("EMPRESA: " + empresa.getNombempresa());
|
||||||
r0.getCell(1).setCellStyle(style);
|
r0.getCell(1).setCellStyle(style);
|
||||||
font.setColor(HSSFColor.RED.index);
|
font.setColor(HSSFColor.RED.index);
|
||||||
style.setFont(font);
|
style.setFont(font);
|
||||||
}else {
|
} else {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
HSSFRow r1 = sheet1.createRow(NUM_LINHA_DATA_EMPRESA + 1);
|
||||||
|
|
||||||
HSSFRow r1 = sheet1.createRow(NUM_LINHA_DATA_EMPRESA+1);
|
|
||||||
List<RelatorioEmbarqueLocalidadeBean> lsAux = new ArrayList<RelatorioEmbarqueLocalidadeBean>();
|
List<RelatorioEmbarqueLocalidadeBean> lsAux = new ArrayList<RelatorioEmbarqueLocalidadeBean>();
|
||||||
|
|
||||||
mapAux = new HashMap<String, Integer>();
|
mapAux = new HashMap<String, Integer>();
|
||||||
|
@ -365,12 +381,12 @@ public class RelatorioEmbarqueLocalidadeController extends MyGenericForwardComp
|
||||||
int i = 3;
|
int i = 3;
|
||||||
for (RelatorioEmbarqueLocalidadeBean bean : ls) {
|
for (RelatorioEmbarqueLocalidadeBean bean : ls) {
|
||||||
|
|
||||||
if(map.containsKey(bean.getHorario())) {
|
if (map.containsKey(bean.getHorario())) {
|
||||||
Integer indice = map.get(bean.getHorario());
|
Integer indice = map.get(bean.getHorario());
|
||||||
map.put(bean.getHorario(), indice);
|
map.put(bean.getHorario(), indice);
|
||||||
bean.setIndexColun(indice);
|
bean.setIndexColun(indice);
|
||||||
}else {
|
} else {
|
||||||
map.put(bean.getHorario(),i);
|
map.put(bean.getHorario(), i);
|
||||||
bean.setIndexColun(i);
|
bean.setIndexColun(i);
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
@ -384,13 +400,12 @@ public class RelatorioEmbarqueLocalidadeController extends MyGenericForwardComp
|
||||||
fontHorario.setBoldweight(Font.BOLDWEIGHT_BOLD);
|
fontHorario.setBoldweight(Font.BOLDWEIGHT_BOLD);
|
||||||
styleHorario.setFont(fontHorario);
|
styleHorario.setFont(fontHorario);
|
||||||
|
|
||||||
for (Entry<String,Integer> bean : mapAux.entrySet()) {
|
for (Entry<String, Integer> bean : mapAux.entrySet()) {
|
||||||
r1.createCell(bean.getValue()).setCellValue(bean.getKey());
|
r1.createCell(bean.getValue()).setCellValue(bean.getKey());
|
||||||
r1.getCell(bean.getValue()).setCellStyle(styleHorario);
|
r1.getCell(bean.getValue()).setCellStyle(styleHorario);
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
r1.createCell(i++).setCellValue("TOTAL");
|
r1.createCell(i++).setCellValue("TOTAL");
|
||||||
r1.setRowStyle(styleHorario);
|
r1.setRowStyle(styleHorario);
|
||||||
total = i;
|
total = i;
|
||||||
|
@ -402,11 +417,12 @@ public class RelatorioEmbarqueLocalidadeController extends MyGenericForwardComp
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void doAfterCompose(Component comp) throws Exception {
|
public void doAfterCompose(Component comp) throws Exception {
|
||||||
|
super.doAfterCompose(comp);
|
||||||
|
|
||||||
lsEmpresas = empresaService.obtenerTodos();
|
lsEmpresas = empresaService.obtenerTodos();
|
||||||
lsOrgaosConcedentes = orgaoConcedenteService.obtenerTodos();
|
lsOrgaosConcedentes = orgaoConcedenteService.obtenerTodos();
|
||||||
lsOrigens = paradaService.obtenerTodos();
|
lsOrigens = paradaService.obtenerTodos();
|
||||||
lsRutas = rutaService.obtenerTodos();
|
// lsRutas = rutaService.obtenerTodos();
|
||||||
super.doAfterCompose(comp);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onChange$cmbOrgaoConcedente(Event ev) throws Exception {
|
public void onChange$cmbOrgaoConcedente(Event ev) throws Exception {
|
||||||
|
@ -435,20 +451,20 @@ public class RelatorioEmbarqueLocalidadeController extends MyGenericForwardComp
|
||||||
sql.append(" inner join marca m on m.marca_id = b.marca_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') ");
|
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 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' ");
|
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 ");
|
sql.append(" and r.orgaoconcedente_id = :orgao ");
|
||||||
}
|
}
|
||||||
if (empresa != null){
|
if (empresa != null) {
|
||||||
sql.append(" and m.empresa_id = :empresa ");
|
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 ");
|
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(" and b.origen_id = :origem ");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -461,7 +477,7 @@ public class RelatorioEmbarqueLocalidadeController extends MyGenericForwardComp
|
||||||
return sql.toString();
|
return sql.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Map<String, Map<String, List<RelatorioEmbarqueLocalidadeBean>>> ResultSetToList(ResultSet rset) throws SQLException {
|
protected Map<String, Map<String, List<RelatorioEmbarqueLocalidadeBean>>> resultSetToList(ResultSet rset) throws SQLException {
|
||||||
|
|
||||||
Map<String, Map<String, List<RelatorioEmbarqueLocalidadeBean>>> datas = new LinkedHashMap<String, Map<String, List<RelatorioEmbarqueLocalidadeBean>>>();
|
Map<String, Map<String, List<RelatorioEmbarqueLocalidadeBean>>> datas = new LinkedHashMap<String, Map<String, List<RelatorioEmbarqueLocalidadeBean>>>();
|
||||||
ls = new ArrayList<RelatorioEmbarqueLocalidadeBean>();
|
ls = new ArrayList<RelatorioEmbarqueLocalidadeBean>();
|
||||||
|
@ -472,14 +488,16 @@ public class RelatorioEmbarqueLocalidadeController extends MyGenericForwardComp
|
||||||
bean.setLinha(rset.getString(2));
|
bean.setLinha(rset.getString(2));
|
||||||
bean.setClasse(rset.getString(3));
|
bean.setClasse(rset.getString(3));
|
||||||
bean.setEmbarques(rset.getLong(4));
|
bean.setEmbarques(rset.getLong(4));
|
||||||
ls.add(bean);;
|
ls.add(bean);
|
||||||
}
|
}
|
||||||
|
|
||||||
return datas;
|
return datas;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void checarLinhasDuplicadas() {
|
public void checarLinhasDuplicadas() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Datebox getDatInicial() {
|
public Datebox getDatInicial() {
|
||||||
return datInicial;
|
return datInicial;
|
||||||
}
|
}
|
||||||
|
@ -577,4 +595,3 @@ public class RelatorioEmbarqueLocalidadeController extends MyGenericForwardComp
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue