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,20 +220,19 @@ 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;
if (excepcion == null){
excepcion = new ExcepcionPeaje();
excepcion.setActivo(true);
excepcion.setDestino(getParada(peaje.destinoId));
excepcion.setFecmodif(Calendar.getInstance().getTime());
excepcion.setOrigem(getParada(peaje.origenId));
excepcion.setRuta(getRuta(peaje.rutaId));
excepcion.setUsuarioId(1);
}
CasetaPeaje caseta = casetas.get(peaje.casetaPeajeId); CasetaPeaje caseta = casetas.get(peaje.casetaPeajeId);
for (CasetaPeajeExcepcion cpe : caseta.getLsCasetaPeajeExcepcion()){ for (CasetaPeajeExcepcion cpe : caseta.getLsCasetaPeajeExcepcion()){
if (excepcion == null){
excepcion = new ExcepcionPeaje();
excepcion.setActivo(true);
excepcion.setDestino(getParada(peaje.destinoId));
excepcion.setFecmodif(Calendar.getInstance().getTime());
excepcion.setOrigem(getParada(peaje.origenId));
excepcion.setRuta(getRuta(peaje.rutaId));
excepcion.setUsuarioId(1);
}
ExcepcionPeajeVigencia epv = new ExcepcionPeajeVigencia(); ExcepcionPeajeVigencia epv = new ExcepcionPeajeVigencia();
epv.setActivo(cpe.getActivo()); epv.setActivo(cpe.getActivo());
epv.setExcepcionPeaje(excepcion); epv.setExcepcionPeaje(excepcion);
@ -254,8 +253,9 @@ 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);
}
} }
} }

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") },