git-svn-id: http://desenvolvimento.rjconsultores.com.br/repositorio/sco/AdmVenta/Model/trunk/modelWeb@20781 d1611594-4594-4d17-8e1d-87c2c4800839
parent
27ff85a7c5
commit
9d0b54f20e
|
@ -0,0 +1,13 @@
|
||||||
|
package com.rjconsultores.ventaboletos.dao;
|
||||||
|
|
||||||
|
import com.rjconsultores.ventaboletos.entidad.SeguroTarifa;
|
||||||
|
|
||||||
|
public interface SeguroTarifaDAO {
|
||||||
|
/**
|
||||||
|
* See {@link SeguroTarifa#atualizarSeguroPorTarifa(Integer, Integer, Integer)}
|
||||||
|
* @param rutaId
|
||||||
|
* @param orgaoId
|
||||||
|
* @param usuarioId
|
||||||
|
*/
|
||||||
|
public void atualizarSeguroPorTarifa(Integer rutaId, Integer orgaoId,Integer usuarioId);
|
||||||
|
}
|
|
@ -29,4 +29,12 @@ public interface TarifaOficialDAO {
|
||||||
* @param usuarioId TODO
|
* @param usuarioId TODO
|
||||||
*/
|
*/
|
||||||
public void copiarParaTarifa(VigenciaTarifa vigenciaTarifa, Integer usuarioId);
|
public void copiarParaTarifa(VigenciaTarifa vigenciaTarifa, Integer usuarioId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* See {@link TarifaOficialService#atualizarTaxaEmbarque(Integer, Integer)}
|
||||||
|
* @param rutaId
|
||||||
|
* @param usuarioId TODO
|
||||||
|
* @param orgaoConcedenteId TODO
|
||||||
|
*/
|
||||||
|
public void atualizarTaxaEmbarque(Integer rutaId, Integer usuarioId, Integer orgaoConcedenteId);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,12 +0,0 @@
|
||||||
package com.rjconsultores.ventaboletos.dao;
|
|
||||||
|
|
||||||
|
|
||||||
public interface TaxaEmbarqueDAO {
|
|
||||||
/**
|
|
||||||
* See {@link TaxaEmbarqueServic#atualizarTaxaEmbarque(Integer, Integer, Integer)}
|
|
||||||
* @param rutaId
|
|
||||||
* @param usuarioId TODO
|
|
||||||
* @param orgaoConcedenteId TODO
|
|
||||||
*/
|
|
||||||
public void atualizarTaxaEmbarque(Integer rutaId, Integer usuarioId, Integer orgaoConcedenteId);
|
|
||||||
}
|
|
|
@ -0,0 +1,30 @@
|
||||||
|
package com.rjconsultores.ventaboletos.dao.hibernate;
|
||||||
|
|
||||||
|
import org.hibernate.SQLQuery;
|
||||||
|
import org.hibernate.SessionFactory;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.annotation.Qualifier;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
import com.rjconsultores.ventaboletos.dao.SeguroTarifaDAO;
|
||||||
|
import com.rjconsultores.ventaboletos.dao.sqlbuilder.SQLBuilder;
|
||||||
|
import com.rjconsultores.ventaboletos.entidad.SeguroTarifa;
|
||||||
|
|
||||||
|
@Repository("seguroTarifaDAO")
|
||||||
|
public class SeguroTarifaHibernateDAO extends GenericHibernateDAO<SeguroTarifa, Integer> implements SeguroTarifaDAO {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SQLBuilder sqlBuilder;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
public SeguroTarifaHibernateDAO(@Qualifier("sessionFactory") SessionFactory factory) {
|
||||||
|
setSessionFactory(factory);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void atualizarSeguroPorTarifa(Integer rutaId, Integer orgaoId, Integer usuarioId) {
|
||||||
|
SQLQuery query = getSession().createSQLQuery(sqlBuilder.getSQLAtualizarSeguroPorTarifa(rutaId, usuarioId, orgaoId));
|
||||||
|
query.executeUpdate();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -1,6 +1,7 @@
|
||||||
package com.rjconsultores.ventaboletos.dao.hibernate;
|
package com.rjconsultores.ventaboletos.dao.hibernate;
|
||||||
|
|
||||||
import org.hibernate.Query;
|
import org.hibernate.Query;
|
||||||
|
import org.hibernate.SQLQuery;
|
||||||
import org.hibernate.SessionFactory;
|
import org.hibernate.SessionFactory;
|
||||||
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;
|
||||||
|
@ -102,7 +103,6 @@ public class TarifaOficialHibernateDAO extends GenericHibernateDAO<TarifaOficial
|
||||||
sb.append(" to.activo =1 ");
|
sb.append(" to.activo =1 ");
|
||||||
sb.append(" and vt.vigenciatarifaId = :vigenciaId ");
|
sb.append(" and vt.vigenciatarifaId = :vigenciaId ");
|
||||||
|
|
||||||
|
|
||||||
Query query = getSession().createQuery("DELETE FROM Tarifa t where t.vigenciaTarifa = :vigencia");
|
Query query = getSession().createQuery("DELETE FROM Tarifa t where t.vigenciaTarifa = :vigencia");
|
||||||
query.setParameter("vigencia", vigenciaTarifa);
|
query.setParameter("vigencia", vigenciaTarifa);
|
||||||
query.executeUpdate();
|
query.executeUpdate();
|
||||||
|
@ -113,4 +113,19 @@ public class TarifaOficialHibernateDAO extends GenericHibernateDAO<TarifaOficial
|
||||||
query.executeUpdate();
|
query.executeUpdate();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void atualizarTaxaEmbarque(Integer rutaId, Integer usuarioId, Integer orgaoConcedenteId) {
|
||||||
|
// Atualizo a taxa de embarque de acordo a parada e km
|
||||||
|
SQLQuery query = getSession().createSQLQuery(sqlBuilder.getAtualizarTaxaEmbarquePorKmParada(rutaId, usuarioId, orgaoConcedenteId));
|
||||||
|
query.executeUpdate();
|
||||||
|
|
||||||
|
// Atualizo a taxa de embarque de acordo a km do orgao
|
||||||
|
query = getSession().createSQLQuery(sqlBuilder.getSQLAtualizarTaxaEmbarquePorKmOrgao(rutaId, usuarioId, orgaoConcedenteId));
|
||||||
|
query.executeUpdate();
|
||||||
|
|
||||||
|
// Atualizo a taxa de embarque de acordo a parada e valor fixo
|
||||||
|
query = getSession().createSQLQuery(sqlBuilder.getSQLAtualizarTaxaEmbarquePorParadaFixo(rutaId, usuarioId, orgaoConcedenteId));
|
||||||
|
query.executeUpdate();
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -1,38 +0,0 @@
|
||||||
package com.rjconsultores.ventaboletos.dao.hibernate;
|
|
||||||
|
|
||||||
import org.hibernate.SQLQuery;
|
|
||||||
import org.hibernate.SessionFactory;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.beans.factory.annotation.Qualifier;
|
|
||||||
import org.springframework.stereotype.Repository;
|
|
||||||
|
|
||||||
import com.rjconsultores.ventaboletos.dao.TaxaEmbarqueDAO;
|
|
||||||
import com.rjconsultores.ventaboletos.dao.sqlbuilder.SQLBuilder;
|
|
||||||
|
|
||||||
@Repository("taxaEmbarqueDAO")
|
|
||||||
public class TaxaEmbarqueHibernateDAO extends GenericHibernateDAO<Object, Integer> implements TaxaEmbarqueDAO {
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private SQLBuilder sqlBuilder;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
public TaxaEmbarqueHibernateDAO(@Qualifier("sessionFactory") SessionFactory factory) {
|
|
||||||
setSessionFactory(factory);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void atualizarTaxaEmbarque(Integer rutaId, Integer usuarioId, Integer orgaoConcedenteId) {
|
|
||||||
// Atualizo a taxa de embarque de acordo a parada e km
|
|
||||||
SQLQuery query = getSession().createSQLQuery(sqlBuilder.getAtualizarTaxaEmbarquePorKmParada(rutaId, usuarioId, orgaoConcedenteId));
|
|
||||||
query.executeUpdate();
|
|
||||||
|
|
||||||
// Atualizo a taxa de embarque de acordo a km do orgao
|
|
||||||
query = getSession().createSQLQuery(sqlBuilder.getSQLAtualizarTaxaEmbarquePorKmOrgao(rutaId, usuarioId, orgaoConcedenteId));
|
|
||||||
query.executeUpdate();
|
|
||||||
|
|
||||||
// Atualizo a taxa de embarque de acordo a parada e valor fixo
|
|
||||||
query = getSession().createSQLQuery(sqlBuilder.getSQLAtualizarTaxaEmbarquePorParadaFixo(rutaId, usuarioId, orgaoConcedenteId));
|
|
||||||
query.executeUpdate();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -26,5 +26,7 @@ public interface SQLBuilder {
|
||||||
|
|
||||||
public String getSQLAtualizarSeguroPorKm(Integer rutaId, Integer usuarioId, Integer orgaoConcedenteId);
|
public String getSQLAtualizarSeguroPorKm(Integer rutaId, Integer usuarioId, Integer orgaoConcedenteId);
|
||||||
|
|
||||||
|
public String getSQLAtualizarSeguroPorTarifa(Integer rutaId, Integer usuarioId, Integer orgaoConcedenteId);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -291,7 +291,7 @@ public class SQLBuilderOracle implements SQLBuilder {
|
||||||
sb.append(" from ");
|
sb.append(" from ");
|
||||||
sb.append(" seguro_km sk1 ");
|
sb.append(" seguro_km sk1 ");
|
||||||
sb.append(" where ");
|
sb.append(" where ");
|
||||||
sb.append(" sk1.KMATE >= t.CANTKMREAL and sk1.activo = 1 ");
|
sb.append(" sk1.KMATE >= t.CANTKMREAL and sk1.activo = 1 and tao.ORGAOCONCEDENTE_ID = sk1.ORGAOCONCEDENTE_ID ");
|
||||||
sb.append(" ) ");
|
sb.append(" ) ");
|
||||||
sb.append(" and tao.marca_id = tarifa_oficial.marca_id ");
|
sb.append(" and tao.marca_id = tarifa_oficial.marca_id ");
|
||||||
sb.append(" and tao.orgaoconcedente_id = tarifa_oficial.orgaoconcedente_id ");
|
sb.append(" and tao.orgaoconcedente_id = tarifa_oficial.orgaoconcedente_id ");
|
||||||
|
@ -314,4 +314,44 @@ public class SQLBuilderOracle implements SQLBuilder {
|
||||||
return sb.toString();
|
return sb.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getSQLAtualizarSeguroPorTarifa(Integer rutaId, Integer usuarioId, Integer orgaoConcedenteId) {
|
||||||
|
StringBuilder sb = new StringBuilder("");
|
||||||
|
sb.append("update tarifa_oficial set IMPORTESEGURO = ");
|
||||||
|
sb.append("( ");
|
||||||
|
sb.append("select ");
|
||||||
|
sb.append(" st.VALORTAXA ");
|
||||||
|
sb.append("from ");
|
||||||
|
sb.append(" tarifa_oficial tao ");
|
||||||
|
sb.append(" inner join seguro_tarifa st on st.VALORTARIFAATE >= tao.precio and st.activo = 1 and tao.ORGAOCONCEDENTE_ID = st.ORGAOCONCEDENTE_ID ");
|
||||||
|
sb.append("where ");
|
||||||
|
sb.append(" st.VALORTARIFAATE= ");
|
||||||
|
sb.append(" (select min(st1.VALORTARIFAATE) ");
|
||||||
|
sb.append(" from ");
|
||||||
|
sb.append(" seguro_tarifa st1 ");
|
||||||
|
sb.append(" where ");
|
||||||
|
sb.append(" st1.VALORTARIFAATE >= tao.precio and st1.activo = 1 and tao.ORGAOCONCEDENTE_ID = st1.ORGAOCONCEDENTE_ID ");
|
||||||
|
sb.append(" ) ");
|
||||||
|
sb.append(" and tao.marca_id = tarifa_oficial.marca_id ");
|
||||||
|
sb.append(" and tao.orgaoconcedente_id = tarifa_oficial.orgaoconcedente_id ");
|
||||||
|
sb.append(" and tao.claseservicio_id=tarifa_oficial.claseservicio_id ");
|
||||||
|
sb.append(" and tao.moneda_id = tarifa_oficial.moneda_id ");
|
||||||
|
sb.append(" and tao.ruta_id = tarifa_oficial.ruta_id ");
|
||||||
|
sb.append(" and tao.tramo_id = tarifa_oficial.tramo_id ");
|
||||||
|
sb.append(") ");
|
||||||
|
sb.append(", usuario_id = ").append(usuarioId).append(",fecmodif = sysdate ");
|
||||||
|
sb.append(" ");
|
||||||
|
sb.append("where ");
|
||||||
|
sb.append(" tarifa_oficial.activo = 1 ");
|
||||||
|
|
||||||
|
if (rutaId != null) {
|
||||||
|
sb.append(" and tarifa_oficial.ruta_id = ").append(rutaId);
|
||||||
|
}
|
||||||
|
if (orgaoConcedenteId != null) {
|
||||||
|
sb.append(" and tarifa_oficial.orgaoconcedente_id = ").append(orgaoConcedenteId);
|
||||||
|
}
|
||||||
|
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -1,5 +1,16 @@
|
||||||
package com.rjconsultores.ventaboletos.service;
|
package com.rjconsultores.ventaboletos.service;
|
||||||
|
|
||||||
|
import com.rjconsultores.ventaboletos.exception.BusinessException;
|
||||||
|
|
||||||
public interface SeguroTarifaService {
|
public interface SeguroTarifaService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Atualiza o seguro de acordo o valor da tarifa
|
||||||
|
*
|
||||||
|
* @param rutaId - Se informado, será filtrado pela ruta
|
||||||
|
* @param orgaoId -Campo obrigatório
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public void atualizarSeguroPorTarifa(Integer rutaId, Integer orgaoId) throws BusinessException;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,4 +50,21 @@ public interface TarifaOficialService {
|
||||||
*/
|
*/
|
||||||
public void copiarParaTarifa(VigenciaTarifa vigenciaTarifa);
|
public void copiarParaTarifa(VigenciaTarifa vigenciaTarifa);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Atualiza a taxa de embarque da entidade TarifaOficial.<br/>
|
||||||
|
*
|
||||||
|
* Para o cálculo, é usado a seguinte lógica:<br/>
|
||||||
|
* - Atualiza de acordo a tabela TAXA_EMBARQUE_PARADA por kilometragem<br/>
|
||||||
|
* - Atualiza de acordo a tabela TAXA_EMBARQUE por kilometragem<br/>
|
||||||
|
* - Atualiza de acordo a tabela TAXA_EMBARQUE_PARADA por valor fixo<br/>
|
||||||
|
*
|
||||||
|
* A sequencia acima indica a ordem de atualização da taxa de embarque.<br/>
|
||||||
|
*
|
||||||
|
* A taxa de embarque mais restritiva fica por último (TAXA_EMBARQUE_PARADA por valor fixo)
|
||||||
|
*
|
||||||
|
* @param rutaId - Se informado, será atualizado apenas a taxa de embarque da ruta informada
|
||||||
|
* @param orgaoConcedenteId TODO
|
||||||
|
*/
|
||||||
|
public void atualizarTaxaEmbarque(Integer rutaId, Integer orgaoConcedenteId);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,22 +0,0 @@
|
||||||
package com.rjconsultores.ventaboletos.service;
|
|
||||||
|
|
||||||
public interface TaxaEmbarqueService {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Atualiza a taxa de embarque da entidade TarifaOficial.<br/>
|
|
||||||
*
|
|
||||||
* Para o cálculo, é usado a seguinte lógica:<br/>
|
|
||||||
* - Atualiza de acordo a tabela TAXA_EMBARQUE_PARADA por kilometragem<br/>
|
|
||||||
* - Atualiza de acordo a tabela TAXA_EMBARQUE por kilometragem<br/>
|
|
||||||
* - Atualiza de acordo a tabela TAXA_EMBARQUE_PARADA por valor fixo<br/>
|
|
||||||
*
|
|
||||||
* A sequencia acima indica a ordem de atualização da taxa de embarque.<br/>
|
|
||||||
*
|
|
||||||
* A taxa de embarque mais restritiva fica por último (TAXA_EMBARQUE_PARADA por valor fixo)
|
|
||||||
*
|
|
||||||
* @param rutaId - Se informado, será atualizado apenas a taxa de embarque da ruta informada
|
|
||||||
* @param orgaoConcedenteId TODO
|
|
||||||
*/
|
|
||||||
public void atualizarTaxaEmbarque(Integer rutaId, Integer orgaoConcedenteId);
|
|
||||||
|
|
||||||
}
|
|
|
@ -0,0 +1,26 @@
|
||||||
|
package com.rjconsultores.ventaboletos.service.impl;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import com.rjconsultores.ventaboletos.dao.SeguroTarifaDAO;
|
||||||
|
import com.rjconsultores.ventaboletos.exception.BusinessException;
|
||||||
|
import com.rjconsultores.ventaboletos.service.SeguroTarifaService;
|
||||||
|
import com.rjconsultores.ventaboletos.utilerias.UsuarioLogado;
|
||||||
|
|
||||||
|
@Service("seguroTarifaService")
|
||||||
|
public class SeguroTarifaServiceImpl implements SeguroTarifaService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SeguroTarifaDAO seguroTarifaDAO;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void atualizarSeguroPorTarifa(Integer rutaId, Integer orgaoId) throws BusinessException {
|
||||||
|
if (orgaoId == null){
|
||||||
|
throw new BusinessException("SeguroServiceImpl.msg.validacion.orgaoObligatorio");
|
||||||
|
}
|
||||||
|
|
||||||
|
seguroTarifaDAO.atualizarSeguroPorTarifa(rutaId, orgaoId, UsuarioLogado.getUsuarioLogado().getUsuarioId());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -43,4 +43,10 @@ public class TarifaOficialServiceImpl implements TarifaOficialService {
|
||||||
return qtd;
|
return qtd;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional
|
||||||
|
public void atualizarTaxaEmbarque(Integer rutaId, Integer orgaoConcedenteId) {
|
||||||
|
tarifaOficialDAO.atualizarTaxaEmbarque(rutaId, UsuarioLogado.getUsuarioLogado().getUsuarioId(), orgaoConcedenteId);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,22 +0,0 @@
|
||||||
package com.rjconsultores.ventaboletos.service.impl;
|
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
|
||||||
|
|
||||||
import com.rjconsultores.ventaboletos.dao.TaxaEmbarqueDAO;
|
|
||||||
import com.rjconsultores.ventaboletos.service.TaxaEmbarqueService;
|
|
||||||
import com.rjconsultores.ventaboletos.utilerias.UsuarioLogado;
|
|
||||||
|
|
||||||
@Service("taxaEmbarqueService")
|
|
||||||
public class TaxaEmbarqueServiceImpl implements TaxaEmbarqueService{
|
|
||||||
@Autowired
|
|
||||||
private TaxaEmbarqueDAO taxaEmbarqueDAO;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@Transactional
|
|
||||||
public void atualizarTaxaEmbarque(Integer rutaId, Integer orgaoConcedenteId) {
|
|
||||||
taxaEmbarqueDAO.atualizarTaxaEmbarque(rutaId, UsuarioLogado.getUsuarioLogado().getUsuarioId(), orgaoConcedenteId);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
Loading…
Reference in New Issue