leonardo 2016-08-04 18:49:49 +00:00
parent 7ccc6ad523
commit 1b8e707921
2 changed files with 15 additions and 14 deletions

View File

@ -220,7 +220,10 @@ public class CalcularPeajeHibernateDAO extends GenericHibernateDAO<String, Strin
Map<Integer, CasetaPeaje> casetas = buscaCasetas(pvos); Map<Integer, CasetaPeaje> casetas = buscaCasetas(pvos);
Map<Integer, ExcepcionPeaje> excepciones = new HashMap<Integer, ExcepcionPeaje>(); Map<Integer, ExcepcionPeaje> excepciones = new HashMap<Integer, ExcepcionPeaje>();
for (PeajeVO peaje : pvos){ for (PeajeVO peaje : pvos){
ExcepcionPeaje excepcion = getExcepcion(peaje.rutaId, peaje.origenId, peaje.destinoId); ExcepcionPeaje excepcion = null;
CasetaPeaje caseta = casetas.get(peaje.casetaPeajeId);
for (CasetaPeajeExcepcion cpe : caseta.getLsCasetaPeajeExcepcion()){
if (excepcion == null){ if (excepcion == null){
excepcion = new ExcepcionPeaje(); excepcion = new ExcepcionPeaje();
excepcion.setActivo(true); excepcion.setActivo(true);
@ -230,10 +233,6 @@ public class CalcularPeajeHibernateDAO extends GenericHibernateDAO<String, Strin
excepcion.setRuta(getRuta(peaje.rutaId)); excepcion.setRuta(getRuta(peaje.rutaId));
excepcion.setUsuarioId(1); excepcion.setUsuarioId(1);
} }
CasetaPeaje caseta = casetas.get(peaje.casetaPeajeId);
for (CasetaPeajeExcepcion cpe : caseta.getLsCasetaPeajeExcepcion()){
ExcepcionPeajeVigencia epv = new ExcepcionPeajeVigencia(); ExcepcionPeajeVigencia epv = new ExcepcionPeajeVigencia();
epv.setActivo(cpe.getActivo()); epv.setActivo(cpe.getActivo());
epv.setExcepcionPeaje(excepcion); epv.setExcepcionPeaje(excepcion);
@ -254,10 +253,11 @@ public class CalcularPeajeHibernateDAO extends GenericHibernateDAO<String, Strin
epv.setCasetaPeaje(caseta); epv.setCasetaPeaje(caseta);
excepcion.getLsExcepcionPeajeVigencia().add(epv); excepcion.getLsExcepcionPeajeVigencia().add(epv);
} }
if (excepcion != null){
getSession().saveOrUpdate(excepcion); getSession().saveOrUpdate(excepcion);
} }
} }
}
private static class PeajeVO { private static class PeajeVO {

View File

@ -51,8 +51,9 @@ public class CasetaPeaje implements Serializable, Comparable<CasetaPeaje>, Clone
private Date fecmodif; private Date fecmodif;
@Column(name = "USUARIO_ID") @Column(name = "USUARIO_ID")
private Integer usuarioId; private Integer usuarioId;
@OneToMany(mappedBy = "casetaPeaje") @OneToMany(mappedBy = "casetaPeaje", fetch=FetchType.EAGER, cascade=CascadeType.ALL)
@Where(clause="ACTIVO=1") @Where(clause="ACTIVO=1")
@Fetch(value = FetchMode.SELECT)
private List<CasetaPeajeExcepcion> lsCasetaPeajeExcepcion = new ArrayList<CasetaPeajeExcepcion>(); private List<CasetaPeajeExcepcion> lsCasetaPeajeExcepcion = new ArrayList<CasetaPeajeExcepcion>();
@ManyToMany(fetch=FetchType.EAGER) @ManyToMany(fetch=FetchType.EAGER)
@JoinTable(name = "RUTA_CASETA", joinColumns = { @JoinColumn(name = "CASETAPEAJE_ID") }, @JoinTable(name = "RUTA_CASETA", joinColumns = { @JoinColumn(name = "CASETAPEAJE_ID") },