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.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,7 +58,7 @@ 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);
|
||||
|
@ -111,10 +113,10 @@ public class RelatorioEmbarqueLocalidadeController extends MyGenericForwardComp
|
|||
|
||||
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");
|
||||
|
@ -123,16 +125,16 @@ public class RelatorioEmbarqueLocalidadeController extends MyGenericForwardComp
|
|||
String horInicio = horInicial.getValue() != null ? hf.format(horInicial.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,
|
||||
orgao != null ? orgao.getOrgaoConcedenteId().toString() : null,
|
||||
origem != null ? origem.getParadaId().toString() : null, horInicio, horFim);
|
||||
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);
|
||||
NamedParameterStatement stmt = new NamedParameterStatement(connection, sql);
|
||||
|
||||
stmt.setString(FILED_FEC_INICIO, fecInicio);
|
||||
stmt.setString(FIELD_FEC_FINAL, fecFinal);
|
||||
|
@ -140,7 +142,7 @@ public class RelatorioEmbarqueLocalidadeController extends MyGenericForwardComp
|
|||
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());
|
||||
}
|
||||
|
||||
|
@ -152,64 +154,79 @@ public class RelatorioEmbarqueLocalidadeController extends MyGenericForwardComp
|
|||
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<String, Map<String, List<RelatorioEmbarqueLocalidadeBean>>> datas = ResultSetToList(rset);
|
||||
ResultSet rset = stmt.executeQuery();
|
||||
|
||||
Map<String, Map<String, List<RelatorioEmbarqueLocalidadeBean>>> 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<String, Map<String, List<RelatorioEmbarqueLocalidadeBean>>> datas) {
|
||||
try {
|
||||
HSSFWorkbook wb = new HSSFWorkbook();
|
||||
HSSFWorkbook wb = new HSSFWorkbook();
|
||||
|
||||
HSSFCellStyle estiloVerticalMerge = wb.createCellStyle();
|
||||
estiloVerticalMerge.setVerticalAlignment(CellStyle.ALIGN_CENTER);
|
||||
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);
|
||||
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;
|
||||
HSSFSheet sheet1 = null;
|
||||
|
||||
int linha = NUM_LINHA_INICIO;
|
||||
HSSFRow row = null;
|
||||
int linha = NUM_LINHA_INICIO;
|
||||
HSSFRow row = null;
|
||||
|
||||
sheet1 = wb.createSheet("07-08-19");
|
||||
geraCabecalho(sheet1, "07-08-19", wb);
|
||||
sheet1 = wb.createSheet("07-08-19");
|
||||
geraCabecalho(sheet1, "07-08-19", wb);
|
||||
|
||||
Map<String, Integer> linhas = new HashMap<String, Integer>();
|
||||
int totalGeral = 0;
|
||||
Map<String, Integer> linhas = new HashMap<String, Integer>();
|
||||
int totalGeral = 0;
|
||||
|
||||
int linhaTotalizador = 6;
|
||||
HSSFCell cellTotal = null ;
|
||||
for (RelatorioEmbarqueLocalidadeBean bean : ls) {
|
||||
int linhaTotalizador = 6;
|
||||
HSSFCell cellTotal = null;
|
||||
for (RelatorioEmbarqueLocalidadeBean bean : ls) {
|
||||
|
||||
int indexColun = mapAux.get(bean.getHorario());
|
||||
int indexColun = mapAux.get(bean.getHorario());
|
||||
|
||||
if(!linhas.containsKey(bean.getLinha())) {
|
||||
linhas.put(bean.getLinha(), linha);
|
||||
row = sheet1.createRow(linha);
|
||||
linhaTotalizador = linha;
|
||||
linha++;
|
||||
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();
|
||||
}
|
||||
} else {
|
||||
row = sheet1.getRow(linhas.get(bean.getLinha()));
|
||||
linhaTotalizador = sheet1.getRow(linhas.get(bean.getLinha())).getRowNum();
|
||||
}
|
||||
|
||||
HSSFCell cellHorario = row.createCell(0);
|
||||
cellHorario.setCellStyle(estiloVerticalMerge);
|
||||
|
@ -220,180 +237,178 @@ public class RelatorioEmbarqueLocalidadeController extends MyGenericForwardComp
|
|||
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);
|
||||
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();
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
row = sheet1.createRow(linha);
|
||||
int qtdLinhas = linhas.size() + 5;
|
||||
|
||||
String nomeArquivo =
|
||||
UsuarioLogado.getUsuarioLogado().getNombusuario()
|
||||
+ "_" + Calendar.getInstance().getTime().getTime()
|
||||
+ "_" + "EmbarqueLocalidade";
|
||||
int somatorioColuna = 3;
|
||||
for (int i = 3; i < mapAux.size() + 3; i++) {
|
||||
|
||||
File fNomeArquivo = File.createTempFile(nomeArquivo, ".tmp");
|
||||
String colluna = CellReference.convertNumToColString(i);
|
||||
cellTotal = row.createCell(somatorioColuna);
|
||||
cellTotal.setCellFormula("SUM(" + colluna + 6 + ":" + colluna + (qtdLinhas) + ")");
|
||||
cellTotal.setCellStyle(style);
|
||||
somatorioColuna++;
|
||||
|
||||
FileOutputStream stream = new FileOutputStream(fNomeArquivo);
|
||||
stream.flush();
|
||||
wb.write(stream);
|
||||
stream.close();
|
||||
}
|
||||
|
||||
InputStream is = null;
|
||||
is = new FileInputStream(fNomeArquivo);
|
||||
Filedownload.save(is, "application/xls", "EmbarqueLocalidade.xls");
|
||||
HSSFCell cellTotalValue = row.createCell(total);
|
||||
cellTotalValue = row.createCell(mapAux.size() + 3);
|
||||
cellTotalValue.setCellValue(totalGeral);
|
||||
cellTotalValue.setCellStyle(style);
|
||||
|
||||
fNomeArquivo.delete();
|
||||
}catch (Exception e) {
|
||||
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);
|
||||
fonte.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
|
||||
HSSFCellStyle estilo = wb.createCellStyle();
|
||||
estilo.setFont(fonte);
|
||||
|
||||
titulo.createCell(0).setCellValue("EMBARQUE POR LOCALIDADE");
|
||||
titulo.createCell(0).setCellValue("EMBARQUE POR LOCALIDADE");
|
||||
titulo.setRowStyle(estilo);
|
||||
}
|
||||
|
||||
private void geraCabecalhoPeriodo(HSSFSheet sheet1){
|
||||
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);
|
||||
|
||||
|
||||
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<RelatorioEmbarqueLocalidadeBean> lsAux = new ArrayList<RelatorioEmbarqueLocalidadeBean>();
|
||||
|
||||
mapAux = new HashMap<String, Integer>();
|
||||
Map<String, Integer> map = new HashMap<String, Integer>();
|
||||
|
||||
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<String, Integer>(map);
|
||||
HSSFFont fontHorario = wb.createFont();
|
||||
HSSFCellStyle styleHorario = wb.createCellStyle();
|
||||
fontHorario.setColor(HSSFColor.BLACK.index);
|
||||
fontHorario.setBoldweight(Font.BOLDWEIGHT_BOLD);
|
||||
styleHorario.setFont(fontHorario);
|
||||
|
||||
for (Entry<String,Integer> bean : mapAux.entrySet()) {
|
||||
r1.createCell(bean.getValue()).setCellValue(bean.getKey());
|
||||
r1.getCell(bean.getValue()).setCellStyle(styleHorario);
|
||||
i++;
|
||||
}
|
||||
|
||||
HSSFRow r1 = sheet1.createRow(NUM_LINHA_DATA_EMPRESA + 1);
|
||||
List<RelatorioEmbarqueLocalidadeBean> lsAux = new ArrayList<RelatorioEmbarqueLocalidadeBean>();
|
||||
|
||||
r1.createCell(i++).setCellValue("TOTAL");
|
||||
r1.setRowStyle(styleHorario);
|
||||
total = i;
|
||||
mapAux = new HashMap<String, Integer>();
|
||||
Map<String, Integer> map = new HashMap<String, Integer>();
|
||||
|
||||
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<String, Integer>(map);
|
||||
HSSFFont fontHorario = wb.createFont();
|
||||
HSSFCellStyle styleHorario = wb.createCellStyle();
|
||||
fontHorario.setColor(HSSFColor.BLACK.index);
|
||||
fontHorario.setBoldweight(Font.BOLDWEIGHT_BOLD);
|
||||
styleHorario.setFont(fontHorario);
|
||||
|
||||
for (Entry<String, Integer> 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 {
|
||||
|
@ -435,20 +451,20 @@ public class RelatorioEmbarqueLocalidadeController extends MyGenericForwardComp
|
|||
sql.append(" inner join marca m on m.marca_id = b.marca_id ");
|
||||
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 ");
|
||||
}
|
||||
|
||||
|
@ -461,7 +477,7 @@ public class RelatorioEmbarqueLocalidadeController extends MyGenericForwardComp
|
|||
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>>>();
|
||||
ls = new ArrayList<RelatorioEmbarqueLocalidadeBean>();
|
||||
|
@ -472,14 +488,16 @@ public class RelatorioEmbarqueLocalidadeController extends MyGenericForwardComp
|
|||
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
|
|||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue