gleimar 2015-11-08 21:06:16 +00:00
parent 90329bd791
commit 49b9a21b5a
2 changed files with 31 additions and 10 deletions

View File

@ -4,9 +4,6 @@
*/
package com.rjconsultores.ventaboletos.service;
import java.util.List;
import com.rjconsultores.ventaboletos.entidad.ConexionCtrl;
import com.rjconsultores.ventaboletos.entidad.PrecioVentaja;
import com.rjconsultores.ventaboletos.exception.BusinessException;
import com.rjconsultores.ventaboletos.utilerias.RegistroConDependenciaException;
@ -19,6 +16,5 @@ public interface PrecioVentajaService {
public PrecioVentaja suscribirActualizacion(PrecioVentaja entidad) throws BusinessException;
public void borrar(PrecioVentaja entidad) throws RegistroConDependenciaException;
public List<PrecioVentaja> buscarPrecioVentaja(Integer origenId, Integer destinoId, Integer rutaid);
}

View File

@ -13,6 +13,7 @@ import org.springframework.transaction.annotation.Transactional;
import org.zkoss.util.resource.Labels;
import com.rjconsultores.ventaboletos.dao.PrecioVentajaDAO;
import com.rjconsultores.ventaboletos.entidad.Estacion;
import com.rjconsultores.ventaboletos.entidad.PrecioVentaja;
import com.rjconsultores.ventaboletos.exception.BusinessException;
import com.rjconsultores.ventaboletos.service.PrecioVentajaService;
@ -76,6 +77,15 @@ public class PrecioVentajaServiceImpl implements PrecioVentajaService {
throw new BusinessException("editarPrecioVentajaController.MSG.destinoOuOrigemNaoExistemDestino");
}
Boolean precioVentajaDuplicado = validarDuplicidade(entidad);
if (precioVentajaDuplicado) {
throw new BusinessException("editarPrecioVentajaController.MSG.data.existeIgual", new Object[] { entidad.getOrigenOriginalId().getDescparada(),
entidad.getDestinoOriginalId().getDescparada(), entidad.getRutaOriginalId().getDescruta() });
}
if (entidad.getPrecioVentajaId() == null) {
return precioVentajaDAO.suscribir(entidad);
} else {
@ -83,6 +93,27 @@ public class PrecioVentajaServiceImpl implements PrecioVentajaService {
}
}
private Boolean validarDuplicidade(PrecioVentaja entidad) {
List<PrecioVentaja> lsPrecioVentaja = precioVentajaDAO.buscarPrecioVentaja(entidad.getOrigenOriginalId().getParadaId(), entidad.getDestinoOriginalId().getParadaId(), entidad.getRutaOriginalId().getRutaId());
Boolean precioVentajaDuplicado = false;
if (!lsPrecioVentaja.isEmpty()) {
if (entidad.getPrecioVentajaId() == null){
precioVentajaDuplicado = Boolean.TRUE;
}else{
for (PrecioVentaja est : lsPrecioVentaja) {
if (!est.getPrecioVentajaId().equals(entidad.getPrecioVentajaId())) {
precioVentajaDuplicado = Boolean.TRUE;
break;
}
}
}
}
return precioVentajaDuplicado;
}
private Boolean verificarPreenchimentoDataInicioFim(PrecioVentaja entidad){
if(entidad.getFechaInicio() == null || entidad.getFechaFinal() == null){
return false;
@ -138,10 +169,4 @@ public class PrecioVentajaServiceImpl implements PrecioVentajaService {
entidad.setActivo(Boolean.FALSE);
precioVentajaDAO.actualizacion(entidad);
}
@Override
public List<PrecioVentaja> buscarPrecioVentaja(Integer origenId, Integer destinoId, Integer rutaid) {
return precioVentajaDAO.buscarPrecioVentaja(origenId, destinoId, rutaid);
}
}