|
|
|
@ -36,12 +36,12 @@ import com.rjconsultores.ventaboletos.entidad.CoeficienteTarifa;
|
|
|
|
|
import com.rjconsultores.ventaboletos.entidad.Empresa;
|
|
|
|
|
import com.rjconsultores.ventaboletos.entidad.OrgaoConcedente;
|
|
|
|
|
import com.rjconsultores.ventaboletos.entidad.OrgaoTramo;
|
|
|
|
|
import com.rjconsultores.ventaboletos.entidad.Parada;
|
|
|
|
|
import com.rjconsultores.ventaboletos.entidad.Tramo;
|
|
|
|
|
import com.rjconsultores.ventaboletos.entidad.TramoKm;
|
|
|
|
|
import com.rjconsultores.ventaboletos.entidad.TramoServicio;
|
|
|
|
|
import com.rjconsultores.ventaboletos.entidad.TramoTiempo;
|
|
|
|
|
import com.rjconsultores.ventaboletos.entidad.Via;
|
|
|
|
|
import com.rjconsultores.ventaboletos.exception.BusinessException;
|
|
|
|
|
import com.rjconsultores.ventaboletos.service.ClaseServicioService;
|
|
|
|
|
import com.rjconsultores.ventaboletos.service.CoeficienteTarifaService;
|
|
|
|
|
import com.rjconsultores.ventaboletos.service.EmpresaService;
|
|
|
|
@ -70,7 +70,10 @@ import com.rjconsultores.ventaboletos.web.utilerias.render.RenderTramoTiempo;
|
|
|
|
|
@Scope("prototype")
|
|
|
|
|
public class EditarTramosController extends MyGenericForwardComposer {
|
|
|
|
|
|
|
|
|
|
private static Logger log = Logger.getLogger(EditarTramosController.class);
|
|
|
|
|
|
|
|
|
|
private static final long serialVersionUID = 1L;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private TramoService tramoService;
|
|
|
|
|
@Autowired
|
|
|
|
@ -135,7 +138,8 @@ public class EditarTramosController extends MyGenericForwardComposer {
|
|
|
|
|
private Button btnApagar;
|
|
|
|
|
private ConstraintNumberBD constraintTarifa;
|
|
|
|
|
private Tab tabExcepcionesKm;
|
|
|
|
|
private static Logger log = Logger.getLogger(EditarTramosController.class);
|
|
|
|
|
|
|
|
|
|
private boolean existeRutaOcupaTramo;
|
|
|
|
|
|
|
|
|
|
public Tramo getTramo() {
|
|
|
|
|
return tramo;
|
|
|
|
@ -219,6 +223,7 @@ public class EditarTramosController extends MyGenericForwardComposer {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void doAfterCompose(Component comp) throws Exception {
|
|
|
|
|
existeRutaOcupaTramo = false;
|
|
|
|
|
lsVias = viaService.obtenerTodos();
|
|
|
|
|
lsEmpresa = empresaService.obtenerTodos();
|
|
|
|
|
lsClaseServicio = claseServicioService.buscarTodosExceto(-1);
|
|
|
|
@ -239,6 +244,7 @@ public class EditarTramosController extends MyGenericForwardComposer {
|
|
|
|
|
|
|
|
|
|
tramo = (Tramo) Executions.getCurrent().getArg().get("tramo");
|
|
|
|
|
if (tramo.getTramoId() != null) {
|
|
|
|
|
existeRutaOcupaTramo = rutaCombinacionService.existeTramo(tramo);
|
|
|
|
|
tramo = tramoService.obtenerID(tramo.getTramoId());
|
|
|
|
|
|
|
|
|
|
for (TramoServicio ta : tramo.getTramoServicioList()) {
|
|
|
|
@ -513,8 +519,7 @@ public class EditarTramosController extends MyGenericForwardComposer {
|
|
|
|
|
cmbParadaDestino.getValue(true);
|
|
|
|
|
|
|
|
|
|
if (listaTramoServicio.isEmpty()) {
|
|
|
|
|
Messagebox.show(Labels.getLabel("editarTramosController.MSG.obligatorioTramoTiempo"),
|
|
|
|
|
Labels.getLabel("editarTramosController.window.title"), Messagebox.OK,
|
|
|
|
|
Messagebox.show(Labels.getLabel("editarTramosController.MSG.obligatorioTramoTiempo"), Labels.getLabel("editarTramosController.window.title"), Messagebox.OK,
|
|
|
|
|
Messagebox.INFORMATION);
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
@ -522,70 +527,21 @@ public class EditarTramosController extends MyGenericForwardComposer {
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
tramo.setLsOrgaoTramo(lsOrgamoTramo);
|
|
|
|
|
|
|
|
|
|
tramo.setActivo(Boolean.TRUE);
|
|
|
|
|
tramo.setFecmodif(Calendar.getInstance().getTime());
|
|
|
|
|
tramo.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId());
|
|
|
|
|
|
|
|
|
|
Parada origem = tramo.getOrigem();
|
|
|
|
|
Parada destino = tramo.getDestino();
|
|
|
|
|
|
|
|
|
|
tramo.setVia((Via) cmbVia.getSelectedItem().getValue());
|
|
|
|
|
tramo.setLsTramoTiempo(listaTramosTiempo);
|
|
|
|
|
tramo.setTramoServicioList(listaTramoServicio);
|
|
|
|
|
tramo.setTramoKms(listaTramosKm);
|
|
|
|
|
|
|
|
|
|
if (!origem.getParadaId().equals(destino.getParadaId())) {
|
|
|
|
|
Tramo tramoConsulta = tramoService.buscar(tramo.getOrigem(), tramo.getDestino(), tramo.getVia());
|
|
|
|
|
|
|
|
|
|
boolean podeSalvar = false;
|
|
|
|
|
if (tramoConsulta == null) {
|
|
|
|
|
podeSalvar = true;
|
|
|
|
|
} else {
|
|
|
|
|
if (tramoConsulta.getTramoId().equals(tramo.getTramoId())) {
|
|
|
|
|
podeSalvar = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (podeSalvar) {
|
|
|
|
|
if (tramo.getTramoId() == null) {
|
|
|
|
|
|
|
|
|
|
tramoService.suscribir(tramo);
|
|
|
|
|
tramosList.addItem(tramo);
|
|
|
|
|
|
|
|
|
|
Messagebox.show(Labels.getLabel("editarTramosController.MSG.suscribirOK"),
|
|
|
|
|
Labels.getLabel("editarTramosController.window.title"), Messagebox.OK,
|
|
|
|
|
Messagebox.INFORMATION);
|
|
|
|
|
|
|
|
|
|
closeWindow();
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
tramoService.actualizacion(tramo);
|
|
|
|
|
tramo = tramoService.suscribirActualizar(tramo);
|
|
|
|
|
tramosList.updateItem(tramo);
|
|
|
|
|
|
|
|
|
|
Messagebox.show(Labels.getLabel("editarTramosController.MSG.suscribirOK"),
|
|
|
|
|
Labels.getLabel("editarTramosController.window.title"), Messagebox.OK,
|
|
|
|
|
Messagebox.show(Labels.getLabel("editarTramosController.MSG.suscribirOK"), Labels.getLabel("editarTramosController.window.title"), Messagebox.OK,
|
|
|
|
|
Messagebox.INFORMATION);
|
|
|
|
|
|
|
|
|
|
closeWindow();
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
Messagebox.show(Labels.getLabel("MSG.Registro.Existe.Origem.Destino.Via"),
|
|
|
|
|
Labels.getLabel("editarTramosController.window.title"), Messagebox.OK,
|
|
|
|
|
Messagebox.EXCLAMATION);
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
Messagebox.show(Labels.getLabel("editarTramosController.MSG.OrigemDestinoIguais"),
|
|
|
|
|
Labels.getLabel("editarTramosController.window.title"), Messagebox.OK,
|
|
|
|
|
Messagebox.EXCLAMATION);
|
|
|
|
|
}
|
|
|
|
|
} catch (Exception ex) {
|
|
|
|
|
if (ex instanceof WrongValueException) {
|
|
|
|
|
throw (WrongValueException) ex;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
log.error(ex);
|
|
|
|
|
Messagebox.show(Labels.getLabel("MSG.Error"), Labels.getLabel("editarTramosController.window.title"),
|
|
|
|
|
Messagebox.OK, Messagebox.ERROR);
|
|
|
|
|
} catch (BusinessException ex) {
|
|
|
|
|
Messagebox.show(ex.getLocalizedMessage(), Labels.getLabel("editarTramosController.window.title"), Messagebox.OK, Messagebox.ERROR);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -676,14 +632,11 @@ public class EditarTramosController extends MyGenericForwardComposer {
|
|
|
|
|
orgaoConcedente = (OrgaoConcedente) cbiOrgaoConcedente.getValue();
|
|
|
|
|
claseServicio = (ClaseServicio) cbiClaseServicio.getValue();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Integer kmCoeficiente1 = txtKMCoeficiente1.getValue();
|
|
|
|
|
Integer kmCoeficiente2 = txtKMCoeficiente2.getValue();
|
|
|
|
|
Integer kmCoeficiente3 = txtKMCoeficiente3.getValue();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ( (coeficienteTarifa1 == null) && (kmCoeficiente1 == null)){
|
|
|
|
|
if ((coeficienteTarifa1 == null) && (kmCoeficiente1 == null)) {
|
|
|
|
|
|
|
|
|
|
Messagebox.show(Labels.getLabel("editarTramosController.msg.coeficiente1Obligatorio"),
|
|
|
|
|
Labels.getLabel("editarTramosController.window.title"), Messagebox.OK, Messagebox.EXCLAMATION);
|
|
|
|
@ -691,21 +644,21 @@ public class EditarTramosController extends MyGenericForwardComposer {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ( ((coeficienteTarifa1 != null) && (kmCoeficiente1 == null)) || ((coeficienteTarifa1 == null) && (kmCoeficiente1 != null))){
|
|
|
|
|
if (((coeficienteTarifa1 != null) && (kmCoeficiente1 == null)) || ((coeficienteTarifa1 == null) && (kmCoeficiente1 != null))) {
|
|
|
|
|
|
|
|
|
|
Messagebox.show(Labels.getLabel("editarTramosController.msg.coeficiente1ObligatorioDados"),
|
|
|
|
|
Labels.getLabel("editarTramosController.window.title"), Messagebox.OK, Messagebox.EXCLAMATION);
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if ( ((coeficienteTarifa2 != null) && (kmCoeficiente2 == null)) || ((coeficienteTarifa2 == null) && (kmCoeficiente2 != null))){
|
|
|
|
|
if (((coeficienteTarifa2 != null) && (kmCoeficiente2 == null)) || ((coeficienteTarifa2 == null) && (kmCoeficiente2 != null))) {
|
|
|
|
|
|
|
|
|
|
Messagebox.show(Labels.getLabel("editarTramosController.msg.coeficiente2ObligatorioDados"),
|
|
|
|
|
Labels.getLabel("editarTramosController.window.title"), Messagebox.OK, Messagebox.EXCLAMATION);
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if ( ((coeficienteTarifa3 != null) && (kmCoeficiente3 == null)) || ((coeficienteTarifa3 == null) && (kmCoeficiente3 != null))){
|
|
|
|
|
if (((coeficienteTarifa3 != null) && (kmCoeficiente3 == null)) || ((coeficienteTarifa3 == null) && (kmCoeficiente3 != null))) {
|
|
|
|
|
|
|
|
|
|
Messagebox.show(Labels.getLabel("editarTramosController.msg.coeficiente3ObligatorioDados"),
|
|
|
|
|
Labels.getLabel("editarTramosController.window.title"), Messagebox.OK, Messagebox.EXCLAMATION);
|
|
|
|
@ -716,13 +669,12 @@ public class EditarTramosController extends MyGenericForwardComposer {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public boolean evaluate(Object obj) {
|
|
|
|
|
OrgaoTramo ot = (OrgaoTramo)obj;
|
|
|
|
|
return (ot.getActivo() && ot.getOrgaoConcedente().equals(orgaoConcedente) && ot.getClaseServicio().equals(claseServicio) );
|
|
|
|
|
OrgaoTramo ot = (OrgaoTramo) obj;
|
|
|
|
|
return (ot.getActivo() && ot.getOrgaoConcedente().equals(orgaoConcedente) && ot.getClaseServicio().equals(claseServicio));
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (orgaoClaseJahInformado){
|
|
|
|
|
if (orgaoClaseJahInformado) {
|
|
|
|
|
Messagebox.show(Labels.getLabel("editarTramosController.msg.orgaoJahInformado"),
|
|
|
|
|
Labels.getLabel("editarTramosController.window.title"), Messagebox.OK, Messagebox.EXCLAMATION);
|
|
|
|
|
|
|
|
|
@ -756,4 +708,9 @@ public class EditarTramosController extends MyGenericForwardComposer {
|
|
|
|
|
txtKMCoeficiente2.setValue(null);
|
|
|
|
|
txtKMCoeficiente3.setValue(null);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public boolean isExisteRutaOcupaTramo() {
|
|
|
|
|
return existeRutaOcupaTramo;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|