Erro - Modificação Massiva de Preços (fixes bug #6227)
Tempo: 02 horas git-svn-id: http://desenvolvimento.rjconsultores.com.br/repositorio/sco/AdmVenta/Web/trunk/ventaboletos@43435 d1611594-4594-4d17-8e1d-87c2c4800839master
parent
25b6eb51da
commit
6acaf374b2
|
@ -304,7 +304,7 @@ public class ModificacionMasivaTarifasController extends MyGenericForwardCompose
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("",e);
|
log.error("", e);
|
||||||
log.debug("Porcentagem Zero");
|
log.debug("Porcentagem Zero");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -329,167 +329,166 @@ public class ModificacionMasivaTarifasController extends MyGenericForwardCompose
|
||||||
String ruta = "";
|
String ruta = "";
|
||||||
int contRow = 0;
|
int contRow = 0;
|
||||||
|
|
||||||
if(!lsRutaCombinacion.isEmpty()){
|
if (!lsRutaCombinacion.isEmpty()) {
|
||||||
|
|
||||||
for (int i = 0; i < lsRutaCombinacion.size(); i++) {
|
for (int i = 0; i < lsRutaCombinacion.size(); i++) {
|
||||||
Object[] obj = (Object[]) lsRutaCombinacion.get(i);
|
Object[] obj = (Object[]) lsRutaCombinacion.get(i);
|
||||||
|
|
||||||
if (!ruta.equals(obj[4].toString().concat(obj[12].toString()))) {
|
if (!ruta.equals(obj[4].toString().concat(obj[12].toString()))) {
|
||||||
|
|
||||||
ruta = obj[4].toString().concat(obj[12].toString());
|
ruta = obj[4].toString().concat(obj[12].toString());
|
||||||
String sheetName = "";
|
String sheetName = "";
|
||||||
if (obj[4].toString().length() > 26) {
|
if (obj[4].toString().length() > 26) {
|
||||||
sheetName = (obj[4].toString().substring(0, 26).concat(" (").concat(obj[12].toString()).concat(")"));
|
sheetName = (obj[12].toString().concat("-").concat(obj[4].toString().substring(0, 26)));
|
||||||
} else {
|
} else {
|
||||||
sheetName = (obj[4].toString().concat(" (").concat(obj[12].toString()).concat(")"));
|
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);
|
||||||
}
|
}
|
||||||
sheetName = sheetName.replaceAll("/", "-");
|
|
||||||
log.debug("Aba: " + sheetName);
|
|
||||||
sheet1 = wb.createSheet(sheetName);
|
|
||||||
contRow = 1;
|
|
||||||
|
|
||||||
HSSFRow rowCabecalho = sheet1.createRow(0);
|
HSSFRow row = sheet1.createRow(contRow++);
|
||||||
|
|
||||||
HSSFCell cell = rowCabecalho.createCell(0);
|
row.createCell(0).setCellValue(Integer.parseInt(obj[0].toString()));
|
||||||
cell.setCellValue(
|
row.createCell(1).setCellValue(obj[1].toString());
|
||||||
Labels.getLabel("busquedaTarifaController.lhId.label"));
|
row.createCell(2).setCellValue(obj[2].toString());
|
||||||
cell.setCellStyle(estilo);
|
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());
|
||||||
|
|
||||||
HSSFCell cell0 = rowCabecalho.createCell(1);
|
DateFormat sfFormatada = new SimpleDateFormat("dd/MM/yyyy");
|
||||||
cell0.setCellValue(
|
|
||||||
Labels.getLabel("busquedaTarifaController.lhTramo.label"));
|
|
||||||
cell0.setCellStyle(estilo);
|
|
||||||
|
|
||||||
HSSFCell cell1 = rowCabecalho.createCell(2);
|
Date dataIni = (Date) obj[7];
|
||||||
cell1.setCellValue(
|
Date dataFim = (Date) obj[8];
|
||||||
Labels.getLabel("busquedaTarifaController.lhOrigen.label"));
|
|
||||||
cell1.setCellStyle(estilo);
|
|
||||||
|
|
||||||
HSSFCell cell2 = rowCabecalho.createCell(3);
|
row.createCell(7).setCellValue(sfFormatada.format(dataIni) + " - " + sfFormatada.format(dataFim));
|
||||||
cell2.setCellValue(
|
row.createCell(8).setCellValue(obj[9].toString());
|
||||||
Labels.getLabel("busquedaTarifaController.lhDestino.label"));
|
|
||||||
cell2.setCellStyle(estilo);
|
|
||||||
|
|
||||||
HSSFCell cell3 = rowCabecalho.createCell(4);
|
String ori = obj[10].toString();
|
||||||
cell3.setCellValue(
|
BigDecimal original = BigDecimal.valueOf(Double.valueOf(ori));
|
||||||
Labels.getLabel("busquedaTarifaController.lhRuta.label"));
|
|
||||||
cell3.setCellStyle(estilo);
|
|
||||||
|
|
||||||
HSSFCell cell4 = rowCabecalho.createCell(5);
|
String atu = obj[11].toString();
|
||||||
cell4.setCellValue(
|
BigDecimal atual = BigDecimal.valueOf(Double.valueOf(atu));
|
||||||
Labels.getLabel("busquedaTarifaController.lhMarca.label"));
|
|
||||||
cell4.setCellStyle(estilo);
|
|
||||||
|
|
||||||
// Preco original I - 6
|
row.createCell(9).setCellValue(original.setScale(2).doubleValue());
|
||||||
HSSFCell cell5 = rowCabecalho.createCell(6);
|
row.createCell(10).setCellValue(atual.setScale(2).doubleValue());
|
||||||
cell5.setCellValue(
|
|
||||||
Labels.getLabel("busquedaTarifaController.lhClaseServicio.label"));
|
|
||||||
cell5.setCellStyle(estilo);
|
|
||||||
|
|
||||||
// H - 6
|
String ped = obj[16] != null ? obj[16].toString() : "0.0";
|
||||||
HSSFCell cell6 = rowCabecalho.createCell(7);
|
BigDecimal pedVal = BigDecimal.valueOf(Double.valueOf(ped));
|
||||||
cell6.setCellValue(
|
row.createCell(12).setCellValue(pedVal.setScale(2).doubleValue());
|
||||||
Labels.getLabel("busquedaTarifaController.lhFeciniciovigencia.label"));
|
|
||||||
cell6.setCellStyle(estilo);
|
|
||||||
|
|
||||||
// I - 8
|
// novo preco:
|
||||||
HSSFCell cell7 = rowCabecalho.createCell(8);
|
BigDecimal novoPrecio = atual;
|
||||||
cell7.setCellValue(
|
|
||||||
Labels.getLabel("busquedaTarifaController.lhMoneda.label"));
|
|
||||||
cell7.setCellStyle(estilo);
|
|
||||||
|
|
||||||
// J - 9
|
novoPrecio = novoPrecio.multiply(coeficiente).setScale(2, RoundingMode.HALF_UP);
|
||||||
HSSFCell cell8 = rowCabecalho.createCell(9);
|
|
||||||
cell8.setCellValue(
|
|
||||||
Labels.getLabel("busquedaTarifaController.lhPrecioOriginal.label"));
|
|
||||||
cell8.setCellStyle(estilo);
|
|
||||||
|
|
||||||
// J - 9
|
HSSFCell cellNovoPrecio = row.createCell(11);
|
||||||
HSSFCell cell9 = rowCabecalho.createCell(10);
|
cellNovoPrecio.setCellValue(novoPrecio.setScale(2).doubleValue());
|
||||||
cell9.setCellValue(
|
cellNovoPrecio.setCellStyle(estilo);
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
HSSFRow row = sheet1.createRow(contRow++);
|
String nomeArquivo =
|
||||||
|
UsuarioLogado.getUsuarioLogado().getNombusuario()
|
||||||
|
+ "_" + Calendar.getInstance().getTime().getTime()
|
||||||
|
+ "_" + "modMassivaT";
|
||||||
|
|
||||||
row.createCell(0).setCellValue(Integer.parseInt(obj[0].toString()));
|
File fNomeArquivo = File.createTempFile(nomeArquivo, ".tmp");
|
||||||
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");
|
FileOutputStream stream = new FileOutputStream(fNomeArquivo);
|
||||||
|
stream.flush();
|
||||||
|
wb.write(stream);
|
||||||
|
stream.close();
|
||||||
|
|
||||||
Date dataIni = (Date) obj[7];
|
InputStream is = null;
|
||||||
Date dataFim = (Date) obj[8];
|
is = new FileInputStream(fNomeArquivo);
|
||||||
|
Filedownload.save(is, "application/xls", "modificacionMasivaTarifa.xls");
|
||||||
|
|
||||||
row.createCell(7).setCellValue(sfFormatada.format(dataIni) + " - " + sfFormatada.format(dataFim));
|
fNomeArquivo.delete();
|
||||||
row.createCell(8).setCellValue(obj[9].toString());
|
|
||||||
|
|
||||||
String ori = obj[10].toString();
|
} else {
|
||||||
BigDecimal original = BigDecimal.valueOf(Double.valueOf(ori));
|
|
||||||
|
|
||||||
String atu = obj[11].toString();
|
|
||||||
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 = obj[16] != null ? obj[16].toString() : "0.0";
|
|
||||||
BigDecimal pedVal = BigDecimal.valueOf(Double.valueOf(ped));
|
|
||||||
row.createCell(12).setCellValue(pedVal.setScale(2).doubleValue());
|
|
||||||
|
|
||||||
// novo preco:
|
|
||||||
BigDecimal novoPrecio = atual;
|
|
||||||
|
|
||||||
novoPrecio = novoPrecio.multiply(coeficiente).setScale(2, RoundingMode.HALF_UP);
|
|
||||||
|
|
||||||
HSSFCell cellNovoPrecio = row.createCell(11);
|
|
||||||
cellNovoPrecio.setCellValue(novoPrecio.setScale(2).doubleValue());
|
|
||||||
cellNovoPrecio.setCellStyle(estilo);
|
|
||||||
}
|
|
||||||
|
|
||||||
String nomeArquivo =
|
|
||||||
UsuarioLogado.getUsuarioLogado().getNombusuario()
|
|
||||||
+ "_" + Calendar.getInstance().getTime().getTime()
|
|
||||||
+ "_" + "modMassivaT";
|
|
||||||
|
|
||||||
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", "modificacionMasivaTarifa.xls");
|
|
||||||
|
|
||||||
fNomeArquivo.delete();
|
|
||||||
|
|
||||||
}else{
|
|
||||||
Messagebox.show(Labels.getLabel("modificacionMasivaTarifasUploadController.MSG.excelVazio"),
|
Messagebox.show(Labels.getLabel("modificacionMasivaTarifasUploadController.MSG.excelVazio"),
|
||||||
Labels.getLabel("modificacionMasivaTarifasController.window.title"), Messagebox.OK, Messagebox.INFORMATION);
|
Labels.getLabel("modificacionMasivaTarifasController.window.title"), Messagebox.OK, Messagebox.INFORMATION);
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
log.error("",ex);
|
log.error("", ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue