fixes bug#16087
dev: qua: git-svn-id: http://desenvolvimento.rjconsultores.com.br/repositorio/sco/AdmVenta/Model/trunk/modelWeb@98211 d1611594-4594-4d17-8e1d-87c2c4800839master
parent
91fa00cd9b
commit
aa19940bd3
|
@ -0,0 +1,22 @@
|
|||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package com.rjconsultores.ventaboletos.dao;
|
||||
|
||||
import com.rjconsultores.ventaboletos.entidad.ClaseServicio;
|
||||
import com.rjconsultores.ventaboletos.entidad.Marca;
|
||||
import com.rjconsultores.ventaboletos.entidad.Moneda;
|
||||
import com.rjconsultores.ventaboletos.entidad.Parada;
|
||||
import com.rjconsultores.ventaboletos.entidad.Ruta;
|
||||
import com.rjconsultores.ventaboletos.entidad.TarifaEmbarcada;
|
||||
import com.rjconsultores.ventaboletos.entidad.Via;
|
||||
import com.rjconsultores.ventaboletos.entidad.VigenciaTarifa;
|
||||
|
||||
public interface TarifaEmbarcadaDAO extends GenericDAO<TarifaEmbarcada, Integer> {
|
||||
|
||||
public void excluirTodasTarifas(Moneda moneda, Marca marca, ClaseServicio claseServicio, VigenciaTarifa vigenciaTarifa, Parada origem,
|
||||
Parada destino, Ruta ruta, Via via, Boolean vende);
|
||||
|
||||
public void updateTarifa(TarifaEmbarcada t);
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package com.rjconsultores.ventaboletos.dao;
|
||||
|
||||
import com.rjconsultores.ventaboletos.entidad.TarifaEmbarcadaHist;
|
||||
|
||||
public interface TarifaEmbarcadaHistDAO extends GenericDAO<TarifaEmbarcadaHist, Integer> {
|
||||
}
|
|
@ -48,7 +48,7 @@ public interface TarifaOficialDAO extends GenericDAO<TarifaOficial, Integer> {
|
|||
* @param empresa Empresa
|
||||
* @param orgaoConcedente OrgaoConcedente
|
||||
*/
|
||||
public void copiarParaTarifa(VigenciaTarifa vigenciaTarifa, Integer usuarioId, Boolean calculaPegagio, Boolean calculaTarifa, Boolean calculaTaxaEmbarque, Boolean calculaSeguro, Boolean calculaTPP, Empresa empresa, OrgaoConcedente orgaoConcedente);
|
||||
public void copiarParaTarifa(VigenciaTarifa vigenciaTarifa, Integer usuarioId, Boolean calculaPegagio, Boolean calculaTarifa, Boolean calculaTaxaEmbarque, Boolean calculaSeguro, Boolean calculaTPP, Boolean calculaEmbarcada, Empresa empresa, OrgaoConcedente orgaoConcedente);
|
||||
|
||||
/**
|
||||
* See {@link TarifaOficialService#atualizarTaxaEmbarque(Integer, Integer)}
|
||||
|
|
|
@ -0,0 +1,103 @@
|
|||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package com.rjconsultores.ventaboletos.dao.hibernate;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.hibernate.Criteria;
|
||||
import org.hibernate.Query;
|
||||
import org.hibernate.Session;
|
||||
import org.hibernate.SessionFactory;
|
||||
import org.hibernate.criterion.Restrictions;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import com.rjconsultores.ventaboletos.dao.TarifaEmbarcadaDAO;
|
||||
import com.rjconsultores.ventaboletos.entidad.ClaseServicio;
|
||||
import com.rjconsultores.ventaboletos.entidad.Marca;
|
||||
import com.rjconsultores.ventaboletos.entidad.Moneda;
|
||||
import com.rjconsultores.ventaboletos.entidad.Parada;
|
||||
import com.rjconsultores.ventaboletos.entidad.Ruta;
|
||||
import com.rjconsultores.ventaboletos.entidad.TarifaEmbarcada;
|
||||
import com.rjconsultores.ventaboletos.entidad.Via;
|
||||
import com.rjconsultores.ventaboletos.entidad.VigenciaTarifa;
|
||||
|
||||
@Repository("tarifaEmbarcadaDAO")
|
||||
public class TarifaEmbarcadaHibernateDAO extends GenericHibernateDAO<TarifaEmbarcada, Integer> implements TarifaEmbarcadaDAO {
|
||||
|
||||
@Autowired
|
||||
public TarifaEmbarcadaHibernateDAO(@Qualifier("sessionFactory") SessionFactory factory) {
|
||||
setSessionFactory(factory);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public List<TarifaEmbarcada> obtenerTodos() {
|
||||
Criteria c = getSession().createCriteria(getPersistentClass());
|
||||
c.add(Restrictions.eq("activo", Boolean.TRUE));
|
||||
return c.list();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void excluirTodasTarifas(Moneda moneda, Marca marca, ClaseServicio claseServicio, VigenciaTarifa vigenciaTarifa, Parada origem,
|
||||
Parada destino, Ruta ruta, Via via, Boolean vende) {
|
||||
StringBuilder hql = new StringBuilder();
|
||||
hql.append(" update TarifaEmbarcada set activo = 0 where tarifaembarcadaId in (");
|
||||
hql.append(" select t.tarifaembarcadaId from TarifaEmbarcada t ");
|
||||
|
||||
if (vende != null) {
|
||||
hql.append(" inner join t.ruta.rutaCombinacionList AS rutaCombinacionList" );
|
||||
}
|
||||
|
||||
hql.append(" where 0 = 0 ");
|
||||
|
||||
if (moneda != null) {
|
||||
hql.append(" and t.moneda.monedaId = " + moneda.getMonedaId());
|
||||
}
|
||||
|
||||
if (marca != null) {
|
||||
hql.append(" and t.marca.marcaId = " + marca.getMarcaId());
|
||||
}
|
||||
|
||||
if (claseServicio != null) {
|
||||
hql.append(" and t.claseServicio.claseservicioId = " + claseServicio.getClaseservicioId());
|
||||
}
|
||||
|
||||
if (vigenciaTarifa != null) {
|
||||
hql.append(" and t.vigenciaTarifa.vigenciatarifaId = " + vigenciaTarifa.getVigenciatarifaId());
|
||||
}
|
||||
|
||||
if (origem != null) {
|
||||
hql.append(" and t.origen.paradaId = " + origem.getParadaId());
|
||||
}
|
||||
|
||||
if (destino != null) {
|
||||
hql.append(" and t.destino.paradaId = " + destino.getParadaId());
|
||||
}
|
||||
|
||||
if (ruta != null) {
|
||||
hql.append(" and t.ruta.rutaId = " + ruta.getRutaId());
|
||||
}
|
||||
|
||||
if (via != null) {
|
||||
hql.append(" and t.tramo.via.viaId = " + via.getViaId());
|
||||
}
|
||||
|
||||
if (vende != null) {
|
||||
hql.append(" and rutaCombinacionList.indventa = " + vende);
|
||||
}
|
||||
|
||||
hql.append(")");
|
||||
|
||||
Query sq = getSession().createQuery(hql.toString());
|
||||
sq.executeUpdate();
|
||||
}
|
||||
|
||||
public void updateTarifa(TarifaEmbarcada entity) {
|
||||
Session session = getSessionFactory().getCurrentSession();
|
||||
session.update(entity);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package com.rjconsultores.ventaboletos.dao.hibernate;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.hibernate.Criteria;
|
||||
import org.hibernate.SessionFactory;
|
||||
import org.hibernate.criterion.Restrictions;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import com.rjconsultores.ventaboletos.dao.TarifaEmbarcadaHistDAO;
|
||||
import com.rjconsultores.ventaboletos.entidad.TarifaEmbarcadaHist;
|
||||
|
||||
@Repository("tarifaEmbarcadaHistDAO")
|
||||
public class TarifaEmbarcadaHistHibernateDAO extends GenericHibernateDAO<TarifaEmbarcadaHist, Integer> implements TarifaEmbarcadaHistDAO {
|
||||
|
||||
@Autowired
|
||||
public TarifaEmbarcadaHistHibernateDAO(@Qualifier("sessionFactory") SessionFactory factory) {
|
||||
setSessionFactory(factory);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public List<TarifaEmbarcadaHist> obtenerTodos() {
|
||||
Criteria c = getSession().createCriteria(getPersistentClass());
|
||||
c.add(Restrictions.eq("activo", Boolean.TRUE));
|
||||
|
||||
return c.list();
|
||||
}
|
||||
}
|
|
@ -167,7 +167,7 @@ public class TarifaOficialHibernateDAO extends GenericHibernateDAO<TarifaOficial
|
|||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public void copiarParaTarifa(VigenciaTarifa vigenciaTarifa, Integer usuarioId, Boolean calculaPegagio, Boolean calculaTarifa, Boolean calculaTaxaEmbarque, Boolean calculaSeguro, Boolean calculaTPP, Empresa empresa, OrgaoConcedente orgaoConcedente) {
|
||||
public void copiarParaTarifa(VigenciaTarifa vigenciaTarifa, Integer usuarioId, Boolean calculaPegagio, Boolean calculaTarifa, Boolean calculaTaxaEmbarque, Boolean calculaSeguro, Boolean calculaTPP, Boolean calculaEmbarcada, Empresa empresa, OrgaoConcedente orgaoConcedente) {
|
||||
// Apago antes as tarifas que podem estar como activo =0
|
||||
apagarTarifasInativas(vigenciaTarifa, empresa, orgaoConcedente);
|
||||
|
||||
|
@ -182,8 +182,33 @@ public class TarifaOficialHibernateDAO extends GenericHibernateDAO<TarifaOficial
|
|||
querySQL = getSession().createSQLQuery(sqlBuilder.getSQLAtualizarTarifaPorTarifaOfical(dado, usuarioId, calculaPegagio, calculaTarifa, calculaTaxaEmbarque, calculaSeguro, calculaTPP));
|
||||
querySQL.executeUpdate();
|
||||
}
|
||||
|
||||
if (Boolean.TRUE.equals(calculaEmbarcada)) {
|
||||
copiarParaTarifaEmbarcada(vigenciaTarifa, usuarioId, calculaPegagio, calculaTarifa, calculaTaxaEmbarque, calculaSeguro, calculaTPP, calculaEmbarcada, empresa, orgaoConcedente);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public void copiarParaTarifaEmbarcada(VigenciaTarifa vigenciaTarifa, Integer usuarioId, Boolean calculaPegagio, Boolean calculaTarifa, Boolean calculaTaxaEmbarque, Boolean calculaSeguro, Boolean calculaTPP, Boolean calculaEmbarcada, Empresa empresa, OrgaoConcedente orgaoConcedente) {
|
||||
// Apago antes as tarifas embarcadas que podem estar como activo =0
|
||||
apagarTarifasEmbarcadasInativas(vigenciaTarifa, empresa, orgaoConcedente);
|
||||
|
||||
// Insiro as tarifas embarcadas que não existem
|
||||
SQLQuery querySQL = getSession().createSQLQuery(sqlBuilder.getSQLInserirTarifaEmbarcadaPelaTarifaOficial(vigenciaTarifa.getVigenciatarifaId(), usuarioId, empresa, orgaoConcedente));
|
||||
querySQL.executeUpdate();
|
||||
|
||||
// Atualizo o preço e o componente dos preços que já existem
|
||||
querySQL = getSession().createSQLQuery(sqlBuilder.getSQLSelecionarTarifaEmbarcadaPorTarifaOficalParaAtualizar(vigenciaTarifa.getVigenciatarifaId(), empresa, orgaoConcedente));
|
||||
querySQL.setResultTransformer(Transformers.ALIAS_TO_ENTITY_MAP);
|
||||
|
||||
List<Map<String, Object>> dados = querySQL.list();
|
||||
|
||||
for (Map<String, Object> dado : dados) {
|
||||
querySQL = getSession().createSQLQuery(sqlBuilder.getSQLAtualizarTarifaEmbarcadaPorTarifaOfical(dado, usuarioId, calculaPegagio, calculaTarifa, calculaTaxaEmbarque, calculaSeguro, calculaTPP));
|
||||
querySQL.executeUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void atualizarTaxaEmbarque(List<Ruta> lsRuta, Integer usuarioId, Integer orgaoConcedenteId, List<Integer> idsEmpresas) {
|
||||
|
||||
|
@ -457,4 +482,41 @@ public class TarifaOficialHibernateDAO extends GenericHibernateDAO<TarifaOficial
|
|||
|
||||
return (List<TarifaOficialVO>) qr.list();
|
||||
}
|
||||
|
||||
private void apagarTarifasEmbarcadasInativas(VigenciaTarifa vigenciaTarifa, Empresa empresa, OrgaoConcedente orgao) {
|
||||
StringBuilder sb = new StringBuilder("");
|
||||
sb.append("select ");
|
||||
sb.append(" tar.tarifaembarcadaId ");
|
||||
sb.append("from ");
|
||||
sb.append(" TarifaEmbarcada tar,TarifaOficial tao ");
|
||||
sb.append("where ");
|
||||
sb.append(" tar.activo=0 ");
|
||||
sb.append(" and tao.activo = 1 ");
|
||||
sb.append(" and tar.tramo=tao.tramo ");
|
||||
sb.append(" and tar.marca=tao.marca ");
|
||||
sb.append(" and tar.claseServicio =tao.claseServicio ");
|
||||
sb.append(" and tar.moneda=tao.moneda ");
|
||||
sb.append(" and tar.orgaoConcedente=tao.orgaoConcedente ");
|
||||
sb.append(" and tar.ruta=tao.ruta ");
|
||||
sb.append(" and tar.vigenciaTarifa.vigenciatarifaId = :vigenciaId ");
|
||||
|
||||
if (orgao != null) {
|
||||
sb.append(" and tar.orgaoConcedente = :orgao ");
|
||||
}
|
||||
if (empresa != null) {
|
||||
sb.append(" and tar.marca.empresa = :empresa ");
|
||||
}
|
||||
|
||||
Query query = getSession().createQuery("DELETE FROM TarifaEmbarcada WHERE activo = 0 and tarifaembarcadaId in (" + sb.toString() + ")");
|
||||
query.setParameter("vigenciaId", vigenciaTarifa.getVigenciatarifaId());
|
||||
if (orgao != null) {
|
||||
query.setParameter("orgao", orgao);
|
||||
}
|
||||
if (empresa != null) {
|
||||
query.setParameter("empresa", empresa);
|
||||
}
|
||||
|
||||
int qtd = query.executeUpdate();
|
||||
log.info("qtd Tarifa Embarcada apagada = " + qtd);
|
||||
}
|
||||
}
|
|
@ -119,4 +119,10 @@ public interface SQLBuilder {
|
|||
public String getSQLObterSequenciaNumOperacion();
|
||||
|
||||
public String getSQLBuscarDatosCaja(Date fechaDesde, Date fechaHasta, Boolean sembilhetesPacote);
|
||||
|
||||
public String getSQLInserirTarifaEmbarcadaPelaTarifaOficial(Integer vigenciaTarifaId, Integer usuarioId, Empresa empresa, OrgaoConcedente orgao);
|
||||
|
||||
public String getSQLSelecionarTarifaEmbarcadaPorTarifaOficalParaAtualizar(Integer vigenciaTarifaId, Empresa empresa, OrgaoConcedente orgao);
|
||||
|
||||
public String getSQLAtualizarTarifaEmbarcadaPorTarifaOfical(Map<String,Object> dados, Integer usuarioId, Boolean calculaPegagio, Boolean calculaTarifa, Boolean calculaTaxaEmbarque, Boolean calculaSeguro, Boolean calculaTPP);
|
||||
}
|
||||
|
|
|
@ -1287,4 +1287,137 @@ public class SQLBuilderOracle implements SQLBuilder {
|
|||
public String getSQLObterSequenciaNumOperacion() {
|
||||
return "select numeoperacion_seq.nextval from dual";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLInserirTarifaEmbarcadaPelaTarifaOficial(final Integer vigenciaTarifaId, final Integer usuarioId, Empresa empresa, OrgaoConcedente orgao) {
|
||||
StringBuilder sb = new StringBuilder("");
|
||||
sb.append(" insert ");
|
||||
sb.append(" into ");
|
||||
sb.append(" TARIFA_EMBARCADA ");
|
||||
sb.append(" ( TARIFAEMBARCADA_ID, PRECIO, PRECIOREDABIERTO, TRAMO_ID, ");
|
||||
sb.append(" MARCA_ID, CLASESERVICIO_ID, PRECIOORIGINAL, MONEDA_ID, ");
|
||||
sb.append(" VIGENCIATARIFA_ID, STATUSTARIFA, ACTIVO, FECMODIF, ");
|
||||
sb.append(" USUARIO_ID, IMPORTETAXAEMBARQUE, IMPORTEPEDAGIO, IMPORTEOUTROS, ");
|
||||
sb.append(" IMPORTESEGURO, IMPORTETPP, ORGAOCONCEDENTE_ID, RUTA_ID, ORIGEN_ID, DESTINO_ID ) ");
|
||||
sb.append(" select ");
|
||||
sb.append(" TARIFA_EMBARCADA_SEQ.nextval, ");
|
||||
sb.append(" tao.PRECIO , ");
|
||||
sb.append(" tao.PRECIOREDABIERTO , ");
|
||||
sb.append(" tao.TRAMO_ID , ");
|
||||
sb.append(" tao.MARCA_ID , ");
|
||||
sb.append(" tao.CLASESERVICIO_ID , ");
|
||||
sb.append(" tao.PRECIOORIGINAL , ");
|
||||
sb.append(" tao.MONEDA_ID , ");
|
||||
sb.append(" v.VIGENCIATARIFA_ID , ");
|
||||
sb.append(" tao.STATUSTARIFA , ");
|
||||
sb.append(" tao.ACTIVO , ");
|
||||
sb.append(" current_timestamp , ");
|
||||
sb.append(" ").append(usuarioId).append(", ");
|
||||
sb.append(" tao.IMPORTETAXAEMBARQUE , ");
|
||||
sb.append(" tao.IMPORTEPEDAGIO , ");
|
||||
sb.append(" tao.IMPORTEOUTROS , ");
|
||||
sb.append(" tao.IMPORTESEGURO , ");
|
||||
sb.append(" tao.IMPORTETPP , ");
|
||||
sb.append(" tao.ORGAOCONCEDENTE_ID , ");
|
||||
sb.append(" tao.RUTA_ID , ");
|
||||
sb.append(" tao.ORIGEN_ID , ");
|
||||
sb.append(" tao.DESTINO_ID ");
|
||||
sb.append(" from ");
|
||||
sb.append(" TARIFA_OFICIAL tao, ");
|
||||
sb.append(" VIGENCIA_TARIFA v, ");
|
||||
sb.append(" MARCA m ");
|
||||
sb.append(" where ");
|
||||
sb.append(" m.MARCA_ID=tao.MARCA_ID ");
|
||||
sb.append(" and tao.ACTIVO=1 ");
|
||||
sb.append(" and v.VIGENCIATARIFA_ID=").append(vigenciaTarifaId).append(" ");
|
||||
|
||||
if (orgao != null) {
|
||||
sb.append(" and tao.ORGAOCONCEDENTE_ID=").append(orgao.getOrgaoConcedenteId()).append(" ");
|
||||
}
|
||||
if (empresa != null) {
|
||||
sb.append(" and m.EMPRESA_ID=").append(empresa.getEmpresaId()).append(" ");
|
||||
}
|
||||
|
||||
sb.append(" and not (exists (select ");
|
||||
sb.append(" tar.TARIFAEMBARCADA_ID ");
|
||||
sb.append(" from ");
|
||||
sb.append(" TARIFA_EMBARCADA tar ");
|
||||
sb.append(" where ");
|
||||
sb.append(" tar.ACTIVO=1 ");
|
||||
sb.append(" and tar.TRAMO_ID=tao.TRAMO_ID ");
|
||||
sb.append(" and tar.MARCA_ID=tao.MARCA_ID ");
|
||||
sb.append(" and tar.CLASESERVICIO_ID=tao.CLASESERVICIO_ID ");
|
||||
sb.append(" and tar.MONEDA_ID=tao.MONEDA_ID ");
|
||||
sb.append(" and tar.ORGAOCONCEDENTE_ID=tao.ORGAOCONCEDENTE_ID ");
|
||||
sb.append(" and tar.RUTA_ID=tao.RUTA_ID ");
|
||||
sb.append(" and tar.VIGENCIATARIFA_ID=").append(vigenciaTarifaId).append("))");
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLSelecionarTarifaEmbarcadaPorTarifaOficalParaAtualizar(final Integer vigenciaTarifaId, Empresa empresa, OrgaoConcedente orgao) {
|
||||
StringBuilder sb = new StringBuilder("");
|
||||
|
||||
sb.append("SELECT tao.IMPORTEPEDAGIO AS \"taoimportepedagio\", ");
|
||||
sb.append(" tao.PRECIO AS \"taoprecio\", ");
|
||||
sb.append(" tao.PRECIOORIGINAL AS \"taopreciooriginal\", ");
|
||||
sb.append(" tao.IMPORTETAXAEMBARQUE AS \"taoimportetaxaembarque\", ");
|
||||
sb.append(" tao.IMPORTESEGURO AS \"taoimporteseguro\", ");
|
||||
sb.append(" tao.IMPORTETPP AS \"taoimportetpp\", ");
|
||||
sb.append(" tao.IMPORTEOUTROS AS \"taoimporteoutros\", ");
|
||||
sb.append(" ta.TARIFAEMBARCADA_ID AS \"tarifaId\" ");
|
||||
|
||||
sb.append("FROM TARIFA_OFICIAL tao " );
|
||||
sb.append("INNER JOIN TARIFA_EMBARCADA ta ON (tao.MARCA_ID = ta.MARCA_ID ");
|
||||
sb.append(" AND tao.CLASESERVICIO_ID = ta.CLASESERVICIO_ID ");
|
||||
sb.append(" AND tao.TRAMO_ID = ta.TRAMO_ID ");
|
||||
sb.append(" AND tao.MONEDA_ID = ta.MONEDA_ID ");
|
||||
sb.append(" AND tao.RUTA_ID = ta.RUTA_ID ");
|
||||
sb.append(" AND tao.ORGAOCONCEDENTE_ID = ta.ORGAOCONCEDENTE_ID ");
|
||||
sb.append(" )");
|
||||
sb.append("INNER JOIN MARCA mTa ON tao.MARCA_ID = mTa.MARCA_ID ");
|
||||
sb.append("INNER JOIN MARCA mTao ON ta.MARCA_ID = mTao.MARCA_ID ");
|
||||
|
||||
sb.append("WHERE ta.VIGENCIATARIFA_ID = ").append(vigenciaTarifaId);
|
||||
|
||||
if(orgao != null){
|
||||
sb.append(" AND tao.ORGAOCONCEDENTE_ID = ").append(orgao.getOrgaoConcedenteId());
|
||||
}
|
||||
if(empresa != null){
|
||||
sb.append(" AND mTa.EMPRESA_ID = ").append(empresa.getEmpresaId());
|
||||
sb.append(" AND mTao.EMPRESA_ID = ").append(empresa.getEmpresaId());
|
||||
}
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLAtualizarTarifaEmbarcadaPorTarifaOfical(Map<String,Object> dados, Integer usuarioId, Boolean calculaPegagio,
|
||||
Boolean calculaTarifa, Boolean calculaTaxaEmbarque, Boolean calculaSeguro, Boolean calculaTPP){
|
||||
|
||||
StringBuilder sb = new StringBuilder("");
|
||||
sb.append("UPDATE TARIFA_EMBARCADA SET ");
|
||||
|
||||
if(calculaPegagio){
|
||||
sb.append("IMPORTEPEDAGIO=").append(dados.get("taoimportepedagio")).append(",");
|
||||
}
|
||||
if(calculaTarifa){
|
||||
sb.append("PRECIO=").append(dados.get("taoprecio")).append(",PRECIOORIGINAL=").append(dados.get("taopreciooriginal")).append(",");
|
||||
}
|
||||
if(calculaTaxaEmbarque){
|
||||
sb.append("IMPORTETAXAEMBARQUE=").append(dados.get("taoimportetaxaembarque")).append(",");
|
||||
}
|
||||
if(calculaSeguro){
|
||||
sb.append("IMPORTESEGURO=").append(dados.get("taoimporteseguro")).append(",");
|
||||
}
|
||||
if(calculaTPP){
|
||||
sb.append("IMPORTETPP=").append(dados.get("taoimportetpp")).append(",");
|
||||
}
|
||||
sb.append("IMPORTEOUTROS=").append(dados.get("taoimporteoutros")).append(",");
|
||||
sb.append("FECMODIF= current_timestamp, USUARIO_ID=").append(usuarioId);
|
||||
sb.append(" WHERE TARIFAEMBARCADA_ID = ").append(dados.get("tarifaId"));
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,296 @@
|
|||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package com.rjconsultores.ventaboletos.entidad;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
|
||||
import javax.persistence.Basic;
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.JoinColumn;
|
||||
import javax.persistence.OneToOne;
|
||||
import javax.persistence.SequenceGenerator;
|
||||
import javax.persistence.Table;
|
||||
import javax.persistence.Temporal;
|
||||
import javax.persistence.TemporalType;
|
||||
|
||||
@Entity
|
||||
@SequenceGenerator(name = "TARIFA_EMBARCADA_SEQ", sequenceName = "TARIFA_EMBARCADA_SEQ", allocationSize = 1)
|
||||
@Table(name = "TARIFA_EMBARCADA")
|
||||
public class TarifaEmbarcada implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
@Id
|
||||
@Basic(optional = false)
|
||||
@GeneratedValue(strategy = GenerationType.AUTO, generator = "TARIFA_EMBARCADA_SEQ")
|
||||
@Column(name = "TARIFAEMBARCADA_ID")
|
||||
private Integer tarifaembarcadaId;
|
||||
@Column(name = "PRECIO")
|
||||
private BigDecimal precio;
|
||||
@Column(name = "IMPORTETAXAEMBARQUE")
|
||||
private BigDecimal importetaxaembarque;
|
||||
@Column(name = "IMPORTEPEDAGIO")
|
||||
private BigDecimal importepedagio;
|
||||
@Column(name = "IMPORTEOUTROS")
|
||||
private BigDecimal importeoutros;
|
||||
@Column(name = "IMPORTESEGURO")
|
||||
private BigDecimal importeseguro;
|
||||
@Column(name = "IMPORTETPP")
|
||||
private BigDecimal importeTPP;
|
||||
@Column(name = "PRECIOORIGINAL")
|
||||
private BigDecimal preciooriginal;
|
||||
@Column(name = "STATUSTARIFA")
|
||||
private String statustarifa;
|
||||
@Column(name = "ACTIVO")
|
||||
private Boolean activo;
|
||||
@Column(name = "FECMODIF")
|
||||
@Temporal(TemporalType.TIMESTAMP)
|
||||
private Date fecmodif;
|
||||
@Column(name = "USUARIO_ID")
|
||||
private Integer usuarioId;
|
||||
@OneToOne
|
||||
@JoinColumn(name = "TRAMO_ID")
|
||||
private Tramo tramo;
|
||||
@OneToOne
|
||||
@JoinColumn(name = "MARCA_ID")
|
||||
private Marca marca;
|
||||
@OneToOne
|
||||
@JoinColumn(name = "CLASESERVICIO_ID")
|
||||
private ClaseServicio claseServicio;
|
||||
@OneToOne
|
||||
@JoinColumn(name = "MONEDA_ID")
|
||||
private Moneda moneda;
|
||||
@OneToOne
|
||||
@JoinColumn(name = "VIGENCIATARIFA_ID")
|
||||
private VigenciaTarifa vigenciaTarifa;
|
||||
@Column(name = "PRECIOREDABIERTO")
|
||||
private BigDecimal precioredabierto;
|
||||
@OneToOne
|
||||
@JoinColumn(name = "ORIGEN_ID")
|
||||
private Parada origen;
|
||||
@OneToOne
|
||||
@JoinColumn(name = "DESTINO_ID")
|
||||
private Parada destino;
|
||||
@OneToOne
|
||||
@JoinColumn(name = "RUTA_ID")
|
||||
private Ruta ruta;
|
||||
@OneToOne
|
||||
@JoinColumn(name = "ORGAOCONCEDENTE_ID")
|
||||
private OrgaoConcedente orgaoConcedente;
|
||||
|
||||
public TarifaEmbarcada() {
|
||||
}
|
||||
|
||||
public OrgaoConcedente getOrgaoConcedente() {
|
||||
return orgaoConcedente;
|
||||
}
|
||||
|
||||
public BigDecimal getImporteTPP() {
|
||||
return importeTPP;
|
||||
}
|
||||
|
||||
public void setImporteTPP(BigDecimal importeTPP) {
|
||||
this.importeTPP = importeTPP;
|
||||
}
|
||||
|
||||
public void setOrgaoConcedente(OrgaoConcedente orgaoConcedente) {
|
||||
this.orgaoConcedente = orgaoConcedente;
|
||||
}
|
||||
|
||||
public Ruta getRuta() {
|
||||
return ruta;
|
||||
}
|
||||
|
||||
public void setRuta(Ruta ruta) {
|
||||
this.ruta = ruta;
|
||||
}
|
||||
public TarifaEmbarcada(Integer tarifaembarcadaId) {
|
||||
this.tarifaembarcadaId = tarifaembarcadaId;
|
||||
}
|
||||
|
||||
public Integer getTarifaembarcadaId() {
|
||||
return tarifaembarcadaId;
|
||||
}
|
||||
|
||||
public void setTarifaembarcadaId(Integer tarifaembarcadaId) {
|
||||
this.tarifaembarcadaId = tarifaembarcadaId;
|
||||
}
|
||||
|
||||
public BigDecimal getPrecio() {
|
||||
return precio;
|
||||
}
|
||||
|
||||
public void setPrecio(BigDecimal precio) {
|
||||
this.precio = precio;
|
||||
}
|
||||
|
||||
public BigDecimal getPreciooriginal() {
|
||||
return preciooriginal;
|
||||
}
|
||||
|
||||
public void setPreciooriginal(BigDecimal preciooriginal) {
|
||||
this.preciooriginal = preciooriginal;
|
||||
}
|
||||
|
||||
public String getStatustarifa() {
|
||||
return statustarifa;
|
||||
}
|
||||
|
||||
public void setStatustarifa(String statustarifa) {
|
||||
this.statustarifa = statustarifa;
|
||||
}
|
||||
|
||||
public Boolean getActivo() {
|
||||
return activo;
|
||||
}
|
||||
|
||||
public void setActivo(Boolean activo) {
|
||||
this.activo = activo;
|
||||
}
|
||||
|
||||
public Date getFecmodif() {
|
||||
return fecmodif;
|
||||
}
|
||||
|
||||
public void setFecmodif(Date fecmodif) {
|
||||
this.fecmodif = fecmodif;
|
||||
}
|
||||
|
||||
public Integer getUsuarioId() {
|
||||
return usuarioId;
|
||||
}
|
||||
|
||||
public void setUsuarioId(Integer usuarioId) {
|
||||
this.usuarioId = usuarioId;
|
||||
}
|
||||
|
||||
public ClaseServicio getClaseServicio() {
|
||||
return claseServicio;
|
||||
}
|
||||
|
||||
public void setClaseServicio(ClaseServicio claseServicio) {
|
||||
this.claseServicio = claseServicio;
|
||||
}
|
||||
|
||||
public Marca getMarca() {
|
||||
return marca;
|
||||
}
|
||||
|
||||
public void setMarca(Marca marca) {
|
||||
this.marca = marca;
|
||||
}
|
||||
|
||||
public Moneda getMoneda() {
|
||||
return moneda;
|
||||
}
|
||||
|
||||
public void setMoneda(Moneda moneda) {
|
||||
this.moneda = moneda;
|
||||
}
|
||||
|
||||
public Tramo getTramo() {
|
||||
return tramo;
|
||||
}
|
||||
|
||||
public void setTramo(Tramo tramo) {
|
||||
this.tramo = tramo;
|
||||
}
|
||||
|
||||
public VigenciaTarifa getVigenciaTarifa() {
|
||||
return vigenciaTarifa;
|
||||
}
|
||||
|
||||
public void setVigenciaTarifa(VigenciaTarifa vigenciaTarifa) {
|
||||
this.vigenciaTarifa = vigenciaTarifa;
|
||||
}
|
||||
|
||||
public BigDecimal getPrecioredabierto() {
|
||||
return precioredabierto;
|
||||
}
|
||||
|
||||
public void setPrecioredabierto(BigDecimal precioredabierto) {
|
||||
this.precioredabierto = precioredabierto;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public Parada getOrigen() {
|
||||
return origen;
|
||||
}
|
||||
|
||||
public void setOrigen(Parada origen) {
|
||||
this.origen = origen;
|
||||
}
|
||||
|
||||
public Parada getDestino() {
|
||||
return destino;
|
||||
}
|
||||
|
||||
public void setDestino(Parada destino) {
|
||||
this.destino = destino;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int hash = 0;
|
||||
hash += (tarifaembarcadaId != null ? tarifaembarcadaId.hashCode() : 0);
|
||||
return hash;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object object) {
|
||||
// TODO: Warning - this method won't work in the case the id fields are not set
|
||||
if (!(object instanceof TarifaEmbarcada)) {
|
||||
return false;
|
||||
}
|
||||
TarifaEmbarcada other = (TarifaEmbarcada) object;
|
||||
if ((this.tarifaembarcadaId == null && other.tarifaembarcadaId != null) || (this.tarifaembarcadaId != null && !this.tarifaembarcadaId.equals(other.tarifaembarcadaId))) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "com.rjconsultores.ventaboletos.entidad.TarifaEmbarcada[tarifaembarcadaId=" + tarifaembarcadaId + "]";
|
||||
}
|
||||
|
||||
public BigDecimal getImportetaxaembarque() {
|
||||
return importetaxaembarque;
|
||||
}
|
||||
|
||||
public void setImportetaxaembarque(BigDecimal importetaxaembarque) {
|
||||
this.importetaxaembarque = importetaxaembarque;
|
||||
}
|
||||
|
||||
public BigDecimal getImportepedagio() {
|
||||
return importepedagio;
|
||||
}
|
||||
|
||||
public void setImportepedagio(BigDecimal importepedagio) {
|
||||
this.importepedagio = importepedagio;
|
||||
}
|
||||
|
||||
public BigDecimal getImporteoutros() {
|
||||
return importeoutros;
|
||||
}
|
||||
|
||||
public void setImporteoutros(BigDecimal importeoutros) {
|
||||
this.importeoutros = importeoutros;
|
||||
}
|
||||
|
||||
public BigDecimal getImporteseguro() {
|
||||
return importeseguro;
|
||||
}
|
||||
|
||||
public void setImporteseguro(BigDecimal importeseguro) {
|
||||
this.importeseguro = importeseguro;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,179 @@
|
|||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package com.rjconsultores.ventaboletos.entidad;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
import javax.persistence.Basic;
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.JoinColumn;
|
||||
import javax.persistence.ManyToOne;
|
||||
import javax.persistence.SequenceGenerator;
|
||||
import javax.persistence.Table;
|
||||
import javax.persistence.Temporal;
|
||||
import javax.persistence.TemporalType;
|
||||
|
||||
@Entity
|
||||
@SequenceGenerator(name = "TARIFA_EMBARCADA_HIST_SEQ", sequenceName = "TARIFA_EMBARCADA_HIST_SEQ", allocationSize=1)
|
||||
@Table(name = "TARIFA_EMBARCADA_HIST")
|
||||
public class TarifaEmbarcadaHist implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
@Id
|
||||
@Basic(optional = false)
|
||||
@GeneratedValue(strategy = GenerationType.AUTO, generator = "TARIFA_EMBARCADA_HIST_SEQ")
|
||||
@Column(name = "TARIFAEMBARCADAHIST_ID")
|
||||
private Long tarifaembarcadahistId;
|
||||
@Column(name = "PRECIO")
|
||||
private BigDecimal precio;
|
||||
@Column(name = "PRECIOORIGINAL")
|
||||
private BigDecimal preciooriginal;
|
||||
@Column(name = "STATUSTARIFA")
|
||||
private String statustarifa;
|
||||
@Column(name = "ACTIVO")
|
||||
private Boolean activo;
|
||||
@Column(name = "FECMODIF")
|
||||
@Temporal(TemporalType.TIMESTAMP)
|
||||
private Date fecmodif;
|
||||
@Column(name = "USUARIO_ID")
|
||||
private Integer usuarioId;
|
||||
@JoinColumn(name = "VIGENCIATARIFA_ID", referencedColumnName = "VIGENCIATARIFA_ID")
|
||||
@ManyToOne
|
||||
private VigenciaTarifa vigenciaTarifa;
|
||||
@JoinColumn(name = "MONEDA_ID", referencedColumnName = "MONEDA_ID")
|
||||
@ManyToOne
|
||||
private Moneda moneda;
|
||||
@JoinColumn(name = "MARCA_ID", referencedColumnName = "MARCA_ID")
|
||||
@ManyToOne
|
||||
private Marca marca;
|
||||
@JoinColumn(name = "CLASESERVICIO_ID", referencedColumnName = "CLASESERVICIO_ID")
|
||||
@ManyToOne
|
||||
private ClaseServicio claseServicio;
|
||||
|
||||
public TarifaEmbarcadaHist() {
|
||||
}
|
||||
|
||||
public TarifaEmbarcadaHist(Long tarifaembarcadahistId) {
|
||||
this.tarifaembarcadahistId = tarifaembarcadahistId;
|
||||
}
|
||||
|
||||
public Long getTarifaembarcadahistId() {
|
||||
return tarifaembarcadahistId;
|
||||
}
|
||||
|
||||
public void setTarifaembarcadahistId(Long tarifaembarcadahistId) {
|
||||
this.tarifaembarcadahistId = tarifaembarcadahistId;
|
||||
}
|
||||
|
||||
public BigDecimal getPrecio() {
|
||||
return precio;
|
||||
}
|
||||
|
||||
public void setPrecio(BigDecimal precio) {
|
||||
this.precio = precio;
|
||||
}
|
||||
|
||||
public BigDecimal getPreciooriginal() {
|
||||
return preciooriginal;
|
||||
}
|
||||
|
||||
public void setPreciooriginal(BigDecimal preciooriginal) {
|
||||
this.preciooriginal = preciooriginal;
|
||||
}
|
||||
|
||||
public String getStatustarifa() {
|
||||
return statustarifa;
|
||||
}
|
||||
|
||||
public void setStatustarifa(String statustarifa) {
|
||||
this.statustarifa = statustarifa;
|
||||
}
|
||||
|
||||
public Boolean getActivo() {
|
||||
return activo;
|
||||
}
|
||||
|
||||
public void setActivo(Boolean activo) {
|
||||
this.activo = activo;
|
||||
}
|
||||
|
||||
public Date getFecmodif() {
|
||||
return fecmodif;
|
||||
}
|
||||
|
||||
public void setFecmodif(Date fecmodif) {
|
||||
this.fecmodif = fecmodif;
|
||||
}
|
||||
|
||||
public Integer getUsuarioId() {
|
||||
return usuarioId;
|
||||
}
|
||||
|
||||
public void setUsuarioId(Integer usuarioId) {
|
||||
this.usuarioId = usuarioId;
|
||||
}
|
||||
|
||||
public VigenciaTarifa getVigenciaTarifa() {
|
||||
return vigenciaTarifa;
|
||||
}
|
||||
|
||||
public void setVigenciaTarifa(VigenciaTarifa vigenciaTarifa) {
|
||||
this.vigenciaTarifa = vigenciaTarifa;
|
||||
}
|
||||
|
||||
public Moneda getMoneda() {
|
||||
return moneda;
|
||||
}
|
||||
|
||||
public void setMoneda(Moneda moneda) {
|
||||
this.moneda = moneda;
|
||||
}
|
||||
|
||||
public Marca getMarca() {
|
||||
return marca;
|
||||
}
|
||||
|
||||
public void setMarca(Marca marca) {
|
||||
this.marca = marca;
|
||||
}
|
||||
|
||||
public ClaseServicio getClaseServicio() {
|
||||
return claseServicio;
|
||||
}
|
||||
|
||||
public void setClaseServicio(ClaseServicio claseServicio) {
|
||||
this.claseServicio = claseServicio;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int hash = 0;
|
||||
hash += (tarifaembarcadahistId != null ? tarifaembarcadahistId.hashCode() : 0);
|
||||
return hash;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object object) {
|
||||
// TODO: Warning - this method won't work in the case the id fields are not set
|
||||
if (!(object instanceof TarifaEmbarcadaHist)) {
|
||||
return false;
|
||||
}
|
||||
TarifaEmbarcadaHist other = (TarifaEmbarcadaHist) object;
|
||||
if ((this.tarifaembarcadahistId == null && other.tarifaembarcadahistId != null) || (this.tarifaembarcadahistId != null && !this.tarifaembarcadahistId.equals(other.tarifaembarcadahistId))) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "com.rjconsultores.ventaboletos.entidad.TarifaEmbarcadaHist[tarifaembarcadahistId=" + tarifaembarcadahistId + "]";
|
||||
}
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package com.rjconsultores.ventaboletos.service;
|
||||
|
||||
import com.rjconsultores.ventaboletos.entidad.TarifaEmbarcadaHist;
|
||||
|
||||
public interface TarifaEmbarcadaHistService extends GenericService<TarifaEmbarcadaHist, Integer> {
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package com.rjconsultores.ventaboletos.service;
|
||||
|
||||
import com.rjconsultores.ventaboletos.entidad.ClaseServicio;
|
||||
import com.rjconsultores.ventaboletos.entidad.Marca;
|
||||
import com.rjconsultores.ventaboletos.entidad.Moneda;
|
||||
import com.rjconsultores.ventaboletos.entidad.Parada;
|
||||
import com.rjconsultores.ventaboletos.entidad.Plaza;
|
||||
import com.rjconsultores.ventaboletos.entidad.Ruta;
|
||||
import com.rjconsultores.ventaboletos.entidad.TarifaEmbarcada;
|
||||
import com.rjconsultores.ventaboletos.entidad.Via;
|
||||
import com.rjconsultores.ventaboletos.entidad.VigenciaTarifa;
|
||||
|
||||
public interface TarifaEmbarcadaService extends GenericService<TarifaEmbarcada, Integer> {
|
||||
|
||||
public void excluirTodasTarifas(Moneda moneda, Marca marca, ClaseServicio claseServicio, VigenciaTarifa vigenciaTarifa, Parada origem,
|
||||
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);
|
||||
}
|
|
@ -75,7 +75,7 @@ public interface TarifaOficialService {
|
|||
*
|
||||
* @param vigenciaTarifa
|
||||
*/
|
||||
public void copiarParaTarifa(VigenciaTarifa vigenciaTarifa, Boolean calculaPegagio, Boolean calculaTarifa, Boolean calculaTaxaEmbarque, Boolean calculaSeguro, Boolean calculaTPP, Empresa empresa, OrgaoConcedente orgaoConcedente);
|
||||
public void copiarParaTarifa(VigenciaTarifa vigenciaTarifa, Boolean calculaPegagio, Boolean calculaTarifa, Boolean calculaTaxaEmbarque, Boolean calculaSeguro, Boolean calculaTPP, Boolean calculaEmbarcada, Empresa empresa, OrgaoConcedente orgaoConcedente);
|
||||
|
||||
/**
|
||||
* Atualiza a taxa de embarque da entidade TarifaOficial.<br/>
|
||||
|
|
|
@ -0,0 +1,59 @@
|
|||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package com.rjconsultores.ventaboletos.service.impl;
|
||||
|
||||
import java.util.Calendar;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import com.rjconsultores.ventaboletos.dao.TarifaEmbarcadaHistDAO;
|
||||
import com.rjconsultores.ventaboletos.entidad.TarifaEmbarcadaHist;
|
||||
import com.rjconsultores.ventaboletos.service.TarifaEmbarcadaHistService;
|
||||
import com.rjconsultores.ventaboletos.utilerias.UsuarioLogado;
|
||||
|
||||
@Service("tarifaEmbarcadaHistService")
|
||||
public class TarifaEmbarcadaHistServiceImpl implements TarifaEmbarcadaHistService {
|
||||
|
||||
@Autowired
|
||||
private TarifaEmbarcadaHistDAO tarifaEmbarcadaHistDAO;
|
||||
|
||||
public List<TarifaEmbarcadaHist> obtenerTodos() {
|
||||
return tarifaEmbarcadaHistDAO.obtenerTodos();
|
||||
}
|
||||
|
||||
public TarifaEmbarcadaHist obtenerID(Integer id) {
|
||||
return tarifaEmbarcadaHistDAO.obtenerID(id);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public TarifaEmbarcadaHist suscribir(TarifaEmbarcadaHist entidad) {
|
||||
entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId());
|
||||
entidad.setFecmodif(Calendar.getInstance().getTime());
|
||||
entidad.setActivo(Boolean.TRUE);
|
||||
|
||||
return tarifaEmbarcadaHistDAO.suscribir(entidad);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public TarifaEmbarcadaHist actualizacion(TarifaEmbarcadaHist entidad) {
|
||||
entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId());
|
||||
entidad.setFecmodif(Calendar.getInstance().getTime());
|
||||
entidad.setActivo(Boolean.TRUE);
|
||||
|
||||
return tarifaEmbarcadaHistDAO.actualizacion(entidad);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void borrar(TarifaEmbarcadaHist entidad) {
|
||||
entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId());
|
||||
entidad.setFecmodif(Calendar.getInstance().getTime());
|
||||
entidad.setActivo(Boolean.FALSE);
|
||||
|
||||
tarifaEmbarcadaHistDAO.borrar(entidad);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,160 @@
|
|||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package com.rjconsultores.ventaboletos.service.impl;
|
||||
|
||||
import java.math.RoundingMode;
|
||||
import java.util.Calendar;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import com.rjconsultores.ventaboletos.dao.TarifaEmbarcadaDAO;
|
||||
import com.rjconsultores.ventaboletos.entidad.ClaseServicio;
|
||||
import com.rjconsultores.ventaboletos.entidad.Marca;
|
||||
import com.rjconsultores.ventaboletos.entidad.Moneda;
|
||||
import com.rjconsultores.ventaboletos.entidad.Parada;
|
||||
import com.rjconsultores.ventaboletos.entidad.Plaza;
|
||||
import com.rjconsultores.ventaboletos.entidad.Ruta;
|
||||
import com.rjconsultores.ventaboletos.entidad.TarifaEmbarcada;
|
||||
import com.rjconsultores.ventaboletos.entidad.TarifaEmbarcadaHist;
|
||||
import com.rjconsultores.ventaboletos.entidad.TarifaMinima;
|
||||
import com.rjconsultores.ventaboletos.entidad.Via;
|
||||
import com.rjconsultores.ventaboletos.entidad.VigenciaTarifa;
|
||||
import com.rjconsultores.ventaboletos.service.TarifaEmbarcadaHistService;
|
||||
import com.rjconsultores.ventaboletos.service.TarifaEmbarcadaService;
|
||||
import com.rjconsultores.ventaboletos.service.TarifaMinimaService;
|
||||
import com.rjconsultores.ventaboletos.utilerias.UsuarioLogado;
|
||||
|
||||
@Service("tarifaEmbarcadaService")
|
||||
public class TarifaEmbarcadaServiceImpl implements TarifaEmbarcadaService {
|
||||
|
||||
private static Logger log = Logger.getLogger(TarifaEmbarcadaService.class);
|
||||
|
||||
@Autowired
|
||||
private TarifaEmbarcadaDAO tarifaEmbarcadaDAO;
|
||||
|
||||
@Autowired
|
||||
private TarifaEmbarcadaHistService tarifaEmbarcadaHistService;
|
||||
|
||||
@Autowired
|
||||
private TarifaMinimaService tarifaMinimaService;
|
||||
|
||||
public List<TarifaEmbarcada> obtenerTodos() {
|
||||
return tarifaEmbarcadaDAO.obtenerTodos();
|
||||
}
|
||||
|
||||
@Transactional(readOnly = true)
|
||||
public TarifaEmbarcada obtenerID(Integer id) {
|
||||
return tarifaEmbarcadaDAO.obtenerID(id);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public TarifaEmbarcada suscribir(TarifaEmbarcada entidad) {
|
||||
entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId());
|
||||
entidad.setFecmodif(Calendar.getInstance().getTime());
|
||||
entidad.setActivo(Boolean.TRUE);
|
||||
if (entidad.getPrecio() != null) {
|
||||
entidad.setPrecio(entidad.getPrecio().setScale(2, RoundingMode.HALF_UP));
|
||||
}
|
||||
if (entidad.getPreciooriginal() != null) {
|
||||
entidad.setPreciooriginal(entidad.getPreciooriginal().setScale(2, RoundingMode.HALF_UP));
|
||||
}
|
||||
if (entidad.getPrecioredabierto() != null) {
|
||||
entidad.setPrecioredabierto(entidad.getPrecioredabierto().setScale(2, RoundingMode.HALF_UP));
|
||||
}
|
||||
cadastrarTarifaEmbarcadaHistorico(entidad);
|
||||
|
||||
return tarifaEmbarcadaDAO.suscribir(entidad);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public TarifaEmbarcada actualizacion(TarifaEmbarcada entidad) {
|
||||
entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId());
|
||||
entidad.setFecmodif(Calendar.getInstance().getTime());
|
||||
entidad.setActivo(Boolean.TRUE);
|
||||
if (entidad.getPrecio() != null) {
|
||||
entidad.setPrecio(entidad.getPrecio().setScale(2, RoundingMode.HALF_UP));
|
||||
}
|
||||
if (entidad.getPreciooriginal() != null) {
|
||||
entidad.setPreciooriginal(entidad.getPreciooriginal().setScale(2, RoundingMode.HALF_UP));
|
||||
}
|
||||
if (entidad.getPrecioredabierto() != null) {
|
||||
entidad.setPrecioredabierto(entidad.getPrecioredabierto().setScale(2, RoundingMode.HALF_UP));
|
||||
}
|
||||
|
||||
|
||||
cadastrarTarifaEmbarcadaHistorico(entidad);
|
||||
|
||||
tarifaEmbarcadaDAO.updateTarifa(entidad);
|
||||
|
||||
return entidad;
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void borrar(TarifaEmbarcada entidad) {
|
||||
entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId());
|
||||
entidad.setFecmodif(Calendar.getInstance().getTime());
|
||||
entidad.setActivo(Boolean.FALSE);
|
||||
|
||||
cadastrarTarifaEmbarcadaHistorico(entidad);
|
||||
|
||||
tarifaEmbarcadaDAO.actualizacion(entidad);
|
||||
}
|
||||
|
||||
private void cadastrarTarifaEmbarcadaHistorico(TarifaEmbarcada entidad) {
|
||||
TarifaEmbarcadaHist th = new TarifaEmbarcadaHist();
|
||||
th.setActivo(entidad.getActivo());
|
||||
th.setClaseServicio(entidad.getClaseServicio());
|
||||
th.setFecmodif(entidad.getFecmodif());
|
||||
th.setMarca(entidad.getMarca());
|
||||
th.setMoneda(entidad.getMoneda());
|
||||
th.setPrecio(entidad.getPrecio());
|
||||
th.setPreciooriginal(entidad.getPreciooriginal());
|
||||
th.setStatustarifa(entidad.getStatustarifa());
|
||||
th.setUsuarioId(entidad.getUsuarioId());
|
||||
th.setVigenciaTarifa(entidad.getVigenciaTarifa());
|
||||
|
||||
th = tarifaEmbarcadaHistService.suscribir(th);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void excluirTodasTarifas(Moneda moneda, Marca marca, ClaseServicio claseServicio, VigenciaTarifa vigenciaTarifa, Parada origem, Parada destino, Ruta ruta, Via via, Boolean vende) {
|
||||
tarifaEmbarcadaDAO.excluirTodasTarifas(moneda, marca, claseServicio, vigenciaTarifa, origem, destino, ruta, via, vende);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean podeAlterarTarifaMinima(TarifaEmbarcada tarifa, Marca marca, Parada origem,
|
||||
Parada destino, ClaseServicio claseServicio, Plaza plaza, Moneda moneda) {
|
||||
|
||||
Boolean podeAlterarTarifaMinima = Boolean.TRUE;
|
||||
|
||||
List<TarifaMinima> lsTarifaMinima = tarifaMinimaService.pesquisarEspecifico(marca, origem, destino, claseServicio, moneda);
|
||||
|
||||
if (lsTarifaMinima.isEmpty()) {
|
||||
lsTarifaMinima = tarifaMinimaService.pesquisarOrigemDestinoTodos(marca, origem, destino, claseServicio, moneda);
|
||||
}
|
||||
|
||||
log.debug("Moneda : " + moneda.getDescmoneda());
|
||||
log.debug("Preço : " + tarifa.getPrecio());
|
||||
|
||||
for (TarifaMinima tm : lsTarifaMinima) {
|
||||
if (tarifa.getPrecio().compareTo(tm.getImportetarifa()) == -1) {
|
||||
podeAlterarTarifaMinima = Boolean.FALSE;
|
||||
log.debug("Tarifa Minima ID: " + tm.getTarifaminimaId());
|
||||
log.debug("Tarifa Minima Origen : " + tm.getOrigem().getDescparada());
|
||||
log.debug("Tarifa Minima Destino: " + tm.getDestino().getDescparada());
|
||||
log.debug("Tarifa Minima Marca : " + tm.getMarca().getDescmarca());
|
||||
log.debug("Tarifa Minima Clase : " + tm.getClaseServicio().getDescclase());
|
||||
log.debug("Tarifa Minima Moneda : " + tm.getMoneda().getDescmoneda());
|
||||
log.debug("Tarifa Minima : " + tm.getImportetarifa() + " Valor Alterado: " + tarifa.getPrecio());
|
||||
}
|
||||
}
|
||||
|
||||
return podeAlterarTarifaMinima;
|
||||
}
|
||||
}
|
|
@ -58,9 +58,9 @@ public class TarifaOficialServiceImpl implements TarifaOficialService {
|
|||
|
||||
@Override
|
||||
@Transactional
|
||||
public void copiarParaTarifa(VigenciaTarifa vigenciaTarifa, Boolean calculaPegagio, Boolean calculaTarifa, Boolean calculaTaxaEmbarque, Boolean calculaSeguro, Boolean calculaTPP,Empresa empresa, OrgaoConcedente orgaoConcedente) {
|
||||
public void copiarParaTarifa(VigenciaTarifa vigenciaTarifa, Boolean calculaPegagio, Boolean calculaTarifa, Boolean calculaTaxaEmbarque, Boolean calculaSeguro, Boolean calculaTPP, Boolean calculaEmbarcada, Empresa empresa, OrgaoConcedente orgaoConcedente) {
|
||||
tarifaOficialDAO.copiarParaTarifa(vigenciaTarifa, UsuarioLogado.getUsuarioLogado().getUsuarioId(),
|
||||
calculaPegagio, calculaTarifa, calculaTaxaEmbarque, calculaSeguro, calculaTPP, empresa, orgaoConcedente);
|
||||
calculaPegagio, calculaTarifa, calculaTaxaEmbarque, calculaSeguro, calculaTPP, calculaEmbarcada, empresa, orgaoConcedente);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in New Issue