fixed bug #7601
git-svn-id: http://desenvolvimento.rjconsultores.com.br/repositorio/sco/AdmVenta/Web/trunk/ventaboletos@57292 d1611594-4594-4d17-8e1d-87c2c4800839master
parent
6998d41b85
commit
6c93746a06
|
@ -9,7 +9,8 @@ public enum EnumTarifaPedagio {
|
|||
TARIFA(Labels.getLabel("busquedaTarifaController.lhPrecio.label")),
|
||||
PEDAGIO(Labels.getLabel("busquedaTarifaController.lhPedagio.label")),
|
||||
TX_EMBARQUE(Labels.getLabel("busquedaTarifaController.lhTaxa.label")),
|
||||
SEGURO(Labels.getLabel("busquedaTarifaController.lhPrecioSeguro.label"));
|
||||
SEGURO(Labels.getLabel("busquedaTarifaController.lhPrecioSeguro.label")),
|
||||
TODOS(Labels.getLabel("busquedaTarifaController.lhTodos.label"));
|
||||
|
||||
private String descricao;
|
||||
|
||||
|
@ -27,10 +28,11 @@ public enum EnumTarifaPedagio {
|
|||
|
||||
public static List<String> obterBundleValues(){
|
||||
List<String> lst = new ArrayList<String>();
|
||||
lst.add(EnumTarifaPedagio.TODOS.getDescricao());
|
||||
lst.add(EnumTarifaPedagio.PEDAGIO.getDescricao());
|
||||
lst.add(EnumTarifaPedagio.TARIFA.getDescricao());
|
||||
lst.add(EnumTarifaPedagio.TX_EMBARQUE.getDescricao());
|
||||
lst.add(EnumTarifaPedagio.SEGURO.getDescricao());
|
||||
lst.add(EnumTarifaPedagio.SEGURO.getDescricao());
|
||||
return lst;
|
||||
}
|
||||
}
|
|
@ -65,7 +65,6 @@ import com.rjconsultores.ventaboletos.entidad.TipoPuntoVenta;
|
|||
import com.rjconsultores.ventaboletos.entidad.VigenciaTarifa;
|
||||
import com.rjconsultores.ventaboletos.service.CategoriaService;
|
||||
import com.rjconsultores.ventaboletos.service.ClaseServicioService;
|
||||
import com.rjconsultores.ventaboletos.service.EsquemaCorridaService;
|
||||
import com.rjconsultores.ventaboletos.service.MarcaService;
|
||||
import com.rjconsultores.ventaboletos.service.MonedaService;
|
||||
import com.rjconsultores.ventaboletos.service.OrgaoConcedenteService;
|
||||
|
@ -118,8 +117,6 @@ public class ModificacionMasivaTarifasController extends MyGenericForwardCompose
|
|||
private VigenciaTarifaService vigenciaTarifaService;
|
||||
@Autowired
|
||||
private OrgaoConcedenteService orgaoConcedenteService;
|
||||
@Autowired
|
||||
private EsquemaCorridaService esquemaCorridaService;
|
||||
private List<Marca> lsMarcas;
|
||||
private List<ClaseServicio> lsClaseServico;
|
||||
private List<Moneda> lsMonedas;
|
||||
|
@ -166,6 +163,9 @@ public class ModificacionMasivaTarifasController extends MyGenericForwardCompose
|
|||
private Tab tabTipoPuntoVenta;
|
||||
private Tab tabCategoria;
|
||||
|
||||
private final int ROW_PEDAGIO = 16;
|
||||
private final int ROW_TXEMBARQUE = 18;
|
||||
private final int ROW_SEGURO = 19;
|
||||
|
||||
private static Logger log = Logger.getLogger(ModificacionMasivaTarifasController.class);
|
||||
|
||||
|
@ -771,43 +771,66 @@ public class ModificacionMasivaTarifasController extends MyGenericForwardCompose
|
|||
BigDecimal seguroVal = BigDecimal.valueOf(Double.valueOf(seguro));
|
||||
row.createCell(16).setCellValue(seguroVal.setScale(2).doubleValue());
|
||||
|
||||
row.createCell(18).setCellValue(obj[17].toString());
|
||||
|
||||
row.createCell(18).setCellValue(obj[17].toString());
|
||||
|
||||
// novo preco:
|
||||
BigDecimal novoPrecio = null;
|
||||
int celulaAlterada = 0;
|
||||
|
||||
if (cmbComponentePreco.getSelectedItem().getValue().equals(EnumTarifaPedagio.TARIFA.getDescricao())){
|
||||
if (cmbComponentePreco.getSelectedItem().getValue().equals(EnumTarifaPedagio.TARIFA.getDescricao()) ||
|
||||
cmbComponentePreco.getSelectedItem().getValue().equals(EnumTarifaPedagio.TODOS.getDescricao())){
|
||||
|
||||
novoPrecio = atual;
|
||||
celulaAlterada = 11;
|
||||
} else if (cmbComponentePreco.getSelectedItem().getValue().equals(EnumTarifaPedagio.PEDAGIO.getDescricao())) {
|
||||
if (obj[16]==null){
|
||||
novoPrecio = novoPrecio.multiply(coeficiente).setScale(2, RoundingMode.HALF_UP);
|
||||
|
||||
HSSFCell cellNovoPrecio = row.createCell(11);//celula alterada
|
||||
cellNovoPrecio.setCellValue(novoPrecio.setScale(2).doubleValue());
|
||||
cellNovoPrecio.setCellStyle(estilo);
|
||||
}
|
||||
|
||||
if (cmbComponentePreco.getSelectedItem().getValue().equals(EnumTarifaPedagio.PEDAGIO.getDescricao())||
|
||||
cmbComponentePreco.getSelectedItem().getValue().equals(EnumTarifaPedagio.TODOS.getDescricao())){
|
||||
|
||||
if (!validarComponente(obj, ROW_PEDAGIO)){
|
||||
continue;
|
||||
}
|
||||
|
||||
novoPrecio = BigDecimal.valueOf(Double.valueOf(getStringImporteSafe(obj[16])));
|
||||
celulaAlterada = 13;
|
||||
} else if (cmbComponentePreco.getSelectedItem().getValue().equals(EnumTarifaPedagio.TX_EMBARQUE.getDescricao())) {
|
||||
if (obj[18]==null){
|
||||
novoPrecio = novoPrecio.multiply(coeficiente).setScale(2, RoundingMode.HALF_UP);
|
||||
|
||||
HSSFCell cellNovoPrecio = row.createCell(13); //celula alterada
|
||||
cellNovoPrecio.setCellValue(novoPrecio.setScale(2).doubleValue());
|
||||
cellNovoPrecio.setCellStyle(estilo);
|
||||
}
|
||||
|
||||
if (cmbComponentePreco.getSelectedItem().getValue().equals(EnumTarifaPedagio.TX_EMBARQUE.getDescricao())||
|
||||
cmbComponentePreco.getSelectedItem().getValue().equals(EnumTarifaPedagio.TODOS.getDescricao())){
|
||||
|
||||
if (!validarComponente(obj, ROW_TXEMBARQUE)){
|
||||
continue;
|
||||
}
|
||||
|
||||
novoPrecio = BigDecimal.valueOf(Double.valueOf(getStringImporteSafe(obj[18])));
|
||||
celulaAlterada = 15;
|
||||
} else if (cmbComponentePreco.getSelectedItem().getValue().equals(EnumTarifaPedagio.SEGURO.getDescricao())) {
|
||||
if (obj[19]==null){
|
||||
novoPrecio = novoPrecio.multiply(coeficiente).setScale(2, RoundingMode.HALF_UP);
|
||||
|
||||
HSSFCell cellNovoPrecio = row.createCell(15); //celula alterada
|
||||
cellNovoPrecio.setCellValue(novoPrecio.setScale(2).doubleValue());
|
||||
cellNovoPrecio.setCellStyle(estilo);
|
||||
}
|
||||
|
||||
if (cmbComponentePreco.getSelectedItem().getValue().equals(EnumTarifaPedagio.SEGURO.getDescricao())||
|
||||
cmbComponentePreco.getSelectedItem().getValue().equals(EnumTarifaPedagio.TODOS.getDescricao())){
|
||||
|
||||
if (!validarComponente(obj, ROW_SEGURO)){
|
||||
continue;
|
||||
}
|
||||
|
||||
novoPrecio = BigDecimal.valueOf(Double.valueOf(getStringImporteSafe(obj[19])));
|
||||
celulaAlterada = 17;
|
||||
novoPrecio = novoPrecio.multiply(coeficiente).setScale(2, RoundingMode.HALF_UP);
|
||||
|
||||
HSSFCell cellNovoPrecio = row.createCell(17); //celula alterada
|
||||
cellNovoPrecio.setCellValue(novoPrecio.setScale(2).doubleValue());
|
||||
cellNovoPrecio.setCellStyle(estilo);
|
||||
}
|
||||
|
||||
novoPrecio = novoPrecio.multiply(coeficiente).setScale(2, RoundingMode.HALF_UP);
|
||||
|
||||
HSSFCell cellNovoPrecio = row.createCell(celulaAlterada);
|
||||
cellNovoPrecio.setCellValue(novoPrecio.setScale(2).doubleValue());
|
||||
cellNovoPrecio.setCellStyle(estilo);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -975,39 +998,67 @@ public class ModificacionMasivaTarifasController extends MyGenericForwardCompose
|
|||
|
||||
// novo preco:
|
||||
BigDecimal novoPrecio = null;
|
||||
int celulaAlterada = 0;
|
||||
|
||||
if (cmbComponentePreco.getSelectedItem().getValue().equals(EnumTarifaPedagio.TARIFA.getDescricao())){
|
||||
if (cmbComponentePreco.getSelectedItem().getValue().equals(EnumTarifaPedagio.TARIFA.getDescricao()) ||
|
||||
cmbComponentePreco.getSelectedItem().getValue().equals(EnumTarifaPedagio.TODOS.getDescricao())){
|
||||
|
||||
novoPrecio = atual;
|
||||
celulaAlterada = 11;
|
||||
} else if (cmbComponentePreco.getSelectedItem().getValue().equals(EnumTarifaPedagio.PEDAGIO.getDescricao())) {
|
||||
if (obj[16]==null){
|
||||
continue;
|
||||
novoPrecio = novoPrecio.multiply(coeficiente).setScale(2, RoundingMode.HALF_UP);
|
||||
|
||||
HSSFCell cellNovoPrecio = row.createCell(11);//celula alterada
|
||||
cellNovoPrecio.setCellValue(novoPrecio.setScale(2).doubleValue());
|
||||
cellNovoPrecio.setCellStyle(estilo);
|
||||
}
|
||||
|
||||
if (cmbComponentePreco.getSelectedItem().getValue().equals(EnumTarifaPedagio.PEDAGIO.getDescricao()) ||
|
||||
cmbComponentePreco.getSelectedItem().getValue().equals(EnumTarifaPedagio.TODOS.getDescricao())) {
|
||||
|
||||
if (validarComponente(obj, ROW_PEDAGIO)){
|
||||
novoPrecio = BigDecimal.valueOf(Double.valueOf(getStringImporteSafe(obj[16])));
|
||||
novoPrecio = novoPrecio.multiply(coeficiente).setScale(2, RoundingMode.HALF_UP);
|
||||
|
||||
HSSFCell cellNovoPrecio = row.createCell(13);//celula alterada
|
||||
cellNovoPrecio.setCellValue(novoPrecio.setScale(2).doubleValue());
|
||||
cellNovoPrecio.setCellStyle(estilo);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (cmbComponentePreco.getSelectedItem().getValue().equals(EnumTarifaPedagio.TX_EMBARQUE.getDescricao()) ||
|
||||
cmbComponentePreco.getSelectedItem().getValue().equals(EnumTarifaPedagio.TODOS.getDescricao())) {
|
||||
|
||||
if (validarComponente(obj, ROW_TXEMBARQUE)){
|
||||
novoPrecio = BigDecimal.valueOf(Double.valueOf(getStringImporteSafe(obj[18])));
|
||||
novoPrecio = novoPrecio.multiply(coeficiente).setScale(2, RoundingMode.HALF_UP);
|
||||
|
||||
HSSFCell cellNovoPrecio = row.createCell(15);//celula alterada
|
||||
cellNovoPrecio.setCellValue(novoPrecio.setScale(2).doubleValue());
|
||||
cellNovoPrecio.setCellStyle(estilo);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (cmbComponentePreco.getSelectedItem().getValue().equals(EnumTarifaPedagio.SEGURO.getDescricao()) ||
|
||||
cmbComponentePreco.getSelectedItem().getValue().equals(EnumTarifaPedagio.TODOS.getDescricao())) {
|
||||
|
||||
if (validarComponente(obj, ROW_SEGURO)){
|
||||
novoPrecio = BigDecimal.valueOf(Double.valueOf(getStringImporteSafe(obj[19])));
|
||||
novoPrecio = novoPrecio.multiply(coeficiente).setScale(2, RoundingMode.HALF_UP);
|
||||
|
||||
HSSFCell cellNovoPrecio = row.createCell(17);//celula alterada
|
||||
cellNovoPrecio.setCellValue(novoPrecio.setScale(2).doubleValue());
|
||||
cellNovoPrecio.setCellStyle(estilo);
|
||||
}
|
||||
|
||||
novoPrecio = BigDecimal.valueOf(Double.valueOf(getStringImporteSafe(obj[16])));
|
||||
celulaAlterada = 13;
|
||||
} else if (cmbComponentePreco.getSelectedItem().getValue().equals(EnumTarifaPedagio.TX_EMBARQUE.getDescricao())) {
|
||||
if (obj[18]==null){
|
||||
continue;
|
||||
}
|
||||
|
||||
novoPrecio = BigDecimal.valueOf(Double.valueOf(getStringImporteSafe(obj[18])));
|
||||
celulaAlterada = 15;
|
||||
} else if (cmbComponentePreco.getSelectedItem().getValue().equals(EnumTarifaPedagio.SEGURO.getDescricao())) {
|
||||
if (obj[19]==null){
|
||||
continue;
|
||||
}
|
||||
|
||||
novoPrecio = BigDecimal.valueOf(Double.valueOf(getStringImporteSafe(obj[19])));
|
||||
celulaAlterada = 17;
|
||||
}
|
||||
|
||||
novoPrecio = novoPrecio.multiply(coeficiente).setScale(2, RoundingMode.HALF_UP);
|
||||
|
||||
HSSFCell cellNovoPrecio = row.createCell(celulaAlterada);
|
||||
cellNovoPrecio.setCellValue(novoPrecio.setScale(2).doubleValue());
|
||||
cellNovoPrecio.setCellStyle(estilo);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean validarComponente(Object[] obj, int rowNum) {
|
||||
if (obj[rowNum] == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -170,25 +170,19 @@ public class ModificacionMasivaTarifasUploadController extends MyGenericForwardC
|
|||
if (row.getCell(0).getCellType() == Cell.CELL_TYPE_BLANK) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (componentePreco.equals(EnumTarifaPedagio.TARIFA.getDescricao())) {
|
||||
if (null == row.getCell(CELL_NOVO_PRECIO)) {
|
||||
continue;
|
||||
}
|
||||
} else if (componentePreco.equals(EnumTarifaPedagio.PEDAGIO.getDescricao())) {
|
||||
if (null == row.getCell(CELL_NOVO_PEAJE)) {
|
||||
continue;
|
||||
}
|
||||
} else if (componentePreco.equals(EnumTarifaPedagio.TX_EMBARQUE.getDescricao())) {
|
||||
if (null == row.getCell(CELL_NOVO_TX_EMBARQUE)) {
|
||||
continue;
|
||||
}
|
||||
} else if (componentePreco.equals(EnumTarifaPedagio.SEGURO.getDescricao())) {
|
||||
if (null == row.getCell(CELL_NOVO_SEGURO)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
boolean retorno = false;
|
||||
|
||||
if (componentePreco.equals(EnumTarifaPedagio.TODOS.getDescricao())){
|
||||
retorno = validarTodosComponentes(row);
|
||||
} else{
|
||||
retorno = validarComponenteEspecifico(row);
|
||||
}
|
||||
|
||||
|
||||
if (!retorno){
|
||||
continue;
|
||||
}
|
||||
|
||||
Cell cellIdTarifa = row.getCell(CELL_ID_TARIFA);
|
||||
BigDecimal bdId = new BigDecimal(cellIdTarifa.getNumericCellValue());
|
||||
Integer idTarifa = bdId.intValue();
|
||||
|
@ -196,149 +190,7 @@ public class ModificacionMasivaTarifasUploadController extends MyGenericForwardC
|
|||
Tarifa tarifa = tarifaService.obtenerID(idTarifa);
|
||||
|
||||
if (tarifa != null) {
|
||||
|
||||
Tramo tramo = tarifa.getTramo();
|
||||
|
||||
if (tramo != null) {
|
||||
|
||||
Parada origem = tarifa.getTramo().getOrigem();
|
||||
Ciudad ciudad = origem.getCiudad();
|
||||
Plaza plaza = null;
|
||||
|
||||
if (ciudad != null) {
|
||||
plaza = ciudad.getPlaza();
|
||||
}
|
||||
|
||||
Parada destino = tarifa.getTramo().getDestino();
|
||||
ClaseServicio claseServicio = tarifa.getClaseServicio();
|
||||
Moneda moneda = tarifa.getMoneda();
|
||||
|
||||
// verificando se a tarifa eh de um mercado competido:
|
||||
boolean existeMercadoCompetido = mercadoCompetidoService.existe(claseServicio, origem, destino);
|
||||
if (!existeMercadoCompetido) {
|
||||
try {
|
||||
Cell cellNovoPrecio = null;
|
||||
|
||||
if (componentePreco.equals(EnumTarifaPedagio.TARIFA.getDescricao())) {
|
||||
cellNovoPrecio = row.getCell(CELL_NOVO_PRECIO);
|
||||
} else if (componentePreco.equals(EnumTarifaPedagio.PEDAGIO.getDescricao())) {
|
||||
cellNovoPrecio = row.getCell(CELL_NOVO_PEAJE);
|
||||
} else if (componentePreco.equals(EnumTarifaPedagio.TX_EMBARQUE.getDescricao())) {
|
||||
cellNovoPrecio = row.getCell(CELL_NOVO_TX_EMBARQUE);
|
||||
} else if (componentePreco.equals(EnumTarifaPedagio.SEGURO.getDescricao())) {
|
||||
cellNovoPrecio = row.getCell(CELL_NOVO_SEGURO);
|
||||
}
|
||||
|
||||
BigDecimal novoPrecio = new BigDecimal(cellNovoPrecio.getNumericCellValue());
|
||||
novoPrecio = novoPrecio.setScale(2, RoundingMode.HALF_UP);
|
||||
|
||||
Boolean podeSalvarTarifaMinima = tarifaService.podeAlterarTarifaMinima(tarifa, tarifa.getMarca(),
|
||||
origem, destino, claseServicio, plaza, moneda);
|
||||
|
||||
if (podeSalvarTarifaMinima) {
|
||||
|
||||
if (salvarNuevos) {
|
||||
|
||||
Tarifa tarifaNueva = new Tarifa();
|
||||
|
||||
tarifaNueva.setClaseServicio(tarifa.getClaseServicio());
|
||||
tarifaNueva.setMarca(tarifa.getMarca());
|
||||
tarifaNueva.setMoneda(tarifa.getMoneda());
|
||||
|
||||
if (componentePreco.equals(EnumTarifaPedagio.TARIFA.getDescricao())) {
|
||||
tarifa.setPrecio(novoPrecio);
|
||||
} else if (componentePreco.equals(EnumTarifaPedagio.PEDAGIO.getDescricao())) {
|
||||
tarifa.setImportepedagio(novoPrecio);
|
||||
} else if (componentePreco.equals(EnumTarifaPedagio.TX_EMBARQUE.getDescricao())) {
|
||||
tarifa.setImportetaxaembarque(novoPrecio);
|
||||
} else if (componentePreco.equals(EnumTarifaPedagio.SEGURO.getDescricao())) {
|
||||
tarifa.setImporteseguro(novoPrecio);
|
||||
}
|
||||
|
||||
tarifaNueva.setPreciooriginal(tarifa.getPreciooriginal());
|
||||
tarifaNueva.setPrecioredabierto(tarifa.getPrecioredabierto());
|
||||
tarifaNueva.setStatustarifa("A");
|
||||
tarifaNueva.setTramo(tarifa.getTramo());
|
||||
tarifaNueva.setRuta(tarifa.getRuta());
|
||||
tarifaNueva.setOrgaoConcedente(tarifa.getOrgaoConcedente());
|
||||
tarifaNueva.setOrigen(tarifa.getOrigen());
|
||||
tarifaNueva.setDestino(tarifa.getDestino());
|
||||
|
||||
Comboitem cbiVt = cmbVigenciaTarifa.getSelectedItem();
|
||||
VigenciaTarifa nuevaVigencia;
|
||||
|
||||
if(getRdVigenciaAtual().isChecked()) {
|
||||
tarifaNueva.setVigenciaTarifa(vigenciaTarifa);
|
||||
nuevaVigencia = vigenciaTarifa;
|
||||
} else {
|
||||
nuevaVigencia = (VigenciaTarifa) cbiVt.getValue();
|
||||
tarifaNueva.setVigenciaTarifa(nuevaVigencia);
|
||||
}
|
||||
|
||||
boolean existeTarifa = tarifaService.existe(tarifaNueva.getMarca(), tarifaNueva.getTramo(), tarifaNueva.getMoneda(),
|
||||
tarifaNueva.getClaseServicio(), nuevaVigencia, tarifaNueva.getRuta(), tarifaNueva.getOrgaoConcedente());
|
||||
|
||||
if (existeTarifa) {
|
||||
strDuplicidade = strDuplicidade + Labels.getLabel("modificacionMasivaTarifasController.MSG.tarifaExiste") + " (" + tarifa.getTarifaId() + "). \n";
|
||||
} else {
|
||||
tarifa = tarifaService.suscribir(tarifaNueva);
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
if (componentePreco.equals(EnumTarifaPedagio.TARIFA.getDescricao())) {
|
||||
tarifa.setPrecio(novoPrecio);
|
||||
} else if (componentePreco.equals(EnumTarifaPedagio.PEDAGIO.getDescricao())) {
|
||||
tarifa.setImportepedagio(novoPrecio);
|
||||
} else if (componentePreco.equals(EnumTarifaPedagio.TX_EMBARQUE.getDescricao())) {
|
||||
tarifa.setImportetaxaembarque(novoPrecio);
|
||||
} else if (componentePreco.equals(EnumTarifaPedagio.SEGURO.getDescricao())) {
|
||||
tarifa.setImporteseguro(novoPrecio);
|
||||
}
|
||||
|
||||
tarifa.setStatustarifa("A");
|
||||
|
||||
tarifa = tarifaService.actualizacion(tarifa);
|
||||
}
|
||||
|
||||
contador = contador + 1;
|
||||
} else {
|
||||
String strTmpTarifaMinima = "TARIFA MINIMA: \n"
|
||||
+ "Tarifa: " + tarifa.getTarifaId() + "; \n"
|
||||
+ "Tramo: " + tramo.getDesctramo() + "; \n"
|
||||
+ "Via: " + tramo.getVia() + "; \n"
|
||||
+ "Clase Servicio: " + claseServicio + "; \n"
|
||||
+ "Precio: " + tarifa.getPrecio().setScale(2).toString() + "\n";
|
||||
|
||||
log.info(strTmpTarifaMinima);
|
||||
|
||||
strTarifaMinima = strTarifaMinima + strTmpTarifaMinima;
|
||||
}
|
||||
} catch (IllegalStateException ex) {
|
||||
String strTmpErrorTarifa = "ERROR: formato nuevo precio." + ex + "\n"
|
||||
+ "Tarifa: " + tarifa.getTarifaId() + "; \n"
|
||||
+ "Tramo: " + tramo.getDesctramo() + "; \n"
|
||||
+ "Via: " + tramo.getVia() + "; \n"
|
||||
+ "Clase Servicio: " + claseServicio + "; \n"
|
||||
+ "Precio: " + tarifa.getPrecio().setScale(2).toString() + "\n";
|
||||
|
||||
log.error(strTmpErrorTarifa);
|
||||
|
||||
strErrorTarifa = strErrorTarifa + strTmpErrorTarifa;
|
||||
}
|
||||
} else {
|
||||
String strTmpMercadoCompetido = "MERCADO COMPETIDO: \n"
|
||||
+ "Tarifa: " + tarifa.getTarifaId() + "; \n"
|
||||
+ "Tramo: " + tramo.getDesctramo() + "; \n"
|
||||
+ "Via: " + tramo.getVia() + "; \n"
|
||||
+ "Clase Servicio: " + claseServicio + "; \n"
|
||||
+ "Precio: " + tarifa.getPrecio().setScale(2).toString() + "\n";
|
||||
|
||||
log.info(strTmpMercadoCompetido);
|
||||
|
||||
strMercadoCompetido = strMercadoCompetido + strTmpMercadoCompetido;
|
||||
}
|
||||
}
|
||||
contador = gerarComponeneteTarifa(tarifa, row, salvarNuevos, contador, strDuplicidade, strTarifaMinima, strErrorTarifa, strMercadoCompetido);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -523,4 +375,222 @@ public class ModificacionMasivaTarifasUploadController extends MyGenericForwardC
|
|||
public void setLsComponentePreco(List<String> lsComponentePreco) {
|
||||
this.lsComponentePreco = lsComponentePreco;
|
||||
}
|
||||
|
||||
private Integer gerarComponeneteTarifa(Tarifa tarifa, Row row, boolean salvarNuevos, Integer contador, String strDuplicidade, String strTarifaMinima,
|
||||
String strErrorTarifa, String strMercadoCompetido){
|
||||
Tramo tramo = tarifa.getTramo();
|
||||
|
||||
if (tramo != null) {
|
||||
|
||||
Parada origem = tarifa.getTramo().getOrigem();
|
||||
Ciudad ciudad = origem.getCiudad();
|
||||
Plaza plaza = null;
|
||||
|
||||
if (ciudad != null) {
|
||||
plaza = ciudad.getPlaza();
|
||||
}
|
||||
|
||||
Parada destino = tarifa.getTramo().getDestino();
|
||||
ClaseServicio claseServicio = tarifa.getClaseServicio();
|
||||
Moneda moneda = tarifa.getMoneda();
|
||||
|
||||
// verificando se a tarifa eh de um mercado competido:
|
||||
boolean existeMercadoCompetido = mercadoCompetidoService.existe(claseServicio, origem, destino);
|
||||
if (!existeMercadoCompetido) {
|
||||
try {
|
||||
Cell cellNovoPrecio = null;
|
||||
|
||||
Boolean podeSalvarTarifaMinima = tarifaService.podeAlterarTarifaMinima(tarifa, tarifa.getMarca(),
|
||||
origem, destino, claseServicio, plaza, moneda);
|
||||
|
||||
if (podeSalvarTarifaMinima) {
|
||||
|
||||
if (salvarNuevos) {
|
||||
|
||||
Tarifa tarifaNueva = new Tarifa();
|
||||
|
||||
tarifaNueva.setClaseServicio(tarifa.getClaseServicio());
|
||||
tarifaNueva.setMarca(tarifa.getMarca());
|
||||
tarifaNueva.setMoneda(tarifa.getMoneda());
|
||||
|
||||
if (componentePreco.equals(EnumTarifaPedagio.TARIFA.getDescricao()) ||
|
||||
(componentePreco.equals(EnumTarifaPedagio.TODOS.getDescricao()) && row.getCell(CELL_NOVO_PRECIO) != null)) {
|
||||
cellNovoPrecio = row.getCell(CELL_NOVO_PRECIO);
|
||||
BigDecimal novoPrecio = new BigDecimal(cellNovoPrecio.getNumericCellValue());
|
||||
novoPrecio = novoPrecio.setScale(2, RoundingMode.HALF_UP);
|
||||
|
||||
tarifa.setPrecio(novoPrecio);
|
||||
}
|
||||
|
||||
if (componentePreco.equals(EnumTarifaPedagio.PEDAGIO.getDescricao()) ||
|
||||
(componentePreco.equals(EnumTarifaPedagio.TODOS.getDescricao()) && row.getCell(CELL_NOVO_PEAJE) != null)) {
|
||||
cellNovoPrecio = row.getCell(CELL_NOVO_PEAJE);
|
||||
BigDecimal novoPrecio = new BigDecimal(cellNovoPrecio.getNumericCellValue());
|
||||
novoPrecio = novoPrecio.setScale(2, RoundingMode.HALF_UP);
|
||||
|
||||
tarifa.setImportepedagio(novoPrecio);
|
||||
}
|
||||
|
||||
if (componentePreco.equals(EnumTarifaPedagio.TX_EMBARQUE.getDescricao()) ||
|
||||
(componentePreco.equals(EnumTarifaPedagio.TODOS.getDescricao()) && row.getCell(CELL_NOVO_TX_EMBARQUE) != null)) {
|
||||
cellNovoPrecio = row.getCell(CELL_NOVO_TX_EMBARQUE);
|
||||
BigDecimal novoPrecio = new BigDecimal(cellNovoPrecio.getNumericCellValue());
|
||||
novoPrecio = novoPrecio.setScale(2, RoundingMode.HALF_UP);
|
||||
|
||||
tarifa.setImportetaxaembarque(novoPrecio);
|
||||
}
|
||||
|
||||
if (componentePreco.equals(EnumTarifaPedagio.SEGURO.getDescricao()) ||
|
||||
(componentePreco.equals(EnumTarifaPedagio.TODOS.getDescricao()) && row.getCell(CELL_NOVO_SEGURO) != null)){
|
||||
cellNovoPrecio = row.getCell(CELL_NOVO_SEGURO);
|
||||
BigDecimal novoPrecio = new BigDecimal(cellNovoPrecio.getNumericCellValue());
|
||||
novoPrecio = novoPrecio.setScale(2, RoundingMode.HALF_UP);
|
||||
|
||||
tarifa.setImporteseguro(novoPrecio);
|
||||
}
|
||||
|
||||
tarifaNueva.setPreciooriginal(tarifa.getPreciooriginal());
|
||||
tarifaNueva.setPrecioredabierto(tarifa.getPrecioredabierto());
|
||||
tarifaNueva.setStatustarifa("A");
|
||||
tarifaNueva.setTramo(tarifa.getTramo());
|
||||
tarifaNueva.setRuta(tarifa.getRuta());
|
||||
tarifaNueva.setOrgaoConcedente(tarifa.getOrgaoConcedente());
|
||||
tarifaNueva.setOrigen(tarifa.getOrigen());
|
||||
tarifaNueva.setDestino(tarifa.getDestino());
|
||||
|
||||
Comboitem cbiVt = cmbVigenciaTarifa.getSelectedItem();
|
||||
VigenciaTarifa nuevaVigencia;
|
||||
|
||||
if(getRdVigenciaAtual().isChecked()) {
|
||||
tarifaNueva.setVigenciaTarifa(vigenciaTarifa);
|
||||
nuevaVigencia = vigenciaTarifa;
|
||||
} else {
|
||||
nuevaVigencia = (VigenciaTarifa) cbiVt.getValue();
|
||||
tarifaNueva.setVigenciaTarifa(nuevaVigencia);
|
||||
}
|
||||
|
||||
boolean existeTarifa = tarifaService.existe(tarifaNueva.getMarca(), tarifaNueva.getTramo(), tarifaNueva.getMoneda(),
|
||||
tarifaNueva.getClaseServicio(), nuevaVigencia, tarifaNueva.getRuta(), tarifaNueva.getOrgaoConcedente());
|
||||
|
||||
if (existeTarifa) {
|
||||
strDuplicidade = strDuplicidade + Labels.getLabel("modificacionMasivaTarifasController.MSG.tarifaExiste") + " (" + tarifa.getTarifaId() + "). \n";
|
||||
} else {
|
||||
tarifa = tarifaService.suscribir(tarifaNueva);
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
if (componentePreco.equals(EnumTarifaPedagio.TARIFA.getDescricao()) ||
|
||||
(componentePreco.equals(EnumTarifaPedagio.TODOS.getDescricao()))) {
|
||||
cellNovoPrecio = row.getCell(CELL_NOVO_PRECIO);
|
||||
BigDecimal novoPrecio = new BigDecimal(cellNovoPrecio.getNumericCellValue());
|
||||
novoPrecio = novoPrecio.setScale(2, RoundingMode.HALF_UP);
|
||||
|
||||
tarifa.setPrecio(novoPrecio);
|
||||
}
|
||||
|
||||
if (componentePreco.equals(EnumTarifaPedagio.PEDAGIO.getDescricao()) ||
|
||||
(componentePreco.equals(EnumTarifaPedagio.TODOS.getDescricao()))) {
|
||||
cellNovoPrecio = row.getCell(CELL_NOVO_PEAJE);
|
||||
BigDecimal novoPrecio = new BigDecimal(cellNovoPrecio.getNumericCellValue());
|
||||
novoPrecio = novoPrecio.setScale(2, RoundingMode.HALF_UP);
|
||||
|
||||
tarifa.setImportepedagio(novoPrecio);
|
||||
}
|
||||
|
||||
if (componentePreco.equals(EnumTarifaPedagio.TX_EMBARQUE.getDescricao()) ||
|
||||
(componentePreco.equals(EnumTarifaPedagio.TODOS.getDescricao()))) {
|
||||
cellNovoPrecio = row.getCell(CELL_NOVO_TX_EMBARQUE);
|
||||
BigDecimal novoPrecio = new BigDecimal(cellNovoPrecio.getNumericCellValue());
|
||||
novoPrecio = novoPrecio.setScale(2, RoundingMode.HALF_UP);
|
||||
|
||||
tarifa.setImportetaxaembarque(novoPrecio);
|
||||
}
|
||||
|
||||
if (componentePreco.equals(EnumTarifaPedagio.SEGURO.getDescricao()) ||
|
||||
(componentePreco.equals(EnumTarifaPedagio.TODOS.getDescricao()))) {
|
||||
cellNovoPrecio = row.getCell(CELL_NOVO_SEGURO);
|
||||
BigDecimal novoPrecio = new BigDecimal(cellNovoPrecio.getNumericCellValue());
|
||||
novoPrecio = novoPrecio.setScale(2, RoundingMode.HALF_UP);
|
||||
|
||||
tarifa.setImporteseguro(novoPrecio);
|
||||
}
|
||||
|
||||
tarifa.setStatustarifa("A");
|
||||
|
||||
tarifa = tarifaService.actualizacion(tarifa);
|
||||
}
|
||||
|
||||
contador = contador + 1;
|
||||
} else {
|
||||
String strTmpTarifaMinima = "TARIFA MINIMA: \n"
|
||||
+ "Tarifa: " + tarifa.getTarifaId() + "; \n"
|
||||
+ "Tramo: " + tramo.getDesctramo() + "; \n"
|
||||
+ "Via: " + tramo.getVia() + "; \n"
|
||||
+ "Clase Servicio: " + claseServicio + "; \n"
|
||||
+ "Precio: " + tarifa.getPrecio().setScale(2).toString() + "\n";
|
||||
|
||||
log.info(strTmpTarifaMinima);
|
||||
|
||||
strTarifaMinima = strTarifaMinima + strTmpTarifaMinima;
|
||||
}
|
||||
} catch (IllegalStateException ex) {
|
||||
String strTmpErrorTarifa = "ERROR: formato nuevo precio." + ex + "\n"
|
||||
+ "Tarifa: " + tarifa.getTarifaId() + "; \n"
|
||||
+ "Tramo: " + tramo.getDesctramo() + "; \n"
|
||||
+ "Via: " + tramo.getVia() + "; \n"
|
||||
+ "Clase Servicio: " + claseServicio + "; \n"
|
||||
+ "Precio: " + tarifa.getPrecio().setScale(2).toString() + "\n";
|
||||
|
||||
log.error(strTmpErrorTarifa);
|
||||
|
||||
strErrorTarifa = strErrorTarifa + strTmpErrorTarifa;
|
||||
}
|
||||
} else {
|
||||
String strTmpMercadoCompetido = "MERCADO COMPETIDO: \n"
|
||||
+ "Tarifa: " + tarifa.getTarifaId() + "; \n"
|
||||
+ "Tramo: " + tramo.getDesctramo() + "; \n"
|
||||
+ "Via: " + tramo.getVia() + "; \n"
|
||||
+ "Clase Servicio: " + claseServicio + "; \n"
|
||||
+ "Precio: " + tarifa.getPrecio().setScale(2).toString() + "\n";
|
||||
|
||||
log.info(strTmpMercadoCompetido);
|
||||
|
||||
strMercadoCompetido = strMercadoCompetido + strTmpMercadoCompetido;
|
||||
}
|
||||
}
|
||||
|
||||
return contador;
|
||||
}
|
||||
|
||||
private boolean validarComponenteEspecifico(Row row) {
|
||||
if (componentePreco.equals(EnumTarifaPedagio.TARIFA.getDescricao())){
|
||||
if (row.getCell(CELL_NOVO_PRECIO) == null) {
|
||||
return false;
|
||||
}
|
||||
} else if (componentePreco.equals(EnumTarifaPedagio.PEDAGIO.getDescricao())){
|
||||
if (row.getCell(CELL_NOVO_PEAJE) == null) {
|
||||
return false;
|
||||
}
|
||||
} else if (componentePreco.equals(EnumTarifaPedagio.SEGURO.getDescricao())){
|
||||
if (row.getCell(CELL_NOVO_SEGURO) == null) {
|
||||
return false;
|
||||
}
|
||||
} else if (componentePreco.equals(EnumTarifaPedagio.TX_EMBARQUE.getDescricao())){
|
||||
if (row.getCell(CELL_NOVO_TX_EMBARQUE) == null) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean validarTodosComponentes(Row row){
|
||||
if (row.getCell(CELL_NOVO_PRECIO) == null || row.getCell(CELL_NOVO_PEAJE) == null || row.getCell(CELL_NOVO_TX_EMBARQUE) == null ||
|
||||
row.getCell(CELL_NOVO_SEGURO) == null){
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2195,6 +2195,7 @@ busquedaTarifaController.MSG.vigenciaTarifa = No se encontró ningún registro c
|
|||
busquedaTarifaController.MSG.categoria = No se encontró ningún registro con este tipo pasajero
|
||||
busquedaTarifaController.MSG.tipoPuntoVenta = No se encontró ningún registro con este canal de venta
|
||||
busquedaTarifaController.MSG.dadosVazios= Não foram encontrados dados para gerar o arquivo Excel
|
||||
busquedaTarifaController.lhTodos.label = Todos
|
||||
|
||||
# Editar Tarifa:
|
||||
editarTarifaController.window.title = Tarifa
|
||||
|
|
|
@ -2250,6 +2250,7 @@ busquedaTarifaController.MSG.vigenciaTarifa = Não foi encontrado nenhum registr
|
|||
busquedaTarifaController.MSG.categoria = Não foi encontrado nenhum registro com esse tipo passageiro
|
||||
busquedaTarifaController.MSG.tipoPuntoVenta = Não foi encontrado nenhum registro com esse canal de Venda
|
||||
busquedaTarifaController.MSG.dadosVazios= Não foram encontrados dados para gerar o arquivo Excel
|
||||
busquedaTarifaController.lhTodos.label = Todos
|
||||
|
||||
# Editar Tarifa:
|
||||
editarTarifaController.window.title = Tarifa
|
||||
|
|
Loading…
Reference in New Issue