fixes bug#17752
dev: qua: git-svn-id: http://desenvolvimento.rjconsultores.com.br/repositorio/sco/AdmVenta/Model/trunk/modelWeb@99584 d1611594-4594-4d17-8e1d-87c2c4800839master
parent
3ce7f6463b
commit
dd409b00bf
|
@ -5,6 +5,7 @@
|
||||||
package com.rjconsultores.ventaboletos.dao;
|
package com.rjconsultores.ventaboletos.dao;
|
||||||
|
|
||||||
import com.rjconsultores.ventaboletos.entidad.ClaseServicio;
|
import com.rjconsultores.ventaboletos.entidad.ClaseServicio;
|
||||||
|
import com.rjconsultores.ventaboletos.entidad.Empresa;
|
||||||
import com.rjconsultores.ventaboletos.entidad.Marca;
|
import com.rjconsultores.ventaboletos.entidad.Marca;
|
||||||
import com.rjconsultores.ventaboletos.entidad.Moneda;
|
import com.rjconsultores.ventaboletos.entidad.Moneda;
|
||||||
import com.rjconsultores.ventaboletos.entidad.Parada;
|
import com.rjconsultores.ventaboletos.entidad.Parada;
|
||||||
|
@ -12,6 +13,7 @@ import com.rjconsultores.ventaboletos.entidad.Ruta;
|
||||||
import com.rjconsultores.ventaboletos.entidad.TarifaEmbarcada;
|
import com.rjconsultores.ventaboletos.entidad.TarifaEmbarcada;
|
||||||
import com.rjconsultores.ventaboletos.entidad.Via;
|
import com.rjconsultores.ventaboletos.entidad.Via;
|
||||||
import com.rjconsultores.ventaboletos.entidad.VigenciaTarifa;
|
import com.rjconsultores.ventaboletos.entidad.VigenciaTarifa;
|
||||||
|
import com.rjconsultores.ventaboletos.exception.BusinessException;
|
||||||
|
|
||||||
public interface TarifaEmbarcadaDAO extends GenericDAO<TarifaEmbarcada, Integer> {
|
public interface TarifaEmbarcadaDAO extends GenericDAO<TarifaEmbarcada, Integer> {
|
||||||
|
|
||||||
|
@ -19,4 +21,6 @@ public interface TarifaEmbarcadaDAO extends GenericDAO<TarifaEmbarcada, Integer>
|
||||||
Parada destino, Ruta ruta, Via via, Boolean vende);
|
Parada destino, Ruta ruta, Via via, Boolean vende);
|
||||||
|
|
||||||
public void updateTarifa(TarifaEmbarcada t);
|
public void updateTarifa(TarifaEmbarcada t);
|
||||||
|
|
||||||
|
public void copiarTarifas(VigenciaTarifa vigenciaTarifaOrigem, VigenciaTarifa vigenciaTarifaDestino, Empresa empresa, boolean excluirTarifasDestino) throws BusinessException;
|
||||||
}
|
}
|
|
@ -6,17 +6,21 @@ package com.rjconsultores.ventaboletos.dao.hibernate;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
import org.hibernate.Criteria;
|
import org.hibernate.Criteria;
|
||||||
import org.hibernate.Query;
|
import org.hibernate.Query;
|
||||||
|
import org.hibernate.SQLQuery;
|
||||||
import org.hibernate.Session;
|
import org.hibernate.Session;
|
||||||
import org.hibernate.SessionFactory;
|
import org.hibernate.SessionFactory;
|
||||||
import org.hibernate.criterion.Restrictions;
|
import org.hibernate.criterion.Restrictions;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.annotation.Qualifier;
|
import org.springframework.beans.factory.annotation.Qualifier;
|
||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import com.rjconsultores.ventaboletos.dao.TarifaEmbarcadaDAO;
|
import com.rjconsultores.ventaboletos.dao.TarifaEmbarcadaDAO;
|
||||||
import com.rjconsultores.ventaboletos.entidad.ClaseServicio;
|
import com.rjconsultores.ventaboletos.entidad.ClaseServicio;
|
||||||
|
import com.rjconsultores.ventaboletos.entidad.Empresa;
|
||||||
import com.rjconsultores.ventaboletos.entidad.Marca;
|
import com.rjconsultores.ventaboletos.entidad.Marca;
|
||||||
import com.rjconsultores.ventaboletos.entidad.Moneda;
|
import com.rjconsultores.ventaboletos.entidad.Moneda;
|
||||||
import com.rjconsultores.ventaboletos.entidad.Parada;
|
import com.rjconsultores.ventaboletos.entidad.Parada;
|
||||||
|
@ -24,10 +28,14 @@ import com.rjconsultores.ventaboletos.entidad.Ruta;
|
||||||
import com.rjconsultores.ventaboletos.entidad.TarifaEmbarcada;
|
import com.rjconsultores.ventaboletos.entidad.TarifaEmbarcada;
|
||||||
import com.rjconsultores.ventaboletos.entidad.Via;
|
import com.rjconsultores.ventaboletos.entidad.Via;
|
||||||
import com.rjconsultores.ventaboletos.entidad.VigenciaTarifa;
|
import com.rjconsultores.ventaboletos.entidad.VigenciaTarifa;
|
||||||
|
import com.rjconsultores.ventaboletos.exception.BusinessException;
|
||||||
|
import com.rjconsultores.ventaboletos.utilerias.UsuarioLogado;
|
||||||
|
|
||||||
@Repository("tarifaEmbarcadaDAO")
|
@Repository("tarifaEmbarcadaDAO")
|
||||||
public class TarifaEmbarcadaHibernateDAO extends GenericHibernateDAO<TarifaEmbarcada, Integer> implements TarifaEmbarcadaDAO {
|
public class TarifaEmbarcadaHibernateDAO extends GenericHibernateDAO<TarifaEmbarcada, Integer> implements TarifaEmbarcadaDAO {
|
||||||
|
|
||||||
|
private static Logger log = Logger.getLogger(TarifaEmbarcadaHibernateDAO.class);
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
public TarifaEmbarcadaHibernateDAO(@Qualifier("sessionFactory") SessionFactory factory) {
|
public TarifaEmbarcadaHibernateDAO(@Qualifier("sessionFactory") SessionFactory factory) {
|
||||||
setSessionFactory(factory);
|
setSessionFactory(factory);
|
||||||
|
@ -100,4 +108,87 @@ public class TarifaEmbarcadaHibernateDAO extends GenericHibernateDAO<TarifaEmbar
|
||||||
Session session = getSessionFactory().getCurrentSession();
|
Session session = getSessionFactory().getCurrentSession();
|
||||||
session.update(entity);
|
session.update(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional(rollbackFor = BusinessException.class)
|
||||||
|
public void copiarTarifas(VigenciaTarifa vigenciaTarifaOrigem, VigenciaTarifa vigenciaTarifaDestino, Empresa empresa, boolean excluirTarifasDestino) throws BusinessException {
|
||||||
|
try {
|
||||||
|
StringBuilder sQuery = null;
|
||||||
|
if (excluirTarifasDestino) {
|
||||||
|
sQuery = new StringBuilder("DELETE FROM TARIFA_EMBARCADA WHERE VIGENCIATARIFA_ID = :VIGENCIATARIFAID ");
|
||||||
|
SQLQuery qrUpdate = getSession().createSQLQuery(sQuery.toString());
|
||||||
|
qrUpdate.setParameter("VIGENCIATARIFAID", vigenciaTarifaDestino.getVigenciatarifaId());
|
||||||
|
qrUpdate.executeUpdate();
|
||||||
|
}
|
||||||
|
|
||||||
|
sQuery = new StringBuilder("INSERT INTO TARIFA_EMBARCADA( ");
|
||||||
|
sQuery.append("TARIFAEMBARCADA_ID,PRECIO,PRECIOREDABIERTO,TRAMO_ID,MARCA_ID,CLASESERVICIO_ID,PRECIOORIGINAL,MONEDA_ID,VIGENCIATARIFA_ID,STATUSTARIFA,ACTIVO,FECMODIF,")
|
||||||
|
.append("USUARIO_ID,IMPORTETAXAEMBARQUE,IMPORTEPEDAGIO,IMPORTEOUTROS,IMPORTESEGURO,ORGAOCONCEDENTE_ID,RUTA_ID,ORIGEN_ID,DESTINO_ID,IMPORTETPP) ")
|
||||||
|
.append(" SELECT "
|
||||||
|
+ "TARIFA_EMBARCADA_SEQ.NEXTVAL, "
|
||||||
|
+ "PRECIO, "
|
||||||
|
+ "PRECIOREDABIERTO, "
|
||||||
|
+ "TRAMO_ID, "
|
||||||
|
+ "tarifa.MARCA_ID, "
|
||||||
|
+ "CLASESERVICIO_ID, "
|
||||||
|
+ "PRECIOORIGINAL, "
|
||||||
|
+ "MONEDA_ID, "
|
||||||
|
+ ":VIGENCIATARIFAIDDESTINO, "
|
||||||
|
+ "STATUSTARIFA, "
|
||||||
|
+ "1, "
|
||||||
|
+ "sysdate, "
|
||||||
|
+ ":USUARIOID, "
|
||||||
|
+ "IMPORTETAXAEMBARQUE, "
|
||||||
|
+ "IMPORTEPEDAGIO, "
|
||||||
|
+ "IMPORTEOUTROS, "
|
||||||
|
+ "IMPORTESEGURO, "
|
||||||
|
+ "ORGAOCONCEDENTE_ID, "
|
||||||
|
+ "RUTA_ID, "
|
||||||
|
+ "ORIGEN_ID, "
|
||||||
|
+ "DESTINO_ID, "
|
||||||
|
+ "IMPORTETPP "
|
||||||
|
|
||||||
|
+ "FROM TARIFA tarifa "
|
||||||
|
+ "INNER JOIN MARCA marca ON marca.MARCA_ID = tarifa.MARCA_ID "
|
||||||
|
+ "WHERE tarifa.ACTIVO = 1 AND VIGENCIATARIFA_ID = :VIGENCIATARIFAIDORIGEM");
|
||||||
|
|
||||||
|
if (!excluirTarifasDestino) {
|
||||||
|
sQuery.append(" AND NOT EXISTS(SELECT"
|
||||||
|
+ " tDestino.TRAMO_ID,"
|
||||||
|
+ " tDestino.MARCA_ID,"
|
||||||
|
+ " tDestino.CLASESERVICIO_ID,"
|
||||||
|
+ " tDestino.MONEDA_ID,"
|
||||||
|
+ " tDestino.ORGAOCONCEDENTE_ID,"
|
||||||
|
+ " tDestino.RUTA_ID"
|
||||||
|
+ " FROM TARIFA_EMBARCADA tDestino"
|
||||||
|
+ " WHERE"
|
||||||
|
+ " tDestino.TRAMO_ID = tarifa.TRAMO_ID"
|
||||||
|
+ " AND tDestino.MARCA_ID = tarifa.MARCA_ID"
|
||||||
|
+ " AND tDestino.CLASESERVICIO_ID = tarifa.CLASESERVICIO_ID"
|
||||||
|
+ " AND tDestino.MONEDA_ID = tarifa.MONEDA_ID"
|
||||||
|
+ " AND tDestino.ORGAOCONCEDENTE_ID = tarifa.ORGAOCONCEDENTE_ID"
|
||||||
|
+ " AND tDestino.RUTA_ID = tarifa.RUTA_ID"
|
||||||
|
+ " AND tdestino.ACTIVO = 1"
|
||||||
|
+ " AND VIGENCIATARIFA_ID = :VIGENCIATARIFAIDDESTINO)");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (empresa != null && empresa.getEmpresaId() != -1) {
|
||||||
|
sQuery.append(" AND marca.EMPRESA_ID = :EMPRESA_ID");
|
||||||
|
}
|
||||||
|
|
||||||
|
SQLQuery qrInsert = getSession().createSQLQuery(sQuery.toString());
|
||||||
|
qrInsert.setParameter("VIGENCIATARIFAIDORIGEM", vigenciaTarifaOrigem.getVigenciatarifaId());
|
||||||
|
qrInsert.setParameter("VIGENCIATARIFAIDDESTINO", vigenciaTarifaDestino.getVigenciatarifaId());
|
||||||
|
qrInsert.setParameter("USUARIOID", UsuarioLogado.getUsuarioLogado().getUsuarioId());
|
||||||
|
|
||||||
|
if (empresa != null && empresa.getEmpresaId() != -1) {
|
||||||
|
qrInsert.setParameter("EMPRESA_ID", empresa.getEmpresaId());
|
||||||
|
}
|
||||||
|
qrInsert.executeUpdate();
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error(e.getMessage());
|
||||||
|
throw new BusinessException(e.getMessage(), e.getCause());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -5,6 +5,7 @@
|
||||||
package com.rjconsultores.ventaboletos.service;
|
package com.rjconsultores.ventaboletos.service;
|
||||||
|
|
||||||
import com.rjconsultores.ventaboletos.entidad.ClaseServicio;
|
import com.rjconsultores.ventaboletos.entidad.ClaseServicio;
|
||||||
|
import com.rjconsultores.ventaboletos.entidad.Empresa;
|
||||||
import com.rjconsultores.ventaboletos.entidad.Marca;
|
import com.rjconsultores.ventaboletos.entidad.Marca;
|
||||||
import com.rjconsultores.ventaboletos.entidad.Moneda;
|
import com.rjconsultores.ventaboletos.entidad.Moneda;
|
||||||
import com.rjconsultores.ventaboletos.entidad.Parada;
|
import com.rjconsultores.ventaboletos.entidad.Parada;
|
||||||
|
@ -13,6 +14,7 @@ import com.rjconsultores.ventaboletos.entidad.Ruta;
|
||||||
import com.rjconsultores.ventaboletos.entidad.TarifaEmbarcada;
|
import com.rjconsultores.ventaboletos.entidad.TarifaEmbarcada;
|
||||||
import com.rjconsultores.ventaboletos.entidad.Via;
|
import com.rjconsultores.ventaboletos.entidad.Via;
|
||||||
import com.rjconsultores.ventaboletos.entidad.VigenciaTarifa;
|
import com.rjconsultores.ventaboletos.entidad.VigenciaTarifa;
|
||||||
|
import com.rjconsultores.ventaboletos.exception.BusinessException;
|
||||||
|
|
||||||
public interface TarifaEmbarcadaService extends GenericService<TarifaEmbarcada, Integer> {
|
public interface TarifaEmbarcadaService extends GenericService<TarifaEmbarcada, Integer> {
|
||||||
|
|
||||||
|
@ -20,4 +22,6 @@ public interface TarifaEmbarcadaService extends GenericService<TarifaEmbarcada,
|
||||||
Parada destino, Ruta ruta, Via via, Boolean vende);
|
Parada destino, Ruta ruta, Via via, Boolean vende);
|
||||||
|
|
||||||
public Boolean podeAlterarTarifaMinima(TarifaEmbarcada tarifa, Marca marca, Parada origem,Parada destino, ClaseServicio claseServicio, Plaza plaza, Moneda moneda);
|
public Boolean podeAlterarTarifaMinima(TarifaEmbarcada tarifa, Marca marca, Parada origem,Parada destino, ClaseServicio claseServicio, Plaza plaza, Moneda moneda);
|
||||||
|
|
||||||
|
public void copiarTarifas(VigenciaTarifa vigenciaTarifaOrigem, VigenciaTarifa vigenciaTarifaDestino, Empresa empresa, boolean excluirTarifasDestino) throws BusinessException;
|
||||||
}
|
}
|
|
@ -15,6 +15,7 @@ import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import com.rjconsultores.ventaboletos.dao.TarifaEmbarcadaDAO;
|
import com.rjconsultores.ventaboletos.dao.TarifaEmbarcadaDAO;
|
||||||
import com.rjconsultores.ventaboletos.entidad.ClaseServicio;
|
import com.rjconsultores.ventaboletos.entidad.ClaseServicio;
|
||||||
|
import com.rjconsultores.ventaboletos.entidad.Empresa;
|
||||||
import com.rjconsultores.ventaboletos.entidad.Marca;
|
import com.rjconsultores.ventaboletos.entidad.Marca;
|
||||||
import com.rjconsultores.ventaboletos.entidad.Moneda;
|
import com.rjconsultores.ventaboletos.entidad.Moneda;
|
||||||
import com.rjconsultores.ventaboletos.entidad.Parada;
|
import com.rjconsultores.ventaboletos.entidad.Parada;
|
||||||
|
@ -25,6 +26,7 @@ import com.rjconsultores.ventaboletos.entidad.TarifaEmbarcadaHist;
|
||||||
import com.rjconsultores.ventaboletos.entidad.TarifaMinima;
|
import com.rjconsultores.ventaboletos.entidad.TarifaMinima;
|
||||||
import com.rjconsultores.ventaboletos.entidad.Via;
|
import com.rjconsultores.ventaboletos.entidad.Via;
|
||||||
import com.rjconsultores.ventaboletos.entidad.VigenciaTarifa;
|
import com.rjconsultores.ventaboletos.entidad.VigenciaTarifa;
|
||||||
|
import com.rjconsultores.ventaboletos.exception.BusinessException;
|
||||||
import com.rjconsultores.ventaboletos.service.TarifaEmbarcadaHistService;
|
import com.rjconsultores.ventaboletos.service.TarifaEmbarcadaHistService;
|
||||||
import com.rjconsultores.ventaboletos.service.TarifaEmbarcadaService;
|
import com.rjconsultores.ventaboletos.service.TarifaEmbarcadaService;
|
||||||
import com.rjconsultores.ventaboletos.service.TarifaMinimaService;
|
import com.rjconsultores.ventaboletos.service.TarifaMinimaService;
|
||||||
|
@ -157,4 +159,9 @@ public class TarifaEmbarcadaServiceImpl implements TarifaEmbarcadaService {
|
||||||
|
|
||||||
return podeAlterarTarifaMinima;
|
return podeAlterarTarifaMinima;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void copiarTarifas(VigenciaTarifa vigenciaTarifaOrigem, VigenciaTarifa vigenciaTarifaDestino, Empresa empresa, boolean excluirTarifasDestino) throws BusinessException {
|
||||||
|
tarifaEmbarcadaDAO.copiarTarifas(vigenciaTarifaOrigem, vigenciaTarifaDestino, empresa, excluirTarifasDestino);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue