bug#22266
dev: Valdevir qua: git-svn-id: http://desenvolvimento.rjconsultores.com.br/repositorio/sco/AdmVenta/Web/trunk/ventaboletos@108245 d1611594-4594-4d17-8e1d-87c2c4800839master
parent
ffa367f964
commit
09a8218109
|
@ -6,7 +6,9 @@ package com.rjconsultores.ventaboletos.web.gui.controladores.tarifas;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
|
import java.io.FileNotFoundException;
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -25,6 +27,8 @@ 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.ss.usermodel.Workbook;
|
||||||
|
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.context.annotation.Scope;
|
import org.springframework.context.annotation.Scope;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
|
@ -87,6 +91,7 @@ import com.rjconsultores.ventaboletos.web.utilerias.MyGenericForwardComposer;
|
||||||
public class TarifaEscalaContorller extends MyGenericForwardComposer {
|
public class TarifaEscalaContorller extends MyGenericForwardComposer {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private TarifaService tarifaService;
|
private TarifaService tarifaService;
|
||||||
@Autowired
|
@Autowired
|
||||||
|
@ -113,6 +118,7 @@ public class TarifaEscalaContorller extends MyGenericForwardComposer {
|
||||||
private CiudadService ciudadService;
|
private CiudadService ciudadService;
|
||||||
@Autowired
|
@Autowired
|
||||||
private MarcaClaseServicioService marcaClaseServicioService;
|
private MarcaClaseServicioService marcaClaseServicioService;
|
||||||
|
|
||||||
private List<Marca> lsMarcas;
|
private List<Marca> lsMarcas;
|
||||||
private List<ClaseServicio> lsClaseServico;
|
private List<ClaseServicio> lsClaseServico;
|
||||||
private List<Moneda> lsMonedas;
|
private List<Moneda> lsMonedas;
|
||||||
|
@ -134,8 +140,10 @@ public class TarifaEscalaContorller extends MyGenericForwardComposer {
|
||||||
private Map<String, Tarifa> mapTramoTarifaNovo;
|
private Map<String, Tarifa> mapTramoTarifaNovo;
|
||||||
private Map<Tramo, Decimalbox> mapTarifaTextbox;
|
private Map<Tramo, Decimalbox> mapTarifaTextbox;
|
||||||
private List<List> lsGridRender;
|
private List<List> lsGridRender;
|
||||||
|
|
||||||
private static Logger log = Logger.getLogger(TarifaEscalaContorller.class);
|
private static Logger log = Logger.getLogger(TarifaEscalaContorller.class);
|
||||||
|
|
||||||
|
|
||||||
public List<ClaseServicio> getLsClaseServico() {
|
public List<ClaseServicio> getLsClaseServico() {
|
||||||
return lsClaseServico;
|
return lsClaseServico;
|
||||||
}
|
}
|
||||||
|
@ -804,7 +812,25 @@ public class TarifaEscalaContorller extends MyGenericForwardComposer {
|
||||||
public void onClick$btnExportarExcel(Event ev) throws InterruptedException {
|
public void onClick$btnExportarExcel(Event ev) throws InterruptedException {
|
||||||
validacion();
|
validacion();
|
||||||
try {
|
try {
|
||||||
|
gerarExcel(false);
|
||||||
|
} catch (Exception ex) {
|
||||||
|
|
||||||
|
log.info("** Erro ao exportar escala de tarifa: " + ex);
|
||||||
|
log.error("** Erro ao exportar escala de tarifa: " + ex);
|
||||||
|
Messagebox.show(Labels.getLabel("MSG.Error"), Labels.getLabel("tarifaEscalaContorller.window.title"), Messagebox.OK,
|
||||||
|
Messagebox.ERROR);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @throws IOException
|
||||||
|
* @throws FileNotFoundException
|
||||||
|
*/
|
||||||
|
private void gerarExcel(Boolean isImprimir) throws IOException, FileNotFoundException {
|
||||||
HSSFWorkbook wb = new HSSFWorkbook();
|
HSSFWorkbook wb = new HSSFWorkbook();
|
||||||
|
Workbook wbi = new XSSFWorkbook();
|
||||||
|
|
||||||
|
|
||||||
// fonte em negrito:
|
// fonte em negrito:
|
||||||
HSSFFont fonte = wb.createFont();
|
HSSFFont fonte = wb.createFont();
|
||||||
|
@ -863,32 +889,48 @@ public class TarifaEscalaContorller extends MyGenericForwardComposer {
|
||||||
}
|
}
|
||||||
|
|
||||||
// linha vazia entre o cabeçalho e escala:
|
// linha vazia entre o cabeçalho e escala:
|
||||||
HSSFRow rowEspaco = sheet1.createRow(5);
|
HSSFRow rowEspaco = sheet1.createRow(6);
|
||||||
rowEspaco.createCell(0).setCellValue("");
|
rowEspaco.createCell(1).setCellValue("");
|
||||||
|
|
||||||
|
int destino = 0;
|
||||||
|
Boolean isSec = false;
|
||||||
for (int i = 0; i < lsGridRender.size(); i++) {
|
for (int i = 0; i < lsGridRender.size(); i++) {
|
||||||
List list = lsGridRender.get(i);
|
List list = lsGridRender.get(i);
|
||||||
|
|
||||||
HSSFRow row = sheet1.createRow(i + 6);
|
HSSFRow row = sheet1.createRow(i + 6);
|
||||||
|
destino++;
|
||||||
|
isSec = false;
|
||||||
for (int j = 0; j < list.size(); j++) {
|
for (int j = 0; j < list.size(); j++) {
|
||||||
Object st = list.get(j);
|
Object st = list.get(j);
|
||||||
|
|
||||||
if (st instanceof Tarifa) {
|
if (st instanceof Tarifa) {
|
||||||
Tarifa tmp = (Tarifa) st;
|
Tarifa tmp = (Tarifa) st;
|
||||||
|
if(i>=1 && destino <= lsGridRender.size()) {
|
||||||
|
row.createCell(0).setCellValue(destino);
|
||||||
|
}
|
||||||
|
row.createCell(j+1).setCellValue(tmp.getPrecio().setScale(2).toString());
|
||||||
|
|
||||||
row.createCell(j).setCellValue(tmp.getPrecio().setScale(2).toString());
|
|
||||||
} else if (st instanceof Parada) {
|
} else if (st instanceof Parada) {
|
||||||
Parada parada = (Parada) st;
|
Parada parada = (Parada) st;
|
||||||
|
|
||||||
HSSFCell cell = row.createCell(j);
|
HSSFCell cell = row.createCell(j+1);
|
||||||
cell.setCellStyle(estilo);
|
cell.setCellStyle(estilo);
|
||||||
|
cell.setCellValue(parada.getDescparada()+" "+"("+parada.getCveparada()+")");
|
||||||
|
|
||||||
cell.setCellValue(parada.getCveparada());
|
|
||||||
} else {
|
} else {
|
||||||
row.createCell(j).setCellValue(st.toString());
|
|
||||||
|
if(!isSec) {
|
||||||
|
row.createCell(j+1).setCellValue(destino+1);
|
||||||
|
isSec = true;
|
||||||
|
} else {
|
||||||
|
row.createCell(j+1).setCellValue(st.toString());
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
sheet1.setFitToPage(true);
|
||||||
|
sheet1.getPrintSetup().setFitWidth((short)1);
|
||||||
|
sheet1.getPrintSetup().setFitHeight((short)0);
|
||||||
|
|
||||||
String nomeArquivo = UsuarioLogado.getUsuarioLogado().getNombusuario() + "_" + Calendar.getInstance().getTime().getTime() + "_"
|
String nomeArquivo = UsuarioLogado.getUsuarioLogado().getNombusuario() + "_" + Calendar.getInstance().getTime().getTime() + "_"
|
||||||
+ "escala";
|
+ "escala";
|
||||||
|
@ -897,22 +939,24 @@ public class TarifaEscalaContorller extends MyGenericForwardComposer {
|
||||||
|
|
||||||
FileOutputStream stream = new FileOutputStream(fNomeArquivo);
|
FileOutputStream stream = new FileOutputStream(fNomeArquivo);
|
||||||
stream.flush();
|
stream.flush();
|
||||||
|
|
||||||
|
if (isImprimir) {
|
||||||
|
wbi.write(stream);
|
||||||
|
} else {
|
||||||
wb.write(stream);
|
wb.write(stream);
|
||||||
|
}
|
||||||
stream.close();
|
stream.close();
|
||||||
|
|
||||||
InputStream is = null;
|
InputStream is = null;
|
||||||
is = new FileInputStream(fNomeArquivo);
|
is = new FileInputStream(fNomeArquivo);
|
||||||
|
|
||||||
|
if (isImprimir) {
|
||||||
Filedownload.save(is, "application/xls", "escala.xls");
|
Filedownload.save(is, "application/xls", "escala.xls");
|
||||||
|
} else {
|
||||||
|
Filedownload.save(is, "application/xls", "escala.xls");
|
||||||
|
}
|
||||||
|
|
||||||
fNomeArquivo.delete();
|
fNomeArquivo.delete();
|
||||||
} catch (Exception ex) {
|
|
||||||
|
|
||||||
log.info("** Erro ao exportar escala de tarifa: " + ex);
|
|
||||||
log.error("** Erro ao exportar escala de tarifa: " + ex);
|
|
||||||
Messagebox.show(Labels.getLabel("MSG.Error"), Labels.getLabel("tarifaEscalaContorller.window.title"), Messagebox.OK,
|
|
||||||
Messagebox.ERROR);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onChange$cmbClaseServicio(Event ev) {
|
public void onChange$cmbClaseServicio(Event ev) {
|
||||||
|
|
Loading…
Reference in New Issue