fixes bug#14052
qua:renato dev: git-svn-id: http://desenvolvimento.rjconsultores.com.br/repositorio/sco/AdmVenta/Web/trunk/ventaboletos@93150 d1611594-4594-4d17-8e1d-87c2c4800839master
parent
0da7cceb6a
commit
b5ebed25f9
|
@ -1,33 +1,94 @@
|
||||||
|
|
||||||
package com.rjconsultores.ventaboletos.relatorios.utilitarios;
|
package com.rjconsultores.ventaboletos.relatorios.utilitarios;
|
||||||
|
|
||||||
public class RelatorioEmbarqueLocalidadeBean {
|
public class RelatorioEmbarqueLocalidadeBean {
|
||||||
protected String data;
|
private String data;
|
||||||
protected String linha;
|
private String horario;
|
||||||
protected Long embarques;
|
private String linha;
|
||||||
|
private String classe;
|
||||||
|
private Long embarques;
|
||||||
|
private Integer indexColun;
|
||||||
|
private Integer indexLinha;
|
||||||
|
|
||||||
|
public String getHorario() {
|
||||||
|
return horario;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setHorario(String horario) {
|
||||||
|
this.horario = horario;
|
||||||
|
}
|
||||||
|
|
||||||
public String getData() {
|
public String getData() {
|
||||||
return data.substring(0, 10);
|
return data.substring(0, 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getHorario(){
|
|
||||||
return data.substring(11, data.length());
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setData(String data) {
|
public void setData(String data) {
|
||||||
this.data = data;
|
this.data = data;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getLinha() {
|
public String getLinha() {
|
||||||
return linha;
|
return linha;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLinha(String linha) {
|
public void setLinha(String linha) {
|
||||||
this.linha = linha;
|
this.linha = linha;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Long getEmbarques() {
|
public Long getEmbarques() {
|
||||||
return embarques;
|
return embarques;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setEmbarques(Long embarques) {
|
public void setEmbarques(Long embarques) {
|
||||||
this.embarques = embarques;
|
this.embarques = embarques;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Integer getIndexColun() {
|
||||||
|
return indexColun;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIndexColun(Integer indexColun) {
|
||||||
|
this.indexColun = indexColun;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getIndexLinha() {
|
||||||
|
return indexLinha;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIndexLinha(Integer indexLinha) {
|
||||||
|
this.indexLinha = indexLinha;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getClasse() {
|
||||||
|
return classe;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setClasse(String classe) {
|
||||||
|
this.classe = classe;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
final int prime = 31;
|
||||||
|
int result = 1;
|
||||||
|
result = prime * result + ((linha == null) ? 0 : linha.hashCode());
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object obj) {
|
||||||
|
if (this == obj)
|
||||||
|
return true;
|
||||||
|
if (obj == null)
|
||||||
|
return false;
|
||||||
|
if (getClass() != obj.getClass())
|
||||||
|
return false;
|
||||||
|
RelatorioEmbarqueLocalidadeBean other = (RelatorioEmbarqueLocalidadeBean) obj;
|
||||||
|
if (linha == null) {
|
||||||
|
if (other.linha != null)
|
||||||
|
return false;
|
||||||
|
} else if (!linha.equals(other.linha))
|
||||||
|
return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,10 +9,12 @@ import java.sql.SQLException;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
|
import java.util.TreeMap;
|
||||||
|
|
||||||
import javax.sql.DataSource;
|
import javax.sql.DataSource;
|
||||||
|
|
||||||
|
@ -23,7 +25,10 @@ import org.apache.poi.hssf.usermodel.HSSFFont;
|
||||||
import org.apache.poi.hssf.usermodel.HSSFRow;
|
import org.apache.poi.hssf.usermodel.HSSFRow;
|
||||||
import org.apache.poi.hssf.usermodel.HSSFSheet;
|
import org.apache.poi.hssf.usermodel.HSSFSheet;
|
||||||
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
||||||
|
import org.apache.poi.hssf.util.CellReference;
|
||||||
|
import org.apache.poi.hssf.util.HSSFColor;
|
||||||
import org.apache.poi.ss.usermodel.CellStyle;
|
import org.apache.poi.ss.usermodel.CellStyle;
|
||||||
|
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.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
|
@ -99,9 +104,10 @@ public class RelatorioEmbarqueLocalidadeController extends MyGenericForwardComp
|
||||||
private Ruta ruta;
|
private Ruta ruta;
|
||||||
private OrgaoConcedente orgao;
|
private OrgaoConcedente orgao;
|
||||||
private Parada origem;
|
private Parada origem;
|
||||||
|
private int total;
|
||||||
|
private Map<String, Integer> mapAux = new HashMap<String, Integer>();
|
||||||
|
|
||||||
|
private List<RelatorioEmbarqueLocalidadeBean> ls;
|
||||||
private List<RelatorioEmbarqueLocalidadeBean> lsDadosRelatorio;
|
|
||||||
|
|
||||||
private void executarRelatorio() throws Exception {
|
private void executarRelatorio() throws Exception {
|
||||||
|
|
||||||
|
@ -119,14 +125,14 @@ public class RelatorioEmbarqueLocalidadeController extends MyGenericForwardComp
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
String sql = getSql(empresa.getEmpresaId().toString(),
|
String sql = getSql(empresa, ruta != null ? ruta.getRutaId().toString() : null,
|
||||||
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;
|
||||||
try{
|
try{
|
||||||
|
|
||||||
NamedParameterStatement stmt = new NamedParameterStatement(dataSourceRead.getConnection(), sql);
|
NamedParameterStatement stmt = new NamedParameterStatement(dataSourceRead.getConnection(), sql);
|
||||||
ResultSet rset = null;
|
|
||||||
|
|
||||||
stmt.setString(FILED_FEC_INICIO, fecInicio);
|
stmt.setString(FILED_FEC_INICIO, fecInicio);
|
||||||
stmt.setString(FIELD_FEC_FINAL, fecFinal);
|
stmt.setString(FIELD_FEC_FINAL, fecFinal);
|
||||||
|
@ -152,129 +158,135 @@ public class RelatorioEmbarqueLocalidadeController extends MyGenericForwardComp
|
||||||
}
|
}
|
||||||
rset = stmt.executeQuery();
|
rset = stmt.executeQuery();
|
||||||
|
|
||||||
lsDadosRelatorio = new ArrayList<RelatorioEmbarqueLocalidadeBean>();
|
|
||||||
Map<String, Map<String, List<RelatorioEmbarqueLocalidadeBean>>> datas = ResultSetToList(rset);
|
Map<String, Map<String, List<RelatorioEmbarqueLocalidadeBean>>> datas = ResultSetToList(rset);
|
||||||
|
|
||||||
exportaExcel(datas);
|
exportaExcel(datas);
|
||||||
} catch (Exception e){
|
} catch (Exception e){
|
||||||
log.error("", e);
|
log.error("", e);
|
||||||
|
}finally {
|
||||||
|
if(rset != null && !rset.isClosed()) {
|
||||||
|
rset.close();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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();
|
||||||
|
|
||||||
HSSFCellStyle estiloVerticalMerge = wb.createCellStyle();
|
HSSFCellStyle estiloVerticalMerge = wb.createCellStyle();
|
||||||
estiloVerticalMerge.setVerticalAlignment(CellStyle.VERTICAL_CENTER);
|
estiloVerticalMerge.setVerticalAlignment(CellStyle.ALIGN_CENTER);
|
||||||
|
|
||||||
HSSFSheet sheet1 = null;
|
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);
|
||||||
|
|
||||||
int linha = NUM_LINHA_INICIO;
|
HSSFSheet sheet1 = null;
|
||||||
int coluna = 1;
|
|
||||||
HSSFRow row = null;
|
|
||||||
|
|
||||||
for (Entry<String, Map<String, List<RelatorioEmbarqueLocalidadeBean>>> data : datas.entrySet()){
|
int linha = NUM_LINHA_INICIO;
|
||||||
// entry.getKey() => Data
|
HSSFRow row = null;
|
||||||
sheet1 = wb.createSheet(data.getKey().replaceAll("/", "-"));
|
|
||||||
geraCabecalho(sheet1, data.getKey(), wb);
|
|
||||||
int totalGeral = 0;
|
|
||||||
for (Entry<String, List<RelatorioEmbarqueLocalidadeBean>> horario : data.getValue().entrySet()){
|
|
||||||
row = sheet1.createRow(linha);
|
|
||||||
HSSFCell cellHorario = row.createCell(0);
|
|
||||||
cellHorario.setCellValue(horario.getKey());
|
|
||||||
cellHorario.setCellStyle(estiloVerticalMerge);
|
|
||||||
|
|
||||||
HSSFCell cellTotal = row.createCell(7);
|
sheet1 = wb.createSheet("07-08-19");
|
||||||
|
geraCabecalho(sheet1, "07-08-19", wb);
|
||||||
|
|
||||||
List<RelatorioEmbarqueLocalidadeBean> rows = horario.getValue();
|
Map<String, Integer> linhas = new HashMap<String, Integer>();
|
||||||
|
int totalGeral = 0;
|
||||||
|
|
||||||
int rowcount = (int) Math.ceil((double)rows.size() / 3) -1;
|
int linhaTotalizador = 6;
|
||||||
|
HSSFCell cellTotal = null ;
|
||||||
|
for (RelatorioEmbarqueLocalidadeBean bean : ls) {
|
||||||
|
|
||||||
|
int indexColun = mapAux.get(bean.getHorario());
|
||||||
|
|
||||||
sheet1.addMergedRegion(new CellRangeAddress(
|
if(!linhas.containsKey(bean.getLinha())) {
|
||||||
linha, //first row (0-based)
|
linhas.put(bean.getLinha(), linha);
|
||||||
linha+rowcount, //last row (0-based)
|
row = sheet1.createRow(linha);
|
||||||
0, //first column (0-based)
|
linhaTotalizador = linha;
|
||||||
0 //last column (0-based)
|
linha++;
|
||||||
));
|
|
||||||
|
|
||||||
sheet1.addMergedRegion(new CellRangeAddress(
|
}else {
|
||||||
linha, //first row (0-based)
|
row = sheet1.getRow(linhas.get(bean.getLinha()));
|
||||||
linha+rowcount, //last row (0-based)
|
linhaTotalizador = sheet1.getRow(linhas.get(bean.getLinha())).getRowNum();
|
||||||
7, //first column (0-based)
|
|
||||||
7 //last column (0-based)
|
|
||||||
));
|
|
||||||
|
|
||||||
int beancount = 1;
|
|
||||||
int embarquesTotais = 0;
|
|
||||||
for (RelatorioEmbarqueLocalidadeBean bean : rows){
|
|
||||||
if (beancount == 4){
|
|
||||||
linha++;
|
|
||||||
row = sheet1.createRow(linha);
|
|
||||||
coluna = 1;
|
|
||||||
}
|
|
||||||
row.createCell(coluna++).setCellValue(bean.getLinha());
|
|
||||||
row.createCell(coluna++).setCellValue(bean.getEmbarques());
|
|
||||||
embarquesTotais += bean.getEmbarques();
|
|
||||||
beancount++;
|
|
||||||
}
|
|
||||||
|
|
||||||
cellTotal.setCellValue(embarquesTotais);
|
|
||||||
cellTotal.setCellStyle(estiloVerticalMerge);
|
|
||||||
|
|
||||||
linha++;
|
|
||||||
coluna = 1;
|
|
||||||
|
|
||||||
totalGeral += embarquesTotais;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
row = sheet1.createRow(linha);
|
HSSFCell cellHorario = row.createCell(0);
|
||||||
HSSFCell cellTotal = row.createCell(0);
|
cellHorario.setCellStyle(estiloVerticalMerge);
|
||||||
cellTotal.setCellValue("TOTAL");
|
|
||||||
HSSFCell cellTotalValue = row.createCell(7);
|
|
||||||
cellTotalValue.setCellValue(totalGeral);
|
|
||||||
|
|
||||||
linha = NUM_LINHA_INICIO;
|
cellTotal = row.createCell(mapAux.size() + 3);
|
||||||
|
|
||||||
sheet1.autoSizeColumn(0);
|
row.createCell(indexColun).setCellValue(bean.getEmbarques());
|
||||||
sheet1.autoSizeColumn(1);
|
row.createCell(0).setCellValue(bean.getLinha());
|
||||||
sheet1.autoSizeColumn(2);
|
row.createCell(1).setCellValue(bean.getClasse());
|
||||||
sheet1.autoSizeColumn(3);
|
|
||||||
sheet1.autoSizeColumn(4);
|
|
||||||
sheet1.autoSizeColumn(5);
|
|
||||||
sheet1.autoSizeColumn(6);
|
|
||||||
sheet1.autoSizeColumn(7);
|
|
||||||
|
|
||||||
}
|
cellTotal.setCellStyle(estiloVerticalMerge);
|
||||||
if(datas.isEmpty()){
|
String colluna;
|
||||||
Messagebox.show(
|
String celTotal ;
|
||||||
Labels.getLabel("relatorio.parametro.msgNoData"),
|
colluna = CellReference.convertNumToColString(mapAux.size()+2);
|
||||||
Labels.getLabel("relatorioEmbarqueLocalidadeController.window.title"),
|
celTotal = "SUM(D"+(linhaTotalizador+1)+":"+colluna+(linhaTotalizador+1)+")";
|
||||||
Messagebox.OK, Messagebox.INFORMATION);
|
row.createCell(mapAux.size()+3).setCellValue(celTotal);
|
||||||
return;
|
cellTotal.setCellFormula(celTotal);
|
||||||
}
|
cellTotal.setCellStyle(style);
|
||||||
|
|
||||||
String nomeArquivo =
|
totalGeral += bean.getEmbarques();
|
||||||
UsuarioLogado.getUsuarioLogado().getNombusuario()
|
}
|
||||||
+ "_" + Calendar.getInstance().getTime().getTime()
|
|
||||||
+ "_" + "EmbarqueLocalidade";
|
|
||||||
|
|
||||||
File fNomeArquivo = File.createTempFile(nomeArquivo, ".tmp");
|
row = sheet1.createRow(linha);
|
||||||
|
int qtdLinhas = linhas.size()+5;
|
||||||
|
|
||||||
FileOutputStream stream = new FileOutputStream(fNomeArquivo);
|
int somatorioColuna = 3;
|
||||||
stream.flush();
|
for (int i = 3; i < mapAux.size()+3; i++) {
|
||||||
wb.write(stream);
|
|
||||||
stream.close();
|
|
||||||
|
|
||||||
InputStream is = null;
|
String colluna = CellReference.convertNumToColString(i);
|
||||||
is = new FileInputStream(fNomeArquivo);
|
cellTotal = row.createCell(somatorioColuna);
|
||||||
Filedownload.save(is, "application/xls", "EmbarqueLocalidade.xls");
|
cellTotal.setCellFormula("SUM("+colluna+6+":"+colluna+(qtdLinhas)+")");
|
||||||
|
cellTotal.setCellStyle(style);
|
||||||
|
somatorioColuna++;
|
||||||
|
|
||||||
fNomeArquivo.delete();
|
}
|
||||||
} catch (Exception e){
|
|
||||||
log.error("", e);
|
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);
|
||||||
|
stream.flush();
|
||||||
|
wb.write(stream);
|
||||||
|
stream.close();
|
||||||
|
|
||||||
|
InputStream is = null;
|
||||||
|
is = new FileInputStream(fNomeArquivo);
|
||||||
|
Filedownload.save(is, "application/xls", "EmbarqueLocalidade.xls");
|
||||||
|
|
||||||
|
fNomeArquivo.delete();
|
||||||
|
}catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void geraCabecalhoTitulo(HSSFSheet sheet1, HSSFWorkbook wb){
|
private void geraCabecalhoTitulo(HSSFSheet sheet1, HSSFWorkbook wb){
|
||||||
|
@ -322,21 +334,66 @@ public class RelatorioEmbarqueLocalidadeController extends MyGenericForwardComp
|
||||||
1, //first column (0-based)
|
1, //first column (0-based)
|
||||||
7 //last 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
|
//Montando o Cabeçalho
|
||||||
HSSFRow r0 = sheet1.createRow(NUM_LINHA_DATA_EMPRESA);
|
HSSFRow r0 = sheet1.createRow(NUM_LINHA_DATA_EMPRESA);
|
||||||
r0.createCell(0).setCellValue("DATA: " + dataAtual);
|
|
||||||
r0.createCell(1).setCellValue("EMPRESA: " + empresa.getNombempresa());
|
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);
|
HSSFRow r1 = sheet1.createRow(NUM_LINHA_DATA_EMPRESA+1);
|
||||||
r1.createCell(0).setCellValue("FAIXA HORÁRIA");
|
List<RelatorioEmbarqueLocalidadeBean> lsAux = new ArrayList<RelatorioEmbarqueLocalidadeBean>();
|
||||||
r1.createCell(1).setCellValue("Prefixo / Nome Linha");
|
|
||||||
r1.createCell(2).setCellValue("Embarques");
|
mapAux = new HashMap<String, Integer>();
|
||||||
r1.createCell(3).setCellValue("Prefixo / Nome Linha");
|
Map<String, Integer> map = new HashMap<String, Integer>();
|
||||||
r1.createCell(4).setCellValue("Embarques");
|
|
||||||
r1.createCell(5).setCellValue("Prefixo / Nome Linha");
|
int i = 3;
|
||||||
r1.createCell(6).setCellValue("Embarques");
|
for (RelatorioEmbarqueLocalidadeBean bean : ls) {
|
||||||
r1.createCell(7).setCellValue("TOTAL");
|
|
||||||
|
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 {
|
public void onClick$btnExecutarRelatorio(Event ev) throws Exception {
|
||||||
|
@ -364,16 +421,17 @@ public class RelatorioEmbarqueLocalidadeController extends MyGenericForwardComp
|
||||||
cmbOrigem.setModel(new ListModelList(lsOrigens));
|
cmbOrigem.setModel(new ListModelList(lsOrigens));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected String getSql(String empresa, String ruta, String orgao, String origem, String horInicio, String horFim) {
|
protected String getSql(Empresa empresa, String ruta, String orgao, String origem, String horInicio, String horFim) {
|
||||||
StringBuilder sql = new StringBuilder();
|
StringBuilder sql = new StringBuilder();
|
||||||
|
|
||||||
sql.append("select ");
|
sql.append("select ");
|
||||||
sql.append(" concat(concat(concat(TO_CHAR(b.fechorviaje,'DD/MM/YYYY HH24'), ':00'), ' a '),concat(TO_CHAR(b.fechorviaje,'HH24'), ':59')), ");
|
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), ");
|
sql.append(" concat(concat(r.prefixo, ' '), r.descruta), cla.descclase, ");
|
||||||
sql.append(" count(b.boleto_id) ");
|
sql.append(" count(b.boleto_id) ");
|
||||||
sql.append("from ");
|
sql.append("from ");
|
||||||
sql.append(" boleto b ");
|
sql.append(" boleto b ");
|
||||||
sql.append(" inner join ruta r on r.ruta_id = b.ruta_id ");
|
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(" 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') ");
|
||||||
|
@ -384,7 +442,7 @@ public class RelatorioEmbarqueLocalidadeController extends MyGenericForwardComp
|
||||||
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.isEmpty()){
|
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")){
|
||||||
|
@ -395,8 +453,8 @@ public class RelatorioEmbarqueLocalidadeController extends MyGenericForwardComp
|
||||||
}
|
}
|
||||||
|
|
||||||
sql.append("group by ");
|
sql.append("group by ");
|
||||||
sql.append(" concat(concat(concat(TO_CHAR(b.fechorviaje,'DD/MM/YYYY HH24'), ':00'), ' a '),concat(TO_CHAR(b.fechorviaje,'HH24'), ':59')), ");
|
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) ");
|
sql.append(" concat(concat(r.prefixo, ' '), r.descruta), cla.descclase ");
|
||||||
sql.append("order by ");
|
sql.append("order by ");
|
||||||
sql.append(" 1 ");
|
sql.append(" 1 ");
|
||||||
|
|
||||||
|
@ -406,26 +464,22 @@ public class RelatorioEmbarqueLocalidadeController extends MyGenericForwardComp
|
||||||
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>();
|
||||||
|
|
||||||
while (rset.next()) {
|
while (rset.next()) {
|
||||||
RelatorioEmbarqueLocalidadeBean bean = new RelatorioEmbarqueLocalidadeBean();
|
RelatorioEmbarqueLocalidadeBean bean = new RelatorioEmbarqueLocalidadeBean();
|
||||||
bean.setData(rset.getString(1));
|
bean.setHorario(rset.getString(1));
|
||||||
bean.setLinha(rset.getString(2));
|
bean.setLinha(rset.getString(2));
|
||||||
bean.setEmbarques(rset.getLong(3));
|
bean.setClasse(rset.getString(3));
|
||||||
|
bean.setEmbarques(rset.getLong(4));
|
||||||
if (!datas.containsKey(bean.getData())){
|
ls.add(bean);;
|
||||||
datas.put(bean.getData(), new LinkedHashMap<String, List<RelatorioEmbarqueLocalidadeBean>>());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!datas.get(bean.getData()).containsKey(bean.getHorario())){
|
|
||||||
datas.get(bean.getData()).put(bean.getHorario(), new ArrayList<RelatorioEmbarqueLocalidadeBean>());
|
|
||||||
}
|
|
||||||
|
|
||||||
datas.get(bean.getData()).get(bean.getHorario()).add(bean);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return datas;
|
return datas;
|
||||||
}
|
}
|
||||||
|
public void checarLinhasDuplicadas() {
|
||||||
|
|
||||||
|
}
|
||||||
public Datebox getDatInicial() {
|
public Datebox getDatInicial() {
|
||||||
return datInicial;
|
return datInicial;
|
||||||
}
|
}
|
||||||
|
@ -523,3 +577,4 @@ public class RelatorioEmbarqueLocalidadeController extends MyGenericForwardComp
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue