From 4ae389fda832ae93223d3409f09ddf3082d87e88 Mon Sep 17 00:00:00 2001 From: "eduardo.dicarde" Date: Fri, 19 Feb 2016 16:51:16 +0000 Subject: [PATCH] fixes bug#7129 git-svn-id: http://desenvolvimento.rjconsultores.com.br/repositorio/sco/AdmVenta/Web/trunk/ventaboletos@53080 d1611594-4594-4d17-8e1d-87c2c4800839 --- .../ModificacionMasivaTarifasController.java | 518 ++++++++++++------ ...ficacionMasivaTarifasUploadController.java | 32 +- web/WEB-INF/i3-label_es_MX.label | 3 + web/WEB-INF/i3-label_pt_BR.label | 3 + web/gui/tarifas/modificacionMasivaTarifas.zul | 8 + 5 files changed, 392 insertions(+), 172 deletions(-) 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 010006f2c..3df3ac90f 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 @@ -34,7 +34,9 @@ import org.apache.poi.ss.usermodel.Cell; 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.ss.util.CellRangeAddress; import org.apache.poi.xssf.usermodel.XSSFWorkbook; +import org.jboss.util.Strings; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Controller; @@ -82,7 +84,6 @@ import com.rjconsultores.ventaboletos.web.utilerias.render.RenderClaseServicio; import com.rjconsultores.ventaboletos.web.utilerias.render.RenderEmpresaModificacionMassivaTarifa; import com.rjconsultores.ventaboletos.web.utilerias.render.RenderMarca; import com.rjconsultores.ventaboletos.web.utilerias.render.RenderMoneda; -import com.rjconsultores.ventaboletos.web.utilerias.render.RenderOrgaoConcedente; import com.rjconsultores.ventaboletos.web.utilerias.render.RenderOrgaoConcedenteModifMassPreco; import com.rjconsultores.ventaboletos.web.utilerias.render.RenderTipoPuntoVenta; import com.rjconsultores.ventaboletos.web.utilerias.render.RenderVigenciaTarifaModificacionMassivaTarifa; @@ -158,6 +159,7 @@ public class ModificacionMasivaTarifasController extends MyGenericForwardCompose private MyListbox vigenciaTarifaList; private Textbox txtPorcentagem; private Radio radIncremento; + private Radio radAgrupamentoLinhasSim; private Button btnGerarTarifas; private Tab tabTipoPuntoVenta; private Tab tabCategoria; @@ -307,7 +309,6 @@ public class ModificacionMasivaTarifasController extends MyGenericForwardCompose } public void onClick$btnGerarExcelLinear(Event ev) { - txtPorcentagem.getValue(); try { if (lsAddRmvVigenciaTarifa.isEmpty()) { @@ -341,6 +342,7 @@ public class ModificacionMasivaTarifasController extends MyGenericForwardCompose return; } + //Estilo padrão para os dois tipos de relatórios HSSFWorkbook wb = new HSSFWorkbook(); // fonte em negrito: @@ -349,175 +351,17 @@ public class ModificacionMasivaTarifasController extends MyGenericForwardCompose HSSFCellStyle estilo = wb.createCellStyle(); estilo.setFont(fonte); - // TESTE: List lsRutaCombinacion = rutaCombinacionService.pesquisaTarifaObj(lsAddRmvMonedas, lsAddRmvMarcas, lsAddRmvClaseServico, lsAddRmvCategoria, lsAddRmvEmpresas, lsAddRmvRutas, lsAddRmvTipoPuntoVenta, lsAddRmvVigenciaTarifa, lsAddRmvOrgaoConcedente); - HSSFSheet sheet1 = null; - String ruta = ""; - int contRow = 0; - if (!lsRutaCombinacion.isEmpty()) { - - for (int i = 0; i < lsRutaCombinacion.size(); i++) { - Object[] obj = (Object[]) lsRutaCombinacion.get(i); - - if (!ruta.equals(obj[4].toString().concat(obj[12].toString()))) { - - ruta = obj[4].toString().concat(obj[12].toString()); - String sheetName = ""; - if (obj[4].toString().length() > 26) { - sheetName = (obj[12].toString().concat("-").concat(obj[4].toString().substring(0, 26))); - } else { - sheetName = (obj[12].toString().concat("-").concat(obj[4].toString())); - } - sheetName = sheetName.replaceAll("/", "-"); - log.debug("Aba: " + sheetName); - - sheet1 = wb.createSheet(sheetName); - contRow = 1; - - HSSFRow rowCabecalho = sheet1.createRow(0); - - HSSFCell cell = rowCabecalho.createCell(0); - cell.setCellValue( - Labels.getLabel("busquedaTarifaController.lhId.label")); - cell.setCellStyle(estilo); - - HSSFCell cell0 = rowCabecalho.createCell(1); - cell0.setCellValue( - Labels.getLabel("busquedaTarifaController.lhTramo.label")); - cell0.setCellStyle(estilo); - - HSSFCell cell1 = rowCabecalho.createCell(2); - cell1.setCellValue( - Labels.getLabel("busquedaTarifaController.lhOrigen.label")); - cell1.setCellStyle(estilo); - - HSSFCell cell2 = rowCabecalho.createCell(3); - cell2.setCellValue( - Labels.getLabel("busquedaTarifaController.lhDestino.label")); - cell2.setCellStyle(estilo); - - HSSFCell cell3 = rowCabecalho.createCell(4); - cell3.setCellValue( - Labels.getLabel("busquedaTarifaController.lhRuta.label")); - cell3.setCellStyle(estilo); - - HSSFCell cell4 = rowCabecalho.createCell(5); - cell4.setCellValue( - Labels.getLabel("busquedaTarifaController.lhMarca.label")); - cell4.setCellStyle(estilo); - - // Preco original I - 6 - HSSFCell cell5 = rowCabecalho.createCell(6); - cell5.setCellValue( - Labels.getLabel("busquedaTarifaController.lhClaseServicio.label")); - cell5.setCellStyle(estilo); - - // H - 6 - HSSFCell cell6 = rowCabecalho.createCell(7); - cell6.setCellValue( - Labels.getLabel("busquedaTarifaController.lhFeciniciovigencia.label")); - cell6.setCellStyle(estilo); - - // I - 8 - HSSFCell cell7 = rowCabecalho.createCell(8); - cell7.setCellValue( - Labels.getLabel("busquedaTarifaController.lhMoneda.label")); - cell7.setCellStyle(estilo); - - // J - 9 - HSSFCell cell8 = rowCabecalho.createCell(9); - cell8.setCellValue( - Labels.getLabel("busquedaTarifaController.lhPrecioOriginal.label")); - cell8.setCellStyle(estilo); - - // J - 9 - HSSFCell cell9 = rowCabecalho.createCell(10); - cell9.setCellValue( - Labels.getLabel("busquedaTarifaController.lhPrecioExcel.label")); - cell9.setCellStyle(estilo); - - // h - 10 - HSSFCell cell10 = rowCabecalho.createCell(11); - cell10.setCellValue( - Labels.getLabel("busquedaTarifaController.lhPrecioNuevo.label")); - cell10.setCellStyle(estilo); - - HSSFCell cell12 = rowCabecalho.createCell(12); - cell12.setCellValue( - Labels.getLabel("busquedaTarifaController.lhPrecioPedagio.label")); - cell12.setCellStyle(estilo); - - HSSFCell cell13 = rowCabecalho.createCell(13); - cell13.setCellValue( - Labels.getLabel("busquedaTarifaController.lhPrecioPedagioNuevo.label")); - cell13.setCellStyle(estilo); - - HSSFCell cell14 = rowCabecalho.createCell(14); - cell14.setCellValue( - Labels.getLabel("busquedaTarifaController.lhOrgaoLabel.label")); - cell14.setCellStyle(estilo); - } - - HSSFRow row = sheet1.createRow(contRow++); - - row.createCell(0).setCellValue(Integer.parseInt(obj[0].toString())); - row.createCell(1).setCellValue(obj[1].toString()); - row.createCell(2).setCellValue(obj[2].toString()); - row.createCell(3).setCellValue(obj[3].toString()); - row.createCell(4).setCellValue(obj[4].toString().concat(" (").concat(obj[12].toString()).concat(")")); - row.createCell(5).setCellValue(obj[5].toString()); - row.createCell(6).setCellValue(obj[6].toString()); - - DateFormat sfFormatada = new SimpleDateFormat("dd/MM/yyyy"); - - Date dataIni = (Date) obj[7]; - Date dataFim = (Date) obj[8]; - - row.createCell(7).setCellValue(sfFormatada.format(dataIni) + " - " + sfFormatada.format(dataFim)); - row.createCell(8).setCellValue(obj[9].toString()); - - String ori = getStringImporteSafe(obj[10]); - BigDecimal original = BigDecimal.valueOf(Double.valueOf(ori)); - - String atu = getStringImporteSafe(obj[11]); - BigDecimal atual = BigDecimal.valueOf(Double.valueOf(atu)); - - row.createCell(9).setCellValue(original.setScale(2).doubleValue()); - row.createCell(10).setCellValue(atual.setScale(2).doubleValue()); - - String ped = getStringImporteSafe(obj[16]); - BigDecimal pedVal = BigDecimal.valueOf(Double.valueOf(ped)); - row.createCell(12).setCellValue(pedVal.setScale(2).doubleValue()); - - row.createCell(14).setCellValue(obj[17].toString()); - - // novo preco: - BigDecimal novoPrecio = null; - int celulaAlterada = 0; - - if (cmbComponentePreco.getSelectedItem().getValue().equals(EnumTarifaPedagio.TARIFA.getDescricao())){ - novoPrecio = atual; - celulaAlterada = 11; - } else{ - if (obj[16]==null){ - continue; - } - - novoPrecio = BigDecimal.valueOf(Double.valueOf(getStringImporteSafe(obj[16]))); - celulaAlterada = 13; - } - - novoPrecio = novoPrecio.multiply(coeficiente).setScale(2, RoundingMode.HALF_UP); - - HSSFCell cellNovoPrecio = row.createCell(celulaAlterada); - cellNovoPrecio.setCellValue(novoPrecio.setScale(2).doubleValue()); - cellNovoPrecio.setCellStyle(estilo); + if (radAgrupamentoLinhasSim.isChecked()){ + gerarExcelComAgrupamento(lsRutaCombinacion,wb,estilo,coeficiente); + } else { + gerarExcelSemAgrupamento(lsRutaCombinacion,wb,estilo,coeficiente); } - + String nomeArquivo = UsuarioLogado.getUsuarioLogado().getNombusuario() + "_" + Calendar.getInstance().getTime().getTime() @@ -785,5 +629,349 @@ public class ModificacionMasivaTarifasController extends MyGenericForwardCompose this.lsOrgaoConcedente = lsOrgaoConcedente; } + private void gerarExcelSemAgrupamento(List lsRutaCombinacion, HSSFWorkbook wb, HSSFCellStyle estilo, BigDecimal coeficiente){ + HSSFSheet sheet1 = null; + String ruta = ""; + int contRow = 0; + + for (int i = 0; i < lsRutaCombinacion.size(); i++) { + Object[] obj = (Object[]) lsRutaCombinacion.get(i); + + if (!ruta.equals(obj[4].toString().concat(obj[12].toString()))) { + + ruta = obj[4].toString().concat(obj[12].toString()); + String sheetName = ""; + if (obj[4].toString().length() > 26) { + sheetName = (obj[12].toString().concat("-").concat(obj[4].toString().substring(0, 26))); + } else { + sheetName = (obj[12].toString().concat("-").concat(obj[4].toString())); + } + sheetName = sheetName.replaceAll("/", "-"); + log.debug("Aba: " + sheetName); + + sheet1 = wb.createSheet(sheetName); + contRow = 1; + + HSSFRow rowCabecalho = sheet1.createRow(0); + + HSSFCell cell = rowCabecalho.createCell(0); + cell.setCellValue( + Labels.getLabel("busquedaTarifaController.lhId.label")); + cell.setCellStyle(estilo); + + HSSFCell cell0 = rowCabecalho.createCell(1); + cell0.setCellValue( + Labels.getLabel("busquedaTarifaController.lhTramo.label")); + cell0.setCellStyle(estilo); + + HSSFCell cell1 = rowCabecalho.createCell(2); + cell1.setCellValue( + Labels.getLabel("busquedaTarifaController.lhOrigen.label")); + cell1.setCellStyle(estilo); + + HSSFCell cell2 = rowCabecalho.createCell(3); + cell2.setCellValue( + Labels.getLabel("busquedaTarifaController.lhDestino.label")); + cell2.setCellStyle(estilo); + + HSSFCell cell3 = rowCabecalho.createCell(4); + cell3.setCellValue( + Labels.getLabel("busquedaTarifaController.lhRuta.label")); + cell3.setCellStyle(estilo); + + HSSFCell cell4 = rowCabecalho.createCell(5); + cell4.setCellValue( + Labels.getLabel("busquedaTarifaController.lhMarca.label")); + cell4.setCellStyle(estilo); + + // Preco original I - 6 + HSSFCell cell5 = rowCabecalho.createCell(6); + cell5.setCellValue( + Labels.getLabel("busquedaTarifaController.lhClaseServicio.label")); + cell5.setCellStyle(estilo); + + // H - 6 + HSSFCell cell6 = rowCabecalho.createCell(7); + cell6.setCellValue( + Labels.getLabel("busquedaTarifaController.lhFeciniciovigencia.label")); + cell6.setCellStyle(estilo); + + // I - 8 + HSSFCell cell7 = rowCabecalho.createCell(8); + cell7.setCellValue( + Labels.getLabel("busquedaTarifaController.lhMoneda.label")); + cell7.setCellStyle(estilo); + + // J - 9 + HSSFCell cell8 = rowCabecalho.createCell(9); + cell8.setCellValue( + Labels.getLabel("busquedaTarifaController.lhPrecioOriginal.label")); + cell8.setCellStyle(estilo); + + // J - 9 + HSSFCell cell9 = rowCabecalho.createCell(10); + cell9.setCellValue( + Labels.getLabel("busquedaTarifaController.lhPrecioExcel.label")); + cell9.setCellStyle(estilo); + + // h - 10 + HSSFCell cell10 = rowCabecalho.createCell(11); + cell10.setCellValue( + Labels.getLabel("busquedaTarifaController.lhPrecioNuevo.label")); + cell10.setCellStyle(estilo); + + HSSFCell cell12 = rowCabecalho.createCell(12); + cell12.setCellValue( + Labels.getLabel("busquedaTarifaController.lhPrecioPedagio.label")); + cell12.setCellStyle(estilo); + + HSSFCell cell13 = rowCabecalho.createCell(13); + cell13.setCellValue( + Labels.getLabel("busquedaTarifaController.lhPrecioPedagioNuevo.label")); + cell13.setCellStyle(estilo); + + HSSFCell cell14 = rowCabecalho.createCell(14); + cell14.setCellValue( + Labels.getLabel("busquedaTarifaController.lhOrgaoLabel.label")); + cell14.setCellStyle(estilo); + } + + HSSFRow row = sheet1.createRow(contRow++); + + row.createCell(0).setCellValue(Integer.parseInt(obj[0].toString())); + row.createCell(1).setCellValue(obj[1].toString()); + row.createCell(2).setCellValue(obj[2].toString()); + row.createCell(3).setCellValue(obj[3].toString()); + row.createCell(4).setCellValue(obj[4].toString().concat(" (").concat(obj[12].toString()).concat(")")); + row.createCell(5).setCellValue(obj[5].toString()); + row.createCell(6).setCellValue(obj[6].toString()); + + DateFormat sfFormatada = new SimpleDateFormat("dd/MM/yyyy"); + + Date dataIni = (Date) obj[7]; + Date dataFim = (Date) obj[8]; + + row.createCell(7).setCellValue(sfFormatada.format(dataIni) + " - " + sfFormatada.format(dataFim)); + row.createCell(8).setCellValue(obj[9].toString()); + + String ori = getStringImporteSafe(obj[10]); + BigDecimal original = BigDecimal.valueOf(Double.valueOf(ori)); + + String atu = getStringImporteSafe(obj[11]); + BigDecimal atual = BigDecimal.valueOf(Double.valueOf(atu)); + + row.createCell(9).setCellValue(original.setScale(2).doubleValue()); + row.createCell(10).setCellValue(atual.setScale(2).doubleValue()); + + String ped = getStringImporteSafe(obj[16]); + BigDecimal pedVal = BigDecimal.valueOf(Double.valueOf(ped)); + row.createCell(12).setCellValue(pedVal.setScale(2).doubleValue()); + + row.createCell(14).setCellValue(obj[17].toString()); + + // novo preco: + BigDecimal novoPrecio = null; + int celulaAlterada = 0; + + if (cmbComponentePreco.getSelectedItem().getValue().equals(EnumTarifaPedagio.TARIFA.getDescricao())){ + novoPrecio = atual; + celulaAlterada = 11; + } else{ + if (obj[16]==null){ + continue; + } + + novoPrecio = BigDecimal.valueOf(Double.valueOf(getStringImporteSafe(obj[16]))); + celulaAlterada = 13; + } + + novoPrecio = novoPrecio.multiply(coeficiente).setScale(2, RoundingMode.HALF_UP); + + HSSFCell cellNovoPrecio = row.createCell(celulaAlterada); + cellNovoPrecio.setCellValue(novoPrecio.setScale(2).doubleValue()); + cellNovoPrecio.setCellStyle(estilo); + } + } + private void gerarExcelComAgrupamento(List lsRutaCombinacion, HSSFWorkbook wb, HSSFCellStyle estilo, BigDecimal coeficiente){ + HSSFSheet sheet1 = null; + String ruta = ""; + int contRow = 0; + + for (int i = 0; i < lsRutaCombinacion.size(); i++) { + Object[] obj = (Object[]) lsRutaCombinacion.get(i); + + if (!ruta.equals(obj[4].toString().concat(obj[12].toString()))) { + int contCell = 0; + + ruta = obj[4].toString().concat(obj[12].toString()); + String linha = ""; + if (obj[4].toString().length() > 26) { + linha = (obj[12].toString().concat("-").concat(obj[4].toString().substring(0, 26))); + } else { + linha = (obj[12].toString().concat("-").concat(obj[4].toString())); + } + linha = "Linha: ".concat(linha.replaceAll("/", "-")); + log.debug("Linha: " + linha); + + if (sheet1 == null){ + sheet1 = wb.createSheet("Agrupado por Linha"); + contRow = 0; + } + + if (contRow > 0){ + HSSFRow rowLinhaBranco = sheet1.createRow(contRow++); + HSSFCell cellLinhaBranco = rowLinhaBranco.createCell(0); + sheet1.addMergedRegion(new CellRangeAddress(rowLinhaBranco.getRowNum(), rowLinhaBranco.getRowNum(), 0, 16)); + cellLinhaBranco.setCellValue(Strings.EMPTY); + cellLinhaBranco.setCellStyle(estilo); + } + + HSSFRow rowTituloLinha = sheet1.createRow(contRow++); + HSSFCell cellTituloLinha = rowTituloLinha.createCell(0); + sheet1.addMergedRegion(new CellRangeAddress(rowTituloLinha.getRowNum(), rowTituloLinha.getRowNum(), 0, 16)); + cellTituloLinha.setCellValue(linha); + //estilo.setAlignment(org.apache.poi.ss.usermodel.CellStyle.ALIGN_CENTER); + cellTituloLinha.setCellStyle(estilo); + + HSSFRow rowCabecalho = sheet1.createRow(contRow++); + + HSSFCell cell = rowCabecalho.createCell(contCell++); + cell.setCellValue( + Labels.getLabel("busquedaTarifaController.lhId.label")); + cell.setCellStyle(estilo); + + HSSFCell cell0 = rowCabecalho.createCell(contCell++); + cell0.setCellValue( + Labels.getLabel("busquedaTarifaController.lhTramo.label")); + cell0.setCellStyle(estilo); + + HSSFCell cell1 = rowCabecalho.createCell(contCell++); + cell1.setCellValue( + Labels.getLabel("busquedaTarifaController.lhOrigen.label")); + cell1.setCellStyle(estilo); + + HSSFCell cell2 = rowCabecalho.createCell(contCell++); + cell2.setCellValue( + Labels.getLabel("busquedaTarifaController.lhDestino.label")); + cell2.setCellStyle(estilo); + + HSSFCell cell3 = rowCabecalho.createCell(contCell++); + cell3.setCellValue( + Labels.getLabel("busquedaTarifaController.lhRuta.label")); + cell3.setCellStyle(estilo); + + HSSFCell cell4 = rowCabecalho.createCell(contCell++); + cell4.setCellValue( + Labels.getLabel("busquedaTarifaController.lhMarca.label")); + cell4.setCellStyle(estilo); + + // Preco original I - 6 + HSSFCell cell5 = rowCabecalho.createCell(contCell++); + cell5.setCellValue( + Labels.getLabel("busquedaTarifaController.lhClaseServicio.label")); + cell5.setCellStyle(estilo); + + // H - 6 + HSSFCell cell6 = rowCabecalho.createCell(contCell++); + cell6.setCellValue( + Labels.getLabel("busquedaTarifaController.lhFeciniciovigencia.label")); + cell6.setCellStyle(estilo); + + // I - 8 + HSSFCell cell7 = rowCabecalho.createCell(contCell++); + cell7.setCellValue( + Labels.getLabel("busquedaTarifaController.lhMoneda.label")); + cell7.setCellStyle(estilo); + + // J - 9 + HSSFCell cell8 = rowCabecalho.createCell(contCell++); + cell8.setCellValue( + Labels.getLabel("busquedaTarifaController.lhPrecioOriginal.label")); + cell8.setCellStyle(estilo); + + // J - 9 + HSSFCell cell9 = rowCabecalho.createCell(contCell++); + cell9.setCellValue( + Labels.getLabel("busquedaTarifaController.lhPrecioExcel.label")); + cell9.setCellStyle(estilo); + + // h - 10 + HSSFCell cell10 = rowCabecalho.createCell(contCell++); + cell10.setCellValue( + Labels.getLabel("busquedaTarifaController.lhPrecioNuevo.label")); + cell10.setCellStyle(estilo); + + HSSFCell cell12 = rowCabecalho.createCell(contCell++); + cell12.setCellValue( + Labels.getLabel("busquedaTarifaController.lhPrecioPedagio.label")); + cell12.setCellStyle(estilo); + + HSSFCell cell13 = rowCabecalho.createCell(contCell++); + cell13.setCellValue( + Labels.getLabel("busquedaTarifaController.lhPrecioPedagioNuevo.label")); + cell13.setCellStyle(estilo); + + HSSFCell cell14 = rowCabecalho.createCell(contCell++); + cell14.setCellValue( + Labels.getLabel("busquedaTarifaController.lhOrgaoLabel.label")); + cell14.setCellStyle(estilo); + } + + HSSFRow row = sheet1.createRow(contRow++); + + row.createCell(0).setCellValue(Integer.parseInt(obj[0].toString())); + row.createCell(1).setCellValue(obj[1].toString()); + row.createCell(2).setCellValue(obj[2].toString()); + row.createCell(3).setCellValue(obj[3].toString()); + row.createCell(4).setCellValue(obj[4].toString().concat(" (").concat(obj[12].toString()).concat(")")); + row.createCell(5).setCellValue(obj[5].toString()); + row.createCell(6).setCellValue(obj[6].toString()); + + DateFormat sfFormatada = new SimpleDateFormat("dd/MM/yyyy"); + + Date dataIni = (Date) obj[7]; + Date dataFim = (Date) obj[8]; + + row.createCell(7).setCellValue(sfFormatada.format(dataIni) + " - " + sfFormatada.format(dataFim)); + row.createCell(8).setCellValue(obj[9].toString()); + + String ori = getStringImporteSafe(obj[10]); + BigDecimal original = BigDecimal.valueOf(Double.valueOf(ori)); + + String atu = getStringImporteSafe(obj[11]); + BigDecimal atual = BigDecimal.valueOf(Double.valueOf(atu)); + + row.createCell(9).setCellValue(original.setScale(2).doubleValue()); + row.createCell(10).setCellValue(atual.setScale(2).doubleValue()); + + String ped = getStringImporteSafe(obj[16]); + BigDecimal pedVal = BigDecimal.valueOf(Double.valueOf(ped)); + row.createCell(12).setCellValue(pedVal.setScale(2).doubleValue()); + + row.createCell(14).setCellValue(obj[17].toString()); + + // novo preco: + BigDecimal novoPrecio = null; + int celulaAlterada = 0; + + if (cmbComponentePreco.getSelectedItem().getValue().equals(EnumTarifaPedagio.TARIFA.getDescricao())){ + novoPrecio = atual; + celulaAlterada = 11; + } else{ + if (obj[16]==null){ + continue; + } + + novoPrecio = BigDecimal.valueOf(Double.valueOf(getStringImporteSafe(obj[16]))); + celulaAlterada = 13; + } + + novoPrecio = novoPrecio.multiply(coeficiente).setScale(2, RoundingMode.HALF_UP); + + HSSFCell cellNovoPrecio = row.createCell(celulaAlterada); + cellNovoPrecio.setCellValue(novoPrecio.setScale(2).doubleValue()); + cellNovoPrecio.setCellStyle(estilo); + } + } } diff --git a/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/tarifas/ModificacionMasivaTarifasUploadController.java b/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/tarifas/ModificacionMasivaTarifasUploadController.java index 619edbf76..cb38a7e28 100644 --- a/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/tarifas/ModificacionMasivaTarifasUploadController.java +++ b/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/tarifas/ModificacionMasivaTarifasUploadController.java @@ -150,12 +150,21 @@ public class ModificacionMasivaTarifasUploadController extends MyGenericForwardC Sheet sheet = wb.getSheetAt(k); int rows = sheet.getPhysicalNumberOfRows(); - // pula o row 0 pq eh o cabecalho: - for (int r = 1; r < rows; r++) { + for (int r = 0; r < rows; r++) { Row row = sheet.getRow(r); - if (row == null) { + + if (row == null || (row.getCell(0).getCellType() == Cell.CELL_TYPE_STRING && (row.getCell(0).getStringCellValue().startsWith("Linha") || row.getCell(0).getStringCellValue().isEmpty()))) { continue; } + + if (row.getCell(0).getCellType() == Cell.CELL_TYPE_STRING && row.getCell(0).getStringCellValue().equalsIgnoreCase("id")){ + continue; + } + + if (row.getCell(0).getCellType() == Cell.CELL_TYPE_BLANK){ + continue; + } + if (componentePreco.equals(EnumTarifaPedagio.TARIFA.getDescricao())) { if (null == row.getCell(CELL_NOVO_PRECIO)) { continue; @@ -366,14 +375,23 @@ public class ModificacionMasivaTarifasUploadController extends MyGenericForwardC Sheet sheet = wb.getSheetAt(k); int rows = sheet.getPhysicalNumberOfRows(); - // pula o row 0 pq eh o cabecalho: - for (int r = 1; r < rows; r++) { + for (int r = 0; r < rows; r++) { Row row = sheet.getRow(r); - if (row == null) { + + if (row == null || (row.getCell(0).getCellType() == Cell.CELL_TYPE_STRING && (row.getCell(0).getStringCellValue().startsWith("Linha") || row.getCell(0).getStringCellValue().isEmpty()))) { continue; } - + + if (row.getCell(0).getCellType() == Cell.CELL_TYPE_STRING && row.getCell(0).getStringCellValue().equalsIgnoreCase("id")){ + continue; + } + + if (row.getCell(0).getCellType() == Cell.CELL_TYPE_BLANK){ + continue; + } + Cell cellIdTarifa = row.getCell(CELL_ID_TARIFA); + BigDecimal bdId = new BigDecimal(cellIdTarifa.getNumericCellValue()); Integer idTarifa = bdId.intValue(); diff --git a/web/WEB-INF/i3-label_es_MX.label b/web/WEB-INF/i3-label_es_MX.label index 8f1712d52..81ac068f6 100644 --- a/web/WEB-INF/i3-label_es_MX.label +++ b/web/WEB-INF/i3-label_es_MX.label @@ -2362,6 +2362,9 @@ modificacionMasivaTarifasController.componentePreco.label = Componente Precio modificacionMasivaTarifasController.orgaoConcedente.label = Instituición Concedente modificacionMasivaTarifasController.lhNombOrgao.label = Nome Instituición Concedente modificacionMasivaTarifasController.lhId.label = ID +modificacionMasivaTarifasController.agrupamentoLinha.label = Línea de Agrupación +modificacionMasivaTarifasController.agrupamentoLinha.radioSim = Sí +modificacionMasivaTarifasController.agrupamentoLinha.radioNao = No #Geracion de Servicio geracionCorridaController.window.title = Generación de corridas diff --git a/web/WEB-INF/i3-label_pt_BR.label b/web/WEB-INF/i3-label_pt_BR.label index adf5f971b..350829350 100644 --- a/web/WEB-INF/i3-label_pt_BR.label +++ b/web/WEB-INF/i3-label_pt_BR.label @@ -2406,6 +2406,9 @@ modificacionMasivaTarifasController.componentePreco.label = Componente do Preço modificacionMasivaTarifasController.orgaoConcedente.label = Órgão Concedente modificacionMasivaTarifasController.lhNombOrgao.label = Nome Órgão Concedente modificacionMasivaTarifasController.lhId.label = ID +modificacionMasivaTarifasController.agrupamentoLinha.label = Agrupamento por Linha +modificacionMasivaTarifasController.agrupamentoLinha.radioSim = Sim +modificacionMasivaTarifasController.agrupamentoLinha.radioNao = Não #Geracion de Serviço diff --git a/web/gui/tarifas/modificacionMasivaTarifas.zul b/web/gui/tarifas/modificacionMasivaTarifas.zul index b90c7ae6b..c90338487 100644 --- a/web/gui/tarifas/modificacionMasivaTarifas.zul +++ b/web/gui/tarifas/modificacionMasivaTarifas.zul @@ -51,6 +51,14 @@ mold="rounded" buttonVisible="true" width="28%" value="${c:l('busquedaTarifaController.lhPrecio.label')}" model="@{winModificacionMasivaTarifa$composer.lsComponentePreco}"/> + +