diff --git a/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/tarifas/ModificacionMasivaTarifasController.java b/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/tarifas/ModificacionMasivaTarifasController.java index 3f2a186d5..5087997e0 100644 --- a/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/tarifas/ModificacionMasivaTarifasController.java +++ b/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/tarifas/ModificacionMasivaTarifasController.java @@ -27,14 +27,15 @@ import org.apache.commons.collections.Predicate; import org.apache.log4j.Logger; import org.apache.poi.hssf.usermodel.HSSFFont; import org.apache.poi.ss.usermodel.Cell; +import org.apache.poi.ss.usermodel.CellStyle; +import org.apache.poi.ss.usermodel.Font; import org.apache.poi.ss.usermodel.Row; import org.apache.poi.ss.usermodel.Sheet; import org.apache.poi.ss.usermodel.Workbook; -import org.apache.poi.xssf.usermodel.XSSFCell; -import org.apache.poi.xssf.usermodel.XSSFCellStyle; -import org.apache.poi.xssf.usermodel.XSSFFont; -import org.apache.poi.xssf.usermodel.XSSFRow; -import org.apache.poi.xssf.usermodel.XSSFSheet; +import org.apache.poi.xssf.streaming.SXSSFCell; +import org.apache.poi.xssf.streaming.SXSSFRow; +import org.apache.poi.xssf.streaming.SXSSFSheet; +import org.apache.poi.xssf.streaming.SXSSFWorkbook; import org.apache.poi.xssf.usermodel.XSSFWorkbook; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Scope; @@ -370,12 +371,12 @@ public class ModificacionMasivaTarifasController extends MyGenericForwardCompose } //Estilo padrão para os dois tipos de relatórios - XSSFWorkbook wb = new XSSFWorkbook (); + SXSSFWorkbook wb = new SXSSFWorkbook (); // fonte em negrito: - XSSFFont fonte = wb.createFont(); + Font fonte = wb.createFont(); fonte.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD); - XSSFCellStyle estilo = wb.createCellStyle(); + CellStyle estilo = wb.createCellStyle(); estilo.setFont(fonte); List lsRutaCombinacion = rutaCombinacionService.pesquisaTarifaObj(lsAddRmvMonedas, lsAddRmvMarcas, @@ -663,8 +664,8 @@ public class ModificacionMasivaTarifasController extends MyGenericForwardCompose this.lsOrgaoConcedente = lsOrgaoConcedente; } - private void gerarExcelSemAgrupamento(List lsRutaCombinacion, XSSFWorkbook wb, XSSFCellStyle estilo, BigDecimal coeficiente){ - XSSFSheet sheet1 = null; + private void gerarExcelSemAgrupamento(List lsRutaCombinacion, SXSSFWorkbook wb, CellStyle estilo, BigDecimal coeficiente){ + SXSSFSheet sheet1 = null; String ruta = ""; int contRow = 0; @@ -687,7 +688,7 @@ public class ModificacionMasivaTarifasController extends MyGenericForwardCompose sheetName = sheetName.replaceAll("/", "-"); log.debug("Aba: " + sheetName); - sheet1 = wb.createSheet(sheetName); + sheet1 = (SXSSFSheet) wb.createSheet(sheetName); contRow = 1; criarCabecalhoExcel(sheet1, estilo); @@ -703,9 +704,9 @@ public class ModificacionMasivaTarifasController extends MyGenericForwardCompose } } - private void gerarExcelComAgrupamento(List lsRutaCombinacion, XSSFWorkbook wb, XSSFCellStyle estilo, BigDecimal coeficiente) { + private void gerarExcelComAgrupamento(List lsRutaCombinacion, SXSSFWorkbook wb, CellStyle estilo, BigDecimal coeficiente) { - XSSFSheet sheet1 = null; + SXSSFSheet sheet1 = null; String ruta = ""; int contRow = 0; @@ -726,7 +727,7 @@ public class ModificacionMasivaTarifasController extends MyGenericForwardCompose log.debug("Linha: " + linha); if (sheet1 == null){ - sheet1 = wb.createSheet("Agrupado por Linha"); + sheet1 = (SXSSFSheet) wb.createSheet("Agrupado por Linha"); contRow = 0; } @@ -748,109 +749,109 @@ public class ModificacionMasivaTarifasController extends MyGenericForwardCompose return true; } - private void criarCabecalhoExcel(XSSFSheet sheet1, XSSFCellStyle estilo) { + private void criarCabecalhoExcel(SXSSFSheet sheet1, CellStyle estilo) { - XSSFRow rowCabecalho = sheet1.createRow(ROW_CABECALHO); + Row rowCabecalho = sheet1.createRow(ROW_CABECALHO); - XSSFCell cellId = rowCabecalho.createCell(IDX_CELL_ID); + Cell cellId = rowCabecalho.createCell(IDX_CELL_ID); cellId.setCellValue(Labels.getLabel("busquedaTarifaController.lhId.label")); cellId.setCellStyle(estilo); - XSSFCell cellMarca = rowCabecalho.createCell(IDX_CELL_MARCA); + Cell cellMarca = rowCabecalho.createCell(IDX_CELL_MARCA); cellMarca.setCellValue(Labels.getLabel("busquedaTarifaController.lhMarca.label")); cellMarca.setCellStyle(estilo); - XSSFCell cellNumLinha = rowCabecalho.createCell(IDX_CELL_NUMLINHA); + Cell cellNumLinha = rowCabecalho.createCell(IDX_CELL_NUMLINHA); cellNumLinha.setCellValue(Labels.getLabel("busquedaTarifaController.lhNumLinha.label")); cellNumLinha.setCellStyle(estilo); - XSSFCell cellDescLinha = rowCabecalho.createCell(IDX_CELL_DESCLINHA); + Cell cellDescLinha = rowCabecalho.createCell(IDX_CELL_DESCLINHA); cellDescLinha.setCellValue(Labels.getLabel("busquedaTarifaController.lhDescLinha.label")); cellDescLinha.setCellStyle(estilo); - XSSFCell cellTipoClasse = rowCabecalho.createCell(IDX_CELL_TIPOCLASSE); + Cell cellTipoClasse = rowCabecalho.createCell(IDX_CELL_TIPOCLASSE); cellTipoClasse.setCellValue(Labels.getLabel("busquedaTarifaController.lhClaseServicio.label")); cellTipoClasse.setCellStyle(estilo); - XSSFCell cellTrecho = rowCabecalho.createCell(IDX_CELL_TRECHO); + Cell cellTrecho = rowCabecalho.createCell(IDX_CELL_TRECHO); cellTrecho.setCellValue(Labels.getLabel("busquedaTarifaController.lhTramo.label")); cellTrecho.setCellStyle(estilo); - XSSFCell cellOrigem = rowCabecalho.createCell(IDX_CELL_ORIGEM); + Cell cellOrigem = rowCabecalho.createCell(IDX_CELL_ORIGEM); cellOrigem.setCellValue(Labels.getLabel("busquedaTarifaController.lhOrigen.label")); cellOrigem.setCellStyle(estilo); - XSSFCell cellDestino = rowCabecalho.createCell(IDX_CELL_DESTINO); + Cell cellDestino = rowCabecalho.createCell(IDX_CELL_DESTINO); cellDestino.setCellValue(Labels.getLabel("busquedaTarifaController.lhDestino.label")); cellDestino.setCellStyle(estilo); - XSSFCell cellTarifaOriginal = rowCabecalho.createCell(IDX_CELL_TARIFAORIGINAL); + Cell cellTarifaOriginal = rowCabecalho.createCell(IDX_CELL_TARIFAORIGINAL); cellTarifaOriginal.setCellValue(Labels.getLabel("busquedaTarifaController.lhPrecioOriginal.label")); cellTarifaOriginal.setCellStyle(estilo); - XSSFCell cellTarifaAtual = rowCabecalho.createCell(IDX_CELL_TARIFAATUAL); + Cell cellTarifaAtual = rowCabecalho.createCell(IDX_CELL_TARIFAATUAL); cellTarifaAtual.setCellValue(Labels.getLabel("busquedaTarifaController.lhPrecioExcel.label")); cellTarifaAtual.setCellStyle(estilo); - XSSFCell cellTarifaSimulada = rowCabecalho.createCell(IDX_CELL_TARIFA_SIMULADA); + Cell cellTarifaSimulada = rowCabecalho.createCell(IDX_CELL_TARIFA_SIMULADA); cellTarifaSimulada.setCellValue(Labels.getLabel("busquedaTarifaController.lhPrecioNuevo.label")); cellTarifaSimulada.setCellStyle(estilo); - XSSFCell cellPedagioAtual = rowCabecalho.createCell(IDX_CELL_PEDAGIOATUAL); + Cell cellPedagioAtual = rowCabecalho.createCell(IDX_CELL_PEDAGIOATUAL); cellPedagioAtual.setCellValue(Labels.getLabel("busquedaTarifaController.lhPrecioPedagio.label")); cellPedagioAtual.setCellStyle(estilo); - XSSFCell cellPedagioSimulado = rowCabecalho.createCell(IDX_CELL_PEDAGIOSIMULADO); + Cell cellPedagioSimulado = rowCabecalho.createCell(IDX_CELL_PEDAGIOSIMULADO); cellPedagioSimulado.setCellValue(Labels.getLabel("busquedaTarifaController.lhPrecioPedagioNuevo.label")); cellPedagioSimulado.setCellStyle(estilo); - XSSFCell cellTxEmbarqueAtual = rowCabecalho.createCell(IDX_CELL_TXEMBARQUEATUAL); + Cell cellTxEmbarqueAtual = rowCabecalho.createCell(IDX_CELL_TXEMBARQUEATUAL); cellTxEmbarqueAtual.setCellValue(Labels.getLabel("busquedaTarifaController.lhPrecioTxEmbarque.label")); cellTxEmbarqueAtual.setCellStyle(estilo); - XSSFCell cellTxEmbarqueSimulado = rowCabecalho.createCell(IDX_CELL_TXEMBARQUESIMULADO); + Cell cellTxEmbarqueSimulado = rowCabecalho.createCell(IDX_CELL_TXEMBARQUESIMULADO); cellTxEmbarqueSimulado.setCellValue(Labels.getLabel("busquedaTarifaController.lhPrecioTxEmbarqueSimulado.label")); cellTxEmbarqueSimulado.setCellStyle(estilo); - XSSFCell cellSeguroAtual = rowCabecalho.createCell(IDX_CELL_SEGUROATUAL); + Cell cellSeguroAtual = rowCabecalho.createCell(IDX_CELL_SEGUROATUAL); cellSeguroAtual.setCellValue(Labels.getLabel("busquedaTarifaController.lhPrecioSeguroAtual.label")); cellSeguroAtual.setCellStyle(estilo); - XSSFCell cellSeguroSimulado = rowCabecalho.createCell(IDX_CELL_SEGUROSIMULADO); + Cell cellSeguroSimulado = rowCabecalho.createCell(IDX_CELL_SEGUROSIMULADO); cellSeguroSimulado.setCellValue(Labels.getLabel("busquedaTarifaController.lhPrecioSeguroSimulado.label")); cellSeguroSimulado.setCellStyle(estilo); - XSSFCell cellTPPAtual = rowCabecalho.createCell(IDX_CELL_TPPATUAL); + Cell cellTPPAtual = rowCabecalho.createCell(IDX_CELL_TPPATUAL); cellTPPAtual.setCellValue(Labels.getLabel("busquedaTarifaController.lhPrecioTPPAtual.label")); cellTPPAtual.setCellStyle(estilo); - XSSFCell cellTPPSimulado = rowCabecalho.createCell(IDX_CELL_TPPSIMULADO); + Cell cellTPPSimulado = rowCabecalho.createCell(IDX_CELL_TPPSIMULADO); cellTPPSimulado.setCellValue(Labels.getLabel("busquedaTarifaController.lhPrecioTPPSimulado.label")); cellTPPSimulado.setCellStyle(estilo); - XSSFCell cellOrgaoConcedente = rowCabecalho.createCell(IDX_CELL_ORGAOCONCEDENTE); + Cell cellOrgaoConcedente = rowCabecalho.createCell(IDX_CELL_ORGAOCONCEDENTE); cellOrgaoConcedente.setCellValue(Labels.getLabel("busquedaTarifaController.lhOrgaoLabel.label")); cellOrgaoConcedente.setCellStyle(estilo); - XSSFCell cellPrefixo = rowCabecalho.createCell(IDX_CELL_PREFIXO); + Cell cellPrefixo = rowCabecalho.createCell(IDX_CELL_PREFIXO); cellPrefixo.setCellValue(Labels.getLabel("busquedaTarifaController.lhPrefixo.label")); cellPrefixo.setCellStyle(estilo); - XSSFCell cellVigencia = rowCabecalho.createCell(IDX_CELL_VIGENCIA); + Cell cellVigencia = rowCabecalho.createCell(IDX_CELL_VIGENCIA); cellVigencia.setCellValue(Labels.getLabel("busquedaTarifaController.lhFeciniciovigencia.label")); cellVigencia.setCellStyle(estilo); - XSSFCell cellMoeda = rowCabecalho.createCell(IDX_CELL_MOEDA); + Cell cellMoeda = rowCabecalho.createCell(IDX_CELL_MOEDA); cellMoeda.setCellValue(Labels.getLabel("busquedaTarifaController.lhMoneda.label")); cellMoeda.setCellStyle(estilo); - XSSFCell cellSentido = rowCabecalho.createCell(IDX_CELL_SENTIDO); + Cell cellSentido = rowCabecalho.createCell(IDX_CELL_SENTIDO); cellSentido.setCellValue(Labels.getLabel("busquedaTarifaController.lhSentido.label")); cellSentido.setCellStyle(estilo); } - private boolean popularPlanilha(XSSFSheet sheet1,Object[] obj, XSSFCellStyle estilo, BigDecimal coeficiente, int rowNum){ - XSSFRow row = sheet1.createRow(rowNum); + private boolean popularPlanilha(SXSSFSheet sheet1,Object[] obj, CellStyle estilo, BigDecimal coeficiente, int rowNum){ + SXSSFRow row = (SXSSFRow) sheet1.createRow(rowNum); //IDXs das coluna diferente dos IDXs do obj row.createCell(IDX_CELL_ID).setCellValue(Integer.parseInt(obj[0].toString())); @@ -911,7 +912,7 @@ public class ModificacionMasivaTarifasController extends MyGenericForwardCompose novoPrecio = atual; novoPrecio = novoPrecio.multiply(coeficiente).setScale(2, RoundingMode.HALF_UP); - XSSFCell cellNovoPrecio = row.createCell(IDX_CELL_TARIFA_SIMULADA);//celula alterada + SXSSFCell cellNovoPrecio = (SXSSFCell) row.createCell(IDX_CELL_TARIFA_SIMULADA);//celula alterada cellNovoPrecio.setCellValue(novoPrecio.setScale(2).doubleValue()); cellNovoPrecio.setCellStyle(estilo); } @@ -926,7 +927,7 @@ public class ModificacionMasivaTarifasController extends MyGenericForwardCompose novoPrecio = BigDecimal.valueOf(Double.valueOf(getStringImporteSafe(obj[16]))); novoPrecio = novoPrecio.multiply(coeficiente).setScale(2, RoundingMode.HALF_UP); - XSSFCell cellNovoPrecio = row.createCell(IDX_CELL_PEDAGIOSIMULADO); //celula alterada + Cell cellNovoPrecio = row.createCell(IDX_CELL_PEDAGIOSIMULADO); //celula alterada cellNovoPrecio.setCellValue(novoPrecio.setScale(2).doubleValue()); cellNovoPrecio.setCellStyle(estilo); } @@ -941,7 +942,7 @@ public class ModificacionMasivaTarifasController extends MyGenericForwardCompose novoPrecio = BigDecimal.valueOf(Double.valueOf(getStringImporteSafe(obj[18]))); novoPrecio = novoPrecio.multiply(coeficiente).setScale(2, RoundingMode.HALF_UP); - XSSFCell cellNovoPrecio = row.createCell(IDX_CELL_TXEMBARQUESIMULADO); //celula alterada + Cell cellNovoPrecio = row.createCell(IDX_CELL_TXEMBARQUESIMULADO); //celula alterada cellNovoPrecio.setCellValue(novoPrecio.setScale(2).doubleValue()); cellNovoPrecio.setCellStyle(estilo); } @@ -956,7 +957,7 @@ public class ModificacionMasivaTarifasController extends MyGenericForwardCompose novoPrecio = BigDecimal.valueOf(Double.valueOf(getStringImporteSafe(obj[19]))); novoPrecio = novoPrecio.multiply(coeficiente).setScale(2, RoundingMode.HALF_UP); - XSSFCell cellNovoPrecio = row.createCell(IDX_CELL_SEGUROSIMULADO); //celula alterada + Cell cellNovoPrecio = row.createCell(IDX_CELL_SEGUROSIMULADO); //celula alterada cellNovoPrecio.setCellValue(novoPrecio.setScale(2).doubleValue()); cellNovoPrecio.setCellStyle(estilo); } @@ -971,7 +972,7 @@ public class ModificacionMasivaTarifasController extends MyGenericForwardCompose novoPrecio = BigDecimal.valueOf(Double.valueOf(getStringImporteSafe(obj[20]))); novoPrecio = novoPrecio.multiply(coeficiente).setScale(2, RoundingMode.HALF_UP); - XSSFCell cellNovoPrecio = row.createCell(IDX_CELL_TPPSIMULADO); //celula alterada + Cell cellNovoPrecio = row.createCell(IDX_CELL_TPPSIMULADO); //celula alterada cellNovoPrecio.setCellValue(novoPrecio.setScale(2).doubleValue()); cellNovoPrecio.setCellStyle(estilo); }